From: John L. <jr...@us...> - 2007-02-26 01:57:26
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv32575/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxldefs.h wxlstate.h Log Message: Change WXLUACLASS to keep a pointer to the base class's WXLUACLASS not it's tag for faster lookup. cleanup of the headers, more comments Index: wxldefs.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxldefs.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** wxldefs.h 26 Dec 2006 10:37:02 -0000 1.13 --- wxldefs.h 26 Feb 2007 01:57:06 -0000 1.14 *************** *** 49,53 **** //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 4 // ---------------------------------------------------------------------------- --- 49,53 ---- //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 5 // ---------------------------------------------------------------------------- Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** wxlbind.h 23 Dec 2006 06:16:20 -0000 1.34 --- wxlbind.h 26 Feb 2007 01:57:06 -0000 1.35 *************** *** 19,23 **** #ifdef GetObject ! #undef GetObject #endif --- 19,23 ---- #ifdef GetObject ! #undef GetObject // MSVC defines this #endif *************** *** 40,44 **** // ---------------------------------------------------------------------------- ! enum LuaType // The type of a Lua method { LuaDelete = 1, // gc routine --- 40,44 ---- // ---------------------------------------------------------------------------- ! enum wxLuaMethod_Type // The type of a Lua method { LuaDelete = 1, // gc routine *************** *** 47,52 **** LuaMethod = 8, // class method LuaGlobal = 16, // global method (not really related to the class) ! LuaGetProp = 32, ! LuaSetProp = 64 }; --- 47,52 ---- LuaMethod = 8, // class method LuaGlobal = 16, // global method (not really related to the class) ! LuaGetProp = 32, // Get %property funcName, read ! LuaSetProp = 64 // Set %property funcName, write }; *************** *** 56,65 **** struct WXDLLIMPEXP_WXLUA WXLUAMETHOD // defines a LUA method or property { ! LuaType type; // type (one of the above enumeration values) ! const char *name; // name of the method or property ! lua_CFunction func; // function that implements the method or property ! int maxargs; // max number of function arguments (was 'params') ! int minargs; // min number of function arguments (was 'required') ! wxLuaArgTag* argtags; // array of lua tags representing each argument, zero terminated }; --- 56,65 ---- struct WXDLLIMPEXP_WXLUA WXLUAMETHOD // defines a LUA method or property { ! wxLuaMethod_Type type; // type (one of the above enumeration values) ! const char* name; // name of the method or property ! lua_CFunction func; // function that implements the method or property ! int maxargs; // max number of function arguments ! int minargs; // min number of function arguments ! wxLuaArgTag* argtags; // array of lua tags representing each argument, zero terminated }; *************** *** 80,88 **** WXLUAMETHOD *methods; // pointer to methods for this class int num_methods; // number of methods - int baseclass_tag; // index in the class list to the base class wxClassInfo *pClassInfo; // pointer to the wxClassInfo associated with this class ! int *class_tag; // tag for user data allocated by ourselves ! // and therefore needs gc. ! const char *baseclass; // name of base class }; --- 80,91 ---- WXLUAMETHOD *methods; // pointer to methods for this class int num_methods; // number of methods wxClassInfo *pClassInfo; // pointer to the wxClassInfo associated with this class ! int *class_tag; // lua tag for user data allocated by ourselves ! const char *baseclassName; // name of base class ! WXLUACLASS *baseclass; // Pointer to the base class or NULL for none. ! // This member is set after all the bindings are ! // registered since the base class may be from ! // a different module (a library perhaps). ! // See wxLuaBinding::SetBaseClass }; *************** *** 101,115 **** struct WXDLLIMPEXP_WXLUA WXLUAEVENT // defines a wxWidgets Event for wxLua { ! const int *eventType; // new wxWidgets event type ! const char *eventName; // name of the event ! int *eventClassTag; // lua class tag }; struct WXDLLIMPEXP_WXLUA WXLUAOBJECT // Defines a wxWidgets object or pointer for wxLua { ! const void *objPtr; // a pointer to the object or pointer ! const void **pObjPtr; // a pointer to the object or pointer ! const char *objName; // the name of the object or pointer ! int *objClassTag; // the class tag of the object or pointer. }; --- 104,118 ---- struct WXDLLIMPEXP_WXLUA WXLUAEVENT // defines a wxWidgets Event for wxLua { ! const int *eventType; // wxWidgets event type, e.g. &wxEVT_COMMAND_MENU_SELECTED ! const char *name; // name of the event, e.g. "wxEVT_COMMAND_MENU_SELECTED" ! int *class_tag; // lua class tag, e.g. &s_wxluatag_wxCommandEvent }; struct WXDLLIMPEXP_WXLUA WXLUAOBJECT // Defines a wxWidgets object or pointer for wxLua { ! const char *name; // the name of the object or pointer ! int *class_tag; // lua class tag of the object or pointer. ! const void *objPtr; // pointer to the object, e.g. &wxDefaultPosition ! const void **pObjPtr; // pointer to the object pointer, e.g. (const void **)&wxThePenList }; *************** *** 126,130 **** ~wxLuaFunction() {} ! int CallMethod(lua_State *L); void *GetObject() const { return m_pObject; } --- 129,133 ---- ~wxLuaFunction() {} ! int CallMethod(lua_State *L); // call WXLUAMETHOD->func(L) void *GetObject() const { return m_pObject; } *************** *** 231,235 **** wxObject_##objName::~wxObject_##objName() \ { \ ! if (m_p##objName != NULL) delete m_p##objName; \ } \ void LUACALL wxLua_AddTrackedObject(wxLuaState& wxlState, className *p##objName) \ --- 234,238 ---- wxObject_##objName::~wxObject_##objName() \ { \ ! delete m_p##objName; \ } \ void LUACALL wxLua_AddTrackedObject(wxLuaState& wxlState, className *p##objName) \ *************** *** 251,255 **** public: wxLuaSmartStringArray(wxString *strArr = NULL) : m_strArr(strArr) { } ! ~wxLuaSmartStringArray() { if (m_strArr != NULL) delete[] m_strArr; } void operator = (wxString *strArr) { m_strArr = strArr; } --- 254,258 ---- public: wxLuaSmartStringArray(wxString *strArr = NULL) : m_strArr(strArr) { } ! ~wxLuaSmartStringArray() { delete[] m_strArr; } void operator = (wxString *strArr) { m_strArr = strArr; } *************** *** 268,272 **** public: wxLuaSmartIntArray(int* intArr = NULL) : m_intArr(intArr) { } ! ~wxLuaSmartIntArray() { if (m_intArr != NULL) delete[] m_intArr; } void operator = (int *intArr) { m_intArr = intArr; } --- 271,275 ---- public: wxLuaSmartIntArray(int* intArr = NULL) : m_intArr(intArr) { } ! ~wxLuaSmartIntArray() { delete[] m_intArr; } void operator = (int *intArr) { m_intArr = intArr; } *************** *** 296,300 **** // Binds C Functions/Defines/Object/Events to namespace Lua Table virtual void RegisterBinding(const wxLuaState& wxlState, bool registerTypes); ! // Unbinds C Functions/Defines/Object/Events by clearing nsmespace Lua table virtual void UnRegisterBinding(lua_State* L); --- 299,303 ---- // Binds C Functions/Defines/Object/Events to namespace Lua Table virtual void RegisterBinding(const wxLuaState& wxlState, bool registerTypes); ! // Unbinds C Functions/Defines/Object/Events by clearing namespace Lua table virtual void UnRegisterBinding(lua_State* L); *************** *** 305,309 **** void SetBindingName(const wxString& name) { m_bindingName = name; } ! // Get/Set the namespace in lua that this binding will be installed to wxString GetLuaNamespace() const { return m_nameSpace; } void SetLuaNamespace(const wxString& nameSpace) { m_nameSpace = nameSpace; } --- 308,312 ---- void SetBindingName(const wxString& name) { m_bindingName = name; } ! // Get/Set the namespace table in lua that this binding will be installed to wxString GetLuaNamespace() const { return m_nameSpace; } void SetLuaNamespace(const wxString& nameSpace) { m_nameSpace = nameSpace; } *************** *** 329,335 **** bool IsTag(int tag) { return (tag >= m_startTag) && (tag <= m_lastTag); } ! // Look for the base class of the input WXLUACLASS in this binding and if ! // found, set the tag of the baseclass_tag member of the input. ! bool SetBaseClassTag(WXLUACLASS *pClass); // Look up the event type name as a string, from the wxEventType number --- 332,339 ---- bool IsTag(int tag) { return (tag >= m_startTag) && (tag <= m_lastTag); } ! // Look for the base class of the input WXLUACLASS in this binding using the ! // baseclassName of the input and if found, set the WXLUACLASS::baseclass ! // member of the input. ! bool SetBaseClass(WXLUACLASS *pClass); // Look up the event type name as a string, from the wxEventType number Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** wxlstate.h 22 Feb 2007 00:01:36 -0000 1.60 --- wxlstate.h 26 Feb 2007 01:57:06 -0000 1.61 *************** *** 342,346 **** // all non parented (top level) windows are destroyed. // You must always call CloseLuaState() when you want to close lua instead ! // of hoping that if when you call Destroy() you have the last refed instance. void Destroy(); // Close the lua_State and if 'force' close all attached wxWindows --- 342,346 ---- // all non parented (top level) windows are destroyed. // You must always call CloseLuaState() when you want to close lua instead ! // of hoping that when you call Destroy() you have the last refed instance. void Destroy(); // Close the lua_State and if 'force' close all attached wxWindows *************** *** 403,408 **** // Try to compile the lua program. Creates new lua_State to test for syntax // errors and sends error events. See LuaError() for errMsg and line_num. ! int CompileString(const wxString &script, const wxString& name = wxEmptyString, wxString* errMsg_ = NULL, int* line_num = NULL); ! int CompileBuffer(const unsigned char buf[], size_t size, const wxString &name = wxEmptyString, wxString* errMsg_ = NULL, int* line_num = NULL); // checks the status with CheckRunError and tries to get lua's error string --- 403,410 ---- // Try to compile the lua program. Creates new lua_State to test for syntax // errors and sends error events. See LuaError() for errMsg and line_num. ! int CompileString(const wxString &script, const wxString& name = wxEmptyString, ! wxString* errMsg_ = NULL, int* line_num = NULL); ! int CompileBuffer(const unsigned char buf[], size_t size, const wxString &name = wxEmptyString, ! wxString* errMsg_ = NULL, int* line_num = NULL); // checks the status with CheckRunError and tries to get lua's error string *************** *** 480,486 **** // returns NULL on failure. bool IsDerivedClass(int iClassTag, int iBaseClassTag) const; ! // Get WXLUAEVENT for given wxEvent by comparing the wxEvent::GetEventType() ! // to WXLUAEVENT::eventType. ! const WXLUAEVENT* GetLuaEvent(wxEvent *pEvent) const; // Get the binding list used to initialize this class --- 482,488 ---- // returns NULL on failure. bool IsDerivedClass(int iClassTag, int iBaseClassTag) const; ! // Get WXLUAEVENT for given wxEventType (wxEvent::GetEventType()) by finding ! // the matching WXLUAEVENT::eventType. ! const WXLUAEVENT* GetLuaEvent(wxEventType eventType) const; // Get the binding list used to initialize this class *************** *** 659,670 **** // else return NULL; // Set isProperty to true if a property is found else it is a method. ! WXLUAMETHOD* GetLuaMethod(const WXLUACLASS *pClass, const char *cpIndex, bool &isProperty); ! // Lookup a lua property called cpIndex in the WXLUACLASS array pClass // Ensure that the lookup is of the required type. If the lua property // can not be found on the current class recurse through base classes // Return a pointer to the WXLUAMETHOD that corresponds to the property name, // else return NULL; ! // Find 'Set' properties if isSet is true else 'Get' properties ! WXLUAMETHOD* GetLuaProperty(const WXLUACLASS *pClass, const char *cpIndex, bool isSet); // Is there a derived method given an object and and a method name. --- 661,672 ---- // else return NULL; // Set isProperty to true if a property is found else it is a method. ! WXLUAMETHOD* GetLuaMethod(const WXLUACLASS *pClass, const char *cpIndex); ! // Lookup a lua property function named cpIndex in the WXLUACLASS pClass // Ensure that the lookup is of the required type. If the lua property // can not be found on the current class recurse through base classes // Return a pointer to the WXLUAMETHOD that corresponds to the property name, // else return NULL; ! // Find 'Set' properties if isLuaSetProp else return 'LuaGetProp' property ! WXLUAMETHOD* GetLuaProperty(const WXLUACLASS *pClass, const char *cpIndex, bool isLuaSetProp); // Is there a derived method given an object and and a method name. *************** *** 944,948 **** lua_State *GetLuaState() const { return m_wxlState.GetLuaState(); } ! // non null only for EVT_LUA_DEBUG_HOOK lua_Debug *GetLuaDebug() const { return m_lua_Debug; } --- 946,950 ---- lua_State *GetLuaState() const { return m_wxlState.GetLuaState(); } ! // non null only for wxEVT_LUA_DEBUG_HOOK lua_Debug *GetLuaDebug() const { return m_lua_Debug; } *************** *** 959,968 **** BEGIN_DECLARE_EVENT_TYPES() ! DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WXLUA, wxEVT_LUA_CREATION, 0) // a wxLuaState is being created ! DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WXLUA, wxEVT_LUA_PRINT, 0) // print statements and such, check GetString() ! DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WXLUA, wxEVT_LUA_ERROR, 0) // error occurred, check GetString() ! DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WXLUA, wxEVT_LUA_DEBUG_HOOK, 0) // see LuaDebugHook function ! DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WXLUA, wxEVT_LUA_INIT, 0) // after app starts, first idle ! DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WXLUA, wxEVT_LUA_DEBUGGERATTACHED, 0) // after app starts, first idle END_DECLARE_EVENT_TYPES() --- 961,976 ---- BEGIN_DECLARE_EVENT_TYPES() ! // A wxLuaState is being created, sent at the end of ! // wxLuaState(wxEvtHandler, win id) or Create(wxEvtHandler, win id) ! DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WXLUA, wxEVT_LUA_CREATION, 0) ! // lua's print(...) statements and such, check GetString() ! DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WXLUA, wxEVT_LUA_PRINT, 0) ! // an error in lua has occurred, check GetString() for message ! DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WXLUA, wxEVT_LUA_ERROR, 0) ! // see LuaDebugHook function ! DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WXLUA, wxEVT_LUA_DEBUG_HOOK, 0) ! // after app starts, first idle ! //DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WXLUA, wxEVT_LUA_INIT, 0) ! //DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WXLUA, wxEVT_LUA_DEBUGGERATTACHED, 0) END_DECLARE_EVENT_TYPES() *************** *** 973,978 **** #define EVT_LUA_ERROR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_LUA_ERROR, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) (wxLuaEventFunction) & fn, (wxObject *) NULL ), #define EVT_LUA_DEBUG_HOOK(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_LUA_DEBUG_HOOK, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) (wxLuaEventFunction) & fn, (wxObject *) NULL ), ! #define EVT_LUA_INIT(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_LUA_INIT, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) (wxLuaEventFunction) & fn, (wxObject *) NULL ), ! #define EVT_LUA_DEBUGGERATTACHED(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_LUA_DEBUGGERATTACHED, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) (wxLuaEventFunction) & fn, (wxObject *) NULL ), #define wxEVT_LUA_CONSOLE wxEVT_LUA_PRINT --- 981,986 ---- #define EVT_LUA_ERROR(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_LUA_ERROR, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) (wxLuaEventFunction) & fn, (wxObject *) NULL ), #define EVT_LUA_DEBUG_HOOK(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_LUA_DEBUG_HOOK, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) (wxLuaEventFunction) & fn, (wxObject *) NULL ), ! //#define EVT_LUA_INIT(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_LUA_INIT, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) (wxLuaEventFunction) & fn, (wxObject *) NULL ), ! //#define EVT_LUA_DEBUGGERATTACHED(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_LUA_DEBUGGERATTACHED, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) (wxLuaEventFunction) & fn, (wxObject *) NULL ), #define wxEVT_LUA_CONSOLE wxEVT_LUA_PRINT |