From: John L. <jr...@us...> - 2007-12-07 02:13:20
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv12976/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: Too many changes to list... A large portion of the internal workings of the wxLuaState have been rewritten. All of the data that was stored in wxLuaStateData that might be needed by a function taking a lua_State* is now in the LUA_REGISTRYINDEX. C functions have been added to access these values. The generated bindings no longer need to have "wxLuaState wxlState(L);" since everything can be done with the C functions. The result is that wxLua should be faster. Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** wxlstack.cpp 5 Dec 2007 00:34:46 -0000 1.24 --- wxlstack.cpp 7 Dec 2007 02:13:14 -0000 1.25 *************** *** 42,48 **** #define DUMMY_TREEITEM wxT(" ") - #define WXLUAARG_WXLUADATA (WXLUAARG__MIN - 100) - - // ---------------------------------------------------------------------------- // wxLuaStackListCtrl --- 42,45 ---- *************** *** 428,433 **** case WXLUAARG_Integer : img = IMG_INTEGER; break; case WXLUAARG_CFunction : img = IMG_CFUNCTION; break; - - case WXLUAARG_WXLUADATA : img = IMG_TABLE; break; } } --- 425,428 ---- *************** *** 576,582 **** } } - - if (m_wxlState.Ok()) - GetDerivedAndTrackedItems(); } --- 571,574 ---- *************** *** 671,699 **** } - void wxLuaStackDialog::GetDerivedAndTrackedItems() - { - wxLuaState wxlState(m_wxlState); - wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); - - int trackedCount = wxlState.GetTrackedObjectStrings().GetCount(); - int callbackCount = wxlState.GetTrackedCallbackStrings().GetCount(); - int windowCount = wxlState.GetTrackedWindowStrings().GetCount(); - int destroyCount = wxlState.GetTrackedWinDestroyCallbackStrings().GetCount(); - - // note: don't have spaces here since we use them to mark expanded levels - wxLuaDebugItem* trackedItem = new wxLuaDebugItem(_("Tracked User Data"), WXLUAARG_None, wxString::Format(wxT("Count %d"), trackedCount), WXLUAARG_WXLUADATA, wxT(""), LUA_NOREF, 0); - wxLuaDebugItem* callbackItem = new wxLuaDebugItem(_("wxEvent Callbacks"), WXLUAARG_None, wxString::Format(wxT("Count %d"), callbackCount), WXLUAARG_WXLUADATA, wxT(""), LUA_NOREF, 0); - wxLuaDebugItem* windowItem = new wxLuaDebugItem(_("Top Level wxWindows"), WXLUAARG_None, wxString::Format(wxT("Count %d"), windowCount), WXLUAARG_WXLUADATA, wxT(""), LUA_NOREF, 0); - wxLuaDebugItem* destroyItem = new wxLuaDebugItem(_("wxWindow Destroy List"), WXLUAARG_None, wxString::Format(wxT("Count %d"), destroyCount), WXLUAARG_WXLUADATA, wxT(""), LUA_NOREF, 0); - - wxLuaDebugData dataArr(true); // this deletes the items - dataArr.Add(trackedItem); - dataArr.Add(callbackItem); - dataArr.Add(windowItem); - dataArr.Add(destroyItem); - - FillTableEntry(m_listData.GetCount(), dataArr); - } - void wxLuaStackDialog::BeginBatch() { --- 663,666 ---- *************** *** 1068,1104 **** } ! // Check our special variables for the wxLuaState data ! if (m_wxlState.Ok() && (debugItem->GetValueType() == WXLUAARG_WXLUADATA)) ! { ! wxLuaState wxlState(m_wxlState); ! wxArrayString strArr; ! ! if (debugItem->GetKey() == _("Tracked User Data")) ! strArr = wxlState.GetTrackedObjectStrings(); ! else if (debugItem->GetKey() == _("wxEvent Callbacks")) ! strArr = wxlState.GetTrackedCallbackStrings(); ! else if (debugItem->GetKey() == _("Top Level wxWindows")) ! strArr = wxlState.GetTrackedWindowStrings(); ! else if (debugItem->GetKey() == _("wxWindow Destroy List")) ! strArr = wxlState.GetTrackedWinDestroyCallbackStrings(); ! else ! wxFAIL_MSG(wxT("Unknown key name with WXLUAARG_WXLUADATA")); ! ! debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); ! ! wxLuaDebugData dataArr(true); ! size_t n, count = strArr.GetCount(); ! for (n = 0; n < count; n++) ! { ! wxLuaDebugItem *item = new wxLuaDebugItem(strArr[n].BeforeLast(wxT(' ')), WXLUAARG_None, ! strArr[n].AfterLast(wxT(' ')), WXLUAARG_None, ! wxT(""), LUA_NOREF, debugItem->GetIndex() + 1); ! dataArr.Add(item); ! } ! ! FillTableEntry(lc_item, dataArr); ! expanded = true; ! } ! else if (nRef != LUA_NOREF) { debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); --- 1035,1039 ---- } ! if (nRef != LUA_NOREF) { debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** wxldebug.cpp 5 Dec 2007 00:34:46 -0000 1.55 --- wxldebug.cpp 7 Dec 2007 02:13:14 -0000 1.56 *************** *** 19,22 **** --- 19,23 ---- #include "wxluadebug/include/wxldebug.h" + #include "wxlua/include/wxlcallb.h" wxLuaDebugData wxNullLuaDebugData(false); *************** *** 283,286 **** --- 284,322 ---- if (wxlState.wxluaR_GetRef(tableRef, &wxlua_lreg_debug_refs_key)) { + bool is_wxlua_lreg_evtcallbacks_key = false; + bool is_wxlua_lreg_windestroycallbacks_key = false; + bool is_wxlua_lreg_topwindows_key = false; + bool is_wxlua_lreg_delobjects_key = false; + + // See if this is one of wxLua's registry tables + lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + is_wxlua_lreg_evtcallbacks_key = lua_equal(L, -1, -2); + lua_pop(L, 1); + + if (!is_wxlua_lreg_evtcallbacks_key) + { + lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + is_wxlua_lreg_windestroycallbacks_key = lua_equal(L, -1, -2); + lua_pop(L, 1); + + if (!is_wxlua_lreg_windestroycallbacks_key) + { + lua_pushlightuserdata(L, &wxlua_lreg_topwindows_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + is_wxlua_lreg_topwindows_key = lua_equal(L, -1, -2); + lua_pop(L, 1); + + if (!is_wxlua_lreg_topwindows_key) + { + lua_pushlightuserdata(L, &wxlua_lreg_delobjects_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + is_wxlua_lreg_delobjects_key = lua_equal(L, -1, -2); + lua_pop(L, 1); + } + } + } + if (lua_getmetatable(L, -1)) // if no metatable then nothing is pushed { *************** *** 301,304 **** --- 337,342 ---- while (lua_next(L, -2) != 0) { + // value at -1, key at -2, table at -3 + // get the index, just want the name=value, type is dummy here GetTypeValue(wxlState, -2, &wxl_keytype, name); *************** *** 306,316 **** GetTypeValue(wxlState, -1, &wxl_valuetype, value); int flag_type = 0; int nRef = RefTable(L, -1, &flag_type, references); - lua_pop(L, 1); - Add(new wxLuaDebugItem(name, wxl_keytype, value, wxl_valuetype, wxT(""), nRef, nIndex, flag_type)); count++; } --- 344,385 ---- GetTypeValue(wxlState, -1, &wxl_valuetype, value); + // Handle special tables to give more information + if (is_wxlua_lreg_evtcallbacks_key) + { + wxLuaCallback* wxlCallback = (wxLuaCallback*)lua_touserdata(L, -2); + wxCHECK_MSG(wxlCallback, count, wxT("Invalid wxLuaCallback")); + + wxString s(wxlCallback->GetInfo()); + name = s.BeforeFirst(wxT('|')); + value = s.AfterFirst(wxT('|')); + } + else if (is_wxlua_lreg_windestroycallbacks_key && (lua_type(L, -1) == LUA_TLIGHTUSERDATA)) + { + // only handle t[wxWindow*] = wxLuaWinDestroyCallback* + wxLuaWinDestroyCallback* wxlDestroyCallBack = (wxLuaWinDestroyCallback*)lua_touserdata(L, -1); + wxCHECK_MSG(wxlDestroyCallBack, count, wxT("Invalid wxLuaWinDestroyCallback")); + + wxString s(wxlDestroyCallBack->GetInfo()); + name = s.BeforeFirst(wxT('|')); + value = s.AfterFirst(wxT('|')); + } + else if (is_wxlua_lreg_topwindows_key) + { + wxWindow* win = (wxWindow*)lua_touserdata(L, -2); + name += wxT(" ") + wxString(win->GetClassInfo()->GetClassName()); + } + else if (is_wxlua_lreg_delobjects_key) + { + wxObject* obj = (wxObject*)lua_touserdata(L, -1); + name = wxString(obj->GetClassInfo()->GetClassName()) + wxT("(") + name + wxT(")"); + } + int flag_type = 0; int nRef = RefTable(L, -1, &flag_type, references); Add(new wxLuaDebugItem(name, wxl_keytype, value, wxl_valuetype, wxT(""), nRef, nIndex, flag_type)); count++; + + lua_pop(L, 1); // pop value, leave key } *************** *** 322,326 **** } - int wxLuaDebugData::RefTable(lua_State* L, int stack_idx, int* flag_type, wxArrayInt& references) { --- 391,394 ---- *************** *** 463,471 **** (udata == &wxlua_lreg_derivedmethods_key) || (udata == &wxlua_lreg_wxluastate_key) || ! (udata == &wxlua_lreg_objects_key) || (udata == &wxlua_lreg_evtcallbacks_key) || (udata == &wxlua_lreg_windestroycallbacks_key) || (udata == &wxlua_lreg_callbaseclassfunc_key) || (udata == &wxlua_metatable_tag_key) || (udata == &wxlua_metatable_wxluabindclass_key)) { --- 531,544 ---- (udata == &wxlua_lreg_derivedmethods_key) || (udata == &wxlua_lreg_wxluastate_key) || ! (udata == &wxlua_lreg_weakobjects_key) || ! (udata == &wxlua_lreg_delobjects_key) || (udata == &wxlua_lreg_evtcallbacks_key) || (udata == &wxlua_lreg_windestroycallbacks_key) || (udata == &wxlua_lreg_callbaseclassfunc_key) || + (udata == &wxlua_lreg_wxeventtype_key) || + (udata == &wxlua_lreg_wxluadebughookdata_key) || + (udata == &wxlua_metatable_tag_key) || + (udata == &wxlua_lreg_topwindows_key) || (udata == &wxlua_metatable_wxluabindclass_key)) { |