From: John L. <jr...@us...> - 2007-12-22 06:07:21
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16833/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlcallb.h wxldefs.h wxlstate.h wxlua_bind.h Log Message: * Updated the naming conventions of the wxLua C/C++ functions to get rid of the term "tag" which dates back to Lua 4. Lua 5 does not use "tags", but rather metatables to attach functions to userdata in Lua. The new term for the C++ objects that wxLua wraps in Lua userdata and assigns a metatable to are wxLua types. wxLua types < 0, the WXLUA_TXXX types, correspond to the LUA_TXXX Lua types. wxLua types > 0 are types from the bindings and denote a class or struct. - Most notably for people who have written their own overrides for their bindings will be that wxLuaState::PushUserTag() is now wxluaT_PushUserDataType(). Those two functions existed before, but basically did the same thing. The calling arguments of PushUserTag() were taken however and were the reverse of what PushUserDataType() had. - wxluaT_new/get/set/tag() are now wxluaT_new/setmetatable() and wxluaT_type() where the latter works just like lua_type(), but returns one of the wxLua types. - Fix crash in wxListCtrl and wxTreeCtrl::AssignImageList() to use the %ungc tag to release wxLua from deleting the input wxImageList. Index: wxlcallb.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlcallb.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** wxlcallb.h 15 Dec 2007 16:56:41 -0000 1.25 --- wxlcallb.h 22 Dec 2007 06:07:15 -0000 1.26 *************** *** 68,72 **** protected: int m_routine; // ref to the Lua routine to call in the wxlua_lreg_refs_key registry table ! wxLuaState m_wxlState; // store it since we're added to a list of it's callbacks. wxEvtHandler* m_evtHandler; wxWindowID m_id; --- 68,72 ---- protected: int m_routine; // ref to the Lua routine to call in the wxlua_lreg_refs_key registry table ! wxLuaState m_wxlState; // store it since we're added to a list of its callbacks. wxEvtHandler* m_evtHandler; wxWindowID m_id; *************** *** 116,120 **** protected: ! wxLuaState m_wxlState; // store it since we're added to a list of it's callbacks. wxWindow* m_window; --- 116,120 ---- protected: ! wxLuaState m_wxlState; // store it since we're added to a list of its callbacks. wxWindow* m_window; Index: wxldefs.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxldefs.h,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** wxldefs.h 20 Dec 2007 02:26:57 -0000 1.39 --- wxldefs.h 22 Dec 2007 06:07:15 -0000 1.40 *************** *** 67,71 **** //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 20 // ---------------------------------------------------------------------------- --- 67,71 ---- //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 21 // ---------------------------------------------------------------------------- *************** *** 112,117 **** // ---------------------------------------------------------------------------- - #define WXLUA_NOTAG 0 // an invalid tag, all tags are initialized to 0 - // initializes a lua_debug by nulling everything before use since the // functions that take it do not initialize it properly --- 112,115 ---- Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** wxlbind.h 20 Dec 2007 02:26:57 -0000 1.74 --- wxlbind.h 22 Dec 2007 06:07:15 -0000 1.75 *************** *** 20,53 **** // ---------------------------------------------------------------------------- ! // C functions for the metatable for wxLua userdata installed by the wxLuaBinding ! // ---------------------------------------------------------------------------- ! ! // Generic delete function for userdata binding objects ! WXDLLIMPEXP_WXLUA int LUACALL wxlua_userdata_delete(lua_State *L); ! ! // memory deallocation function for created wxLuaBindClass defined objects, Lua's __gc metatable index ! WXDLLIMPEXP_WXLUA int LUACALL wxlua_wxLuaBindClass__gc(lua_State *L); ! // Lua 'set table' function for created wxLuaBindClass defined objects, Lua's __newindex metatable index ! WXDLLIMPEXP_WXLUA int LUACALL wxlua_wxLuaBindClass__newindex(lua_State *L); ! // Lua 'get table' function for created wxLuaBindClass defined objects, Lua's __index metatable index ! WXDLLIMPEXP_WXLUA int LUACALL wxlua_wxLuaBindClass__index(lua_State *L); ! // Lua 'tostring' function for created wxLuaBindClass defined objects, Lua's __tostring metatable index ! WXDLLIMPEXP_WXLUA int LUACALL wxlua_wxLuaBindClass__tostring(lua_State *L); ! ! // ---------------------------------------------------------------------------- ! // wxLua binding enums and structs // ---------------------------------------------------------------------------- ! // Binding tags are generated as positive tag id automatically when bound ! // so we set the inbuilt Lua arg tags to negative values // ! // note that -1 is use as initialiser for class tags ! // and 0 is used as an end marker for the wxLuaArgTag array that ! // represents function prototype argument types. ! ! // Note: WXLUA_TXXX = -1*LUA_TXXX - 2 ! ! // wxlua arg tags for common Lua types #define WXLUA_TUNKNOWN 0 // unset and invalid, not a LUA_TXXX #define WXLUA_TNONE -1 // LUA_TNONE -1 --- 20,37 ---- // ---------------------------------------------------------------------------- ! // wxLua binding defines, enums, and structs // ---------------------------------------------------------------------------- ! // Binding wxLua types are positive integers generated automatically when initialized ! // so the inbuilt wxLua types (WXLUA_TXXX) corresponding to Lua types ! // (LUA_TXXX) are negative values. ! // *Use the function bool wxlua_iswxuserdatatype(wxl_type) if you want to ! // differentiate between the two. // ! // Note that WXLUA_TUNKNOWN is use as initialiser for class types ! // and is used as an end marker for the wxLuaArgType array that ! // represents function prototype argument types in the wxLuaBindCFunc struct. + // wxLua types for Lua types #define WXLUA_TUNKNOWN 0 // unset and invalid, not a LUA_TXXX #define WXLUA_TNONE -1 // LUA_TNONE -1 *************** *** 67,97 **** #define WXLUA_T_MIN -12 // Min of the WXLUA_TXXX values ! // Blindly convert the lua_type to the wxlua_type, see wxlua_getwxluatype() for better function #define LUAT_TO_WXLUAT(luatype) (-1*(luatype) - 2) ! // Variables used in the wxLuaArgTag member of the wxLuaBindCFunc for ! // common types. The binding generator will use these and generate others ! // as specified in the bindings. ! extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_None; ! extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_Nil; ! extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_Boolean; ! extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_LightUserData; ! extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_Number; ! extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_String; ! extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_Table; ! extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_Function; ! extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_UserData; ! extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_Thread; ! extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_Integer; ! extern WXDLLIMPEXP_DATA_WXLUA(int) s_wxluaarg_CFunction; ! // copies of wxlua arg tags for binding types that are used very often ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_NULL; // The Lua tag for NULL pointer ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxEvent; // The Lua tag for wxEvents ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxWindow; // The Lua tag for wxWindows ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxString; // The Lua tag for wxStrings ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxArrayString; // The Lua tag for wxArrayString ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxSortedArrayString; // The Lua tag for wxSortedArrayString ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxArrayInt; // The Lua tag for wxArrayInt // ---------------------------------------------------------------------------- --- 51,82 ---- #define WXLUA_T_MIN -12 // Min of the WXLUA_TXXX values ! // Blindly convert the lua_type to the wxlua_type. Note: WXLUA_TXXX = -1*LUA_TXXX - 2 ! // *** See wxlua_luatowxluatype() for better function *** #define LUAT_TO_WXLUAT(luatype) (-1*(luatype) - 2) ! // Variables used in the wxLuaArgType member of the wxLuaBindCFunc for ! // Lua types. The binding generator will use these and generate new ones for ! // classes and structs as specified in the bindings. ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TNONE; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TNIL; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TBOOLEAN; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TLIGHTUSERDATA; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TNUMBER; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TSTRING; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TTABLE; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TFUNCTION; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TUSERDATA; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TTHREAD; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TINTEGER; ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatype_TCFUNCTION; ! // copies of wxLua types for binding types that are used very often ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_NULL; // wxLua type for NULL pointer ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxEvent; // wxLua type for wxEvents ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxWindow; // wxLua type for wxWindows ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxString; // wxLua type for wxStrings ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxArrayString; // wxLua type for wxArrayString ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxSortedArrayString; // wxLua type for wxSortedArrayString ! extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxArrayInt; // wxLua type for wxArrayInt // ---------------------------------------------------------------------------- *************** *** 99,106 **** // ---------------------------------------------------------------------------- ! typedef int* wxLuaArgTag; // address of class tag (a pointer to it) ! extern WXDLLIMPEXP_DATA_WXLUA(wxLuaArgTag) s_wxluaargArray_None[1]; // = {0} ! enum wxLuaMethod_Type // The type of a Lua method { WXLUAMETHOD_CONSTRUCTOR = 0x0001, // constructor --- 84,92 ---- // ---------------------------------------------------------------------------- ! typedef int* wxLuaArgType; // address of wxLua class type (a pointer to it) ! extern WXDLLIMPEXP_DATA_WXLUA(wxLuaArgType) g_wxluaargtypeArray_None[1]; // = {0} ! // Values for the wxLuaBindMethod::type and wxLuaBindCFunc::type ! enum wxLuaMethod_Type { WXLUAMETHOD_CONSTRUCTOR = 0x0001, // constructor *************** *** 116,136 **** // original class. ! WXLUAMETHOD_OVERLOAD_BASE = 0x10000, // Class method has been checked to see if it is ! // overloaded from the base class by the function ! // wxLuaState::RegisterBindings() ! // Check wxLuaBindMethod::basemethod and if !NULL ! // this method is an overload from the base class }; struct WXDLLIMPEXP_WXLUA wxLuaBindCFunc { ! lua_CFunction func; // C function that implements the method or property ! int type; // wxLuaMethod_Type flags for this function ! int minargs; // min number of required args ! int maxargs; // total number of args allowed ! wxLuaArgTag* argtags; // array of Lua tags representing each argument, zero terminated ! // NOTE: there may be less argtags than minargs if this is an ! // overloaded function since the argtags == s_wxluaargArray_None ! // but the minargs are the min of minargs of all the overloaded functions }; --- 102,122 ---- // original class. ! WXLUAMETHOD_CHECKED_OVERLOAD = 0x10000, // Class method has been checked to see if it is ! // overloaded function from the base class by ! // wxLuaBinding::InitAllBindings(). ! // wxLuaBindMethod::basemethod is !NULL ! // if an overloaded function was found. ! ! WXLUAMETHOD_SEARCH_MASK = 0xFFFF, // Helper for wxLuaBinding::GetClassMethod(), ignore WXLUAMETHOD_CHECKED_OVERLOAD ! WXLUAMETHOD_SORT_MASK = 0xFFFF, // Helper for wxLuaBinding::InitAllBindings(), ignore WXLUAMETHOD_CHECKED_OVERLOAD }; struct WXDLLIMPEXP_WXLUA wxLuaBindCFunc { ! lua_CFunction lua_cfunc; // C function that implements the method or property ! int method_type; // enum wxLuaMethod_Type flags for this function ! int minargs; // Min number of required args ! int maxargs; // Total number of args allowed ! wxLuaArgType* argtypes; // Array of wxLua types representing each argument, zero terminated. }; *************** *** 141,184 **** struct WXDLLIMPEXP_WXLUA wxLuaBindMethod { ! const char *name; // name of the method or property ! int type; // wxLuaMethod_Type flags for this method ! // note each func has own type, this is ored values of them ! wxLuaBindCFunc *funcs; // array of C functions for this method ! int funcs_n; // number of C functions (overloaded > 1) for this method ! wxLuaBindMethod *basemethod; // overloaded methods from base class, else NULL ! // see comments for WXLUAMETHOD_OVERLOAD_BASE }; // ---------------------------------------------------------------------------- ! // wxLuaBindDefine - Defines a numeric define for wxLua // ---------------------------------------------------------------------------- ! struct WXDLLIMPEXP_WXLUA wxLuaBindDefine { ! const char *name; // name double value; // numeric value }; ! extern WXDLLIMPEXP_DATA_WXLUA(wxLuaBindDefine) s_wxluadefineArray_None[1]; // = {{0,0}} // ---------------------------------------------------------------------------- ! // wxLuaBindString - Defines a wxWidgets wxString for wxLua // ---------------------------------------------------------------------------- struct WXDLLIMPEXP_WXLUA wxLuaBindString { ! const char *name; // name ! const wxChar *value; // string value }; // ---------------------------------------------------------------------------- ! // wxLuaBindEvent - Defines a wxWidgets wxEvent for wxLua // ---------------------------------------------------------------------------- struct WXDLLIMPEXP_WXLUA wxLuaBindEvent { ! const char *name; // name of the event, e.g. "wxEVT_COMMAND_MENU_SELECTED" ! const wxEventType *eventType; // wxWidgets event type, e.g. &wxEVT_COMMAND_MENU_SELECTED ! int *class_tag; // Lua class tag, e.g. &s_wxluatag_wxCommandEvent }; --- 127,171 ---- struct WXDLLIMPEXP_WXLUA wxLuaBindMethod { ! const char* name; // Name of the method or property ! int method_type; // enum wxLuaMethod_Type flags for this method. ! // Note that each func has own type, this is ored values of them. ! wxLuaBindCFunc* wxluacfuncs; // Array of C functions for this method ! int wxluacfuncs_n; // Number of C functions (overloaded > 1) for this method ! wxLuaBindMethod* basemethod; // Overloaded method from the base class, else NULL. ! // See comments for WXLUAMETHOD_CHECKED_OVERLOAD }; // ---------------------------------------------------------------------------- ! // wxLuaBindNumber - Defines a numeric value for wxLua // ---------------------------------------------------------------------------- ! struct WXDLLIMPEXP_WXLUA wxLuaBindNumber { ! const char* name; // name double value; // numeric value }; ! extern WXDLLIMPEXP_DATA_WXLUA(wxLuaBindNumber) g_wxluanumberArray_None[1]; // = {{0,0}} // ---------------------------------------------------------------------------- ! // wxLuaBindString - Defines a wxWidgets wxChar* string for wxLua // ---------------------------------------------------------------------------- struct WXDLLIMPEXP_WXLUA wxLuaBindString { ! const char* name; // name ! const wxChar* value; // string value }; // ---------------------------------------------------------------------------- ! // wxLuaBindEvent - Defines a wxWidgets wxEventType for wxLua // ---------------------------------------------------------------------------- struct WXDLLIMPEXP_WXLUA wxLuaBindEvent { ! const char* name; // Name of the wxEventType, e.g. "wxEVT_COMMAND_MENU_SELECTED" ! const wxEventType* eventType; // wxWidgets event type, e.g. &wxEVT_COMMAND_MENU_SELECTED ! int* wxluatype; // wxLua class type that wxWidgets uses for this wxEventType, ! // e.g. &g_wxluatype_wxCommandEvent }; *************** *** 189,196 **** struct WXDLLIMPEXP_WXLUA wxLuaBindObject { ! 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 }; --- 176,183 ---- struct WXDLLIMPEXP_WXLUA wxLuaBindObject { ! const char* name; // Name of the object or pointer ! int* wxluatype; // wxLua class type 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 }; *************** *** 201,234 **** struct WXDLLIMPEXP_WXLUA wxLuaBindClass { ! const char *name; // name of the class ! wxLuaBindMethod *methods; // pointer to methods for this class ! int methods_n; // number of methods ! wxClassInfo *classInfo; // 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 ! wxLuaBindClass *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 ! wxLuaBindDefine* enums; // Class member enums (if any) int enums_n; // number of enums }; // ---------------------------------------------------------------------------- // Central function to call for overloaded functions // ---------------------------------------------------------------------------- ! // Redirect Lua function call to 1 method from a list of overloaded functions ! // if the 1st upvalue is a wxLuaBindMethod. int LUACALL wxlua_callOverloadedFunction(lua_State* L); ! // Redirect Lua function call to 1 method from a list of overloaded functions declared ! // in the wxLuaBindMethod. WXDLLIMPEXP_WXLUA int LUACALL wxlua_callOverloadedFunction(lua_State* L, struct wxLuaBindMethod* wxlMethod); // Get a human readable string of the Lua args (items on the stack) for a function call WXDLLIMPEXP_WXLUA wxString wxlua_getLuaArgsMsg(lua_State* L, int start_stack_idx, int end_stack_idx); ! // Get a human readable wxArrayString of the wxLua args for the functions in the method ! WXDLLIMPEXP_WXLUA wxArrayString wxlua_getBindMethodArgsMsg(lua_State* L, struct wxLuaBindMethod* method); // ---------------------------------------------------------------------------- --- 188,237 ---- struct WXDLLIMPEXP_WXLUA wxLuaBindClass { ! const char* name; // Name of the class ! wxLuaBindMethod* wxluamethods; // Pointer to methods for this class ! int wxluamethods_n; // Number of methods ! wxClassInfo* classInfo; // Pointer to the wxClassInfo associated with this class or NULL. ! int* wxluatype; // wxLua class type for userdata ! const char* baseclassName; // Name of base class, or NULL if none. ! wxLuaBindClass* 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() ! wxLuaBindNumber* enums; // Class member enums or NULL if none int enums_n; // number of enums }; // ---------------------------------------------------------------------------- + // C functions for the metatable for wxLua userdata installed by the wxLuaBinding + // ---------------------------------------------------------------------------- + + // Generic delete function for userdata binding objects + WXDLLIMPEXP_WXLUA int LUACALL wxlua_userdata_delete(lua_State *L); + + // memory deallocation function for created wxLuaBindClass defined objects, Lua's __gc metatable index + WXDLLIMPEXP_WXLUA int LUACALL wxlua_wxLuaBindClass__gc(lua_State *L); + // Lua 'set table' function for created wxLuaBindClass defined objects, Lua's __newindex metatable index + WXDLLIMPEXP_WXLUA int LUACALL wxlua_wxLuaBindClass__newindex(lua_State *L); + // Lua 'get table' function for created wxLuaBindClass defined objects, Lua's __index metatable index + WXDLLIMPEXP_WXLUA int LUACALL wxlua_wxLuaBindClass__index(lua_State *L); + // Lua 'tostring' function for created wxLuaBindClass defined objects, Lua's __tostring metatable index + WXDLLIMPEXP_WXLUA int LUACALL wxlua_wxLuaBindClass__tostring(lua_State *L); + + // ---------------------------------------------------------------------------- // Central function to call for overloaded functions // ---------------------------------------------------------------------------- ! // Redirect a Lua function call to 1 wxLuaBindCFunc from a list of overloaded functions. ! // The 1st upvalue must be a wxLuaBindMethod. int LUACALL wxlua_callOverloadedFunction(lua_State* L); ! // Redirect a Lua function call to 1 wxLuaBindCFunc from a list of overloaded functions ! // declared in the wxLuaBindMethod. WXDLLIMPEXP_WXLUA int LUACALL wxlua_callOverloadedFunction(lua_State* L, struct wxLuaBindMethod* wxlMethod); // Get a human readable string of the Lua args (items on the stack) for a function call WXDLLIMPEXP_WXLUA wxString wxlua_getLuaArgsMsg(lua_State* L, int start_stack_idx, int end_stack_idx); ! // Get a human readable wxString of the wxLuaArgType arrays for the functions in the method ! WXDLLIMPEXP_WXLUA wxString wxlua_getBindMethodArgsMsg(lua_State* L, struct wxLuaBindMethod* wxlMethod); // ---------------------------------------------------------------------------- *************** *** 263,267 **** bool GetObject(); // Remove any existing reference and allocate another. ! // You cannot call this after calling GetXXXPtr() however only if this wraps a // stack item. void SetObject(int stack_idx = 1); --- 266,270 ---- bool GetObject(); // Remove any existing reference and allocate another. ! // You cannot call this after calling GetXXXPtr(), but only if this wraps a // stack item. void SetObject(int stack_idx = 1); *************** *** 285,289 **** private: ! wxLuaState* m_wxlState; // a pointer due to include recursion. int m_reference; // reference in wxlua_lreg_refs_key registry table --- 288,292 ---- private: ! wxLuaState* m_wxlState; // a pointer due to #include recursion. int m_reference; // reference in wxlua_lreg_refs_key registry table *************** *** 481,486 **** wxLuaBindClass* GetClassArray() { return m_classArray; } ! size_t GetDefineCount() const { return m_defineCount; } ! wxLuaBindDefine* GetDefineArray() { return m_defineArray; } size_t GetStringCount() const { return m_stringCount; } --- 484,489 ---- wxLuaBindClass* GetClassArray() { return m_classArray; } ! size_t GetNumberCount() const { return m_numberCount; } ! wxLuaBindNumber* GetNumberArray() { return m_numberArray; } size_t GetStringCount() const { return m_stringCount; } *************** *** 496,507 **** wxLuaBindMethod* GetFunctionArray() { return m_functionArray; } ! // Is this tag defined as something in this binding? ! bool HasTag(int tag) const { return (tag >= m_start_tag) && (tag <= m_last_tag); } ! ! // Look for the base class of the input wxLuaBindClass in this binding using the ! // baseclassName of the input and if found, set the wxLuaBindClass::baseclass ! // member of the input. ! // This is called by the wxLuaState during creation and should not be called afterwards. ! bool SetBaseClass(wxLuaBindClass *pClass); // ----------------------------------------------------------------------- --- 499,504 ---- wxLuaBindMethod* GetFunctionArray() { return m_functionArray; } ! // Is this wxLua type defined in this binding? ! bool HaswxLuaType(int wxl_type) const { return (wxl_type >= m_first_wxluatype) && (wxl_type <= m_last_wxluatype); } // ----------------------------------------------------------------------- *************** *** 510,522 **** // Find the wxLuaBindEvent with the wxEventType, returns NULL if not found. const wxLuaBindEvent* GetBindEvent(wxEventType eventType) const; ! // Look up the event type name as a string, from the wxEventType number // in the wxLuaBindEvent* struct list of this binding. wxString GetEventTypeName(wxEventType eventType) const; ! // Get the wxLuaBindClass that has this tag, or NULL if none ! const wxLuaBindClass* GetBindClass(int class_tag) const; // Get the first wxLuaBindClass that has this wxLuaBindMethod const wxLuaBindClass* GetBindClass(const wxLuaBindMethod* wxlMethod) const; // Get the first wxLuaBindClass that has this wxLuaBindCFunc ! const wxLuaBindClass* GetBindClass(const wxLuaBindCFunc* wxlMethod_cfunc) const; // ----------------------------------------------------------------------- --- 507,521 ---- // Find the wxLuaBindEvent with the wxEventType, returns NULL if not found. const wxLuaBindEvent* GetBindEvent(wxEventType eventType) const; ! // Look up the wxEventType name as a string, from the wxEventType number // in the wxLuaBindEvent* struct list of this binding. wxString GetEventTypeName(wxEventType eventType) const; ! // Get the wxLuaBindClass that has this wxLua type, or NULL if none ! const wxLuaBindClass* GetBindClass(int wxl_type) const; ! // Get the wxLuaBindClass that has this name, or NULL if none ! const wxLuaBindClass* GetBindClass(const char* className) const; // Get the first wxLuaBindClass that has this wxLuaBindMethod const wxLuaBindClass* GetBindClass(const wxLuaBindMethod* wxlMethod) const; // Get the first wxLuaBindClass that has this wxLuaBindCFunc ! const wxLuaBindClass* GetBindClass(const wxLuaBindCFunc* wxlCFunc) const; // ----------------------------------------------------------------------- *************** *** 528,566 **** static wxLuaBinding* GetLuaBinding(const wxString& bindingName, const wxLuaBindingList* bindingList); ! // Get wxLuaBindClass for given Lua Tag using wxLuaBindClass::class_tag, // returns NULL on failure. ! static const wxLuaBindClass* GetBindClass(int class_tag, const wxLuaBindingList* bindingList); // Get the first wxLuaBindClass that has this particular wxLuaBindMethod // returns NULL on failure. ! static const wxLuaBindClass* GetBindClass(const wxLuaBindMethod* method, const wxLuaBindingList* bindingList); ! // Get the first wxLuaBindClass that has this particular wxLuaBindCFunc in it's methods // returns NULL on failure. ! static const wxLuaBindClass* GetBindClass(const wxLuaBindCFunc* method_cfunc, const wxLuaBindingList* bindingList); // Get wxLuaBindEvent for given wxEventType (wxEvent::GetEventType()) by finding // the matching wxLuaBindEvent::eventType. // returns NULL on failure. ! static const wxLuaBindEvent* GetBindEvent(wxEventType eventType_, const wxLuaBindingList* bindingList); ! // Get the wxLuaBinding that has this wxLuaBindMethod in it's wxLuaBinding::GetFunctionArray(). // returns NULL on failure. ! static wxLuaBinding* GetFunctionBinding(const wxLuaBindMethod* method, const wxLuaBindingList* bindingList); // ----------------------------------------------------------------------- // These functions search through the input struct ! // Lookup a Lua method or get property called methodName in the wxLuaBindClass array wxlClass. ! // Ensure that the lookup is of WXLUAMETHOD_METHOD|WXLUAMETHOD_GETPROP type. ! // If the Lua method cannot be found on the current class recurse through base classes ! // Return a pointer to the wxLuaBindMethod that corresponds to the method name, ! // else return NULL; ! static wxLuaBindMethod* GetClassMethod(const wxLuaBindClass *wxlClass, const char *methodName, bool search_baseclasses = true); ! // Lookup a Lua property function named propName in the wxLuaBindClass wxlClass ! // Ensure that the lookup is of WXLUAMETHOD_GETPROP|WXLUAMETHOD_SETPROP type. ! // If the Lua property cannot be found on the current class recurse through base classes ! // Return a pointer to the wxLuaBindMethod that corresponds to the property name, ! // else return NULL; ! // Find 'Set' properties if isLuaSetProp else return 'WXLUAMETHOD_GETPROP' property ! static wxLuaBindMethod* GetClassProperty(const wxLuaBindClass *wxlClass, const char *propName, bool isLuaSetProp); // ----------------------------------------------------------------------- --- 527,559 ---- static wxLuaBinding* GetLuaBinding(const wxString& bindingName, const wxLuaBindingList* bindingList); ! // Get wxLuaBindClass for given wxLua type using wxLuaBindClass::wxluatype, // returns NULL on failure. ! static const wxLuaBindClass* GetBindClass(int wxl_type, const wxLuaBindingList* bindingList); // Get the first wxLuaBindClass that has this particular wxLuaBindMethod // returns NULL on failure. ! static const wxLuaBindClass* GetBindClass(const wxLuaBindMethod* wxlMethod, const wxLuaBindingList* bindingList); ! // Get the first wxLuaBindClass that has this particular wxLuaBindCFunc in its methods // returns NULL on failure. ! static const wxLuaBindClass* GetBindClass(const wxLuaBindCFunc* wxlCFunc, const wxLuaBindingList* bindingList); // Get wxLuaBindEvent for given wxEventType (wxEvent::GetEventType()) by finding // the matching wxLuaBindEvent::eventType. // returns NULL on failure. ! static const wxLuaBindEvent* GetBindEvent(wxEventType eventType, const wxLuaBindingList* bindingList); ! // Get the wxLuaBinding that has this wxLuaBindMethod in its wxLuaBinding::GetFunctionArray(). // returns NULL on failure. ! static wxLuaBinding* GetFunctionBinding(const wxLuaBindMethod* wxlMethod, const wxLuaBindingList* bindingList); // ----------------------------------------------------------------------- // These functions search through the input struct ! // Lookup a wxLuaBindMethod function or property called methodName in the wxLuaBindClass ! // that is also of the wxLuaMethod_Type method_type. The method_type may be ! // ored values and the first match found is returned or NULL if not found. ! // If the wxLuaBindMethod cannot be found on the current class recurse through base classes ! // if search_baseclasses. ! static wxLuaBindMethod* GetClassMethod(const wxLuaBindClass *wxlClass, const char *methodName, ! int method_type, bool search_baseclasses); // ----------------------------------------------------------------------- *************** *** 569,573 **** // function wxLuaBinding_[binding name]_init(). // You can adjust the list *only* if you do not have any wxLuaStates ! // created, otherwise the tags will be out of sync. static wxLuaBindingList* GetBindingList() { return &sm_bindingList; } --- 562,566 ---- // function wxLuaBinding_[binding name]_init(). // You can adjust the list *only* if you do not have any wxLuaStates ! // created, otherwise the wxLua types will be out of sync. static wxLuaBindingList* GetBindingList() { return &sm_bindingList; } *************** *** 576,582 **** // Initialize all of the bindings by iterating the GetBindingList() and // setting the base classes and base class functions. This function ! // is automatically run by the wxLuaState and should not ever need to be called. static void InitAllBindings(bool force_update = false); protected: void InitBinding(); // must called after subclassed version is created --- 569,581 ---- // Initialize all of the bindings by iterating the GetBindingList() and // setting the base classes and base class functions. This function ! // is automatically run by the wxLuaState and should not need to be called. static void InitAllBindings(bool force_update = false); + // Look for the base class of the input wxLuaBindClass in this binding using the + // baseclassName of the input and if found, set the wxLuaBindClass::baseclass + // member of the input. + // This is called by InitAllBindings() by the wxLuaState and should not be called afterwards. + bool SetBaseClass(wxLuaBindClass* wxlClass); + protected: void InitBinding(); // must called after subclassed version is created *************** *** 584,601 **** // Register the classes, defines, strings, events, objects, and functions generated by the binding ! virtual void DoRegisterBinding(const wxLuaState& wxlState, int tableOffset); // Before registering anything from this binding this function is called // at the beginning of RegisterBinding(...) ! virtual void PreRegister(const wxLuaState& WXUNUSED(wxlState), int WXUNUSED(luaTable)) {} // After registering everything from this binding this function is called // at the end of RegisterBinding(...) ! virtual void PostRegister(const wxLuaState& WXUNUSED(wxlState), int WXUNUSED(luaTable)) {} // binding objects size_t m_classCount; wxLuaBindClass* m_classArray; ! size_t m_defineCount; ! wxLuaBindDefine* m_defineArray; size_t m_stringCount; wxLuaBindString* m_stringArray; --- 583,600 ---- // Register the classes, defines, strings, events, objects, and functions generated by the binding ! virtual void DoRegisterBinding(const wxLuaState& wxlState, int bind_table_idx); // Before registering anything from this binding this function is called // at the beginning of RegisterBinding(...) ! virtual void PreRegister(const wxLuaState& WXUNUSED(wxlState), int WXUNUSED(bind_table_idx)) {} // After registering everything from this binding this function is called // at the end of RegisterBinding(...) ! virtual void PostRegister(const wxLuaState& WXUNUSED(wxlState), int WXUNUSED(bind_table_idx)) {} // binding objects size_t m_classCount; wxLuaBindClass* m_classArray; ! size_t m_numberCount; ! wxLuaBindNumber* m_numberArray; size_t m_stringCount; wxLuaBindString* m_stringArray; *************** *** 610,615 **** wxString m_nameSpace; // Lua table namespace e.g. "wx" bool m_bindings_registered; // Is the binding registered ! int m_start_tag; // The first wxLua allocated Lua tag ! int m_last_tag; // The last wxLua Lua tag of registered classes int m_luaTable_ref; // The Lua ref for the wxLua private tables --- 609,614 ---- wxString m_nameSpace; // Lua table namespace e.g. "wx" bool m_bindings_registered; // Is the binding registered ! int m_first_wxluatype; // The first wxLua type allocated for a class ! int m_last_wxluatype; // The last wxLua type of registered classes int m_luaTable_ref; // The Lua ref for the wxLua private tables Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.111 retrieving revision 1.112 diff -C2 -d -r1.111 -r1.112 *** wxlstate.h 20 Dec 2007 02:26:57 -0000 1.111 --- wxlstate.h 22 Dec 2007 06:07:15 -0000 1.112 *************** *** 77,90 **** // ---------------------------------------------------------------------------- ! // Light user data used as keys in the Lua LUA_REGISTRYINDEX table for wxLua items. ! // Note that even though these have values, they're not used, just the memory address. // The key in the LUA_REGISTRYINDEX table that is a table indexed ! // on the "tags" and each item is a metatable for a C++ class. ! // LUA_REGISTRYINDEX[&wxlua_lreg_tags_key][tag number] = { metatable for a C++ class } ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_tags_key; // The key in the LUA_REGISTRYINDEX table that is a numerically keyed table // with references to Lua objects we want to keep a handle to. The object could be ! // anything, a table, function, userdata... // LUA_REGISTRYINDEX[&wxlua_lreg_refs_key][ref number] = Lua object extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_refs_key; --- 77,93 ---- // ---------------------------------------------------------------------------- ! // Light userdata used as keys in the Lua LUA_REGISTRYINDEX table for wxLua items. ! // Note that even though these keys have values, they're not used, just the memory address. // The key in the LUA_REGISTRYINDEX table that is a table indexed ! // on the wxLua types where each item is a userdata metatable for a C++ class. ! // Note: The wxLua types WXLUA_TXXX that correspond to the Lua LUA_TXXX types ! // are not stored in this table since they do not use our metatables. ! // The keys in this table are all > 1. ! // LUA_REGISTRYINDEX[&wxlua_lreg_types_key][wxLua type number] = { metatable for a C++ class } ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_types_key; // The key in the LUA_REGISTRYINDEX table that is a numerically keyed table // with references to Lua objects we want to keep a handle to. The object could be ! // anything, a table, function, number, string, userdata... // LUA_REGISTRYINDEX[&wxlua_lreg_refs_key][ref number] = Lua object extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_refs_key; *************** *** 108,116 **** extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_wxluastate_key; // The key in the LUA_REGISTRYINDEX table that is table of all ! // objects that we've pushed into Lua using wxluaT_pushusertag(). ! // Note: A single object like a wxWindow may be pushed with multiple tags. // e.g. wxWindow* w = wx.wxWindow() retrieve the window later from wxObject* wxEvent:GetEventObject() // LUA_REGISTRYINDEX[&wxlua_lreg_weakobjects_key][lightuserdata(obj_ptr)] = ! // { tag1 = weak fulluserdata, tag2 = weak fulluserdata... } extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_weakobjects_key; // The key in the LUA_REGISTRYINDEX table that is table of all --- 111,119 ---- extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_wxluastate_key; // The key in the LUA_REGISTRYINDEX table that is table of all ! // objects that we've pushed into Lua using wxluaT_pushuserdatatype(). ! // Note: A single object like a wxWindow may be pushed with multiple wxLua types. // e.g. wxWindow* w = wx.wxWindow() retrieve the window later from wxObject* wxEvent:GetEventObject() // LUA_REGISTRYINDEX[&wxlua_lreg_weakobjects_key][lightuserdata(obj_ptr)] = ! // { wxLua type1 = weak fulluserdata, wxLua type2 = weak fulluserdata... } extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_weakobjects_key; // The key in the LUA_REGISTRYINDEX table that is table of all *************** *** 118,122 **** // Note that non wxObject classes use wxLUA_DECLARE_ENCAPSULATION so // the key is the object pointer and the value is the wxObject encapsulation. ! // If not encapsulated both the key and the value are the same. // LUA_REGISTRYINDEX[&wxlua_lreg_gcobjects_key][lightuserdata(obj_ptr)] = // lightuserdata(wxObject derived class) --- 121,125 ---- // Note that non wxObject classes use wxLUA_DECLARE_ENCAPSULATION so // the key is the object pointer and the value is the wxObject encapsulation. ! // Both the key and the value are the same if not encapsulated . // LUA_REGISTRYINDEX[&wxlua_lreg_gcobjects_key][lightuserdata(obj_ptr)] = // lightuserdata(wxObject derived class) *************** *** 135,139 **** extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_windestroycallbacks_key; // The key in the LUA_REGISTRYINDEX table that is table of all ! // top level windows that we've created and need to destroy when closed. // LUA_REGISTRYINDEX[&wxlua_lreg_topwindows_key][lightuserdata(&wxWindow)] = 1 extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_topwindows_key; --- 138,142 ---- extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_windestroycallbacks_key; // The key in the LUA_REGISTRYINDEX table that is table of all ! // top level wxWindows that we've created and need to destroy when closed. // LUA_REGISTRYINDEX[&wxlua_lreg_topwindows_key][lightuserdata(&wxWindow)] = 1 extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_topwindows_key; *************** *** 159,178 **** extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_regtable_key; ! // Light user data used as keys in the metatables created for the class userdata objects. ! // Note that even though these have values, they're not used, just the memory address. ! // wxLua metatable structure: // { ! // lightuserdata(&wxlua_metatable_tag_key) = tag number in wxlua_lreg_tags_key table // lightuserdata(&wxlua_metatable_wxluabindclass_key) = lightuserdata(&wxLuaBindClass) ! // __gc = function(wxluabind__gc_wxLuaBindClass) ! // __index = function(wxluabind__index_wxLuaBindClass) ! // __newindex = function(wxluabind__newindex_wxLuaBindClass) ! // __tostring = function(wxluabind__tostring_wxLuaBindClass) // } ! // The key of a metatable used for wxLua userdata that is the tag number in the ! // wxlua_lreg_tags_key table this metatable is for. ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_metatable_tag_key; // The key of a metatable used for wxLua userdata that stores a lightuserdata // of the wxLuaBindClass struct for this class. --- 162,181 ---- extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_regtable_key; ! // Light userdata used as keys in the metatables created for the class userdata objects. ! // Note that even though these keys have values, they're not used, just the memory address. ! // wxLua userdata metatable structure: // { ! // lightuserdata(&wxlua_metatable_type_key) = wxLua type number in wxlua_lreg_types_key table // lightuserdata(&wxlua_metatable_wxluabindclass_key) = lightuserdata(&wxLuaBindClass) ! // __gc = function(wxlua_wxLuaBindClass__gc) ! // __index = function(wxlua_wxLuaBindClass__index) ! // __newindex = function(wxlua_wxLuaBindClass__newindex) ! // __tostring = function(wxlua_wxLuaBindClass__tostring) // } ! // The key of a metatable used for wxLua userdata that is the wxLua type number in the ! // wxlua_lreg_types_key table this metatable is for. ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_metatable_type_key; // The key of a metatable used for wxLua userdata that stores a lightuserdata // of the wxLuaBindClass struct for this class. *************** *** 181,189 **** // ---------------------------------------------------------------------------- // Create one of the wxlua_lreg_XXX_key tables in the LUA_REGISTRYINDEX and ! // properly set the wxlua_lreg_regtablekey_key key too. WXDLLIMPEXP_WXLUA void wxlua_lreg_createtable(lua_State* L, void* lightuserdata_reg_key, int narr = 0, int nrec = 0); // ---------------------------------------------------------------------------- ! // Lua C helper functions - These functions are also part of the wxLuaState // and you are recommended to use those if the wxLuaState is required. However // in some cases it may not be necessary to create a wxLuaState and just --- 184,192 ---- // ---------------------------------------------------------------------------- // Create one of the wxlua_lreg_XXX_key tables in the LUA_REGISTRYINDEX and ! // properly set the wxlua_lreg_regtablekey_key too. WXDLLIMPEXP_WXLUA void wxlua_lreg_createtable(lua_State* L, void* lightuserdata_reg_key, int narr = 0, int nrec = 0); // ---------------------------------------------------------------------------- ! // The functions below are Lua C helper functions that are also part of the wxLuaState // and you are recommended to use those if the wxLuaState is required. However // in some cases it may not be necessary to create a wxLuaState and just *************** *** 192,202 **** // ---------------------------------------------------------------------------- ! // Push the errorMsg on the stack and call luaL_error WXDLLIMPEXP_WXLUA void LUACALL wxlua_error(lua_State* L, const char* errorMsg); wxLUA_UNICODE_ONLY(WXDLLIMPEXP_WXLUA inline void LUACALL wxlua_error(lua_State* L, const wxString& errorMsg) { wxlua_error(L, wx2lua(errorMsg)); }) ! // Create an error message that the item at the stack_idx is not of the type wxl_tag ! // and call wxlua_error(). WXDLLIMPEXP_WXLUA void LUACALL wxlua_argerror(lua_State *L, int stack_idx, const wxString& expectedType); // Get the userdata at the stack index, if null_ptr then set the pointer wrapped --- 195,217 ---- // ---------------------------------------------------------------------------- ! // Push the errorMsg on the stack and call luaL_error() WXDLLIMPEXP_WXLUA void LUACALL wxlua_error(lua_State* L, const char* errorMsg); wxLUA_UNICODE_ONLY(WXDLLIMPEXP_WXLUA inline void LUACALL wxlua_error(lua_State* L, const wxString& errorMsg) { wxlua_error(L, wx2lua(errorMsg)); }) ! // Create an error message that the item at the stack_idx is not correct for a ! // function call and call wxlua_argerrormsg(). ! // The expectedType string should tell the user what is valid input and is a ! // string to be flexible for multiple valid types. ! // The error message format is: ! // "wxLua: Expected %s for parameter %d, but got a '%s'.", expectedType.c_str(), stack_idx, argType.c_str() ! // Typical expectedType strings would be wxT("a 'number'") WXDLLIMPEXP_WXLUA void LUACALL wxlua_argerror(lua_State *L, int stack_idx, const wxString& expectedType); + // Create an error message for an incorrect function call and call wxlua_error(). + // The message created has this format: + // msg + // "functionNameCalled(argName1, argName2, ...)" <-- from wxlua_getLuaArgsMsg() + // "01. functionName(validArgName1, validArgName2, ...)" <-- from wxlua_getBindMethodArgsMsg() + // "02. ..." + WXDLLIMPEXP_WXLUA void LUACALL wxlua_argerrormsg(lua_State *L, const wxString& msg); // Get the userdata at the stack index, if null_ptr then set the pointer wrapped *************** *** 210,214 **** // // Possible values for the "void* lightuserdata_reg_key" are ! // wxlua_lreg_tags_key, wxlua_lreg_refs_key, wxlua_lreg_debug_refs_key // unless you are using these functions for your own table in the LUA_REGISTRYINDEX. //---------------------------------------------------------------------------- --- 225,229 ---- // // Possible values for the "void* lightuserdata_reg_key" are ! // wxlua_lreg_types_key, wxlua_lreg_refs_key, wxlua_lreg_debug_refs_key // unless you are using these functions for your own table in the LUA_REGISTRYINDEX. //---------------------------------------------------------------------------- *************** *** 223,283 **** // Push onto the top of the stack the object at the index in a table with the key // lightuserdata_reg_key in the LUA_REGISTRYINDEX table, if the index is LUA_REFNIL or the ! // value is nil return false and don't leave anything on the stack. WXDLLIMPEXP_WXLUA bool LUACALL wxluaR_getref(lua_State* L, int wxlref_idx, const void* lightuserdata_reg_key); // Is the item at the stack_idx in the table with the key lightuserdata_reg_key ! // in the LUA_REGISTRYINDEX table. Returns the tag or LUA_NOREF if it's not. WXDLLIMPEXP_WXLUA int LUACALL wxluaR_isrefed(lua_State* L, int stack_idx, const void* lightuserdata_reg_key); //---------------------------------------------------------------------------- - // wxluaT_XXX - functions operate on the "tags" which are a numerical indexes - // in the wxlua_lreg_tags_key table in Lua's LUA_REGISTRYINDEX to determine - // the C++ class type for a Lua userdata. - //---------------------------------------------------------------------------- - - // Allocate a new table (metatable) with a wxlua_metatable_tag_key key equal - // to the number from wxluaR_ref() and store it in the wxlua_lreg_tags_key LUA_REGISTRYINDEX table. - // Returns the index into the tags table, the return value from wxluaR_ref(). - // Leaves the new table on the top of the stack. - WXDLLIMPEXP_WXLUA int LUACALL wxluaT_newtag(lua_State* L); - // Get the numeric tag of the userdata at the stack index using the metatable's wxlua_metatable_tag_key key. - // Returns WXLUA_NOTAG if the metatable of the userdata doesn't have a wxlua_metatable_tag_key - // key or it isn't a number. The tag is presumedly the index into the wxlua_lreg_tags_key - // LUA_REGISTRYINDEX table and denotes what type of C++ object this is. - WXDLLIMPEXP_WXLUA int LUACALL wxluaT_gettag(lua_State* L, int stack_idx); - // Set the metatable of the userdata at top of stack to the table stored in the - // wxlua_lreg_tags_key LUA_REGISTRYINDEX table using wxluaR_getref(L, wxl_tag). - WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_settag(lua_State* L, int wxl_tag); - - // Get the wxLuaBindClass* for this wxl_tag or NULL if the tag is invalid. - // Gets the wxLuaBindClass from the metatable stored in the wxlua_lreg_tags_key registry table - // for the classes that have been installed into Lua. - WXDLLIMPEXP_WXLUA const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, int wxl_tag); - // Get the wxLuaBindClass* for this class_name or NULL if the name is invalid. - // Gets the wxLuaBindClass from the wxlua_lreg_classes_key table in the LUA_REGISTRYINDEX. - WXDLLIMPEXP_WXLUA const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, const char* class_name); - // Get the name of the class with this wxl_tag. - WXDLLIMPEXP_WXLUA wxString LUACALL wxluaT_gettagname(lua_State* L, int wxl_tag); - // Get the tag for the class with the given name - WXDLLIMPEXP_WXLUA int LUACALL wxluaT_gettag(lua_State* L, const char* name); - // Is the item at stack_idx of the userdata type with or derived from the the given tag. - WXDLLIMPEXP_WXLUA bool wxluaT_isuserdatatype(lua_State* L, int stack_idx, int wxl_tag); - - // Get the userdata object at the stack_idx that is of the class type tag or a - // class derived from the tag. If the userdata does not have the correct tag, - // or if the parameter isn't a userdata then wxlua_error() is called and NULL is returned. - WXDLLIMPEXP_WXLUA void* LUACALL wxluaT_getuserdatatype(lua_State* L, int stack_idx, int wxl_tag); - // Push the obj_ptr onto the top of the stack wrapped in a newuserdata - // with it's metatable set to the table from wxluaR_getref(L, tag, &wxlua_lreg_tags_key). - // Returns true if the tag is known and the metatable was set. - // If track=true then push the obj_ptr as a lightuser data key into the - // wxlua_lreg_weakobjects_key table of the Lua LUA_REGISTRYINDEX table so - // that if we need to push it again we just push the already created full userdata value. - WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_pushusertag(lua_State* L, const void* obj_ptr, int wxl_tag, bool track); - // Push a data type onto the stack and set its tag by calling wxluaT_pushusertag() - // after checking if the object is a wxWindow and adding it to the - // wxlua_lreg_windestroycallbacks_key table if it is. - WXDLLIMPEXP_WXLUA void LUACALL wxluaT_pushuserdatatype(lua_State* L, int wxl_tag, const void *obj_ptr); - - //---------------------------------------------------------------------------- // wxluaO_XXX - functions operate on wxLua "Objects" which are userdata wrapping // C++ class objects and are stored in the wxlua_lreg_weakobjects_key --- 238,248 ---- // Push onto the top of the stack the object at the index in a table with the key // lightuserdata_reg_key in the LUA_REGISTRYINDEX table, if the index is LUA_REFNIL or the ! // value is nil it returns false and doesn't leave anything on the stack. WXDLLIMPEXP_WXLUA bool LUACALL wxluaR_getref(lua_State* L, int wxlref_idx, const void* lightuserdata_reg_key); // Is the item at the stack_idx in the table with the key lightuserdata_reg_key ! // in the LUA_REGISTRYINDEX table. Returns the ref index or LUA_NOREF if it's not. WXDLLIMPEXP_WXLUA int LUACALL wxluaR_isrefed(lua_State* L, int stack_idx, const void* lightuserdata_reg_key); //---------------------------------------------------------------------------- // wxluaO_XXX - functions operate on wxLua "Objects" which are userdata wrapping // C++ class objects and are stored in the wxlua_lreg_weakobjects_key *************** *** 319,336 **** WXDLLIMPEXP_WXLUA wxArrayString LUACALL wxluaO_getgcobjectinfo(lua_State *L); ! // Track the obj_ptr and it's Lua userdata at udata_stack_idx in the ! // wxlua_lreg_weakobjects_key table of the LUA_REGISTRYINDEX so we can push ! // it again if needed. ! WXDLLIMPEXP_WXLUA void LUACALL wxluaO_trackweakobject(lua_State *L, int udata_stack_idx, void *obj_ptr, int tag); // Remove the obj_ptr key from the wxlua_lreg_weakobjects_key table of // the LUA_REGISTRYINDEX. It removes the metatable for the single Lua userdata, // "udata", since this function is called before the object is deleted. ! // e.g. p1 = wx.wxPoint(); p2 = p1; p2:delete(); p1:SetX(5) errors, but doesn't segfault // If udata == NULL it removes ALL tracked userdata for this obj_ptr and clears // all of their metatables. WXDLLIMPEXP_WXLUA int LUACALL wxluaO_untrackweakobject(lua_State *L, void* udata, void *obj_ptr); ! // Check if this object with the given tag is in the wxlua_lreg_weakobjects_key ! // table of the LUA_REGISTRYINDEX. If push_on_stack then push on top of the stack. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaO_istrackedweakobject(lua_State *L, void *obj_ptr, int tag, bool push_on_stack); //---------------------------------------------------------------------------- --- 284,304 ---- WXDLLIMPEXP_WXLUA wxArrayString LUACALL wxluaO_getgcobjectinfo(lua_State *L); ! // Track the obj_ptr and its Lua userdata at udata_stack_idx which is of the ! // wxLua type in the wxlua_lreg_weakobjects_key table of the ! // LUA_REGISTRYINDEX so we can push it again if needed. ! WXDLLIMPEXP_WXLUA void LUACALL wxluaO_trackweakobject(lua_State *L, int udata_stack_idx, void *obj_ptr, int wxl_type); // Remove the obj_ptr key from the wxlua_lreg_weakobjects_key table of // the LUA_REGISTRYINDEX. It removes the metatable for the single Lua userdata, // "udata", since this function is called before the object is deleted. ! // e.g. p1 = wx.wxPoint(); p2 = p1; p2:delete(); p1:SetX(5) errors, but doesn't segfault. // If udata == NULL it removes ALL tracked userdata for this obj_ptr and clears // all of their metatables. WXDLLIMPEXP_WXLUA int LUACALL wxluaO_untrackweakobject(lua_State *L, void* udata, void *obj_ptr); ! // Check if this object with the given wxLua type is in the wxlua_lreg_weakobjects_key ! // table of the LUA_REGISTRYINDEX. ! // If the object is found with the right wxLua type and push_on_stack is true ! // the Lua userdata for the object is pushed on top of the stack. If it's not ! // found then it returns false and nothing is left on the stack. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaO_istrackedweakobject(lua_State *L, void *obj_ptr, int wxl_type, bool push_on_stack); //---------------------------------------------------------------------------- *************** *** 346,350 **** // LUA_REGISTRYINDEX table. WXDLLIMPEXP_WXLUA void LUACALL wxluaW_removetrackedwindow(lua_State *L, wxWindow* win); ! // Is this wxWindow or one of it's parents already added to the // wxlua_lreg_topwindows_key table of the LUA_REGISTRYINDEX table? WXDLLIMPEXP_WXLUA bool LUACALL wxluaW_istrackedwindow(lua_State *L, wxWindow* win, bool check_parents); --- 314,318 ---- // LUA_REGISTRYINDEX table. WXDLLIMPEXP_WXLUA void LUACALL wxluaW_removetrackedwindow(lua_State *L, wxWindow* win); ! // Is this wxWindow or one of its parents already added to the // wxlua_lreg_topwindows_key table of the LUA_REGISTRYINDEX table? WXDLLIMPEXP_WXLUA bool LUACALL wxluaW_istrackedwindow(lua_State *L, wxWindow* win, bool check_parents); *************** *** 353,388 **** WXDLLIMPEXP_WXLUA wxArrayString LUACALL wxluaW_gettrackedwindowinfo(lua_State *L); // ---------------------------------------------------------------------------- ! // Functions to get info about the tags or the args wxLua uses to determine ! // the lua_type() or C++ class type. // Used to determine what to expect for a function call in the bindings. // ---------------------------------------------------------------------------- ! // Is a class with the wxl_tag equal to or derived from a class with the base_wxl_tag. // 0 means same class, +1 means base is parent, +2 base is grandparent, ... ! // returns -1 if the class_tag is not derived from the base class ! WXDLLIMPEXP_WXLUA int LUACALL wxlua_isderivedclass(lua_State* L, int wxl_tag, int base_wxl_tag); // Same as above, but works directly with the wxLuaBindClasses. ! WXDLLIMPEXP_WXLUA int LUACALL wxlua_isderivedclass(const wxLuaBindClass* wxlClass, const wxLuaBindClass* base_wxlClass); // Verify if the luatype = lua_type(L, stack_idx) is valid for the ! // wxluaarg_tag which is one of the predefined WXLUA_T... [truncated message content] |