You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(191) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(238) |
Dec
(68) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(104) |
Feb
(518) |
Mar
(302) |
Apr
(211) |
May
(311) |
Jun
(55) |
Jul
(6) |
Aug
(35) |
Sep
(76) |
Oct
(50) |
Nov
(37) |
Dec
(340) |
2007 |
Jan
(23) |
Feb
(107) |
Mar
(98) |
Apr
(60) |
May
(136) |
Jun
(371) |
Jul
(175) |
Aug
(74) |
Sep
(3) |
Oct
(2) |
Nov
(53) |
Dec
(129) |
2008 |
Jan
(337) |
Feb
(23) |
Mar
(18) |
Apr
(4) |
May
(3) |
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
(33) |
Nov
|
Dec
(26) |
2009 |
Jan
(4) |
Feb
(1) |
Mar
(15) |
Apr
|
May
(35) |
Jun
(11) |
Jul
|
Aug
|
Sep
(19) |
Oct
(26) |
Nov
(11) |
Dec
(11) |
2010 |
Jan
(4) |
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(8) |
Sep
|
Oct
|
Nov
(8) |
Dec
(7) |
2011 |
Jan
|
Feb
|
Mar
(4) |
Apr
(8) |
May
(5) |
Jun
(8) |
Jul
(1) |
Aug
|
Sep
|
Oct
(5) |
Nov
(13) |
Dec
|
From: John L. <jr...@us...> - 2007-12-07 02:13:20
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv12976/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlcallb.h wxldefs.h wxlstate.h wxlua_bind.h Log Message: Too many changes to list... A large portion of the internal workings of the wxLuaState have been rewritten. All of the data that was stored in wxLuaStateData that might be needed by a function taking a lua_State* is now in the LUA_REGISTRYINDEX. C functions have been added to access these values. The generated bindings no longer need to have "wxLuaState wxlState(L);" since everything can be done with the C functions. The result is that wxLua should be faster. Index: wxlcallb.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlcallb.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** wxlcallb.h 4 Dec 2007 05:20:28 -0000 1.22 --- wxlcallb.h 7 Dec 2007 02:13:14 -0000 1.23 *************** *** 53,56 **** --- 53,60 ---- const wxLuaBindEvent* GetwxLuaBindEvent() const { return m_wxlBindEvent; } + // Get a human readable string + // "wxEVT_XXX(evt#) -> wxLuaCallback(&callback, ids %d %d)|wxEvtHandler(&evthandler) -> wxEvtHandlerClassName" + wxString GetInfo() const; // Get a human readable string + // Central event handler that calls CallFunction() for the actual // wxLuaCallback callback user data. This function is treated like a *************** *** 99,102 **** --- 103,110 ---- wxWindow* GetWindow() const { return m_window; } + // Get a human readable string + // "wxWindowClassName(&win, id=%d)|wxLuaDestroyCallback(&callback)" + wxString GetInfo() const; + // Central event handler that calls OnDestroy() for the actual // wxLuaWinDestroyCallback callback user data. This function is treated like a Index: wxldefs.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxldefs.h,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** wxldefs.h 28 Nov 2007 00:20:49 -0000 1.36 --- wxldefs.h 7 Dec 2007 02:13:14 -0000 1.37 *************** *** 67,71 **** //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 18 // ---------------------------------------------------------------------------- --- 67,71 ---- //----------------------------------------------------------------------------- ! #define WXLUA_BINDING_VERSION 19 // ---------------------------------------------------------------------------- Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** wxlbind.h 5 Dec 2007 05:54:11 -0000 1.68 --- wxlbind.h 7 Dec 2007 02:13:14 -0000 1.69 *************** *** 239,242 **** --- 239,252 ---- // ---------------------------------------------------------------------------- + // Central function to call for overloaded functions + // ---------------------------------------------------------------------------- + + // Redirect Lua function call to 1 method from a list of overloaded functions + WXDLLIMPEXP_WXLUA int LUACALL wxlua_CallOverloadedFunction(lua_State* L, struct wxLuaBindMethod* wxlMethod); + + // Return a human readable string of the args for the functions in the method + WXDLLIMPEXP_WXLUA wxArrayString wxlua_CreateMethodArgTagsMsg(lua_State* L, struct wxLuaBindMethod* method); + + // ---------------------------------------------------------------------------- // wxLuaObject - wraps a reference to a Lua object reference inside a // wxObject-derived class so that a Lua object can be used for *************** *** 375,378 **** --- 385,460 ---- // ---------------------------------------------------------------------------- + // wxLuaSmartwxArrayString - Wraps a "new" wxArrayString with an automatic + // destructor to delete them to make binding easier + // ---------------------------------------------------------------------------- + + class WXDLLIMPEXP_WXLUA wxLuaSmartwxArrayString : public wxObject + { + public: + wxLuaSmartwxArrayString(const wxLuaSmartwxArrayString& arr) { Ref(arr); } + wxLuaSmartwxArrayString(wxArrayString *arr, bool del); + + wxArrayString* GetArray() const; + + operator const wxArrayString *() const { return GetArray(); } + operator const wxArrayString &() const { return *GetArray(); } + operator wxArrayString &() { return *GetArray(); } + + wxLuaSmartwxArrayString& operator = (const wxLuaSmartwxArrayString& arr) + { + Ref(arr); + return *this; + } + }; + + // ---------------------------------------------------------------------------- + // wxLuaSmartwxSortedArrayString - Wraps a "new" wxSortedArrayString with an automatic + // destructor to delete them to make binding easier + // ---------------------------------------------------------------------------- + + class WXDLLIMPEXP_WXLUA wxLuaSmartwxSortedArrayString : public wxObject + { + public: + wxLuaSmartwxSortedArrayString(const wxLuaSmartwxArrayString& arr) { Ref(arr); } + wxLuaSmartwxSortedArrayString(wxSortedArrayString *arr, bool del); + + wxSortedArrayString* GetArray() const; + + operator const wxSortedArrayString *() const { return GetArray(); } + operator const wxSortedArrayString &() const { return *GetArray(); } + operator wxSortedArrayString &() { return *GetArray(); } + + wxLuaSmartwxSortedArrayString& operator = (const wxLuaSmartwxSortedArrayString& arr) + { + Ref(arr); + return *this; + } + }; + + // ---------------------------------------------------------------------------- + // wxLuaSmartwxArrayInt - Wraps a "new" wxArrayInt with an automatic + // destructor to delete them to make binding easier + // ---------------------------------------------------------------------------- + + class WXDLLIMPEXP_WXLUA wxLuaSmartwxArrayInt : public wxObject + { + public: + wxLuaSmartwxArrayInt(const wxLuaSmartwxArrayInt& arr) { Ref(arr); } + wxLuaSmartwxArrayInt(wxArrayInt *arr = NULL, bool del = true); + + wxArrayInt* GetArray() const; + + operator const wxArrayInt *() const { return GetArray(); } + operator const wxArrayInt &() const { return *GetArray(); } + operator wxArrayInt &() { return *GetArray(); } + + wxLuaSmartwxArrayInt& operator = (const wxLuaSmartwxArrayInt& arr) + { + Ref(arr); + return *this; + } + }; + + // ---------------------------------------------------------------------------- // wxLuaBinding - binds classes, functions, objects, and event callbacks to // the wxLuaState. Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** wxlstate.h 5 Dec 2007 05:54:11 -0000 1.100 --- wxlstate.h 7 Dec 2007 02:13:14 -0000 1.101 *************** *** 21,24 **** --- 21,25 ---- class WXDLLIMPEXP_WXLUA wxLuaCallback; class WXDLLIMPEXP_WXLUA wxLuaWinDestroyCallback; + class WXDLLIMPEXP_WXLUA wxLuaDebugHookData; // ---------------------------------------------------------------------------- *************** *** 101,105 **** // The key in the LUA_REGISTRYINDEX table that is table of all // objects that we've pushed into Lua. t[lightuserdata] = [weak valued full userdata] ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_objects_key; // The key in the LUA_REGISTRYINDEX table that is table of all // wxLuaCallbacks that we've created. --- 102,112 ---- // The key in the LUA_REGISTRYINDEX table that is table of all // objects that we've pushed into Lua. t[lightuserdata] = [weak valued full userdata] ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_weakobjects_key; ! // The key in the LUA_REGISTRYINDEX table that is table of all ! // objects we pushed into Lua and want to delete when done with them. ! // t[lightuserdata(&object)] = lightuserdata(wxObject derived class) ! // Note that non wxObject classes use wxLUA_DECLARE_ENCAPSULATION so ! // the key is the object pointer and the value is the wxObject encapsulation. ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_delobjects_key; // The key in the LUA_REGISTRYINDEX table that is table of all // wxLuaCallbacks that we've created. *************** *** 111,119 **** // t[lightuserdata wxWindow] = lightuserdata wxLuaWinDestroyCallback extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_windestroycallbacks_key; ! // The key in the LUA_REGISTRYINDEX table that is a boolean value // of whether the Lua code has prepended a '_' to function name to indicate // that they want the base class function called. extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_callbaseclassfunc_key; ! // Light user data used as keys in the metatables created for the class userdata objects. --- 118,135 ---- // t[lightuserdata wxWindow] = lightuserdata wxLuaWinDestroyCallback 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. ! // t[lightuserdata wxWindow] = 1 (the number 1) ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_topwindows_key; ! // The key in the LUA_REGISTRYINDEX table that has a boolean value // of whether the Lua code has prepended a '_' to function name to indicate // that they want the base class function called. extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_callbaseclassfunc_key; ! // The key in the LUA_REGISTRYINDEX table that has a wxEventType (integer) value ! // of the current wxEvent is that is being run or wxEVT_NULL if not in an event. ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_wxeventtype_key; ! // The key in the LUA_REGISTRYINDEX table that has a wxLuaDebugHookData ! // lightuserdata value for the wxLuaState. ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_wxluadebughookdata_key; // Light user data used as keys in the metatables created for the class userdata objects. *************** *** 138,141 **** --- 154,161 ---- wxLUA_UNICODE_ONLY(inline WXDLLIMPEXP_WXLUA void LUACALL wxlua_error(lua_State* L, const wxString& errorMsg) { wxlua_error(L, wx2lua(errorMsg)); }) + // Get the userdata at the stack index, if null_ptr then set the pointer wrapped + // by Lua's userdata to NULL to clear it. + WXDLLIMPEXP_WXLUA void* LUACALL wxlua_touserdata(lua_State* L, int stack_idx, bool null_ptr = false); + //---------------------------------------------------------------------------- // wxluaR_XXX - functions operate on tables in Lua's LUA_REGISTRYINDEX which *************** *** 144,147 **** --- 164,168 ---- // 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. //---------------------------------------------------------------------------- *************** *** 162,168 **** //---------------------------------------------------------------------------- ! // wxluaT_XXX - functions operate on the "Tags" which is a numerical index in the ! // wxlua_lreg_tags_key table in Lua's LUA_REGISTRYINDEX to determine the C++ ! // class for a Lua userdata. //---------------------------------------------------------------------------- --- 183,189 ---- //---------------------------------------------------------------------------- ! // 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 for a Lua userdata. //---------------------------------------------------------------------------- *************** *** 180,209 **** // wxlua_lreg_tags_key LUA_REGISTRYINDEX table using wxluaR_getref(tag). WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_settag(lua_State* L, int tag); // Push the object u 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 object as a lightuser data key into the ! // wxlua_lreg_objects_key table of the Lua LUA_REGISTRYINDEX table so that if we need to // push it again we just push the full userdata value. WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_pushusertag(lua_State* L, const void* u, int tag, bool track); //---------------------------------------------------------------------------- // wxluaO_XXX - functions operate on the "Objects" which are userdata wrapping ! // C++ class objects and are stored in the wxlua_lreg_objects_key table in ! // Lua's LUA_REGISTRYINDEX. //---------------------------------------------------------------------------- ! // If an object was pushed into Lua using wxluaT_pushusertag with track=true ! // then this function will remove the object from being tracked in the ! // wxlua_lreg_objects_key Lua LUA_REGISTRYINDEX table. ! WXDLLIMPEXP_WXLUA void LUACALL wxluaO_untrackuserdata(lua_State* L, const void* u); // If an object was pushed into Lua using wxluaT_pushusertag with track=true // then this function will remove the metable of the object being tracked in the ! // wxlua_lreg_objects_key Lua LUA_REGISTRYINDEX table. WXDLLIMPEXP_WXLUA void LUACALL wxluaO_cleartrackedmetatable(lua_State* L, const void* u); ! // Get the userdata at the stack index, if null_ptr then set the pointer wrapped ! // by Lua's userdata to NULL to clear it. ! WXDLLIMPEXP_WXLUA void* LUACALL wxlua_touserdata(lua_State* L, int stack_idx, bool null_ptr = false); // ---------------------------------------------------------------------------- --- 201,285 ---- // wxlua_lreg_tags_key LUA_REGISTRYINDEX table using wxluaR_getref(tag). WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_settag(lua_State* L, int tag); + + // Get the wxLuaBindClass* for this class_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 class_tag); + // Get the wxLuaBindClass* for this class_name or NULL if the name is invalid. + // Gets the wxLuaBindClass from the "wxLuaClasses" table in the Lua registry. + WXDLLIMPEXP_WXLUA const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, const char* class_name); + // Get the name of the class with this tag. + WXDLLIMPEXP_WXLUA wxString LUACALL wxluaT_gettagname(lua_State* L, int class_tag); + // Get the tag for the class with the given name + WXDLLIMPEXP_WXLUA int LUACALL wxluaT_gettag(lua_State* L, const char* name); + + // Get the userdata object at the stack_idx that is of the class type tag or a + // class derived from the tag. + // If the data type 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 object u 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 object 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 full userdata value. WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_pushusertag(lua_State* L, const void* u, int 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 *data); //---------------------------------------------------------------------------- // wxluaO_XXX - functions operate on the "Objects" which are userdata wrapping ! // C++ class objects and are stored in the wxlua_lreg_weakobjects_key table ! // and the wxlua_lreg_delobjects_key in Lua's LUA_REGISTRYINDEX. //---------------------------------------------------------------------------- ! enum wxLuaRemoveTrackedObject_flags ! { ! wxLUA_UNDELETE_OBJECT = 0, // stop tracking for deletion (someone else owns this) ! wxLUA_DELETE_OBJECT = 0x0001, // delete the object ! wxLUA_CLEAR_TRACKED_OBJECT = 0x0002, // clear tracking the object in Lua reg table ! wxLUA_CLEAR_DERIVED_METHODS = 0x0004, // clear any derived methods in Lua reg table ! wxLUA_DELETE_CLEAR_OBJECT = wxLUA_DELETE_OBJECT|wxLUA_CLEAR_TRACKED_OBJECT|wxLUA_CLEAR_DERIVED_METHODS ! }; ! ! // Track this wxObject and delete it when Lua calls the __gc method for it. ! // The object is stored in the wxlua_lreg_delobjects_key of the LUA_REGISTRYINDEX ! // as t[lightuserdata(obj_ptr)] = lightuserdata(wxobj). ! // The second version is used when the non-wxObject class is encapsulated and so ! // the obj_ptr points to the actual object that the wxObject encapsulates. ! WXDLLIMPEXP_WXLUA void LUACALL wxluaO_addtrackedobject(lua_State* L, wxObject* wxobj); ! WXDLLIMPEXP_WXLUA void LUACALL wxluaO_addtrackedobject(lua_State* L, const void* obj_ptr, wxObject* wxobj); ! // Remove this tracked wxObject from the wxlua_lreg_delobjects_key table of the ! // LUA_REGISTRYINDEX. ! // The object can be deleted and other items assicated may be cleared ! // by setting the "flags" from ored values of enum wxLuaRemoveTrackedObject_flags ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaO_removetrackedobject(lua_State *L, void *obj_ptr, int flags); ! // Check if this object is in the wxlua_lreg_delobjects_key table of the ! // LUA_REGISTRYINDEX. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaO_istrackedobject(lua_State *L, void *obj_ptr); ! // If an object was pushed into Lua using wxluaT_pushusertag with track=true // then this function will remove the metable of the object being tracked in the ! // wxlua_lreg_weakobjects_key Lua LUA_REGISTRYINDEX table. WXDLLIMPEXP_WXLUA void LUACALL wxluaO_cleartrackedmetatable(lua_State* L, const void* u); ! //---------------------------------------------------------------------------- ! // wxluaW_XXX - functions operate on tracked wxWindows stored in the ! // wxlua_lreg_topwindows_key in Lua's LUA_REGISTRYINDEX. ! //---------------------------------------------------------------------------- ! ! // Add the wxObject which is presumably a wxWindow (this will check) and ! // to the wxlua_lreg_topwindows_key table of the LUA_REGISTRYINDEX table if ! // it has not already been added. ! WXDLLIMPEXP_WXLUA void LUACALL wxluaW_addtrackedwindow(lua_State *L, wxObject* obj); ! // Remove the wxWindow from the wxlua_lreg_topwindows_key table of the ! // 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); // ---------------------------------------------------------------------------- *************** *** 211,221 **** // ---------------------------------------------------------------------------- - // Get the wxLuaBindClass* for this class_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 class_tag); - // Get the wxLuaBindClass* for this class_name or NULL if the name is invalid. - // Gets the wxLuaBindClass from the "wxLuaClasses" table in the Lua registry. - WXDLLIMPEXP_WXLUA const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, const char* class_name); // Is a class with the class_tag equal to or derived from a class with the base_class_tag. // 0 means same class, +1 means base is parent, +2 base is grandparent, ... --- 287,290 ---- *************** *** 229,236 **** // Note that this function does not do a direct mapping between wxlua_getwxluatype() // and wxlua_getluatype() since it allows a small amount of coersion between types. ! // It also doesn't account for the automatic conversion of certain Lua types ! // to wxluatypes, (wxString, wxArrayString, wxArrayInt) ! // see wxLuaState::IswxLuaType which is more complete. ! WXDLLIMPEXP_WXLUA int LUACALL wxlua_iswxluatype(int luatype, int wxluaarg_tag); // Get a human readable name for the predefined WXLUAARG_XXX or s_wxluaarg_XXX tags. // returns empty string if the tag was not one of the predefined types. --- 298,306 ---- // Note that this function does not do a direct mapping between wxlua_getwxluatype() // and wxlua_getluatype() since it allows a small amount of coersion between types. ! // If the input lua_State is not NULL it will account for the automatic conversion of ! // (wxString, wxArrayString, wxArrayInt) to and from Lua types to wxluatypes, ! WXDLLIMPEXP_WXLUA int LUACALL wxlua_iswxluatype(int luatype, int wxluaarg_tag, lua_State* L = NULL); ! // Is the item at stack_idx of the userdata type with or derived from the the given tag. ! WXDLLIMPEXP_WXLUA bool wxlua_isuserdatatype(lua_State* L, int stack_idx, int tag); // Get a human readable name for the predefined WXLUAARG_XXX or s_wxluaarg_XXX tags. // returns empty string if the tag was not one of the predefined types. *************** *** 242,245 **** --- 312,317 ---- // returns -1 (LUA_TNONE) if the tag was not one of the predefined types. WXDLLIMPEXP_WXLUA int wxlua_getluatype(int wxluatype); + // Get the lua_typename(lua_type(stack_idx)) as a wxString + WXDLLIMPEXP_WXLUA wxString LUACALL wxlua_gettypename(lua_State* L, int stack_idx); // Is this data a userdata object that wxLua has pushed into Lua? *************** *** 253,258 **** // Note: wxLua has a stricter sense of type than Lua and we don't want to // always allow coersion between types since oftentimes there's an error. ! // Note: The wxLuaState::IsStringType function takes both a Lua string and a wxString ! // userdata as valid strings. #define wxlua_isstringtype(L, stack_idx) (wxlua_iswxluatype(lua_type(L, stack_idx), WXLUAARG_String) == 1) #define wxlua_isbooleantype(L, stack_idx) (wxlua_iswxluatype(lua_type(L, stack_idx), WXLUAARG_Boolean) == 1) --- 325,329 ---- // Note: wxLua has a stricter sense of type than Lua and we don't want to // always allow coersion between types since oftentimes there's an error. ! WXDLLIMPEXP_WXLUA bool wxlua_iswxstringtype(lua_State* L, int stack_idx); #define wxlua_isstringtype(L, stack_idx) (wxlua_iswxluatype(lua_type(L, stack_idx), WXLUAARG_String) == 1) #define wxlua_isbooleantype(L, stack_idx) (wxlua_iswxluatype(lua_type(L, stack_idx), WXLUAARG_Boolean) == 1) *************** *** 266,269 **** --- 337,341 ---- // of both a Lua string and a userdata wxString to a wxString. WXDLLIMPEXP_WXLUA const char* LUACALL wxlua_getstringtype(lua_State* L, int stack_idx); + WXDLLIMPEXP_WXLUA wxString LUACALL wxlua_getwxstringtype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA bool LUACALL wxlua_getbooleantype(lua_State* L, int stack_idx); WXDLLIMPEXP_WXLUA long LUACALL wxlua_getintegertype(lua_State* L, int stack_idx); *************** *** 284,287 **** --- 356,382 ---- WXDLLIMPEXP_WXLUA const char** LUACALL wxlua_getchararray(lua_State* L, int stack_idx, int& count); + + // Convert a table or a wxArrayString object at the stack_idx to an array of wxStrings. + // If it's a table, it must have integer keys and string or wxString values. + // Returns a pointer to a new array of wxStrings and set the size in count. + // the return value will need to be deleted. + WXDLLIMPEXP_WXLUA wxString* LUACALL wxlua_getwxStringarray(lua_State* L, int stack_idx, int& count); + // Convert a table or a wxArrayInt object at the stack_idx to an array of integers. + // If it's a table, it must have integer keys and values. + // Returns a pointer to a new array of ints and set the size in count + // You must delete the return value if not NULL. + WXDLLIMPEXP_WXLUA int* LUACALL wxlua_getintarray(lua_State* L, int stack_idx, int& count); + + // Convert a table or a wxArrayString object at the stack_idx to a wxArrayString. + // If it's a table, it must have integer keys and string or wxString values. + WXDLLIMPEXP_WXLUA wxLuaSmartwxArrayString LUACALL wxlua_getwxArrayString(lua_State* L, int stack_idx); + // Convert a table or a wxSortedArrayString object at the stack_idx to a wxSortedArrayString. + // If it's a table, it must have integer keys and string or wxString values. + WXDLLIMPEXP_WXLUA wxLuaSmartwxSortedArrayString LUACALL wxlua_getwxSortedArrayString(lua_State* L, int stack_idx); + // Convert a table or a wxArrayInt object at the stack_idx to a wxArrayInt. + // If it's a table, it must have integer keys and values. + WXDLLIMPEXP_WXLUA wxLuaSmartwxArrayInt LUACALL wxlua_getwxArrayInt(lua_State* L, int stack_idx); + + // Creates a Lua table and pushes the strings into it, returns the number of items added // The table is left on the stack *************** *** 290,293 **** --- 385,390 ---- // The table is left on the stack WXDLLIMPEXP_WXLUA int LUACALL wxlua_pushwxArrayInttable(lua_State* L, const wxArrayInt& intArray); + // Push the wxString into Lua after converting it. + WXDLLIMPEXP_WXLUA void LUACALL wxlua_pushwxString(lua_State* L, const wxString& str); //---------------------------------------------------------------------------- *************** *** 311,321 **** WXDLLIMPEXP_WXLUA bool LUACALL wxlua_removederivedmethod(lua_State* L, void *pObject); ! // Get the value of the flag set to determine if a virtual C++ class member ! // function should call it's own base class function or a wxLua derived method. WXDLLIMPEXP_WXLUA bool LUACALL wxlua_getcallbaseclassfunction(lua_State*L); // Set if the class member function call has a prepended '_' to imply that // the user wants the base class function and not the derived method. WXDLLIMPEXP_WXLUA void LUACALL wxlua_setcallbaseclassfunction(lua_State*L, bool call_base); //---------------------------------------------------------------------------- // wxLuaStateData - the internal data for the wxLuaState. --- 408,459 ---- WXDLLIMPEXP_WXLUA bool LUACALL wxlua_removederivedmethod(lua_State* L, void *pObject); ! //---------------------------------------------------------------------------- ! // Other functions for wxLua's keys in the ! //---------------------------------------------------------------------------- ! ! // Get the wxlua_lreg_callbaseclassfunc_key value of the LUA_REGISTRYINDEX table ! // to determines whether a virtual C++ class member function should call it's own ! // base class function or a wxLua derived method. WXDLLIMPEXP_WXLUA bool LUACALL wxlua_getcallbaseclassfunction(lua_State*L); // Set if the class member function call has a prepended '_' to imply that // the user wants the base class function and not the derived method. + // Sets the wxlua_lreg_callbaseclassfunc_key value of the LUA_REGISTRYINDEX table. WXDLLIMPEXP_WXLUA void LUACALL wxlua_setcallbaseclassfunction(lua_State*L, bool call_base); + // Get the wxlua_lreg_wxeventtype_key value of the LUA_REGISTRYINDEX table + // to see if we're currently in a wxEvent callback. + WXDLLIMPEXP_WXLUA wxEventType LUACALL wxlua_getwxeventtype(lua_State*L); + // Set the wxlua_lreg_wxeventtype_key value of the LUA_REGISTRYINDEX table + // with the current wxEventType we're in or wxEVT_NULL if none. + WXDLLIMPEXP_WXLUA void LUACALL wxlua_setwxeventtype(lua_State*L, wxEventType evt_type); + + // Get the wxlua_lreg_wxluadebughookdata_key wxLuaDebugHookData value from + // the LUA_REGISTRYINDEX table for the owner wxLuaState. + // Note: It returns NULL if the lua_State is about to be closed. + WXDLLIMPEXP_WXLUA wxLuaDebugHookData* LUACALL wxlua_getwxluadebughookdata(lua_State*L); + + //---------------------------------------------------------------------------- + // wxLuaDebugHookData - data for setting/getting the debug hook settings + //---------------------------------------------------------------------------- + + class WXDLLIMPEXP_WXLUA wxLuaDebugHookData + { + public: + wxLuaDebugHookData() : m_lua_debug_hook_count(100), m_lua_debug_hook_yield(50), + m_lua_debug_hook_send_evt(false), m_lua_debug_hook(0), + m_last_debug_hook_time(0), + m_debug_hook_break(false), m_debug_hook_break_msg(wxT("Break")) {} + + int m_lua_debug_hook_count; // values from wxLuaState::SetLuaDebugHook() + int m_lua_debug_hook_yield; + bool m_lua_debug_hook_send_evt; + int m_lua_debug_hook; + + unsigned long m_last_debug_hook_time; // last time the debug hook was called + + bool m_debug_hook_break; // should the lua_State break for next debug_hook + wxString m_debug_hook_break_msg; // message when breaking in the debug_hook + }; + //---------------------------------------------------------------------------- // wxLuaStateData - the internal data for the wxLuaState. *************** *** 331,364 **** ~wxLuaStateData(); ! wxLuaBindingList m_bindingList; // A wxList of generated Lua bindings ! // that are loaded into Lua on startup ! bool m_bindings_registered; // Are the bindings registered into the lua_State ! ! wxEventType m_inEventType; // wxEventType set when in event, else wxEVT_NULL ! ! wxLongToLongHashMap m_trackedObjects; // tracked wxObjects that we will delete when the ! // wxLuaState is closed or Lua gc them. ! // key is (long)object* and value is the wxObject ! // Note that non wxObject classes use ! // wxLUA_DECLARE_ENCAPSULATION so the key is the object pointer ! // and the value is the wxObject encapsulation. ! wxWindowList m_windowList; // all wxWindow objects, wxWidgets will delete these ! // but for an embedded program they must be deleted before ! // shutting down the interpreter, else they dangle ! ! bool m_is_running; // is the lua_State running a script ! bool m_is_closing; // are we currently being closed ! bool m_debug_hook_break; // should the lua_State break for next debug_hook ! wxString m_debug_hook_break_msg; // message when breaking in the debug_hook ! unsigned long m_last_debug_hook_time; // last time the debug hook was called ! int m_lua_debug_hook_count; // values from SetLuaDebugHook ! int m_lua_debug_hook_yield; ! bool m_lua_debug_hook_send_evt; ! int m_lua_debug_hook; ! wxEvtHandler *m_evtHandler; // event handler to send wxLuaEvents to ! wxWindowID m_id; // event id to send the events with }; --- 469,483 ---- ~wxLuaStateData(); ! wxLuaBindingList m_bindingList; // A wxList of generated Lua bindings ! // that are loaded into Lua on startup ! bool m_bindings_registered; // Are the bindings registered into the lua_State ! bool m_is_running; // is the lua_State running a script ! bool m_is_closing; // are we currently being closed ! wxLuaDebugHookData m_debugHookData; // Data for the wxLuaState::SetLuaDebugHook() ! wxEvtHandler *m_evtHandler; // event handler to send wxLuaEvents to ! wxWindowID m_id; // event id to send the events with }; *************** *** 489,500 **** // ----------------------------------------------------------------------- - // Get the wxEventType that Lua may currently be in, wxEVT_NULL if not in an - // event handler. Be careful about destroying Lua when in an event handler. - wxEventType GetInEventType() const; - // Set the wxEventType that the Lua code is currently running (internal use) - void SetInEventType(wxEventType eventType); - - // ----------------------------------------------------------------------- - // Set the event handler that the wxLuaEvents from this will be sent to, can be NULL. // See wxEVT_LUA_XXX for a list of possible events that may be sent. --- 608,611 ---- *************** *** 551,554 **** --- 662,671 ---- static bool CheckRunError(int status, wxString *msg); + // Get the wxEventType that Lua may currently be in, wxEVT_NULL if not in an + // event handler. Be careful about destroying Lua when in an event handler. + wxEventType GetInEventType() const; + // Set the wxEventType that the Lua code is currently running (internal use) + void SetInEventType(wxEventType eventType); + // ----------------------------------------------------------------------- *************** *** 582,586 **** // Lua code and SetLuaDebugHook is turned on unsigned long GetLastLuaDebugHookTime() const; ! // Set to an arbitrary time to control debug timing void SetLastLuaDebugHookTime(unsigned long t); --- 699,703 ---- // Lua code and SetLuaDebugHook is turned on unsigned long GetLastLuaDebugHookTime() const; ! // Set to an specific time to control debug timing void SetLastLuaDebugHookTime(unsigned long t); *************** *** 636,648 **** // memory tracking functions (internal use) - enum RemoveTrackedObject_flags - { - UNDELETE_OBJECT = 0, // stop tracking for deletion (someone else owns this) - DELETE_OBJECT = 0x0001, // delete the object - CLEAR_TRACKED_OBJECT = 0x0002, // clear tracking the object in Lua reg table - CLEAR_DERIVED_METHODS = 0x0004, // clear any derived methods in Lua reg table - DELETE_CLEAR_OBJECT = DELETE_OBJECT|CLEAR_TRACKED_OBJECT|CLEAR_DERIVED_METHODS - }; - // Track this object and delete it when Lua calls the gc method for it void AddTrackedObject(wxObject *pObject); --- 753,756 ---- *************** *** 650,662 **** // pObject and delete it when Lua calls the gc method for it. // This is used for encapsulated classes that are wrapped in a wxObject. ! void AddTrackedObject(long obj_ptr, wxObject *pObject); // Remove the object from the tracked memory and optionally delete it. ! // flags are ored values of enum RemoveTrackedObject_flags bool RemoveTrackedObject(void *pObject, int flags); // Is this object currently tracked? bool IsTrackedObject(void *pObject) const; - // The the hashtable of [long object pointer] = [long wxObject (container) pointer] - // The key = value for wxObject derived classes, but are different for non wxObject classes. - wxLongToLongHashMap* GetTrackedObjects(); // Get an array of strings "wxObject_classname count#" wxArrayString GetTrackedObjectStrings(); --- 758,767 ---- // pObject and delete it when Lua calls the gc method for it. // This is used for encapsulated classes that are wrapped in a wxObject. ! void AddTrackedObject(const void* obj_ptr, wxObject *pObject); // Remove the object from the tracked memory and optionally delete it. ! // flags are ored values of enum wxLuaRemoveTrackedObject_flags bool RemoveTrackedObject(void *pObject, int flags); // Is this object currently tracked? bool IsTrackedObject(void *pObject) const; // Get an array of strings "wxObject_classname count#" wxArrayString GetTrackedObjectStrings(); *************** *** 667,677 **** // function for all objects with classinfo in the bindings and we // want to minimize the code in the bindings. ! bool AddTrackedWindow(wxObject *win); // Don't track this window anymore and don't delete it. ! bool RemoveTrackedWindow(wxWindow *win); // Is this window tracked, if check_parents see if a parent of it is. ! bool IsWindowTracked(wxWindow *win, bool check_parents = true) const; // Get an array of strings "wxWindow_classname count#" ! wxArrayString GetTrackedWindowStrings(); // delete all stray wxWindow derived classes that have been destroyed --- 772,782 ---- // function for all objects with classinfo in the bindings and we // want to minimize the code in the bindings. ! void AddTrackedWindow(wxObject *win); // Don't track this window anymore and don't delete it. ! void RemoveTrackedWindow(wxWindow *win); // Is this window tracked, if check_parents see if a parent of it is. ! bool IsTrackedWindow(wxWindow *win, bool check_parents = true) const; // Get an array of strings "wxWindow_classname count#" ! wxArrayString GetTrackedWindowStrings() const; // delete all stray wxWindow derived classes that have been destroyed *************** *** 684,688 **** bool RemoveTrackedCallback(wxLuaCallback* callback); // Get an array of strings "wxEVT_XXX (wxEventType #) count#" ! wxArrayString GetTrackedCallbackStrings(); // Add or remove a tracked wxLuaWinDestroyCallback connected to wxEVT_DESTROY. --- 789,793 ---- bool RemoveTrackedCallback(wxLuaCallback* callback); // Get an array of strings "wxEVT_XXX (wxEventType #) count#" ! wxArrayString GetTrackedCallbackStrings() const; // Add or remove a tracked wxLuaWinDestroyCallback connected to wxEVT_DESTROY. *************** *** 690,694 **** bool RemoveTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback); // Get an array of strings "wxWindow_classname count#" ! wxArrayString GetTrackedWinDestroyCallbackStrings(); // ----------------------------------------------------------------------- --- 795,799 ---- bool RemoveTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback); // Get an array of strings "wxWindow_classname count#" ! wxArrayString GetTrackedWinDestroyCallbackStrings() const; // ----------------------------------------------------------------------- *************** *** 698,701 **** --- 803,808 ---- wxLUA_UNICODE_ONLY(void wxlua_Error(const wxString& errorMsg) const { wxlua_Error(wx2lua(errorMsg)); }) + void* wxlua_ToUserdata(int stack_idx, bool null_ptr = false) const; + // ----------------------------------------------------------------------- // wxLua Lua Registry Table Functions *************** *** 704,713 **** bool wxluaR_Unref(int wxlref_index, const void* lightuserdata_reg_key); bool wxluaR_GetRef(int wxlref_index, const void* lightuserdata_reg_key); ! bool wxluaT_PushUserTag(const void *u, int tag, bool track); ! int wxluaT_GetTag(int stack_idx) const; ! void* wxlua_ToUserdata(int stack_idx, bool null_ptr = false) const; int wxluaT_NewTag(); bool wxluaT_SetTag(int tag); // ----------------------------------------------------------------------- // wxLua get data type --- 811,821 ---- bool wxluaR_Unref(int wxlref_index, const void* lightuserdata_reg_key); bool wxluaR_GetRef(int wxlref_index, const void* lightuserdata_reg_key); ! int wxluaT_NewTag(); + int wxluaT_GetTag(int stack_idx) const; bool wxluaT_SetTag(int tag); + bool wxluaT_PushUserTag(const void *u, int tag, bool track); + // ----------------------------------------------------------------------- // wxLua get data type *************** *** 721,729 **** // Check if the item at the Lua stack index is user data type tag bool IsUserDataType(int stack_idx, int tag) const; ! // Return a pointer to the object that corresponds to the specified stack ! // index and tag. Get a user data type either allocated by wxLua or a ! // system allocated tag. ! // If the data type does not have the correct tag, or if the parameter ! // stack_idx is nil, NULL is returned, otherwise wxlua_error is called. void* GetUserDataType(int stack_idx, int iTag) const; // Push a data type onto the stack and set its tag --- 829,836 ---- // Check if the item at the Lua stack index is user data type tag bool IsUserDataType(int stack_idx, int tag) const; ! // Get the userdata object at the stack_idx that is of the class type tag or a ! // class derived from the tag. ! // If the data type does not have the correct tag, or if the parameter isn't a ! // userdata then wxlua_error is called and NULL is returned. void* GetUserDataType(int stack_idx, int iTag) const; // Push a data type onto the stack and set its tag *************** *** 755,772 **** // be converted into the type by Lua, returns false if not (no errors) bool IsStringType(int stack_idx) const; bool IsBooleanType(int stack_idx) const; bool IsIntegerType(int stack_idx) const; bool IsNumberType(int stack_idx) const; ! // Validate that the object at the stack index specified is a table object ! // or a wxArrayString and convert it to an array of wxStrings. ! // If it's a table, this assumes that each numeric entry in the table is a ! // string object or can be converted to a string. // Returns a pointer to a new array of wxStrings and set the size in count. // the return value will need to be deleted. ! wxString* GetStringArray(int stack_idx, int &count); ! // Convert a parameter which is either an wxArrayString or a table into a wxArrayString. ! // returns the number of values in the array. ! int GetwxArrayString(int stack_idx, wxArrayString &strArray); // Convert a parameter which is presumably a table into a character pointer array. // returns the number of character strings in the array in count. --- 862,878 ---- // be converted into the type by Lua, returns false if not (no errors) bool IsStringType(int stack_idx) const; + bool IswxStringType(int stack_idx) const; bool IsBooleanType(int stack_idx) const; bool IsIntegerType(int stack_idx) const; bool IsNumberType(int stack_idx) const; ! // Convert a table or a wxArrayString object at the stack_idx to an array of wxStrings. ! // If it's a table, it must have integer keys and string or wxString values. // Returns a pointer to a new array of wxStrings and set the size in count. // the return value will need to be deleted. ! wxString* GetwxStringArray(int stack_idx, int &count); ! // Convert a table or a wxArrayString object at the stack_idx to a wxArrayString. ! // If it's a table, it must have integer keys and string or wxString values. ! wxLuaSmartwxArrayString GetwxArrayString(int stack_idx); // Convert a parameter which is presumably a table into a character pointer array. // returns the number of character strings in the array in count. *************** *** 774,787 **** const char** GetCharArray(int stack_idx, int &count); ! // Validate that the object at the stack index specified is a table object ! // or a wxArrayInt and convert it to an array of ints. ! // If it's a table, this assumes that each numeric entry in the table is a ! // numeric object or can be converted to a number // Returns a pointer to a new array of ints and set the size in count // You must delete the return value if not NULL. int* GetIntArray(int stack_idx, int &count); ! // convert a parameter which is presumably a table into a wxArrayInt. ! // returns the number of values put into the array. ! int GetwxArrayInt(int stack_idx, wxArrayInt &intArray); // Convert a wxArrayString object to a table of strings, returns number of values --- 880,891 ---- const char** GetCharArray(int stack_idx, int &count); ! // Convert a table or a wxArrayInt object at the stack_idx to an array of integers. ! // If it's a table, it must have integer keys and values. // Returns a pointer to a new array of ints and set the size in count // You must delete the return value if not NULL. int* GetIntArray(int stack_idx, int &count); ! // Convert a table or a wxArrayInt object at the stack_idx to a wxArrayInt. ! // If it's a table, it must have integer keys and values. ! wxLuaSmartwxArrayInt GetwxArrayInt(int stack_idx); // Convert a wxArrayString object to a table of strings, returns number of values *************** *** 848,852 **** int lua_Type(int index) const; wxString lua_TypeName(int type) const; - wxString lua_TypeNameIndex(int index) const { return lua_TypeName(lua_Type(index)); } int lua_Equal(int index1, int index2) const; --- 952,955 ---- Index: wxlua_bind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlua_bind.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** wxlua_bind.h 17 Nov 2007 00:15:01 -0000 1.6 --- wxlua_bind.h 7 Dec 2007 02:13:14 -0000 1.7 *************** *** 17,23 **** // the current version of the bindings. // See 'bindings/genwxbind.lua' and 'modules/wxlua/include/wxldefs.h' ! #if WXLUA_BINDING_VERSION > 18 # error "The WXLUA_BINDING_VERSION in the bindings is too old, regenerate bindings." ! #endif //WXLUA_BINDING_VERSION > 18 // --------------------------------------------------------------------------- --- 17,23 ---- // the current version of the bindings. // See 'bindings/genwxbind.lua' and 'modules/wxlua/include/wxldefs.h' ! #if WXLUA_BINDING_VERSION > 19 # error "The WXLUA_BINDING_VERSION in the bindings is too old, regenerate bindings." ! #endif //WXLUA_BINDING_VERSION > 19 // --------------------------------------------------------------------------- |
From: John L. <jr...@us...> - 2007-12-07 02:13:20
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv12976/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp wxlcallb.cpp wxlstate.cpp wxlua.cpp wxlua_bind.cpp Log Message: Too many changes to list... A large portion of the internal workings of the wxLuaState have been rewritten. All of the data that was stored in wxLuaStateData that might be needed by a function taking a lua_State* is now in the LUA_REGISTRYINDEX. C functions have been added to access these values. The generated bindings no longer need to have "wxLuaState wxlState(L);" since everything can be done with the C functions. The result is that wxLua should be faster. Index: wxlua.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** wxlua.cpp 1 Aug 2007 19:15:38 -0000 1.4 --- wxlua.cpp 7 Dec 2007 02:13:14 -0000 1.5 *************** *** 38,45 **** static int LUACALL wxLua_wxLuaState_delete(lua_State *L) { ! wxLuaState wxlState(L); ! wxLuaState * self = (wxLuaState *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaState); // if removed from tracked mem list, reset the tag so that gc() is not called on this object. ! if ((self != NULL) && wxlState.RemoveTrackedObject(self, wxLuaState::DELETE_CLEAR_OBJECT)) { lua_pushnil(L); --- 38,44 ---- static int LUACALL wxLua_wxLuaState_delete(lua_State *L) { ! wxLuaState * self = (wxLuaState *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaState); // if removed from tracked mem list, reset the tag so that gc() is not called on this object. ! if ((self != NULL) && wxluaO_removetrackedobject(L, self, wxLUA_DELETE_CLEAR_OBJECT)) { lua_pushnil(L); *************** *** 73,80 **** static int LUACALL wxLua_wxLuaObject_GetAllocationFlag(lua_State *L) { - wxLuaState wxlState(L); int returns; // get this ! wxLuaObject * self = (wxLuaObject *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaObject); // call GetAllocationFlag returns = (self->GetAllocationFlag()); --- 72,78 ---- static int LUACALL wxLua_wxLuaObject_GetAllocationFlag(lua_State *L) { int returns; // get this ! wxLuaObject * self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaObject); // call GetAllocationFlag returns = (self->GetAllocationFlag()); *************** *** 125,132 **** static int LUACALL wxLua_wxLuaObject_delete(lua_State *L) { ! wxLuaState wxlState(L); ! wxLuaObject * self = (wxLuaObject *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaObject); // if removed from tracked mem list, reset the tag so that gc() is not called on this object. ! if ((self != NULL) && wxlState.RemoveTrackedObject(self, wxLuaState::DELETE_CLEAR_OBJECT)) { lua_pushnil(L); --- 123,129 ---- static int LUACALL wxLua_wxLuaObject_delete(lua_State *L) { ! wxLuaObject * self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaObject); // if removed from tracked mem list, reset the tag so that gc() is not called on this object. ! if ((self != NULL) && wxluaO_removetrackedobject(L, self, wxLUA_DELETE_CLEAR_OBJECT)) { lua_pushnil(L); Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.144 retrieving revision 1.145 diff -C2 -d -r1.144 -r1.145 *** wxlstate.cpp 5 Dec 2007 05:54:11 -0000 1.144 --- wxlstate.cpp 7 Dec 2007 02:13:14 -0000 1.145 *************** *** 29,36 **** const char* wxlua_lreg_derivedmethods_key = "wxLua derived class methods"; const char* wxlua_lreg_wxluastate_key = "wxLuaState"; ! const char* wxlua_lreg_objects_key = "wxLua pushed userdata"; const char* wxlua_lreg_evtcallbacks_key = "wxLuaCallbacks"; const char* wxlua_lreg_windestroycallbacks_key = "wxLuaWinDestoyCallbacks"; const char* wxlua_lreg_callbaseclassfunc_key = "wxLua CallBaseClassFunc"; const char* wxlua_metatable_tag_key = "wxLua Metatable Class Tag"; --- 29,40 ---- const char* wxlua_lreg_derivedmethods_key = "wxLua derived class methods"; [...3071 lines suppressed...] --- 3788,3799 ---- wxArrayString wxLuaState::CreateMethodArgTagsMsg(struct wxLuaBindMethod* wxlMethod) { ! wxCHECK_MSG(Ok() && wxlMethod, wxArrayString(), wxT("Invalid wxLuaState or overloaded method table")); ! return wxlua_CreateMethodArgTagsMsg(M_WXLSTATEDATA->m_lua_State, wxlMethod); } int LUACALL wxLuaState::CallOverloadedFunction(struct wxLuaBindMethod* wxlMethod) { ! wxCHECK_MSG(Ok() && wxlMethod, 0, wxT("Invalid wxLuaState or overloaded method table")); ! return wxlua_CallOverloadedFunction(M_WXLSTATEDATA->m_lua_State, wxlMethod); } *************** *** 3855,3857 **** return 1; } - --- 3895,3896 ---- Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** wxlbind.cpp 5 Dec 2007 05:54:11 -0000 1.99 --- wxlbind.cpp 7 Dec 2007 02:13:14 -0000 1.100 *************** *** 89,92 **** --- 89,339 ---- } + // ---------------------------------------------------------------------------- + // Central function to call for overloaded functions + // ---------------------------------------------------------------------------- + + int LUACALL wxlua_CallOverloadedFunction(lua_State* L, struct wxLuaBindMethod* wxlMethod) + { + int i, arg; + int invalidArg = 0; + + // get number of arguments called from Lua + int argCount = lua_gettop(L); + int lua_argStart = 0; + + // don't remove the table, but do skip past it when counting args + bool remove_table = wxluabind_removetableforcall(L, true); + + if (remove_table) + { + argCount--; + lua_argStart++; + } + + // only look at the methods that could possibly work and traverse base classes + wxArrayPtrVoid funcArray; + wxLuaBindMethod* method = wxlMethod; + while (method) + { + for (i = 0; i < method->funcs_n; ++i) + { + if (!WXLUA_HASBIT(method->funcs[i].type, WXLUAMETHOD_OVERLOAD) && + (argCount >= method->funcs[i].minargs) && + (argCount <= method->funcs[i].maxargs)) + { + funcArray.Add(&method->funcs[i]); + } + + } + + method = method->basemethod; + } + + wxLuaBindCFunc* bestFunc = NULL; // store the last function that worked. + + // Look at the available functions in parallel, per arg + for (arg = 0; (arg < argCount) && (funcArray.GetCount() != 0); arg++) + { + int arg_lua = arg+1+lua_argStart; // arg N in Lua + int ltype = lua_type(L, arg_lua); + + for (i = 0; i < (int)funcArray.GetCount(); i++) + { + wxLuaBindCFunc* func = (wxLuaBindCFunc*)funcArray[i]; + bestFunc = func; + invalidArg = arg; + + int arg_wxlua = arg; // arg N in wxLuaArgTag + + // does this method have any more arguments? + if (!func->argtags[arg_wxlua]) + { + funcArray.RemoveAt(i); + i--; + continue; + } + + // get argument tag id + int tag = (int)*(func->argtags[arg_wxlua]); + + //wxPrintf(wxT("ARG '%s' type %d argCount %d arg %d arg_lua %d arg_wxlua %d ltype %d wxtype %d func_count %d/%d\n"), lua2wx(wxlMethod->name).c_str(), func->type, argCount, arg, arg_lua, arg_wxlua, ltype, tag, i, funcArray.GetCount()); + + // Does the Lua type match the wxlua arg tag type + int is_ok = wxlua_iswxluatype(ltype, tag, L); + + // unknown/invalid standard wxlua arg type, check binding tag + if ((is_ok == -1) || ((is_ok == 0) && (tag == WXLUAARG_String))) + { + is_ok = (wxlua_isuserdatatype(L, arg_lua, tag) || + (tag == g_wxluatag_NULL)) ? 1 : 0; + } + + // this arg is not a match, remove this function as a possibility + if (is_ok == 0) + { + funcArray.RemoveAt(i); + i--; + continue; + } + } + } + + // If there was a function that matched run it, if > 1 ??? + // Note that the top function is the one that is highest in the + // derived functions from any baseclasses and should be the best choice. + if (funcArray.GetCount() > 0) + { + lua_CFunction func = ((wxLuaBindCFunc*)funcArray[0])->func; + + // successfully found overloaded function to handle wxLua call + return (*func)(L); + } + + lua_Debug ar; + lua_getstack(L, 0, &ar); + lua_getinfo(L, "n", &ar); + wxString name = lua2wx(ar.name); + + // Build an error message + wxString fnCall = name + wxT("("); + for (arg = 0; arg < argCount; arg++) + { + if (arg > 0) + fnCall += wxT(", "); + + int ltype = lua_type(L, arg+1+lua_argStart); + + if (ltype != LUA_TUSERDATA) + { + fnCall += lua_typename(L, ltype); + } + else + { + int tag = wxluaT_gettag(L, arg+1+lua_argStart); + fnCall += wxluaT_gettagname(L, tag); + } + } + fnCall += wxT(")"); + + + wxString fnOverloadList = wxT("wxLua Function Overload Table:\n"); + wxArrayString overloadMethodArray = wxlua_CreateMethodArgTagsMsg(L, wxlMethod); + for (i = 0; i < (int)overloadMethodArray.GetCount(); i++) + fnOverloadList += overloadMethodArray[i] + wxT("\n"); + + wxString errmsg; + + if (funcArray.GetCount() > 1) + { + errmsg = wxT("wxLua Overloaded function call is ambiguous.\nTry coercing values to proper types using tostring/number as appropriate.\n"); + } + + if (bestFunc == NULL) + errmsg += wxString::Format(wxT("wxLua overloaded function %s has invalid argument\n%s"), fnCall.c_str(), fnOverloadList.c_str()); + else + { + // We have to count the methods that are displayed to find the one that failed. + // Since we're failing anyway, we don't need this to be fast. + method = wxlMethod; + int i_func = 0; + bool found = false; + while (method && !found) + { + for (i = 0; i < method->funcs_n; ++i) + { + i_func++; + if (&method->funcs[i] == bestFunc) + { + found = true; + break; + } + } + + method = method->basemethod; + } + + errmsg += wxString::Format(wxT("wxLua overloaded function %s has invalid argument %d on method %02d\n%s"), fnCall.c_str(), (invalidArg), i_func, fnOverloadList.c_str()); + } + + wxlua_error(L, errmsg); + + return 0; + } + + wxArrayString wxlua_CreateMethodArgTagsMsg(lua_State* L, struct wxLuaBindMethod* wxlMethod) + { + wxArrayString overloadMethodArray; + wxCHECK_MSG(wxlMethod, overloadMethodArray, wxT("Invalid method table")); + + wxLuaState wxlState(L); + + int i_func = 0; // count total number of overloads + wxLuaBindMethod* method = wxlMethod; + + // traverse the methods down the baseclass methods if any + while (method) + { + wxLuaBindCFunc* funcs = method->funcs; + int i, arg, funcs_count = method->funcs_n; + wxString className; + + const wxLuaBindClass* wxlClass = wxlState.GetBindClass(method); + if (wxlClass) + className = lua2wx(wxlClass->name) + wxT("::"); + + for (i = 0; i < funcs_count; i++) + { + i_func++; + + wxString fnOverload = wxString::Format(wxT("%02d. %s%s("), i_func, className.c_str(), lua2wx(method->name).c_str()); + + // overloaded function has invalid tags + if (WXLUA_HASBIT(funcs[i].type, WXLUAMETHOD_OVERLOAD)) + { + // However, we do print that there is an overload so that in CallOverloadedFunction + // we can find what function we were closest too. + fnOverload += wxT(" ... ) - overloaded function"); + } + else + { + for (arg = 0; arg < funcs[i].maxargs; arg++) + { + // optional args? + if ((funcs[i].minargs < funcs[i].maxargs) && (arg == funcs[i].minargs)) + fnOverload += wxT("["); + + if (arg > 0) + fnOverload += wxT(", "); + + int tag = (int)*(funcs[i].argtags[arg]); + + fnOverload += wxluaT_gettagname(L, tag); + + if ((arg == 0) && + !WXLUA_HASBIT(funcs[i].type, WXLUAMETHOD_STATIC) && + !WXLUA_HASBIT(funcs[i].type, WXLUAMETHOD_CONSTRUCTOR) && + !WXLUA_HASBIT(funcs[i].type, WXLUAMETHOD_CFUNCTION)) + fnOverload += wxT("(self)"); + } + + // close optional args + if (funcs[i].minargs < funcs[i].maxargs) + fnOverload += wxT("]"); + + fnOverload += wxT(")"); + + if (WXLUA_HASBIT(funcs[i].type, WXLUAMETHOD_STATIC)) + fnOverload += wxT(" - static"); + } + + overloadMethodArray.Add(fnOverload); + } + + method = method->basemethod; + } + + return overloadMethodArray; + } + //----------------------------------------------------------------------------- // wxLuaObject *************** *** 218,222 **** if ((m_reference != LUA_NOREF) && GetObject()) { ! m_wxlState->GetwxArrayInt(-1, *m_arrayInt); m_alloc_flag = wxLUAOBJECT_ARRAYINT; m_wxlState->lua_Pop(1); --- 465,469 ---- if ((m_reference != LUA_NOREF) && GetObject()) { ! *m_arrayInt = (wxArrayInt&)m_wxlState->GetwxArrayInt(-1); m_alloc_flag = wxLUAOBJECT_ARRAYINT; m_wxlState->lua_Pop(1); *************** *** 226,229 **** --- 473,559 ---- // ---------------------------------------------------------------------------- + // wxLuaSmartwxArrayString + // ---------------------------------------------------------------------------- + + class wxLuaSmartwxArrayStringRefData : public wxObjectRefData + { + public: + wxLuaSmartwxArrayStringRefData(wxArrayString* arr, int del) : m_arr(arr), m_delete(del) + { + if (!m_arr) { m_arr = new wxArrayString; m_delete = true; } // always exists + } + + virtual ~wxLuaSmartwxArrayStringRefData() { if (m_delete) delete m_arr; } + + wxArrayString *m_arr; + bool m_delete; + }; + + wxLuaSmartwxArrayString::wxLuaSmartwxArrayString(wxArrayString *arr, bool del) + { + m_refData = new wxLuaSmartwxArrayStringRefData(arr, del); + } + wxArrayString* wxLuaSmartwxArrayString::GetArray() const + { + return ((wxLuaSmartwxArrayStringRefData*)m_refData)->m_arr; + } + + // ---------------------------------------------------------------------------- + // wxLuaSmartwxSortedArrayString + // ---------------------------------------------------------------------------- + + class wxLuaSmartwxSortedArrayStringRefData : public wxObjectRefData + { + public: + wxLuaSmartwxSortedArrayStringRefData(wxSortedArrayString* arr, int del) : m_arr(arr), m_delete(del) + { + if (!m_arr) { m_arr = new wxSortedArrayString; m_delete = true; } // always exists + } + + virtual ~wxLuaSmartwxSortedArrayStringRefData() { if (m_delete) delete m_arr; } + + wxSortedArrayString *m_arr; + bool m_delete; + }; + + wxLuaSmartwxSortedArrayString::wxLuaSmartwxSortedArrayString(wxSortedArrayString *arr, bool del) + { + m_refData = new wxLuaSmartwxSortedArrayStringRefData(arr, del); + } + wxSortedArrayString* wxLuaSmartwxSortedArrayString::GetArray() const + { + return ((wxLuaSmartwxSortedArrayStringRefData*)m_refData)->m_arr; + } + + // ---------------------------------------------------------------------------- + // wxLuaSmartwxArrayInt + // ---------------------------------------------------------------------------- + + class wxLuaSmartwxArrayIntRefData : public wxObjectRefData + { + public: + wxLuaSmartwxArrayIntRefData(wxArrayInt* arr, int del) : m_arr(arr), m_delete(del) + { + if (!m_arr) { m_arr = new wxArrayInt; m_delete = true; } // always exists + } + + virtual ~wxLuaSmartwxArrayIntRefData() { if (m_delete) delete m_arr; } + + wxArrayInt *m_arr; + bool m_delete; + }; + + wxLuaSmartwxArrayInt::wxLuaSmartwxArrayInt(wxArrayInt *arr, bool del) + { + m_refData = new wxLuaSmartwxArrayIntRefData(arr, del); + } + + wxArrayInt* wxLuaSmartwxArrayInt::GetArray() const + { + return ((wxLuaSmartwxArrayIntRefData*)m_refData)->m_arr; + } + + + // ---------------------------------------------------------------------------- // wxlua_tableErrorHandler // ---------------------------------------------------------------------------- *************** *** 245,251 **** if ((wxlClass != NULL) && wxlua_iswxuserdata(L, 1) && (wxluaT_gettag(L, 1) == *wxlClass->class_tag)) { - wxLuaState wxlState(L); - wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); - void* key = wxlua_touserdata(L, 1, true); --- 575,578 ---- *************** *** 254,258 **** // clean up the rest of this, this won't error if the key doesn't exist ! wxlState.RemoveTrackedObject(key, wxLuaState::DELETE_CLEAR_OBJECT); } --- 581,585 ---- // clean up the rest of this, this won't error if the key doesn't exist ! wxluaO_removetrackedobject(L, key, wxLUA_DELETE_CLEAR_OBJECT); } Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** wxlcallb.cpp 5 Dec 2007 05:54:11 -0000 1.46 --- wxlcallb.cpp 7 Dec 2007 02:13:14 -0000 1.47 *************** *** 29,33 **** wxWindowID win_id, wxWindowID last_id, wxEventType eventType, wxEvtHandler *evtHandler) ! : wxObject(), m_routine(0), m_wxlState(wxlState), m_evtHandler(evtHandler), m_id(win_id), m_last_id(last_id), m_wxlBindEvent(NULL) --- 29,33 ---- wxWindowID win_id, wxWindowID last_id, wxEventType eventType, wxEvtHandler *evtHandler) ! : m_routine(0), m_wxlState(wxlState), m_evtHandler(evtHandler), m_id(win_id), m_last_id(last_id), m_wxlBindEvent(NULL) *************** *** 70,78 **** } void wxLuaCallback::EventHandler(wxEvent& event) { // Get the wxLuaCallback to use, NOT "this" since "this" is a central event handler function wxLuaCallback *theCallback = (wxLuaCallback *)event.m_callbackUserData; - wxCHECK_RET(theCallback != NULL, wxT("Invalid wxLuaCallback in wxEvent user data")); --- 70,87 ---- } + wxString wxLuaCallback::GetInfo() const + { + return wxString::Format(wxT("%s(%d) -> wxLuaCallback(%p, ids %d, %d)|wxEvtHandler(%p) -> %s"), + lua2wx(m_wxlBindEvent ? m_wxlBindEvent->name : "?").c_str(), (int)GetEventType(), + this, m_id, m_last_id, + m_evtHandler, m_evtHandler->GetClassInfo()->GetClassName()); + } + void wxLuaCallback::EventHandler(wxEvent& event) { + wxEventType evtType = event.GetEventType(); + // Get the wxLuaCallback to use, NOT "this" since "this" is a central event handler function wxLuaCallback *theCallback = (wxLuaCallback *)event.m_callbackUserData; wxCHECK_RET(theCallback != NULL, wxT("Invalid wxLuaCallback in wxEvent user data")); *************** *** 81,96 **** if (wxlState.Ok()) { - wxEventType evtType = event.GetEventType(); - wxlState.SetInEventType(evtType); - theCallback->CallFunction(&event); - - // we want the wxLuaWinDestroyCallback to get this too - if (evtType == wxEVT_DESTROY) - event.Skip(); - wxlState.SetInEventType(wxEVT_NULL); } } --- 90,101 ---- if (wxlState.Ok()) { wxlState.SetInEventType(evtType); theCallback->CallFunction(&event); wxlState.SetInEventType(wxEVT_NULL); } + + // we want the wxLuaWinDestroyCallback to get this too + if (evtType == wxEVT_DESTROY) + event.Skip(); } *************** *** 158,162 **** wxLuaWinDestroyCallback::wxLuaWinDestroyCallback(const wxLuaState& wxlState, wxWindow* win, int iTag) ! :wxObject(), m_wxlState(wxlState), m_window(win) { wxCHECK_RET(m_wxlState.Ok(), wxT("Invalid wxLuaState")); --- 163,167 ---- wxLuaWinDestroyCallback::wxLuaWinDestroyCallback(const wxLuaState& wxlState, wxWindow* win, int iTag) ! :m_wxlState(wxlState), m_window(win) { wxCHECK_RET(m_wxlState.Ok(), wxT("Invalid wxLuaState")); *************** *** 179,182 **** --- 184,198 ---- } + wxString wxLuaWinDestroyCallback::GetInfo() const + { + wxString winName(wxT("wxWindow?")); + if (m_window && m_window->GetClassInfo() && m_window->GetClassInfo()->GetClassName()) + winName = m_window->GetClassInfo()->GetClassName(); + + return wxString::Format(wxT("%s(%p, id=%d)|wxLuaDestroyCallback(%p)"), + winName.c_str(), m_window, m_window ? m_window->GetId() : -1, + this); + } + void wxLuaWinDestroyCallback::EventHandler(wxWindowDestroyEvent& event) { *************** *** 203,207 **** wxluaO_cleartrackedmetatable(m_wxlState.GetLuaState(), m_window); // Now remove the object since it's gone ! m_wxlState.RemoveTrackedObject(m_window, wxLuaState::CLEAR_TRACKED_OBJECT|wxLuaState::CLEAR_DERIVED_METHODS); // Clear our own pointer to this window m_wxlState.RemoveTrackedWindow(m_window); --- 219,223 ---- wxluaO_cleartrackedmetatable(m_wxlState.GetLuaState(), m_window); // Now remove the object since it's gone ! m_wxlState.RemoveTrackedObject(m_window, wxLUA_CLEAR_TRACKED_OBJECT|wxLUA_CLEAR_DERIVED_METHODS); // Clear our own pointer to this window m_wxlState.RemoveTrackedWindow(m_window); *************** *** 241,245 **** } else ! lua_pop(L, 1); // pop value, lua_next will pop key at end } --- 257,261 ---- } else ! lua_pop(L, 1); // pop value, lua_next will pop key at end } Index: wxlua_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua_bind.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** wxlua_bind.cpp 5 Dec 2007 05:54:11 -0000 1.12 --- wxlua_bind.cpp 7 Dec 2007 02:13:14 -0000 1.13 *************** *** 745,761 **** { wxLuaState wxlState(L); ! wxArrayString strArr = wxlState.GetTrackedCallbackStrings(); ! size_t n, count = strArr.GetCount(); ! long val = 0; ! lua_createtable(L, 0, count); ! ! for (n = 0; n < count; ++n) ! { ! lua_pushstring(L, wx2lua(strArr[n].BeforeFirst(wxT(' ')))); ! strArr[n].AfterLast(wxT(' ')).ToLong(&val); ! lua_pushnumber(L, (double)val); ! lua_rawset(L, -3); ! } ! return 1; } --- 745,749 ---- { wxLuaState wxlState(L); ! wxlua_pushwxArrayStringtable(L, wxlState.GetTrackedCallbackStrings()); return 1; } *************** *** 768,784 **** { wxLuaState wxlState(L); ! wxArrayString strArr = wxlState.GetTrackedWindowStrings(); ! size_t n, count = strArr.GetCount(); ! long val = 0; ! lua_createtable(L, 0, count); ! ! for (n = 0; n < count; ++n) ! { ! lua_pushstring(L, wx2lua(strArr[n].BeforeLast(wxT(' ')))); ! strArr[n].AfterLast(wxT(' ')).ToLong(&val); ! lua_pushnumber(L, (double)val); ! lua_rawset(L, -3); ! } ! return 1; } --- 756,760 ---- { wxLuaState wxlState(L); ! wxlua_pushwxArrayStringtable(L, wxlState.GetTrackedWindowStrings()); return 1; } *************** *** 791,807 **** { wxLuaState wxlState(L); ! wxArrayString strArr = wxlState.GetTrackedObjectStrings(); ! size_t n, count = strArr.GetCount(); ! long val = 0; ! lua_createtable(L, 0, count); ! ! for (n = 0; n < count; ++n) ! { ! lua_pushstring(L, wx2lua(strArr[n].BeforeLast(wxT(' ')))); ! strArr[n].AfterLast(wxT(' ')).ToLong(&val); ! lua_pushnumber(L, (double)val); ! lua_rawset(L, -3); ! } ! return 1; } --- 767,771 ---- { wxLuaState wxlState(L); ! wxlua_pushwxArrayStringtable(L, wxlState.GetTrackedObjectStrings()); return 1; } *************** *** 814,830 **** { wxLuaState wxlState(L); ! wxArrayString strArr = wxlState.GetTrackedWinDestroyCallbackStrings(); ! size_t n, count = strArr.GetCount(); ! long val = 0; ! lua_createtable(L, 0, count); ! ! for (n = 0; n < count; ++n) ! { ! lua_pushstring(L, wx2lua(strArr[n].BeforeLast(wxT(' ')))); ! strArr[n].AfterLast(wxT(' ')).ToLong(&val); ! lua_pushnumber(L, (double)val); ! lua_rawset(L, -3); ! } ! return 1; } --- 778,782 ---- { wxLuaState wxlState(L); ! wxlua_pushwxArrayStringtable(L, wxlState.GetTrackedWinDestroyCallbackStrings()); return 1; } |
From: John L. <jr...@us...> - 2007-12-07 02:13:20
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv12976/wxLua/modules/wxluasocket/src Modified Files: wxluasocket.cpp Log Message: Too many changes to list... A large portion of the internal workings of the wxLuaState have been rewritten. All of the data that was stored in wxLuaStateData that might be needed by a function taking a lua_State* is now in the LUA_REGISTRYINDEX. C functions have been added to access these values. The generated bindings no longer need to have "wxLuaState wxlState(L);" since everything can be done with the C functions. The result is that wxLua should be faster. Index: wxluasocket.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxluasocket.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** wxluasocket.cpp 1 Aug 2007 19:15:38 -0000 1.31 --- wxluasocket.cpp 7 Dec 2007 02:13:14 -0000 1.32 *************** *** 33,44 **** static int LUACALL wxLua_wxLuaDebuggerServer_AddBreakPoint(lua_State *L) { - wxLuaState wxlState(L); bool returns; // int lineNumber int lineNumber = (int)wxlua_getnumbertype(L, 3); // const wxString fileName ! const wxString fileName = wxlState.GetwxStringType(2); // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call AddBreakPoint returns = (self->AddBreakPoint(fileName, lineNumber)); --- 33,43 ---- static int LUACALL wxLua_wxLuaDebuggerServer_AddBreakPoint(lua_State *L) { bool returns; // int lineNumber int lineNumber = (int)wxlua_getnumbertype(L, 3); // const wxString fileName ! const wxString fileName = wxlua_getwxstringtype(L, 2); // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call AddBreakPoint returns = (self->AddBreakPoint(fileName, lineNumber)); *************** *** 55,62 **** static int LUACALL wxLua_wxLuaDebuggerServer_Break(lua_State *L) { - wxLuaState wxlState(L); bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call Break returns = (self->Break()); --- 54,60 ---- static int LUACALL wxLua_wxLuaDebuggerServer_Break(lua_State *L) { bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call Break returns = (self->Break()); *************** *** 73,80 **** static int LUACALL wxLua_wxLuaDebuggerServer_ClearAllBreakPoints(lua_State *L) { - wxLuaState wxlState(L); bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call ClearAllBreakPoints returns = (self->ClearAllBreakPoints()); --- 71,77 ---- static int LUACALL wxLua_wxLuaDebuggerServer_ClearAllBreakPoints(lua_State *L) { bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call ClearAllBreakPoints returns = (self->ClearAllBreakPoints()); *************** *** 91,98 **** static int LUACALL wxLua_wxLuaDebuggerServer_Continue(lua_State *L) { - wxLuaState wxlState(L); bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call Continue returns = (self->Continue()); --- 88,94 ---- static int LUACALL wxLua_wxLuaDebuggerServer_Continue(lua_State *L) { bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call Continue returns = (self->Continue()); *************** *** 109,113 **** static int LUACALL wxLua_wxLuaDebuggerServer_DisplayStackDialog(lua_State *L) { - wxLuaState wxlState(L); // get number of arguments int argCount = lua_gettop(L); --- 105,108 ---- *************** *** 115,121 **** wxWindowID id = (argCount >= 3 ? (wxWindowID)wxlua_getnumbertype(L, 3) : wxID_ANY); // wxWindow pParent ! wxWindow * pParent = (wxWindow *)wxlState.GetUserDataType(2, s_wxluatag_wxWindow); // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call DisplayStackDialog self->DisplayStackDialog(pParent, id); --- 110,116 ---- wxWindowID id = (argCount >= 3 ? (wxWindowID)wxlua_getnumbertype(L, 3) : wxID_ANY); // wxWindow pParent ! wxWindow * pParent = (wxWindow *)wxluaT_getuserdatatype(L, 2, s_wxluatag_wxWindow); // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call DisplayStackDialog self->DisplayStackDialog(pParent, id); *************** *** 130,141 **** static int LUACALL wxLua_wxLuaDebuggerServer_EvaluateExpr(lua_State *L) { - wxLuaState wxlState(L); bool returns; // const wxString expr ! const wxString expr = wxlState.GetwxStringType(3); // int exprRef int exprRef = (int)wxlua_getnumbertype(L, 2); // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call EvaluateExpr returns = (self->EvaluateExpr(exprRef, expr)); --- 125,135 ---- static int LUACALL wxLua_wxLuaDebuggerServer_EvaluateExpr(lua_State *L) { bool returns; // const wxString expr ! const wxString expr = wxlua_getwxstringtype(L, 3); // int exprRef int exprRef = (int)wxlua_getnumbertype(L, 2); // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call EvaluateExpr returns = (self->EvaluateExpr(exprRef, expr)); *************** *** 152,159 **** static int LUACALL wxLua_wxLuaDebuggerServer_GetDebuggeeProcessId(lua_State *L) { - wxLuaState wxlState(L); long returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call GetDebuggeeProcessId returns = (self->GetDebuggeeProcessId()); --- 146,152 ---- static int LUACALL wxLua_wxLuaDebuggerServer_GetDebuggeeProcessId(lua_State *L) { long returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call GetDebuggeeProcessId returns = (self->GetDebuggeeProcessId()); *************** *** 169,178 **** static int LUACALL wxLua_wxLuaDebuggerServer_GetNetworkName(lua_State *L) { - wxLuaState wxlState(L); wxString returns; // call GetNetworkName returns = (wxLuaDebuggerServer::GetNetworkName()); // push the result string ! wxlState.lua_PushString(returns); return 1; --- 162,170 ---- static int LUACALL wxLua_wxLuaDebuggerServer_GetNetworkName(lua_State *L) { wxString returns; // call GetNetworkName returns = (wxLuaDebuggerServer::GetNetworkName()); // push the result string ! wxlua_pushwxString(L, returns); return 1; *************** *** 184,193 **** static int LUACALL wxLua_wxLuaDebuggerServer_GetProgramName(lua_State *L) { - wxLuaState wxlState(L); wxString returns; // call GetProgramName returns = (wxLuaDebuggerServer::GetProgramName()); // push the result string ! wxlState.lua_PushString(returns); return 1; --- 176,184 ---- static int LUACALL wxLua_wxLuaDebuggerServer_GetProgramName(lua_State *L) { wxString returns; // call GetProgramName returns = (wxLuaDebuggerServer::GetProgramName()); // push the result string ! wxlua_pushwxString(L, returns); return 1; *************** *** 200,207 **** static int LUACALL wxLua_wxLuaDebuggerServer_KillDebuggee(lua_State *L) { - wxLuaState wxlState(L); bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call KillDebuggee returns = (self->KillDebuggee()); --- 191,197 ---- static int LUACALL wxLua_wxLuaDebuggerServer_KillDebuggee(lua_State *L) { bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call KillDebuggee returns = (self->KillDebuggee()); *************** *** 218,229 **** static int LUACALL wxLua_wxLuaDebuggerServer_RemoveBreakPoint(lua_State *L) { - wxLuaState wxlState(L); bool returns; // int lineNumber int lineNumber = (int)wxlua_getnumbertype(L, 3); // const wxString fileName ! const wxString fileName = wxlState.GetwxStringType(2); // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call RemoveBreakPoint returns = (self->RemoveBreakPoint(fileName, lineNumber)); --- 208,218 ---- static int LUACALL wxLua_wxLuaDebuggerServer_RemoveBreakPoint(lua_State *L) { bool returns; // int lineNumber int lineNumber = (int)wxlua_getnumbertype(L, 3); // const wxString fileName ! const wxString fileName = wxlua_getwxstringtype(L, 2); // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call RemoveBreakPoint returns = (self->RemoveBreakPoint(fileName, lineNumber)); *************** *** 240,247 **** static int LUACALL wxLua_wxLuaDebuggerServer_Reset(lua_State *L) { - wxLuaState wxlState(L); bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call Reset returns = (self->Reset()); --- 229,235 ---- static int LUACALL wxLua_wxLuaDebuggerServer_Reset(lua_State *L) { bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call Reset returns = (self->Reset()); *************** *** 258,269 **** static int LUACALL wxLua_wxLuaDebuggerServer_Run(lua_State *L) { - wxLuaState wxlState(L); bool returns; // const wxString fileName ! const wxString fileName = wxlState.GetwxStringType(3); // const wxString file ! const wxString file = wxlState.GetwxStringType(2); // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call Run returns = (self->Run(file, fileName)); --- 246,256 ---- static int LUACALL wxLua_wxLuaDebuggerServer_Run(lua_State *L) { bool returns; // const wxString fileName ! const wxString fileName = wxlua_getwxstringtype(L, 3); // const wxString file ! const wxString file = wxlua_getwxstringtype(L, 2); // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call Run returns = (self->Run(file, fileName)); *************** *** 280,287 **** static int LUACALL wxLua_wxLuaDebuggerServer_StartClient(lua_State *L) { - wxLuaState wxlState(L); long returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call StartClient returns = (self->StartClient()); --- 267,273 ---- static int LUACALL wxLua_wxLuaDebuggerServer_StartClient(lua_State *L) { long returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call StartClient returns = (self->StartClient()); *************** *** 298,305 **** static int LUACALL wxLua_wxLuaDebuggerServer_StartServer(lua_State *L) { - wxLuaState wxlState(L); bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call StartServer returns = (self->StartServer()); --- 284,290 ---- static int LUACALL wxLua_wxLuaDebuggerServer_StartServer(lua_State *L) { bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call StartServer returns = (self->StartServer()); *************** *** 316,323 **** static int LUACALL wxLua_wxLuaDebuggerServer_Step(lua_State *L) { - wxLuaState wxlState(L); bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call Step returns = (self->Step()); --- 301,307 ---- static int LUACALL wxLua_wxLuaDebuggerServer_Step(lua_State *L) { bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call Step returns = (self->Step()); *************** *** 334,341 **** static int LUACALL wxLua_wxLuaDebuggerServer_StepOut(lua_State *L) { - wxLuaState wxlState(L); bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call StepOut returns = (self->StepOut()); --- 318,324 ---- static int LUACALL wxLua_wxLuaDebuggerServer_StepOut(lua_State *L) { bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call StepOut returns = (self->StepOut()); *************** *** 352,359 **** static int LUACALL wxLua_wxLuaDebuggerServer_StepOver(lua_State *L) { - wxLuaState wxlState(L); bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call StepOver returns = (self->StepOver()); --- 335,341 ---- static int LUACALL wxLua_wxLuaDebuggerServer_StepOver(lua_State *L) { bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call StepOver returns = (self->StepOver()); *************** *** 370,377 **** static int LUACALL wxLua_wxLuaDebuggerServer_StopServer(lua_State *L) { - wxLuaState wxlState(L); bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // call StopServer returns = (self->StopServer()); --- 352,358 ---- static int LUACALL wxLua_wxLuaDebuggerServer_StopServer(lua_State *L) { bool returns; // get this ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // call StopServer returns = (self->StopServer()); *************** *** 387,394 **** static int LUACALL wxLua_wxLuaDebuggerServer_delete(lua_State *L) { ! wxLuaState wxlState(L); ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerServer); // if removed from tracked mem list, reset the tag so that gc() is not called on this object. ! if ((self != NULL) && wxlState.RemoveTrackedObject(self, wxLuaState::DELETE_CLEAR_OBJECT)) { lua_pushnil(L); --- 368,374 ---- static int LUACALL wxLua_wxLuaDebuggerServer_delete(lua_State *L) { ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); // if removed from tracked mem list, reset the tag so that gc() is not called on this object. ! if ((self != NULL) && wxluaO_removetrackedobject(L, self, wxLUA_DELETE_CLEAR_OBJECT)) { lua_pushnil(L); *************** *** 405,409 **** { wxluabind_removetableforcall(L); - wxLuaState wxlState(L); wxLuaDebuggerServer *returns; // int portNumber --- 385,388 ---- *************** *** 412,418 **** returns = new wxLuaDebuggerServer(portNumber); // add to tracked memory list ! wxlState.AddTrackedObject(returns); // push the constructed class pointer ! wxlState.PushUserDataType(s_wxluatag_wxLuaDebuggerServer, returns); return 1; --- 391,397 ---- returns = new wxLuaDebuggerServer(portNumber); // add to tracked memory list ! wxluaO_addtrackedobject(L, returns); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, s_wxluatag_wxLuaDebuggerServer, returns); return 1; *************** *** 463,474 **** static int LUACALL wxLua_wxLuaDebuggerEvent_GetFileName(lua_State *L) { - wxLuaState wxlState(L); wxString returns; // get this ! wxLuaDebuggerEvent * self = (wxLuaDebuggerEvent *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerEvent); // call GetFileName returns = (self->GetFileName()); // push the result string ! wxlState.lua_PushString(returns); return 1; --- 442,452 ---- static int LUACALL wxLua_wxLuaDebuggerEvent_GetFileName(lua_State *L) { wxString returns; // get this ! wxLuaDebuggerEvent * self = (wxLuaDebuggerEvent *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerEvent); // call GetFileName returns = (self->GetFileName()); // push the result string ! wxlua_pushwxString(L, returns); return 1; *************** *** 481,488 **** static int LUACALL wxLua_wxLuaDebuggerEvent_GetLineNumber(lua_State *L) { - wxLuaState wxlState(L); int returns; // get this ! wxLuaDebuggerEvent * self = (wxLuaDebuggerEvent *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerEvent); // call GetLineNumber returns = (self->GetLineNumber()); --- 459,465 ---- static int LUACALL wxLua_wxLuaDebuggerEvent_GetLineNumber(lua_State *L) { int returns; // get this ! wxLuaDebuggerEvent * self = (wxLuaDebuggerEvent *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerEvent); // call GetLineNumber returns = (self->GetLineNumber()); *************** *** 499,510 **** static int LUACALL wxLua_wxLuaDebuggerEvent_GetMessage(lua_State *L) { - wxLuaState wxlState(L); wxString returns; // get this ! wxLuaDebuggerEvent * self = (wxLuaDebuggerEvent *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerEvent); // call GetMessage returns = (self->GetMessage()); // push the result string ! wxlState.lua_PushString(returns); return 1; --- 476,486 ---- static int LUACALL wxLua_wxLuaDebuggerEvent_GetMessage(lua_State *L) { wxString returns; // get this ! wxLuaDebuggerEvent * self = (wxLuaDebuggerEvent *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerEvent); // call GetMessage returns = (self->GetMessage()); // push the result string ! wxlua_pushwxString(L, returns); return 1; *************** *** 517,524 **** static int LUACALL wxLua_wxLuaDebuggerEvent_GetReference(lua_State *L) { - wxLuaState wxlState(L); int returns; // get this ! wxLuaDebuggerEvent * self = (wxLuaDebuggerEvent *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerEvent); // call GetReference returns = (self->GetReference()); --- 493,499 ---- static int LUACALL wxLua_wxLuaDebuggerEvent_GetReference(lua_State *L) { int returns; // get this ! wxLuaDebuggerEvent * self = (wxLuaDebuggerEvent *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerEvent); // call GetReference returns = (self->GetReference()); *************** *** 534,541 **** static int LUACALL wxLua_wxLuaDebuggerEvent_delete(lua_State *L) { ! wxLuaState wxlState(L); ! wxLuaDebuggerEvent * self = (wxLuaDebuggerEvent *)wxlState.GetUserDataType(1, s_wxluatag_wxLuaDebuggerEvent); // if removed from tracked mem list, reset the tag so that gc() is not called on this object. ! if ((self != NULL) && wxlState.RemoveTrackedObject(self, wxLuaState::DELETE_CLEAR_OBJECT)) { lua_pushnil(L); --- 509,515 ---- static int LUACALL wxLua_wxLuaDebuggerEvent_delete(lua_State *L) { ! wxLuaDebuggerEvent * self = (wxLuaDebuggerEvent *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerEvent); // if removed from tracked mem list, reset the tag so that gc() is not called on this object. ! if ((self != NULL) && wxluaO_removetrackedobject(L, self, wxLUA_DELETE_CLEAR_OBJECT)) { lua_pushnil(L); |
From: John L. <jr...@us...> - 2007-12-07 02:13:20
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv12976/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: Too many changes to list... A large portion of the internal workings of the wxLuaState have been rewritten. All of the data that was stored in wxLuaStateData that might be needed by a function taking a lua_State* is now in the LUA_REGISTRYINDEX. C functions have been added to access these values. The generated bindings no longer need to have "wxLuaState wxlState(L);" since everything can be done with the C functions. The result is that wxLua should be faster. Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** wxlstack.cpp 5 Dec 2007 00:34:46 -0000 1.24 --- wxlstack.cpp 7 Dec 2007 02:13:14 -0000 1.25 *************** *** 42,48 **** #define DUMMY_TREEITEM wxT(" ") - #define WXLUAARG_WXLUADATA (WXLUAARG__MIN - 100) - - // ---------------------------------------------------------------------------- // wxLuaStackListCtrl --- 42,45 ---- *************** *** 428,433 **** case WXLUAARG_Integer : img = IMG_INTEGER; break; case WXLUAARG_CFunction : img = IMG_CFUNCTION; break; - - case WXLUAARG_WXLUADATA : img = IMG_TABLE; break; } } --- 425,428 ---- *************** *** 576,582 **** } } - - if (m_wxlState.Ok()) - GetDerivedAndTrackedItems(); } --- 571,574 ---- *************** *** 671,699 **** } - void wxLuaStackDialog::GetDerivedAndTrackedItems() - { - wxLuaState wxlState(m_wxlState); - wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); - - int trackedCount = wxlState.GetTrackedObjectStrings().GetCount(); - int callbackCount = wxlState.GetTrackedCallbackStrings().GetCount(); - int windowCount = wxlState.GetTrackedWindowStrings().GetCount(); - int destroyCount = wxlState.GetTrackedWinDestroyCallbackStrings().GetCount(); - - // note: don't have spaces here since we use them to mark expanded levels - wxLuaDebugItem* trackedItem = new wxLuaDebugItem(_("Tracked User Data"), WXLUAARG_None, wxString::Format(wxT("Count %d"), trackedCount), WXLUAARG_WXLUADATA, wxT(""), LUA_NOREF, 0); - wxLuaDebugItem* callbackItem = new wxLuaDebugItem(_("wxEvent Callbacks"), WXLUAARG_None, wxString::Format(wxT("Count %d"), callbackCount), WXLUAARG_WXLUADATA, wxT(""), LUA_NOREF, 0); - wxLuaDebugItem* windowItem = new wxLuaDebugItem(_("Top Level wxWindows"), WXLUAARG_None, wxString::Format(wxT("Count %d"), windowCount), WXLUAARG_WXLUADATA, wxT(""), LUA_NOREF, 0); - wxLuaDebugItem* destroyItem = new wxLuaDebugItem(_("wxWindow Destroy List"), WXLUAARG_None, wxString::Format(wxT("Count %d"), destroyCount), WXLUAARG_WXLUADATA, wxT(""), LUA_NOREF, 0); - - wxLuaDebugData dataArr(true); // this deletes the items - dataArr.Add(trackedItem); - dataArr.Add(callbackItem); - dataArr.Add(windowItem); - dataArr.Add(destroyItem); - - FillTableEntry(m_listData.GetCount(), dataArr); - } - void wxLuaStackDialog::BeginBatch() { --- 663,666 ---- *************** *** 1068,1104 **** } ! // Check our special variables for the wxLuaState data ! if (m_wxlState.Ok() && (debugItem->GetValueType() == WXLUAARG_WXLUADATA)) ! { ! wxLuaState wxlState(m_wxlState); ! wxArrayString strArr; ! ! if (debugItem->GetKey() == _("Tracked User Data")) ! strArr = wxlState.GetTrackedObjectStrings(); ! else if (debugItem->GetKey() == _("wxEvent Callbacks")) ! strArr = wxlState.GetTrackedCallbackStrings(); ! else if (debugItem->GetKey() == _("Top Level wxWindows")) ! strArr = wxlState.GetTrackedWindowStrings(); ! else if (debugItem->GetKey() == _("wxWindow Destroy List")) ! strArr = wxlState.GetTrackedWinDestroyCallbackStrings(); ! else ! wxFAIL_MSG(wxT("Unknown key name with WXLUAARG_WXLUADATA")); ! ! debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); ! ! wxLuaDebugData dataArr(true); ! size_t n, count = strArr.GetCount(); ! for (n = 0; n < count; n++) ! { ! wxLuaDebugItem *item = new wxLuaDebugItem(strArr[n].BeforeLast(wxT(' ')), WXLUAARG_None, ! strArr[n].AfterLast(wxT(' ')), WXLUAARG_None, ! wxT(""), LUA_NOREF, debugItem->GetIndex() + 1); ! dataArr.Add(item); ! } ! ! FillTableEntry(lc_item, dataArr); ! expanded = true; ! } ! else if (nRef != LUA_NOREF) { debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); --- 1035,1039 ---- } ! if (nRef != LUA_NOREF) { debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** wxldebug.cpp 5 Dec 2007 00:34:46 -0000 1.55 --- wxldebug.cpp 7 Dec 2007 02:13:14 -0000 1.56 *************** *** 19,22 **** --- 19,23 ---- #include "wxluadebug/include/wxldebug.h" + #include "wxlua/include/wxlcallb.h" wxLuaDebugData wxNullLuaDebugData(false); *************** *** 283,286 **** --- 284,322 ---- if (wxlState.wxluaR_GetRef(tableRef, &wxlua_lreg_debug_refs_key)) { + bool is_wxlua_lreg_evtcallbacks_key = false; + bool is_wxlua_lreg_windestroycallbacks_key = false; + bool is_wxlua_lreg_topwindows_key = false; + bool is_wxlua_lreg_delobjects_key = false; + + // See if this is one of wxLua's registry tables + lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + is_wxlua_lreg_evtcallbacks_key = lua_equal(L, -1, -2); + lua_pop(L, 1); + + if (!is_wxlua_lreg_evtcallbacks_key) + { + lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + is_wxlua_lreg_windestroycallbacks_key = lua_equal(L, -1, -2); + lua_pop(L, 1); + + if (!is_wxlua_lreg_windestroycallbacks_key) + { + lua_pushlightuserdata(L, &wxlua_lreg_topwindows_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + is_wxlua_lreg_topwindows_key = lua_equal(L, -1, -2); + lua_pop(L, 1); + + if (!is_wxlua_lreg_topwindows_key) + { + lua_pushlightuserdata(L, &wxlua_lreg_delobjects_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + is_wxlua_lreg_delobjects_key = lua_equal(L, -1, -2); + lua_pop(L, 1); + } + } + } + if (lua_getmetatable(L, -1)) // if no metatable then nothing is pushed { *************** *** 301,304 **** --- 337,342 ---- while (lua_next(L, -2) != 0) { + // value at -1, key at -2, table at -3 + // get the index, just want the name=value, type is dummy here GetTypeValue(wxlState, -2, &wxl_keytype, name); *************** *** 306,316 **** GetTypeValue(wxlState, -1, &wxl_valuetype, value); int flag_type = 0; int nRef = RefTable(L, -1, &flag_type, references); - lua_pop(L, 1); - Add(new wxLuaDebugItem(name, wxl_keytype, value, wxl_valuetype, wxT(""), nRef, nIndex, flag_type)); count++; } --- 344,385 ---- GetTypeValue(wxlState, -1, &wxl_valuetype, value); + // Handle special tables to give more information + if (is_wxlua_lreg_evtcallbacks_key) + { + wxLuaCallback* wxlCallback = (wxLuaCallback*)lua_touserdata(L, -2); + wxCHECK_MSG(wxlCallback, count, wxT("Invalid wxLuaCallback")); + + wxString s(wxlCallback->GetInfo()); + name = s.BeforeFirst(wxT('|')); + value = s.AfterFirst(wxT('|')); + } + else if (is_wxlua_lreg_windestroycallbacks_key && (lua_type(L, -1) == LUA_TLIGHTUSERDATA)) + { + // only handle t[wxWindow*] = wxLuaWinDestroyCallback* + wxLuaWinDestroyCallback* wxlDestroyCallBack = (wxLuaWinDestroyCallback*)lua_touserdata(L, -1); + wxCHECK_MSG(wxlDestroyCallBack, count, wxT("Invalid wxLuaWinDestroyCallback")); + + wxString s(wxlDestroyCallBack->GetInfo()); + name = s.BeforeFirst(wxT('|')); + value = s.AfterFirst(wxT('|')); + } + else if (is_wxlua_lreg_topwindows_key) + { + wxWindow* win = (wxWindow*)lua_touserdata(L, -2); + name += wxT(" ") + wxString(win->GetClassInfo()->GetClassName()); + } + else if (is_wxlua_lreg_delobjects_key) + { + wxObject* obj = (wxObject*)lua_touserdata(L, -1); + name = wxString(obj->GetClassInfo()->GetClassName()) + wxT("(") + name + wxT(")"); + } + int flag_type = 0; int nRef = RefTable(L, -1, &flag_type, references); Add(new wxLuaDebugItem(name, wxl_keytype, value, wxl_valuetype, wxT(""), nRef, nIndex, flag_type)); count++; + + lua_pop(L, 1); // pop value, leave key } *************** *** 322,326 **** } - int wxLuaDebugData::RefTable(lua_State* L, int stack_idx, int* flag_type, wxArrayInt& references) { --- 391,394 ---- *************** *** 463,471 **** (udata == &wxlua_lreg_derivedmethods_key) || (udata == &wxlua_lreg_wxluastate_key) || ! (udata == &wxlua_lreg_objects_key) || (udata == &wxlua_lreg_evtcallbacks_key) || (udata == &wxlua_lreg_windestroycallbacks_key) || (udata == &wxlua_lreg_callbaseclassfunc_key) || (udata == &wxlua_metatable_tag_key) || (udata == &wxlua_metatable_wxluabindclass_key)) { --- 531,544 ---- (udata == &wxlua_lreg_derivedmethods_key) || (udata == &wxlua_lreg_wxluastate_key) || ! (udata == &wxlua_lreg_weakobjects_key) || ! (udata == &wxlua_lreg_delobjects_key) || (udata == &wxlua_lreg_evtcallbacks_key) || (udata == &wxlua_lreg_windestroycallbacks_key) || (udata == &wxlua_lreg_callbaseclassfunc_key) || + (udata == &wxlua_lreg_wxeventtype_key) || + (udata == &wxlua_lreg_wxluadebughookdata_key) || + (udata == &wxlua_metatable_tag_key) || + (udata == &wxlua_lreg_topwindows_key) || (udata == &wxlua_metatable_wxluabindclass_key)) { |
From: John L. <jr...@us...> - 2007-12-07 02:13:19
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv12976/wxLua/modules/wxluadebug/include Modified Files: wxlstack.h Log Message: Too many changes to list... A large portion of the internal workings of the wxLuaState have been rewritten. All of the data that was stored in wxLuaStateData that might be needed by a function taking a lua_State* is now in the LUA_REGISTRYINDEX. C functions have been added to access these values. The generated bindings no longer need to have "wxLuaState wxlState(L);" since everything can be done with the C functions. The result is that wxLua should be faster. Index: wxlstack.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/include/wxlstack.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** wxlstack.h 4 Dec 2007 16:26:11 -0000 1.14 --- wxlstack.h 7 Dec 2007 02:13:14 -0000 1.15 *************** *** 168,174 **** void FillTableEntry(long lc_item, const wxLuaDebugData& debugData); - // Add info from the wxLuaState (must be valid) about items the wxLuaState tracks. - void GetDerivedAndTrackedItems(); - // implementation --- 168,171 ---- |
From: John L. <jr...@us...> - 2007-12-07 02:13:19
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv12976/wxLua/samples Modified Files: unittest.wx.lua Log Message: Too many changes to list... A large portion of the internal workings of the wxLuaState have been rewritten. All of the data that was stored in wxLuaStateData that might be needed by a function taking a lua_State* is now in the LUA_REGISTRYINDEX. C functions have been added to access these values. The generated bindings no longer need to have "wxLuaState wxlState(L);" since everything can be done with the C functions. The result is that wxLua should be faster. Index: unittest.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/unittest.wx.lua,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** unittest.wx.lua 8 Aug 2007 02:55:34 -0000 1.16 --- unittest.wx.lua 7 Dec 2007 02:13:16 -0000 1.17 *************** *** 120,123 **** --- 120,124 ---- b = a:ToLuaTable() PrintOk((b[2] == "b") and (#b == 3), "Test wxSortedArrayString::ToLuaTable()") + collectgarbage("collect") -- test if wxLuaSmartwxSortedArrayString works a = wx.wxArrayInt({1, 2, 3}) |
From: John L. <jr...@us...> - 2007-12-07 02:13:19
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv12976/wxLua/modules/wxluasocket/include Modified Files: wxluasocket_bind.h Log Message: Too many changes to list... A large portion of the internal workings of the wxLuaState have been rewritten. All of the data that was stored in wxLuaStateData that might be needed by a function taking a lua_State* is now in the LUA_REGISTRYINDEX. C functions have been added to access these values. The generated bindings no longer need to have "wxLuaState wxlState(L);" since everything can be done with the C functions. The result is that wxLua should be faster. Index: wxluasocket_bind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/wxluasocket_bind.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** wxluasocket_bind.h 17 Nov 2007 00:15:11 -0000 1.27 --- wxluasocket_bind.h 7 Dec 2007 02:13:14 -0000 1.28 *************** *** 21,27 **** // the current version of the bindings. // See 'bindings/genwxbind.lua' and 'modules/wxlua/include/wxldefs.h' ! #if WXLUA_BINDING_VERSION > 18 # error "The WXLUA_BINDING_VERSION in the bindings is too old, regenerate bindings." ! #endif //WXLUA_BINDING_VERSION > 18 // --------------------------------------------------------------------------- --- 21,27 ---- // the current version of the bindings. // See 'bindings/genwxbind.lua' and 'modules/wxlua/include/wxldefs.h' ! #if WXLUA_BINDING_VERSION > 19 # error "The WXLUA_BINDING_VERSION in the bindings is too old, regenerate bindings." ! #endif //WXLUA_BINDING_VERSION > 19 // --------------------------------------------------------------------------- |
From: John L. <jr...@us...> - 2007-12-05 05:54:18
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv20622/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp wxlcallb.cpp wxlstate.cpp wxlua_bind.cpp Log Message: Rename wxLuaBinding/wxLuaState::GetLuaClass() to GetBindClass() since it gets the wxLuaBindClass struct Moved the code for searching the binding classes to static functions of wxLuaBinding to keep the code together with the wxLuaBinding class Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.143 retrieving revision 1.144 diff -C2 -d -r1.143 -r1.144 *** wxlstate.cpp 5 Dec 2007 00:34:46 -0000 1.143 --- wxlstate.cpp 5 Dec 2007 05:54:11 -0000 1.144 *************** *** 892,896 **** // delete all of the derived methods we've pushed ! lua_pushnil(L); while (lua_next(L, -2) != 0) { --- 892,896 ---- // delete all of the derived methods we've pushed ! lua_pushnil(L); while (lua_next(L, -2) != 0) { *************** *** 1193,1205 **** // remove refs table to try to clear memory gracefully lua_pushlightuserdata(m_lua_State, &wxlua_lreg_refs_key); ! lua_pushnil(m_lua_State); lua_rawset(m_lua_State, LUA_REGISTRYINDEX); lua_pushlightuserdata(m_lua_State, &wxlua_lreg_debug_refs_key); ! lua_pushnil(m_lua_State); lua_rawset(m_lua_State, LUA_REGISTRYINDEX); //lua_pushlightuserdata(m_lua_State, &wxlua_lreg_derivedmethods_key); // gc will delete them ! //lua_pushnil(m_lua_State); //lua_rawset(m_lua_State, LUA_REGISTRYINDEX); --- 1193,1205 ---- // remove refs table to try to clear memory gracefully lua_pushlightuserdata(m_lua_State, &wxlua_lreg_refs_key); ! lua_pushnil(m_lua_State); lua_rawset(m_lua_State, LUA_REGISTRYINDEX); lua_pushlightuserdata(m_lua_State, &wxlua_lreg_debug_refs_key); ! lua_pushnil(m_lua_State); lua_rawset(m_lua_State, LUA_REGISTRYINDEX); //lua_pushlightuserdata(m_lua_State, &wxlua_lreg_derivedmethods_key); // gc will delete them ! //lua_pushnil(m_lua_State); //lua_rawset(m_lua_State, LUA_REGISTRYINDEX); *************** *** 1246,1250 **** if (cb && (cb->GetwxLuaState().GetRefData() != this)) // don't unref us cb->ClearwxLuaState(); ! lua_pop(L, 1); // pop value, lua_next will pop key at end } --- 1246,1250 ---- if (cb && (cb->GetwxLuaState().GetRefData() != this)) // don't unref us cb->ClearwxLuaState(); ! lua_pop(L, 1); // pop value, lua_next will pop key at end } *************** *** 1272,1276 **** cb->ClearwxLuaState(); } ! lua_pop(L, 1); // pop value, lua_next will pop key at end } --- 1272,1276 ---- cb->ClearwxLuaState(); } ! lua_pop(L, 1); // pop value, lua_next will pop key at end } *************** *** 1820,1823 **** --- 1820,1827 ---- { wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); + + // Note: It may be possible to allow this in the future if there is a need. + wxCHECK_RET(!GetBindingsRegistered(), wxT("wxLua bindings already registered")); + lua_State* L = M_WXLSTATEDATA->m_lua_State; *************** *** 1897,1909 **** const wxLuaBindClass* wxlClass = NULL; ! wxlClass = GetLuaClass("wxEvent"); wxCHECK_RET(wxlClass, wxT("wxEvent Lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); g_wxluatag_wxEvent = *wxlClass->class_tag; ! wxlClass = GetLuaClass("wxString"); wxCHECK_RET(wxlClass, wxT("wxString Lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); g_wxluatag_wxString = *wxlClass->class_tag; ! wxlClass = GetLuaClass("wxWindow"); wxCHECK_RET(wxlClass, wxT("wxWindow Lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); g_wxluatag_wxWindow = *wxlClass->class_tag; --- 1901,1913 ---- const wxLuaBindClass* wxlClass = NULL; ! wxlClass = GetBindClass("wxEvent"); wxCHECK_RET(wxlClass, wxT("wxEvent Lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); g_wxluatag_wxEvent = *wxlClass->class_tag; ! wxlClass = GetBindClass("wxString"); wxCHECK_RET(wxlClass, wxT("wxString Lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); g_wxluatag_wxString = *wxlClass->class_tag; ! wxlClass = GetBindClass("wxWindow"); wxCHECK_RET(wxlClass, wxT("wxWindow Lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); g_wxluatag_wxWindow = *wxlClass->class_tag; *************** *** 1913,1928 **** { wxCHECK_MSG(GetRefData() != NULL, NULL, wxT("Invalid wxLuaState")); ! wxLuaBindingList::compatibility_iterator node; ! for (node = M_WXLSTATEDATA->m_wxlStateData->m_bindingList.GetFirst(); node; node = node->GetNext() ) ! { ! wxLuaBinding* binding = node->GetData(); ! if (binding->GetBindingName() == bindingName) ! return binding; ! } ! ! return NULL; } ! const wxLuaBindClass* wxLuaState::GetLuaClass(int class_tag) const { wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); --- 1917,1924 ---- { wxCHECK_MSG(GetRefData() != NULL, NULL, wxT("Invalid wxLuaState")); ! return wxLuaBinding::GetLuaBinding(bindingName, &M_WXLSTATEDATA->m_wxlStateData->m_bindingList); } ! const wxLuaBindClass* wxLuaState::GetBindClass(int class_tag) const { wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); *************** *** 1933,1983 **** // we shouldn't ever need this code if (wxlClass == NULL) ! { ! wxLuaBindingList::compatibility_iterator node; ! for (node = M_WXLSTATEDATA->m_wxlStateData->m_bindingList.GetFirst(); node; node = node->GetNext() ) ! { ! wxLuaBinding* binding = node->GetData(); ! wxlClass = binding->GetLuaClass(class_tag); ! ! if (wxlClass) break; ! } ! } return wxlClass; } ! ! const wxLuaBindClass* wxLuaState::GetLuaClass(const char* className) const { ! wxCHECK_MSG(GetRefData() != NULL, NULL, wxT("Invalid wxLuaState")); return wxluaT_getclass(M_WXLSTATEDATA->m_lua_State, className); } ! ! const wxLuaBindClass* wxLuaState::GetLuaClass(const wxLuaBindMethod* method) const { ! wxLuaBindingList::compatibility_iterator node; ! for (node = M_WXLSTATEDATA->m_wxlStateData->m_bindingList.GetFirst(); node; node = node->GetNext() ) ! { ! wxLuaBinding* binding = node->GetData(); ! ! const wxLuaBindClass *pLuaClass = binding->GetLuaClass(method); ! if (pLuaClass) ! return pLuaClass; ! } ! ! return NULL; } ! const wxLuaBindClass* wxLuaState::GetLuaClass(const wxLuaBindCFunc* method_cfunc) const { ! wxLuaBindingList::compatibility_iterator node; ! for (node = M_WXLSTATEDATA->m_wxlStateData->m_bindingList.GetFirst(); node; node = node->GetNext() ) ! { ! wxLuaBinding* binding = node->GetData(); ! ! const wxLuaBindClass *pLuaClass = binding->GetLuaClass(method_cfunc); ! if (pLuaClass) ! return pLuaClass; ! } ! ! return NULL; } --- 1929,1950 ---- // we shouldn't ever need this code if (wxlClass == NULL) ! wxlClass = wxLuaBinding::GetBindClass(class_tag, &M_WXLSTATEDATA->m_wxlStateData->m_bindingList); return wxlClass; } ! const wxLuaBindClass* wxLuaState::GetBindClass(const char* className) const { ! wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); return wxluaT_getclass(M_WXLSTATEDATA->m_lua_State, className); } ! const wxLuaBindClass* wxLuaState::GetBindClass(const wxLuaBindMethod* method) const { ! wxCHECK_MSG(GetRefData() != NULL, NULL, wxT("Invalid wxLuaState")); ! return wxLuaBinding::GetBindClass(method, &M_WXLSTATEDATA->m_wxlStateData->m_bindingList); } ! const wxLuaBindClass* wxLuaState::GetBindClass(const wxLuaBindCFunc* method_cfunc) const { ! wxCHECK_MSG(GetRefData() != NULL, NULL, wxT("Invalid wxLuaState")); ! return wxLuaBinding::GetBindClass(method_cfunc, &M_WXLSTATEDATA->m_wxlStateData->m_bindingList); } *************** *** 1988,2006 **** } ! const wxLuaBindEvent* wxLuaState::GetLuaEvent(wxEventType eventType_) const { wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); ! ! wxLuaBindingList::compatibility_iterator node; ! for (node = M_WXLSTATEDATA->m_wxlStateData->m_bindingList.GetFirst(); node; node = node->GetNext()) ! { ! wxLuaBinding* binding = node->GetData(); ! const wxLuaBindEvent *pLuaEvent = binding->GetEvent(eventType_); ! ! if (pLuaEvent) ! return pLuaEvent; ! } ! ! return NULL; } --- 1955,1962 ---- } ! const wxLuaBindEvent* wxLuaState::GetBindEvent(wxEventType eventType) const { wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); ! return wxLuaBinding::GetBindEvent(eventType, &M_WXLSTATEDATA->m_wxlStateData->m_bindingList); } *************** *** 2202,2209 **** lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) lua_pushlightuserdata(L, callback); // push key ! lua_pushlightuserdata(L, callback->GetEvtHandler()); // push value lua_rawset(L, -3); // set t[key] = value; pops key and value --- 2158,2165 ---- lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) lua_pushlightuserdata(L, callback); // push key ! lua_pushlightuserdata(L, callback->GetEvtHandler()); // push value lua_rawset(L, -3); // set t[key] = value; pops key and value *************** *** 2216,2223 **** lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) lua_pushlightuserdata(L, callback); // push key ! lua_pushnil(L); // push value lua_rawset(L, -3); // set t[key] = value; pops key and value --- 2172,2179 ---- lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) lua_pushlightuserdata(L, callback); // push key ! lua_pushnil(L); // push value lua_rawset(L, -3); // set t[key] = value; pops key and value *************** *** 2255,2260 **** } } ! ! names.Add(wxString::Format(wxT("%s (%d) wxEvtHandler(%p)-wxLuacallback(%p)"), evtName.c_str(), (int)wxlCallback->GetEventType(), wxlCallback->GetEvtHandler(), wxlCallback)); --- 2211,2216 ---- } } ! ! names.Add(wxString::Format(wxT("%s (%d) wxEvtHandler(%p)-wxLuacallback(%p)"), evtName.c_str(), (int)wxlCallback->GetEventType(), wxlCallback->GetEvtHandler(), wxlCallback)); *************** *** 2274,2278 **** lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) lua_pushlightuserdata(L, callback); // push key --- 2230,2234 ---- lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) lua_pushlightuserdata(L, callback); // push key *************** *** 2280,2287 **** lua_rawset(L, -3); // set t[key] = value; pops key and value ! lua_pushlightuserdata(L, callback->GetWindow()); // push key lua_pushlightuserdata(L, callback); // push value lua_rawset(L, -3); // set t[key] = value; pops key and value ! lua_pop(L, 1); // pop table } --- 2236,2243 ---- lua_rawset(L, -3); // set t[key] = value; pops key and value ! lua_pushlightuserdata(L, callback->GetWindow()); // push key lua_pushlightuserdata(L, callback); // push value lua_rawset(L, -3); // set t[key] = value; pops key and value ! lua_pop(L, 1); // pop table } *************** *** 2292,2296 **** lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) lua_pushlightuserdata(L, callback); // push key --- 2248,2252 ---- lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) lua_pushlightuserdata(L, callback); // push key *************** *** 2298,2305 **** lua_rawset(L, -3); // set t[key] = value; pops key and value ! lua_pushlightuserdata(L, callback->GetWindow()); // push key lua_pushnil(L); // push value lua_rawset(L, -3); // set t[key] = value; pops key and value ! lua_pop(L, 1); // pop table --- 2254,2261 ---- lua_rawset(L, -3); // set t[key] = value; pops key and value ! lua_pushlightuserdata(L, callback->GetWindow()); // push key lua_pushnil(L); // push value lua_rawset(L, -3); // set t[key] = value; pops key and value ! lua_pop(L, 1); // pop table *************** *** 2491,2495 **** lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) lua_pushlightuserdata(L, win); // push key --- 2447,2451 ---- lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) lua_pushlightuserdata(L, win); // push key *************** *** 2794,2798 **** return wxT("wxLuaFunction"); ! const wxLuaBindClass *wxlClass = GetLuaClass(tag); if (wxlClass) return lua2wx(wxlClass->name); --- 2750,2754 ---- return wxT("wxLuaFunction"); ! const wxLuaBindClass *wxlClass = GetBindClass(tag); if (wxlClass) return lua2wx(wxlClass->name); *************** *** 3573,3577 **** wxString className; ! const wxLuaBindClass* wxlClass = GetLuaClass(method); if (wxlClass) className = lua2wx(wxlClass->name) + wxT("::"); --- 3529,3533 ---- wxString className; ! const wxLuaBindClass* wxlClass = GetBindClass(method); if (wxlClass) className = lua2wx(wxlClass->name) + wxT("::"); Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -d -r1.98 -r1.99 *** wxlbind.cpp 5 Dec 2007 00:34:46 -0000 1.98 --- wxlbind.cpp 5 Dec 2007 05:54:11 -0000 1.99 *************** *** 661,665 **** // and share the m_luaTable_ref to that of the previously loaded binding wxLuaBindingList::compatibility_iterator node = wxlState.GetLuaBindingList()->GetFirst(); ! for (; node; node = node->GetNext()) { wxLuaBinding* binding = node->GetData(); --- 661,665 ---- // and share the m_luaTable_ref to that of the previously loaded binding wxLuaBindingList::compatibility_iterator node = wxlState.GetLuaBindingList()->GetFirst(); ! while (node) { wxLuaBinding* binding = node->GetData(); *************** *** 670,673 **** --- 670,675 ---- break; } + + node = node->GetNext(); } *************** *** 815,819 **** // add table to the binding table t[wxlMethod->name] = { this table } ! lua_rawset(L, -3); #elif 0 // C++ constructors are userdata, use metatable for access to items. --- 817,821 ---- // add table to the binding table t[wxlMethod->name] = { this table } ! lua_rawset(L, -3); #elif 0 // C++ constructors are userdata, use metatable for access to items. *************** *** 913,917 **** } ! const wxLuaBindEvent* wxLuaBinding::GetEvent(wxEventType eventType_) const { // we've sorted this, see InitBinding() --- 915,919 ---- } ! const wxLuaBindEvent* wxLuaBinding::GetBindEvent(wxEventType eventType_) const { // we've sorted this, see InitBinding() *************** *** 929,938 **** wxString wxLuaBinding::GetEventTypeName(wxEventType eventType) const { ! const wxLuaBindEvent* luaEvent = GetEvent(eventType); return (luaEvent != NULL) ? lua2wx(luaEvent->name) : wxString(); } ! const wxLuaBindClass* wxLuaBinding::GetLuaClass(int class_tag_) const { int class_tag = class_tag_; --- 931,940 ---- wxString wxLuaBinding::GetEventTypeName(wxEventType eventType) const { ! const wxLuaBindEvent* luaEvent = GetBindEvent(eventType); return (luaEvent != NULL) ? lua2wx(luaEvent->name) : wxString(); } ! const wxLuaBindClass* wxLuaBinding::GetBindClass(int class_tag_) const { int class_tag = class_tag_; *************** *** 951,955 **** } ! const wxLuaBindClass* wxLuaBinding::GetLuaClass(const wxLuaBindMethod* wxlMethod) const { wxLuaBindClass* wxlClass_i = m_classArray; --- 953,957 ---- } ! const wxLuaBindClass* wxLuaBinding::GetBindClass(const wxLuaBindMethod* wxlMethod) const { wxLuaBindClass* wxlClass_i = m_classArray; *************** *** 971,975 **** } ! const wxLuaBindClass* wxLuaBinding::GetLuaClass(const wxLuaBindCFunc* wxlMethod_cfunc) const { wxLuaBindClass* wxlClass_i = m_classArray; --- 973,977 ---- } ! const wxLuaBindClass* wxLuaBinding::GetBindClass(const wxLuaBindCFunc* wxlMethod_cfunc) const { wxLuaBindClass* wxlClass_i = m_classArray; *************** *** 998,1001 **** --- 1000,1106 ---- } + // -------------------------------------------------------------------------- + + // static + wxLuaBinding* wxLuaBinding::GetLuaBinding(const wxString& bindingName, const wxLuaBindingList* bindingList_) + { + const wxLuaBindingList* bindingList = bindingList_ ? bindingList_ : &sm_bindingList; + wxLuaBindingList::compatibility_iterator node = bindingList->GetFirst(); + + while (node) + { + wxLuaBinding* binding = node->GetData(); + if (binding->GetBindingName() == bindingName) + return binding; + + node = node->GetNext(); + } + + return NULL; + } + + // static + const wxLuaBindClass* wxLuaBinding::GetBindClass(int class_tag, const wxLuaBindingList* bindingList_) + { + const wxLuaBindingList* bindingList = bindingList_ ? bindingList_ : &sm_bindingList; + wxLuaBindingList::compatibility_iterator node = bindingList->GetFirst(); + + while (node) + { + wxLuaBinding* binding = node->GetData(); + const wxLuaBindClass* wxlClass = binding->GetBindClass(class_tag); + + if (wxlClass) + return wxlClass; + + node = node->GetNext(); + } + + return NULL; + } + + // static + const wxLuaBindClass* wxLuaBinding::GetBindClass(const wxLuaBindMethod* method, const wxLuaBindingList* bindingList_) + { + const wxLuaBindingList* bindingList = bindingList_ ? bindingList_ : &sm_bindingList; + wxLuaBindingList::compatibility_iterator node = bindingList->GetFirst(); + + while (node) + { + wxLuaBinding* binding = node->GetData(); + const wxLuaBindClass *pLuaClass = binding->GetBindClass(method); + + if (pLuaClass) + return pLuaClass; + + node = node->GetNext(); + } + + return NULL; + } + + // static + const wxLuaBindClass* wxLuaBinding::GetBindClass(const wxLuaBindCFunc* method_cfunc, const wxLuaBindingList* bindingList_) + { + const wxLuaBindingList* bindingList = bindingList_ ? bindingList_ : &sm_bindingList; + wxLuaBindingList::compatibility_iterator node = bindingList->GetFirst(); + + while (node) + { + wxLuaBinding* binding = node->GetData(); + const wxLuaBindClass *pLuaClass = binding->GetBindClass(method_cfunc); + + if (pLuaClass) + return pLuaClass; + + node = node->GetNext(); + } + + return NULL; + } + + // static + const wxLuaBindEvent* wxLuaBinding::GetBindEvent(wxEventType eventType_, const wxLuaBindingList* bindingList_) + { + const wxLuaBindingList* bindingList = bindingList_ ? bindingList_ : &sm_bindingList; + wxLuaBindingList::compatibility_iterator node = bindingList->GetFirst(); + + while (node) + { + wxLuaBinding* binding = node->GetData(); + const wxLuaBindEvent *pLuaEvent = binding->GetBindEvent(eventType_); + + if (pLuaEvent) + return pLuaEvent; + + node = node->GetNext(); + } + + return NULL; + } + + // -------------------------------------------------------------------------- + + // static wxLuaBindMethod* wxLuaBinding::GetClassMethod(const wxLuaBindClass *wxlClass, const char *methodName, bool search_baseclasses) { *************** *** 1046,1049 **** --- 1151,1155 ---- } + // static wxLuaBindMethod* wxLuaBinding::GetClassProperty(const wxLuaBindClass *wxlClass, const char *propName, bool isLuaSetProp) { *************** *** 1073,1076 **** --- 1179,1185 ---- } + // -------------------------------------------------------------------------- + + // static void wxLuaBinding::InitAllBindings(bool force_update) { *************** *** 1089,1094 **** if (wxlClass->baseclassName) // does it have a name { ! wxLuaBindingList::compatibility_iterator basenode; ! for (basenode = sm_bindingList.GetFirst(); basenode; basenode = basenode->GetNext() ) { wxLuaBinding* basebinding = basenode->GetData(); --- 1198,1203 ---- if (wxlClass->baseclassName) // does it have a name { ! wxLuaBindingList::compatibility_iterator basenode = sm_bindingList.GetFirst(); ! while (basenode) { wxLuaBinding* basebinding = basenode->GetData(); *************** *** 1097,1100 **** --- 1206,1211 ---- if (basebinding->SetBaseClass(wxlClass)) break; + + basenode = basenode->GetNext(); } } *************** *** 1159,1161 **** sm_bindingList_initialized = true; ! } \ No newline at end of file --- 1270,1272 ---- sm_bindingList_initialized = true; ! } Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** wxlcallb.cpp 5 Dec 2007 00:34:46 -0000 1.45 --- wxlcallb.cpp 5 Dec 2007 05:54:11 -0000 1.46 *************** *** 36,40 **** wxCHECK_RET(m_wxlState.Ok(), wxT("Invalid wxLuaState")); ! m_wxlBindEvent = wxlState.GetLuaEvent(eventType); m_wxlState.AddTrackedCallback(this); --- 36,40 ---- wxCHECK_RET(m_wxlState.Ok(), wxT("Invalid wxLuaState")); ! m_wxlBindEvent = wxlState.GetBindEvent(eventType); m_wxlState.AddTrackedCallback(this); *************** *** 119,123 **** (event->GetClassInfo()->GetClassName() == wxString(wxT("wxSpinEvent")))) { ! const wxLuaBindClass *wxlClass = wxlState.GetLuaClass("wxSpinEvent"); if (wxlClass != NULL) event_tag = *wxlClass->class_tag; --- 119,123 ---- (event->GetClassInfo()->GetClassName() == wxString(wxT("wxSpinEvent")))) { ! const wxLuaBindClass *wxlClass = wxlState.GetBindClass("wxSpinEvent"); if (wxlClass != NULL) event_tag = *wxlClass->class_tag; *************** *** 240,244 **** lua_rawset(L, -4); // set t[key] = nil to remove it } ! else lua_pop(L, 1); // pop value, lua_next will pop key at end } --- 240,244 ---- lua_rawset(L, -4); // set t[key] = nil to remove it } ! else lua_pop(L, 1); // pop value, lua_next will pop key at end } Index: wxlua_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua_bind.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** wxlua_bind.cpp 5 Dec 2007 00:34:46 -0000 1.11 --- wxlua_bind.cpp 5 Dec 2007 05:54:11 -0000 1.12 *************** *** 248,252 **** else if (strcmp(idx_str, "class") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetLuaClass(wxlCFunc); if (c != NULL) { --- 248,252 ---- else if (strcmp(idx_str, "class") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetBindClass(wxlCFunc); if (c != NULL) { *************** *** 265,269 **** else if (strcmp(idx_str, "class_name") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetLuaClass(wxlCFunc); if (c != NULL) { --- 265,269 ---- else if (strcmp(idx_str, "class_name") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetBindClass(wxlCFunc); if (c != NULL) { *************** *** 353,357 **** else if (strcmp(idx_str, "class") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetLuaClass(wxlMethod); if (c != NULL) { --- 353,357 ---- else if (strcmp(idx_str, "class") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetBindClass(wxlMethod); if (c != NULL) { *************** *** 370,374 **** else if (strcmp(idx_str, "class_name") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetLuaClass(wxlMethod); if (c != NULL) { --- 370,374 ---- else if (strcmp(idx_str, "class_name") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetBindClass(wxlMethod); if (c != NULL) { *************** *** 450,454 **** if (wxlClass->classInfo) { ! const wxLuaBindClass* classInfoClass = wxlState.GetLuaClass("wxClassInfo"); if (classInfoClass) { --- 450,454 ---- if (wxlClass->classInfo) { ! const wxLuaBindClass* classInfoClass = wxlState.GetBindClass("wxClassInfo"); if (classInfoClass) { |
From: John L. <jr...@us...> - 2007-12-05 05:54:17
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv20622/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlstate.h Log Message: Rename wxLuaBinding/wxLuaState::GetLuaClass() to GetBindClass() since it gets the wxLuaBindClass struct Moved the code for searching the binding classes to static functions of wxLuaBinding to keep the code together with the wxLuaBinding class Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** wxlbind.h 5 Dec 2007 00:34:46 -0000 1.67 --- wxlbind.h 5 Dec 2007 05:54:11 -0000 1.68 *************** *** 406,425 **** void SetLuaNamespace(const wxString& nameSpace) { m_nameSpace = nameSpace; } ! size_t GetClassCount() const { return m_classCount; } ! wxLuaBindClass* GetClassArray() { return m_classArray; } ! size_t GetDefineCount() const { return m_defineCount; } ! wxLuaBindDefine* GetDefineArray() { return m_defineArray; } ! size_t GetStringCount() const { return m_stringCount; } ! wxLuaBindString* GetStringArray() { return m_stringArray; } ! size_t GetEventCount() { return m_eventCount; } ! wxLuaBindEvent* GetEventArray() { return m_eventArray; } ! size_t GetObjectCount() { return m_objectCount; } ! wxLuaBindObject* GetObjectArray() { return m_objectArray; } ! size_t GetFunctionCount() { return m_functionCount; } wxLuaBindMethod* GetFunctionArray() { return m_functionArray; } --- 406,425 ---- void SetLuaNamespace(const wxString& nameSpace) { m_nameSpace = nameSpace; } ! size_t GetClassCount() const { return m_classCount; } ! wxLuaBindClass* GetClassArray() { return m_classArray; } ! size_t GetDefineCount() const { return m_defineCount; } ! wxLuaBindDefine* GetDefineArray() { return m_defineArray; } ! size_t GetStringCount() const { return m_stringCount; } ! wxLuaBindString* GetStringArray() { return m_stringArray; } ! size_t GetEventCount() const { return m_eventCount; } ! wxLuaBindEvent* GetEventArray() { return m_eventArray; } ! size_t GetObjectCount() const { return m_objectCount; } ! wxLuaBindObject* GetObjectArray() { return m_objectArray; } ! size_t GetFunctionCount() const { return m_functionCount; } wxLuaBindMethod* GetFunctionArray() { return m_functionArray; } *************** *** 437,452 **** // Find the wxLuaBindEvent with the wxEventType, returns NULL if not found. ! const wxLuaBindEvent* GetEvent(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* GetLuaClass(int class_tag) const; // Get the first wxLuaBindClass that has this wxLuaBindMethod ! const wxLuaBindClass* GetLuaClass(const wxLuaBindMethod* wxlMethod) const; // Get the first wxLuaBindClass that has this wxLuaBindCFunc ! const wxLuaBindClass* GetLuaClass(const wxLuaBindCFunc* wxlMethod_cfunc) const; // ----------------------------------------------------------------------- // Lookup a Lua method or get property called methodName in the wxLuaBindClass array wxlClass. --- 437,476 ---- // 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; // ----------------------------------------------------------------------- + // These functions search through the input wxLuaBindingList or if NULL + // the static wxLuaBinding::GetBindingList(). + + // Get the installed wxLuaBinding with the given + // wxLuaBinding::GetBindingName() or NULL for no match. + 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); + + // ----------------------------------------------------------------------- + // These functions search through the input struct // Lookup a Lua method or get property called methodName in the wxLuaBindClass array wxlClass. *************** *** 464,467 **** --- 488,493 ---- static wxLuaBindMethod* GetClassProperty(const wxLuaBindClass *wxlClass, const char *propName, bool isLuaSetProp); + // ----------------------------------------------------------------------- + // Get all the bindings that were initialized using the generated binding // function wxLuaBinding_[binding name]_init(). *************** *** 470,475 **** static wxLuaBindingList* GetBindingList() { return &sm_bindingList; } ! // 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. --- 496,502 ---- static wxLuaBindingList* GetBindingList() { return &sm_bindingList; } + // ----------------------------------------------------------------------- ! // 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. Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** wxlstate.h 5 Dec 2007 00:34:46 -0000 1.99 --- wxlstate.h 5 Dec 2007 05:54:11 -0000 1.100 *************** *** 103,111 **** extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_objects_key; // The key in the LUA_REGISTRYINDEX table that is table of all ! // wxLuaCallbacks that we've created. // t[lightuserdata wxLuaCallback] = lightuserdata wxEvtHandler extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_evtcallbacks_key; // The key in the LUA_REGISTRYINDEX table that is table of all ! // wxLuaWinDestroyCallbacks that we've created. // t[lightuserdata wxLuaWinDestroyCallback] = 1 (the number 1) // t[lightuserdata wxWindow] = lightuserdata wxLuaWinDestroyCallback --- 103,111 ---- extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_objects_key; // The key in the LUA_REGISTRYINDEX table that is table of all ! // wxLuaCallbacks that we've created. // t[lightuserdata wxLuaCallback] = lightuserdata wxEvtHandler extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_evtcallbacks_key; // The key in the LUA_REGISTRYINDEX table that is table of all ! // wxLuaWinDestroyCallbacks that we've created. // t[lightuserdata wxLuaWinDestroyCallback] = 1 (the number 1) // t[lightuserdata wxWindow] = lightuserdata wxLuaWinDestroyCallback *************** *** 601,612 **** // Get wxLuaBindClass for given Lua Tag using wxLuaBindClass::class_tag, // returns NULL on failure. ! const wxLuaBindClass* GetLuaClass(int iClassTag) const; // Get wxLuaBindClass for given class name using wxLuaBindClass::name, // returns NULL on failure. ! const wxLuaBindClass* GetLuaClass(const char* className) const; // Get the first wxLuaBindClass that has this particular wxLuaBindMethod ! const wxLuaBindClass* GetLuaClass(const wxLuaBindMethod* method) const; // Get the first wxLuaBindClass that has this particular wxLuaBindCFunc in it's methods ! const wxLuaBindClass* GetLuaClass(const wxLuaBindCFunc* method_cfunc) const; // returns >= 0 if iClassTag is derived from or equal to iBaseClassTag by using // wxLuaBindClass::class_tag and wxLuaBindClass::baseclass_tag. --- 601,614 ---- // Get wxLuaBindClass for given Lua Tag using wxLuaBindClass::class_tag, // returns NULL on failure. ! const wxLuaBindClass* GetBindClass(int iClassTag) const; // Get wxLuaBindClass for given class name using wxLuaBindClass::name, // returns NULL on failure. ! const wxLuaBindClass* GetBindClass(const char* className) const; // Get the first wxLuaBindClass that has this particular wxLuaBindMethod ! // returns NULL on failure. ! const wxLuaBindClass* GetBindClass(const wxLuaBindMethod* method) const; // Get the first wxLuaBindClass that has this particular wxLuaBindCFunc in it's methods ! // returns NULL on failure. ! const wxLuaBindClass* GetBindClass(const wxLuaBindCFunc* method_cfunc) const; // returns >= 0 if iClassTag is derived from or equal to iBaseClassTag by using // wxLuaBindClass::class_tag and wxLuaBindClass::baseclass_tag. *************** *** 616,620 **** // Get wxLuaBindEvent for given wxEventType (wxEvent::GetEventType()) by finding // the matching wxLuaBindEvent::eventType. ! const wxLuaBindEvent* GetLuaEvent(wxEventType eventType) const; // Get the wxLuaBinding list of classes/objects installed into Lua. --- 618,622 ---- // Get wxLuaBindEvent for given wxEventType (wxEvent::GetEventType()) by finding // the matching wxLuaBindEvent::eventType. ! const wxLuaBindEvent* GetBindEvent(wxEventType eventType) const; // Get the wxLuaBinding list of classes/objects installed into Lua. |
From: John L. <jr...@us...> - 2007-12-05 05:54:16
|
Update of /cvsroot/wxlua/wxLua/modules/wxbind/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv20622/wxLua/modules/wxbind/src Modified Files: wxbase_data.cpp Log Message: Rename wxLuaBinding/wxLuaState::GetLuaClass() to GetBindClass() since it gets the wxLuaBindClass struct Moved the code for searching the binding classes to static functions of wxLuaBinding to keep the code together with the wxLuaBinding class Index: wxbase_data.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxbind/src/wxbase_data.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** wxbase_data.cpp 17 Nov 2007 00:14:58 -0000 1.5 --- wxbase_data.cpp 5 Dec 2007 05:54:11 -0000 1.6 *************** *** 612,616 **** wxObject *pObject = (wxObject *)wxlState.wxlua_ToUserdata( 1 ); ! const wxLuaBindClass *pClass = wxlState.GetLuaClass(className); if (pClass && pClass->classInfo) { --- 612,616 ---- wxObject *pObject = (wxObject *)wxlState.wxlua_ToUserdata( 1 ); ! const wxLuaBindClass *pClass = wxlState.GetBindClass(className); if (pClass && pClass->classInfo) { |
From: John L. <jr...@us...> - 2007-12-05 05:54:16
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv20622/wxLua/samples Modified Files: wxluasudoku.wx.lua Log Message: Rename wxLuaBinding/wxLuaState::GetLuaClass() to GetBindClass() since it gets the wxLuaBindClass struct Moved the code for searching the binding classes to static functions of wxLuaBinding to keep the code together with the wxLuaBinding class Index: wxluasudoku.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/wxluasudoku.wx.lua,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** wxluasudoku.wx.lua 8 Nov 2007 05:41:21 -0000 1.75 --- wxluasudoku.wx.lua 5 Dec 2007 05:54:11 -0000 1.76 *************** *** 441,446 **** for cell = 1, 81 do sudoku.cellToRowColBlockCellsArray[cell] = {} ! for k, v in pairs(sudoku.cellToRowColBlockCellsTable) do ! table.insert(sudoku.cellToRowColBlockCellsArray, k) end end --- 441,446 ---- for cell = 1, 81 do sudoku.cellToRowColBlockCellsArray[cell] = {} ! for k, v in pairs(sudoku.cellToRowColBlockCellsTable[cell]) do ! table.insert(sudoku.cellToRowColBlockCellsArray[cell], k) end end |
From: John L. <jr...@us...> - 2007-12-05 05:54:16
|
Update of /cvsroot/wxlua/wxLua/bindings/wxlua In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv20622/wxLua/bindings/wxlua Modified Files: override.hpp Log Message: Rename wxLuaBinding/wxLuaState::GetLuaClass() to GetBindClass() since it gets the wxLuaBindClass struct Moved the code for searching the binding classes to static functions of wxLuaBinding to keep the code together with the wxLuaBinding class Index: override.hpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/wxlua/override.hpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** override.hpp 5 Dec 2007 00:34:44 -0000 1.9 --- override.hpp 5 Dec 2007 05:54:11 -0000 1.10 *************** *** 265,269 **** else if (strcmp(idx_str, "class") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetLuaClass(wxlCFunc); if (c != NULL) { --- 265,269 ---- else if (strcmp(idx_str, "class") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetBindClass(wxlCFunc); if (c != NULL) { *************** *** 282,286 **** else if (strcmp(idx_str, "class_name") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetLuaClass(wxlCFunc); if (c != NULL) { --- 282,286 ---- else if (strcmp(idx_str, "class_name") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetBindClass(wxlCFunc); if (c != NULL) { *************** *** 370,374 **** else if (strcmp(idx_str, "class") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetLuaClass(wxlMethod); if (c != NULL) { --- 370,374 ---- else if (strcmp(idx_str, "class") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetBindClass(wxlMethod); if (c != NULL) { *************** *** 387,391 **** else if (strcmp(idx_str, "class_name") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetLuaClass(wxlMethod); if (c != NULL) { --- 387,391 ---- else if (strcmp(idx_str, "class_name") == 0) { ! const wxLuaBindClass* c = wxlBinding->GetBindClass(wxlMethod); if (c != NULL) { *************** *** 467,471 **** if (wxlClass->classInfo) { ! const wxLuaBindClass* classInfoClass = wxlState.GetLuaClass("wxClassInfo"); if (classInfoClass) { --- 467,471 ---- if (wxlClass->classInfo) { ! const wxLuaBindClass* classInfoClass = wxlState.GetBindClass("wxClassInfo"); if (classInfoClass) { |
From: John L. <jr...@us...> - 2007-12-05 05:54:15
|
Update of /cvsroot/wxlua/wxLua/bindings/wxwidgets In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv20622/wxLua/bindings/wxwidgets Modified Files: wxbase_override.hpp Log Message: Rename wxLuaBinding/wxLuaState::GetLuaClass() to GetBindClass() since it gets the wxLuaBindClass struct Moved the code for searching the binding classes to static functions of wxLuaBinding to keep the code together with the wxLuaBinding class Index: wxbase_override.hpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/wxwidgets/wxbase_override.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** wxbase_override.hpp 17 Nov 2007 00:14:55 -0000 1.5 --- wxbase_override.hpp 5 Dec 2007 05:54:11 -0000 1.6 *************** *** 426,430 **** wxObject *pObject = (wxObject *)wxlState.wxlua_ToUserdata( 1 ); ! const wxLuaBindClass *pClass = wxlState.GetLuaClass(className); if (pClass && pClass->classInfo) { --- 426,430 ---- wxObject *pObject = (wxObject *)wxlState.wxlua_ToUserdata( 1 ); ! const wxLuaBindClass *pClass = wxlState.GetBindClass(className); if (pClass && pClass->classInfo) { |
From: John L. <jr...@us...> - 2007-12-05 00:34:53
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv21421/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp wxlcallb.cpp wxlstate.cpp wxlua_bind.cpp Log Message: Removed the rest of "UnregisterBinding" functions since they did nothing useful Moved binding base class linking code to wxLuaBinding::InitAllBindings from wxLuaState::RegisterBindings Removed wxLuaStateData::m_winDestroyCallbackList and wxLuaStateData::m_callbackList and added two registry tables for their values. Should be faster and easier to verify operation. Fix searching in the wxLuaStackDialog. Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.142 retrieving revision 1.143 diff -C2 -d -r1.142 -r1.143 *** wxlstate.cpp 4 Dec 2007 05:20:28 -0000 1.142 --- wxlstate.cpp 5 Dec 2007 00:34:46 -0000 1.143 *************** *** 30,33 **** --- 30,35 ---- const char* wxlua_lreg_wxluastate_key = "wxLuaState"; const char* wxlua_lreg_objects_key = "wxLua pushed userdata"; + const char* wxlua_lreg_evtcallbacks_key = "wxLuaCallbacks"; + const char* wxlua_lreg_windestroycallbacks_key = "wxLuaWinDestoyCallbacks"; const char* wxlua_lreg_callbaseclassfunc_key = "wxLua CallBaseClassFunc"; *************** *** 286,290 **** } ! lua_pop(L, 1); // pop object we pushed and the ref table } --- 288,292 ---- } ! lua_pop(L, 1); // pop ref table } *************** *** 299,303 **** lua_pushlightuserdata(L, &wxlua_metatable_tag_key); // push key lua_pushnumber(L, tag); // push value ! lua_rawset(L, -3); // t[key] = value; pop key and value return tag; // leave the table on the stack --- 301,305 ---- lua_pushlightuserdata(L, &wxlua_metatable_tag_key); // push key lua_pushnumber(L, tag); // push value ! lua_rawset(L, -3); // set t[key] = value; pop key and value return tag; // leave the table on the stack *************** *** 890,898 **** // delete all of the derived methods we've pushed ! lua_pushnil(L); /* first key */ while (lua_next(L, -2) != 0) { ! // uses 'key' (at index -2) and 'value' (at index -1) ! if (lua_islightuserdata(L, -1)) { --- 892,899 ---- // delete all of the derived methods we've pushed ! lua_pushnil(L); while (lua_next(L, -2) != 0) { ! // value at -1, key at -2, table at -3 if (lua_islightuserdata(L, -1)) { *************** *** 904,908 **** } ! lua_pop(L, 1); // pop the obj table so reg table is on top lua_pushlightuserdata(L, (void *)pObject); // push key --- 905,909 ---- } ! lua_pop(L, 1); // pop the obj table lua_pushlightuserdata(L, (void *)pObject); // push key *************** *** 910,917 **** lua_rawset(L, -3); // set t[key] = value; pop key and value ! lua_pop(L, 1); // pop reg table } else ! lua_pop(L, 2); // pop the reg table and nil for the obj table return found; --- 911,918 ---- lua_rawset(L, -3); // set t[key] = value; pop key and value ! lua_pop(L, 1); // pop the derived table } else ! lua_pop(L, 2); // pop the derived table and nil for the obj table return found; *************** *** 1079,1086 **** m_id(wxID_ANY) { - // don't "own" pointers to wxLuaCallbacks, let wxEventHandler do it - m_callbackList.DeleteContents(false); - // don't delete wxLuaWinDestroyCallbacks, let wxEventHandler do it - m_winDestroyCallbackList.DeleteContents(false); // don't delete wxWindow derived classes, let wxWidgets do it m_windowList.DeleteContents(false); --- 1080,1083 ---- *************** *** 1152,1160 **** bool wxLuaStateRefData::CloseLuaState(bool force) { ! if ((m_lua_State == NULL) || m_wxlStateData->m_is_closing) return true; - if (m_lua_State_coroutine) return true; - m_wxlStateData->m_is_closing = true; --- 1149,1155 ---- bool wxLuaStateRefData::CloseLuaState(bool force) { ! if ((m_lua_State == NULL) || m_wxlStateData->m_is_closing || m_lua_State_coroutine) return true; m_wxlStateData->m_is_closing = true; *************** *** 1192,1201 **** } - // m_wxlStateData->m_windowList.Clear(); wxLuaCleanupWindows does this for us - - ClearCallbacks(); if (m_lua_State != NULL) { ! UnRegisterBindings(); if (!m_lua_State_static) --- 1187,1208 ---- } if (m_lua_State != NULL) { ! ClearCallbacks(); ! ! // remove refs table to try to clear memory gracefully ! lua_pushlightuserdata(m_lua_State, &wxlua_lreg_refs_key); ! lua_pushnil(m_lua_State); ! lua_rawset(m_lua_State, LUA_REGISTRYINDEX); ! ! lua_pushlightuserdata(m_lua_State, &wxlua_lreg_debug_refs_key); ! lua_pushnil(m_lua_State); ! lua_rawset(m_lua_State, LUA_REGISTRYINDEX); ! ! //lua_pushlightuserdata(m_lua_State, &wxlua_lreg_derivedmethods_key); // gc will delete them ! //lua_pushnil(m_lua_State); ! //lua_rawset(m_lua_State, LUA_REGISTRYINDEX); ! ! lua_gc(m_lua_State, LUA_GCCOLLECT, 0); // round up dead refs if (!m_lua_State_static) *************** *** 1206,1210 **** // Note: even though the lua_State is closed the pointer value is still good. // The wxLuaState we pushed into the reg table is a light userdata so ! // it doesn't get deleted. wxHashMapLuaState::iterator it = s_wxHashMapLuaState.find(m_lua_State); if (it != s_wxHashMapLuaState.end()) --- 1213,1217 ---- // Note: even though the lua_State is closed the pointer value is still good. // The wxLuaState we pushed into the reg table is a light userdata so ! // it didn't get deleted. wxHashMapLuaState::iterator it = s_wxHashMapLuaState.find(m_lua_State); if (it != s_wxHashMapLuaState.end()) *************** *** 1224,1290 **** void wxLuaStateRefData::ClearCallbacks() { ! // remove any and all callbacks that use this event handler since its gone ! wxList::compatibility_iterator node = m_wxlStateData->m_callbackList.GetFirst(); ! while (node) ! { ! wxLuaCallback *pCallback = (wxLuaCallback *)node->GetData(); ! wxCHECK_RET(pCallback, wxT("Invalid wxLuaCallback")); ! if (pCallback->GetwxLuaState().GetRefData() != this) // don't unref us ! pCallback->ClearwxLuaState(); ! ! node = node->GetNext(); ! } ! ! node = m_wxlStateData->m_winDestroyCallbackList.GetFirst(); ! while (node) ! { ! wxLuaWinDestroyCallback *pCallback = (wxLuaWinDestroyCallback *) node->GetData(); ! wxCHECK_RET(pCallback, wxT("Invalid wxLuaWinDestroyCallback")); ! if (pCallback->GetwxLuaState().GetRefData() != this) // don't unref us ! pCallback->ClearwxLuaState(); ! ! node = node->GetNext(); ! } ! m_wxlStateData->m_callbackList.Clear(); ! m_wxlStateData->m_winDestroyCallbackList.Clear(); ! } ! void wxLuaStateRefData::UnRegisterBindings() ! { ! if (m_lua_State == NULL) return; ! // UnRegister bindings ! wxLuaBindingList::compatibility_iterator node = m_wxlStateData->m_bindingList.GetFirst(); ! while (node) { ! wxLuaBinding* binding = node->GetData(); ! binding->UnRegisterBinding(m_lua_State); ! node = node->GetNext(); } ! lua_pushlightuserdata(m_lua_State, &wxlua_lreg_wxluastate_key); ! lua_pushnil(m_lua_State); ! lua_rawset(m_lua_State, LUA_REGISTRYINDEX); ! lua_pushlightuserdata(m_lua_State, &wxlua_lreg_tags_key); ! lua_pushnil(m_lua_State); ! lua_rawset(m_lua_State, LUA_REGISTRYINDEX); ! lua_pushlightuserdata(m_lua_State, &wxlua_lreg_refs_key); ! lua_pushnil(m_lua_State); ! lua_rawset(m_lua_State, LUA_REGISTRYINDEX); ! lua_pushlightuserdata(m_lua_State, &wxlua_lreg_debug_refs_key); ! lua_pushnil(m_lua_State); ! lua_rawset(m_lua_State, LUA_REGISTRYINDEX); ! lua_pushlightuserdata(m_lua_State, &wxlua_lreg_classes_key); ! lua_pushnil(m_lua_State); ! lua_rawset(m_lua_State, LUA_REGISTRYINDEX); ! //lua_pushlightuserdata(m_lua_State, &wxlua_lreg_derivedmethods_key); // gc will delete them ! //lua_pushnil(m_lua_State); ! //lua_rawset(m_lua_State, LUA_REGISTRYINDEX); } --- 1231,1284 ---- void wxLuaStateRefData::ClearCallbacks() { ! wxCHECK_RET(m_lua_State, wxT("Invalid lua_State")); ! lua_State* L = m_lua_State; ! lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! lua_pushnil(L); ! while (lua_next(L, -2) != 0) { ! // value = -1, key = -2, table = -3 ! wxLuaCallback* cb = (wxLuaCallback*)lua_touserdata(L, -1); ! wxCHECK_RET(cb, wxT("Invalid wxLuaCallback")); ! if (cb && (cb->GetwxLuaState().GetRefData() != this)) // don't unref us ! cb->ClearwxLuaState(); ! ! lua_pop(L, 1); // pop value, lua_next will pop key at end } ! lua_pop(L, 1); // pop table ! lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key ! lua_newtable(L); // push value ! lua_rawset(L, LUA_REGISTRYINDEX); // set t[key] = value, pops key and value ! // ---------------------------------------------------------------------- ! lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! lua_pushnil(L); ! while (lua_next(L, -2) != 0) ! { ! // value = -1, key = -2, table = -3 ! if (lua_type(L, -2) == LUA_TNUMBER) ! { ! wxLuaWinDestroyCallback* cb = (wxLuaWinDestroyCallback*)lua_touserdata(L, -1); ! wxCHECK_RET(cb, wxT("Invalid wxLuaWinDestroyCallback")); ! if (cb && (cb->GetwxLuaState().GetRefData() != this)) // don't unref us ! cb->ClearwxLuaState(); ! } ! ! lua_pop(L, 1); // pop value, lua_next will pop key at end ! } ! lua_pop(L, 1); // pop table ! ! lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_newtable(L); // push value ! lua_rawset(L, LUA_REGISTRYINDEX); // set t[key] = value, pops key and value } *************** *** 1580,1585 **** { wxLuaCharBuffer buf(script); ! int status = CompileBuffer((unsigned char*)buf.GetData(), buf.Length(), name, errMsg_, line_num_); ! return status; } int wxLuaState::CompileBuffer(const unsigned char buf[], size_t size, const wxString &name, wxString* errMsg_, int* line_num_) --- 1574,1578 ---- { wxLuaCharBuffer buf(script); ! return CompileBuffer((unsigned char*)buf.GetData(), buf.Length(), name, errMsg_, line_num_); } int wxLuaState::CompileBuffer(const unsigned char buf[], size_t size, const wxString &name, wxString* errMsg_, int* line_num_) *************** *** 1844,1848 **** lua_rawset(L, LUA_REGISTRYINDEX); // set the value ! // create the wxLuaClasses table in the registry lua_pushlightuserdata(L, &wxlua_lreg_classes_key); lua_newtable(L); --- 1837,1841 ---- lua_rawset(L, LUA_REGISTRYINDEX); // set the value ! // create the wxLuaBindClasses table in the registry lua_pushlightuserdata(L, &wxlua_lreg_classes_key); lua_newtable(L); *************** *** 1865,1868 **** --- 1858,1873 ---- lua_rawset( L, LUA_REGISTRYINDEX ); // set the value + // Create a table for wxLuaCallbacks + lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); + lua_newtable(L); + lua_rawset( L, LUA_REGISTRYINDEX ); // set the value + + // Create a table for wxLuaWinDestroyCallbacks + lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); + lua_newtable(L); + lua_rawset( L, LUA_REGISTRYINDEX ); // set the value + + wxLuaBinding::InitAllBindings(); // only runs the first time through + // Register bindings wxLuaBindingList::compatibility_iterator node = M_WXLSTATEDATA->m_wxlStateData->m_bindingList.GetFirst(); *************** *** 1876,1962 **** M_WXLSTATEDATA->m_wxlStateData->m_bindings_registered = true; - // setup base class tags, must do it here since we can have many bindings - // that have derived classes and they have to be installed first to get - // their tags initialized. - node = M_WXLSTATEDATA->m_wxlStateData->m_bindingList.GetFirst(); - while (node) - { - wxLuaBinding* binding = node->GetData(); - wxLuaBindClass* wxlClass = binding->GetClassArray(); - size_t i, class_count = binding->GetClassCount(); - - for (i = 0; i < class_count; ++i, ++wxlClass) - { - if (wxlClass->baseclassName) // does it have a name - { - wxLuaBindingList::compatibility_iterator basenode; - for (basenode = M_WXLSTATEDATA->m_wxlStateData->m_bindingList.GetFirst(); basenode; basenode = basenode->GetNext() ) - { - wxLuaBinding* basebinding = basenode->GetData(); - - // found base class in binding? - if (basebinding->SetBaseClass(wxlClass)) - break; - } - } - } - - node = node->GetNext(); - } - - // Link together all of the class member functions with base class functions - // with the same name so the overloads work for them too. - node = M_WXLSTATEDATA->m_wxlStateData->m_bindingList.GetFirst(); - while (node) - { - wxLuaBinding* binding = node->GetData(); - wxLuaBindClass* wxlClass = binding->GetClassArray(); - size_t i, class_count = binding->GetClassCount(); - - for (i = 0; i < class_count; ++i, ++wxlClass) - { - if (wxlClass->baseclass) // does it have a base class at all? - { - wxLuaBindMethod *wxlMethod = wxlClass->methods; - size_t j, method_count = wxlClass->methods_n; - - for (j = 0; j < method_count; ++j, ++wxlMethod) - { - // iterate through the base classes to find if this function is - // an overload, but only if we haven't checked already. - if (!WXLUA_HASBIT(wxlMethod->type, WXLUAMETHOD_OVERLOAD_BASE|WXLUAMETHOD_DELETE)) - { - wxLuaBindClass *baseClass = wxlClass->baseclass; - wxLuaBindMethod *parentMethod = wxlMethod; - - while (baseClass) - { - parentMethod->type |= WXLUAMETHOD_OVERLOAD_BASE; // have checked this - - wxLuaBindMethod* baseMethod = wxLuaBinding::GetClassMethod(baseClass, wxlMethod->name, false); - if (baseMethod) - { - // don't link to base class delete functions - if (!WXLUA_HASBIT(baseMethod->type, WXLUAMETHOD_DELETE)) - { - parentMethod->basemethod = baseMethod; - parentMethod = baseMethod; - } - - // we have already checked the base classes below this - if (WXLUA_HASBIT(baseMethod->type, WXLUAMETHOD_OVERLOAD_BASE)) - break; - } - - baseClass = baseClass->baseclass; - } - } - } - } - } - - node = node->GetNext(); - } - // Create a metatable for our C function wrapper wxLuaFunction g_wxluatag_wxLuaFunction = wxluaT_NewTag(); --- 1881,1884 ---- *************** *** 2172,2176 **** { wxArrayString names; - wxArrayInt counts; wxCHECK_MSG(Ok(), names, wxT("Invalid wxLuaState")); --- 2094,2097 ---- *************** *** 2187,2206 **** name = obj->GetClassInfo()->GetClassName(); ! //name = wxString::Format(wxT("%p "), obj) + name; ! ! int idx = names.Index(name); ! if (idx == wxNOT_FOUND) ! { ! names.Add(name); ! counts.Add(1); ! } ! else ! counts[idx]++; } - size_t n, count = names.GetCount(); - for (n = 0; n < count; ++n) - names[n] += wxString::Format(wxT(" %d"), counts[n]); - names.Sort(); return names; --- 2108,2114 ---- name = obj->GetClassInfo()->GetClassName(); ! names.Add(wxString::Format(wxT("%s %p"), name.c_str(), obj)); } names.Sort(); return names; *************** *** 2258,2262 **** { wxArrayString names; - wxArrayInt counts; wxCHECK_MSG(Ok(), names, wxT("Invalid wxLuaState")); --- 2166,2169 ---- *************** *** 2270,2281 **** { wxString name(win->GetClassInfo()->GetClassName()); ! int idx = names.Index(name); ! if (idx == wxNOT_FOUND) ! { ! names.Add(name); ! counts.Add(1); ! } ! else ! counts[idx]++; } --- 2177,2182 ---- { wxString name(win->GetClassInfo()->GetClassName()); ! ! names.Add(wxString::Format(wxT("%s %p"), name.c_str(), win)); } *************** *** 2283,2290 **** } - size_t n, count = names.GetCount(); - for (n = 0; n < count; ++n) - names[n] += wxString::Format(wxT(" %d"), counts[n]); - names.Sort(); return names; --- 2184,2187 ---- *************** *** 2302,2316 **** { wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); ! M_WXLSTATEDATA->m_wxlStateData->m_callbackList.Append(callback); } bool wxLuaState::RemoveTrackedCallback(wxLuaCallback* callback) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! return M_WXLSTATEDATA->m_wxlStateData->m_callbackList.DeleteObject(callback); ! } ! wxList* wxLuaState::GetTrackedCallbackList() ! { ! wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); ! return &M_WXLSTATEDATA->m_wxlStateData->m_callbackList; } --- 2199,2228 ---- { wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); ! lua_State* L = M_WXLSTATEDATA->m_lua_State; ! ! lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! ! lua_pushlightuserdata(L, callback); // push key ! lua_pushlightuserdata(L, callback->GetEvtHandler()); // push value ! lua_rawset(L, -3); // set t[key] = value; pops key and value ! ! lua_pop(L, 1); // pop table } bool wxLuaState::RemoveTrackedCallback(wxLuaCallback* callback) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! lua_State* L = M_WXLSTATEDATA->m_lua_State; ! ! lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! ! lua_pushlightuserdata(L, callback); // push key ! lua_pushnil(L); // push value ! lua_rawset(L, -3); // set t[key] = value; pops key and value ! ! lua_pop(L, 1); // pop table ! ! return true; // FIXME return a real value } *************** *** 2318,2330 **** { wxArrayString names; - wxArrayInt counts; wxCHECK_MSG(Ok(), names, wxT("Invalid wxLuaState")); ! wxList::compatibility_iterator node = GetTrackedCallbackList()->GetFirst(); ! while (node) { ! wxLuaCallback *wxlCallback = (wxLuaCallback *)node->GetData(); ! wxCHECK_MSG(wxlCallback, false, wxT("Invalid wxLuaCallback")); wxString evtName; --- 2230,2246 ---- { wxArrayString names; wxCHECK_MSG(Ok(), names, wxT("Invalid wxLuaState")); + lua_State* L = M_WXLSTATEDATA->m_lua_State; ! lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! ! lua_pushnil(L); ! while (lua_next(L, -2) != 0) { ! // value = -1, key = -2, table = -3 ! wxLuaCallback* wxlCallback = (wxLuaCallback*)lua_touserdata(L, -2); ! wxCHECK_MSG(wxlCallback, names, wxT("Invalid wxLuaCallback")); wxString evtName; *************** *** 2336,2359 **** wxLuaBinding* binding = bindNode->GetData(); evtName = binding->GetEventTypeName(wxlCallback->GetEventType()); ! if (!evtName.IsEmpty()) break; } } ! wxString name = wxString::Format(wxT("%s (%d)"), evtName.c_str(), (int)wxlCallback->GetEventType()); ! int idx = names.Index(name); ! if (idx == wxNOT_FOUND) ! { ! names.Add(name); ! counts.Add(1); ! } ! else ! counts[idx]++; ! ! node = node->GetNext(); } ! size_t n, count = names.GetCount(); ! for (n = 0; n < count; ++n) ! names[n] += wxString::Format(wxT(" %d"), counts[n]); names.Sort(); --- 2252,2266 ---- wxLuaBinding* binding = bindNode->GetData(); evtName = binding->GetEventTypeName(wxlCallback->GetEventType()); ! if (!evtName.IsEmpty()) break; // found event name } } + + names.Add(wxString::Format(wxT("%s (%d) wxEvtHandler(%p)-wxLuacallback(%p)"), + evtName.c_str(), (int)wxlCallback->GetEventType(), wxlCallback->GetEvtHandler(), wxlCallback)); ! lua_pop(L, 1); // pop value, lua_next will pop key at end } ! lua_pop(L, 1); // pop table names.Sort(); *************** *** 2364,2378 **** { wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); ! M_WXLSTATEDATA->m_wxlStateData->m_winDestroyCallbackList.Append(callback); } bool wxLuaState::RemoveTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! return M_WXLSTATEDATA->m_wxlStateData->m_winDestroyCallbackList.DeleteObject(callback); ! } ! wxList* wxLuaState::GetTrackedWinDestroyCallbackList() ! { ! wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); ! return &M_WXLSTATEDATA->m_wxlStateData->m_winDestroyCallbackList; } --- 2271,2308 ---- { wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); ! lua_State* L = M_WXLSTATEDATA->m_lua_State; ! ! lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! ! lua_pushlightuserdata(L, callback); // push key ! lua_pushnumber(L, 1); // push value ! lua_rawset(L, -3); // set t[key] = value; pops key and value ! ! lua_pushlightuserdata(L, callback->GetWindow()); // push key ! lua_pushlightuserdata(L, callback); // push value ! lua_rawset(L, -3); // set t[key] = value; pops key and value ! ! lua_pop(L, 1); // pop table } bool wxLuaState::RemoveTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! lua_State* L = M_WXLSTATEDATA->m_lua_State; ! ! lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! ! lua_pushlightuserdata(L, callback); // push key ! lua_pushnil(L); // push value ! lua_rawset(L, -3); // set t[key] = value; pops key and value ! ! lua_pushlightuserdata(L, callback->GetWindow()); // push key ! lua_pushnil(L); // push value ! lua_rawset(L, -3); // set t[key] = value; pops key and value ! ! lua_pop(L, 1); // pop table ! ! return true; // FIXME return if it was here or not } *************** *** 2380,2409 **** { wxArrayString names; - wxArrayInt counts; wxCHECK_MSG(Ok(), names, wxT("Invalid wxLuaState")); ! wxList::compatibility_iterator node = GetTrackedWinDestroyCallbackList()->GetFirst(); ! while (node) { ! wxLuaWinDestroyCallback *wxlDestroyCallBack = (wxLuaWinDestroyCallback *) node->GetData(); ! wxCHECK_MSG(wxlDestroyCallBack, false, wxT("Invalid wxLuaWinDestroyCallback")); ! wxString name(wxT("Unknown Tracked Window Type")); ! wxWindow* win = wxlDestroyCallBack->GetWindow(); ! if (win && win->GetClassInfo() && win->GetClassInfo()->GetClassName()) ! name = win->GetClassInfo()->GetClassName(); ! names.Add(name); ! counts.Add(1); ! node = node->GetNext(); } - size_t n, count = names.GetCount(); - for (n = 0; n < count; ++n) - names[n] += wxString::Format(wxT(" %d"), counts[n]); - names.Sort(); return names; --- 2310,2341 ---- { wxArrayString names; wxCHECK_MSG(Ok(), names, wxT("Invalid wxLuaState")); + lua_State* L = M_WXLSTATEDATA->m_lua_State; ! lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! ! lua_pushnil(L); ! while (lua_next(L, -2) != 0) { ! // value = -1, key = -2, table = -3 ! if (lua_type(L, -1) == LUA_TNUMBER) ! { ! wxLuaWinDestroyCallback* wxlDestroyCallBack = (wxLuaWinDestroyCallback*)lua_touserdata(L, -2); ! wxCHECK_MSG(wxlDestroyCallBack, names, wxT("Invalid wxLuaWinDestroyCallback")); ! wxString name(wxT("Unknown Tracked wxWindow Type")); ! wxWindow* win = wxlDestroyCallBack->GetWindow(); ! if (win && win->GetClassInfo() && win->GetClassInfo()->GetClassName()) ! name = win->GetClassInfo()->GetClassName(); ! names.Add(wxString::Format(wxT("%s(%p) wxLuaDestroyCallback(%p)"), name.c_str(), win, wxlDestroyCallBack)); ! } ! lua_pop(L, 1); } names.Sort(); return names; *************** *** 2557,2573 **** // check to make sure that we're not trying to attach another destroy callback bool destroy_handled = false; - wxList::compatibility_iterator node = M_WXLSTATEDATA->m_wxlStateData->m_winDestroyCallbackList.GetFirst(); - while (node) - { - wxLuaWinDestroyCallback *pCallback = (wxLuaWinDestroyCallback *)node->GetData(); ! if (pCallback->GetWindow() == win) ! { ! destroy_handled = true; ! break; ! } ! node = node->GetNext(); ! } // Connect an object to the destroy event and this will also set the --- 2489,2503 ---- // check to make sure that we're not trying to attach another destroy callback bool destroy_handled = false; ! lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! lua_pushlightuserdata(L, win); // push key ! lua_rawget(L, -2); // get t[key] = value; pops key ! ! if (lua_islightuserdata(L, -1)) ! destroy_handled = true; ! ! lua_pop(L, 2); // pop windestroy table and value // Connect an object to the destroy event and this will also set the Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** wxlbind.cpp 4 Dec 2007 05:20:28 -0000 1.97 --- wxlbind.cpp 5 Dec 2007 00:34:46 -0000 1.98 *************** *** 402,409 **** int LUACALL wxluabind__newindex_wxLuaBindClass(lua_State *L) { - wxLuaState wxlState(L); - wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); - wxLuaBindClass *wxlClass = (wxLuaBindClass *)lua_touserdata(L, lua_upvalueindex(1)); const char *name = lua_tostring(L, 2); bool found = false; --- 402,408 ---- int LUACALL wxluabind__newindex_wxLuaBindClass(lua_State *L) { wxLuaBindClass *wxlClass = (wxLuaBindClass *)lua_touserdata(L, lua_upvalueindex(1)); + wxCHECK_MSG(wxlClass, 0, wxT("Invalid wxLuaBindClass")); + const char *name = lua_tostring(L, 2); bool found = false; *************** *** 440,443 **** --- 439,445 ---- if (!found) { + wxLuaState wxlState(L); + wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); + void *pObject = wxlua_touserdata(L, 1, false); wxLuaObject* wxlObj = new wxLuaObject(wxlState, 3); *************** *** 565,568 **** --- 567,571 ---- wxLuaBindingList wxLuaBinding::sm_bindingList; + bool wxLuaBinding::sm_bindingList_initialized = false; wxLuaBinding::wxLuaBinding() : wxObject(), *************** *** 688,699 **** } - void wxLuaBinding::UnRegisterBinding(const wxLuaState& wxlState_) - { - wxLuaState wxlState(wxlState_); // unconst the state - wxlState.lua_PushString(m_nameSpace); - wxlState.lua_PushNil(); - wxlState.lua_RawSet(LUA_GLOBALSINDEX); - } - void wxLuaBinding::DoRegisterBinding(const wxLuaState& wxlState_, int tableOffset) { --- 691,694 ---- *************** *** 801,813 **** // add the items to the table as t[first pushed] = second pushed ! lua_pushstring(L, "new"); lua_pushcfunction(L, wxlMethod->funcs[0].func); lua_rawset(L, -3); // same as lua_setfield(L, -2, "key") // Create the metatable for this table - //luaL_newmetatable(L, wxlMethod->func); // we don't need to register it lua_newtable(L); ! lua_pushstring(L, "__call"); lua_pushlightuserdata(L, &wxluabind_checkremovetable); // push tag to recognize table call lua_pushcclosure(L, wxlMethod->funcs[0].func, 1); // push func with tag as upvalue --- 796,807 ---- // add the items to the table as t[first pushed] = second pushed ! lua_pushlstring(L, "new", 3); lua_pushcfunction(L, wxlMethod->funcs[0].func); lua_rawset(L, -3); // same as lua_setfield(L, -2, "key") // Create the metatable for this table lua_newtable(L); ! lua_pushlstring(L, "__call", 6); lua_pushlightuserdata(L, &wxluabind_checkremovetable); // push tag to recognize table call lua_pushcclosure(L, wxlMethod->funcs[0].func, 1); // push func with tag as upvalue *************** *** 821,825 **** // add table to the binding table t[wxlMethod->name] = { this table } ! lua_rawset(L, -3); // same as lua_settable(L, tableOffset); #elif 0 // C++ constructors are userdata, use metatable for access to items. --- 815,819 ---- // add table to the binding table t[wxlMethod->name] = { this table } ! lua_rawset(L, -3); #elif 0 // C++ constructors are userdata, use metatable for access to items. *************** *** 1079,1080 **** --- 1073,1161 ---- } + void wxLuaBinding::InitAllBindings(bool force_update) + { + if (sm_bindingList_initialized && !force_update) return; + + // setup base class tags + wxLuaBindingList::compatibility_iterator node = sm_bindingList.GetFirst(); + while (node) + { + wxLuaBinding* binding = node->GetData(); + wxLuaBindClass* wxlClass = binding->GetClassArray(); + size_t i, class_count = binding->GetClassCount(); + + for (i = 0; i < class_count; ++i, ++wxlClass) + { + if (wxlClass->baseclassName) // does it have a name + { + wxLuaBindingList::compatibility_iterator basenode; + for (basenode = sm_bindingList.GetFirst(); basenode; basenode = basenode->GetNext() ) + { + wxLuaBinding* basebinding = basenode->GetData(); + + // found base class in binding? + if (basebinding->SetBaseClass(wxlClass)) + break; + } + } + } + + node = node->GetNext(); + } + + // Link together all of the class member functions with base class functions + // with the same name so the overloads work for them too. + node = sm_bindingList.GetFirst(); + while (node) + { + wxLuaBinding* binding = node->GetData(); + wxLuaBindClass* wxlClass = binding->GetClassArray(); + size_t i, class_count = binding->GetClassCount(); + + for (i = 0; i < class_count; ++i, ++wxlClass) + { + if (wxlClass->baseclass) // does it have a base class at all? + { + wxLuaBindMethod *wxlMethod = wxlClass->methods; + size_t j, method_count = wxlClass->methods_n; + + for (j = 0; j < method_count; ++j, ++wxlMethod) + { + // iterate through the base classes to find if this function is + // an overload, but only if we haven't checked already. + if (!WXLUA_HASBIT(wxlMethod->type, WXLUAMETHOD_OVERLOAD_BASE|WXLUAMETHOD_DELETE)) + { + wxLuaBindClass *baseClass = wxlClass->baseclass; + wxLuaBindMethod *parentMethod = wxlMethod; + + while (baseClass) + { + parentMethod->type |= WXLUAMETHOD_OVERLOAD_BASE; // have checked this + + wxLuaBindMethod* baseMethod = wxLuaBinding::GetClassMethod(baseClass, wxlMethod->name, false); + if (baseMethod) + { + // don't link to base class delete functions + if (!WXLUA_HASBIT(baseMethod->type, WXLUAMETHOD_DELETE)) + { + parentMethod->basemethod = baseMethod; + parentMethod = baseMethod; + } + + // we have already checked the base classes below this + if (WXLUA_HASBIT(baseMethod->type, WXLUAMETHOD_OVERLOAD_BASE)) + break; + } + + baseClass = baseClass->baseclass; + } + } + } + } + } + + node = node->GetNext(); + } + + sm_bindingList_initialized = true; + } \ No newline at end of file Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** wxlcallb.cpp 4 Dec 2007 05:20:28 -0000 1.44 --- wxlcallb.cpp 5 Dec 2007 00:34:46 -0000 1.45 *************** *** 36,43 **** wxCHECK_RET(m_wxlState.Ok(), wxT("Invalid wxLuaState")); - m_wxlState.AddTrackedCallback(this); - m_wxlBindEvent = wxlState.GetLuaEvent(eventType); if (m_wxlBindEvent == NULL) { --- 36,43 ---- wxCHECK_RET(m_wxlState.Ok(), wxT("Invalid wxLuaState")); m_wxlBindEvent = wxlState.GetLuaEvent(eventType); + m_wxlState.AddTrackedCallback(this); + if (m_wxlBindEvent == NULL) { *************** *** 79,96 **** // Ok if !Ok() since the wxLuaState may been cleared during shutdown or after destroy event wxLuaState wxlState(theCallback->GetwxLuaState()); ! if (!wxlState.Ok()) ! return; ! ! wxEventType evtType = event.GetEventType(); ! wxlState.SetInEventType(evtType); ! theCallback->CallFunction(&event); ! // we want the wxLuaWinDestroyCallback to get this too ! if (evtType == wxEVT_DESTROY) ! event.Skip(); ! wxlState.SetInEventType(wxEVT_NULL); } --- 79,96 ---- // Ok if !Ok() since the wxLuaState may been cleared during shutdown or after destroy event wxLuaState wxlState(theCallback->GetwxLuaState()); ! if (wxlState.Ok()) ! { ! wxEventType evtType = event.GetEventType(); ! wxlState.SetInEventType(evtType); ! theCallback->CallFunction(&event); ! // we want the wxLuaWinDestroyCallback to get this too ! if (evtType == wxEVT_DESTROY) ! event.Skip(); ! wxlState.SetInEventType(wxEVT_NULL); ! } } *************** *** 138,141 **** --- 138,142 ---- // don't track this since we didn't create it // Tracking this causes clashes in the object registry table + // since many can be created and deleted and the mem address is resused by C++. wxlState.wxluaT_PushUserTag(event, event_tag, false); wxlState.LuaPCall(1, 0); *************** *** 213,236 **** // and when the dialog is closed the frame below sends an activation event, // but we're right in the middle of being destroyed and we crash. ! wxList::compatibility_iterator node = m_wxlState.GetTrackedCallbackList()->GetFirst(); ! while (node) { ! wxLuaCallback *wxlCallback = (wxLuaCallback *)node->GetData(); if (wxlCallback->GetEvtHandler() == evtHandler) { - // delete the reference to all other handlers that are cleared - wxList::compatibility_iterator pc_node = node; // remember current node - node = node->GetNext(); - m_wxlState.GetTrackedCallbackList()->Erase(pc_node); - // remove the ref to the routine since we're clearing the wxLuaState // See ~wxLuaCallback m_wxlState.wxluaR_Unref(wxlCallback->GetLuaRoutine(), &wxlua_lreg_refs_key); wxlCallback->ClearwxLuaState(); } ! else ! node = node->GetNext(); } } } --- 214,248 ---- // and when the dialog is closed the frame below sends an activation event, // but we're right in the middle of being destroyed and we crash. ! ! lua_State* L = m_wxlState.GetLuaState(); ! ! lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! ! lua_pushnil(L); ! while (lua_next(L, -2) != 0) { ! // value = -1, key = -2, table = -3 ! wxLuaCallback* wxlCallback = (wxLuaCallback*)lua_touserdata(L, -1); ! wxCHECK_RET(wxlCallback, wxT("Invalid wxLuaCallback")); if (wxlCallback->GetEvtHandler() == evtHandler) { // remove the ref to the routine since we're clearing the wxLuaState // See ~wxLuaCallback m_wxlState.wxluaR_Unref(wxlCallback->GetLuaRoutine(), &wxlua_lreg_refs_key); wxlCallback->ClearwxLuaState(); + + lua_pop(L, 1); // pop value + + lua_pushvalue(L, -1); // copy key for next iteration + lua_pushnil(L); + lua_rawset(L, -4); // set t[key] = nil to remove it } ! else ! lua_pop(L, 1); // pop value, lua_next will pop key at end } + + lua_pop(L, 1); // pop table } } Index: wxlua_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua_bind.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** wxlua_bind.cpp 4 Dec 2007 05:20:28 -0000 1.10 --- wxlua_bind.cpp 5 Dec 2007 00:34:46 -0000 1.11 *************** *** 1,4 **** // --------------------------------------------------------------------------- ! // This file was generated by genwxbind.lua // // Any changes made to this file may be lost when file is regenerated. --- 1,4 ---- // --------------------------------------------------------------------------- ! // This file was generated by genwxbind.lua // // Any changes made to this file may be lost when file is regenerated. *************** *** 965,969 **** { "wxLUA_CHECK_VERSION_FULL", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_wxLUA_CHECK_VERSION_FULL, 1, NULL }, ! { 0, 0, 0, 0 }, }; count = sizeof(functionList)/sizeof(wxLuaBindMethod) - 1; --- 965,969 ---- { "wxLUA_CHECK_VERSION_FULL", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_wxLUA_CHECK_VERSION_FULL, 1, NULL }, ! { 0, 0, 0, 0 }, }; count = sizeof(functionList)/sizeof(wxLuaBindMethod) - 1; *************** *** 981,988 **** static wxLuaBindClass classList[] = { ! { "wxLuaObject", wxLuaObject_methods, wxLuaObject_methodCount, CLASSINFO(wxLuaObject), &s_wxluatag_wxLuaObject, "wxObject", NULL ,s_wxluadefineArray_None, 0, }, ! { "wxLuaState", wxLuaState_methods, wxLuaState_methodCount, CLASSINFO(wxLuaState), &s_wxluatag_wxLuaState, "wxObject", NULL ,s_wxluadefineArray_None, 0, }, ! { 0, 0, 0, 0, 0, 0, 0 }, }; count = sizeof(classList)/sizeof(wxLuaBindClass) - 1; --- 981,988 ---- static wxLuaBindClass classList[] = { ! { "wxLuaObject", wxLuaObject_methods, wxLuaObject_methodCount, CLASSINFO(wxLuaObject), &s_wxluatag_wxLuaObject, "wxObject", NULL ,s_wxluadefineArray_None, 0, }, ! { "wxLuaState", wxLuaState_methods, wxLuaState_methodCount, CLASSINFO(wxLuaState), &s_wxluatag_wxLuaState, "wxObject", NULL ,s_wxluadefineArray_None, 0, }, ! { 0, 0, 0, 0, 0, 0, 0 }, }; count = sizeof(classList)/sizeof(wxLuaBindClass) - 1; |
From: John L. <jr...@us...> - 2007-12-05 00:34:51
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv21421/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: Removed the rest of "UnregisterBinding" functions since they did nothing useful Moved binding base class linking code to wxLuaBinding::InitAllBindings from wxLuaState::RegisterBindings Removed wxLuaStateData::m_winDestroyCallbackList and wxLuaStateData::m_callbackList and added two registry tables for their values. Should be faster and easier to verify operation. Fix searching in the wxLuaStackDialog. Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** wxlstack.cpp 4 Dec 2007 16:26:11 -0000 1.23 --- wxlstack.cpp 5 Dec 2007 00:34:46 -0000 1.24 *************** *** 676,683 **** wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); ! int trackedCount = wxlState.GetTrackedObjects()->size(); ! int callbackCount = wxlState.GetTrackedCallbackList()->GetCount(); ! int windowCount = wxlState.GetLuaStateData()->m_windowList.GetCount(); ! int destroyCount = wxlState.GetTrackedWinDestroyCallbackList()->GetCount(); // note: don't have spaces here since we use them to mark expanded levels --- 676,683 ---- wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); ! int trackedCount = wxlState.GetTrackedObjectStrings().GetCount(); ! int callbackCount = wxlState.GetTrackedCallbackStrings().GetCount(); ! int windowCount = wxlState.GetTrackedWindowStrings().GetCount(); ! int destroyCount = wxlState.GetTrackedWinDestroyCallbackStrings().GetCount(); // note: don't have spaces here since we use them to mark expanded levels *************** *** 874,878 **** if (start_item < 0) { ! i = direction > 0 ? 0 : list_count - 1; wrap_count++; // we're looking at all the elements } --- 874,878 ---- if (start_item < 0) { ! i = (direction > 0) ? 0 : list_count - 1; wrap_count++; // we're looking at all the elements } *************** *** 885,889 **** else { ! i = direction > 0 ? 0 : list_count - 1; } --- 885,889 ---- else { ! i = (direction > 0) ? 0 : list_count - 1; } *************** *** 895,899 **** txt = GetItemText(i, col, true); ! if (match_case) txt.MakeLower(); if ((whole_string && (txt == findStr)) || --- 895,899 ---- txt = GetItemText(i, col, true); ! if (!match_case) txt.MakeLower(); if ((whole_string && (txt == findStr)) || *************** *** 1092,1096 **** { wxLuaDebugItem *item = new wxLuaDebugItem(strArr[n].BeforeLast(wxT(' ')), WXLUAARG_None, ! wxT("Count ")+strArr[n].AfterLast(wxT(' ')), WXLUAARG_None, wxT(""), LUA_NOREF, debugItem->GetIndex() + 1); dataArr.Add(item); --- 1092,1096 ---- { wxLuaDebugItem *item = new wxLuaDebugItem(strArr[n].BeforeLast(wxT(' ')), WXLUAARG_None, ! strArr[n].AfterLast(wxT(' ')), WXLUAARG_None, wxT(""), LUA_NOREF, debugItem->GetIndex() + 1); dataArr.Add(item); Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** wxldebug.cpp 4 Dec 2007 05:20:29 -0000 1.54 --- wxldebug.cpp 5 Dec 2007 00:34:46 -0000 1.55 *************** *** 463,468 **** (udata == &wxlua_lreg_derivedmethods_key) || (udata == &wxlua_lreg_wxluastate_key) || - (udata == &wxlua_lreg_callbaseclassfunc_key) || (udata == &wxlua_lreg_objects_key) || (udata == &wxlua_metatable_tag_key) || (udata == &wxlua_metatable_wxluabindclass_key)) --- 463,470 ---- (udata == &wxlua_lreg_derivedmethods_key) || (udata == &wxlua_lreg_wxluastate_key) || (udata == &wxlua_lreg_objects_key) || + (udata == &wxlua_lreg_evtcallbacks_key) || + (udata == &wxlua_lreg_windestroycallbacks_key) || + (udata == &wxlua_lreg_callbaseclassfunc_key) || (udata == &wxlua_metatable_tag_key) || (udata == &wxlua_metatable_wxluabindclass_key)) |
From: John L. <jr...@us...> - 2007-12-05 00:34:51
|
Update of /cvsroot/wxlua/wxLua/modules/wxbind/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv21421/wxLua/modules/wxbind/src Modified Files: wxbase_bind.cpp wxcore_bind.cpp Log Message: Removed the rest of "UnregisterBinding" functions since they did nothing useful Moved binding base class linking code to wxLuaBinding::InitAllBindings from wxLuaState::RegisterBindings Removed wxLuaStateData::m_winDestroyCallbackList and wxLuaStateData::m_callbackList and added two registry tables for their values. Should be faster and easier to verify operation. Fix searching in the wxLuaStackDialog. Index: wxcore_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxbind/src/wxcore_bind.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** wxcore_bind.cpp 17 Nov 2007 00:14:58 -0000 1.5 --- wxcore_bind.cpp 5 Dec 2007 00:34:46 -0000 1.6 *************** *** 3849,3853 **** // wxKillError rc = NULL wxKillError rc = wxKILL_OK; ! //wxKillError * rc = (argCount >= 3 ? (wxKillError *)wxlState.wxluaT_ToUserdata(3) : NULL); // wxSignal sig = wxSIGTERM wxSignal sig = (argCount >= 2 ? (wxSignal)wxlua_getintegertype(L, 2) : wxSIGTERM); --- 3849,3853 ---- // wxKillError rc = NULL wxKillError rc = wxKILL_OK; ! //wxKillError * rc = (argCount >= 3 ? (wxKillError *)wxlua_touserdata(L, 3) : NULL); // wxSignal sig = wxSIGTERM wxSignal sig = (argCount >= 2 ? (wxSignal)wxlua_getintegertype(L, 2) : wxSIGTERM); Index: wxbase_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxbind/src/wxbase_bind.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** wxbase_bind.cpp 17 Nov 2007 00:14:57 -0000 1.3 --- wxbase_bind.cpp 5 Dec 2007 00:34:46 -0000 1.4 *************** *** 2492,2504 **** void wxLuaBinding_wxbase::PostRegister(const wxLuaState& wxlState, int luaTable) { ! wxLuaState wxLS(wxlState); ! wxCHECK_RET(wxLS.Ok(), wxT("Invalid wxLuaState")); ! lua_State* L = wxLS.GetLuaState(); ! g_wxluatag_NULL = wxLS.wxluaT_NewTag(); lua_pushlstring(L, "NULL", 4); ! wxLS.wxluaT_PushUserTag(NULL, g_wxluatag_NULL, true); ! lua_rawset(L, luaTable); } --- 2492,2504 ---- void wxLuaBinding_wxbase::PostRegister(const wxLuaState& wxlState, int luaTable) { ! wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); ! lua_State* L = wxlState.GetLuaState(); ! g_wxluatag_NULL = wxluaT_newtag(L); ! lua_pop(L, 1); // pop the table lua_pushlstring(L, "NULL", 4); ! wxluaT_pushusertag(L, NULL, g_wxluatag_NULL, true); ! lua_rawset(L, luaTable); // set t["NULL"] = userdata(NULL) w/ NULL tag } |
From: John L. <jr...@us...> - 2007-12-05 00:34:50
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv21421/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlstate.h Log Message: Removed the rest of "UnregisterBinding" functions since they did nothing useful Moved binding base class linking code to wxLuaBinding::InitAllBindings from wxLuaState::RegisterBindings Removed wxLuaStateData::m_winDestroyCallbackList and wxLuaStateData::m_callbackList and added two registry tables for their values. Should be faster and easier to verify operation. Fix searching in the wxLuaStackDialog. Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** wxlbind.h 4 Dec 2007 05:20:28 -0000 1.66 --- wxlbind.h 5 Dec 2007 00:34:46 -0000 1.67 *************** *** 393,398 **** // Binds C Functions/Defines/Object/Events to namespace Lua Table virtual bool RegisterBinding(const wxLuaState& wxlState); - // Unbinds C Functions/Defines/Object/Events by clearing namespace Lua table - virtual void UnRegisterBinding(const wxLuaState& wxlState); // ----------------------------------------------------------------------- --- 393,396 ---- *************** *** 427,431 **** // Is this tag defined as something in this binding? ! bool IsTag(int tag) { return (tag >= m_start_tag) && (tag <= m_last_tag); } // Look for the base class of the input wxLuaBindClass in this binding using the --- 425,429 ---- // 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 *************** *** 472,475 **** --- 470,479 ---- static wxLuaBindingList* GetBindingList() { return &sm_bindingList; } + + // 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 *************** *** 508,511 **** --- 512,516 ---- static wxLuaBindingList sm_bindingList; + static bool sm_bindingList_initialized; DECLARE_ABSTRACT_CLASS(wxLuaBinding) Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -d -r1.98 -r1.99 *** wxlstate.h 4 Dec 2007 05:20:28 -0000 1.98 --- wxlstate.h 5 Dec 2007 00:34:46 -0000 1.99 *************** *** 100,105 **** 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 t[lightuserdata] = [weak valued full userdata] extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_objects_key; // The key in the LUA_REGISTRYINDEX table that is a boolean value // of whether the Lua code has prepended a '_' to function name to indicate --- 100,114 ---- 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. t[lightuserdata] = [weak valued full userdata] extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_objects_key; + // The key in the LUA_REGISTRYINDEX table that is table of all + // wxLuaCallbacks that we've created. + // t[lightuserdata wxLuaCallback] = lightuserdata wxEvtHandler + extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_evtcallbacks_key; + // The key in the LUA_REGISTRYINDEX table that is table of all + // wxLuaWinDestroyCallbacks that we've created. + // t[lightuserdata wxLuaWinDestroyCallback] = 1 (the number 1) + // t[lightuserdata wxWindow] = lightuserdata wxLuaWinDestroyCallback + extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_windestroycallbacks_key; // The key in the LUA_REGISTRYINDEX table that is a boolean value // of whether the Lua code has prepended a '_' to function name to indicate *************** *** 107,110 **** --- 116,120 ---- extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_callbaseclassfunc_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. *************** *** 325,329 **** bool m_bindings_registered; // Are the bindings registered into the lua_State ! wxEventType m_inEventType; // wxEventType set when in event, else wxEVT_NULL wxLongToLongHashMap m_trackedObjects; // tracked wxObjects that we will delete when the --- 335,339 ---- bool m_bindings_registered; // Are the bindings registered into the lua_State ! wxEventType m_inEventType; // wxEventType set when in event, else wxEVT_NULL wxLongToLongHashMap m_trackedObjects; // tracked wxObjects that we will delete when the *************** *** 333,338 **** // wxLUA_DECLARE_ENCAPSULATION so the key is the object pointer // and the value is the wxObject encapsulation. - wxList m_callbackList; // installed wxLuaCallbacks - wxList m_winDestroyCallbackList; // installed wxLuaWinDestroyCallbacks wxWindowList m_windowList; // all wxWindow objects, wxWidgets will delete these // but for an embedded program they must be deleted before --- 343,346 ---- *************** *** 374,379 **** // clear all wxLuaCallbacks on destruction void ClearCallbacks(); - // remove all the bindings - void UnRegisterBindings(); // ------------------------------------------------------------------------ --- 382,385 ---- *************** *** 675,679 **** void AddTrackedCallback(wxLuaCallback* callback); bool RemoveTrackedCallback(wxLuaCallback* callback); - wxList* GetTrackedCallbackList(); // Get an array of strings "wxEVT_XXX (wxEventType #) count#" wxArrayString GetTrackedCallbackStrings(); --- 681,684 ---- *************** *** 682,686 **** void AddTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback); bool RemoveTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback); - wxList* GetTrackedWinDestroyCallbackList(); // Get an array of strings "wxWindow_classname count#" wxArrayString GetTrackedWinDestroyCallbackStrings(); --- 687,690 ---- |
From: John L. <jr...@us...> - 2007-12-05 00:34:50
|
Update of /cvsroot/wxlua/wxLua/bindings/wxwidgets In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv21421/wxLua/bindings/wxwidgets Modified Files: wxbase_rules.lua Log Message: Removed the rest of "UnregisterBinding" functions since they did nothing useful Moved binding base class linking code to wxLuaBinding::InitAllBindings from wxLuaState::RegisterBindings Removed wxLuaStateData::m_winDestroyCallbackList and wxLuaStateData::m_callbackList and added two registry tables for their values. Should be faster and easier to verify operation. Fix searching in the wxLuaStackDialog. Index: wxbase_rules.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/wxwidgets/wxbase_rules.lua,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** wxbase_rules.lua 17 Nov 2007 00:14:55 -0000 1.4 --- wxbase_rules.lua 5 Dec 2007 00:34:45 -0000 1.5 *************** *** 134,146 **** wxLuaBinding_PostRegister = [[ ! wxLuaState wxLS(wxlState); ! wxCHECK_RET(wxLS.Ok(), wxT("Invalid wxLuaState")); ! lua_State* L = wxLS.GetLuaState(); ! g_wxluatag_NULL = wxLS.wxluaT_NewTag(); lua_pushlstring(L, "NULL", 4); ! wxLS.wxluaT_PushUserTag(NULL, g_wxluatag_NULL, true); ! lua_rawset(L, luaTable); ]] --- 134,146 ---- wxLuaBinding_PostRegister = [[ ! wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); ! lua_State* L = wxlState.GetLuaState(); ! g_wxluatag_NULL = wxluaT_newtag(L); ! lua_pop(L, 1); // pop the table lua_pushlstring(L, "NULL", 4); ! wxluaT_pushusertag(L, NULL, g_wxluatag_NULL, true); ! lua_rawset(L, luaTable); // set t["NULL"] = userdata(NULL) w/ NULL tag ]] |
From: John L. <jr...@us...> - 2007-12-05 00:34:50
|
Update of /cvsroot/wxlua/wxLua/bindings/wxlua In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv21421/wxLua/bindings/wxlua Modified Files: override.hpp Log Message: Removed the rest of "UnregisterBinding" functions since they did nothing useful Moved binding base class linking code to wxLuaBinding::InitAllBindings from wxLuaState::RegisterBindings Removed wxLuaStateData::m_winDestroyCallbackList and wxLuaStateData::m_callbackList and added two registry tables for their values. Should be faster and easier to verify operation. Fix searching in the wxLuaStackDialog. Index: override.hpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/wxlua/override.hpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** override.hpp 17 Nov 2007 00:14:55 -0000 1.8 --- override.hpp 5 Dec 2007 00:34:44 -0000 1.9 *************** *** 133,137 **** // this may a wxLua data if (ltype == LUA_TUSERDATA) ! wxluaarg_tag = wxluaT_tag(L, 1); // I guess it wasn't or isn't a userdata --- 133,137 ---- // this may a wxLua data if (ltype == LUA_TUSERDATA) ! wxluaarg_tag = wxluaT_gettag(L, 1); // I guess it wasn't or isn't a userdata |
From: John L. <jr...@us...> - 2007-12-04 16:26:16
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv20946/wxLua/modules/wxluadebug/src Modified Files: wxlstack.cpp Log Message: Show linked table message when expanding all for the first table only Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** wxlstack.cpp 4 Dec 2007 05:20:29 -0000 1.22 --- wxlstack.cpp 4 Dec 2007 16:26:11 -0000 1.23 *************** *** 109,113 **** stkCtrl->m_itemAttr.SetTextColour(m_stkDlg->m_typeColours[img]); ! //SetBackgroundColour return &stkCtrl->m_itemAttr; --- 109,115 ---- stkCtrl->m_itemAttr.SetTextColour(m_stkDlg->m_typeColours[img]); ! ! //unsigned char c = 255 - (stkListData->m_level % 5)*22; ! //stkCtrl->m_itemAttr.SetBackgroundColour(wxColour(c,c,c)); return &stkCtrl->m_itemAttr; *************** *** 444,447 **** --- 446,450 ---- { case 0: + { if (exact_value) return debugItem->GetKey(); *************** *** 456,459 **** --- 459,463 ---- else return debugItem->GetKey(); + } case 1: return wxString::Format(wxT("%d:%d"), stkListData->m_level+1, stkListData->m_item_idx+1); *************** *** 715,741 **** } - wxTreeItemId wxLuaStackDialog::FindTreeItemId(const wxTreeItemId& id_, wxLuaStackListData* stkListData) const - { - wxTreeItemIdValue cookie; - wxTreeItemId id = m_treeCtrl->GetFirstChild(id_, cookie); - - while (id) - { - wxTreeItemId i = FindTreeItemId(id, stkListData); - if (i) return i; - - wxLuaStackTreeData* data = (wxLuaStackTreeData*)m_treeCtrl->GetItemData(id); - if (data != NULL) - { - if (data->m_stkListData == stkListData) - return id; - } - - id = m_treeCtrl->GetNextChild(id_, cookie); - } - - return wxTreeItemId(); - } - long wxLuaStackDialog::FindListItem(wxLuaStackListData* stkListData, bool get_parent) const { --- 719,722 ---- *************** *** 816,830 **** if (list_item >= 0) { ! wxListItem li; ! li.SetId(list_item); ! li.SetMask(wxLIST_MASK_TEXT); ! li.SetColumn(id - ID_WXLUA_STACK_LISTMENU_COPY0); ! m_listCtrl->GetItem(li); if (wxTheClipboard->Open()) { ! // This data objects are held by the clipboard, // so do not delete them in the app. ! wxTheClipboard->SetData( new wxTextDataObject(li.GetText()) ); wxTheClipboard->Close(); } --- 797,807 ---- if (list_item >= 0) { ! wxString s(GetItemText(list_item, id - ID_WXLUA_STACK_LISTMENU_COPY0, true)); if (wxTheClipboard->Open()) { ! // These data objects are held by the clipboard, // so do not delete them in the app. ! wxTheClipboard->SetData( new wxTextDataObject(s) ); wxTheClipboard->Close(); } *************** *** 1151,1155 **** wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); - m_show_dup_expand_msg = false; BeginBatch(); --- 1128,1131 ---- *************** *** 1164,1167 **** --- 1140,1146 ---- while (n < (int)m_listData.GetCount()) { + // show message for first item only so it doesn't silently fail + if (n > lc_item) m_show_dup_expand_msg = false; + wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listData[n]; |
From: John L. <jr...@us...> - 2007-12-04 16:26:16
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv20946/wxLua/modules/wxluadebug/include Modified Files: wxldebug.h wxlstack.h Log Message: Show linked table message when expanding all for the first table only Index: wxldebug.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/include/wxldebug.h,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** wxldebug.h 4 Dec 2007 05:20:29 -0000 1.46 --- wxldebug.h 4 Dec 2007 16:26:11 -0000 1.47 *************** *** 96,100 **** // ---------------------------------------------------------------------------- // wxLuaDebugData - a wxObject ref counted container for a wxLuaDebugItemArray ! // The Ref data is always expected to exist and the destructor deletes the array items // ---------------------------------------------------------------------------- --- 96,100 ---- // ---------------------------------------------------------------------------- // wxLuaDebugData - a wxObject ref counted container for a wxLuaDebugItemArray ! // The destructor deletes the array items. // ---------------------------------------------------------------------------- Index: wxlstack.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/include/wxlstack.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** wxlstack.h 4 Dec 2007 05:20:29 -0000 1.13 --- wxlstack.h 4 Dec 2007 16:26:11 -0000 1.14 *************** *** 177,181 **** void EndBatch(); - wxTreeItemId FindTreeItemId(const wxTreeItemId& id, wxLuaStackListData* stkListData) const; long FindListItem(wxLuaStackListData* stkListData, bool get_parent = false) const; --- 177,180 ---- *************** *** 229,235 **** int m_batch_count; ! wxLongToLongHashMap m_expandedItems; ! wxArrayPtrVoid m_listData; static wxSize m_defaultSize; // remember last dialog size --- 228,234 ---- int m_batch_count; ! wxLongToLongHashMap m_expandedItems; // map[long Lua table ptr] = &wxLuaStackListData ! wxArrayPtrVoid m_listData; // array of wxLuaStackListData static wxSize m_defaultSize; // remember last dialog size |
From: John L. <jr...@us...> - 2007-12-04 05:20:33
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16657/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp wxlcallb.cpp wxlstate.cpp wxlua_bind.cpp Log Message: After separating the tags, refs, and debug refs in the Lua registry rename the wxluaT_XXX functions to match what they operate on wxluaR_ for generic ref functions wxluaT_ for tag functions wxluaO_ for object functions Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.141 retrieving revision 1.142 diff -C2 -d -r1.141 -r1.142 *** wxlstate.cpp 3 Dec 2007 23:47:24 -0000 1.141 --- wxlstate.cpp 4 Dec 2007 05:20:28 -0000 1.142 *************** *** 43,48 **** // ---------------------------------------------------------------------------- ! // The print function that we push into Lua replacing "print(...)" ! // to generate wxLuaEvent(wxEVT_LUA_PRINT, ...) // Code copied from Lua's luaB_print() function in lbaselib.c int LUACALL wxlua_printFunction( lua_State *L ) --- 43,48 ---- // ---------------------------------------------------------------------------- ! // The print function that we push into Lua replacing "print(...)" ! // to generate wxLuaEvent(wxEVT_LUA_PRINT, ...) // Code copied from Lua's luaB_print() function in lbaselib.c int LUACALL wxlua_printFunction( lua_State *L ) *************** *** 178,185 **** // call ref 3 times and the new references will be 4, 3, 6 ! int wxluaT_insert(lua_State* L, int stack_idx, const void* lightuserdata_reg_key) { // nothing on stack to insert and don't bother inserting nil ! if (lua_isnoneornil(L, stack_idx)) return LUA_REFNIL; --- 178,185 ---- // call ref 3 times and the new references will be 4, 3, 6 ! int wxluaR_ref(lua_State* L, int stack_idx, const void* lightuserdata_reg_key) { // nothing on stack to insert and don't bother inserting nil ! if (lua_isnoneornil(L, stack_idx)) return LUA_REFNIL; *************** *** 195,199 **** { lua_pushvalue(L, ABS_LUA_STKIDX(stack_idx,1)); // push key ! lua_pushnumber(L, table_idx); // push value lua_rawset(L, -3); // set t[key] = value; pops key and value } --- 195,199 ---- { lua_pushvalue(L, ABS_LUA_STKIDX(stack_idx,1)); // push key ! lua_pushnumber(L, table_idx); // push value lua_rawset(L, -3); // set t[key] = value; pops key and value } *************** *** 204,208 **** } ! bool wxluaT_remove(lua_State* L, int table_idx, const void* lightuserdata_reg_key) { if (table_idx == LUA_REFNIL) // nothing to remove --- 204,208 ---- } ! bool wxluaR_unref(lua_State* L, int table_idx, const void* lightuserdata_reg_key) { if (table_idx == LUA_REFNIL) // nothing to remove *************** *** 216,220 **** { lua_pushnumber(L, table_idx); // push key ! lua_rawget(L, -2); // get t[key] = value; pop key, push value; lua_pushnil(L); --- 216,220 ---- { lua_pushnumber(L, table_idx); // push key ! lua_rawget(L, -2); // get t[key] = value; pop key, push value; lua_pushnil(L); *************** *** 223,227 **** luaL_unref(L, -1, table_idx); // remove key and value in refs table ! // note: this key will be used for the next wxluaT_insert lua_pop(L, 1); // pop table --- 223,227 ---- luaL_unref(L, -1, table_idx); // remove key and value in refs table ! // note: this key will be used for the next wxluaR_ref lua_pop(L, 1); // pop table *************** *** 230,234 **** } ! bool LUACALL wxluaT_get(lua_State *L, int table_idx, const void* lightuserdata_reg_key) { if (table_idx == LUA_REFNIL) // nothing to get --- 230,234 ---- } ! bool LUACALL wxluaR_getref(lua_State *L, int table_idx, const void* lightuserdata_reg_key) { if (table_idx == LUA_REFNIL) // nothing to get *************** *** 251,254 **** --- 251,338 ---- } + int LUACALL wxluaR_isrefed(lua_State* L, int stack_idx, const void* lightuserdata_reg_key) + { + int tag = LUA_NOREF; + + lua_pushlightuserdata(L, (void*)lightuserdata_reg_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + + if (lightuserdata_reg_key == &wxlua_lreg_debug_refs_key) + { + // For this table we push the value for a faster index + lua_pushvalue(L, ABS_LUA_STKIDX(stack_idx,1)); // push key (the value) + lua_rawget(L, -2); // get t[key] = value; pop key push value + + if (lua_isnumber(L, -1)) + tag = (int)lua_tonumber(L, -1); + + lua_pop(L, 2); // pop object we pushed and the ref table + } + else + { + // otherwise search through all the values + lua_pushnil(L); + while (lua_next(L, -2) != 0) + { + // value = -1, key = -2, table = -3, object = stack_idx before 3 added items + if (lua_equal(L, -1, ABS_LUA_STKIDX(stack_idx,3))) + { + tag = (int)lua_tonumber(L, -2); + lua_pop(L, 2); // pop key, value + break; + } + else + lua_pop(L, 1); // pop value, lua_next will pop key at end + } + + lua_pop(L, 1); // pop object we pushed and the ref table + } + + return tag; + } + + int wxluaT_newtag(lua_State* L) + { + lua_newtable(L); // create a table for our new tag + int tag = wxluaR_ref(L, -1, &wxlua_lreg_tags_key); // insert the table into the registry table + + lua_pushlightuserdata(L, &wxlua_metatable_tag_key); // push key + lua_pushnumber(L, tag); // push value + lua_rawset(L, -3); // t[key] = value; pop key and value + + return tag; // leave the table on the stack + } + + int LUACALL wxluaT_gettag(lua_State *L, int stack_idx) + { + int tag = WXLUA_NOTAG; + + if (lua_getmetatable(L, stack_idx) != 0) // see wxluaT_newtag + { + lua_pushlightuserdata(L, &wxlua_metatable_tag_key); // push key + lua_rawget(L, -2); // get t[key] = value; pop key push value + + //if (lua_isnumber(L, -1)) // Note: lua_tonumber returns 0 == WXLUA_NOTAG if it's not a number + tag = (int)lua_tonumber(L, -1); + + lua_pop(L, 2); // pop metatable and tag number + } + + return tag; + } + + bool LUACALL wxluaT_settag(lua_State *L, int tag) + { + if (wxluaR_getref(L, tag, &wxlua_lreg_tags_key)) // get the metatable + { + if (lua_setmetatable(L, -2)) // set it as the metatable of the object at the top of the stack + return true; + else + wxlua_error(L, "wxLua: Unable to set metatable in wxluaT_settag."); + } + + return false; + } + bool LUACALL wxluaT_pushusertag(lua_State *L, const void *u, int tag, bool track) { *************** *** 262,267 **** if (tag != g_wxluatag_wxLuaFunction) { ! lua_pushlightuserdata(L, &wxlua_lreg_objects_key); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (the obj table) lua_pushlightuserdata(L, (void*)u); // push key lua_rawget(L, -2); // get t[key] value; pop key push value --- 346,352 ---- if (tag != g_wxluatag_wxLuaFunction) { ! lua_pushlightuserdata(L, &wxlua_lreg_objects_key); // push key lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (the obj table) + lua_pushlightuserdata(L, (void*)u); // push key lua_rawget(L, -2); // get t[key] value; pop key push value *************** *** 272,276 **** return true; } ! lua_pop(L, 2); // pop the table and the nil. } --- 357,361 ---- return true; } ! lua_pop(L, 2); // pop the table and the nil. } *************** *** 282,286 **** *ptr = u; // try to get the object's references table and set the metatable to the object ! if (wxluaT_get(L, tag, &wxlua_lreg_tags_key)) { // pop the table and set it as the metatable for the newuserdata --- 367,371 ---- *ptr = u; // try to get the object's references table and set the metatable to the object ! if (wxluaR_getref(L, tag, &wxlua_lreg_tags_key)) { // pop the table and set it as the metatable for the newuserdata *************** *** 313,317 **** } ! void LUACALL wxluaT_untrackuserdata(lua_State *L, const void *u) { lua_pushlightuserdata(L, &wxlua_lreg_objects_key); // push key --- 398,402 ---- } ! void LUACALL wxluaO_untrackuserdata(lua_State *L, const void *u) { lua_pushlightuserdata(L, &wxlua_lreg_objects_key); // push key *************** *** 320,328 **** lua_pushlightuserdata(L, (void*)u); // push key lua_pushnil(L); // push value ! lua_rawset(L, -3); // t[key] = nil; pops key and value lua_pop(L, 1); // pop objects table } ! void LUACALL wxluaT_cleartrackedmetatable(lua_State *L, const void *u) { lua_pushlightuserdata(L, &wxlua_lreg_objects_key); // push key --- 405,413 ---- lua_pushlightuserdata(L, (void*)u); // push key lua_pushnil(L); // push value ! lua_rawset(L, -3); // set t[key] = nil; pops key and value lua_pop(L, 1); // pop objects table } ! void LUACALL wxluaO_cleartrackedmetatable(lua_State *L, const void *u) { lua_pushlightuserdata(L, &wxlua_lreg_objects_key); // push key *************** *** 341,362 **** } - int LUACALL wxluaT_tag(lua_State *L, int stack_idx) - { - int tag = WXLUA_NOTAG; - - if (lua_getmetatable(L, stack_idx) != 0) // see wxluaT_newtag - { - lua_pushlightuserdata(L, &wxlua_metatable_tag_key); // push key - lua_rawget(L, -2); // get t[key] = value; pop key push value - - //if (lua_isnumber(L, -1)) // Note: lua_tonumber returns 0 == WXLUA_NOTAG if it's not a number - tag = (int)lua_tonumber(L, -1); - - lua_pop(L, 2); // pop metatable and tag number - } - - return tag; - } - void* LUACALL wxlua_touserdata(lua_State *L, int stack_idx, bool null_ptr /* = false*/) { --- 426,429 ---- *************** *** 374,443 **** } - int wxluaT_newtag(lua_State* L) - { - lua_newtable(L); // create a table for our new tag - int tag = wxluaT_insert(L, -1, &wxlua_lreg_tags_key); // insert the table into the registry table - - lua_pushlightuserdata(L, &wxlua_metatable_tag_key); // push key - lua_pushnumber(L, tag); // push value - lua_rawset(L, -3); // t[key] = value; pop key and value - - return tag; // leave the table on the stack - } - - bool LUACALL wxluaT_settag(lua_State *L, int tag) - { - if (wxluaT_get(L, tag, &wxlua_lreg_tags_key)) // get the metatable table from the wxLuaReferences registry table - { - if (lua_setmetatable(L, -2)) // set it as the metatable of the object at the top of the stack - return true; - else - wxlua_error(L, "wxLua: Unable to set metatable in wxluaT_settag."); - } - - return false; - } - - int LUACALL wxluaT_isrefed(lua_State* L, int stack_idx, const void* lightuserdata_reg_key) - { - int tag = LUA_NOREF; - - lua_pushlightuserdata(L, (void*)lightuserdata_reg_key); // push key - lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) - - if (lightuserdata_reg_key == &wxlua_lreg_debug_refs_key) - { - // For this table we push the value for a faster index - lua_pushvalue(L, ABS_LUA_STKIDX(stack_idx,1)); // push key (the value) - lua_rawget(L, -2); // get t[key] = value; pop key push value - - if (lua_isnumber(L, -1)) - tag = (int)lua_tonumber(L, -1); - - lua_pop(L, 2); // pop object we pushed and the ref table - } - else - { - // otherwise search through all the values - lua_pushnil(L); - while (lua_next(L, -2) != 0) - { - // value = -1, key = -2, table = -3, object = stack_idx before 3 added items - if (lua_equal(L, -1, ABS_LUA_STKIDX(stack_idx,3))) - { - tag = (int)lua_tonumber(L, -2); - lua_pop(L, 2); // pop key, value - break; - } - else - lua_pop(L, 1); // pop value, lua_next will pop key at end - } - - lua_pop(L, 1); // pop object we pushed and the ref table - } - - return tag; - } - // ---------------------------------------------------------------------------- // Functions to get info about the tags wxlua uses to determine type --- 441,444 ---- *************** *** 446,451 **** const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, int class_tag) { ! // note: wxluaT_get doesn't leave anything on the stack on failure ! if (wxluaT_get(L, class_tag, &wxlua_lreg_tags_key) && lua_istable(L, -1)) { // t[class_tag] = { [bindclass_key] = lightuserdata wxLuaBindClass... (or nil if not a class tag) --- 447,452 ---- const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, int class_tag) { ! // note: wxluaR_getref() doesn't leave anything on the stack on failure ! if (wxluaR_getref(L, class_tag, &wxlua_lreg_tags_key) && lua_istable(L, -1)) { // t[class_tag] = { [bindclass_key] = lightuserdata wxLuaBindClass... (or nil if not a class tag) *************** *** 468,472 **** lua_pushstring(L, class_name); // push key ! lua_rawget(L, -2); // get t["class_name"] = &wxLuaBindClass; pop key push value const wxLuaBindClass* wxlClass = (wxLuaBindClass *)lua_touserdata(L, -1); // actually lightuserdata --- 469,473 ---- lua_pushstring(L, class_name); // push key ! lua_rawget(L, -2); // get t["class_name"] = &wxLuaBindClass; pop key push value const wxLuaBindClass* wxlClass = (wxLuaBindClass *)lua_touserdata(L, -1); // actually lightuserdata *************** *** 798,820 **** lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push value (table) ! if (lua_istable(L, -1)) // else not installed or already removed? Not good in any case. ! { ! lua_pushlightuserdata(L, (void *)pObject); // push key ! lua_rawget(L, -2); // get t[key] = value, pop key push value ! ! if (!lua_istable(L, -1)) ! { ! lua_pop(L, 1); // pop nil value ! // add new table for this object ! lua_pushlightuserdata(L, (void *)pObject); ! lua_newtable(L); ! lua_rawset(L, -3); ! // put the new table back on the top of the stack ! lua_pushlightuserdata(L, (void *)pObject); ! lua_rawget(L, -2); ! } // see if there already is a method lua_pushstring( L, method_name ); --- 799,820 ---- lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push value (table) ! lua_pushlightuserdata(L, (void *)pObject); // push key ! lua_rawget(L, -2); // get t[key] = value, pop key push value ! if (!lua_istable(L, -1)) ! { ! lua_pop(L, 1); // pop nil value ! // add new table for this object ! lua_pushlightuserdata(L, (void *)pObject); // push key ! lua_newtable(L); // push value ! lua_rawset(L, -3); // set t[key] = value; pops key and value + // put the new table back on the top of the stack + lua_pushlightuserdata(L, (void *)pObject); + lua_rawget(L, -2); + } + else + { // see if there already is a method lua_pushstring( L, method_name ); *************** *** 829,845 **** lua_pop(L, 1); // pop the deleted old object, or nil ! lua_pushstring( L, method_name ); ! lua_pushlightuserdata(L, (void*)wxlObj); ! lua_rawset(L, -3); ! lua_pop(L, 2); // pop the object and overridden function table ! } ! else ! { ! lua_pop(L, 1); // pop the nil reg table ! wxlua_error(L, "wxLua: The wxLuaDerivedMethods table in the registry is missing!"); ! return false; ! } return true; --- 829,839 ---- lua_pop(L, 1); // pop the deleted old object, or nil + } ! lua_pushstring( L, method_name ); // push key ! lua_pushlightuserdata(L, (void*)wxlObj); // push value ! lua_rawset(L, -3); // set t[key] = value; pops key and value ! lua_pop(L, 2); // pop the object and overridden function table return true; *************** *** 848,888 **** { bool found = false; lua_pushlightuserdata(L, &wxlua_lreg_derivedmethods_key); lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push table ! if (lua_istable(L, -1)) // else not installed or already removed? Not good in any case. ! { ! wxLuaObject* wxlObj = NULL; ! ! lua_pushlightuserdata(L, (void *)pObject); ! lua_rawget(L, -2); // pop key, push table or nil ! if (lua_istable(L, -1)) ! { ! // see if there is a method with the same name ! lua_pushstring( L, method_name ); ! lua_rawget(L, -2); ! if (lua_islightuserdata(L, -1)) ! wxlObj = (wxLuaObject*)lua_touserdata( L, -1 ); ! lua_pop(L, 1); // pop the method object or nil ! } ! lua_pop(L, 2); // pop registry table and object table or nil ! if (wxlObj != NULL) ! { ! if (push_method && wxlObj->GetObject()) ! found = true; ! else if (!push_method) ! found = true; ! } ! } ! else { ! lua_pop(L, 1); // pop the nil reg table ! wxlua_error(L, "wxLua: The wxLuaDerivedMethods table in the registry is missing!"); } --- 842,874 ---- { bool found = false; + wxLuaObject* wxlObj = NULL; lua_pushlightuserdata(L, &wxlua_lreg_derivedmethods_key); lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push table ! lua_pushlightuserdata(L, (void *)pObject); ! lua_rawget(L, -2); // pop key, push table or nil ! if (lua_istable(L, -1)) ! { ! // see if there is a method with the same name ! lua_pushstring( L, method_name ); ! lua_rawget(L, -2); ! if (lua_islightuserdata(L, -1)) ! wxlObj = (wxLuaObject*)lua_touserdata( L, -1 ); ! lua_pop(L, 1); // pop the method object or nil ! } ! lua_pop(L, 2); // pop registry table and object table or nil ! if (wxlObj != NULL) { ! // if we've got the object, put it on top of the stack ! if (push_method && wxlObj->GetObject()) ! found = true; ! else if (!push_method) ! found = true; } *************** *** 896,941 **** lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push table ! if (lua_istable(L, -1)) // else not installed or already removed? Not good in any case. { ! lua_pushlightuserdata(L, (void *)pObject); ! lua_rawget(L, -2); // pop key, push table or nil ! if (lua_istable(L, -1)) { ! found = true; ! lua_pushnil(L); /* first key */ ! while (lua_next(L, -2) != 0) { ! // uses 'key' (at index -2) and 'value' (at index -1) ! //wxPrintf(wxT("%s - %s\n"), lua2wx(lua_tostring(L, -2)).c_str(), lua2wx(lua_typename(L, lua_type(L, -1))).c_str()); ! ! if (lua_islightuserdata(L, -1)) ! { ! wxLuaObject* o = (wxLuaObject*)lua_touserdata(L, -1); ! delete o; ! } ! ! // removes 'value'; keeps 'key' for next iteration ! lua_pop(L, 1); } ! lua_pop(L, 1); // pop the obj table so reg table is on top ! lua_pushlightuserdata(L, (void *)pObject); // push key ! lua_pushnil(L); // push value, to remove it ! lua_rawset(L, -3); // set t[key] = value; pop key and value ! lua_pop(L, 1); // pop reg table ! } ! else ! lua_pop(L, 2); // pop the reg table and nil for the obj table } else ! { ! lua_pop(L, 1); // pop the nil reg table ! wxlua_error(L, "wxLua: The wxLuaDerivedMethods table in the registry is missing!"); ! return false; ! } return found; --- 882,917 ---- lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push table ! lua_pushlightuserdata(L, (void *)pObject); ! lua_rawget(L, -2); // pop key, push table or nil ! ! if (lua_istable(L, -1)) { ! found = true; ! // delete all of the derived methods we've pushed ! lua_pushnil(L); /* first key */ ! while (lua_next(L, -2) != 0) { ! // uses 'key' (at index -2) and 'value' (at index -1) ! if (lua_islightuserdata(L, -1)) { ! wxLuaObject* o = (wxLuaObject*)lua_touserdata(L, -1); ! delete o; } ! lua_pop(L, 1); // remove value; keep key for next iteration ! } ! lua_pop(L, 1); // pop the obj table so reg table is on top ! lua_pushlightuserdata(L, (void *)pObject); // push key ! lua_pushnil(L); // push value, to remove it ! lua_rawset(L, -3); // set t[key] = value; pop key and value ! ! lua_pop(L, 1); // pop reg table } else ! lua_pop(L, 2); // pop the reg table and nil for the obj table return found; *************** *** 2155,2159 **** // Nor are we tracking it within the Lua reg table if (WXLUA_HASBIT(flags, CLEAR_TRACKED_OBJECT)) ! wxluaT_untrackuserdata(L, pObject); wxLongToLongHashMap::iterator it = M_WXLSTATEDATA->m_wxlStateData->m_trackedObjects.find((long) pObject); --- 2131,2135 ---- // Nor are we tracking it within the Lua reg table if (WXLUA_HASBIT(flags, CLEAR_TRACKED_OBJECT)) ! wxluaO_untrackuserdata(L, pObject); wxLongToLongHashMap::iterator it = M_WXLSTATEDATA->m_wxlStateData->m_trackedObjects.find((long) pObject); *************** *** 2437,2456 **** // wxLua Lua Registry Table Functions ! int wxLuaState::wxluaT_Insert(int stack_idx, const void* lightuserdata_reg_key) { wxCHECK_MSG(Ok(), LUA_REFNIL, wxT("Invalid wxLuaState")); ! return wxluaT_insert(M_WXLSTATEDATA->m_lua_State, stack_idx, lightuserdata_reg_key); } ! bool wxLuaState::wxluaT_Remove(int wxlref_index, const void* lightuserdata_reg_key) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! return wxluaT_remove(M_WXLSTATEDATA->m_lua_State, wxlref_index, lightuserdata_reg_key); } ! bool wxLuaState::wxluaT_Get(int wxlref_index, const void* lightuserdata_reg_key) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! return wxluaT_get(M_WXLSTATEDATA->m_lua_State, wxlref_index, lightuserdata_reg_key); } --- 2413,2432 ---- // wxLua Lua Registry Table Functions ! int wxLuaState::wxluaR_Ref(int stack_idx, const void* lightuserdata_reg_key) { wxCHECK_MSG(Ok(), LUA_REFNIL, wxT("Invalid wxLuaState")); ! return wxluaR_ref(M_WXLSTATEDATA->m_lua_State, stack_idx, lightuserdata_reg_key); } ! bool wxLuaState::wxluaR_Unref(int wxlref_index, const void* lightuserdata_reg_key) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! return wxluaR_unref(M_WXLSTATEDATA->m_lua_State, wxlref_index, lightuserdata_reg_key); } ! bool wxLuaState::wxluaR_GetRef(int wxlref_index, const void* lightuserdata_reg_key) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! return wxluaR_getref(M_WXLSTATEDATA->m_lua_State, wxlref_index, lightuserdata_reg_key); } *************** *** 2467,2474 **** } ! int wxLuaState::wxluaT_Tag(int stack_idx) const { wxCHECK_MSG(Ok(), WXLUA_NOTAG, wxT("Invalid wxLuaState")); ! return wxluaT_tag(M_WXLSTATEDATA->m_lua_State, stack_idx); } --- 2443,2450 ---- } ! int wxLuaState::wxluaT_GetTag(int stack_idx) const { wxCHECK_MSG(Ok(), WXLUA_NOTAG, wxT("Invalid wxLuaState")); ! return wxluaT_gettag(M_WXLSTATEDATA->m_lua_State, stack_idx); } *************** *** 2529,2533 **** if (wxlua_iswxuserdata(L, stack_idx)) { ! int stack_tag = wxluaT_tag(L, stack_idx); if ((g_wxluatag_NULL == stack_tag) || // FIXME, how to check when NULL is valid or not? (g_wxluatag_wxLuaFunction == stack_tag) || --- 2505,2509 ---- if (wxlua_iswxuserdata(L, stack_idx)) { ! int stack_tag = wxluaT_gettag(L, stack_idx); if ((g_wxluatag_NULL == stack_tag) || // FIXME, how to check when NULL is valid or not? (g_wxluatag_wxLuaFunction == stack_tag) || *************** *** 2547,2551 **** if (wxlua_iswxuserdata(L, stack_idx)) { ! int stack_tag = wxluaT_tag(L, stack_idx); if (g_wxluatag_wxLuaFunction == stack_tag) --- 2523,2527 ---- if (wxlua_iswxuserdata(L, stack_idx)) { ! int stack_tag = wxluaT_gettag(L, stack_idx); if (g_wxluatag_wxLuaFunction == stack_tag) *************** *** 2632,2636 **** else if (wxlua_iswxuserdata(L, stack_idx)) { ! int stack_tag = wxluaT_tag(L, stack_idx); if (wxlua_isderivedclass(L, stack_tag, g_wxluatag_wxString) >= 0) --- 2608,2612 ---- else if (wxlua_iswxuserdata(L, stack_idx)) { ! int stack_tag = wxluaT_gettag(L, stack_idx); if (wxlua_isderivedclass(L, stack_tag, g_wxluatag_wxString) >= 0) *************** *** 2672,2676 **** else if (wxlua_iswxuserdata(L, stack_idx)) { ! int stack_tag = wxluaT_tag(L, stack_idx); return (wxlua_isderivedclass(L, stack_tag, g_wxluatag_wxString) >= 0); } --- 2648,2652 ---- else if (wxlua_iswxuserdata(L, stack_idx)) { ! int stack_tag = wxluaT_gettag(L, stack_idx); return (wxlua_isderivedclass(L, stack_tag, g_wxluatag_wxString) >= 0); } *************** *** 2750,2754 **** else if (wxlua_iswxuserdata(L, stack_idx)) { ! int class_tag = wxluaT_tag(L, stack_idx); const wxLuaBindClass* wxlClass = wxluaT_getclass(L, class_tag); const wxLuaBindClass* arrStrClass = wxluaT_getclass(L, "wxArrayString"); --- 2726,2730 ---- else if (wxlua_iswxuserdata(L, stack_idx)) { ! int class_tag = wxluaT_gettag(L, stack_idx); const wxLuaBindClass* wxlClass = wxluaT_getclass(L, class_tag); const wxLuaBindClass* arrStrClass = wxluaT_getclass(L, "wxArrayString"); *************** *** 2850,2854 **** else if (wxlua_iswxuserdata(L, stack_idx)) { ! int class_tag = wxluaT_tag(L, stack_idx); const wxLuaBindClass* wxlClass = wxluaT_getclass(L, class_tag); const wxLuaBindClass* arrIntClass = wxluaT_getclass(L, "wxArrayInt"); --- 2826,2830 ---- else if (wxlua_iswxuserdata(L, stack_idx)) { ! int class_tag = wxluaT_gettag(L, stack_idx); const wxLuaBindClass* wxlClass = wxluaT_getclass(L, class_tag); const wxLuaBindClass* arrIntClass = wxluaT_getclass(L, "wxArrayInt"); *************** *** 3845,3849 **** else { ! int tag = wxluaT_Tag(arg+1+lua_argStart); fnCall += GetLuaTagName(tag); } --- 3821,3825 ---- else { ! int tag = wxluaT_GetTag(arg+1+lua_argStart); fnCall += GetLuaTagName(tag); } Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** wxlbind.cpp 30 Nov 2007 23:00:07 -0000 1.96 --- wxlbind.cpp 4 Dec 2007 05:20:28 -0000 1.97 *************** *** 69,73 **** { // Sanity check, but this is only attached to a wxLuaFunction, so it has to be ok. ! //if (wxlua_iswxuserdata(L, 1) && (wxluaT_tag(L, 1) == g_wxluatag_wxLuaFunction)) { wxLuaFunction *wxlFunction = (wxLuaFunction *)wxlua_touserdata(L, 1, true); --- 69,73 ---- { // Sanity check, but this is only attached to a wxLuaFunction, so it has to be ok. ! //if (wxlua_iswxuserdata(L, 1) && (wxluaT_gettag(L, 1) == g_wxluatag_wxLuaFunction)) { wxLuaFunction *wxlFunction = (wxLuaFunction *)wxlua_touserdata(L, 1, true); *************** *** 81,85 **** { // Sanity check, but this is only attached to a wxLuaFunction, so it has to be ok. ! //if (wxlua_iswxuserdata(L, 1) && (wxluaT_tag(L, 1) == g_wxluatag_wxLuaFunction)) { wxLuaFunction *f = (wxLuaFunction *)wxlua_touserdata(L, 1, false); --- 81,85 ---- { // Sanity check, but this is only attached to a wxLuaFunction, so it has to be ok. ! //if (wxlua_iswxuserdata(L, 1) && (wxluaT_gettag(L, 1) == g_wxluatag_wxLuaFunction)) { wxLuaFunction *f = (wxLuaFunction *)wxlua_touserdata(L, 1, false); *************** *** 101,105 **** { // set up the reference to the item on the stack ! m_reference = m_wxlState->wxluaT_Insert(stack_idx, &wxlua_lreg_refs_key); } --- 101,105 ---- { // set up the reference to the item on the stack ! m_reference = m_wxlState->wxluaR_Ref(stack_idx, &wxlua_lreg_refs_key); } *************** *** 113,117 **** // If a refererence exists, remove it, but don't bother if Lua is being closed if ((m_reference != LUA_NOREF) && m_wxlState->Ok() && !m_wxlState->IsClosing()) ! m_wxlState->wxluaT_Remove(m_reference, &wxlua_lreg_refs_key); delete m_wxlState; --- 113,117 ---- // If a refererence exists, remove it, but don't bother if Lua is being closed if ((m_reference != LUA_NOREF) && m_wxlState->Ok() && !m_wxlState->IsClosing()) ! m_wxlState->wxluaR_Unref(m_reference, &wxlua_lreg_refs_key); delete m_wxlState; *************** *** 148,152 **** return true; } ! else if (m_wxlState->wxluaT_Get(m_reference, &wxlua_lreg_refs_key)) return true; --- 148,152 ---- return true; } ! else if (m_wxlState->wxluaR_GetRef(m_reference, &wxlua_lreg_refs_key)) return true; *************** *** 159,165 **** if (m_reference != LUA_NOREF) // FIXME should this error out? ! m_wxlState->wxluaT_Remove(m_reference, &wxlua_lreg_refs_key); ! m_reference = m_wxlState->wxluaT_Insert(stack_idx, &wxlua_lreg_refs_key); } --- 159,165 ---- if (m_reference != LUA_NOREF) // FIXME should this error out? ! m_wxlState->wxluaR_Unref(m_reference, &wxlua_lreg_refs_key); ! m_reference = m_wxlState->wxluaR_Ref(stack_idx, &wxlua_lreg_refs_key); } *************** *** 243,247 **** wxLuaBindClass *wxlClass = (wxLuaBindClass *)lua_touserdata(L, lua_upvalueindex(1)); ! if ((wxlClass != NULL) && wxlua_iswxuserdata(L, 1) && (wxluaT_tag(L, 1) == *wxlClass->class_tag)) { wxLuaState wxlState(L); --- 243,247 ---- wxLuaBindClass *wxlClass = (wxLuaBindClass *)lua_touserdata(L, lua_upvalueindex(1)); ! if ((wxlClass != NULL) && wxlua_iswxuserdata(L, 1) && (wxluaT_gettag(L, 1) == *wxlClass->class_tag)) { wxLuaState wxlState(L); *************** *** 311,315 **** lua2wx(lua_typename(L, lua_type(L, 2))).c_str(), lua2wx(wxlClass ? wxlClass->name : "").c_str())); } ! else if ((wxlClass != NULL) && wxlua_iswxuserdata(L, 1) && (wxluaT_tag(L, 1) == *wxlClass->class_tag)) { void *pObject = wxlua_touserdata(L, 1, false); --- 311,315 ---- lua2wx(lua_typename(L, lua_type(L, 2))).c_str(), lua2wx(wxlClass ? wxlClass->name : "").c_str())); } ! else if ((wxlClass != NULL) && wxlua_iswxuserdata(L, 1) && (wxluaT_gettag(L, 1) == *wxlClass->class_tag)) { void *pObject = wxlua_touserdata(L, 1, false); *************** *** 409,413 **** bool found = false; ! if ((wxlClass != NULL) && wxlua_iswxuserdata(L, 1) && (wxluaT_tag(L, 1) == *wxlClass->class_tag)) { // See if there is a WXLUAMETHOD_SETPROP in the wxLuaBindClass's wxLuaBindMethods --- 409,413 ---- bool found = false; ! if ((wxlClass != NULL) && wxlua_iswxuserdata(L, 1) && (wxluaT_gettag(L, 1) == *wxlClass->class_tag)) { // See if there is a WXLUAMETHOD_SETPROP in the wxLuaBindClass's wxLuaBindMethods *************** *** 465,469 **** str = wxString::Format(wxT("userdata: %p"), lua_touserdata(L, 1)); ! int nTag = wxluaT_tag(L, 1); if (nTag != WXLUA_NOTAG) { --- 465,469 ---- str = wxString::Format(wxT("userdata: %p"), lua_touserdata(L, 1)); ! int nTag = wxluaT_gettag(L, 1); if (nTag != WXLUA_NOTAG) { *************** *** 673,677 **** { // create a ref for the wxLua table we're filling ! m_luaTable_ref = wxlState.wxluaT_Insert(-1, &wxlua_lreg_refs_key); } --- 673,677 ---- { // create a ref for the wxLua table we're filling ! m_luaTable_ref = wxlState.wxluaR_Ref(-1, &wxlua_lreg_refs_key); } *************** *** 750,754 **** } ! lua_remove(L, -1); // remove metatable we got from wxluaT_get // ------------------------------------------------------------------ --- 750,754 ---- } ! lua_remove(L, -1); // remove metatable we got from wxluaR_getref() // ------------------------------------------------------------------ *************** *** 833,837 **** *ptr = wxlClass; ! wxluaT_get(L, iTag); lua_setmetatable(L, -2); --- 833,837 ---- *ptr = wxlClass; ! wxluaR_getref(L, iTag); lua_setmetatable(L, -2); Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** wxlcallb.cpp 30 Nov 2007 23:00:07 -0000 1.43 --- wxlcallb.cpp 4 Dec 2007 05:20:28 -0000 1.44 *************** *** 52,56 **** // create a reference to the Lua event handler function if (lua_func_stack_idx != WXLUACALLBACK_NOROUTINE) ! m_routine = m_wxlState.wxluaT_Insert(lua_func_stack_idx, &wxlua_lreg_refs_key); m_evtHandler->Connect(win_id, last_id, eventType, --- 52,56 ---- // create a reference to the Lua event handler function if (lua_func_stack_idx != WXLUACALLBACK_NOROUTINE) ! m_routine = m_wxlState.wxluaR_Ref(lua_func_stack_idx, &wxlua_lreg_refs_key); m_evtHandler->Connect(win_id, last_id, eventType, *************** *** 64,68 **** if (m_wxlState.Ok()) { ! m_wxlState.wxluaT_Remove(m_routine, &wxlua_lreg_refs_key); // delete the reference to this handler m_wxlState.RemoveTrackedCallback(this); --- 64,68 ---- if (m_wxlState.Ok()) { ! m_wxlState.wxluaR_Unref(m_routine, &wxlua_lreg_refs_key); // delete the reference to this handler m_wxlState.RemoveTrackedCallback(this); *************** *** 131,135 **** wxlState.lua_CheckStack(LUA_MINSTACK); int oldTop = wxlState.lua_GetTop(); ! if (wxlState.wxluaT_Get(m_routine, &wxlua_lreg_refs_key)) { wxlState.lua_PushValue(LUA_GLOBALSINDEX); --- 131,135 ---- wxlState.lua_CheckStack(LUA_MINSTACK); int oldTop = wxlState.lua_GetTop(); ! if (wxlState.wxluaR_GetRef(m_routine, &wxlua_lreg_refs_key)) { wxlState.lua_PushValue(LUA_GLOBALSINDEX); *************** *** 200,204 **** { // clear the metatable for the copy of the we are tracking (clears it for all copies too) ! wxluaT_cleartrackedmetatable(m_wxlState.GetLuaState(), m_window); // Now remove the object since it's gone m_wxlState.RemoveTrackedObject(m_window, wxLuaState::CLEAR_TRACKED_OBJECT|wxLuaState::CLEAR_DERIVED_METHODS); --- 200,204 ---- { // clear the metatable for the copy of the we are tracking (clears it for all copies too) ! wxluaO_cleartrackedmetatable(m_wxlState.GetLuaState(), m_window); // Now remove the object since it's gone m_wxlState.RemoveTrackedObject(m_window, wxLuaState::CLEAR_TRACKED_OBJECT|wxLuaState::CLEAR_DERIVED_METHODS); *************** *** 227,231 **** // remove the ref to the routine since we're clearing the wxLuaState // See ~wxLuaCallback ! m_wxlState.wxluaT_Remove(wxlCallback->GetLuaRoutine(), &wxlua_lreg_refs_key); wxlCallback->ClearwxLuaState(); } --- 227,231 ---- // remove the ref to the routine since we're clearing the wxLuaState // See ~wxLuaCallback ! m_wxlState.wxluaR_Unref(wxlCallback->GetLuaRoutine(), &wxlua_lreg_refs_key); wxlCallback->ClearwxLuaState(); } Index: wxlua_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua_bind.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** wxlua_bind.cpp 17 Nov 2007 00:15:03 -0000 1.9 --- wxlua_bind.cpp 4 Dec 2007 05:20:28 -0000 1.10 *************** *** 1,4 **** // --------------------------------------------------------------------------- ! // This file was generated by genwxbind.lua // // Any changes made to this file may be lost when file is regenerated. --- 1,4 ---- // --------------------------------------------------------------------------- ! // This file was generated by genwxbind.lua // // Any changes made to this file may be lost when file is regenerated. *************** *** 864,868 **** // this may a wxLua data if (ltype == LUA_TUSERDATA) ! wxluaarg_tag = wxluaT_tag(L, 1); // I guess it wasn't or isn't a userdata --- 864,868 ---- // this may a wxLua data if (ltype == LUA_TUSERDATA) ! wxluaarg_tag = wxluaT_gettag(L, 1); // I guess it wasn't or isn't a userdata *************** *** 965,969 **** { "wxLUA_CHECK_VERSION_FULL", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_wxLUA_CHECK_VERSION_FULL, 1, NULL }, ! { 0, 0, 0, 0 }, }; count = sizeof(functionList)/sizeof(wxLuaBindMethod) - 1; --- 965,969 ---- { "wxLUA_CHECK_VERSION_FULL", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_wxLUA_CHECK_VERSION_FULL, 1, NULL }, ! { 0, 0, 0, 0 }, }; count = sizeof(functionList)/sizeof(wxLuaBindMethod) - 1; *************** *** 981,988 **** static wxLuaBindClass classList[] = { ! { "wxLuaObject", wxLuaObject_methods, wxLuaObject_methodCount, CLASSINFO(wxLuaObject), &s_wxluatag_wxLuaObject, "wxObject", NULL ,s_wxluadefineArray_None, 0, }, ! { "wxLuaState", wxLuaState_methods, wxLuaState_methodCount, CLASSINFO(wxLuaState), &s_wxluatag_wxLuaState, "wxObject", NULL ,s_wxluadefineArray_None, 0, }, ! { 0, 0, 0, 0, 0, 0, 0 }, }; count = sizeof(classList)/sizeof(wxLuaBindClass) - 1; --- 981,988 ---- static wxLuaBindClass classList[] = { ! { "wxLuaObject", wxLuaObject_methods, wxLuaObject_methodCount, CLASSINFO(wxLuaObject), &s_wxluatag_wxLuaObject, "wxObject", NULL ,s_wxluadefineArray_None, 0, }, ! { "wxLuaState", wxLuaState_methods, wxLuaState_methodCount, CLASSINFO(wxLuaState), &s_wxluatag_wxLuaState, "wxObject", NULL ,s_wxluadefineArray_None, 0, }, ! { 0, 0, 0, 0, 0, 0, 0 }, }; count = sizeof(classList)/sizeof(wxLuaBindClass) - 1; |
From: John L. <jr...@us...> - 2007-12-04 05:20:33
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16657/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: After separating the tags, refs, and debug refs in the Lua registry rename the wxluaT_XXX functions to match what they operate on wxluaR_ for generic ref functions wxluaT_ for tag functions wxluaO_ for object functions Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** wxlstack.cpp 2 Dec 2007 20:57:34 -0000 1.21 --- wxlstack.cpp 4 Dec 2007 05:20:29 -0000 1.22 *************** *** 1022,1026 **** // refresh here and not in Expand/CollapseItem() to make ExpandItemChildren() faster. ! m_listCtrl->RefreshItem(list_item); } } --- 1022,1026 ---- // refresh here and not in Expand/CollapseItem() to make ExpandItemChildren() faster. ! m_listCtrl->RefreshItem(list_item); } } *************** *** 1114,1119 **** for (n = 0; n < count; n++) { ! wxLuaDebugItem *item = new wxLuaDebugItem(strArr[n].BeforeLast(wxT(' ')), WXLUAARG_None, ! wxT("Count ")+strArr[n].AfterLast(wxT(' ')), WXLUAARG_None, wxT(""), LUA_NOREF, debugItem->GetIndex() + 1); dataArr.Add(item); --- 1114,1119 ---- for (n = 0; n < count; n++) { ! wxLuaDebugItem *item = new wxLuaDebugItem(strArr[n].BeforeLast(wxT(' ')), WXLUAARG_None, ! wxT("Count ")+strArr[n].AfterLast(wxT(' ')), WXLUAARG_None, wxT(""), LUA_NOREF, debugItem->GetIndex() + 1); dataArr.Add(item); *************** *** 1240,1244 **** delete stkListData_n; ! n--; count = m_listData.GetCount(); } } --- 1240,1244 ---- delete stkListData_n; ! n--; count = m_listData.GetCount(); } } *************** *** 1304,1308 **** { int lua_ref = debugItem->GetReference(); ! int ok = m_wxlState.wxluaT_Remove(lua_ref); debugItem->SetReference(LUA_NOREF); --- 1304,1308 ---- { int lua_ref = debugItem->GetReference(); ! int ok = m_wxlState.wxluaR_Unref(lua_ref); debugItem->SetReference(LUA_NOREF); *************** *** 1319,1323 **** for (i = (int)m_luaReferences.GetCount()-1; i >= 0; --i) { ! bool ok = m_wxlState.wxluaT_Remove(m_luaReferences[i], &wxlua_lreg_debug_refs_key); wxCHECK_RET(ok, wxT("Unable to remove a reference in Lua")); //wxPrintf(wxT("Extra Lua reference in listctrl #%d ok %d ref %d count %d\n"), i, ok, m_luaReferences[i], m_luaReferences.GetCount()); --- 1319,1323 ---- for (i = (int)m_luaReferences.GetCount()-1; i >= 0; --i) { ! bool ok = m_wxlState.wxluaR_Unref(m_luaReferences[i], &wxlua_lreg_debug_refs_key); wxCHECK_RET(ok, wxT("Unable to remove a reference in Lua")); //wxPrintf(wxT("Extra Lua reference in listctrl #%d ok %d ref %d count %d\n"), i, ok, m_luaReferences[i], m_luaReferences.GetCount()); Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** wxldebug.cpp 3 Dec 2007 23:47:24 -0000 1.53 --- wxldebug.cpp 4 Dec 2007 05:20:29 -0000 1.54 *************** *** 139,143 **** if (ret == 0) // can be true for unnamed "(*temporary)" vars { ! ret = elem1->GetKeyType() - elem2->GetKeyType(); if (ret == 0) --- 139,143 ---- if (ret == 0) // can be true for unnamed "(*temporary)" vars { ! ret = elem1->GetKeyType() - elem2->GetKeyType(); if (ret == 0) *************** *** 221,228 **** // FIXME! local tables get the right values for GetTypeValue(...) ! // but when you run wxluaT_insert() to store them they disappear ! // so that the next time wxluaT_insert() is run it reuses the same // index as your local table. ! // When using the stack dialog the next wxluaT_insert() is the // global table which is very confusing. --- 221,228 ---- // FIXME! local tables get the right values for GetTypeValue(...) ! // but when you run wxluaR_ref() to store them they disappear ! // so that the next time wxluaR_ref() is run it reuses the same // index as your local table. ! // When using the stack dialog the next wxluaR_ref() is the // global table which is very confusing. *************** *** 281,285 **** { // push the table onto the stack to iterate through ! if (wxlState.wxluaT_Get(tableRef, &wxlua_lreg_debug_refs_key)) { if (lua_getmetatable(L, -1)) // if no metatable then nothing is pushed --- 281,285 ---- { // push the table onto the stack to iterate through ! if (wxlState.wxluaR_GetRef(tableRef, &wxlua_lreg_debug_refs_key)) { if (lua_getmetatable(L, -1)) // if no metatable then nothing is pushed *************** *** 330,339 **** if (lua_istable(L, stack_idx)) { ! nRef = wxluaT_isrefed(L, stack_idx, &wxlua_lreg_debug_refs_key); // don't duplicate refs if (nRef == LUA_NOREF) { if (flag_type) *flag_type |= WXLUA_DEBUGITEM_LUAREFED; ! nRef = wxluaT_insert(L, -1, &wxlua_lreg_debug_refs_key); references.Add(nRef); } --- 330,339 ---- if (lua_istable(L, stack_idx)) { ! nRef = wxluaR_isrefed(L, stack_idx, &wxlua_lreg_debug_refs_key); // don't duplicate refs if (nRef == LUA_NOREF) { if (flag_type) *flag_type |= WXLUA_DEBUGITEM_LUAREFED; ! nRef = wxluaR_ref(L, -1, &wxlua_lreg_debug_refs_key); references.Add(nRef); } *************** *** 430,434 **** lua_State* L = wxlState.GetLuaState(); ! int nTag = wxluaT_tag(L, stack_idx); int nItems = luaL_getn(L, stack_idx); const void *pItem = lua_topointer(L, stack_idx); --- 430,434 ---- lua_State* L = wxlState.GetLuaState(); ! int nTag = wxluaT_gettag(L, stack_idx); int nItems = luaL_getn(L, stack_idx); const void *pItem = lua_topointer(L, stack_idx); *************** *** 474,478 **** else // is full userdata { ! int nTag = wxluaT_tag(L, stack_idx); if (nTag != WXLUA_NOTAG) --- 474,478 ---- else // is full userdata { ! int nTag = wxluaT_gettag(L, stack_idx); if (nTag != WXLUA_NOTAG) |
From: John L. <jr...@us...> - 2007-12-04 05:20:33
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16657/wxLua/modules/wxluasocket/src Modified Files: wxldtarg.cpp Log Message: After separating the tags, refs, and debug refs in the Lua registry rename the wxluaT_XXX functions to match what they operate on wxluaR_ for generic ref functions wxluaT_ for tag functions wxluaO_ for object functions Index: wxldtarg.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxldtarg.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** wxldtarg.cpp 30 Nov 2007 23:00:08 -0000 1.42 --- wxldtarg.cpp 4 Dec 2007 05:20:29 -0000 1.43 *************** *** 322,326 **** { int iItem = m_references.Item(idx); ! m_wxlState.wxluaT_Remove(iItem, &wxlua_lreg_debug_refs_key); } m_references.Clear(); --- 322,326 ---- { int iItem = m_references.Item(idx); ! m_wxlState.wxluaR_Unref(iItem, &wxlua_lreg_debug_refs_key); } m_references.Clear(); *************** *** 509,513 **** lua_pushliteral(L, "OK"); ! nReference = m_wxlState.wxluaT_Insert(-1, &wxlua_lreg_refs_key); lua_settop(L, nOldTop); // throw out all return values } --- 509,513 ---- lua_pushliteral(L, "OK"); ! nReference = m_wxlState.wxluaR_Ref(-1, &wxlua_lreg_refs_key); lua_settop(L, nOldTop); // throw out all return values } *************** *** 526,530 **** if (strExpr == name) { ! nReference = m_wxlState.wxluaT_Insert(-1, &wxlua_lreg_refs_key); fFound = true; break; --- 526,530 ---- if (strExpr == name) { ! nReference = m_wxlState.wxluaR_Ref(-1, &wxlua_lreg_refs_key); fFound = true; break; *************** *** 552,556 **** if (strExpr == name) { ! nReference = m_wxlState.wxluaT_Insert(-1, &wxlua_lreg_refs_key); // reference value lua_pop(L, 2); // pop key and value fFound = true; --- 552,556 ---- if (strExpr == name) { ! nReference = m_wxlState.wxluaR_Ref(-1, &wxlua_lreg_refs_key); // reference value lua_pop(L, 2); // pop key and value fFound = true; *************** *** 565,571 **** } ! if (m_wxlState.wxluaT_Get(nReference, &wxlua_lreg_refs_key)) { ! m_wxlState.wxluaT_Remove(nReference, &wxlua_lreg_refs_key); int wxl_type = 0; --- 565,571 ---- } ! if (m_wxlState.wxluaR_GetRef(nReference, &wxlua_lreg_refs_key)) { ! m_wxlState.wxluaR_Unref(nReference, &wxlua_lreg_refs_key); int wxl_type = 0; |
From: John L. <jr...@us...> - 2007-12-04 05:20:32
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16657/wxLua/modules/wxluadebug/include Modified Files: wxldebug.h wxlstack.h Log Message: After separating the tags, refs, and debug refs in the Lua registry rename the wxluaT_XXX functions to match what they operate on wxluaR_ for generic ref functions wxluaT_ for tag functions wxluaO_ for object functions Index: wxldebug.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/include/wxldebug.h,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** wxldebug.h 30 Nov 2007 23:00:08 -0000 1.45 --- wxldebug.h 4 Dec 2007 05:20:29 -0000 1.46 *************** *** 30,34 **** WXLUA_DEBUGITEM_EXPANDED = 0x0400, // for wxLuaStackDialog WXLUA_DEBUGITEM_LUAREFED = 0x0800 // This item was created with a ! // new wxluaT_insert() reference // rather than using an existing one. }; --- 30,34 ---- WXLUA_DEBUGITEM_EXPANDED = 0x0400, // for wxLuaStackDialog WXLUA_DEBUGITEM_LUAREFED = 0x0800 // This item was created with a ! // new wxluaR_ref() reference // rather than using an existing one. }; *************** *** 58,62 **** wxString GetSource() const { return m_itemSource; } ! int GetReference() const { return m_lua_ref; } // wxluaT_tag reference int GetIndex() const { return m_index; } // stack index or table level index int GetFlag() const { return m_flag; } // see wxLuaDebugItem_Type --- 58,62 ---- wxString GetSource() const { return m_itemSource; } ! int GetReference() const { return m_lua_ref; } // wxluaT_gettag() reference int GetIndex() const { return m_index; } // stack index or table level index int GetFlag() const { return m_flag; } // see wxLuaDebugItem_Type *************** *** 65,69 **** void SetFlag(int flag) { m_flag = flag; } void SetFlagBit(int bit, bool set) { m_flag = WXLUA_SETBIT(m_flag, bit, set); } ! void SetReference(int lua_ref) { m_lua_ref = lua_ref; } // only if you've wxluaT_removed it // Get a human readable string for debugging --- 65,69 ---- void SetFlag(int flag) { m_flag = flag; } void SetFlagBit(int bit, bool set) { m_flag = WXLUA_SETBIT(m_flag, bit, set); } ! void SetReference(int lua_ref) { m_lua_ref = lua_ref; } // only if you've wxluaR_unref()ed it // Get a human readable string for debugging Index: wxlstack.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/include/wxlstack.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** wxlstack.h 2 Dec 2007 20:57:34 -0000 1.12 --- wxlstack.h 4 Dec 2007 05:20:29 -0000 1.13 *************** *** 194,198 **** void OnListRightClick(wxListEvent &event); ! // Expand a single list item bool ExpandItem(long lc_item); // Expand a list item and all it's children --- 194,198 ---- void OnListRightClick(wxListEvent &event); ! // Expand a single list item bool ExpandItem(long lc_item); // Expand a list item and all it's children *************** *** 221,225 **** wxLuaState m_wxlState; // lua_State to show stack for ! wxArrayInt m_luaReferences; // references from m_wxlState.wxluaT_Insert wxImageList* m_imageList; // image list for listctrl --- 221,225 ---- wxLuaState m_wxlState; // lua_State to show stack for ! wxArrayInt m_luaReferences; // references from m_wxlState.wxluaR_Ref() wxImageList* m_imageList; // image list for listctrl |