From: John L. <jr...@us...> - 2007-06-16 06:21:50
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv19284/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: Add back the wxTreeCtrl into the stack dialog, on left of listctrl so you get both for easier navigation. Added functions to the wxlua.XXX table to get info about the status of wxLua Use qsort and bsearch to find the class methods ~ %25 faster Make wxLuaDebugData not always create it's ref data so it can !Ok() Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** wxlstack.cpp 14 Jun 2007 23:59:48 -0000 1.5 --- wxlstack.cpp 16 Jun 2007 06:21:47 -0000 1.6 *************** *** 20,23 **** --- 20,26 ---- #include "wx/imaglist.h" #include "wx/artprov.h" + #include "wx/listctrl.h" + #include "wx/splitter.h" + #include "wxluadebug/include/wxlstack.h" #include "wxlua/include/wxlua.h" *************** *** 43,49 **** [...1088 lines suppressed...] + debugItem->SetReference(LUA_NOREF); + + int idx = m_luaReferences.Index(lua_ref); + if (idx != wxNOT_FOUND) + m_luaReferences.RemoveAt(idx); + else + wxPrintf(wxT("Missing lua reference in listctrl #%d ok %d ref %d count %d idx %d\n"), i, ok, debugItem->GetReference(), m_luaReferences.GetCount(), idx); + } + } + */ + + for (i = 0; i < (int)m_luaReferences.GetCount(); ++i) + { + bool ok = m_wxlState.tremove(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()); + } + + m_luaReferences.Clear(); + } Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** wxldebug.cpp 14 Jun 2007 23:59:48 -0000 1.34 --- wxldebug.cpp 16 Jun 2007 06:21:47 -0000 1.35 *************** *** 20,23 **** --- 20,25 ---- #include "wxluadebug/include/wxldebug.h" + wxLuaDebugData wxNullLuaDebugData(false); + #define lua_Debug_to_String(ld) \ wxString::Format(wxT("%p event=%d name='%s' namewhat='%s' what='%s' source='%s' currentline=%d nups=%d linedefined=%d lastlinedefined=%d short_src='%s' i_ci=%d"), \ *************** *** 73,79 **** #define M_DEBUGREFDATA ((wxLuaDebugDataRefData*)m_refData) ! wxLuaDebugData::wxLuaDebugData() : wxObject() { ! m_refData = new wxLuaDebugDataRefData; // Sanity check to make sure that lua hasn't changed the items on us --- 75,82 ---- #define M_DEBUGREFDATA ((wxLuaDebugDataRefData*)m_refData) ! wxLuaDebugData::wxLuaDebugData(bool create) : wxObject() { ! if (create) ! m_refData = new wxLuaDebugDataRefData; // Sanity check to make sure that lua hasn't changed the items on us *************** *** 121,126 **** wxLuaDebugData wxLuaDebugData::Copy() const { ! wxLuaDebugData copyData; ! wxCHECK_MSG(M_DEBUGREFDATA != NULL, copyData, wxT("Invalid ref data")); size_t idx, count = GetCount(); --- 124,130 ---- wxLuaDebugData wxLuaDebugData::Copy() const { ! wxCHECK_MSG(M_DEBUGREFDATA != NULL, wxNullLuaDebugData, wxT("Invalid ref data")); ! ! wxLuaDebugData copyData(true); size_t idx, count = GetCount(); *************** *** 219,225 **** if (lua_istable(L, -1)) { ! lua_pushvalue(L, -1); ! nRef = wxlState.tinsert(-1); ! references.Add(nRef); } else --- 223,235 ---- if (lua_istable(L, -1)) { ! nRef = wxlua_tisrefed(L, -1); // don't duplicate refs ! ! if (nRef == LUA_NOREF) ! { ! flag_type |= WXLUA_DEBUGITEM_LUAREFED; ! lua_pushvalue(L, -1); ! nRef = wxlState.tinsert(-1); ! references.Add(nRef); ! } } else *************** *** 254,259 **** wxlState.GetGlobals(); GetTypeValue(wxlState, -1, type, value, &flag_type); ! int nRef = wxlState.tinsert(-1); ! Add(new wxLuaDebugItem(wxT("Globals"), wxT("Table"), value, wxT(""), nRef, 0, WXLUA_DEBUGITEM_TTABLE)); references.Add(nRef); } --- 264,269 ---- wxlState.GetGlobals(); GetTypeValue(wxlState, -1, type, value, &flag_type); ! int nRef = wxlua_tinsert(L, -1); ! Add(new wxLuaDebugItem(wxT("Globals"), wxT("Table"), value, wxT(""), nRef, 0, WXLUA_DEBUGITEM_TTABLE|WXLUA_DEBUGITEM_LUAREFED)); references.Add(nRef); } *************** *** 262,292 **** wxlState.lua_PushValue(LUA_REGISTRYINDEX); GetTypeValue(wxlState, -1, type, value, &flag_type); ! int nRef = wxlState.tinsert(-1); ! Add(new wxLuaDebugItem(wxT("Lua Registry"), wxT("Table"), value, wxT(""), nRef, 0, WXLUA_DEBUGITEM_TTABLE)); references.Add(nRef); } else { if (wxlState.tget(tableRef)) { - // ------------------------------ - // if we're actually looking at the wxLuaReferences table we'd just - // keep adding new refs, so count what we've got now and show only them. - // This is only for debugging or curiosity. - int is_reftable = -1; - wxlua_pushkey_wxLuaReferences(L); - wxlState.lua_RawGet(LUA_REGISTRYINDEX); - - if (wxlState.lua_Equal(-1, -2)) - is_reftable = lua_objlen(L, -1); - - wxlState.lua_Pop(1); - // ------------------------------ - int nTop = lua_gettop(L); // start iterating lua_pushnil(L); ! while ((lua_next(L, nTop) != 0) && ((is_reftable < 0) || (count < is_reftable))) { // get the index, just want the name=value, type is dummy here --- 272,289 ---- wxlState.lua_PushValue(LUA_REGISTRYINDEX); GetTypeValue(wxlState, -1, type, value, &flag_type); ! int nRef = wxlua_tinsert(L, -1); ! Add(new wxLuaDebugItem(wxT("Lua Registry"), wxT("Table"), value, wxT(""), nRef, 0, WXLUA_DEBUGITEM_TTABLE|WXLUA_DEBUGITEM_LUAREFED)); references.Add(nRef); } else { + // push the table onto the stack to iterate through if (wxlState.tget(tableRef)) { int nTop = lua_gettop(L); // start iterating lua_pushnil(L); ! while (lua_next(L, nTop) != 0) { // get the index, just want the name=value, type is dummy here *************** *** 300,305 **** if (lua_istable(L, -1)) { ! nRef = wxlState.tinsert(-1); ! references.Add(nRef); } else --- 297,310 ---- if (lua_istable(L, -1)) { ! nRef = wxlua_tisrefed(L, -1); // don't duplicate refs ! ! if (nRef == LUA_NOREF) ! { ! flag_type |= WXLUA_DEBUGITEM_LUAREFED; ! nRef = wxlua_tinsert(L, -1); // pops value ! references.Add(nRef); ! } ! else ! lua_pop(L, 1); } else *************** *** 321,348 **** wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); - // try to use the wxString ref counting to reduce memory - static wxString s_typeStrings[WXLUA_DEBUGITEM_T_COUNT] = { - wxT("Unknown data type"), - wxT("None"), - wxT("Nil"), - wxT("Boolean"), - wxT("Light User Data"), - wxT("Number"), - wxT("String"), - wxT("Table"), - wxT("Lua Function"), - wxT("User Data"), - wxT("Thread"), - wxT("C Function") - }; - lua_State* L = wxlState.GetLuaState(); int l_type = lua_type(L, index); int flag_type = WXLUA_DEBUGITEM_TUNKNOWN; switch (l_type) { case LUA_TNONE: - type = s_typeStrings[WXLUA_DEBUGITEM_TNONE]; value = wxEmptyString; flag_type = WXLUA_DEBUGITEM_TNONE; --- 326,338 ---- wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); lua_State* L = wxlState.GetLuaState(); int l_type = lua_type(L, index); int flag_type = WXLUA_DEBUGITEM_TUNKNOWN; + type = wxlua_getwxluatypename(wxlua_getwxluatype(l_type)); + switch (l_type) { case LUA_TNONE: value = wxEmptyString; flag_type = WXLUA_DEBUGITEM_TNONE; *************** *** 350,354 **** case LUA_TNIL: - type = s_typeStrings[WXLUA_DEBUGITEM_TNIL]; value = wxT("nil"); flag_type = WXLUA_DEBUGITEM_TNIL; --- 340,343 ---- *************** *** 356,360 **** case LUA_TBOOLEAN: - type = s_typeStrings[WXLUA_DEBUGITEM_TBOOLEAN]; value = MakeBoolean(lua_toboolean(L, index)); flag_type = WXLUA_DEBUGITEM_TBOOLEAN; --- 345,348 ---- *************** *** 362,366 **** case LUA_TLIGHTUSERDATA: - type = s_typeStrings[WXLUA_DEBUGITEM_TLIGHTUSERDATA]; value = GetUserDataInfo(wxlState, index, false); flag_type = WXLUA_DEBUGITEM_TLIGHTUSERDATA; --- 350,353 ---- *************** *** 368,372 **** case LUA_TNUMBER: - type = s_typeStrings[WXLUA_DEBUGITEM_TNUMBER]; value = MakeNumber(lua_tonumber(L, index)); flag_type = WXLUA_DEBUGITEM_TNUMBER; --- 355,358 ---- *************** *** 374,378 **** case LUA_TSTRING: - type = s_typeStrings[WXLUA_DEBUGITEM_TSTRING]; value = lua2wx(lua_tostring(L, index)); flag_type = WXLUA_DEBUGITEM_TSTRING; --- 360,363 ---- *************** *** 380,384 **** case LUA_TTABLE: - type = s_typeStrings[WXLUA_DEBUGITEM_TTABLE]; value = GetTableInfo(wxlState, index); flag_type = WXLUA_DEBUGITEM_TTABLE; --- 365,368 ---- *************** *** 388,392 **** if (lua_iscfunction(L, index)) { ! type = s_typeStrings[WXLUA_DEBUGITEM_TCFUNCTION]; value.Printf(wxT("%p"), lua_tocfunction(L, index)); flag_type = WXLUA_DEBUGITEM_TCFUNCTION; --- 372,376 ---- if (lua_iscfunction(L, index)) { ! type = wxT("cfunction"); value.Printf(wxT("%p"), lua_tocfunction(L, index)); flag_type = WXLUA_DEBUGITEM_TCFUNCTION; *************** *** 394,398 **** else { - type = s_typeStrings[WXLUA_DEBUGITEM_TFUNCTION]; value.Printf(wxT("%p"), lua_topointer(L, index)); flag_type = WXLUA_DEBUGITEM_TFUNCTION; --- 378,381 ---- *************** *** 401,405 **** case LUA_TUSERDATA: - type = s_typeStrings[WXLUA_DEBUGITEM_TUSERDATA]; value = GetUserDataInfo(wxlState, index, true); flag_type = WXLUA_DEBUGITEM_TUSERDATA; --- 384,387 ---- *************** *** 407,411 **** case LUA_TTHREAD: - type = s_typeStrings[WXLUA_DEBUGITEM_TTHREAD]; value.Printf(wxT("%p"), lua_topointer(L, index)); flag_type = WXLUA_DEBUGITEM_TTHREAD; --- 389,392 ---- *************** *** 413,417 **** default : ! type = s_typeStrings[WXLUA_DEBUGITEM_TUNKNOWN]; value = wxEmptyString; flag_type = WXLUA_DEBUGITEM_TUNKNOWN; --- 394,398 ---- default : ! type = wxT("Unknown Data Type?"); value = wxEmptyString; flag_type = WXLUA_DEBUGITEM_TUNKNOWN; |