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-04 05:20:32
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16657/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlcallb.h wxlstate.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: wxlcallb.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlcallb.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** wxlcallb.h 7 Aug 2007 20:23:25 -0000 1.21 --- wxlcallb.h 4 Dec 2007 05:20:28 -0000 1.22 *************** *** 63,67 **** protected: ! int m_routine; // ref to the Lua routine to call in the wxLuaReferences registry table wxLuaState m_wxlState; // store it since we're added to a list of it's callbacks. wxEvtHandler* m_evtHandler; --- 63,67 ---- protected: ! int m_routine; // ref to the Lua routine to call in the wxlua_lreg_refs_key registry table wxLuaState m_wxlState; // store it since we're added to a list of it's callbacks. wxEvtHandler* m_evtHandler; Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** wxlbind.h 30 Nov 2007 23:00:06 -0000 1.65 --- wxlbind.h 4 Dec 2007 05:20:28 -0000 1.66 *************** *** 258,263 **** public: // Wrap the item at the lua_State's stack index and create a reference to it ! // in the wxLuaReferences registy table ! wxLuaObject(const wxLuaState& wxlState, int stack_idx = 1); virtual ~wxLuaObject(); --- 258,263 ---- public: // Wrap the item at the lua_State's stack index and create a reference to it ! // in the wxlua_lreg_refs_key registy table ! wxLuaObject(const wxLuaState& wxlState, int stack_idx); virtual ~wxLuaObject(); *************** *** 292,296 **** private: wxLuaState* m_wxlState; // a pointer due to include recursion. ! int m_reference; // reference in wxLuaReferences registry table wxLuaObject_Type m_alloc_flag; // type of object for wxValidator interface --- 292,296 ---- private: wxLuaState* m_wxlState; // a pointer due to include recursion. ! int m_reference; // reference in wxlua_lreg_refs_key registry table wxLuaObject_Type m_alloc_flag; // type of object for wxValidator interface Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** wxlstate.h 3 Dec 2007 23:47:24 -0000 1.97 --- wxlstate.h 4 Dec 2007 05:20:28 -0000 1.98 *************** *** 71,77 **** // Special keys used by wxLua // ! // Note we do not push a human readable string for these because Lua always makes ! // a copy and hashes the string, this takes a considerable amount of time ! // when benchmarked using valgrind. // ---------------------------------------------------------------------------- --- 71,77 ---- // Special keys used by wxLua // ! // Note: We do not push a human readable string for these because Lua always ! // makes a copy and hashes the string, this takes a considerable amount of ! // time when benchmarked using valgrind. // ---------------------------------------------------------------------------- *************** *** 129,134 **** //---------------------------------------------------------------------------- ! // wxluaT_XXX - the 'T' stands for Tag which is a numerical index in the ! // Lua registry table for determining userdata type (it's class) //---------------------------------------------------------------------------- --- 129,137 ---- //---------------------------------------------------------------------------- ! // wxluaR_XXX - functions operate on tables in Lua's LUA_REGISTRYINDEX which ! // are keyed on lightuserdata. The 'R' stands for Registry or Reference. ! // ! // Possible values for the "void* lightuserdata_reg_key" are ! // wxlua_lreg_tags_key, wxlua_lreg_refs_key, wxlua_lreg_debug_refs_key //---------------------------------------------------------------------------- *************** *** 136,149 **** // lightuserdata_reg_key in the LUA_REGISTRYINDEX table. Does not pop the object. // Returns the table index or LUA_REFNIL if the item on the stack is none or nil (an error). ! WXDLLIMPEXP_WXLUA int LUACALL wxluaT_insert(lua_State* L, int stack_idx, const void* lightuserdata_reg_key); // Remove a reference to the object at the index in a table with the key // lightuserdata_reg_key in the LUA_REGISTRYINDEX table, returns success. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_remove(lua_State* L, int wxlref_index, const void* lightuserdata_reg_key); // Push onto the top of the stack the object at the index in a table with the key // lightuserdata_reg_key in the LUA_REGISTRYINDEX table, if the index is LUA_REFNIL or the // value is nil return false and don't leave anything on the stack. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_get(lua_State* L, int wxlref_index, const void* lightuserdata_reg_key); // Push the object u onto the top of the stack wrapped in a newuserdata ! // with it's metatable set to the table from wxluaT_get(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 --- 139,175 ---- // lightuserdata_reg_key in the LUA_REGISTRYINDEX table. Does not pop the object. // Returns the table index or LUA_REFNIL if the item on the stack is none or nil (an error). ! WXDLLIMPEXP_WXLUA int LUACALL wxluaR_ref(lua_State* L, int stack_idx, const void* lightuserdata_reg_key); // Remove a reference to the object at the index in a table with the key // lightuserdata_reg_key in the LUA_REGISTRYINDEX table, returns success. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaR_unref(lua_State* L, int wxlref_index, const void* lightuserdata_reg_key); // Push onto the top of the stack the object at the index in a table with the key // lightuserdata_reg_key in the LUA_REGISTRYINDEX table, if the index is LUA_REFNIL or the // value is nil return false and don't leave anything on the stack. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaR_getref(lua_State* L, int wxlref_index, const void* lightuserdata_reg_key); ! // Is the item at the stack_idx in the table with the key lightuserdata_reg_key ! // in the LUA_REGISTRYINDEX table. Returns the tag or LUA_NOREF if it's not. ! WXDLLIMPEXP_WXLUA int LUACALL wxluaR_isrefed(lua_State* L, int stack_idx, const void* lightuserdata_reg_key); ! ! //---------------------------------------------------------------------------- ! // wxluaT_XXX - functions operate on the "Tags" which 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. ! //---------------------------------------------------------------------------- ! ! // Allocate a new table (metatable) with a wxlua_metatable_tag_key key equal ! // to the number from wxluaR_ref() and store it in the wxlua_lreg_tags_key LUA_REGISTRYINDEX table. ! // Returns the index into the tags table, the return value from wxluaR_ref(). ! // Leaves the new table on the top of the stack. ! WXDLLIMPEXP_WXLUA int LUACALL wxluaT_newtag(lua_State* L); ! // Get the numeric tag of the object at the stack index using the metatable's wxlua_metatable_tag_key key. ! // Returns WXLUA_NOTAG if the metatable of the object doesn't have a wxlua_metatable_tag_key ! // key or it isn't a number. The tag is presumedly the index into the wxlua_lreg_tags_key ! // LUA_REGISTRYINDEX table and denotes what type of C++ object this is. ! WXDLLIMPEXP_WXLUA int LUACALL wxluaT_gettag(lua_State* L, int stack_idx); ! // Set the metatable of the object at top of stack to the table stored in the ! // 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 *************** *** 151,188 **** // 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); // 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 wxluaT_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 wxluaT_cleartrackedmetatable(lua_State* L, const void* u); ! // Get the numeric tag of the object at the stack index using the metatable's wxlua_metatable_tag_key key. ! // Returns WXLUA_NOTAG if the metatable of the object doesn't have a wxlua_metatable_tag_key ! // key or it isn't a number. The tag is presumedly the index into the wxlua_lreg_tags_key ! // LUA_REGISTRYINDEX table and denotes what type of C++ object this is. ! WXDLLIMPEXP_WXLUA int LUACALL wxluaT_tag(lua_State* L, int stack_idx); // 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); - // Allocate a new table (metatable) with a wxlua_metatable_tag_key key equal - // to the number from wxluaT_insert and store it in the wxlua_lreg_tags_key LUA_REGISTRYINDEX table. - // Returns the index into the tags table, the return value from wxluaT_insert. - // Leaves the new table on the top of the stack. - WXDLLIMPEXP_WXLUA int LUACALL wxluaT_newtag(lua_State* L); - // Set the metatable of the object at top of stack to the table stored in the - // wxlua_lreg_tags_key LUA_REGISTRYINDEX table using wxluaT_get(tag). - WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_settag(lua_State* L, int tag); - // Is the item at the stack_idx in the wxLuaReferences table already? - // returns the tag or LUA_NOREF if it's not. - WXDLLIMPEXP_WXLUA int LUACALL wxluaT_isrefed(lua_State* L, int stack_idx, const void* lightuserdata_reg_key); // ---------------------------------------------------------------------------- ! // Functions to get info about the tags wxLua uses to determine type // ---------------------------------------------------------------------------- // Get the wxLuaBindClass* for this class_tag or NULL if the tag is invalid. ! // Gets the wxLuaBindClass from the metatable stored in the wxLuaReferences registry table // for the classes that have been installed into Lua. WXDLLIMPEXP_WXLUA const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, int class_tag); --- 177,206 ---- // 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); // ---------------------------------------------------------------------------- ! // Functions to get info about the tags wxLua uses to determine C++ class type // ---------------------------------------------------------------------------- // 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); *************** *** 677,685 **** // wxLua Lua Registry Table Functions ! int wxluaT_Insert(int stack_idx, const void* lightuserdata_reg_key); ! bool wxluaT_Remove(int wxlref_index, const void* lightuserdata_reg_key); ! bool wxluaT_Get(int wxlref_index, const void* lightuserdata_reg_key); bool wxluaT_PushUserTag(const void *u, int tag, bool track); ! int wxluaT_Tag(int stack_idx) const; void* wxlua_ToUserdata(int stack_idx, bool null_ptr = false) const; int wxluaT_NewTag(); --- 695,703 ---- // wxLua Lua Registry Table Functions ! int wxluaR_Ref(int stack_idx, const void* lightuserdata_reg_key); ! 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(); |
From: John L. <jr...@us...> - 2007-12-04 05:20:31
|
Update of /cvsroot/wxlua/wxLua/bindings/wxwidgets In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16657/wxLua/bindings/wxwidgets Modified Files: wxcore_override.hpp 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: wxcore_override.hpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/wxwidgets/wxcore_override.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** wxcore_override.hpp 17 Nov 2007 00:14:55 -0000 1.5 --- wxcore_override.hpp 4 Dec 2007 05:20:27 -0000 1.6 *************** *** 807,811 **** // 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); --- 807,811 ---- // 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); |
From: John L. <jr...@us...> - 2007-12-03 23:47:31
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv9980/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp Log Message: Code cleanup in wxlstate.cpp Sort numeric debug items by number so you don't get 1,10,2,3,4... Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** wxldebug.cpp 2 Dec 2007 20:57:34 -0000 1.52 --- wxldebug.cpp 3 Dec 2007 23:47:24 -0000 1.53 *************** *** 125,133 **** int wxLuaDebugData::SortFunction(wxLuaDebugItem *elem1, wxLuaDebugItem *elem2 ) { ! int ret = elem1->m_itemKey.Cmp(elem2->m_itemKey); // not GetKey() for speed if (ret == 0) // can be true for unnamed "(*temporary)" vars { ! ret = elem1->GetKeyType() - elem2->GetKeyType(); // shouldn't happen if (ret == 0) --- 125,143 ---- int wxLuaDebugData::SortFunction(wxLuaDebugItem *elem1, wxLuaDebugItem *elem2 ) { ! int ret = 0; ! ! long l1 = 0, l2 = 0; ! ! if ((elem1->m_itemKeyType == WXLUAARG_Number) && ! (elem2->m_itemKeyType == WXLUAARG_Number) && ! elem1->m_itemKey.BeforeFirst(wxT(' ')).ToLong(&l1) && ! elem2->m_itemKey.BeforeFirst(wxT(' ')).ToLong(&l2)) ! ret = l1 - l2; ! else ! ret = elem1->m_itemKey.Cmp(elem2->m_itemKey); if (ret == 0) // can be true for unnamed "(*temporary)" vars { ! ret = elem1->GetKeyType() - elem2->GetKeyType(); if (ret == 0) |
From: John L. <jr...@us...> - 2007-12-03 23:47:29
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv9980/wxLua/modules/wxlua/src Modified Files: wxlstate.cpp Log Message: Code cleanup in wxlstate.cpp Sort numeric debug items by number so you don't get 1,10,2,3,4... Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.140 retrieving revision 1.141 diff -C2 -d -r1.140 -r1.141 *** wxlstate.cpp 30 Nov 2007 23:00:07 -0000 1.140 --- wxlstate.cpp 3 Dec 2007 23:47:24 -0000 1.141 *************** *** 43,46 **** --- 43,49 ---- // ---------------------------------------------------------------------------- + // 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 ) { *************** *** 54,58 **** for (i = 1; i <= n; i++) { - // code copied from luaB_print in lbaselib.c if (i > 1) msg.Append(wxT("\t")); // Lua uses a tab too in luaB_print --- 57,60 ---- *************** *** 84,158 **** } - #if 0 - // copied from the Lua 5.0.1 debug library - #define LEVELS1 12 /* size of the first part of the stack */ - #define LEVELS2 10 /* size of the second part of the stack */ - - //static lua_State *getthread (lua_State *L, int *arg) in ldblib.c - lua_State LUACALL *wxlua_getthread(lua_State *L, int *arg) { - if (lua_isthread(L, 1)) { - *arg = 1; - return lua_tothread(L, 1); - } - else { - *arg = 0; - return L; - } - } - - //static int db_errorfb (lua_State *L) in ldblib.c - static int LUACALL wxlua_tracebackFunction(lua_State *L) { - int level; - int firstpart = 1; /* still before eventual `...' */ - int arg; - lua_State *L1 = wxlua_getthread(L, &arg); - lua_Debug ar = INIT_LUA_DEBUG; - if (lua_isnumber(L, arg+2)) { - level = (int)lua_tointeger(L, arg+2); - lua_pop(L, 1); - } - else - level = (L == L1) ? 1 : 0; /* level 0 may be this own function */ - if (lua_gettop(L) == arg) - lua_pushliteral(L, ""); - else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ - else lua_pushliteral(L, "\n"); - lua_pushliteral(L, "stack traceback:"); - while (lua_getstack(L1, level++, &ar)) { - if (level > LEVELS1 && firstpart) { - /* no more than `LEVELS2' more levels? */ - if (!lua_getstack(L1, level+LEVELS2, &ar)) - level--; /* keep going */ - else { - lua_pushliteral(L, "\n\t..."); /* too many levels */ - while (lua_getstack(L1, level+LEVELS2, &ar)) /* find last levels */ - level++; - } - firstpart = 0; - continue; - } - lua_pushliteral(L, "\n\t"); - lua_getinfo(L1, "Snl", &ar); - lua_pushfstring(L, "%s:", ar.short_src); - if (ar.currentline > 0) - lua_pushfstring(L, "line# %d:", ar.currentline); - if (*ar.namewhat != '\0') /* is there a name? */ - lua_pushfstring(L, " in function " LUA_QS, ar.name); - else { - if (*ar.what == 'm') /* main? */ - lua_pushfstring(L, " in main chunk"); - else if (*ar.what == 'C' || *ar.what == 't') - lua_pushliteral(L, " ?"); /* C function or tail call */ - else - lua_pushfstring(L, " in function <%s:%d>", - ar.short_src, ar.linedefined); - } - lua_concat(L, lua_gettop(L) - arg); - } - lua_concat(L, lua_gettop(L) - arg); - return 1; - } - #endif // 0 - void LUACALL wxlua_debugHookFunction(lua_State *L, lua_Debug *LDebug) { --- 86,89 ---- *************** *** 237,240 **** --- 168,173 ---- // ---------------------------------------------------------------------------- + #define ABS_LUA_STKIDX(n, added_items) ((n) > 0 ? (n) : (n)-(added_items)) + // Note about luaL_ref and luaL_unref. // ref creates integer numbers from 1 to ... *************** *** 247,323 **** int wxluaT_insert(lua_State* L, int stack_idx, const void* lightuserdata_reg_key) { ! if (lua_isnone(L, stack_idx)) // nothing on stack to insert ! return LUA_REFNIL; ! ! if (lua_isnil(L, stack_idx)) // don't bother inserting nil ! { ! lua_pop(L, 1); return LUA_REFNIL; - } ! lua_pushlightuserdata(L, (void*)lightuserdata_reg_key); // push name of table to get as key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) ! lua_pushvalue(L, stack_idx > 0 ? stack_idx : stack_idx-1); // push value to store ! int table_idx = luaL_ref(L, -2); // create unique integer reference ! // in our refs table ! // We also store the value for this table for faster lookup if (lightuserdata_reg_key == &wxlua_lreg_debug_refs_key) { ! lua_pushvalue(L, stack_idx > 0 ? stack_idx : stack_idx-1); // push value to store ! lua_pushnumber(L, table_idx); ! ! lua_rawset(L, -3); } ! lua_pop(L, 1); // pop refs table return table_idx; } ! bool wxluaT_remove(lua_State* L, int wxlref_index, const void* lightuserdata_reg_key) { ! if (wxlref_index == LUA_REFNIL) // nothing to remove ! return true; ! lua_pushlightuserdata(L, (void*)lightuserdata_reg_key); // push name of table to get as key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) if (lightuserdata_reg_key == &wxlua_lreg_debug_refs_key) { ! lua_pushnumber(L, wxlref_index); ! lua_rawget(L, -2); lua_pushnil(L); ! lua_rawset(L, -3); } ! luaL_unref(L, -1, wxlref_index); // remove key and value in refs table ! // note: this key will be used for the next wxluaT_insert ! lua_pop(L, 1); // pop the refs table return true; } ! bool LUACALL wxluaT_get(lua_State *L, int wxlref_index, const void* lightuserdata_reg_key) { ! if (wxlref_index == LUA_REFNIL) // nothing to get return false; ! lua_pushlightuserdata(L, (void*)lightuserdata_reg_key); // push name of table to get as key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) ! lua_rawgeti(L, -1, wxlref_index); // get table value at wxlref_index ! lua_remove(L, -2); // remove wxLua's registry table ! if (lua_isnil(L, -1)) // not a valid table key { ! lua_pop(L, 1); return false; } return true; // return if table has a valid value and it's on the stack } --- 180,251 ---- 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; ! lua_pushlightuserdata(L, (void*)lightuserdata_reg_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! lua_pushvalue(L, ABS_LUA_STKIDX(stack_idx,1)); // push value to store ! int table_idx = luaL_ref(L, -2); // t[table_idx] = value; pops value ! // We also store t[value] = table_idx for this table for faster lookup if (lightuserdata_reg_key == &wxlua_lreg_debug_refs_key) { ! 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 } ! lua_pop(L, 1); // pop table return table_idx; } ! bool wxluaT_remove(lua_State* L, int table_idx, const void* lightuserdata_reg_key) { ! if (table_idx == LUA_REFNIL) // nothing to remove ! return false; ! lua_pushlightuserdata(L, (void*)lightuserdata_reg_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + // Also remove the t[value] = table_idx for this table if (lightuserdata_reg_key == &wxlua_lreg_debug_refs_key) { ! lua_pushnumber(L, table_idx); // push key ! lua_rawget(L, -2); // get t[key] = value; pop key, push value; lua_pushnil(L); ! lua_rawset(L, -3); // t[value] = nil; pops key and value } ! 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 return true; } ! bool LUACALL wxluaT_get(lua_State *L, int table_idx, const void* lightuserdata_reg_key) { ! if (table_idx == LUA_REFNIL) // nothing to get return false; ! lua_pushlightuserdata(L, (void*)lightuserdata_reg_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! lua_rawgeti(L, -1, table_idx); // get t[table_idx] = value; push value ! if (lua_isnil(L, -1)) // not a valid table key { ! lua_pop(L, 2); // pop nil and table return false; } + lua_remove(L, -2); // remove table, leaving value on top + return true; // return if table has a valid value and it's on the stack } *************** *** 335,350 **** { lua_pushlightuserdata(L, &wxlua_lreg_objects_key); ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the obj table) ! lua_pushlightuserdata(L, (void*)u); // key on Lua's userdata ! lua_rawget(L, -2); if (wxlua_iswxuserdata(L, -1)) { ! lua_remove(L, -2); // remove the obj table return true; } ! ! // pop the table and the nil. ! lua_pop(L, 2); } --- 263,277 ---- { 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 if (wxlua_iswxuserdata(L, -1)) { ! lua_remove(L, -2); // remove the obj table, leave value on the stack return true; } ! ! lua_pop(L, 2); // pop the table and the nil. } *************** *** 362,376 **** if (track) { ! lua_pushlightuserdata(L, &wxlua_lreg_objects_key); ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the obj table) lua_pushlightuserdata(L, (void*)u); // key on the object since we can reuse the userdata ! lua_pushvalue(L, -3); // push the Lua userdata as the value (note: weak valued table) ! lua_rawset(L, -3); ! lua_pop(L, 1); // pop obj table } ! return true; } else --- 289,303 ---- if (track) { ! 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); // key on the object since we can reuse the userdata ! lua_pushvalue(L, -3); // push the Lua userdata as the value (note: weak valued table) ! lua_rawset(L, -3); // t[key] = value; pops key and value ! lua_pop(L, 1); // pop obj table } ! return true; // leave value on the stack } else *************** *** 388,405 **** void LUACALL wxluaT_untrackuserdata(lua_State *L, const void *u) { ! lua_pushlightuserdata(L, &wxlua_lreg_objects_key); ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the object table) ! lua_pushlightuserdata(L, (void*)u); ! lua_pushnil(L); // t["lightuserdata ptr"] = nil to remove it ! lua_rawset(L, -3); ! lua_pop(L, 1); // pop objects table } void LUACALL wxluaT_cleartrackedmetatable(lua_State *L, const void *u) { ! lua_pushlightuserdata(L, &wxlua_lreg_objects_key); ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the object table) ! lua_pushlightuserdata(L, (void*)u); ! lua_rawget(L, -2); if (lua_isuserdata(L, -1)) --- 315,334 ---- void LUACALL wxluaT_untrackuserdata(lua_State *L, const void *u) { ! lua_pushlightuserdata(L, &wxlua_lreg_objects_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (the object table) ! ! 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 ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (the object table) ! ! lua_pushlightuserdata(L, (void*)u); // push key ! lua_rawget(L, -2); // get t[key] = value; pop key push value if (lua_isuserdata(L, -1)) *************** *** 415,422 **** { int tag = WXLUA_NOTAG; if (lua_getmetatable(L, stack_idx) != 0) // see wxluaT_newtag { ! lua_pushlightuserdata(L, &wxlua_metatable_tag_key); // get t[tag_key] ! lua_rawget(L, -2); //if (lua_isnumber(L, -1)) // Note: lua_tonumber returns 0 == WXLUA_NOTAG if it's not a number tag = (int)lua_tonumber(L, -1); --- 344,353 ---- { 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); *************** *** 424,427 **** --- 355,359 ---- lua_pop(L, 2); // pop metatable and tag number } + return tag; } *************** *** 444,453 **** 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); // add t[tag_key] = tag to new table ! lua_pushnumber(L, tag); ! lua_rawset(L, -3); return tag; // leave the table on the stack --- 376,385 ---- 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 *************** *** 458,465 **** 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 ! wxlua_error(L, "wxLua: Unable to set metatable in wxluaT_settag."); ! else return true; } --- 390,397 ---- 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."); } *************** *** 471,494 **** int tag = LUA_NOREF; ! lua_pushlightuserdata(L, (void*)lightuserdata_reg_key); // push name of table to get as key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) if (lightuserdata_reg_key == &wxlua_lreg_debug_refs_key) { ! lua_pushvalue(L, stack_idx > 0 ? stack_idx : stack_idx-1); // push value to compare - lua_rawget(L, -2); if (lua_isnumber(L, -1)) tag = (int)lua_tonumber(L, -1); ! lua_pop(L, 2); // pop number/nil and reg table } else { lua_pushnil(L); ! while (lua_next(L, -2) != 0) // ref table can have holes in it { ! // value = -1, key = -2, table = -3, object = -4 ! if (lua_equal(L, -1, -4)) { tag = (int)lua_tonumber(L, -2); --- 403,428 ---- 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); *************** *** 500,504 **** } ! lua_pop(L, 2); // pop object we pushed and the ref table } --- 434,438 ---- } ! lua_pop(L, 1); // pop object we pushed and the ref table } *************** *** 520,524 **** const wxLuaBindClass* wxlClass = (wxLuaBindClass *)lua_touserdata(L, -1); // actually lightuserdata ! lua_pop(L, 2); // pop wxLuaReferences table and lightuserdata (or nil if none) return wxlClass; --- 454,458 ---- const wxLuaBindClass* wxlClass = (wxLuaBindClass *)lua_touserdata(L, -1); // actually lightuserdata ! lua_pop(L, 2); // pop tag table and lightuserdata (or nil if none) return wxlClass; *************** *** 530,541 **** const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, const char* class_name) { ! lua_pushlightuserdata(L, &wxlua_lreg_classes_key); ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the classes table) ! lua_pushstring(L, class_name); // t["class_name"] = lightuserdata wxLuaBindClass (or nil if not a class tag) ! lua_rawget(L, -2); const wxLuaBindClass* wxlClass = (wxLuaBindClass *)lua_touserdata(L, -1); // actually lightuserdata ! lua_pop(L, 2); // pop wxLuaClasses table and lightuserdata (or nil if none) return wxlClass; --- 464,475 ---- const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, const char* class_name) { ! lua_pushlightuserdata(L, &wxlua_lreg_classes_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! 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 ! lua_pop(L, 2); // pop table and lightuserdata (or nil if none) return wxlClass; *************** *** 544,547 **** --- 478,482 ---- int LUACALL wxlua_isderivedclass(lua_State* L, int class_tag, int base_class_tag) { + // These two class tags are the same if (class_tag == base_class_tag) return 0; *************** *** 551,555 **** int levels = 1; ! while (wxlClass != NULL) // check level by level { if (wxlClass->baseclass && (*wxlClass->baseclass->class_tag == base_class_tag)) --- 486,490 ---- int levels = 1; ! while (wxlClass != NULL) // check baseclass by baseclass { if (wxlClass->baseclass && (*wxlClass->baseclass->class_tag == base_class_tag)) *************** *** 560,568 **** } ! return -1; } int LUACALL wxlua_isderivedclass(const wxLuaBindClass* wxlClass, const wxLuaBindClass* wxlBaseClass) { if ((wxlClass == NULL) || (wxlBaseClass == NULL)) return -1; --- 495,504 ---- } ! return -1; // class_tag is not derived from base_class_tag } int LUACALL wxlua_isderivedclass(const wxLuaBindClass* wxlClass, const wxLuaBindClass* wxlBaseClass) { + // Ok if either is NULL to allow since we can blindly call this if ((wxlClass == NULL) || (wxlBaseClass == NULL)) return -1; *************** *** 579,583 **** } ! return -1; } --- 515,519 ---- } ! return -1; // wxlClass is not derived from wxlBaseClass } *************** *** 721,725 **** if (!wxlua_isstringtype(L, stack_idx)) { ! wxString msg(wxString::Format(_("wxLua: Expected a string for parameter %d, but got '%s'."), stack_idx, lua2wx(lua_typename(L, lua_type(L, stack_idx))).c_str())); wxlua_error(L, msg); --- 657,661 ---- if (!wxlua_isstringtype(L, stack_idx)) { ! wxString msg(wxString::Format(_("wxLua: Expected a string for parameter %d, but got a '%s'."), stack_idx, lua2wx(lua_typename(L, lua_type(L, stack_idx))).c_str())); wxlua_error(L, msg); *************** *** 734,738 **** if (!wxlua_iswxluatype(l_type, WXLUAARG_Boolean)) { ! wxString msg(wxString::Format(_("wxLua: Expected a boolean for parameter %d, but got '%s'."), stack_idx, lua2wx(lua_typename(L, lua_type(L, stack_idx))).c_str())); wxlua_error(L, msg); --- 670,674 ---- if (!wxlua_iswxluatype(l_type, WXLUAARG_Boolean)) { ! wxString msg(wxString::Format(_("wxLua: Expected a boolean for parameter %d, but got a '%s'."), stack_idx, lua2wx(lua_typename(L, lua_type(L, stack_idx))).c_str())); wxlua_error(L, msg); *************** *** 754,758 **** if (!wxlua_iswxluatype(l_type, WXLUAARG_Integer)) { ! wxString msg(wxString::Format(_("wxLua: Expected an integer for parameter %d, but got '%s'."), stack_idx, lua2wx(lua_typename(L, lua_type(L, stack_idx))).c_str())); wxlua_error(L, msg); --- 690,694 ---- if (!wxlua_iswxluatype(l_type, WXLUAARG_Integer)) { ! wxString msg(wxString::Format(_("wxLua: Expected an integer for parameter %d, but got a '%s'."), stack_idx, lua2wx(lua_typename(L, lua_type(L, stack_idx))).c_str())); wxlua_error(L, msg); *************** *** 781,785 **** if (!wxlua_iswxluatype(l_type, WXLUAARG_Number)) { ! wxString msg(wxString::Format(_("wxLua: Expected a number for parameter %d, but got '%s'."), stack_idx, lua2wx(lua_typename(L, lua_type(L, stack_idx))).c_str())); wxlua_error(L, msg); --- 717,721 ---- if (!wxlua_iswxluatype(l_type, WXLUAARG_Number)) { ! wxString msg(wxString::Format(_("wxLua: Expected a number for parameter %d, but got a '%s'."), stack_idx, lua2wx(lua_typename(L, lua_type(L, stack_idx))).c_str())); wxlua_error(L, msg); *************** *** 819,823 **** else { ! wxString msg(wxString::Format(_("wxLua: Expected a table of strings for parameter %d, but got '%s'."), stack_idx, lua2wx(lua_typename(L, lua_type(L, stack_idx))).c_str())); wxlua_error(L, msg); --- 755,759 ---- else { ! wxString msg(wxString::Format(_("wxLua: Expected a table of strings for parameter %d, but got a '%s'."), stack_idx, lua2wx(lua_typename(L, lua_type(L, stack_idx))).c_str())); wxlua_error(L, msg); *************** *** 859,869 **** bool LUACALL wxlua_setderivedmethod(lua_State* L, void *pObject, const char *method_name, wxLuaObject* wxlObj) { ! 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. { ! lua_pushlightuserdata(L, (void *)pObject); ! lua_rawget(L, -2); // pop key, push table or nil if (!lua_istable(L, -1)) { --- 795,806 ---- bool LUACALL wxlua_setderivedmethod(lua_State* L, void *pObject, const char *method_name, wxLuaObject* wxlObj) { ! lua_pushlightuserdata(L, &wxlua_lreg_derivedmethods_key); // push key ! 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)) { *************** *** 921,924 **** --- 858,862 ---- lua_pushlightuserdata(L, (void *)pObject); lua_rawget(L, -2); // pop key, push table or nil + if (lua_istable(L, -1)) { *************** *** 962,971 **** lua_pushlightuserdata(L, (void *)pObject); lua_rawget(L, -2); // pop key, push table or nil if (lua_istable(L, -1)) { found = true; ! int t = lua_gettop(L); lua_pushnil(L); /* first key */ ! while (lua_next(L, t) != 0) { // uses 'key' (at index -2) and 'value' (at index -1) --- 900,910 ---- 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) *************** *** 982,989 **** } ! lua_pop(L, 1); // pop the obj table ! lua_pushlightuserdata(L, (void *)pObject); ! lua_pushnil(L); ! lua_rawset(L, -3); // nil the obj table lua_pop(L, 1); // pop reg table } --- 921,930 ---- } ! 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 } *************** *** 1005,1010 **** lua_pushlightuserdata(L, &wxlua_lreg_callbaseclassfunc_key); lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push bool ! bool call_base = (bool)lua_toboolean(L, -1); ! lua_pop(L, 1); // pop bool return call_base; --- 946,952 ---- lua_pushlightuserdata(L, &wxlua_lreg_callbaseclassfunc_key); lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push bool ! ! bool call_base = (bool)lua_toboolean(L, -1); // nil == 0 too ! lua_pop(L, 1); // pop bool return call_base; *************** *** 1705,1709 **** lua_pushcfunction(L, wxlua_traceback); // push our traceback function - //lua_pushcfunction(L, wxlua_tracebackFunction); // push our traceback function lua_insert(L, base); // put it under chunk and args --- 1647,1650 ---- *************** *** 1788,1810 **** return true; case LUA_YIELD: ! msg = wxT("lua: Thread is suspended"); break; case LUA_ERRRUN: ! msg = wxT("lua: Error while running chunk"); break; case LUA_ERRSYNTAX: ! msg = wxT("lua: Syntax error during pre-compilation"); break; case LUA_ERRMEM: ! msg = wxT("lua: Memory allocation error"); break; case LUA_ERRERR: ! msg = wxT("lua: Generic error or an error occurred while running the error handler"); break; case LUA_ERRFILE: ! msg = wxT("lua: Error occurred while opening file"); break; default : ! msg = wxT("lua: Unknown error"); break; } --- 1729,1751 ---- return true; case LUA_YIELD: ! msg = wxT("Lua: Thread is suspended"); break; case LUA_ERRRUN: ! msg = wxT("Lua: Error while running chunk"); break; case LUA_ERRSYNTAX: ! msg = wxT("Lua: Syntax error during pre-compilation"); break; case LUA_ERRMEM: ! msg = wxT("Lua: Memory allocation error"); break; case LUA_ERRERR: ! msg = wxT("Lua: Generic error or an error occurred while running the error handler"); break; case LUA_ERRFILE: ! msg = wxT("Lua: Error occurred while opening file"); break; default : ! msg = wxT("Lua: Unknown error"); break; } |
From: John L. <jr...@us...> - 2007-12-03 23:47:29
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv9980/wxLua/modules/wxlua/include Modified Files: wxlstate.h Log Message: Code cleanup in wxlstate.cpp Sort numeric debug items by number so you don't get 1,10,2,3,4... Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** wxlstate.h 30 Nov 2007 23:00:07 -0000 1.96 --- wxlstate.h 3 Dec 2007 23:47:24 -0000 1.97 *************** *** 69,73 **** // ---------------------------------------------------------------------------- ! // Push a special key into Lua, defines to make sure it's always done the same. // // Note we do not push a human readable string for these because Lua always makes --- 69,73 ---- // ---------------------------------------------------------------------------- ! // Special keys used by wxLua // // Note we do not push a human readable string for these because Lua always makes *************** *** 145,149 **** WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_get(lua_State* L, int wxlref_index, const void* lightuserdata_reg_key); // Push the object u onto the top of the stack wrapped in a newuserdata ! // with it's metatable set to the table from wxluaT_get(tag). // 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 --- 145,149 ---- WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_get(lua_State* L, int wxlref_index, const void* lightuserdata_reg_key); // Push the object u onto the top of the stack wrapped in a newuserdata ! // with it's metatable set to the table from wxluaT_get(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 |
From: John L. <jr...@us...> - 2007-12-02 20:57:38
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv543/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: Fix collapse bug in stack dialog Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** wxlstack.cpp 30 Nov 2007 23:00:08 -0000 1.20 --- wxlstack.cpp 2 Dec 2007 20:57:34 -0000 1.21 *************** *** 77,117 **** wxString wxLuaStackListCtrl::OnGetItemText(long item, long column) const { ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_stkDlg->m_listData[item]; ! wxCHECK_MSG(stkListData, wxEmptyString, wxT("Invalid wxLuaStackListData item")); ! wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); ! wxCHECK_MSG(debugItem, wxEmptyString, wxT("Invalid wxLuaDebugItem item")); ! ! switch (column) ! { ! case 0: ! if (stkListData->m_level > 0) ! { ! wxString s(wxT("-->")); ! for (int i = 1; i < stkListData->m_level; ++i) s += wxT("-->"); ! return s + debugItem->GetKey(); ! } ! else ! return debugItem->GetKey(); ! case 1: ! return wxString::Format(wxT("%d:%d"), stkListData->m_level+1, stkListData->m_item_idx+1); ! case 2: ! return debugItem->GetKeyTypeString(); ! case 3: ! return debugItem->GetValueTypeString(); ! case 4: ! { ! wxString value(debugItem->GetValue()); ! if (value.Length() > 200) value = value.Mid(0, 200) + wxT("... <snip>"); ! value.Replace(wxT("\n"), wxT("\\n")); ! value.Replace(wxT("\r"), wxT("\\r")); ! return value; ! } ! } ! ! return wxEmptyString; } int wxLuaStackListCtrl::OnGetItemImage(long item) const { ! return -1; } int wxLuaStackListCtrl::OnGetItemColumnImage(long item, long column) const --- 77,85 ---- wxString wxLuaStackListCtrl::OnGetItemText(long item, long column) const { ! return m_stkDlg->GetItemText(item, column); } int wxLuaStackListCtrl::OnGetItemImage(long item) const { ! return -1; // use OnGetItemColumnImage() } int wxLuaStackListCtrl::OnGetItemColumnImage(long item, long column) const *************** *** 171,176 **** EVT_TREE_SEL_CHANGED( ID_WXLUA_STACK_TREECTRL, wxLuaStackDialog::OnTreeItem) ! EVT_LIST_ITEM_SELECTED( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListItemActivated) ! EVT_LIST_ITEM_ACTIVATED( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListItemActivated) EVT_LIST_ITEM_RIGHT_CLICK( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListRightClick) END_EVENT_TABLE() --- 139,144 ---- EVT_TREE_SEL_CHANGED( ID_WXLUA_STACK_TREECTRL, wxLuaStackDialog::OnTreeItem) ! EVT_LIST_ITEM_SELECTED( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListItem) ! EVT_LIST_ITEM_ACTIVATED( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListItem) EVT_LIST_ITEM_RIGHT_CLICK( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListRightClick) END_EVENT_TABLE() *************** *** 287,298 **** m_findMenu = new wxMenu(wxT("Find Options"), 0); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_CASE, wxT("&Case sensitive"), wxT("Case sensitive searching"), wxITEM_CHECK); m_findMenu->AppendSeparator(); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_ALL, wxT("Search everywhere"), wxT("Search in all columns"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_NAME, wxT("Search names"), wxT("Search in name column"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_LEVEL, wxT("Search level"), wxT("Search in level column"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_KEYTYPE, wxT("Search key type"), wxT("Search in key type column"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_VALUETYPE, wxT("Search value type"), wxT("Search in value type column"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_VALUE, wxT("Search values"), wxT("Search in value column"), wxITEM_CHECK); m_findMenu->Check(ID_WXLUA_STACK_FINDMENU_NAME, true); --- 255,267 ---- m_findMenu = new wxMenu(wxT("Find Options"), 0); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_CASE, wxT("&Case sensitive"), wxT("Case sensitive searching"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_WHOLE_STRING, wxT("Match whole string"), wxT("Search for a string with an exact match"), wxITEM_CHECK); m_findMenu->AppendSeparator(); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_ALL, wxT("Search &everywhere"), wxT("Search in all columns"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_NAME, wxT("Search &names"), wxT("Search in name column"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_LEVEL, wxT("Search &level"), wxT("Search in level column"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_KEYTYPE, wxT("Search &key type"), wxT("Search in key type column"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_VALUETYPE, wxT("Search v&alue type"), wxT("Search in value type column"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_VALUE, wxT("Search &values"), wxT("Search in value column"), wxITEM_CHECK); m_findMenu->Check(ID_WXLUA_STACK_FINDMENU_NAME, true); *************** *** 437,466 **** int img = IMG_NONE; ! switch (dbgItem->GetValueType()) ! { ! case WXLUAARG_None : img = IMG_NONE; break; ! case WXLUAARG_Unknown : img = IMG_UNKNOWN; break; ! case WXLUAARG_Nil : img = IMG_NIL; break; ! case WXLUAARG_Boolean : img = IMG_BOOLEAN; break; ! case WXLUAARG_LightUserData : img = IMG_LIGHTUSERDATA; break; ! case WXLUAARG_Number : img = IMG_NUMBER; break; ! case WXLUAARG_String : img = IMG_STRING; break; ! case WXLUAARG_Table : img = IMG_TABLE; break; ! case WXLUAARG_Function : img = IMG_LUAFUNCTION; break; ! case WXLUAARG_UserData : img = IMG_USERDATA; break; ! case WXLUAARG_Thread : img = IMG_THREAD; break; ! case WXLUAARG_Integer : img = IMG_INTEGER; break; ! case WXLUAARG_CFunction : img = IMG_CFUNCTION; break; ! } ! ! // now fix up the images for special cases if (dbgItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) img = IMG_TABLE_OPEN; ! else if (dbgItem->GetValueType() == WXLUAARG_WXLUADATA) // our internal data structs ! img = IMG_TABLE; return img; } void wxLuaStackDialog::EnumerateStack() { --- 406,481 ---- int img = IMG_NONE; ! // Expanded nodes all use the open table icon if (dbgItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) img = IMG_TABLE_OPEN; ! else ! { ! switch (dbgItem->GetValueType()) ! { ! case WXLUAARG_None : img = IMG_NONE; break; ! case WXLUAARG_Unknown : img = IMG_UNKNOWN; break; ! case WXLUAARG_Nil : img = IMG_NIL; break; ! case WXLUAARG_Boolean : img = IMG_BOOLEAN; break; ! case WXLUAARG_LightUserData : img = IMG_LIGHTUSERDATA; break; ! case WXLUAARG_Number : img = IMG_NUMBER; break; ! case WXLUAARG_String : img = IMG_STRING; break; ! case WXLUAARG_Table : img = IMG_TABLE; break; ! case WXLUAARG_Function : img = IMG_LUAFUNCTION; break; ! case WXLUAARG_UserData : img = IMG_USERDATA; break; ! case WXLUAARG_Thread : img = IMG_THREAD; break; ! case WXLUAARG_Integer : img = IMG_INTEGER; break; ! case WXLUAARG_CFunction : img = IMG_CFUNCTION; break; ! ! case WXLUAARG_WXLUADATA : img = IMG_TABLE; break; ! } ! } return img; } + wxString wxLuaStackDialog::GetItemText(long item, long column, bool exact_value) + { + wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[item]; + wxCHECK_MSG(stkListData, wxEmptyString, wxT("Invalid wxLuaStackListData item")); + wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); + wxCHECK_MSG(debugItem, wxEmptyString, wxT("Invalid wxLuaDebugItem item")); + + switch (column) + { + case 0: + if (exact_value) + return debugItem->GetKey(); + + if (stkListData->m_level > 0) + { + //wxString s(wxT("-->")); + //for (int i = 1; i < stkListData->m_level; ++i) s += wxT("-->"); + + return wxString(wxT(' '), stkListData->m_level*4) + debugItem->GetKey(); + } + else + return debugItem->GetKey(); + case 1: + return wxString::Format(wxT("%d:%d"), stkListData->m_level+1, stkListData->m_item_idx+1); + case 2: + return debugItem->GetKeyTypeString(); + case 3: + return debugItem->GetValueTypeString(); + case 4: + { + if (exact_value) + return debugItem->GetValue(); + + wxString value(debugItem->GetValue()); + if (value.Length() > 200) value = value.Mid(0, 200) + wxT("... <snip>"); + value.Replace(wxT("\n"), wxT("\\n")); + value.Replace(wxT("\r"), wxT("\\r")); + return value; + } + } + + return wxEmptyString; + } + void wxLuaStackDialog::EnumerateStack() { *************** *** 534,539 **** // Add the locals, fake a debug item to get it setup right ! wxLuaDebugItem* localItem = new wxLuaDebugItem(_("Locals"), WXLUAARG_Table, ! wxString::Format(wxT("Count %d"), (int)debugData.GetCount()), WXLUAARG_Table, wxT(""), LUA_NOREF, 0, WXLUA_DEBUGITEM_EXPANDED); wxLuaDebugData localData(true); // this deletes the items --- 549,554 ---- // Add the locals, fake a debug item to get it setup right ! wxLuaDebugItem* localItem = new wxLuaDebugItem(_("Locals"), WXLUAARG_None, ! wxString::Format(wxT("Count %d"), (int)debugData.GetCount()), WXLUAARG_None, wxT(""), LUA_NOREF, 0, WXLUA_DEBUGITEM_EXPANDED); wxLuaDebugData localData(true); // this deletes the items *************** *** 580,583 **** --- 595,599 ---- wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[lc_item_]; wxCHECK_RET((stkListData != NULL), wxT("The wxLuaStackDialog does have stack data!")); + // sanity check, either add new children data or we're expanding using the old data wxCHECK_RET(!stkListData->m_childrenDebugData.Ok() || (stkListData->m_childrenDebugData == debugData), wxT("Replacing the child data?")); if (!stkListData->m_childrenDebugData.Ok()) *************** *** 676,680 **** } - void wxLuaStackDialog::BeginBatch() { --- 692,695 ---- *************** *** 700,704 **** } - wxTreeItemId wxLuaStackDialog::FindTreeItemId(const wxTreeItemId& id_, wxLuaStackListData* stkListData) const { --- 715,718 ---- *************** *** 748,800 **** if (start_item < 0) return; ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[start_item]; ! ! bool expand = (event.GetId() == ID_WXLUA_STACK_EXPAND_BUTTON); ! ! wxString caption; ! if (expand) ! caption = wxT("wxLua Stack Expanding node"); else ! caption = wxT("wxLua Stack Collapsing node"); ! ! wxProgressDialog dlg(caption, wxEmptyString, 100, this, ! wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); ! ! m_show_dup_expand_msg = false; ! BeginBatch(); ! ! // Note: Iterating through all of the listctrl items, even though most of ! // them are not expandable, is MUCH faster than using the far fewer ! // wxTreeCtrl items and calling Expand() on them. ! ! int counter = 0; ! int n = start_item, level = stkListData->m_level; ! while (n < (int)m_listData.GetCount()) ! { ! wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listData[n]; ! ! if ((n > start_item) && (stkListData_n->m_level <= level)) break; ! ! if (counter % 20 == 0) ! { ! wxString msg; ! if (expand) ! msg.Printf(wxT("Expanding nodes : %d"), counter); ! else ! msg.Printf(wxT("Collapsing nodes : %d"), counter); ! ! if (!dlg.Pulse(msg)) ! break; ! } ! ! if (!stkListData_n->GetDebugItem()->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) ! ExpandItem(n); ! ! counter++; ! n++; ! } ! ! EndBatch(); ! m_show_dup_expand_msg = true; } --- 762,769 ---- if (start_item < 0) return; ! if (event.GetId() == ID_WXLUA_STACK_EXPAND_BUTTON) ! ExpandItemChildren(start_item); else ! CollapseItem(start_item); } *************** *** 832,836 **** else if ((id >= ID_WXLUA_STACK_FINDMENU_NAME) && (id <= ID_WXLUA_STACK_FINDMENU_VALUE)) { ! bool are_checked = m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_NAME) && m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_LEVEL) && m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_KEYTYPE) && --- 801,805 ---- else if ((id >= ID_WXLUA_STACK_FINDMENU_NAME) && (id <= ID_WXLUA_STACK_FINDMENU_VALUE)) { ! bool all_checked = m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_NAME) && m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_LEVEL) && m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_KEYTYPE) && *************** *** 839,843 **** if (m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_ALL) != checked) ! m_findMenu->Check(ID_WXLUA_STACK_FINDMENU_ALL, are_checked); } else if ((id >= ID_WXLUA_STACK_LISTMENU_COPY0) && (id <= ID_WXLUA_STACK_LISTMENU_COPY4)) --- 808,812 ---- if (m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_ALL) != checked) ! m_findMenu->Check(ID_WXLUA_STACK_FINDMENU_ALL, all_checked); } else if ((id >= ID_WXLUA_STACK_LISTMENU_COPY0) && (id <= ID_WXLUA_STACK_LISTMENU_COPY4)) *************** *** 904,907 **** --- 873,878 ---- if (!match_case) findStr = findStr.Lower(); + bool whole_string = m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_WHOLE_STRING); + long direction = (event.GetId() == ID_WXLUA_STACK_FINDPREV_BUTTON) ? -1 : 1; *************** *** 912,915 **** --- 883,887 ---- bool found = false; + wxString txt; while ((wrap_count < 2) && !found) *************** *** 941,958 **** for ( ; (i >= 0) && (i < list_count) && !found; i = i + direction) { - wxListItem li; - li.SetId(i); - li.SetMask(wxLIST_MASK_TEXT); - for (int col = 0; (col < 5) && !found; col++) { if (!find_col[col]) continue; ! li.SetColumn(col); ! m_listCtrl->GetItem(li); ! wxString txt(li.GetText()); ! if ((match_case && (txt.Find(findStr) != wxNOT_FOUND)) || ! (!match_case && (txt.Lower().Find(findStr) != wxNOT_FOUND))) { m_listCtrl->SetItemState(i, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); --- 913,925 ---- for ( ; (i >= 0) && (i < list_count) && !found; i = i + direction) { for (int col = 0; (col < 5) && !found; col++) { if (!find_col[col]) continue; ! txt = GetItemText(i, col, true); ! if (match_case) txt.MakeLower(); ! if ((whole_string && (txt == findStr)) || ! (!whole_string && (txt.Find(findStr) != wxNOT_FOUND))) { m_listCtrl->SetItemState(i, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); *************** *** 1001,1004 **** --- 968,972 ---- wxBusyCursor busy; ExpandItem(list_item); + m_listCtrl->RefreshItem(list_item); } else if (evt_type == wxEVT_COMMAND_TREE_ITEM_COLLAPSED) *************** *** 1006,1009 **** --- 974,978 ---- wxBusyCursor busy; CollapseItem(list_item); + m_listCtrl->RefreshItem(list_item); } else if (evt_type == wxEVT_COMMAND_TREE_SEL_CHANGED) *************** *** 1015,1021 **** } ! void wxLuaStackDialog::OnListItemActivated(wxListEvent &event) { ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[event.GetIndex()]; wxCHECK_RET(stkListData != NULL, wxT("Invalid wxLuaStack data")); wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); --- 984,992 ---- } ! void wxLuaStackDialog::OnListItem(wxListEvent &event) { ! long list_item = event.GetIndex(); ! ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[list_item]; wxCHECK_RET(stkListData != NULL, wxT("Invalid wxLuaStack data")); wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); *************** *** 1034,1038 **** if (!debugItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) { ! if (ExpandItem(event.GetIndex())) { // Hack for WXLUA_STACK_MSWTREE, need children to expand --- 1005,1009 ---- if (!debugItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) { ! if (ExpandItem(list_item)) { // Hack for WXLUA_STACK_MSWTREE, need children to expand *************** *** 1047,1052 **** m_treeCtrl->Collapse(stkListData->m_treeId); ! CollapseItem(event.GetIndex()); } } } --- 1018,1026 ---- m_treeCtrl->Collapse(stkListData->m_treeId); ! CollapseItem(list_item); } + + // refresh here and not in Expand/CollapseItem() to make ExpandItemChildren() faster. + m_listCtrl->RefreshItem(list_item); } } *************** *** 1062,1066 **** bool wxLuaStackDialog::ExpandItem(long lc_item) { ! wxCHECK_MSG((lc_item >= 0) && (lc_item < m_listCtrl->GetItemCount()), false, wxT("Invalid list item to expand")); --- 1036,1040 ---- bool wxLuaStackDialog::ExpandItem(long lc_item) { ! wxCHECK_MSG((lc_item >= 0) && (lc_item < (long)m_listData.GetCount()), false, wxT("Invalid list item to expand")); *************** *** 1080,1089 **** { debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); - m_listCtrl->SetItemImage(lc_item, IMG_TABLE_OPEN); wxString val(debugItem->GetValue()); long vkey = 0; ! wxCHECK_MSG(val.BeforeFirst(wxT(' ')).ToLong(&vkey, 16), false, wxT("Invalid table item")); ! m_expandedItems[vkey] = (long)stkListData; FillTableEntry(lc_item, stkListData->m_childrenDebugData); --- 1054,1062 ---- { debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); wxString val(debugItem->GetValue()); long vkey = 0; ! if (val.BeforeFirst(wxT(' ')).ToLong(&vkey, 16)) ! m_expandedItems[vkey] = (long)stkListData; FillTableEntry(lc_item, stkListData->m_childrenDebugData); *************** *** 1118,1129 **** } - wxString key(debugItem->GetKey()); - // Check our special variables for the wxLuaState data ! if (m_wxlState.Ok() && ! ((key == _("Tracked User Data")) || ! (key == _("wxEvent Callbacks")) || ! (key == _("Top Level wxWindows")) || ! (key == _("wxWindow Destroy List")))) { wxLuaState wxlState(m_wxlState); --- 1091,1096 ---- } // Check our special variables for the wxLuaState data ! if (m_wxlState.Ok() && (debugItem->GetValueType() == WXLUAARG_WXLUADATA)) { wxLuaState wxlState(m_wxlState); *************** *** 1138,1144 **** else if (debugItem->GetKey() == _("wxWindow Destroy List")) strArr = wxlState.GetTrackedWinDestroyCallbackStrings(); debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); - m_listCtrl->SetItemImage(lc_item, IMG_TABLE_OPEN); wxLuaDebugData dataArr(true); --- 1105,1112 ---- 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); *************** *** 1146,1150 **** 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,1120 ---- 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); } *************** *** 1171,1174 **** --- 1141,1190 ---- } + bool wxLuaStackDialog::ExpandItemChildren(long lc_item) + { + wxCHECK_MSG((lc_item >= 0) && (lc_item < (long)m_listData.GetCount()), false, + wxT("Invalid list item to expand")); + + bool expanded = false; + + wxProgressDialog dlg(wxT("wxLua Stack Expanding node"), wxEmptyString, 100, this, + wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); + + m_show_dup_expand_msg = false; + BeginBatch(); + + // Note: Iterating through all of the listctrl items, even though most of + // them are not expandable, is MUCH faster than using the far fewer + // wxTreeCtrl items and calling Expand() on them. + + wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[lc_item]; + + int counter = 0; + int n = lc_item, level = stkListData->m_level; + while (n < (int)m_listData.GetCount()) + { + wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listData[n]; + + if ((n > lc_item) && (stkListData_n->m_level <= level)) break; + + if (counter % 20 == 0) + { + if (!dlg.Pulse(wxString::Format(wxT("Expanding nodes : %d"), counter))) + break; + } + + if (!stkListData_n->GetDebugItem()->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) + expanded |= ExpandItem(n); + + counter++; + n++; + } + + EndBatch(); + m_show_dup_expand_msg = true; + + return expanded; + } + bool wxLuaStackDialog::CollapseItem(long lc_item) { *************** *** 1224,1228 **** delete stkListData_n; ! n--; count = m_listData.GetCount(); } } --- 1240,1244 ---- delete stkListData_n; ! n--; count = m_listData.GetCount(); } } *************** *** 1236,1240 **** debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, false); - m_listCtrl->SetItemImage(lc_item, IMG_TABLE); wxString val(debugItem->GetValue()); --- 1252,1255 ---- Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** wxldebug.cpp 30 Nov 2007 23:00:08 -0000 1.51 --- wxldebug.cpp 2 Dec 2007 20:57:34 -0000 1.52 *************** *** 171,177 **** if (luaDebug.name != NULL) ! name = wxString::Format(_("function %s line %u"), lua2wx(luaDebug.name).c_str(), currentLine); else ! name = wxString::Format(_("line %u"), currentLine); Add(new wxLuaDebugItem(name, WXLUAARG_None, wxT(""), WXLUAARG_None, source, LUA_NOREF, stack_frame, 0)); --- 171,177 ---- if (luaDebug.name != NULL) ! name = wxString::Format(_("function %s line %d"), lua2wx(luaDebug.name).c_str(), currentLine); else ! name = wxString::Format(_("line %d"), currentLine); Add(new wxLuaDebugItem(name, WXLUAARG_None, wxT(""), WXLUAARG_None, source, LUA_NOREF, stack_frame, 0)); |
From: John L. <jr...@us...> - 2007-12-02 20:57:38
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv543/wxLua/modules/wxluadebug/include Modified Files: wxlstack.h Log Message: Fix collapse bug in stack dialog Index: wxlstack.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/include/wxlstack.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** wxlstack.h 30 Nov 2007 23:00:08 -0000 1.11 --- wxlstack.h 2 Dec 2007 20:57:34 -0000 1.12 *************** *** 51,54 **** --- 51,55 ---- ID_WXLUA_STACK_FINDMENU_CASE, + ID_WXLUA_STACK_FINDMENU_WHOLE_STRING, ID_WXLUA_STACK_FINDMENU_ALL, ID_WXLUA_STACK_FINDMENU_NAME, *************** *** 60,64 **** // ---------------------------------------------------------------------------- ! // wxLuaStackListData - the data we store in the wxListCtrl item's data // ---------------------------------------------------------------------------- --- 61,67 ---- // ---------------------------------------------------------------------------- ! // wxLuaStackListData - the data we store for the listctrl. ! // ! // Note: We do not use a tree structure for speed at the expense of memory. // ---------------------------------------------------------------------------- *************** *** 144,149 **** // Draw the string centered in the bitmap virtual wxBitmap CreateBmpString(const wxBitmap& bmp, const wxString& s); ! // Set the image and color to use virtual int GetItemImage(const wxLuaDebugItem *dbgItem); // Override these functions if you need to provide an alternate way to get --- 147,154 ---- // Draw the string centered in the bitmap virtual wxBitmap CreateBmpString(const wxBitmap& bmp, const wxString& s); ! // Get the IMG_XXX enum to use for this dataitem virtual int GetItemImage(const wxLuaDebugItem *dbgItem); + // Get the string to show in the wxListCtrl + virtual wxString GetItemText(long item, long column, bool exact_value = false); // Override these functions if you need to provide an alternate way to get *************** *** 179,183 **** void OnFind(wxCommandEvent& event); ! // Handle and set the stack from the stack combobox selection void OnSelectStack(wxCommandEvent &event); void SelectStack(int stack_sel); --- 184,188 ---- void OnFind(wxCommandEvent& event); ! // Handle and set the stack from the stack combo selection void OnSelectStack(wxCommandEvent &event); void SelectStack(int stack_sel); *************** *** 185,194 **** void OnTreeItem(wxTreeEvent &event); // Handle and expand/collapse a listctrl item ! void OnListItemActivated(wxListEvent &event); // Popup menu on right click void OnListRightClick(wxListEvent &event); ! // Main functions to expand or collapse a list item bool ExpandItem(long lc_item); bool CollapseItem(long lc_item); --- 190,202 ---- void OnTreeItem(wxTreeEvent &event); // Handle and expand/collapse a listctrl item ! void OnListItem(wxListEvent &event); // Popup menu on right click void OnListRightClick(wxListEvent &event); ! // Expand a single list item bool ExpandItem(long lc_item); + // Expand a list item and all it's children + bool ExpandItemChildren(long lc_item); + // Collapse an item and it's children bool CollapseItem(long lc_item); |
From: John L. <jr...@us...> - 2007-11-30 23:00:45
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv22316/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp wxlcallb.cpp wxlstate.cpp Log Message: - wxLuaStackDialog has better search for all columns, collapse and expand tables, and show metatables. It also now uses a virtual wxListCtrl so it's much faster. - Separated the "tags" for C++ classes from "refs" for objects we want a handle on in the Lua registry by putting them in separate tables. - Removed wxlua_pushkey_XXX #defines since we now have a few tables in the registry that we use and those methods were not useful anymore. The lightuserdata keys are now const char* strings with a descriptive name, however only the mem address is used as the table key. - wxluaT_newtag() now leaves the created table on the stack. - Removed wxluaT_newweaktag() and wxluaT_settagmethod() since they were not needed anymore. Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.139 retrieving revision 1.140 diff -C2 -d -r1.139 -r1.140 *** wxlstate.cpp 28 Nov 2007 22:55:00 -0000 1.139 --- wxlstate.cpp 30 Nov 2007 23:00:07 -0000 1.140 *************** *** 23,35 **** #include "wx/tokenzr.h" ! int wxlua_lreg_references_key = WXLUA_LREG_REFERENCES; ! int wxlua_lreg_classes_key = WXLUA_LREG_CLASSES; ! int wxlua_lreg_derivedmethods_key = WXLUA_LREG_DERIVED_METHODS; ! int wxlua_lreg_wxluastate_key = WXLUA_LREG_WXLUASTATE; ! int wxlua_lreg_objects_key = WXLUA_LREG_OBJECTS; ! int wxlua_lreg_callbaseclassfunc_key = WXLUA_LREG_CALLBASECLASSFUNC; ! int wxlua_lreg_metatable_tag_key = WXLUA_METATABLE_TAG; ! int wxlua_lreg_metatable_class_key = WXLUA_METATABLE_CLASS; wxLuaState wxNullLuaState(false); --- 23,37 ---- #include "wx/tokenzr.h" ! const char* wxlua_lreg_tags_key = "wxLua metatable class tags"; ! const char* wxlua_lreg_refs_key = "wxLua object references"; ! const char* wxlua_lreg_debug_refs_key = "wxLuaDebug references"; ! const char* wxlua_lreg_classes_key = "wxLuaBindClasses structs"; ! 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_callbaseclassfunc_key = "wxLua CallBaseClassFunc"; ! const char* wxlua_metatable_tag_key = "wxLua Metatable Class Tag"; ! const char* wxlua_metatable_wxluabindclass_key = "wxLua Metatable wxLuaBindClass"; wxLuaState wxNullLuaState(false); *************** *** 243,247 **** // call ref 3 times and the new references will be 4, 3, 6 ! int wxluaT_insert(lua_State* L, int stack_idx) { if (lua_isnone(L, stack_idx)) // nothing on stack to insert --- 245,249 ---- // 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) { if (lua_isnone(L, stack_idx)) // nothing on stack to insert *************** *** 254,259 **** } ! wxlua_pushkey_wxLuaReferences(L); // push name of table to get as key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) lua_pushvalue(L, stack_idx > 0 ? stack_idx : stack_idx-1); // push value to store --- 256,261 ---- } ! lua_pushlightuserdata(L, (void*)lightuserdata_reg_key); // push name of table to get as key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) lua_pushvalue(L, stack_idx > 0 ? stack_idx : stack_idx-1); // push value to store *************** *** 262,265 **** --- 264,276 ---- // in our refs table + // We also store the value for this table for faster lookup + if (lightuserdata_reg_key == &wxlua_lreg_debug_refs_key) + { + lua_pushvalue(L, stack_idx > 0 ? stack_idx : stack_idx-1); // push value to store + lua_pushnumber(L, table_idx); + + lua_rawset(L, -3); + } + lua_pop(L, 1); // pop refs table *************** *** 267,291 **** } ! bool wxluaT_remove(lua_State* L, int wxlref_index) { if (wxlref_index == LUA_REFNIL) // nothing to remove return true; ! wxlua_pushkey_wxLuaReferences(L); // push name of table to get as key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) luaL_unref(L, -1, wxlref_index); // remove key and value in refs table // note: this key will be used for the next wxluaT_insert lua_pop(L, 1); // pop the refs table return true; } ! bool LUACALL wxluaT_get(lua_State *L, int wxlref_index) { if (wxlref_index == LUA_REFNIL) // nothing to get return false; ! wxlua_pushkey_wxLuaReferences(L); // push name of table to get as key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) lua_rawgeti(L, -1, wxlref_index); // get table value at wxlref_index --- 278,313 ---- } ! bool wxluaT_remove(lua_State* L, int wxlref_index, const void* lightuserdata_reg_key) { if (wxlref_index == LUA_REFNIL) // nothing to remove return true; ! lua_pushlightuserdata(L, (void*)lightuserdata_reg_key); // push name of table to get as key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) ! ! if (lightuserdata_reg_key == &wxlua_lreg_debug_refs_key) ! { ! lua_pushnumber(L, wxlref_index); ! lua_rawget(L, -2); ! ! lua_pushnil(L); ! lua_rawset(L, -3); ! } luaL_unref(L, -1, wxlref_index); // remove key and value in refs table // note: this key will be used for the next wxluaT_insert lua_pop(L, 1); // pop the refs table + + return true; } ! bool LUACALL wxluaT_get(lua_State *L, int wxlref_index, const void* lightuserdata_reg_key) { if (wxlref_index == LUA_REFNIL) // nothing to get return false; ! lua_pushlightuserdata(L, (void*)lightuserdata_reg_key); // push name of table to get as key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) lua_rawgeti(L, -1, wxlref_index); // get table value at wxlref_index *************** *** 312,316 **** if (tag != g_wxluatag_wxLuaFunction) { ! wxlua_pushkey_wxLuaObjects(L); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the obj table) lua_pushlightuserdata(L, (void*)u); // key on Lua's userdata --- 334,338 ---- if (tag != g_wxluatag_wxLuaFunction) { ! lua_pushlightuserdata(L, &wxlua_lreg_objects_key); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the obj table) lua_pushlightuserdata(L, (void*)u); // key on Lua's userdata *************** *** 333,337 **** *ptr = u; // try to get the object's references table and set the metatable to the object ! if (wxluaT_get(L, tag)) { // pop the table and set it as the metatable for the newuserdata --- 355,359 ---- *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 *************** *** 340,344 **** if (track) { ! wxlua_pushkey_wxLuaObjects(L); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the obj table) --- 362,366 ---- if (track) { ! lua_pushlightuserdata(L, &wxlua_lreg_objects_key); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the obj table) *************** *** 366,370 **** void LUACALL wxluaT_untrackuserdata(lua_State *L, const void *u) { ! wxlua_pushkey_wxLuaObjects(L); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the object table) lua_pushlightuserdata(L, (void*)u); --- 388,392 ---- void LUACALL wxluaT_untrackuserdata(lua_State *L, const void *u) { ! lua_pushlightuserdata(L, &wxlua_lreg_objects_key); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the object table) lua_pushlightuserdata(L, (void*)u); *************** *** 376,380 **** void LUACALL wxluaT_cleartrackedmetatable(lua_State *L, const void *u) { ! wxlua_pushkey_wxLuaObjects(L); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the object table) lua_pushlightuserdata(L, (void*)u); --- 398,402 ---- void LUACALL wxluaT_cleartrackedmetatable(lua_State *L, const void *u) { ! lua_pushlightuserdata(L, &wxlua_lreg_objects_key); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the object table) lua_pushlightuserdata(L, (void*)u); *************** *** 395,399 **** if (lua_getmetatable(L, stack_idx) != 0) // see wxluaT_newtag { ! wxlua_pushkey_metatableTag(L); // get t[tag_key] lua_rawget(L, -2); //if (lua_isnumber(L, -1)) // Note: lua_tonumber returns 0 == WXLUA_NOTAG if it's not a number --- 417,421 ---- if (lua_getmetatable(L, stack_idx) != 0) // see wxluaT_newtag { ! lua_pushlightuserdata(L, &wxlua_metatable_tag_key); // get t[tag_key] lua_rawget(L, -2); //if (lua_isnumber(L, -1)) // Note: lua_tonumber returns 0 == WXLUA_NOTAG if it's not a number *************** *** 422,477 **** int wxluaT_newtag(lua_State* L) { ! lua_newtable(L); // create a table for our new tag ! int tag = wxluaT_insert(L, -1); // insert the table into the wxLuaReferences registry table ! ! wxlua_pushkey_metatableTag(L); // add t[tag_key] = tag to new table ! lua_pushnumber(L, tag); ! lua_rawset(L, -3); ! ! lua_pop(L, 1); // pop our new table ! return tag; ! } ! ! int wxluaT_newweaktag(lua_State* L, bool weak_keys, bool weak_values) ! { ! //if (!weak_keys && !weak_values) return wxluaT_newtag(L); ! ! lua_newtable(L); // main table ! lua_newtable(L); // metatable ! ! lua_pushlstring(L, "__mode", 6); ! ! // for metatable.__weak = k for weak keys, v for weak values ! if (weak_keys) ! { ! if (weak_values) ! lua_pushlstring(L, "kv", 2); ! else ! lua_pushlstring(L, "k", 1); ! } ! else ! { ! if (weak_values) ! lua_pushlstring(L, "v", 1); ! else // yeah, we really shouldn't reach here ! lua_pushnil(L); ! } ! ! lua_rawset(L, -3); // set mode of main table ! lua_setmetatable(L, -2); // via the metatable ! ! int tag = wxluaT_insert(L, -1); // insert the table into the wxLuaReferences registry table ! wxlua_pushkey_metatableTag(L); // add t[tag_key] = tag to new table lua_pushnumber(L, tag); lua_rawset(L, -3); ! lua_pop(L, 1); // pop our new table ! return tag; } bool LUACALL wxluaT_settag(lua_State *L, int tag) { ! if (wxluaT_get(L, tag)) // 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 --- 444,460 ---- 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); // add t[tag_key] = tag to new table lua_pushnumber(L, tag); lua_rawset(L, -3); ! 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 *************** *** 484,537 **** } ! bool LUACALL wxluaT_settagmethod(lua_State *L, int tag, const char *method_name, ! lua_CFunction func, void *pClass /* = NULL*/) ! { ! if (wxluaT_get(L, tag)) // get the metatable for the object from the ! { // wxLuaReferences registy table ! if (pClass != NULL) ! { ! lua_pushstring(L, method_name); // push method name ! lua_pushlightuserdata(L, pClass); // push the userdata ! lua_pushcclosure(L, func, 1); // push func with pClass as upvalue ! } ! else ! { ! lua_pushstring(L, method_name); ! lua_pushcclosure(L, func, 0); ! } ! ! lua_rawset(L, -3); // t["method_name"] = closure of func (and upvalues) ! lua_pop(L, 1); // pop the table from wxluaT_get we got from the wxLuaReferences registry table ! return true; ! } ! ! return false; ! } ! ! int LUACALL wxluaT_isrefed(lua_State* L, int stack_idx) { int tag = LUA_NOREF; ! lua_pushvalue(L, stack_idx); // push value to compare ! ! wxlua_pushkey_wxLuaReferences(L); // push name of table to get as key lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) - int nTop = lua_gettop(L); // this is where refs table is ! lua_pushnil(L); ! while (lua_next(L, nTop) != 0) // ref table can have holes in it { ! // value = -1, key = -2, table = -3, object = -4 ! if (lua_equal(L, -1, -4)) { ! 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, 2); // pop object we pushed and the ref table return tag; --- 467,505 ---- } ! 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 name of table to get as key lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) ! if (lightuserdata_reg_key == &wxlua_lreg_debug_refs_key) { ! lua_pushvalue(L, stack_idx > 0 ? stack_idx : stack_idx-1); // push value to compare ! ! lua_rawget(L, -2); ! if (lua_isnumber(L, -1)) ! tag = (int)lua_tonumber(L, -1); ! ! lua_pop(L, 2); // pop number/nil and reg table ! } ! else ! { ! lua_pushnil(L); ! while (lua_next(L, -2) != 0) // ref table can have holes in it { ! // value = -1, key = -2, table = -3, object = -4 ! if (lua_equal(L, -1, -4)) ! { ! 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, 2); // pop object we pushed and the ref table ! } return tag; *************** *** 545,552 **** { // note: wxluaT_get doesn't leave anything on the stack on failure ! if (wxluaT_get(L, class_tag) && lua_istable(L, -1)) { // t[class_tag] = { [bindclass_key] = lightuserdata wxLuaBindClass... (or nil if not a class tag) ! wxlua_pushkey_metatableClass(L); lua_rawget(L, -2); const wxLuaBindClass* wxlClass = (wxLuaBindClass *)lua_touserdata(L, -1); // actually lightuserdata --- 513,520 ---- { // 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) ! lua_pushlightuserdata(L, &wxlua_metatable_wxluabindclass_key); lua_rawget(L, -2); const wxLuaBindClass* wxlClass = (wxLuaBindClass *)lua_touserdata(L, -1); // actually lightuserdata *************** *** 562,566 **** const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, const char* class_name) { ! wxlua_pushkey_wxLuaClasses(L); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the classes table) --- 530,534 ---- const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, const char* class_name) { ! lua_pushlightuserdata(L, &wxlua_lreg_classes_key); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the classes table) *************** *** 891,895 **** bool LUACALL wxlua_setderivedmethod(lua_State* L, void *pObject, const char *method_name, wxLuaObject* wxlObj) { ! wxlua_pushkey_wxLuaDerivedMethods(L); lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push table --- 859,863 ---- bool LUACALL wxlua_setderivedmethod(lua_State* L, void *pObject, const char *method_name, wxLuaObject* wxlObj) { ! lua_pushlightuserdata(L, &wxlua_lreg_derivedmethods_key); lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push table *************** *** 944,948 **** bool found = false; ! wxlua_pushkey_wxLuaDerivedMethods(L); lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push table --- 912,916 ---- bool found = false; ! lua_pushlightuserdata(L, &wxlua_lreg_derivedmethods_key); lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push table *************** *** 987,991 **** bool found = false; ! wxlua_pushkey_wxLuaDerivedMethods(L); lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push table --- 955,959 ---- bool found = false; ! lua_pushlightuserdata(L, &wxlua_lreg_derivedmethods_key); lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push table *************** *** 1035,1039 **** bool LUACALL wxlua_getcallbaseclassfunction(lua_State*L) { ! wxlua_pushkey_CallBaseClassFunc(L); lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push bool bool call_base = (bool)lua_toboolean(L, -1); --- 1003,1007 ---- bool LUACALL wxlua_getcallbaseclassfunction(lua_State*L) { ! lua_pushlightuserdata(L, &wxlua_lreg_callbaseclassfunc_key); lua_rawget( L, LUA_REGISTRYINDEX ); // pop key, push bool bool call_base = (bool)lua_toboolean(L, -1); *************** *** 1045,1049 **** void LUACALL wxlua_setcallbaseclassfunction(lua_State*L, bool call_base) { ! wxlua_pushkey_CallBaseClassFunc(L); lua_pushboolean(L, call_base); lua_rawset( L, LUA_REGISTRYINDEX ); // pop key and bool --- 1013,1017 ---- void LUACALL wxlua_setcallbaseclassfunction(lua_State*L, bool call_base) { ! lua_pushlightuserdata(L, &wxlua_lreg_callbaseclassfunc_key); lua_pushboolean(L, call_base); lua_rawset( L, LUA_REGISTRYINDEX ); // pop key and bool *************** *** 1378,1394 **** } ! wxlua_pushkey_wxLuaState(m_lua_State); lua_pushnil(m_lua_State); lua_rawset(m_lua_State, LUA_REGISTRYINDEX); ! wxlua_pushkey_wxLuaReferences(m_lua_State); lua_pushnil(m_lua_State); lua_rawset(m_lua_State, LUA_REGISTRYINDEX); ! wxlua_pushkey_wxLuaClasses(m_lua_State); lua_pushnil(m_lua_State); lua_rawset(m_lua_State, LUA_REGISTRYINDEX); ! //wxlua_pushkey_wxLuaDerivedMethods(m_lua_State); // gc will delete them //lua_pushnil(m_lua_State); //lua_rawset(m_lua_State, LUA_REGISTRYINDEX); --- 1346,1370 ---- } ! 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); *************** *** 1409,1413 **** // try to get the state we've stored ! wxlua_pushkey_wxLuaState(L); lua_rawget( L, LUA_REGISTRYINDEX ); --- 1385,1389 ---- // try to get the state we've stored ! lua_pushlightuserdata(L, &wxlua_lreg_wxluastate_key); lua_rawget( L, LUA_REGISTRYINDEX ); *************** *** 1514,1518 **** // Stick us into the Lua registry table - push key, value ! wxlua_pushkey_wxLuaState(L); lua_pushlightuserdata( L, (void*)hashState ); lua_rawset( L, LUA_REGISTRYINDEX ); // set the value --- 1490,1494 ---- // Stick us into the Lua registry table - push key, value ! lua_pushlightuserdata(L, &wxlua_lreg_wxluastate_key); lua_pushlightuserdata( L, (void*)hashState ); lua_rawset( L, LUA_REGISTRYINDEX ); // set the value *************** *** 1936,1951 **** lua_State* L = M_WXLSTATEDATA->m_lua_State; ! // create the wxLuaReferences table in registry ! wxlua_pushkey_wxLuaReferences(L); lua_newtable(L); lua_rawset(L, LUA_REGISTRYINDEX); // set the value // create the wxLuaClasses table in the registry ! wxlua_pushkey_wxLuaClasses(L); lua_newtable(L); lua_rawset(L, LUA_REGISTRYINDEX); // Create a table for overridden methods for C++ userdata objects ! wxlua_pushkey_wxLuaDerivedMethods(L); lua_newtable(L); lua_rawset( L, LUA_REGISTRYINDEX ); // set the value --- 1912,1937 ---- lua_State* L = M_WXLSTATEDATA->m_lua_State; ! // create the tags table in registry ! lua_pushlightuserdata(L, &wxlua_lreg_tags_key); ! lua_newtable(L); ! lua_rawset(L, LUA_REGISTRYINDEX); // set the value ! ! // create the refs table in registry ! lua_pushlightuserdata(L, &wxlua_lreg_refs_key); ! lua_newtable(L); ! lua_rawset(L, LUA_REGISTRYINDEX); // set the value ! ! // create the debug refs table in registry ! lua_pushlightuserdata(L, &wxlua_lreg_debug_refs_key); lua_newtable(L); 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); lua_rawset(L, LUA_REGISTRYINDEX); // Create a table for overridden methods for C++ userdata objects ! lua_pushlightuserdata(L, &wxlua_lreg_derivedmethods_key); lua_newtable(L); lua_rawset( L, LUA_REGISTRYINDEX ); // set the value *************** *** 1953,1962 **** // Create a table for the userdata that we've pushed into Lua // Use weak values so the gc works on them ! wxlua_pushkey_wxLuaObjects(L); ! lua_newtable(L); // main table ! lua_newtable(L); // metatable ! lua_pushlstring(L, "__mode", 6); ! lua_pushlstring(L, "v", 1); ! lua_rawset(L, -3); // set mode of main table lua_setmetatable(L, -2); // via the metatable lua_rawset( L, LUA_REGISTRYINDEX ); // set the value --- 1939,1948 ---- // Create a table for the userdata that we've pushed into Lua // Use weak values so the gc works on them ! lua_pushlightuserdata(L, &wxlua_lreg_objects_key); ! lua_newtable(L); // main table ! lua_newtable(L); // metatable ! lua_pushlstring(L, "__mode", 6); ! lua_pushlstring(L, "v", 1); ! lua_rawset(L, -3); // set mode of main table lua_setmetatable(L, -2); // via the metatable lua_rawset( L, LUA_REGISTRYINDEX ); // set the value *************** *** 2056,2064 **** } ! // register our 'function' object handlers g_wxluatag_wxLuaFunction = wxluaT_NewTag(); ! wxluaT_SetTagMethod(g_wxluatag_wxLuaFunction, "__gc", wxlua__gc_wxLuaFunction); ! wxluaT_SetTagMethod(g_wxluatag_wxLuaFunction, "__call", wxlua__call_wxLuaFunction); // Finally - set the global tags from the bindings we've just installed --- 2042,2057 ---- } ! // Create a metatable for our C function wrapper wxLuaFunction g_wxluatag_wxLuaFunction = wxluaT_NewTag(); ! lua_pushstring(L, "__gc"); ! lua_pushcfunction(L, wxlua__gc_wxLuaFunction); ! lua_rawset(L, -3); // t["method_name"] = closure of func ! ! lua_pushstring(L, "__call"); ! lua_pushcfunction(L, wxlua__call_wxLuaFunction); ! lua_rawset(L, -3); // t["method_name"] = closure of func ! ! lua_pop(L, 1); // remove the new table from wxluaT_NewTag() // Finally - set the global tags from the bindings we've just installed *************** *** 2503,2522 **** // wxLua Lua Registry Table Functions ! int wxLuaState::wxluaT_Insert(int stack_idx) { wxCHECK_MSG(Ok(), LUA_REFNIL, wxT("Invalid wxLuaState")); ! return wxluaT_insert(M_WXLSTATEDATA->m_lua_State, stack_idx); } ! bool wxLuaState::wxluaT_Remove(int wxlref_index) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! return wxluaT_remove(M_WXLSTATEDATA->m_lua_State, wxlref_index); } ! bool wxLuaState::wxluaT_Get(int wxlref_index) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! return wxluaT_get(M_WXLSTATEDATA->m_lua_State, wxlref_index); } --- 2496,2515 ---- // 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); } *************** *** 2551,2560 **** } - int wxLuaState::wxluaT_NewWeakTag(bool weak_keys, bool weak_values) - { - wxCHECK_MSG(Ok(), WXLUA_NOTAG, wxT("Invalid wxLuaState")); - return wxluaT_newweaktag(M_WXLSTATEDATA->m_lua_State, weak_keys, weak_values); - } - bool wxLuaState::wxluaT_SetTag(int tag) { --- 2544,2547 ---- *************** *** 2563,2572 **** } - bool wxLuaState::wxluaT_SetTagMethod(int tag, const char *method, lua_CFunction func, void *pClass /* = NULL*/) - { - wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); - return wxluaT_settagmethod(M_WXLSTATEDATA->m_lua_State, tag, method, func, pClass); - } - // ---------------------------------------------------------------------------- // wxLua get data type --- 2550,2553 ---- Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** wxlbind.cpp 28 Nov 2007 00:20:49 -0000 1.95 --- wxlbind.cpp 30 Nov 2007 23:00:07 -0000 1.96 *************** *** 101,105 **** { // set up the reference to the item on the stack ! m_reference = m_wxlState->wxluaT_Insert(stack_idx); } --- 101,105 ---- { // set up the reference to the item on the stack ! m_reference = m_wxlState->wxluaT_Insert(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); 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->wxluaT_Remove(m_reference, &wxlua_lreg_refs_key); delete m_wxlState; *************** *** 148,152 **** return true; } ! else if (m_wxlState->wxluaT_Get(m_reference)) return true; --- 148,152 ---- return true; } ! else if (m_wxlState->wxluaT_Get(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); ! m_reference = m_wxlState->wxluaT_Insert(stack_idx); } --- 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); } *************** *** 308,312 **** { // name is NULL if it's not a string ! wxlua_error(L, wxString::Format(_("wxLua: Attempt to call a class method using '%s' on a '%s' type."), lua2wx(lua_typename(L, lua_type(L, 2))).c_str(), lua2wx(wxlClass ? wxlClass->name : "").c_str())); } --- 308,312 ---- { // name is NULL if it's not a string ! wxlua_error(L, wxString::Format(_("wxLua: Attempt to call a class method using '%s' on a '%s' type."), lua2wx(lua_typename(L, lua_type(L, 2))).c_str(), lua2wx(wxlClass ? wxlClass->name : "").c_str())); } *************** *** 388,392 **** if (!found) { ! wxlua_error(L, wxString::Format(_("wxLua: Attempt to call an unknown method '%s' on a '%s' type."), lua2wx(name).c_str(), lua2wx(wxlClass ? wxlClass->name : "").c_str())); } --- 388,392 ---- if (!found) { ! wxlua_error(L, wxString::Format(_("wxLua: Attempt to call an unknown method '%s' on a '%s' type."), lua2wx(name).c_str(), lua2wx(wxlClass ? wxlClass->name : "").c_str())); } *************** *** 576,580 **** m_start_tag(0), m_last_tag(0), ! m_luaTable_tag(-1) { } --- 576,580 ---- m_start_tag(0), m_last_tag(0), ! m_luaTable_ref(-1) { } *************** *** 656,660 **** // Find a registered binding with the same namespace, if any, ! // and share the m_luaTable_tag to that of the previously loaded binding wxLuaBindingList::compatibility_iterator node = wxlState.GetLuaBindingList()->GetFirst(); for (; node; node = node->GetNext()) --- 656,660 ---- // Find a registered binding with the same namespace, if any, ! // 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()) *************** *** 662,668 **** wxLuaBinding* binding = node->GetData(); ! if ((binding->GetLuaNamespace() == m_nameSpace) && (binding->m_luaTable_tag >= 0)) { ! m_luaTable_tag = binding->m_luaTable_tag; break; } --- 662,668 ---- wxLuaBinding* binding = node->GetData(); ! if ((binding->GetLuaNamespace() == m_nameSpace) && (binding->m_luaTable_ref >= 0)) { ! m_luaTable_ref = binding->m_luaTable_ref; break; } *************** *** 670,680 **** // first time adding this namespace table ! if (m_luaTable_tag < 1) { ! // create a tag for the wxLua table ! m_luaTable_tag = wxlState.wxluaT_NewTag(); ! ! // set the table tag ! wxlState.wxluaT_SetTag(m_luaTable_tag); } --- 670,677 ---- // first time adding this namespace table ! if (m_luaTable_ref < 1) { ! // create a ref for the wxLua table we're filling ! m_luaTable_ref = wxlState.wxluaT_Insert(-1, &wxlua_lreg_refs_key); } *************** *** 715,720 **** lua_State *L = wxlState.GetLuaState(); - m_start_tag = wxlState.wxluaT_NewTag(); - int iTag = m_start_tag; --- 712,715 ---- *************** *** 726,730 **** // ------------------------------------------------------------------ // Add to the lookup table for "class name" to wxLuaBindClass struct ! wxlua_pushkey_wxLuaClasses(L); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the classes table) lua_pushstring(L, wxlClass->name); --- 721,725 ---- // ------------------------------------------------------------------ // Add to the lookup table for "class name" to wxLuaBindClass struct ! lua_pushlightuserdata(L, &wxlua_lreg_classes_key); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the classes table) lua_pushstring(L, wxlClass->name); *************** *** 737,744 **** iTag = wxlState.wxluaT_NewTag(); *wxlClass->class_tag = iTag; ! // store a lookup in the class metatable to the wxLuaBindClass struct ! wxluaT_get(L, iTag); ! wxlua_pushkey_metatableClass(L); lua_pushlightuserdata(L, (void *)wxlClass); lua_rawset(L, -3); // t[name] = tag --- 732,741 ---- iTag = wxlState.wxluaT_NewTag(); *wxlClass->class_tag = iTag; ! ! if (i_class == 0) ! m_start_tag = iTag; ! // store a lookup in the class metatable to the wxLuaBindClass struct ! lua_pushlightuserdata(L, &wxlua_metatable_wxluabindclass_key); lua_pushlightuserdata(L, (void *)wxlClass); lua_rawset(L, -3); // t[name] = tag *************** *** 747,752 **** for (size_t i_func = 0; i_func < s_funcCount; ++i_func) { - //wxlState.wxluaT_SetTagMethod(iTag, s_funcTable[i_func].name, s_funcTable[i_func].func, (void *)wxlClass); - lua_pushstring(L, s_funcTable[i_func].name); // push method name lua_pushlightuserdata(L, (void *)wxlClass); // push the userdata --- 744,747 ---- Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** wxlcallb.cpp 17 Nov 2007 00:15:02 -0000 1.42 --- wxlcallb.cpp 30 Nov 2007 23:00:07 -0000 1.43 *************** *** 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); 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.wxluaT_Insert(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); // delete the reference to this handler m_wxlState.RemoveTrackedCallback(this); --- 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); *************** *** 131,135 **** wxlState.lua_CheckStack(LUA_MINSTACK); int oldTop = wxlState.lua_GetTop(); ! if (wxlState.wxluaT_Get(m_routine)) { wxlState.lua_PushValue(LUA_GLOBALSINDEX); --- 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); *************** *** 227,231 **** // remove the ref to the routine since we're clearing the wxLuaState // See ~wxLuaCallback ! m_wxlState.wxluaT_Remove(wxlCallback->GetLuaRoutine()); wxlCallback->ClearwxLuaState(); } --- 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(); } |
From: John L. <jr...@us...> - 2007-11-30 23:00:44
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv22316/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: - wxLuaStackDialog has better search for all columns, collapse and expand tables, and show metatables. It also now uses a virtual wxListCtrl so it's much faster. - Separated the "tags" for C++ classes from "refs" for objects we want a handle on in the Lua registry by putting them in separate tables. - Removed wxlua_pushkey_XXX #defines since we now have a few tables in the registry that we use and those methods were not useful anymore. The lightuserdata keys are now const char* strings with a descriptive name, however only the mem address is used as the table key. - wxluaT_newtag() now leaves the created table on the stack. - Removed wxluaT_newweaktag() and wxluaT_settagmethod() since they were not needed anymore. Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** wxlstack.cpp 30 Nov 2007 06:23:39 -0000 1.19 --- wxlstack.cpp 30 Nov 2007 23:00:08 -0000 1.20 *************** *** 44,47 **** --- 44,150 ---- #define WXLUAARG_WXLUADATA (WXLUAARG__MIN - 100) + + // ---------------------------------------------------------------------------- + // wxLuaStackListCtrl + // ---------------------------------------------------------------------------- + + class wxLuaStackListCtrl : public wxListCtrl + { + public: + wxLuaStackListCtrl( wxLuaStackDialog* stkDialog, + wxWindow *parent, + wxWindowID winid = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxLC_REPORT, + const wxValidator& validator = wxDefaultValidator, + const wxString &name = wxT("wxLuaStackListCtrl")) + : wxListCtrl(parent, winid, pos, size, style, validator, name) + { + m_stkDlg = stkDialog; + } + + virtual wxString OnGetItemText(long item, long column) const; + virtual int OnGetItemImage(long item) const; + virtual int OnGetItemColumnImage(long item, long column) const; + virtual wxListItemAttr *OnGetItemAttr(long item) const; + + wxListItemAttr m_itemAttr; + wxLuaStackDialog* m_stkDlg; + }; + + + wxString wxLuaStackListCtrl::OnGetItemText(long item, long column) const + { + wxLuaStackListData* stkListData = (wxLuaStackListData*)m_stkDlg->m_listData[item]; + wxCHECK_MSG(stkListData, wxEmptyString, wxT("Invalid wxLuaStackListData item")); + wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); + wxCHECK_MSG(debugItem, wxEmptyString, wxT("Invalid wxLuaDebugItem item")); + + switch (column) + { + case 0: + if (stkListData->m_level > 0) + { + wxString s(wxT("-->")); + for (int i = 1; i < stkListData->m_level; ++i) s += wxT("-->"); + return s + debugItem->GetKey(); + } + else + return debugItem->GetKey(); + case 1: + return wxString::Format(wxT("%d:%d"), stkListData->m_level+1, stkListData->m_item_idx+1); + case 2: + return debugItem->GetKeyTypeString(); + case 3: + return debugItem->GetValueTypeString(); + case 4: + { + wxString value(debugItem->GetValue()); + if (value.Length() > 200) value = value.Mid(0, 200) + wxT("... <snip>"); + value.Replace(wxT("\n"), wxT("\\n")); + value.Replace(wxT("\r"), wxT("\\r")); + return value; + } + } + + return wxEmptyString; + } + int wxLuaStackListCtrl::OnGetItemImage(long item) const + { + return -1; + } + int wxLuaStackListCtrl::OnGetItemColumnImage(long item, long column) const + { + if (column == 0) + { + wxLuaStackListData* stkListData = (wxLuaStackListData*)m_stkDlg->m_listData[item]; + wxCHECK_MSG(stkListData, NULL, wxT("Invalid wxLuaStackListData item")); + wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); + wxCHECK_MSG(debugItem, NULL, wxT("Invalid wxLuaDebugItem item")); + + return m_stkDlg->GetItemImage(debugItem); + } + + return -1; + } + wxListItemAttr *wxLuaStackListCtrl::OnGetItemAttr(long item) const + { + wxLuaStackListData* stkListData = (wxLuaStackListData*)m_stkDlg->m_listData[item]; + wxCHECK_MSG(stkListData, NULL, wxT("Invalid wxLuaStackListData item")); + wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); + wxCHECK_MSG(debugItem, NULL, wxT("Invalid wxLuaDebugItem item")); + + int img = m_stkDlg->GetItemImage(debugItem); + + wxLuaStackListCtrl* stkCtrl = (wxLuaStackListCtrl*)this; // unconst + + stkCtrl->m_itemAttr.SetTextColour(m_stkDlg->m_typeColours[img]); + //SetBackgroundColour + + return &stkCtrl->m_itemAttr; + } + + // ---------------------------------------------------------------------------- // wxLuaStackDialog *************** *** 71,76 **** EVT_LIST_ITEM_ACTIVATED( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListItemActivated) EVT_LIST_ITEM_RIGHT_CLICK( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListRightClick) - EVT_LIST_DELETE_ITEM( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListItemDeleted) - EVT_LIST_DELETE_ALL_ITEMS( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListAllItemsDeleted) END_EVENT_TABLE() --- 174,177 ---- *************** *** 89,93 **** m_show_dup_expand_msg = true; m_batch_count = 0; - m_skip_tree_event = false; } --- 190,193 ---- *************** *** 238,244 **** m_treeCtrl->SetImageList(m_imageList); ! m_listCtrl = new wxListCtrl(m_splitterWin, ID_WXLUA_STACK_LISTCTRL, wxDefaultPosition, wxDefaultSize, ! wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_HRULES|wxLC_VRULES ); m_listCtrl->SetImageList(m_imageList, wxIMAGE_LIST_SMALL); --- 338,344 ---- m_treeCtrl->SetImageList(m_imageList); ! m_listCtrl = new wxLuaStackListCtrl(this, m_splitterWin, ID_WXLUA_STACK_LISTCTRL, wxDefaultPosition, wxDefaultSize, ! wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_HRULES|wxLC_VRULES|wxLC_VIRTUAL ); m_listCtrl->SetImageList(m_imageList, wxIMAGE_LIST_SMALL); *************** *** 331,335 **** } ! int wxLuaStackDialog::SetupListItem(const wxLuaDebugItem *dbgItem, wxListItem& lItem) { wxCHECK_MSG(dbgItem, IMG_UNKNOWN, wxT("Invalid wxLuaDebugItem")); --- 431,435 ---- } ! int wxLuaStackDialog::GetItemImage(const wxLuaDebugItem *dbgItem) { wxCHECK_MSG(dbgItem, IMG_UNKNOWN, wxT("Invalid wxLuaDebugItem")); *************** *** 360,382 **** img = IMG_TABLE; - lItem.SetImage(img); - lItem.SetTextColour(m_typeColours[img]); - - /* - // Adjust the fonts to highlight some types - wxFont f(m_listCtrl->GetFont()); - - if ((img == IMG_TABLE) || (img == IMG_TABLE_OPEN)) - { - f.SetWeight(wxFONTWEIGHT_BOLD); - lItem.SetFont(f); - } - else if (img == IMG_STRING) - { - f.SetStyle(wxFONTSTYLE_ITALIC); - lItem.SetFont(f); - } - */ - return img; } --- 460,463 ---- *************** *** 445,449 **** RemoveAllLuaReferences(); DeleteAllListItemData(); ! m_listCtrl->DeleteAllItems(); m_treeCtrl->DeleteAllItems(); --- 526,531 ---- RemoveAllLuaReferences(); DeleteAllListItemData(); ! m_expandedItems.clear(); ! m_listCtrl->SetItemCount(0); m_treeCtrl->DeleteAllItems(); *************** *** 493,500 **** // If less than the count we're expanding a item, else adding a new root ! if (lc_item_ < m_listCtrl->GetItemCount()) { // Set the children data for the parent ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listCtrl->GetItemData(lc_item_); wxCHECK_RET((stkListData != NULL), wxT("The wxLuaStackDialog does have stack data!")); wxCHECK_RET(!stkListData->m_childrenDebugData.Ok() || (stkListData->m_childrenDebugData == debugData), wxT("Replacing the child data?")); --- 575,582 ---- // If less than the count we're expanding a item, else adding a new root ! if (lc_item_ < (long)m_listData.GetCount()) { // Set the children data for the parent ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[lc_item_]; wxCHECK_RET((stkListData != NULL), wxT("The wxLuaStackDialog does have stack data!")); wxCHECK_RET(!stkListData->m_childrenDebugData.Ok() || (stkListData->m_childrenDebugData == debugData), wxT("Replacing the child data?")); *************** *** 505,515 **** if (!treeId) treeId = m_treeCtrl->GetRootItem(); ! wxString levelText(m_listCtrl->GetItemText(lc_item_).BeforeLast(wxT('>'))); ! if (levelText.Length() > 0) ! levelStr = levelText + wxT(">--> "); ! else ! levelStr = levelText + wxT("--> "); ! ! level = (levelStr.Length()-1)/3; } else --- 587,591 ---- if (!treeId) treeId = m_treeCtrl->GetRootItem(); ! level = stkListData->m_level+1; } else *************** *** 522,544 **** BeginBatch(); - m_skip_tree_event = true; size_t n, count = debugData.GetCount(); long lc_item = lc_item_; for (n = 0; n < count; ++n) { ! const wxLuaDebugItem *item = debugData.Item(n); ! //wxPrintf(wxT("FillTableEntry %ld %ld n %d %ld '%s'\n"), lc_item_, lc_item, n, (long)item, item->GetName().c_str()); ! wxListItem info; ! info.SetId(lc_item+1); ! info.SetText(levelStr + item->GetKey()); ! wxLuaStackListData* stkListData = new wxLuaStackListData(n, debugData); ! info.SetData(stkListData); // we must delete this ! int img = SetupListItem(item, info); if ((img == IMG_TABLE) || (img == IMG_TABLE_OPEN)) { ! wxTreeItemId id = m_treeCtrl->AppendItem(treeId, item->GetKey(), -1, -1, new wxLuaStackTreeData(stkListData)); m_treeCtrl->SetItemHasChildren(id); stkListData->m_treeId = id; --- 598,618 ---- BeginBatch(); + bool removed_tree_dummy = false; size_t n, count = debugData.GetCount(); + long lc_item = lc_item_; for (n = 0; n < count; ++n) { ! wxLuaStackListData* stkListData = new wxLuaStackListData(n, level, debugData); ! m_listData.Insert(stkListData, lc_item+n+1); ! wxLuaDebugItem* debugItem = debugData.Item(n); ! ! int img = GetItemImage(debugItem); if ((img == IMG_TABLE) || (img == IMG_TABLE_OPEN)) { ! wxTreeItemId id = m_treeCtrl->AppendItem(treeId, debugItem->GetKey(), -1, -1, new wxLuaStackTreeData(stkListData)); m_treeCtrl->SetItemHasChildren(id); stkListData->m_treeId = id; *************** *** 550,574 **** // now that we've added something, remove the first dummy " " item from parent ! wxTreeItemIdValue dummyCookie; ! wxTreeItemId dummyId = m_treeCtrl->GetFirstChild(treeId, dummyCookie); ! if (m_treeCtrl->GetItemText(dummyId) == DUMMY_TREEITEM) ! m_treeCtrl->Delete(dummyId); ! } ! ! lc_item = m_listCtrl->InsertItem(info); ! info.SetId(lc_item); ! ! m_listCtrl->SetItem(lc_item, 1, wxString::Format(wxT("%d:%d"), level+1, n+1)); ! m_listCtrl->SetItem(lc_item, 2, item->GetKeyTypeString()); ! m_listCtrl->SetItem(lc_item, 3, item->GetValueTypeString()); ! // generic listctrl doesn't like showing huge strings, nor \n ! wxString value(item->GetValue()); ! if (value.Length() > 200) value = value.Mid(0, 200) + wxT("... <snip>"); ! value.Replace(wxT("\n"), wxT("\\n")); ! value.Replace(wxT("\r"), wxT("\\r")); ! m_listCtrl->SetItem(lc_item, 4, value); } EndBatch(); --- 624,641 ---- // now that we've added something, remove the first dummy " " item from parent ! if (!removed_tree_dummy) ! { ! removed_tree_dummy = true; ! wxTreeItemIdValue dummyCookie; ! wxTreeItemId dummyId = m_treeCtrl->GetFirstChild(treeId, dummyCookie); ! if (m_treeCtrl->GetItemText(dummyId) == DUMMY_TREEITEM) ! m_treeCtrl->Delete(dummyId); ! } ! } } + m_listCtrl->SetItemCount(m_listData.GetCount()); + EndBatch(); *************** *** 581,587 **** m_treeCtrl->Expand(treeId); #endif //!defined(WXLUA_STACK_MSWTREE) - - m_skip_tree_event = false; - } } --- 648,651 ---- *************** *** 609,613 **** dataArr.Add(destroyItem); ! FillTableEntry(m_listCtrl->GetItemCount(), dataArr); } --- 673,677 ---- dataArr.Add(destroyItem); ! FillTableEntry(m_listData.GetCount(), dataArr); } *************** *** 667,671 **** for (n = 0; n < count; n++) { ! stkListData_n = (wxLuaStackListData*)m_listCtrl->GetItemData(n); if (!get_parent && (stkListData_n == stkListData)) --- 731,735 ---- for (n = 0; n < count; n++) { ! stkListData_n = (wxLuaStackListData*)m_listData[n]; if (!get_parent && (stkListData_n == stkListData)) *************** *** 678,718 **** } - void wxLuaStackDialog::DoExpandCollapse(const wxTreeItemId& item, bool expand, wxProgressDialog* dlg, long& counter) - { - if (counter < 0) // allows for immediate exit, see below - return; - - if (dlg && (counter % 20 == 0)) - { - wxString msg; - if (expand) - msg.Printf(wxT("Expanding nodes : %ld"), counter); - else - msg.Printf(wxT("Collapsing nodes : %ld"), counter); - - if (!dlg->Pulse(msg)) - { - counter = -1; - return; - } - } - - if (expand) - m_treeCtrl->Expand(item); - - // then (recursively) expand all the children - wxTreeItemIdValue cookie; - for ( wxTreeItemId idCurr = m_treeCtrl->GetFirstChild(item, cookie); - idCurr.IsOk(); - idCurr = m_treeCtrl->GetNextChild(item, cookie) ) - { - DoExpandCollapse(idCurr, expand, dlg, ++counter); - } - - if (!expand) - m_treeCtrl->Collapse(item); - } - - void wxLuaStackDialog::OnExpandButton(wxCommandEvent &event) { --- 742,745 ---- *************** *** 721,729 **** if (start_item < 0) return; ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listCtrl->GetItemData(start_item); ! wxTreeItemId treeId = stkListData->m_treeId; ! ! bool expand = event.GetId() == ID_WXLUA_STACK_EXPAND_BUTTON; wxString caption; --- 748,754 ---- if (start_item < 0) return; + wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[start_item]; ! bool expand = (event.GetId() == ID_WXLUA_STACK_EXPAND_BUTTON); wxString caption; *************** *** 734,744 **** wxProgressDialog dlg(caption, wxEmptyString, 100, this, ! wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); m_show_dup_expand_msg = false; BeginBatch(); ! long counter = 0; ! DoExpandCollapse(treeId, expand, &dlg, counter); EndBatch(); --- 759,797 ---- wxProgressDialog dlg(caption, wxEmptyString, 100, this, ! wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); m_show_dup_expand_msg = false; BeginBatch(); ! // Note: Iterating through all of the listctrl items, even though most of ! // them are not expandable, is MUCH faster than using the far fewer ! // wxTreeCtrl items and calling Expand() on them. ! ! int counter = 0; ! int n = start_item, level = stkListData->m_level; ! while (n < (int)m_listData.GetCount()) ! { ! wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listData[n]; ! ! if ((n > start_item) && (stkListData_n->m_level <= level)) break; ! ! if (counter % 20 == 0) ! { ! wxString msg; ! if (expand) ! msg.Printf(wxT("Expanding nodes : %d"), counter); ! else ! msg.Printf(wxT("Collapsing nodes : %d"), counter); ! ! if (!dlg.Pulse(msg)) ! break; ! } ! ! if (!stkListData_n->GetDebugItem()->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) ! ExpandItem(n); ! ! counter++; ! n++; ! } EndBatch(); *************** *** 932,936 **** void wxLuaStackDialog::OnTreeItem(wxTreeEvent &event) { ! if (m_skip_tree_event) return; wxTreeItemId id = event.GetItem(); --- 985,989 ---- void wxLuaStackDialog::OnTreeItem(wxTreeEvent &event) { ! if (m_batch_count > 0) return; wxTreeItemId id = event.GetItem(); *************** *** 964,968 **** void wxLuaStackDialog::OnListItemActivated(wxListEvent &event) { ! wxLuaStackListData* stkListData = (wxLuaStackListData*)event.GetData(); wxCHECK_RET(stkListData != NULL, wxT("Invalid wxLuaStack data")); wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); --- 1017,1021 ---- void wxLuaStackDialog::OnListItemActivated(wxListEvent &event) { ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[event.GetIndex()]; wxCHECK_RET(stkListData != NULL, wxT("Invalid wxLuaStack data")); wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); *************** *** 1014,1018 **** bool expanded = false; ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listCtrl->GetItemData(lc_item); wxCHECK_MSG(stkListData != NULL, false, wxT("Invalid wxLuaStack data")); wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); --- 1067,1071 ---- bool expanded = false; ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[lc_item]; wxCHECK_MSG(stkListData != NULL, false, wxT("Invalid wxLuaStack data")); wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); *************** *** 1048,1100 **** if (m_expandedItems[vkey]) { ! if (m_show_dup_expand_msg) ! { ! wxMessageBox(wxT("Cannot expand linked tables,\nplease see the already expanded table."), ! wxT("wxLua Stack"), wxOK | wxCENTRE, this); ! ! long n = m_listCtrl->FindItem(0, (long)m_expandedItems[vkey]); ! ! m_listCtrl->SetItemState(n, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); ! m_listCtrl->SetItemState(n, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); ! m_listCtrl->EnsureVisible(n); ! } ! ! return false; ! } ! ! /* ! long n, count = m_listCtrl->GetItemCount(); ! for (n = 0; n < count; n++) ! { ! wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listCtrl->GetItemData(n); ! wxCHECK_MSG(stkListData_n != NULL, false, wxT("Invalid wxLuaStack data")); ! wxLuaDebugItem* debugItem_n = stkListData_n->GetDebugItem(); ! ! if (debugItem_n && (debugItem_n != debugItem) && ! debugItem_n->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED) && ! (debugItem_n->GetValue() == val)) { ! if (m_show_dup_expand_msg) ! { ! wxMessageBox(wxT("Cannot expand linked tables,\nplease see the already expanded table."), ! wxT("wxLua Stack"), wxOK | wxCENTRE, this); ! m_listCtrl->SetItemState(n, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); ! m_listCtrl->SetItemState(n, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); ! m_listCtrl->EnsureVisible(n); ! } ! return false; } } - */ } // Check our special variables for the wxLuaState data if (m_wxlState.Ok() && ! ((debugItem->GetKey() == _("Tracked User Data")) || ! (debugItem->GetKey() == _("wxEvent Callbacks")) || ! (debugItem->GetKey() == _("Top Level wxWindows")) || ! (debugItem->GetKey() == _("wxWindow Destroy List")))) { wxLuaState wxlState(m_wxlState); --- 1101,1129 ---- if (m_expandedItems[vkey]) { ! if (m_show_dup_expand_msg) { ! wxMessageBox(wxT("Cannot expand linked tables,\nplease see the already expanded table."), ! wxT("wxLua Stack"), wxOK | wxCENTRE, this); ! int n = m_listData.Index((void*)m_expandedItems[vkey]); ! wxCHECK_MSG(n != wxNOT_FOUND, false, wxT("Unable to find hash of expanded items.")); ! m_listCtrl->SetItemState(n, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); ! m_listCtrl->SetItemState(n, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); ! m_listCtrl->EnsureVisible(n); } + + return false; } } + wxString key(debugItem->GetKey()); + // Check our special variables for the wxLuaState data if (m_wxlState.Ok() && ! ((key == _("Tracked User Data")) || ! (key == _("wxEvent Callbacks")) || ! (key == _("Top Level wxWindows")) || ! (key == _("wxWindow Destroy List")))) { wxLuaState wxlState(m_wxlState); *************** *** 1127,1131 **** { debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); - m_listCtrl->SetItemImage(lc_item, IMG_TABLE_OPEN); wxString val(debugItem->GetValue()); --- 1156,1159 ---- *************** *** 1150,1154 **** bool collapsed = false; ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listCtrl->GetItemData(lc_item); wxCHECK_MSG(stkListData != NULL, false, wxT("Invalid wxLuaStack data")); wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); --- 1178,1182 ---- bool collapsed = false; ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[lc_item]; wxCHECK_MSG(stkListData != NULL, false, wxT("Invalid wxLuaStack data")); wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); *************** *** 1167,1172 **** for (n = lc_item+1; n < count; n++) { ! wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listCtrl->GetItemData(n); wxCHECK_MSG(stkListData_n != NULL, false, wxT("Invalid wxLuaStack data")); if (stkListData_n->m_parentDebugData == childData) { --- 1195,1201 ---- for (n = lc_item+1; n < count; n++) { ! wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listData[n]; wxCHECK_MSG(stkListData_n != NULL, false, wxT("Invalid wxLuaStack data")); + if (stkListData_n->m_parentDebugData == childData) { *************** *** 1174,1180 **** stkListData_n->GetDebugItem()->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) { CollapseItem(n); ! n = (n > 2) ? (n - 2) : -1; continue; } --- 1203,1214 ---- stkListData_n->GetDebugItem()->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) { + wxString val(stkListData_n->GetDebugItem()->GetValue()); + long vkey = 0; + if (val.BeforeFirst(wxT(' ')).ToLong(&vkey, 16)) + m_expandedItems.erase(vkey); + CollapseItem(n); ! n--; count = m_listData.GetCount(); continue; } *************** *** 1182,1188 **** collapsed = true; // only if we removed anything ! m_listCtrl->DeleteItem(n); ! n = (n > 2) ? (n - 2) : -1; // back up and try again ! count = m_listCtrl->GetItemCount(); } } --- 1216,1228 ---- collapsed = true; // only if we removed anything ! if (stkListData_n->m_treeId) ! m_treeCtrl->Delete(stkListData_n->m_treeId); ! ! m_listData.RemoveAt(n); ! ! if (stkListData_n != NULL) ! delete stkListData_n; ! ! n--; count = m_listData.GetCount(); } } *************** *** 1200,1236 **** wxString val(debugItem->GetValue()); long vkey = 0; ! wxCHECK_MSG(val.BeforeFirst(wxT(' ')).ToLong(&vkey, 16), false, wxT("Invalid table item")); ! m_expandedItems.erase(vkey); } EndBatch(); ! return collapsed; ! } ! ! void wxLuaStackDialog::OnListItemDeleted(wxListEvent &event) ! { ! wxLuaStackListData* stkListData = (wxLuaStackListData*)event.GetData(); ! wxCHECK_RET(stkListData != NULL, wxT("wxLuaStackDialog::OnItemDeleted not handled")); ! ! wxString val(stkListData->GetDebugItem()->GetValue()); ! long vkey = 0; ! val.BeforeFirst(wxT(' ')).ToLong(&vkey, 16); ! m_expandedItems.erase(vkey); ! ! // make sure that we don't forget any items... ! if (stkListData->m_treeId) ! m_treeCtrl->Delete(stkListData->m_treeId); ! m_listCtrl->SetItemData(event.GetIndex(), 0); // null it so we won't try to delete it again ! if (stkListData != NULL) ! delete stkListData; ! } ! void wxLuaStackDialog::OnListAllItemsDeleted(wxListEvent &event) ! { ! RemoveAllLuaReferences(); ! DeleteAllListItemData(); ! m_expandedItems.clear(); ! event.Skip(); } --- 1240,1252 ---- wxString val(debugItem->GetValue()); long vkey = 0; ! if (val.BeforeFirst(wxT(' ')).ToLong(&vkey, 16)) ! m_expandedItems.erase(vkey); } EndBatch(); ! m_listCtrl->SetItemCount(m_listData.GetCount()); ! return collapsed; } *************** *** 1239,1251 **** m_expandedItems.clear(); ! long i, count = m_listCtrl->GetItemCount(); ! for (i = 0; i < count; i++) { ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listCtrl->GetItemData(i); - m_listCtrl->SetItemData(i, 0); // null it so we won't try to delete it again if (stkListData != NULL) delete stkListData; } } --- 1255,1269 ---- m_expandedItems.clear(); ! int i, count = m_listData.GetCount(); ! ! for (i = 0; i < count; ++i) { ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[i]; if (stkListData != NULL) delete stkListData; } + + m_listData.Clear(); } *************** *** 1283,1289 **** */ ! for (i = 0; i < (int)m_luaReferences.GetCount(); ++i) { ! bool ok = m_wxlState.wxluaT_Remove(m_luaReferences[i]); 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()); --- 1301,1308 ---- */ ! // remove the last to so we don't make any holes ! 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()); *************** *** 1291,1293 **** --- 1310,1347 ---- m_luaReferences.Clear(); + + // ---------------------------------------------------------------------- + // Sanity check to make sure that we've cleared all the references + // There should be only one of us created at any time. + + lua_State* L = m_wxlState.GetLuaState(); + //wxLuaCheckStack cs(L, wxT("wxLuaStackDialog::RemoveAllLuaReferences")); + lua_pushlightuserdata(L, &wxlua_lreg_debug_refs_key); // push name of table to get as key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) + + lua_pushnil(L); + while (lua_next(L, -2) != 0) // ref table can have holes in it + { + // value = -1, key = -2, table = -3 + if (!lua_isnumber(L, -2)) + wxPrintf(wxT("wxLuaStackDialog::RemoveAllLuaReferences refs not empty key=%d value=%d\n"), lua_type(L, -2), lua_type(L, -1)); + else if ((lua_tonumber(L, -2) == 0) && (lua_tonumber(L, -1) != 1)) + wxPrintf(wxT("wxLuaStackDialog::RemoveAllLuaReferences refs not empty key=%lf value=%lg\n"), lua_tonumber(L, -2), lua_tonumber(L, -1)); + + lua_pop(L, 1); // pop value, lua_next will pop key at end + } + + lua_pop(L, 1); // pop ref table + + // Clear out the old numeric references since it should be "empty" + // though full of table[idx]=next_idx, where table[0] = 1; + + lua_pushlightuserdata(L, &wxlua_lreg_debug_refs_key); // push name of table to get as key + lua_pushnil(L); + lua_rawset(L, LUA_REGISTRYINDEX); // clear the table completely + + // create the debug refs table in registry + lua_pushlightuserdata(L, &wxlua_lreg_debug_refs_key); + lua_newtable(L); + lua_rawset(L, LUA_REGISTRYINDEX); // set the value } Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** wxldebug.cpp 30 Nov 2007 06:23:39 -0000 1.50 --- wxldebug.cpp 30 Nov 2007 23:00:08 -0000 1.51 *************** *** 271,275 **** { // push the table onto the stack to iterate through ! if (wxlState.wxluaT_Get(tableRef)) { if (lua_getmetatable(L, -1)) // if no metatable then nothing is pushed --- 271,275 ---- { // 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 *************** *** 320,329 **** if (lua_istable(L, stack_idx)) { ! nRef = wxluaT_isrefed(L, stack_idx); // don't duplicate refs if (nRef == LUA_NOREF) { if (flag_type) *flag_type |= WXLUA_DEBUGITEM_LUAREFED; ! nRef = wxluaT_insert(L, -1); references.Add(nRef); } --- 320,329 ---- 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); } *************** *** 388,400 **** case LUA_TFUNCTION: { if (lua_iscfunction(L, stack_idx)) - { wxl_type = WXLUAARG_CFunction; ! value.Printf(wxT("%p"), lua_tocfunction(L, stack_idx)); ! } ! else ! { ! value.Printf(wxT("%p"), lua_topointer(L, stack_idx)); ! } break; } --- 388,396 ---- case LUA_TFUNCTION: { + value.Printf(wxT("%p"), lua_topointer(L, stack_idx)); + if (lua_iscfunction(L, stack_idx)) wxl_type = WXLUAARG_CFunction; ! break; } *************** *** 439,443 **** } ! wxString wxLuaDebugData::GetUserDataInfo(const wxLuaState& wxlState, int stack_idx, bool full) { wxCHECK_MSG(wxlState.Ok(), wxEmptyString, wxT("Invalid wxLuaState")); --- 435,439 ---- } ! wxString wxLuaDebugData::GetUserDataInfo(const wxLuaState& wxlState, int stack_idx, bool full_userdata) { wxCHECK_MSG(wxlState.Ok(), wxEmptyString, wxT("Invalid wxLuaState")); *************** *** 448,471 **** wxString s(wxString::Format(wxT("%p"), udata)); ! if (!full) { // Convert our known keys to something more readable ! if (udata == &wxlua_lreg_references_key) ! s += wxT(" - wxLua References"); ! else if (udata == &wxlua_lreg_classes_key) ! s += wxT(" - wxLuaBindClasses"); ! else if (udata == &wxlua_lreg_derivedmethods_key) ! s += wxT(" - wxLua Derived Class Methods"); ! else if (udata == &wxlua_lreg_wxluastate_key) ! s += wxT(" - wxLuaState"); ! else if (udata == &wxlua_lreg_objects_key) ! s += wxT(" - wxLua Pushed Userdata"); ! else if (udata == &wxlua_lreg_callbaseclassfunc_key) ! s += wxT(" - CallBaseClassFunc"); ! ! else if (udata == &wxlua_lreg_metatable_tag_key) ! s += wxT(" - wxLua Metatable Class Tag"); ! else if (udata == &wxlua_lreg_metatable_class_key) ! s += wxT(" - wxLua Metatable wxLuaBindClass"); } else // is full userdata --- 444,464 ---- wxString s(wxString::Format(wxT("%p"), udata)); ! if (!full_userdata) { // Convert our known keys to something more readable ! if ((udata == &wxlua_lreg_tags_key) || ! (udata == &wxlua_lreg_refs_key) || ! (udata == &wxlua_lreg_debug_refs_key) || ! (udata == &wxlua_lreg_classes_key) || ! (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)) ! { ! const char* ss = *(const char**)udata; ! s += wxString::Format(wxT(" : %s"), lua2wx(ss).c_str()); ! } } else // is full userdata |
From: John L. <jr...@us...> - 2007-11-30 23:00:43
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv22316/wxLua/modules/wxluadebug/include Modified Files: wxldebug.h wxlstack.h Log Message: - wxLuaStackDialog has better search for all columns, collapse and expand tables, and show metatables. It also now uses a virtual wxListCtrl so it's much faster. - Separated the "tags" for C++ classes from "refs" for objects we want a handle on in the Lua registry by putting them in separate tables. - Removed wxlua_pushkey_XXX #defines since we now have a few tables in the registry that we use and those methods were not useful anymore. The lightuserdata keys are now const char* strings with a descriptive name, however only the mem address is used as the table key. - wxluaT_newtag() now leaves the created table on the stack. - Removed wxluaT_newweaktag() and wxluaT_settagmethod() since they were not needed anymore. Index: wxldebug.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/include/wxldebug.h,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** wxldebug.h 30 Nov 2007 06:23:39 -0000 1.44 --- wxldebug.h 30 Nov 2007 23:00:08 -0000 1.45 *************** *** 147,151 **** // Get a wxString description about user data at the stack_idx in the Lua stack // if full then try to look up the name of the user data from the bindings ! static wxString GetUserDataInfo(const wxLuaState& wxlState, int stack_idx, bool full = true); //------------------------------------------------------------------------- --- 147,151 ---- // Get a wxString description about user data at the stack_idx in the Lua stack // if full then try to look up the name of the user data from the bindings ! static wxString GetUserDataInfo(const wxLuaState& wxlState, int stack_idx, bool full_userdata); //------------------------------------------------------------------------- Index: wxlstack.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/include/wxlstack.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** wxlstack.h 30 Nov 2007 06:23:39 -0000 1.10 --- wxlstack.h 30 Nov 2007 23:00:08 -0000 1.11 *************** *** 66,73 **** { public: ! wxLuaStackListData(int item_idx, const wxLuaDebugData& parentDebugData, const wxLuaDebugData& childrenDebugData = wxNullLuaDebugData) : ! m_item_idx(item_idx), m_parentDebugData(parentDebugData), m_childrenDebugData(childrenDebugData) {} --- 66,73 ---- { public: ! wxLuaStackListData(int item_idx, int level, const wxLuaDebugData& parentDebugData, const wxLuaDebugData& childrenDebugData = wxNullLuaDebugData) : ! m_item_idx(item_idx), m_level(level), m_parentDebugData(parentDebugData), m_childrenDebugData(childrenDebugData) {} *************** *** 76,79 **** --- 76,80 ---- int m_item_idx; + int m_level; wxLuaDebugData m_parentDebugData; wxLuaDebugData m_childrenDebugData; *************** *** 144,148 **** virtual wxBitmap CreateBmpString(const wxBitmap& bmp, const wxString& s); // Set the image and color to use ! virtual int SetupListItem(const wxLuaDebugItem *dbgItem, wxListItem& lItem); // Override these functions if you need to provide an alternate way to get --- 145,149 ---- virtual wxBitmap CreateBmpString(const wxBitmap& bmp, const wxString& s); // Set the image and color to use ! virtual int GetItemImage(const wxLuaDebugItem *dbgItem); // Override these functions if you need to provide an alternate way to get *************** *** 174,179 **** long FindListItem(wxLuaStackListData* stkListData, bool get_parent = false) const; - void DoExpandCollapse(const wxTreeItemId& treeId, bool expand, wxProgressDialog* dlg, long& counter); - void OnExpandButton(wxCommandEvent& event); void OnMenu(wxCommandEvent& event); --- 175,178 ---- *************** *** 197,204 **** void SetShowDuplicateExpandMessage(bool show) { m_show_dup_expand_msg = show; } ! void OnListItemDeleted(wxListEvent &event); ! void OnListAllItemsDeleted(wxListEvent &event); ! ! protected: void DeleteAllListItemData(); void RemoveAllLuaReferences(); --- 196,200 ---- void SetShowDuplicateExpandMessage(bool show) { m_show_dup_expand_msg = show; } ! //protected: void DeleteAllListItemData(); void RemoveAllLuaReferences(); *************** *** 224,231 **** bool m_show_dup_expand_msg; int m_batch_count; - bool m_skip_tree_event; wxLongToLongHashMap m_expandedItems; static wxSize m_defaultSize; // remember last dialog size --- 220,228 ---- bool m_show_dup_expand_msg; int m_batch_count; wxLongToLongHashMap m_expandedItems; + wxArrayPtrVoid m_listData; + static wxSize m_defaultSize; // remember last dialog size |
From: John L. <jr...@us...> - 2007-11-30 23:00:42
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv22316/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlstate.h Log Message: - wxLuaStackDialog has better search for all columns, collapse and expand tables, and show metatables. It also now uses a virtual wxListCtrl so it's much faster. - Separated the "tags" for C++ classes from "refs" for objects we want a handle on in the Lua registry by putting them in separate tables. - Removed wxlua_pushkey_XXX #defines since we now have a few tables in the registry that we use and those methods were not useful anymore. The lightuserdata keys are now const char* strings with a descriptive name, however only the mem address is used as the table key. - wxluaT_newtag() now leaves the created table on the stack. - Removed wxluaT_newweaktag() and wxluaT_settagmethod() since they were not needed anymore. Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** wxlbind.h 30 Nov 2007 06:23:39 -0000 1.64 --- wxlbind.h 30 Nov 2007 23:00:06 -0000 1.65 *************** *** 505,509 **** int m_start_tag; // The first wxLua allocated Lua tag int m_last_tag; // The last wxLua Lua tag of registered classes ! int m_luaTable_tag; // The Lua tag for the wxLua private tables static wxLuaBindingList sm_bindingList; --- 505,509 ---- int m_start_tag; // The first wxLua allocated Lua tag int m_last_tag; // The last wxLua Lua tag of registered classes ! int m_luaTable_ref; // The Lua ref for the wxLua private tables static wxLuaBindingList sm_bindingList; Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** wxlstate.h 17 Nov 2007 00:15:00 -0000 1.95 --- wxlstate.h 30 Nov 2007 23:00:07 -0000 1.96 *************** *** 76,129 **** // ---------------------------------------------------------------------------- - #define WXLUA_LREG_REFERENCES 1 - #define WXLUA_LREG_CLASSES 2 - #define WXLUA_LREG_DERIVED_METHODS 3 - #define WXLUA_LREG_WXLUASTATE 4 - #define WXLUA_LREG_OBJECTS 5 - #define WXLUA_LREG_CALLBASECLASSFUNC 6 - #define WXLUA_METATABLE_TAG 7 - #define WXLUA_METATABLE_CLASS 8 - // Light user data used as keys in the Lua LUA_REGISTRYINDEX table for wxLua items. // Note that even though these have values, they're not used, just the memory address. - extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_references_key; // WXLUA_LREG_REFERENCES - extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_classes_key; // WXLUA_LREG_CLASSES - extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_derivedmethods_key; // WXLUA_LREG_DERIVED_METHODS - extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_wxluastate_key; // WXLUA_LREG_WXLUASTATE - extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_objects_key; // WXLUA_LREG_OBJECTS - extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_callbaseclassfunc_key; // WXLUA_LREG_CALLBASECLASSFUNC - - // 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. - extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_metatable_tag_key; // WXLUA_METATABLE_TAG - extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_metatable_class_key; // WXLUA_METATABLE_CLASS ! // Push a key that is index in the LUA_REGISTRYINDEX table that is a table indexed ! // on the "tags" and each item is a metatable for classes ! // or a reference to an object we want to keep a handle to. ! #define wxlua_pushkey_wxLuaReferences(L) lua_pushlightuserdata(L, &wxlua_lreg_references_key) ! // Push a key that is an index in the LUA_REGISTRYINDEX table that is a table ! // t[wxLuaBindClass.name] = wxLuaBindClass, where the wxLuaBindClass struct is a lightuserdata. ! #define wxlua_pushkey_wxLuaClasses(L) lua_pushlightuserdata(L, &wxlua_lreg_classes_key) ! // Push a key that is an index in the LUA_REGISTRYINDEX table that is a table // of Lua functions assigned to wxLua userdata programatically in Lua. // t[lightuserdata object] = {["derived func/value name"] = wxLuaObject(Lua function/value), ...} ! #define wxlua_pushkey_wxLuaDerivedMethods(L) lua_pushlightuserdata(L, &wxlua_lreg_derivedmethods_key) ! // Push a key that is an index of the LUA_REGISTRYINDEX table who's value is a // lightuserdata of the wxLuaState for this lua_State. ! #define wxlua_pushkey_wxLuaState(L) lua_pushlightuserdata(L, &wxlua_lreg_wxluastate_key) ! // Push a key that is an index of the LUA_REGISTRYINDEX table that is table of all // objects that we've pushed into Lua using t[lightuserdata] = [weak valued full userdata] ! #define wxlua_pushkey_wxLuaObjects(L) lua_pushlightuserdata(L, &wxlua_lreg_objects_key) ! // Push a key that is an index of the LUA_REGISTRYINDEX table that is boolean value // of whether the Lua code has prepended a '_' to function name to indicate // that they want the base class function called. ! #define wxlua_pushkey_CallBaseClassFunc(L) lua_pushlightuserdata(L, &wxlua_lreg_callbaseclassfunc_key) // Push a key of an index into the metatable of a wxLua userdata for the "tag" number. ! #define wxlua_pushkey_metatableTag(L) lua_pushlightuserdata(L, &wxlua_lreg_metatable_tag_key) // Push a key of an index into the metatable of a wxLua userdata for the // lightuserdata of the wxLuaBindClass struct. ! #define wxlua_pushkey_metatableClass(L) lua_pushlightuserdata(L, &wxlua_lreg_metatable_class_key) // ---------------------------------------------------------------------------- --- 76,118 ---- // ---------------------------------------------------------------------------- // Light user data used as keys in the Lua LUA_REGISTRYINDEX table for wxLua items. // Note that even though these have values, they're not used, just the memory address. ! // The key in the LUA_REGISTRYINDEX table that is a table indexed ! // on the "tags" and each item is a metatable for a C++ class. ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_tags_key; ! // The key in the LUA_REGISTRYINDEX table that is a numerically keyed table ! // with references to objects we want to keep a handle to. ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_refs_key; ! // The key in the LUA_REGISTRYINDEX table that is a numerically keyed table ! // with references to objects we want to keep a handle to. It also ! // stores their value for faster lookup. It is used only for the wxLuaDebugData. ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_debug_refs_key; ! // The key that in the LUA_REGISTRYINDEX table that is a table ! // t[wxLuaBindClass.name] = lightuserdata(wxLuaBindClass stuct) ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_classes_key; ! // The key in the LUA_REGISTRYINDEX table that is a table // of Lua functions assigned to wxLua userdata programatically in Lua. // t[lightuserdata object] = {["derived func/value name"] = wxLuaObject(Lua function/value), ...} ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_lreg_derivedmethods_key; ! // The key in the LUA_REGISTRYINDEX table who's value is a // lightuserdata of the wxLuaState for this lua_State. ! 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 // 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. ! // Note that even though these have values, they're not used, just the memory address. // Push a key of an index into the metatable of a wxLua userdata for the "tag" number. ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_metatable_tag_key; // Push a key of an index into the metatable of a wxLua userdata for the // lightuserdata of the wxLuaBindClass struct. ! extern WXDLLIMPEXP_DATA_WXLUA(const char*) wxlua_metatable_wxluabindclass_key; // ---------------------------------------------------------------------------- *************** *** 144,199 **** //---------------------------------------------------------------------------- ! // Create a reference to the object at stack index in the ! // wxLuaReferences registry table, returns the table index or LUA_REFNIL ! // if the item on the stack is none or nil (an error). ! WXDLLIMPEXP_WXLUA int LUACALL wxluaT_insert(lua_State* L, int stack_idx); ! // Remove a reference to the object at the index in the ! // wxLuaReferences registry table, returns success. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_remove(lua_State* L, int wxlref_index); ! // Push onto the top of the stack the object at the index in the ! // wxLuaReferences registry table, if the index is LUA_REFNIL or the // value is nil return false and don't leave anything on the stack. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_get(lua_State* L, int wxlref_index); // Push the object u onto the top of the stack wrapped in a newuserdata ! // with it's metatable set to the table from wxluaT_get(tag). 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_pushkey_wxLuaObjects table of ! // the Lua registry 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); // 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_pushkey_wxLuaObjects Lua registry table. WXDLLIMPEXP_WXLUA void LUACALL wxluaT_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_pushkey_wxLuaObjects Lua registry table. WXDLLIMPEXP_WXLUA void LUACALL wxluaT_cleartrackedmetatable(lua_State* L, const void* u); ! // Get the numeric tag of the object at the stack index using the metatable's "tag" key. ! // returns WXLUA_NOTAG if the metatable of the object doesn't have a "tag" ! // key or it isn't a number. The tag is presumedly the index into the wxLuaReferences ! // registry table and denotes what type of object this is. WXDLLIMPEXP_WXLUA int LUACALL wxluaT_tag(lua_State* L, int stack_idx); // 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); ! // Allocate a new table (metatable) with a "tag" key equal to the number from wxluaT_insert ! // and store it in the wxLuaReferences registry table. ! // Returns the index into the ref table, the "tag" from wxluaT_insert. WXDLLIMPEXP_WXLUA int LUACALL wxluaT_newtag(lua_State* L); - // Create a new table and its metatable with weak keys and/or values by setting the - // metatable's __weak index to [k/v]. The table is wxluaT_insert into the wxLuaReferences - // registry table. Returns the created index into the ref table. - WXDLLIMPEXP_WXLUA int LUACALL wxluaT_newweaktag(lua_State* L, bool weak_keys, bool weak_values); // Set the metatable of the object at top of stack to the table stored in the ! // wxLuaReferences registry table using wxluaT_get(tag). WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_settag(lua_State* L, int tag); - // Set a metamethod for the metatable referenced by tag with the supplied name and function. - // If pClass is non-null set the upvalue of the function to the supplied wxLuaBindClass. - WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_settagmethod(lua_State* L, int tag, const char* method, - lua_CFunction func, void* pClass = NULL); // Is the item at the stack_idx in the wxLuaReferences table already? // returns the tag or LUA_NOREF if it's not. ! WXDLLIMPEXP_WXLUA int LUACALL wxluaT_isrefed(lua_State* L, int stack_idx); // ---------------------------------------------------------------------------- --- 133,181 ---- //---------------------------------------------------------------------------- ! // Create a reference to the object at stack index in a table with the key ! // lightuserdata_reg_key in the LUA_REGISTRYINDEX table. Does not pop the object. ! // Returns the table index or LUA_REFNIL if the item on the stack is none or nil (an error). ! WXDLLIMPEXP_WXLUA int LUACALL wxluaT_insert(lua_State* L, int stack_idx, const void* lightuserdata_reg_key); ! // Remove a reference to the object at the index in a table with the key ! // lightuserdata_reg_key in the LUA_REGISTRYINDEX table, returns success. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_remove(lua_State* L, int wxlref_index, const void* lightuserdata_reg_key); ! // Push onto the top of the stack the object at the index in a table with the key ! // lightuserdata_reg_key in the LUA_REGISTRYINDEX table, if the index is LUA_REFNIL or the // value is nil return false and don't leave anything on the stack. ! WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_get(lua_State* L, int wxlref_index, const void* lightuserdata_reg_key); // Push the object u onto the top of the stack wrapped in a newuserdata ! // with it's metatable set to the table from wxluaT_get(tag). ! // 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); // 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 wxluaT_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 wxluaT_cleartrackedmetatable(lua_State* L, const void* u); ! // Get the numeric tag of the object at the stack index using the metatable's wxlua_metatable_tag_key key. ! // Returns WXLUA_NOTAG if the metatable of the object doesn't have a wxlua_metatable_tag_key ! // key or it isn't a number. The tag is presumedly the index into the wxlua_lreg_tags_key ! // LUA_REGISTRYINDEX table and denotes what type of C++ object this is. WXDLLIMPEXP_WXLUA int LUACALL wxluaT_tag(lua_State* L, int stack_idx); // 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); ! // Allocate a new table (metatable) with a wxlua_metatable_tag_key key equal ! // to the number from wxluaT_insert and store it in the wxlua_lreg_tags_key LUA_REGISTRYINDEX table. ! // Returns the index into the tags table, the return value from wxluaT_insert. ! // Leaves the new table on the top of the stack. WXDLLIMPEXP_WXLUA int LUACALL wxluaT_newtag(lua_State* L); // Set the metatable of the object at top of stack to the table stored in the ! // wxlua_lreg_tags_key LUA_REGISTRYINDEX table using wxluaT_get(tag). WXDLLIMPEXP_WXLUA bool LUACALL wxluaT_settag(lua_State* L, int tag); // Is the item at the stack_idx in the wxLuaReferences table already? // returns the tag or LUA_NOREF if it's not. ! WXDLLIMPEXP_WXLUA int LUACALL wxluaT_isrefed(lua_State* L, int stack_idx, const void* lightuserdata_reg_key); // ---------------------------------------------------------------------------- *************** *** 695,732 **** // wxLua Lua Registry Table Functions ! // Create a reference to the object at stack index in the ! // wxLuaReferences registry table, returns the table index. ! int wxluaT_Insert(int stack_idx); ! // Remove a reference to the object at the index in the ! // wxLuaReferences registry table, returns success. ! bool wxluaT_Remove(int wxlref_index); ! // Push onto the top of the stack the object at the index in the ! // wxLuaReferences registry table, if the index is LUA_REFNIL or the ! // value is nil return false and don't leave anything on the stack. ! bool wxluaT_Get(int wxlref_index); ! // Push the object u onto the top of the stack wrapped in a newuserdata ! // with it's metatable set to the table from wxluaT_Get(tag). Returns true if the ! // tag is known and the metatable was set. ! bool wxluaT_PushUserTag(const void *u, int tag, bool track); ! // Get the numeric tag of the object at the stack index using the metatable's "tag" key. ! // returns WXLUA_NOTAG if the metatable of the object doesn't have a "tag" ! // key or it isn't a number. The tag is presumedly the index into the wxLuaReferences ! // registry table and denotes what type of object this is. ! int wxluaT_Tag(int stack_idx) const; ! // Get the userdata at the stack index, if null_ptr then set the userdata pointer ! // in Lua to NULL so that Lua won't gc it. void* wxlua_ToUserdata(int stack_idx, bool null_ptr = false) const; ! // Create a new table (metatable) wxluaT_Insert it into the wxLuaReferences registry table ! // and return its index into the ref table. ! int wxluaT_NewTag(); ! // Create a new table and its metatable with weak keys and/or values by setting the ! // metatable's __weak index to [k/v]. The table is wxluaT_Insert into the wxLuaReferences ! // registry table and return its index into the ref table. ! int wxluaT_NewWeakTag(bool weak_keys, bool weak_values); ! // Set the metatable of the object at top of stack to wxluaT_Get(tag) ! bool wxluaT_SetTag(int tag); ! // Set a metamethod for the metatable referenced by tag with the supplied name and function. ! // if pClass is non-null set the upvalue of the function to the supplied class ! bool wxluaT_SetTagMethod(int tag, const char *method, lua_CFunction func, void *pClass = NULL); // ----------------------------------------------------------------------- --- 677,688 ---- // wxLua Lua Registry Table Functions ! int wxluaT_Insert(int stack_idx, const void* lightuserdata_reg_key); ! bool wxluaT_Remove(int wxlref_index, const void* lightuserdata_reg_key); ! bool wxluaT_Get(int wxlref_index, const void* lightuserdata_reg_key); ! bool wxluaT_PushUserTag(const void *u, int tag, bool track); ! int wxluaT_Tag(int stack_idx) const; void* wxlua_ToUserdata(int stack_idx, bool null_ptr = false) const; ! int wxluaT_NewTag(); ! bool wxluaT_SetTag(int tag); // ----------------------------------------------------------------------- |
From: John L. <jr...@us...> - 2007-11-30 23:00:41
|
Update of /cvsroot/wxlua/wxLua/docs In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv22316/wxLua/docs Modified Files: changelog.txt Log Message: - wxLuaStackDialog has better search for all columns, collapse and expand tables, and show metatables. It also now uses a virtual wxListCtrl so it's much faster. - Separated the "tags" for C++ classes from "refs" for objects we want a handle on in the Lua registry by putting them in separate tables. - Removed wxlua_pushkey_XXX #defines since we now have a few tables in the registry that we use and those methods were not useful anymore. The lightuserdata keys are now const char* strings with a descriptive name, however only the mem address is used as the table key. - wxluaT_newtag() now leaves the created table on the stack. - Removed wxluaT_newweaktag() and wxluaT_settagmethod() since they were not needed anymore. Index: changelog.txt =================================================================== RCS file: /cvsroot/wxlua/wxLua/docs/changelog.txt,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** changelog.txt 29 Nov 2007 23:35:53 -0000 1.48 --- changelog.txt 30 Nov 2007 23:00:00 -0000 1.49 *************** *** 18,22 **** - Use wxSIGKILL to kill debuggee process since wxSIGTERM doesn't work in MSW. - wxLuaStackDialog has better search for all columns, collapse and expand ! tables, and show metatables. version 2.8.4.2 --- 18,32 ---- - Use wxSIGKILL to kill debuggee process since wxSIGTERM doesn't work in MSW. - wxLuaStackDialog has better search for all columns, collapse and expand ! tables, and show metatables. It also now uses a virtual wxListCtrl so ! it's much faster. ! - Separated the "tags" for C++ classes from "refs" for objects we want a ! handle on in the Lua registry by putting them in separate tables. ! - Removed wxlua_pushkey_XXX #defines since we now have a few tables in the ! registry that we use and those methods were not useful anymore. ! The lightuserdata keys are now const char* strings with a descriptive name, ! however only the mem address is used as the table key. ! - wxluaT_newtag() now leaves the created table on the stack. ! - Removed wxluaT_newweaktag() and wxluaT_settagmethod() since they were ! not needed anymore. version 2.8.4.2 |
From: John L. <jr...@us...> - 2007-11-30 23:00:19
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv22316/wxLua/modules/wxluasocket/src Modified Files: wxldtarg.cpp Log Message: - wxLuaStackDialog has better search for all columns, collapse and expand tables, and show metatables. It also now uses a virtual wxListCtrl so it's much faster. - Separated the "tags" for C++ classes from "refs" for objects we want a handle on in the Lua registry by putting them in separate tables. - Removed wxlua_pushkey_XXX #defines since we now have a few tables in the registry that we use and those methods were not useful anymore. The lightuserdata keys are now const char* strings with a descriptive name, however only the mem address is used as the table key. - wxluaT_newtag() now leaves the created table on the stack. - Removed wxluaT_newweaktag() and wxluaT_settagmethod() since they were not needed anymore. Index: wxldtarg.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxldtarg.cpp,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** wxldtarg.cpp 28 Nov 2007 22:55:02 -0000 1.41 --- wxldtarg.cpp 30 Nov 2007 23:00:08 -0000 1.42 *************** *** 322,326 **** { int iItem = m_references.Item(idx); ! m_wxlState.wxluaT_Remove(iItem); } m_references.Clear(); --- 322,326 ---- { int iItem = m_references.Item(idx); ! m_wxlState.wxluaT_Remove(iItem, &wxlua_lreg_debug_refs_key); } m_references.Clear(); *************** *** 509,513 **** lua_pushliteral(L, "OK"); ! nReference = m_wxlState.wxluaT_Insert(-1); lua_settop(L, nOldTop); // throw out all return values } --- 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 } *************** *** 526,534 **** if (strExpr == name) { ! nReference = m_wxlState.wxluaT_Insert(-1); fFound = true; break; } ! lua_pop(L, 1); } --- 526,534 ---- if (strExpr == name) { ! nReference = m_wxlState.wxluaT_Insert(-1, &wxlua_lreg_refs_key); fFound = true; break; } ! lua_pop(L, 1); } *************** *** 552,556 **** if (strExpr == name) { ! nReference = m_wxlState.wxluaT_Insert(-1); // reference value lua_pop(L, 2); // pop key and value fFound = true; --- 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; *************** *** 565,575 **** } ! if (m_wxlState.wxluaT_Get(nReference)) { ! m_wxlState.wxluaT_Remove(nReference); int wxl_type = 0; wxString value; ! int l_type = wxLuaDebugData::GetTypeValue(m_wxlState, -1, &wxl_type, value); strResult = wxlua_getwxluatypename(wxl_type) + wxT(" : ") + value; --- 565,575 ---- } ! if (m_wxlState.wxluaT_Get(nReference, &wxlua_lreg_refs_key)) { ! m_wxlState.wxluaT_Remove(nReference, &wxlua_lreg_refs_key); int wxl_type = 0; wxString value; ! wxLuaDebugData::GetTypeValue(m_wxlState, -1, &wxl_type, value); strResult = wxlua_getwxluatypename(wxl_type) + wxT(" : ") + value; *************** *** 662,666 **** int lineNumber = 0; wxString fileName; ! if (!(m_forceBreak && m_resetRequested)) { --- 662,666 ---- int lineNumber = 0; wxString fileName; ! if (!(m_forceBreak && m_resetRequested)) { |
From: John L. <jr...@us...> - 2007-11-30 06:23:43
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv6752/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: Make the wxLuaStackDialog run a little faster Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** wxlstack.cpp 29 Nov 2007 23:35:53 -0000 1.18 --- wxlstack.cpp 30 Nov 2007 06:23:39 -0000 1.19 *************** *** 42,46 **** #define DUMMY_TREEITEM wxT(" ") - #define WXLUAARG_WXLUADATA (WXLUAARG__MIN - 100) --- 42,45 ---- *************** *** 90,93 **** --- 89,93 ---- m_show_dup_expand_msg = true; m_batch_count = 0; + m_skip_tree_event = false; } *************** *** 189,193 **** m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_CASE, wxT("&Case sensitive"), wxT("Case sensitive searching"), wxITEM_CHECK); m_findMenu->AppendSeparator(); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_ALL, wxT("Search everywhere"), wxT("Search in all columns"), wxITEM_CHECK); m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_NAME, wxT("Search names"), wxT("Search in name column"), wxITEM_CHECK); m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_LEVEL, wxT("Search level"), wxT("Search in level column"), wxITEM_CHECK); --- 189,193 ---- m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_CASE, wxT("&Case sensitive"), wxT("Case sensitive searching"), wxITEM_CHECK); m_findMenu->AppendSeparator(); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_ALL, wxT("Search everywhere"), wxT("Search in all columns"), wxITEM_CHECK); m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_NAME, wxT("Search names"), wxT("Search in name column"), wxITEM_CHECK); m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_LEVEL, wxT("Search level"), wxT("Search in level column"), wxITEM_CHECK); *************** *** 335,339 **** wxCHECK_MSG(dbgItem, IMG_UNKNOWN, wxT("Invalid wxLuaDebugItem")); - //int img = WXLUAARG_TO_POSINDEX(dbgItem->GetValueType()); int img = IMG_NONE; --- 335,338 ---- *************** *** 433,437 **** } ! if (debugData.GetCount() > 0) { m_stackChoice->SetSelection(0); --- 432,436 ---- } ! if (count > 0) { m_stackChoice->SetSelection(0); *************** *** 523,526 **** --- 522,526 ---- BeginBatch(); + m_skip_tree_event = true; size_t n, count = debugData.GetCount(); *************** *** 581,584 **** --- 581,587 ---- m_treeCtrl->Expand(treeId); #endif //!defined(WXLUA_STACK_MSWTREE) + + m_skip_tree_event = false; + } } *************** *** 683,687 **** { wxString msg; ! if (expand) msg.Printf(wxT("Expanding nodes : %ld"), counter); else --- 686,690 ---- { wxString msg; ! if (expand) msg.Printf(wxT("Expanding nodes : %ld"), counter); else *************** *** 690,694 **** if (!dlg->Pulse(msg)) { ! counter = -1; return; } --- 693,697 ---- if (!dlg->Pulse(msg)) { ! counter = -1; return; } *************** *** 730,734 **** caption = wxT("wxLua Stack Collapsing node"); ! wxProgressDialog dlg(caption, wxEmptyString, 100, this, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); --- 733,737 ---- caption = wxT("wxLua Stack Collapsing node"); ! wxProgressDialog dlg(caption, wxEmptyString, 100, this, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); *************** *** 799,803 **** 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()) ); --- 802,806 ---- 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()) ); *************** *** 832,837 **** if (!find_col[0] && !find_col[1] && !find_col[2] && !find_col[3] && !find_col[4]) { ! wxMessageBox(wxT("Please select the columns to search with the find options button"), ! wxT("wxLua Stack Find Error"), wxOK|wxICON_EXCLAMATION|wxCENTRE, this); return; --- 835,840 ---- if (!find_col[0] && !find_col[1] && !find_col[2] && !find_col[3] && !find_col[4]) { ! wxMessageBox(wxT("Please select at least one column to search with the find options button"), ! wxT("wxLua Stack Find Error"), wxOK|wxICON_EXCLAMATION|wxCENTRE, this); return; *************** *** 892,900 **** { if (!find_col[col]) continue; ! li.SetColumn(col); m_listCtrl->GetItem(li); wxString txt(li.GetText()); ! if ((match_case && (txt.Find(findStr) != wxNOT_FOUND)) || (!match_case && (txt.Lower().Find(findStr) != wxNOT_FOUND))) --- 895,903 ---- { if (!find_col[col]) continue; ! li.SetColumn(col); m_listCtrl->GetItem(li); wxString txt(li.GetText()); ! if ((match_case && (txt.Find(findStr) != wxNOT_FOUND)) || (!match_case && (txt.Lower().Find(findStr) != wxNOT_FOUND))) *************** *** 929,933 **** void wxLuaStackDialog::OnTreeItem(wxTreeEvent &event) { ! event.Skip(); wxTreeItemId id = event.GetItem(); wxLuaStackTreeData* stkTreeData = (wxLuaStackTreeData*)m_treeCtrl->GetItemData(id); --- 932,937 ---- void wxLuaStackDialog::OnTreeItem(wxTreeEvent &event) { ! if (m_skip_tree_event) return; ! wxTreeItemId id = event.GetItem(); wxLuaStackTreeData* stkTreeData = (wxLuaStackTreeData*)m_treeCtrl->GetItemData(id); *************** *** 942,949 **** --- 946,955 ---- if (evt_type == wxEVT_COMMAND_TREE_ITEM_EXPANDED) { + wxBusyCursor busy; ExpandItem(list_item); } else if (evt_type == wxEVT_COMMAND_TREE_ITEM_COLLAPSED) { + wxBusyCursor busy; CollapseItem(list_item); } *************** *** 1006,1010 **** wxT("Invalid list item to expand")); - wxBusyCursor busy; bool expanded = false; --- 1012,1015 ---- *************** *** 1066,1070 **** wxLuaDebugItem* debugItem_n = stkListData_n->GetDebugItem(); ! if (debugItem_n && (debugItem_n != debugItem) && debugItem_n->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED) && (debugItem_n->GetValue() == val)) --- 1071,1075 ---- wxLuaDebugItem* debugItem_n = stkListData_n->GetDebugItem(); ! if (debugItem_n && (debugItem_n != debugItem) && debugItem_n->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED) && (debugItem_n->GetValue() == val)) *************** *** 1143,1147 **** wxT("Invalid list item to expand")); - wxBusyCursor busy; bool collapsed = false; --- 1148,1151 ---- Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** wxldebug.cpp 28 Nov 2007 22:55:02 -0000 1.49 --- wxldebug.cpp 30 Nov 2007 06:23:39 -0000 1.50 *************** *** 125,129 **** int wxLuaDebugData::SortFunction(wxLuaDebugItem *elem1, wxLuaDebugItem *elem2 ) { ! int ret = elem1->GetKey().Cmp(elem2->GetKey()); if (ret == 0) // can be true for unnamed "(*temporary)" vars --- 125,129 ---- int wxLuaDebugData::SortFunction(wxLuaDebugItem *elem1, wxLuaDebugItem *elem2 ) { ! int ret = elem1->m_itemKey.Cmp(elem2->m_itemKey); // not GetKey() for speed if (ret == 0) // can be true for unnamed "(*temporary)" vars *************** *** 213,223 **** // 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. int flag_type = 0; int nRef = LUA_NOREF; //RefTable(L, -1, &flag_type, references); ! lua_pop(L, 1); // remove variable value --- 213,223 ---- // 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. int flag_type = 0; int nRef = LUA_NOREF; //RefTable(L, -1, &flag_type, references); ! lua_pop(L, 1); // remove variable value *************** *** 283,287 **** Add(new wxLuaDebugItem(wxT(" __metatable"), WXLUAARG_Table, value, wxl_valuetype, wxT(""), nRef, nIndex, flag_type)); count++; ! lua_pop(L, 1); // pop metatable } --- 283,287 ---- Add(new wxLuaDebugItem(wxT(" __metatable"), WXLUAARG_Table, value, wxl_valuetype, wxT(""), nRef, nIndex, flag_type)); count++; ! lua_pop(L, 1); // pop metatable } *************** *** 298,302 **** int flag_type = 0; int nRef = RefTable(L, -1, &flag_type, references); ! lua_pop(L, 1); --- 298,302 ---- int flag_type = 0; int nRef = RefTable(L, -1, &flag_type, references); ! lua_pop(L, 1); *************** *** 341,375 **** int wxl_type = wxlua_getwxluatype(l_type); switch (l_type) { case LUA_TNONE: value = wxEmptyString; break; ! case LUA_TNIL: value = wxT("nil"); break; ! case LUA_TBOOLEAN: ! value = MakeBoolean(lua_toboolean(L, stack_idx)); break; ! case LUA_TLIGHTUSERDATA: value = GetUserDataInfo(wxlState, stack_idx, false); break; ! case LUA_TNUMBER: ! value = MakeNumber(lua_tonumber(L, stack_idx)); ! break; case LUA_TSTRING: value = lua2wx(lua_tostring(L, stack_idx)); break; ! case LUA_TTABLE: value = GetTableInfo(wxlState, stack_idx); break; ! case LUA_TFUNCTION: if (lua_iscfunction(L, stack_idx)) { --- 341,391 ---- int wxl_type = wxlua_getwxluatype(l_type); + if (wxl_type_) *wxl_type_ = wxl_type; + switch (l_type) { case LUA_TNONE: + { value = wxEmptyString; break; ! } case LUA_TNIL: + { value = wxT("nil"); break; ! } case LUA_TBOOLEAN: ! { ! value = (lua_toboolean(L, stack_idx) != 0) ? wxT("true") : wxT("false"); break; ! } case LUA_TLIGHTUSERDATA: + { value = GetUserDataInfo(wxlState, stack_idx, false); break; ! } case LUA_TNUMBER: ! { ! double num = lua_tonumber(L, stack_idx); + if ((long)num == num) + value = wxString::Format(wxT("%ld (0x%lx)"), (long)num, (unsigned long)num); + else + value = wxString::Format(wxT("%g"), num); + + break; + } case LUA_TSTRING: + { value = lua2wx(lua_tostring(L, stack_idx)); break; ! } case LUA_TTABLE: + { value = GetTableInfo(wxlState, stack_idx); break; ! } case LUA_TFUNCTION: + { if (lua_iscfunction(L, stack_idx)) { *************** *** 382,418 **** } break; ! case LUA_TUSERDATA: value = GetUserDataInfo(wxlState, stack_idx, true); break; ! case LUA_TTHREAD: value.Printf(wxT("%p"), lua_topointer(L, stack_idx)); break; ! default : value = wxEmptyString; break; } - if (wxl_type_) *wxl_type_ = wxl_type; - return l_type; } - wxString wxLuaDebugData::MakeNumber(double dnum) - { - long num = (long) dnum; - if ((double) num == dnum) - return wxString::Format(wxT("%ld (0x%lx)"), num, (unsigned long)num); - - return wxString::Format(wxT("%g"), dnum); - } - - wxString wxLuaDebugData::MakeBoolean(int num) - { - return num != 0 ? wxT("true") : wxT("false"); - } - wxString wxLuaDebugData::GetTableInfo(const wxLuaState& wxlState, int stack_idx) { --- 398,422 ---- } break; ! } case LUA_TUSERDATA: + { value = GetUserDataInfo(wxlState, stack_idx, true); break; ! } case LUA_TTHREAD: + { value.Printf(wxT("%p"), lua_topointer(L, stack_idx)); break; ! } default : + { value = wxEmptyString; break; + } } return l_type; } wxString wxLuaDebugData::GetTableInfo(const wxLuaState& wxlState, int stack_idx) { *************** *** 424,428 **** const void *pItem = lua_topointer(L, stack_idx); ! wxString s = wxString::Format(wxT("%p"), pItem); if (nItems > 0) --- 428,432 ---- const void *pItem = lua_topointer(L, stack_idx); ! wxString s(wxString::Format(wxT("%p"), pItem)); if (nItems > 0) *************** *** 435,450 **** } ! wxString wxLuaDebugData::GetUserDataInfo(const wxLuaState& wxlState_, int stack_idx, bool full) { ! wxCHECK_MSG(wxlState_.Ok(), wxEmptyString, wxT("Invalid wxLuaState")); ! wxLuaState wxlState(wxlState_); // unconst wxLuaState lua_State* L = wxlState.GetLuaState(); ! wxString s = wxString::Format(wxT("%p"), lua_touserdata(L, stack_idx)); if (!full) { - void* udata = lua_touserdata(L, stack_idx); - // Convert our known keys to something more readable if (udata == &wxlua_lreg_references_key) --- 439,453 ---- } ! wxString wxLuaDebugData::GetUserDataInfo(const wxLuaState& wxlState, int stack_idx, bool full) { ! wxCHECK_MSG(wxlState.Ok(), wxEmptyString, wxT("Invalid wxLuaState")); lua_State* L = wxlState.GetLuaState(); ! void* udata = lua_touserdata(L, stack_idx); ! ! wxString s(wxString::Format(wxT("%p"), udata)); if (!full) { // Convert our known keys to something more readable if (udata == &wxlua_lreg_references_key) *************** *** 474,480 **** s += wxString::Format(wxT(" (tag %d)"), nTag); ! wxString pTagName = wxlState.GetLuaTagName(nTag); ! if (!pTagName.IsEmpty()) ! s += wxString::Format(wxT(" '%s'"), pTagName.c_str()); } } --- 477,483 ---- s += wxString::Format(wxT(" (tag %d)"), nTag); ! wxString tagName(wxlState.GetLuaTagName(nTag)); ! if (!tagName.IsEmpty()) ! s += wxString::Format(wxT(" '%s'"), tagName.c_str()); } } *************** *** 533,537 **** int l_type = wxLuaDebugData::GetTypeValue(wxlState, i, &wxl_type, value); ! str.Printf(wxT(" idx %d: l_type = %d, wxl_type = %d : '%s'='%s'\n"), i, l_type, wxl_type, wxlua_getwxluatypename(wxl_type).c_str(), value.c_str()); retStr += str; --- 536,540 ---- int l_type = wxLuaDebugData::GetTypeValue(wxlState, i, &wxl_type, value); ! str.Printf(wxT(" idx %d: l_type = %d, wxl_type = %d : '%s'='%s'\n"), i, l_type, wxl_type, wxlua_getwxluatypename(wxl_type).c_str(), value.c_str()); retStr += str; *************** *** 566,573 **** lua_pushstring(L, wx2lua(tname.BeforeFirst(wxT('.')))); lua_rawget(L, -2); ! if (lua_isnil(L, -1) || !lua_istable(L, -1)) { ! lua_pop(L, 2); // remove table and value s.Printf(wxT("wxLuaCheckStack::DumpTable(L=%p) Table: '%s' cannot be found!\n"), L, tablename.c_str()); --- 569,576 ---- lua_pushstring(L, wx2lua(tname.BeforeFirst(wxT('.')))); lua_rawget(L, -2); ! if (lua_isnil(L, -1) || !lua_istable(L, -1)) { ! lua_pop(L, 2); // remove table and value s.Printf(wxT("wxLuaCheckStack::DumpTable(L=%p) Table: '%s' cannot be found!\n"), L, tablename.c_str()); *************** *** 576,580 **** } ! lua_remove(L, -2); // remove previous table tname = tname.AfterFirst(wxT('.')); } while (tname.Len() > 0); --- 579,583 ---- } ! lua_remove(L, -2); // remove previous table tname = tname.AfterFirst(wxT('.')); } while (tname.Len() > 0); *************** *** 673,677 **** void wxLuaCheckStack::OutputMsg(const wxString& msg) const { ! if (m_print_to_console) { #if defined(__WXMSW__) --- 676,680 ---- void wxLuaCheckStack::OutputMsg(const wxString& msg) const { ! if (m_print_to_console) { #if defined(__WXMSW__) |
From: John L. <jr...@us...> - 2007-11-30 06:23:42
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv6752/wxLua/modules/wxluadebug/include Modified Files: wxldebug.h wxlstack.h Log Message: Make the wxLuaStackDialog run a little faster Index: wxldebug.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/include/wxldebug.h,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** wxldebug.h 28 Nov 2007 22:55:01 -0000 1.43 --- wxldebug.h 30 Nov 2007 06:23:39 -0000 1.44 *************** *** 71,76 **** { return wxString::Format(wxT("Key: '%s' KeyType: %d '%s' Value: '%s' ValueType: %d '%s' Ref: %d Idx: %d Flag: %d HasSrc: %d"), ! m_itemKey.c_str(), m_itemKeyType, GetKeyTypeString().c_str(), ! m_itemValue.c_str(), m_itemValueType, GetValueTypeString().c_str(), m_lua_ref, m_index, m_flag, (int)!m_itemSource.IsEmpty()); } --- 71,76 ---- { return wxString::Format(wxT("Key: '%s' KeyType: %d '%s' Value: '%s' ValueType: %d '%s' Ref: %d Idx: %d Flag: %d HasSrc: %d"), ! m_itemKey.c_str(), m_itemKeyType, GetKeyTypeString().c_str(), ! m_itemValue.c_str(), m_itemValueType, GetValueTypeString().c_str(), m_lua_ref, m_index, m_flag, (int)!m_itemSource.IsEmpty()); } *************** *** 140,150 **** // give a consistent feel to the display of Lua values. ! // Get information about the item at the 'stack_idx'. Returns the lua_type(L, stack_idx), // fills 'wxl_type' with the WXLUAARG_XXX type and 'value' with a human readable value. static int GetTypeValue(const wxLuaState& wxlState, int stack_idx, int* wxl_type, wxString& value); - // Write the input number as either an int, uint, or as a double - static wxString MakeNumber(double dnum); - // Convert the number to either "true" or "false" (eg !0 or 0) - static wxString MakeBoolean(int num); // Get a wxString description about the table at the stack_idx in the Lua stack static wxString GetTableInfo(const wxLuaState& wxlState, int stack_idx); --- 140,146 ---- // give a consistent feel to the display of Lua values. ! // Get information about the item at the 'stack_idx'. Returns the lua_type(L, stack_idx), // fills 'wxl_type' with the WXLUAARG_XXX type and 'value' with a human readable value. static int GetTypeValue(const wxLuaState& wxlState, int stack_idx, int* wxl_type, wxString& value); // Get a wxString description about the table at the stack_idx in the Lua stack static wxString GetTableInfo(const wxLuaState& wxlState, int stack_idx); *************** *** 186,190 **** public: // Create a instance, remembers lua_gettop(), 'msg' can be used to add ! // information about where or why this was created. // If 'print_to_console' then all functions below that return a string will also // print to the console as well. --- 182,186 ---- public: // Create a instance, remembers lua_gettop(), 'msg' can be used to add ! // information about where or why this was created. // If 'print_to_console' then all functions below that return a string will also // print to the console as well. *************** *** 198,202 **** // Returns a string of the current items on the stack with their types. wxString DumpStack(const wxString& msg = wxEmptyString); ! // Returns a string of all of the global variables and subtables with additional msg. wxString DumpGlobals(const wxString& msg = wxEmptyString); --- 194,198 ---- // Returns a string of the current items on the stack with their types. wxString DumpStack(const wxString& msg = wxEmptyString); ! // Returns a string of all of the global variables and subtables with additional msg. wxString DumpGlobals(const wxString& msg = wxEmptyString); Index: wxlstack.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/include/wxlstack.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** wxlstack.h 29 Nov 2007 23:35:53 -0000 1.9 --- wxlstack.h 30 Nov 2007 06:23:39 -0000 1.10 *************** *** 106,110 **** const wxString& title = wxT("wxLua Stack"), const wxPoint& pos = wxDefaultPosition, ! const wxSize& size = wxDefaultSize) { Init(); --- 106,110 ---- const wxString& title = wxT("wxLua Stack"), const wxPoint& pos = wxDefaultPosition, ! const wxSize& size = wxDefaultSize) { Init(); *************** *** 224,227 **** --- 224,228 ---- bool m_show_dup_expand_msg; int m_batch_count; + bool m_skip_tree_event; wxLongToLongHashMap m_expandedItems; |
From: John L. <jr...@us...> - 2007-11-30 06:23:42
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv6752/wxLua/modules/wxlua/include Modified Files: wxlbind.h Log Message: Make the wxLuaStackDialog run a little faster Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** wxlbind.h 17 Nov 2007 00:15:00 -0000 1.63 --- wxlbind.h 30 Nov 2007 06:23:39 -0000 1.64 *************** *** 65,70 **** #define WXLUAARG__MIN -13 // Min of the WXLUAARG_XXX values - #define WXLUAARG_TO_POSINDEX(wxlua_arg) (-(wxlua_arg)) - // Variables used in the wxLuaArgTag member of the wxLuaBindCFunc for // common types. The binding generator will use these and generate others --- 65,68 ---- |
From: John L. <jr...@us...> - 2007-11-29 23:35:58
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv29041/wxLua/modules/wxluasocket/src Modified Files: wxldserv.cpp Log Message: Made the wxLuaStackDialog much nicer, faster, search in all cols, collapse and expand child tables. Index: wxldserv.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxldserv.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** wxldserv.cpp 28 Nov 2007 22:55:02 -0000 1.47 --- wxldserv.cpp 29 Nov 2007 23:35:54 -0000 1.48 *************** *** 94,98 **** const wxString& title, const wxPoint& pos, const wxSize& size) ! :wxLuaStackDialog(), m_luaDebugger(luaDebugger) { wxCHECK_RET(m_luaDebugger != NULL, wxT("Invalid wxLuaDebuggerBase in wxLuaDebuggerStackDialog")); --- 94,98 ---- const wxString& title, const wxPoint& pos, const wxSize& size) ! : m_luaDebugger(luaDebugger) { wxCHECK_RET(m_luaDebugger != NULL, wxT("Invalid wxLuaDebuggerBase in wxLuaDebuggerStackDialog")); *************** *** 564,572 **** } ! bool wxLuaDebuggerBase::DisplayStackDialog(wxWindow *parent, wxWindowID id) { wxCHECK_MSG(m_stackDialog == NULL, false, wxT("Stack dialog already shown")); ! m_stackDialog = new wxLuaDebuggerStackDialog(this, parent, id); m_stackDialog->ShowModal(); m_stackDialog->Destroy(); --- 564,572 ---- } ! bool wxLuaDebuggerBase::DisplayStackDialog(wxWindow *parent, wxWindowID winid) { wxCHECK_MSG(m_stackDialog == NULL, false, wxT("Stack dialog already shown")); ! m_stackDialog = new wxLuaDebuggerStackDialog(this, parent, winid); m_stackDialog->ShowModal(); m_stackDialog->Destroy(); |
From: John L. <jr...@us...> - 2007-11-29 23:35:58
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv29041/wxLua/modules/wxluadebug/src Modified Files: wxlstack.cpp Log Message: Made the wxLuaStackDialog much nicer, faster, search in all cols, collapse and expand child tables. Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** wxlstack.cpp 17 Nov 2007 00:15:07 -0000 1.17 --- wxlstack.cpp 29 Nov 2007 23:35:53 -0000 1.18 *************** *** 22,25 **** --- 22,27 ---- #include "wx/listctrl.h" #include "wx/splitter.h" + #include "wx/progdlg.h" + #include "wx/clipbrd.h" #include "wxluadebug/include/wxlstack.h" *************** *** 48,59 **** IMPLEMENT_ABSTRACT_CLASS(wxLuaStackDialog, wxDialog) BEGIN_EVENT_TABLE(wxLuaStackDialog, wxDialog) EVT_CHOICE( ID_WXLUA_STACK_CHOICE, wxLuaStackDialog::OnSelectStack) ! EVT_BUTTON( ID_WXLUA_STACK_EXPAND_BUTTON, wxLuaStackDialog::OnExpandButton) EVT_TEXT_ENTER( ID_WXLUA_STACK_FIND_COMBO, wxLuaStackDialog::OnFind) EVT_BUTTON( ID_WXLUA_STACK_FINDNEXT_BUTTON, wxLuaStackDialog::OnFind) EVT_BUTTON( ID_WXLUA_STACK_FINDPREV_BUTTON, wxLuaStackDialog::OnFind) EVT_TREE_ITEM_COLLAPSED(ID_WXLUA_STACK_TREECTRL, wxLuaStackDialog::OnTreeItem) --- 50,67 ---- IMPLEMENT_ABSTRACT_CLASS(wxLuaStackDialog, wxDialog) + wxSize wxLuaStackDialog::m_defaultSize(500, 300); + BEGIN_EVENT_TABLE(wxLuaStackDialog, wxDialog) EVT_CHOICE( ID_WXLUA_STACK_CHOICE, wxLuaStackDialog::OnSelectStack) ! EVT_BUTTON( ID_WXLUA_STACK_COLLAPSE_BUTTON, wxLuaStackDialog::OnExpandButton) ! EVT_BUTTON( ID_WXLUA_STACK_EXPAND_BUTTON, wxLuaStackDialog::OnExpandButton) ! ! EVT_MENU( wxID_ANY, wxLuaStackDialog::OnMenu) EVT_TEXT_ENTER( ID_WXLUA_STACK_FIND_COMBO, wxLuaStackDialog::OnFind) EVT_BUTTON( ID_WXLUA_STACK_FINDNEXT_BUTTON, wxLuaStackDialog::OnFind) EVT_BUTTON( ID_WXLUA_STACK_FINDPREV_BUTTON, wxLuaStackDialog::OnFind) + EVT_BUTTON( ID_WXLUA_STACK_FINDMENU_BUTTON, wxLuaStackDialog::OnFind) EVT_TREE_ITEM_COLLAPSED(ID_WXLUA_STACK_TREECTRL, wxLuaStackDialog::OnTreeItem) *************** *** 63,66 **** --- 71,75 ---- EVT_LIST_ITEM_SELECTED( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListItemActivated) EVT_LIST_ITEM_ACTIVATED( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListItemActivated) + EVT_LIST_ITEM_RIGHT_CLICK( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListRightClick) EVT_LIST_DELETE_ITEM( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListItemDeleted) EVT_LIST_DELETE_ALL_ITEMS( ID_WXLUA_STACK_LISTCTRL, wxLuaStackDialog::OnListAllItemsDeleted) *************** *** 71,80 **** m_listCtrl = NULL; m_treeCtrl = NULL; m_stackChoice = NULL; m_stack_sel = -1; m_findComboBox = NULL; ! m_findCaseCheckBox = NULL; m_imageList = NULL; } --- 80,93 ---- m_listCtrl = NULL; m_treeCtrl = NULL; + m_listMenu = NULL; m_stackChoice = NULL; m_stack_sel = -1; m_findComboBox = NULL; ! m_findMenu = NULL; m_imageList = NULL; + + m_show_dup_expand_msg = true; + m_batch_count = 0; } *************** *** 82,89 **** wxWindow* parent, wxWindowID id, const wxString& title, ! const wxPoint& pos, const wxSize& size) { m_wxlState = wxlState; if (!wxDialog::Create(parent, id, title, pos, size, wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxMAXIMIZE_BOX | wxRESIZE_BORDER)) --- 95,105 ---- wxWindow* parent, wxWindowID id, const wxString& title, ! const wxPoint& pos, const wxSize& size_) { m_wxlState = wxlState; + wxSize size(size_); + if (size == wxDefaultSize) size = m_defaultSize; + if (!wxDialog::Create(parent, id, title, pos, size, wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxMAXIMIZE_BOX | wxRESIZE_BORDER)) *************** *** 140,148 **** wxDefaultPosition, wxDefaultSize, 0, NULL, 0, wxDefaultValidator ); // help GCC find which fn to call ! m_stackChoice->SetToolTip(wxT("Select Lua stack to display.")); ! wxButton* expandButton = new wxButton(panel, ID_WXLUA_STACK_EXPAND_BUTTON, ! wxT("Expand Item")); ! expandButton->SetToolTip(wxT("Expand all item's children (may take awhile)")); // ----------------------------------------------------------------------- --- 156,168 ---- wxDefaultPosition, wxDefaultSize, 0, NULL, 0, wxDefaultValidator ); // help GCC find which fn to call ! m_stackChoice->SetToolTip(wxT("Select Lua stack frame to display.")); ! wxBitmapButton* expandButton = new wxBitmapButton(panel, ID_WXLUA_STACK_EXPAND_BUTTON, ! wxArtProvider::GetBitmap(wxART_ADD_BOOKMARK, wxART_BUTTON)); ! expandButton->SetToolTip(wxT("Expand selected item's children (may take awhile)")); ! ! wxBitmapButton* collapseButton = new wxBitmapButton(panel, ID_WXLUA_STACK_COLLAPSE_BUTTON, ! wxArtProvider::GetBitmap(wxART_DEL_BOOKMARK, wxART_BUTTON)); ! collapseButton->SetToolTip(wxT("Collapse selected item's children (may take awhile)")); // ----------------------------------------------------------------------- *************** *** 153,157 **** wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN | wxTE_PROCESS_ENTER); ! m_findComboBox->SetToolTip(wxT("Enter variable name or table key to find")); wxBitmapButton* findPrev = new wxBitmapButton( panel, ID_WXLUA_STACK_FINDPREV_BUTTON, --- 173,177 ---- wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN | wxTE_PROCESS_ENTER); ! m_findComboBox->SetToolTip(wxT("Enter string to find")); wxBitmapButton* findPrev = new wxBitmapButton( panel, ID_WXLUA_STACK_FINDPREV_BUTTON, *************** *** 162,169 **** findNext->SetToolTip(wxT("Find next instance")); ! m_findCaseCheckBox = new wxCheckBox(panel, ID_WXLUA_STACK_FINDCASE_CHECKBOX, ! wxT("Match case")); ! m_findCaseCheckBox->SetValue(true); ! m_findCaseCheckBox->SetToolTip(wxT("Match case when finding")); // ----------------------------------------------------------------------- --- 182,200 ---- findNext->SetToolTip(wxT("Find next instance")); ! wxBitmapButton* findMenuButton = new wxBitmapButton(panel, ID_WXLUA_STACK_FINDMENU_BUTTON, ! wxArtProvider::GetBitmap(wxART_HELP_SETTINGS, wxART_BUTTON)); ! findMenuButton->SetToolTip(wxT("Select find options")); ! ! m_findMenu = new wxMenu(wxT("Find Options"), 0); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_CASE, wxT("&Case sensitive"), wxT("Case sensitive searching"), wxITEM_CHECK); ! m_findMenu->AppendSeparator(); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_ALL, wxT("Search everywhere"), wxT("Search in all columns"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_NAME, wxT("Search names"), wxT("Search in name column"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_LEVEL, wxT("Search level"), wxT("Search in level column"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_KEYTYPE, wxT("Search key type"), wxT("Search in key type column"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_VALUETYPE, wxT("Search value type"), wxT("Search in value type column"), wxITEM_CHECK); ! m_findMenu->Append(ID_WXLUA_STACK_FINDMENU_VALUE, wxT("Search values"), wxT("Search in value column"), wxITEM_CHECK); ! ! m_findMenu->Check(ID_WXLUA_STACK_FINDMENU_NAME, true); // ----------------------------------------------------------------------- *************** *** 174,180 **** topSizer->Add(stackText, wxSizerFlags().Expand().Border().Align(wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL)); ! wxFlexGridSizer* stackSizer = new wxFlexGridSizer(2, 1); stackSizer->AddGrowableCol(0); stackSizer->Add(m_stackChoice, wxSizerFlags().Expand().Border()); stackSizer->Add(expandButton, wxSizerFlags().Border()); topSizer->Add(stackSizer, wxSizerFlags().Expand()); --- 205,212 ---- topSizer->Add(stackText, wxSizerFlags().Expand().Border().Align(wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL)); ! wxFlexGridSizer* stackSizer = new wxFlexGridSizer(3, 1); stackSizer->AddGrowableCol(0); stackSizer->Add(m_stackChoice, wxSizerFlags().Expand().Border()); + stackSizer->Add(collapseButton, wxSizerFlags().Border()); stackSizer->Add(expandButton, wxSizerFlags().Border()); topSizer->Add(stackSizer, wxSizerFlags().Expand()); *************** *** 187,191 **** findSizer->Add(findPrev, wxSizerFlags().Expand().Border()); findSizer->Add(findNext, wxSizerFlags().Expand().Border()); ! findSizer->Add(m_findCaseCheckBox, wxSizerFlags().Expand().Border()); topSizer->Add(findSizer, wxSizerFlags().Expand()); --- 219,224 ---- findSizer->Add(findPrev, wxSizerFlags().Expand().Border()); findSizer->Add(findNext, wxSizerFlags().Expand().Border()); ! ! findSizer->Add(findMenuButton, wxSizerFlags().Expand().Border()); topSizer->Add(findSizer, wxSizerFlags().Expand()); *************** *** 227,233 **** m_listCtrl->SetColumnWidth(3, txt_width); // ----------------------------------------------------------------------- ! m_splitterWin->SplitVertically(m_treeCtrl, m_listCtrl, 200); // use sizers to layout the windows in the panel of the dialog --- 260,273 ---- m_listCtrl->SetColumnWidth(3, txt_width); + m_listMenu = new wxMenu(wxEmptyString, 0); + m_listMenu->Append(ID_WXLUA_STACK_LISTMENU_COPY0, wxT("Copy name"), wxT("Copy name to clipboard"), wxITEM_NORMAL); + m_listMenu->Append(ID_WXLUA_STACK_LISTMENU_COPY1, wxT("Copy level"), wxT("Copy level to clipboard"), wxITEM_NORMAL); + m_listMenu->Append(ID_WXLUA_STACK_LISTMENU_COPY2, wxT("Copy key type"), wxT("Copy key type to clipboard"), wxITEM_NORMAL); + m_listMenu->Append(ID_WXLUA_STACK_LISTMENU_COPY3, wxT("Copy value type"), wxT("Copy value type to clipboard"), wxITEM_NORMAL); + m_listMenu->Append(ID_WXLUA_STACK_LISTMENU_COPY4, wxT("Copy value"), wxT("Copy value to clipboard"), wxITEM_NORMAL); + // ----------------------------------------------------------------------- ! m_splitterWin->SplitVertically(m_treeCtrl, m_listCtrl, 160); // use sizers to layout the windows in the panel of the dialog *************** *** 235,242 **** rootSizer->Add(topSizer, 0, wxEXPAND|wxBOTTOM, 5); rootSizer->Add(m_splitterWin, 1, wxEXPAND); ! rootSizer->SetMinSize(450, 400); panel->SetSizer(rootSizer); rootSizer->SetSizeHints(this); EnumerateStack(); --- 275,284 ---- rootSizer->Add(topSizer, 0, wxEXPAND|wxBOTTOM, 5); rootSizer->Add(m_splitterWin, 1, wxEXPAND); ! rootSizer->SetMinSize(200, 150); panel->SetSizer(rootSizer); rootSizer->SetSizeHints(this); + SetSize(size); // force last good/known size + EnumerateStack(); *************** *** 246,252 **** --- 288,300 ---- wxLuaStackDialog::~wxLuaStackDialog() { + if (!IsFullScreen() && !IsIconized() && !IsMaximized()) + m_defaultSize = GetSize(); + RemoveAllLuaReferences(); DeleteAllListItemData(); + delete m_listMenu; + delete m_findMenu; + if (m_listCtrl) m_listCtrl->SetImageList(NULL, wxIMAGE_LIST_SMALL); if (m_treeCtrl) m_treeCtrl->SetImageList(NULL); *************** *** 439,445 **** wxCHECK_RET(lc_item_ <= m_listCtrl->GetItemCount(), wxT("Attempting to add list item past end")); ! if (debugData.GetCount() == 0) ! return; ! else { wxTreeItemId treeId; --- 487,491 ---- wxCHECK_RET(lc_item_ <= m_listCtrl->GetItemCount(), wxT("Attempting to add list item past end")); ! if (debugData.GetCount() > 0) { wxTreeItemId treeId; *************** *** 476,479 **** --- 522,527 ---- m_treeCtrl->SetItemHasChildren(treeId); + BeginBatch(); + size_t n, count = debugData.GetCount(); long lc_item = lc_item_; *************** *** 523,533 **** } // NOTE : The MSW treectrl will expand and immediately collapse a node if you call Expand() // from within a handler, don't do anything and it works... #if !defined(WXLUA_STACK_MSWTREE) // Cannot expand hidden root, nor can you check it ! if (treeId && ! ((treeId != m_treeCtrl->GetRootItem()) || ((m_treeCtrl->GetWindowStyle() & wxTR_HIDE_ROOT) == 0)) && ! !m_treeCtrl->IsExpanded(treeId)) m_treeCtrl->Expand(treeId); #endif //!defined(WXLUA_STACK_MSWTREE) --- 571,582 ---- } + EndBatch(); + // NOTE : The MSW treectrl will expand and immediately collapse a node if you call Expand() // from within a handler, don't do anything and it works... #if !defined(WXLUA_STACK_MSWTREE) // Cannot expand hidden root, nor can you check it ! if (treeId && !m_treeCtrl->IsExpanded(treeId) && ! ((treeId != m_treeCtrl->GetRootItem()) || ((m_treeCtrl->GetWindowStyle() & wxTR_HIDE_ROOT) == 0))) m_treeCtrl->Expand(treeId); #endif //!defined(WXLUA_STACK_MSWTREE) *************** *** 560,563 **** --- 609,637 ---- } + + void wxLuaStackDialog::BeginBatch() + { + if (m_batch_count == 0) + { + m_listCtrl->Freeze(); + m_treeCtrl->Freeze(); + } + + m_batch_count++; + } + + void wxLuaStackDialog::EndBatch() + { + if (m_batch_count == 1) + { + m_listCtrl->Thaw(); + m_treeCtrl->Thaw(); + } + + if (m_batch_count > 0) + m_batch_count--; + } + + wxTreeItemId wxLuaStackDialog::FindTreeItemId(const wxTreeItemId& id_, wxLuaStackListData* stkListData) const { *************** *** 601,652 **** } ! void wxLuaStackDialog::OnExpandButton(wxCommandEvent &event) { ! wxBusyCursor wait; long start_item = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); // they must select an item if (start_item < 0) return; - int level = -1; - int level_count = 1; ! while (level_count > 0) ! { ! level_count = 0; ! for (long i = start_item; i < m_listCtrl->GetItemCount(); ++i) ! { ! wxString s(m_listCtrl->GetItemText(i)); ! if (s.Find(wxT("--> _G")) == wxNOT_FOUND) ! { ! int cur_level = (s.BeforeLast(wxT('>')).Length() + 1) / 3; ! if (level < 0) ! { ! // initialze level 1st time through and don't recheck first item ! level = cur_level; ! start_item = i+1; ! } ! else if (cur_level <= level) ! { ! // we've left the start item, all done ! level_count = 0; ! break; ! } ! if (cur_level == level) ! { ! level_count++; ! ExpandItem(i, false); ! } ! } ! else if (i == start_item) // we never expand global _G ! return; ! } ! if (level_count > 0) ! level++; ! } } --- 675,744 ---- } ! void wxLuaStackDialog::DoExpandCollapse(const wxTreeItemId& item, bool expand, wxProgressDialog* dlg, long& counter) { ! if (counter < 0) // allows for immediate exit, see below ! return; ! ! if (dlg && (counter % 20 == 0)) ! { ! wxString msg; ! if (expand) ! msg.Printf(wxT("Expanding nodes : %ld"), counter); ! else ! msg.Printf(wxT("Collapsing nodes : %ld"), counter); ! ! if (!dlg->Pulse(msg)) ! { ! counter = -1; ! return; ! } ! } ! ! if (expand) ! m_treeCtrl->Expand(item); + // then (recursively) expand all the children + wxTreeItemIdValue cookie; + for ( wxTreeItemId idCurr = m_treeCtrl->GetFirstChild(item, cookie); + idCurr.IsOk(); + idCurr = m_treeCtrl->GetNextChild(item, cookie) ) + { + DoExpandCollapse(idCurr, expand, dlg, ++counter); + } + + if (!expand) + m_treeCtrl->Collapse(item); + } + + + void wxLuaStackDialog::OnExpandButton(wxCommandEvent &event) + { long start_item = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); // they must select an item if (start_item < 0) return; ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listCtrl->GetItemData(start_item); ! wxTreeItemId treeId = stkListData->m_treeId; ! bool expand = event.GetId() == ID_WXLUA_STACK_EXPAND_BUTTON; ! wxString caption; ! if (expand) ! caption = wxT("wxLua Stack Expanding node"); ! else ! caption = wxT("wxLua Stack Collapsing node"); ! wxProgressDialog dlg(caption, wxEmptyString, 100, this, ! wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); ! m_show_dup_expand_msg = false; ! BeginBatch(); ! ! long counter = 0; ! DoExpandCollapse(treeId, expand, &dlg, counter); ! ! EndBatch(); ! m_show_dup_expand_msg = true; } *************** *** 669,674 **** --- 761,841 ---- } + void wxLuaStackDialog::OnMenu(wxCommandEvent& event) + { + int id = event.GetId(); + bool checked = event.IsChecked(); + + if (id == ID_WXLUA_STACK_FINDMENU_ALL) + { + m_findMenu->Check(ID_WXLUA_STACK_FINDMENU_NAME, checked); + m_findMenu->Check(ID_WXLUA_STACK_FINDMENU_LEVEL, checked); + m_findMenu->Check(ID_WXLUA_STACK_FINDMENU_KEYTYPE, checked); + m_findMenu->Check(ID_WXLUA_STACK_FINDMENU_VALUETYPE, checked); + m_findMenu->Check(ID_WXLUA_STACK_FINDMENU_VALUE, checked); + } + else if ((id >= ID_WXLUA_STACK_FINDMENU_NAME) && (id <= ID_WXLUA_STACK_FINDMENU_VALUE)) + { + bool are_checked = m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_NAME) && + m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_LEVEL) && + m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_KEYTYPE) && + m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_VALUETYPE) && + m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_VALUE); + + if (m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_ALL) != checked) + m_findMenu->Check(ID_WXLUA_STACK_FINDMENU_ALL, are_checked); + } + else if ((id >= ID_WXLUA_STACK_LISTMENU_COPY0) && (id <= ID_WXLUA_STACK_LISTMENU_COPY4)) + { + long list_item = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + // they must select an item + 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(); + } + } + } + } + void wxLuaStackDialog::OnFind(wxCommandEvent &event) { + if (event.GetId() == ID_WXLUA_STACK_FINDMENU_BUTTON) + { + wxWindow* button = ((wxWindow*)event.GetEventObject()); + wxSize s(button->GetSize()); + button->PopupMenu(m_findMenu, 0, s.GetHeight()); + + return; + } + + // Remaining events we handle are for finding + + bool find_col[5] = { + m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_NAME), + m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_LEVEL), + m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_KEYTYPE), + m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_VALUETYPE), + m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_VALUE), + }; + + // Send warning instead of silently doing nothing + if (!find_col[0] && !find_col[1] && !find_col[2] && !find_col[3] && !find_col[4]) + { + wxMessageBox(wxT("Please select the columns to search with the find options button"), + wxT("wxLua Stack Find Error"), + wxOK|wxICON_EXCLAMATION|wxCENTRE, this); + return; + } + wxString findStr = m_findComboBox->GetValue(); if (findStr.IsEmpty()) *************** *** 678,685 **** wxLuaPrependComboBoxString(findStr, 10, m_findComboBox); ! bool match_case = m_findCaseCheckBox->IsChecked(); if (!match_case) findStr = findStr.Lower(); ! long direction = event.GetId() == ID_WXLUA_STACK_FINDPREV_BUTTON ? -1 : 1; long list_count = m_listCtrl->GetItemCount(); --- 845,852 ---- wxLuaPrependComboBoxString(findStr, 10, m_findComboBox); ! bool match_case = m_findMenu->IsChecked(ID_WXLUA_STACK_FINDMENU_CASE); if (!match_case) findStr = findStr.Lower(); ! long direction = (event.GetId() == ID_WXLUA_STACK_FINDPREV_BUTTON) ? -1 : 1; long list_count = m_listCtrl->GetItemCount(); *************** *** 688,695 **** int wrap_count = 0; // start at current item and wrap back around ! while (wrap_count < 2) { long i = 0; ! bool found = false; if (wrap_count == 0) --- 855,864 ---- int wrap_count = 0; // start at current item and wrap back around ! bool found = false; ! ! while ((wrap_count < 2) && !found) { long i = 0; ! found = false; if (wrap_count == 0) *************** *** 714,732 **** } ! for ( ; (i >= 0) && (i < list_count); i = i + direction) { ! if ((match_case && (m_listCtrl->GetItemText(i).Find(findStr) != wxNOT_FOUND)) || ! (!match_case && (m_listCtrl->GetItemText(i).Lower().Find(findStr) != wxNOT_FOUND))) { ! m_listCtrl->SetItemState(i, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); ! m_listCtrl->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); ! m_listCtrl->EnsureVisible(i); ! found = true; ! break; } } wrap_count++; - if (found) break; } } --- 883,913 ---- } ! for ( ; (i >= 0) && (i < list_count) && !found; i = i + direction) { ! wxListItem li; ! li.SetId(i); ! li.SetMask(wxLIST_MASK_TEXT); ! ! for (int col = 0; (col < 5) && !found; col++) { ! if (!find_col[col]) continue; ! ! li.SetColumn(col); ! m_listCtrl->GetItem(li); ! wxString txt(li.GetText()); ! ! if ((match_case && (txt.Find(findStr) != wxNOT_FOUND)) || ! (!match_case && (txt.Lower().Find(findStr) != wxNOT_FOUND))) ! { ! m_listCtrl->SetItemState(i, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); ! m_listCtrl->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); ! m_listCtrl->EnsureVisible(i); ! found = true; ! break; ! } } } wrap_count++; } } *************** *** 757,769 **** if (list_item < 0) return; // not an item that we can do anything with ! if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_EXPANDED) { ExpandItem(list_item); } ! else if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_COLLAPSED) { CollapseItem(list_item); } ! else if (event.GetEventType() == wxEVT_COMMAND_TREE_SEL_CHANGED) { m_listCtrl->SetItemState(list_item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); --- 938,952 ---- if (list_item < 0) return; // not an item that we can do anything with ! int evt_type = event.GetEventType(); ! ! if (evt_type == wxEVT_COMMAND_TREE_ITEM_EXPANDED) { ExpandItem(list_item); } ! else if (evt_type == wxEVT_COMMAND_TREE_ITEM_COLLAPSED) { CollapseItem(list_item); } ! else if (evt_type == wxEVT_COMMAND_TREE_SEL_CHANGED) { m_listCtrl->SetItemState(list_item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); *************** *** 810,814 **** } ! bool wxLuaStackDialog::ExpandItem(long lc_item, bool show_err_msg) { wxCHECK_MSG((lc_item >= 0) && (lc_item < m_listCtrl->GetItemCount()), false, --- 993,1005 ---- } ! void wxLuaStackDialog::OnListRightClick(wxListEvent &event) // FIXME for easy debugging of mem addresses ! { ! event.Skip(); ! ! if (event.GetIndex() >= 0) ! m_listCtrl->PopupMenu(m_listMenu); ! } ! ! bool wxLuaStackDialog::ExpandItem(long lc_item) { wxCHECK_MSG((lc_item >= 0) && (lc_item < m_listCtrl->GetItemCount()), false, *************** *** 821,825 **** wxCHECK_MSG(stkListData != NULL, false, wxT("Invalid wxLuaStack data")); wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); ! wxCHECK_MSG((debugItem != NULL), false, wxT("Invalid debug item")); int nRef = debugItem->GetReference(); --- 1012,1016 ---- wxCHECK_MSG(stkListData != NULL, false, wxT("Invalid wxLuaStack data")); wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); ! wxCHECK_MSG(debugItem != NULL, false, wxT("Invalid debug item")); int nRef = debugItem->GetReference(); *************** *** 833,836 **** --- 1024,1032 ---- m_listCtrl->SetItemImage(lc_item, IMG_TABLE_OPEN); + wxString val(debugItem->GetValue()); + long vkey = 0; + wxCHECK_MSG(val.BeforeFirst(wxT(' ')).ToLong(&vkey, 16), false, wxT("Invalid table item")); + m_expandedItems[vkey] = (long)stkListData; + FillTableEntry(lc_item, stkListData->m_childrenDebugData); expanded = true; *************** *** 841,847 **** if (debugItem->GetValueType() == WXLUAARG_Table) { ! wxString val = debugItem->GetValue(); ! int n, count = m_listCtrl->GetItemCount(); for (n = 0; n < count; n++) { --- 1037,1063 ---- if (debugItem->GetValueType() == WXLUAARG_Table) { ! wxString val(debugItem->GetValue()); ! long vkey = 0; ! wxCHECK_MSG(val.BeforeFirst(wxT(' ')).ToLong(&vkey, 16), false, wxT("Invalid table item")); ! if (m_expandedItems[vkey]) ! { ! if (m_show_dup_expand_msg) ! { ! wxMessageBox(wxT("Cannot expand linked tables,\nplease see the already expanded table."), ! wxT("wxLua Stack"), wxOK | wxCENTRE, this); ! ! long n = m_listCtrl->FindItem(0, (long)m_expandedItems[vkey]); ! ! m_listCtrl->SetItemState(n, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); ! m_listCtrl->SetItemState(n, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); ! m_listCtrl->EnsureVisible(n); ! } ! ! return false; ! } ! ! /* ! long n, count = m_listCtrl->GetItemCount(); for (n = 0; n < count; n++) { *************** *** 850,861 **** wxLuaDebugItem* debugItem_n = stkListData_n->GetDebugItem(); ! if (debugItem_n && (debugItem_n != debugItem) && (debugItem_n->GetValue() == val) && ! debugItem_n->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) { ! if (show_err_msg) { wxMessageBox(wxT("Cannot expand linked tables,\nplease see the already expanded table."), ! wxT("wxLua Stack"), ! wxOK | wxCENTRE, this); m_listCtrl->SetItemState(n, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); --- 1066,1077 ---- wxLuaDebugItem* debugItem_n = stkListData_n->GetDebugItem(); ! if (debugItem_n && (debugItem_n != debugItem) && ! debugItem_n->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED) && ! (debugItem_n->GetValue() == val)) { ! if (m_show_dup_expand_msg) { wxMessageBox(wxT("Cannot expand linked tables,\nplease see the already expanded table."), ! wxT("wxLua Stack"), wxOK | wxCENTRE, this); m_listCtrl->SetItemState(n, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); *************** *** 867,870 **** --- 1083,1087 ---- } } + */ } *************** *** 907,910 **** --- 1124,1132 ---- m_listCtrl->SetItemImage(lc_item, IMG_TABLE_OPEN); + wxString val(debugItem->GetValue()); + long vkey = 0; + wxCHECK_MSG(val.BeforeFirst(wxT(' ')).ToLong(&vkey, 16), false, wxT("Invalid table item")); + m_expandedItems[vkey] = (long)stkListData; + int nIndex = debugItem->GetIndex() + 1; EnumerateTable(nRef, nIndex, lc_item); *************** *** 930,933 **** --- 1152,1157 ---- wxLuaDebugData childData = stkListData->m_childrenDebugData; + BeginBatch(); + // Collapse the item, remove children if (debugItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) *************** *** 935,939 **** if (childData.Ok()) { ! for (int n = 0; n < m_listCtrl->GetItemCount(); n++) { wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listCtrl->GetItemData(n); --- 1159,1165 ---- if (childData.Ok()) { ! long n, count = m_listCtrl->GetItemCount(); ! ! for (n = lc_item+1; n < count; n++) { wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listCtrl->GetItemData(n); *************** *** 953,957 **** m_listCtrl->DeleteItem(n); ! n = (n > 2) ? (n - 2) : -1; } } --- 1179,1184 ---- m_listCtrl->DeleteItem(n); ! n = (n > 2) ? (n - 2) : -1; // back up and try again ! count = m_listCtrl->GetItemCount(); } } *************** *** 966,971 **** --- 1193,1205 ---- debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, false); m_listCtrl->SetItemImage(lc_item, IMG_TABLE); + + wxString val(debugItem->GetValue()); + long vkey = 0; + wxCHECK_MSG(val.BeforeFirst(wxT(' ')).ToLong(&vkey, 16), false, wxT("Invalid table item")); + m_expandedItems.erase(vkey); } + EndBatch(); + return collapsed; } *************** *** 976,979 **** --- 1210,1218 ---- wxCHECK_RET(stkListData != NULL, wxT("wxLuaStackDialog::OnItemDeleted not handled")); + wxString val(stkListData->GetDebugItem()->GetValue()); + long vkey = 0; + val.BeforeFirst(wxT(' ')).ToLong(&vkey, 16); + m_expandedItems.erase(vkey); + // make sure that we don't forget any items... if (stkListData->m_treeId) *************** *** 986,991 **** void wxLuaStackDialog::OnListAllItemsDeleted(wxListEvent &event) { ! void RemoveAllLuaReferences(); ! void DeleteAllListItemData(); event.Skip(); } --- 1225,1231 ---- void wxLuaStackDialog::OnListAllItemsDeleted(wxListEvent &event) { ! RemoveAllLuaReferences(); ! DeleteAllListItemData(); ! m_expandedItems.clear(); event.Skip(); } *************** *** 993,997 **** void wxLuaStackDialog::DeleteAllListItemData() { ! int i, count = m_listCtrl->GetItemCount(); for (i = 0; i < count; i++) { --- 1233,1239 ---- void wxLuaStackDialog::DeleteAllListItemData() { ! m_expandedItems.clear(); ! ! long i, count = m_listCtrl->GetItemCount(); for (i = 0; i < count; i++) { *************** *** 1008,1018 **** if (!m_wxlState.Ok()) return; // doesn't have to be ok - // try first to remove the refs in the listctrl (sanity check really) - // make sure that we reset their data's ref to LUA_NOREF too. - int i; /* ! // Remove the references using the listctrl data itself for (i = 0; i < m_listCtrl->GetItemCount(); ++i) { --- 1250,1260 ---- if (!m_wxlState.Ok()) return; // doesn't have to be ok int i; /* ! // try first to remove the refs in the listctrl (sanity check really) ! // make sure that we reset their data's ref to LUA_NOREF too. ! ! // Remove the references using the listctrl data itself for (i = 0; i < m_listCtrl->GetItemCount(); ++i) { |
From: John L. <jr...@us...> - 2007-11-29 23:35:57
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv29041/wxLua/modules/wxluadebug/include Modified Files: wxlstack.h Log Message: Made the wxLuaStackDialog much nicer, faster, search in all cols, collapse and expand child tables. Index: wxlstack.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/include/wxlstack.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** wxlstack.h 17 Nov 2007 00:15:07 -0000 1.8 --- wxlstack.h 29 Nov 2007 23:35:53 -0000 1.9 *************** *** 18,21 **** --- 18,22 ---- class WXDLLEXPORT wxListEvent; class WXDLLEXPORT wxSplitterWindow; + class WXDLLEXPORT wxProgressDialog; #include "wxluadebug/include/wxluadebugdefs.h" *************** *** 32,42 **** ID_WXLUA_STACK_CHOICE = 2000, ID_WXLUA_STACK_EXPAND_BUTTON, ID_WXLUA_STACK_FIND_COMBO, ID_WXLUA_STACK_FINDNEXT_BUTTON, ID_WXLUA_STACK_FINDPREV_BUTTON, ! ID_WXLUA_STACK_FINDCASE_CHECKBOX, ID_WXLUA_STACK_SPLITTERWIN, ID_WXLUA_STACK_LISTCTRL, ! ID_WXLUA_STACK_TREECTRL }; --- 33,60 ---- ID_WXLUA_STACK_CHOICE = 2000, ID_WXLUA_STACK_EXPAND_BUTTON, + ID_WXLUA_STACK_COLLAPSE_BUTTON, + ID_WXLUA_STACK_FIND_COMBO, ID_WXLUA_STACK_FINDNEXT_BUTTON, ID_WXLUA_STACK_FINDPREV_BUTTON, ! ID_WXLUA_STACK_FINDMENU_BUTTON, ! ID_WXLUA_STACK_SPLITTERWIN, ID_WXLUA_STACK_LISTCTRL, ! ID_WXLUA_STACK_TREECTRL, ! ! ID_WXLUA_STACK_LISTMENU_COPY0, ! ID_WXLUA_STACK_LISTMENU_COPY1, ! ID_WXLUA_STACK_LISTMENU_COPY2, ! ID_WXLUA_STACK_LISTMENU_COPY3, ! ID_WXLUA_STACK_LISTMENU_COPY4, ! ! ID_WXLUA_STACK_FINDMENU_CASE, ! ID_WXLUA_STACK_FINDMENU_ALL, ! ID_WXLUA_STACK_FINDMENU_NAME, ! ID_WXLUA_STACK_FINDMENU_LEVEL, ! ID_WXLUA_STACK_FINDMENU_KEYTYPE, ! ID_WXLUA_STACK_FINDMENU_VALUETYPE, ! ID_WXLUA_STACK_FINDMENU_VALUE }; *************** *** 64,68 **** // ---------------------------------------------------------------------------- ! // wxLuaStackListData - the data we store in the wxTreeCtrl item's data // ---------------------------------------------------------------------------- --- 82,86 ---- // ---------------------------------------------------------------------------- ! // wxLuaStackTreeData - the data we store in the wxTreeCtrl item's data // ---------------------------------------------------------------------------- *************** *** 82,86 **** { public: ! wxLuaStackDialog() : wxDialog() { Init(); } wxLuaStackDialog(const wxLuaState& wxlState, --- 100,104 ---- { public: ! wxLuaStackDialog() { Init(); } wxLuaStackDialog(const wxLuaState& wxlState, *************** *** 88,92 **** const wxString& title = wxT("wxLua Stack"), const wxPoint& pos = wxDefaultPosition, ! const wxSize& size = wxSize(500, 300)) : wxDialog() { Init(); --- 106,110 ---- const wxString& title = wxT("wxLua Stack"), const wxPoint& pos = wxDefaultPosition, ! const wxSize& size = wxDefaultSize) { Init(); *************** *** 149,156 **** --- 167,181 ---- // implementation + // Put BeginBatch() before adding/removing items and EndBatch() afterwards for speed. + void BeginBatch(); + void EndBatch(); + wxTreeItemId FindTreeItemId(const wxTreeItemId& id, wxLuaStackListData* stkListData) const; long FindListItem(wxLuaStackListData* stkListData, bool get_parent = false) const; + void DoExpandCollapse(const wxTreeItemId& treeId, bool expand, wxProgressDialog* dlg, long& counter); + void OnExpandButton(wxCommandEvent& event); + void OnMenu(wxCommandEvent& event); void OnFind(wxCommandEvent& event); *************** *** 162,168 **** // Handle and expand/collapse a listctrl item void OnListItemActivated(wxListEvent &event); ! bool ExpandItem(long lc_item, bool show_err_msg = true); bool CollapseItem(long lc_item); void OnListItemDeleted(wxListEvent &event); void OnListAllItemsDeleted(wxListEvent &event); --- 187,200 ---- // Handle and expand/collapse a listctrl item void OnListItemActivated(wxListEvent &event); ! // Popup menu on right click ! void OnListRightClick(wxListEvent &event); ! ! // Main functions to expand or collapse a list item ! bool ExpandItem(long lc_item); bool CollapseItem(long lc_item); + // Don't warn about expanding duplicate tables + void SetShowDuplicateExpandMessage(bool show) { m_show_dup_expand_msg = show; } + void OnListItemDeleted(wxListEvent &event); void OnListAllItemsDeleted(wxListEvent &event); *************** *** 175,178 **** --- 207,211 ---- wxListCtrl* m_listCtrl; wxTreeCtrl* m_treeCtrl; + wxMenu* m_listMenu; wxChoice* m_stackChoice; // display stack entries *************** *** 181,185 **** wxComboBox* m_findComboBox; // Find string combobox ! wxCheckBox* m_findCaseCheckBox; // Find case sensitive wxLuaState m_wxlState; // lua_State to show stack for --- 214,218 ---- wxComboBox* m_findComboBox; // Find string combobox ! wxMenu* m_findMenu; wxLuaState m_wxlState; // lua_State to show stack for *************** *** 189,192 **** --- 222,232 ---- wxColour m_typeColours[IMG__COUNT]; + bool m_show_dup_expand_msg; + int m_batch_count; + + wxLongToLongHashMap m_expandedItems; + + static wxSize m_defaultSize; // remember last dialog size + private: void Init(); |
From: John L. <jr...@us...> - 2007-11-29 23:35:57
|
Update of /cvsroot/wxlua/wxLua/docs In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv29041/wxLua/docs Modified Files: changelog.txt Log Message: Made the wxLuaStackDialog much nicer, faster, search in all cols, collapse and expand child tables. Index: changelog.txt =================================================================== RCS file: /cvsroot/wxlua/wxLua/docs/changelog.txt,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** changelog.txt 28 Nov 2007 22:55:00 -0000 1.47 --- changelog.txt 29 Nov 2007 23:35:53 -0000 1.48 *************** *** 17,20 **** --- 17,22 ---- - Made wxLuaCheckStack class work a little nicer for easier debugging in C++. - Use wxSIGKILL to kill debuggee process since wxSIGTERM doesn't work in MSW. + - wxLuaStackDialog has better search for all columns, collapse and expand + tables, and show metatables. version 2.8.4.2 |
From: John L. <jr...@us...> - 2007-11-29 23:35:57
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv29041/wxLua/modules/wxluasocket/include Modified Files: wxldserv.h Log Message: Made the wxLuaStackDialog much nicer, faster, search in all cols, collapse and expand child tables. Index: wxldserv.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/wxldserv.h,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** wxldserv.h 7 Aug 2007 20:23:26 -0000 1.39 --- wxldserv.h 29 Nov 2007 23:35:54 -0000 1.40 *************** *** 85,94 **** // ---------------------------------------------------------------------------- // wxLuaDebuggerStackDialog - a wxLuaStackDialog for the wxLuaDebuggerBase. ! // If you want to show a wxLuaStackDialog for a program being debugged, ! // create this dialog in the debugger process. The overridden EnumerateXXX ! // functions will act as a middle man to get the wxLuaDebugData through the // socket connection to the debuggee using the wxLuaDebuggerBase. ! // Note: The wxLuaState of the wxLuaStackDialog is not used in this case ! // since it 'exists' in the independent debuggee process. // ---------------------------------------------------------------------------- --- 85,96 ---- // ---------------------------------------------------------------------------- // wxLuaDebuggerStackDialog - a wxLuaStackDialog for the wxLuaDebuggerBase. ! // Use the function wxLuaDebuggerBase::DisplayStackDialog() to create ! // and show one of these. ! // ! // Note: The wxLuaStackDialog is created by the debugger process and uses ! // the overridden EnumerateXXX functions to get the wxLuaDebugData through the // socket connection to the debuggee using the wxLuaDebuggerBase. ! // Note: The wxLuaState of the wxLuaStackDialog is not used in this case ! // since it 'exists' in the independent debuggee process. // ---------------------------------------------------------------------------- *************** *** 100,104 **** const wxString& title = wxT("wxLua Stack"), const wxPoint& pos = wxDefaultPosition, ! const wxSize& size = wxSize(500, 300)); virtual ~wxLuaDebuggerStackDialog(); --- 102,106 ---- const wxString& title = wxT("wxLua Stack"), const wxPoint& pos = wxDefaultPosition, ! const wxSize& size = wxDefaultSize); virtual ~wxLuaDebuggerStackDialog(); *************** *** 113,117 **** virtual void EnumerateGlobalData(long lc_item); ! protected: wxLuaDebuggerBase* m_luaDebugger; --- 115,120 ---- virtual void EnumerateGlobalData(long lc_item); ! // implementation ! wxLuaDebuggerBase* m_luaDebugger; *************** *** 121,125 **** // ---------------------------------------------------------------------------- ! // wxLuaDebuggerProcess - handle OnTerminate gracefully // ---------------------------------------------------------------------------- --- 124,129 ---- // ---------------------------------------------------------------------------- ! // wxLuaDebuggerProcess - The wxProcess from wxExecute to run a ! // wxLuaDebugTarget as a debuggee. It handles OnTerminate gracefully. // ---------------------------------------------------------------------------- |
From: John L. <jr...@us...> - 2007-11-28 22:55:33
|
Update of /cvsroot/wxlua/wxLua/docs In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv28670/wxLua/docs Modified Files: changelog.txt Log Message: Use wxSIGKILL to kill debuggee process since wxSIGTERM doesn't work in MSW Made wxLuaCheckStack class work a little nicer for easier debugging in C++ Made wxluaT_insert(L, idx) not pop the value that it refs since it may not be the one at the top of the stack. Use wxLuaDebugData::GetTypeValue in wxLuaDebugTarget and other code cleanup in wxLuaDebugTarget Index: changelog.txt =================================================================== RCS file: /cvsroot/wxlua/wxLua/docs/changelog.txt,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** changelog.txt 17 Nov 2007 00:14:55 -0000 1.46 --- changelog.txt 28 Nov 2007 22:55:00 -0000 1.47 *************** *** 13,16 **** --- 13,20 ---- called just "txxx" and are now called wxluaT_Xxx where the first letter or each word is capitalized (camel-case); again for searching. + - Made wxluaT_insert(L, idx) not pop the value that it refs since + it may not be the one at the top of the stack. + - Made wxLuaCheckStack class work a little nicer for easier debugging in C++. + - Use wxSIGKILL to kill debuggee process since wxSIGTERM doesn't work in MSW. version 2.8.4.2 |
From: John L. <jr...@us...> - 2007-11-28 22:55:07
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv28670/wxLua/modules/wxlua/src Modified Files: wxlstate.cpp Log Message: Use wxSIGKILL to kill debuggee process since wxSIGTERM doesn't work in MSW Made wxLuaCheckStack class work a little nicer for easier debugging in C++ Made wxluaT_insert(L, idx) not pop the value that it refs since it may not be the one at the top of the stack. Use wxLuaDebugData::GetTypeValue in wxLuaDebugTarget and other code cleanup in wxLuaDebugTarget Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.138 retrieving revision 1.139 diff -C2 -d -r1.138 -r1.139 *** wxlstate.cpp 28 Nov 2007 00:20:49 -0000 1.138 --- wxlstate.cpp 28 Nov 2007 22:55:00 -0000 1.139 *************** *** 254,268 **** } - lua_pushvalue(L, stack_idx); // push a copy of value to store to top - wxlua_pushkey_wxLuaReferences(L); // push name of table to get as key lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) ! lua_pushvalue(L, -2); // push value to store int table_idx = luaL_ref(L, -2); // create unique integer reference // in our refs table ! lua_pop(L, 3); // pop value, refs table, value return table_idx; --- 254,266 ---- } wxlua_pushkey_wxLuaReferences(L); // push name of table to get as key lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) ! lua_pushvalue(L, stack_idx > 0 ? stack_idx : stack_idx-1); // push value to store int table_idx = luaL_ref(L, -2); // create unique integer reference // in our refs table ! lua_pop(L, 1); // pop refs table return table_idx; *************** *** 424,429 **** int wxluaT_newtag(lua_State* L) { ! lua_newtable(L); // create a table for our new tag ! lua_pushvalue(L, -1); // push a copy of new table to top of the stack int tag = wxluaT_insert(L, -1); // insert the table into the wxLuaReferences registry table --- 422,426 ---- int wxluaT_newtag(lua_State* L) { ! lua_newtable(L); // create a table for our new tag int tag = wxluaT_insert(L, -1); // insert the table into the wxLuaReferences registry table *************** *** 464,468 **** lua_setmetatable(L, -2); // via the metatable - lua_pushvalue(L, -1); // push a copy of main table to top of stack int tag = wxluaT_insert(L, -1); // insert the table into the wxLuaReferences registry table --- 461,464 ---- |
From: John L. <jr...@us...> - 2007-11-28 22:55:07
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv28670/wxLua/modules/wxluadebug/include Modified Files: wxldebug.h Log Message: Use wxSIGKILL to kill debuggee process since wxSIGTERM doesn't work in MSW Made wxLuaCheckStack class work a little nicer for easier debugging in C++ Made wxluaT_insert(L, idx) not pop the value that it refs since it may not be the one at the top of the stack. Use wxLuaDebugData::GetTypeValue in wxLuaDebugTarget and other code cleanup in wxLuaDebugTarget Index: wxldebug.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/include/wxldebug.h,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** wxldebug.h 28 Nov 2007 00:20:50 -0000 1.42 --- wxldebug.h 28 Nov 2007 22:55:01 -0000 1.43 *************** *** 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're 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 wxluaT_removed it // Get a human readable string for debugging *************** *** 99,103 **** // ---------------------------------------------------------------------------- ! // an invalid wxLuaState for comparison (like wxNullBitmap) extern WXDLLIMPEXP_DATA_WXLUADEBUG(wxLuaDebugData) wxNullLuaDebugData; --- 99,103 ---- // ---------------------------------------------------------------------------- ! // an invalid wxLuaDebugData for comparison (like wxNullBitmap) extern WXDLLIMPEXP_DATA_WXLUADEBUG(wxLuaDebugData) wxNullLuaDebugData; *************** *** 124,137 **** void Add(wxLuaDebugItem* item); // fill this with the stack entries for the wxLuaState // returns the number of stack entries added int EnumerateStack(const wxLuaState& wxlState); ! // fill this with the locals from a particular stack entry, if an item is a // table then add a reference to it in the references array ! int EnumerateStackEntry(const wxLuaState& wxlState, int stackRef, wxArrayInt& references); // fill this with the name and value of items in a table at the given reference, // if the table has a sub table then add a reference to it to the references array int EnumerateTable(const wxLuaState& wxlState, int nRef, int nEntry, wxArrayInt& references); // These functions are static to allow them to be used in other places to // give a consistent feel to the display of Lua values. --- 124,140 ---- void Add(wxLuaDebugItem* item); + //------------------------------------------------------------------------- + // fill this with the stack entries for the wxLuaState // returns the number of stack entries added int EnumerateStack(const wxLuaState& wxlState); ! // fill this with the locals from a particular stack frame, if an item on the stack is a // table then add a reference to it in the references array ! int EnumerateStackEntry(const wxLuaState& wxlState, int stack_frame, wxArrayInt& references); // fill this with the name and value of items in a table at the given reference, // if the table has a sub table then add a reference to it to the references array int EnumerateTable(const wxLuaState& wxlState, int nRef, int nEntry, wxArrayInt& references); + //------------------------------------------------------------------------- // These functions are static to allow them to be used in other places to // give a consistent feel to the display of Lua values. *************** *** 155,158 **** --- 158,164 ---- wxLuaDebugData Copy() const; + // Ref this table if it hasn't been refed already, returns ref # or LUA_NOREF if not refed + int RefTable(lua_State* L, int stack_idx, int* flag_type, wxArrayInt& references); + // Sorting function for the wxLuaDebugItemArray, sorts by name static int SortFunction(wxLuaDebugItem *elem1, wxLuaDebugItem *elem2 ); *************** *** 173,177 **** // ---------------------------------------------------------------------------- ! // wxLuaCheckStack - dumps the contents of the lua_State // ---------------------------------------------------------------------------- --- 179,183 ---- // ---------------------------------------------------------------------------- ! // wxLuaCheckStack - Dump the contents of the lua_State for debugging // ---------------------------------------------------------------------------- *************** *** 179,198 **** { public: ! wxLuaCheckStack(lua_State* L, const wxString &msg); ~wxLuaCheckStack(); ! void TestStack(const wxString &msg); ! void DumpGlobals(); ! void DumpTable(const wxString &tableName); ! void DumpTable(int index, const wxString& tablename, wxSortedArrayString& tableArray, int indent); ! void DumpStack(); void OutputMsg(const wxString& msg) const; ! private: lua_State* m_luaState; wxString m_msg; int m_top; }; --- 185,224 ---- { public: ! // Create a instance, remembers lua_gettop(), 'msg' can be used to add ! // information about where or why this was created. ! // If 'print_to_console' then all functions below that return a string will also ! // print to the console as well. ! wxLuaCheckStack(lua_State* L, const wxString &msg = wxEmptyString, bool print_to_console = true); ! // Prints out the starting top and ending top if 'print_to_console' in constructor ~wxLuaCheckStack(); ! // Returns a string comparing the starting and current lua_gettop() with additional msg ! wxString TestStack(const wxString &msg = wxEmptyString); ! // Returns a string of the current items on the stack with their types. ! wxString DumpStack(const wxString& msg = wxEmptyString); ! ! // Returns a string of all of the global variables and subtables with additional msg. ! wxString DumpGlobals(const wxString& msg = wxEmptyString); ! // Dump the table and it's subtables from the globals index with additional msg. ! // The name may be of the form "table1.subtable2.subtable3..." ! wxString DumpTable(const wxString& tableName, const wxString& msg = wxEmptyString); ! // Dump the table and it's subtables at the stack_idx with additional msg. ! wxString DumpTable(int stack_idx, const wxString& msg = wxEmptyString); ! ! // Dump the contents of the table at the stack_idx to a string. 'tablename' and 'msg' are ! // for informational messages, 'tableArray' is used to avoid recursion and should be empty ! // for the initial call, and 'indent' is used to track indentation level for each subtable. ! wxString DumpTable(int stack_idx, const wxString& tablename, const wxString& msg, wxSortedArrayString& tableArray, int indent); + // Print a message to the console if 'print_to_console' in constructor. void OutputMsg(const wxString& msg) const; ! // implementation ! lua_State* m_luaState; wxString m_msg; int m_top; + bool m_print_to_console; }; |
From: John L. <jr...@us...> - 2007-11-28 22:55:06
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv28670/wxLua/modules/wxluasocket/src Modified Files: wxldserv.cpp wxldtarg.cpp Log Message: Use wxSIGKILL to kill debuggee process since wxSIGTERM doesn't work in MSW Made wxLuaCheckStack class work a little nicer for easier debugging in C++ Made wxluaT_insert(L, idx) not pop the value that it refs since it may not be the one at the top of the stack. Use wxLuaDebugData::GetTypeValue in wxLuaDebugTarget and other code cleanup in wxLuaDebugTarget Index: wxldtarg.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxldtarg.cpp,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** wxldtarg.cpp 17 Nov 2007 00:15:11 -0000 1.40 --- wxldtarg.cpp 28 Nov 2007 22:55:02 -0000 1.41 *************** *** 328,335 **** break; } ! case wxLUASOCKET_DEBUGGER_CMD_DISABLE_BREAKPOINT: ret = true; break; ! case wxLUASOCKET_DEBUGGER_CMD_ENABLE_BREAKPOINT: ret = true; break; --- 328,335 ---- break; } ! case wxLUASOCKET_DEBUGGER_CMD_DISABLE_BREAKPOINT: // FIXME do something here ret = true; break; ! case wxLUASOCKET_DEBUGGER_CMD_ENABLE_BREAKPOINT: // FIXME do something here ret = true; break; *************** *** 343,347 **** wxString wxLuaDebugTarget::CreateBreakPoint(const wxString &fileName, int lineNumber) const { ! return wxString::Format(wxT("%u:"), lineNumber) + fileName; } --- 343,353 ---- wxString wxLuaDebugTarget::CreateBreakPoint(const wxString &fileName, int lineNumber) const { ! return wxString::Format(wxT("%d:"), lineNumber) + fileName; ! } ! ! bool wxLuaDebugTarget::AtBreakPoint(const wxString &fileName, int lineNumber) const ! { ! wxCriticalSectionLocker locker(m_breakPointListCriticalSection); ! return (m_breakPointList.Index(CreateBreakPoint(fileName, lineNumber)) != wxNOT_FOUND); } *************** *** 477,481 **** } ! bool wxLuaDebugTarget::EvaluateExpr(int exprRef, const wxString &strExpr) { wxString strResult(wxT("Error")); --- 483,487 ---- } ! bool wxLuaDebugTarget::EvaluateExpr(int exprRef, const wxString &strExpr) // FIXME - check this code { wxString strResult(wxT("Error")); *************** *** 504,508 **** nReference = m_wxlState.wxluaT_Insert(-1); ! lua_settop(L, nOldTop); } else --- 510,514 ---- nReference = m_wxlState.wxluaT_Insert(-1); ! lua_settop(L, nOldTop); // throw out all return values } else *************** *** 524,529 **** break; } ! else ! lua_pop(L, 1); } --- 530,535 ---- break; } ! ! lua_pop(L, 1); } *************** *** 546,559 **** if (strExpr == name) { ! nReference = m_wxlState.wxluaT_Insert(-1); // reference value and pop it. ! lua_pop(L, 1); // pop index fFound = true; break; } - else - lua_pop(L, 1); // removes `value'; } ! else ! lua_pop(L, 1); // removes `value'; } lua_settop(L, nOldTop); // the table of globals. --- 552,563 ---- if (strExpr == name) { ! nReference = m_wxlState.wxluaT_Insert(-1); // reference value ! lua_pop(L, 2); // pop key and value fFound = true; break; } } ! ! lua_pop(L, 1); // removes `value'; } lua_settop(L, nOldTop); // the table of globals. *************** *** 564,611 **** { m_wxlState.wxluaT_Remove(nReference); - switch (lua_type(L, -1)) - { - case LUA_TNIL: - strResult = wxT("Nil"); - break; - - case LUA_TBOOLEAN: - strResult = wxLuaDebugData::MakeBoolean(lua_toboolean(L, -1)); - break; ! case LUA_TNUMBER: ! strResult = wxLuaDebugData::MakeNumber(lua_tonumber(L, -1)); ! break; ! ! case LUA_TSTRING: ! strResult = wxString::Format(wxT("\"%s\""), lua2wx(lua_tostring(L, -1)).c_str()); ! break; ! ! case LUA_TTABLE: ! strResult = wxT("table ") + wxLuaDebugData::GetTableInfo(m_wxlState, -1); ! break; ! ! case LUA_TFUNCTION: ! if (lua_iscfunction(L, -1)) ! strResult = wxString::Format(wxT("C-function %p"), lua_tocfunction(L, -1)); ! else ! strResult = wxString::Format(wxT("lua function %p"), lua_topointer(L, -1)); ! break; ! ! case LUA_TUSERDATA: ! strResult = wxT("user data ") + wxLuaDebugData::GetUserDataInfo(m_wxlState, -1); ! break; ! ! case LUA_TLIGHTUSERDATA: ! strResult = wxT("light user data ") + wxLuaDebugData::GetUserDataInfo(m_wxlState, -1, false); ! break; ! ! case LUA_TTHREAD: ! strResult = wxString::Format(wxT("thread %p"), lua_topointer(L, -1)); ! break; ! default: ! break; ! } lua_pop(L, 1); --- 568,577 ---- { m_wxlState.wxluaT_Remove(nReference); ! int wxl_type = 0; ! wxString value; ! int l_type = wxLuaDebugData::GetTypeValue(m_wxlState, -1, &wxl_type, value); ! strResult = wxlua_getwxluatypename(wxl_type) + wxT(" : ") + value; lua_pop(L, 1); *************** *** 641,645 **** } else ! wxMessageBox(errorMsg, wxT("wxLua client error"), wxOK | wxCENTRE, NULL); m_fErrorsSeen = true; --- 607,611 ---- } else ! wxMessageBox(errorMsg, wxT("wxLua debug client error"), wxOK | wxCENTRE, NULL); m_fErrorsSeen = true; *************** *** 689,701 **** } - wxString wxLuaDebugTarget::GetDebugInfo(int &lineNumber) const - { - lua_Debug luaDebug = INIT_LUA_DEBUG; - lua_getstack(m_wxlState.GetLuaState(), 0, &luaDebug); - lua_getinfo(m_wxlState.GetLuaState(), "Sln", &luaDebug); - lineNumber = luaDebug.currentline - 1; - return lua2wx(luaDebug.source); - } - bool wxLuaDebugTarget::DebugHook(int event) { --- 655,658 ---- *************** *** 703,706 **** --- 660,675 ---- m_fStopped = true; + int lineNumber = 0; + wxString fileName; + + if (!(m_forceBreak && m_resetRequested)) + { + lua_Debug luaDebug = INIT_LUA_DEBUG; + lua_getstack(m_wxlState.GetLuaState(), 0, &luaDebug); + lua_getinfo(m_wxlState.GetLuaState(), "Sln", &luaDebug); + lineNumber = luaDebug.currentline - 1; + fileName = lua2wx(luaDebug.source); + } + if (m_forceBreak) { *************** *** 714,720 **** if (!m_fExiting) { - int lineNumber = 0; - wxString fileName = GetDebugInfo(lineNumber); - if (NotifyBreak(fileName, lineNumber)) fWait = true; --- 683,686 ---- *************** *** 725,736 **** if (event == LUA_HOOKCALL) // call m_nFramesUntilBreak++; ! else ! if ((event == LUA_HOOKRET) || (event == LUA_HOOKTAILRET)) // return { if (m_nFramesUntilBreak > 0) m_nFramesUntilBreak--; } ! else ! if (event == LUA_HOOKLINE) // line { switch (m_nextOperation) --- 691,700 ---- if (event == LUA_HOOKCALL) // call m_nFramesUntilBreak++; ! else if ((event == LUA_HOOKRET) || (event == LUA_HOOKTAILRET)) // return { if (m_nFramesUntilBreak > 0) m_nFramesUntilBreak--; } ! else if (event == LUA_HOOKLINE) // line { switch (m_nextOperation) *************** *** 738,744 **** case DEBUG_STEP: { - int lineNumber = 0; - wxString fileName = GetDebugInfo(lineNumber); - if (NotifyBreak(fileName, lineNumber)) fWait = true; --- 702,705 ---- *************** *** 748,759 **** case DEBUG_STEPOVER: { ! if (m_nFramesUntilBreak == 0) ! { ! int lineNumber = 0; ! wxString fileName = GetDebugInfo(lineNumber); - if (NotifyBreak(fileName, lineNumber)) - fWait = true; - } break; } --- 709,715 ---- case DEBUG_STEPOVER: { ! if ((m_nFramesUntilBreak == 0) && NotifyBreak(fileName, lineNumber)) ! fWait = true; break; } *************** *** 761,769 **** default: { ! int lineNumber = 0; ! wxString fileName = GetDebugInfo(lineNumber); ! ! if (AtBreakPoint(fileName, lineNumber) && ! NotifyBreak(fileName, lineNumber)) fWait = true; --- 717,721 ---- default: { ! if (AtBreakPoint(fileName, lineNumber) && NotifyBreak(fileName, lineNumber)) fWait = true; *************** *** 784,792 **** EnterLuaCriticalSection(); } m_fStopped = false; return fWait; } ! void LUACALL wxLuaDebugTarget::LuaDebugHook(lua_State *L, lua_Debug *pLuaDebug) { wxLuaDebugTarget *pTarget = NULL; --- 736,747 ---- EnterLuaCriticalSection(); } + m_fStopped = false; return fWait; } ! // -------------------------------------------------------------------------- ! ! wxLuaDebugTarget* wxLuaDebugTarget::GetDebugTarget(lua_State* L) { wxLuaDebugTarget *pTarget = NULL; *************** *** 801,812 **** lua_pop(L, 1); ! if (pTarget != NULL) ! pTarget->DebugHook(pLuaDebug->event); } ! bool wxLuaDebugTarget::AtBreakPoint(const wxString &fileName, int lineNumber) const { ! wxCriticalSectionLocker locker(m_breakPointListCriticalSection); ! return (m_breakPointList.Index(CreateBreakPoint(fileName, lineNumber)) != wxNOT_FOUND); } --- 756,768 ---- lua_pop(L, 1); ! return pTarget; } ! void LUACALL wxLuaDebugTarget::LuaDebugHook(lua_State *L, lua_Debug *pLuaDebug) { ! wxLuaDebugTarget *pTarget = GetDebugTarget(L); ! ! if (pTarget != NULL) ! pTarget->DebugHook(pLuaDebug->event); } *************** *** 831,844 **** } ! wxLuaDebugTarget *pTarget = NULL; ! ! // try to get the state we've stored ! lua_pushstring( L, "__wxLuaDebugTarget__" ); ! lua_rawget( L, LUA_REGISTRYINDEX ); ! // if nothing was returned or it wasn't a ptr, abort ! if ( lua_islightuserdata(L, -1) ) ! pTarget = (wxLuaDebugTarget*)lua_touserdata( L, -1 ); ! ! lua_pop(L, 1); if (pTarget != NULL) --- 787,791 ---- } ! wxLuaDebugTarget *pTarget = GetDebugTarget(L); if (pTarget != NULL) Index: wxldserv.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxldserv.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** wxldserv.cpp 26 Jul 2007 18:56:40 -0000 1.46 --- wxldserv.cpp 28 Nov 2007 22:55:02 -0000 1.47 *************** *** 195,198 **** --- 195,200 ---- wxLuaDebuggerBase::~wxLuaDebuggerBase() { + //wxPrintf(wxT("~wxLuaDebuggerBase the m_debuggeeProcess %p %d exists %d\n"), m_debuggeeProcess, m_debuggeeProcessID, wxProcess::Exists(m_debuggeeProcessID)); fflush(stdout); + // we don't delete the the process, we kill it and it's OnTerminate deletes it if ((m_debuggeeProcess != NULL) && (m_debuggeeProcessID > 0) && *************** *** 202,207 **** m_debuggeeProcess = NULL; wxProcess::Kill(m_debuggeeProcessID, wxSIGKILL, wxKILL_CHILDREN); - - //wxPrintf(wxT("Deleting the m_debuggeeProcess %d\n"), m_debuggeeProcessID); } } --- 204,207 ---- *************** *** 605,608 **** --- 605,610 ---- void wxLuaDebuggerBase::OnEndDebugeeProcess(wxProcessEvent& event) { + //wxPrintf(wxT("OnEndDebugeeProcess the m_debuggeeProcess %p %d exists %d\n"), m_debuggeeProcess, m_debuggeeProcessID, wxProcess::Exists(m_debuggeeProcessID)); fflush(stdout); + // The process's OnTerminate will null m_debuggeeProcess, // but if in destructor it's already NULL and don't send event. *************** *** 619,622 **** --- 621,626 ---- bool wxLuaDebuggerBase::KillDebuggee() { + //wxPrintf(wxT("KillDebuggee the m_debuggeeProcess %p %d exists %d\n"), m_debuggeeProcess, m_debuggeeProcessID, wxProcess::Exists(m_debuggeeProcessID)); fflush(stdout); + if ((m_debuggeeProcess != NULL) && (m_debuggeeProcessID > 0)) { *************** *** 625,629 **** //if (p->Exists(m_debuggeeProcessID)) should exist since OnTerminate hasn't been called ! wxProcess::Kill(m_debuggeeProcessID, wxSIGTERM, wxKILL_CHILDREN); } else if (m_debuggeeProcess != NULL) // error starting process? --- 629,633 ---- //if (p->Exists(m_debuggeeProcessID)) should exist since OnTerminate hasn't been called ! wxProcess::Kill(m_debuggeeProcessID, wxSIGKILL, wxKILL_CHILDREN); } else if (m_debuggeeProcess != NULL) // error starting process? |