From: John L. <jr...@us...> - 2007-12-10 05:39:22
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv23281/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: genwxbind.lua - don't create "returns" variable before use to save a line of code. Applied Lua patches for 5.1.2 8-11 Added wxlua_lreg_createtable(..) to create the LUA_REGISTRYINDEX tables for wxLua Added wxlua_lreg_regtable_key in LUA_REGISTRYINDEX to help the wxLuaDebugData find wxLua's tables faster to give more information Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** wxlstack.cpp 7 Dec 2007 02:13:14 -0000 1.25 --- wxlstack.cpp 10 Dec 2007 05:39:10 -0000 1.26 *************** *** 671,675 **** } ! m_batch_count++; } --- 671,675 ---- } ! ++m_batch_count; } *************** *** 691,695 **** wxLuaStackListData* stkListData_n = NULL; ! for (n = 0; n < count; n++) { stkListData_n = (wxLuaStackListData*)m_listData[n]; --- 691,695 ---- wxLuaStackListData* stkListData_n = NULL; ! for (n = 0; n < count; ++n) { stkListData_n = (wxLuaStackListData*)m_listData[n]; *************** *** 842,851 **** { i = (direction > 0) ? 0 : list_count - 1; ! wrap_count++; // we're looking at all the elements } else if ((direction > 0) && (start_item == list_count - 1)) { i = 0; ! wrap_count++; // we're looking at all the elements } } --- 842,851 ---- { i = (direction > 0) ? 0 : list_count - 1; ! ++wrap_count; // we're looking at all the elements } else if ((direction > 0) && (start_item == list_count - 1)) { i = 0; ! ++wrap_count; // we're looking at all the elements } } *************** *** 857,861 **** for ( ; (i >= 0) && (i < list_count) && !found; i = i + direction) { ! for (int col = 0; (col < 5) && !found; col++) { if (!find_col[col]) continue; --- 857,861 ---- for ( ; (i >= 0) && (i < list_count) && !found; i = i + direction) { ! for (int col = 0; (col < 5) && !found; ++col) { if (!find_col[col]) continue; *************** *** 876,880 **** } ! wrap_count++; } } --- 876,880 ---- } ! ++wrap_count; } } *************** *** 1060,1065 **** bool expanded = false; ! wxProgressDialog dlg(wxT("wxLua Stack Expanding node"), wxEmptyString, 100, this, ! wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); BeginBatch(); --- 1060,1066 ---- bool expanded = false; ! wxProgressDialog* dlg = ! new wxProgressDialog(wxT("wxLua Stack Expanding node"), wxEmptyString, 100, this, ! wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT); BeginBatch(); *************** *** 1077,1081 **** // show message for first item only so it doesn't silently fail if (n > lc_item) m_show_dup_expand_msg = false; ! wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listData[n]; --- 1078,1082 ---- // show message for first item only so it doesn't silently fail if (n > lc_item) m_show_dup_expand_msg = false; ! wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listData[n]; *************** *** 1084,1088 **** if (counter % 20 == 0) { ! if (!dlg.Pulse(wxString::Format(wxT("Expanding nodes : %d"), counter))) break; } --- 1085,1089 ---- if (counter % 20 == 0) { ! if (!dlg->Pulse(wxString::Format(wxT("Expanding nodes : %d"), counter))) break; } *************** *** 1091,1098 **** expanded |= ExpandItem(n); ! counter++; ! n++; } EndBatch(); m_show_dup_expand_msg = true; --- 1092,1101 ---- expanded |= ExpandItem(n); ! ++counter; ! ++n; } + dlg->Destroy(); + EndBatch(); m_show_dup_expand_msg = true; *************** *** 1123,1127 **** long n, count = m_listCtrl->GetItemCount(); ! for (n = lc_item+1; n < count; n++) { wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listData[n]; --- 1126,1130 ---- long n, count = m_listCtrl->GetItemCount(); ! for (n = lc_item+1; n < count; ++n) { wxLuaStackListData* stkListData_n = (wxLuaStackListData*)m_listData[n]; *************** *** 1230,1237 **** */ // 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.wxluaR_Unref(m_luaReferences[i], &wxlua_lreg_debug_refs_key); wxCHECK_RET(ok, wxT("Unable to remove a reference in Lua")); //wxPrintf(wxT("Extra Lua reference in listctrl #%d ok %d ref %d count %d\n"), i, ok, m_luaReferences[i], m_luaReferences.GetCount()); --- 1233,1242 ---- */ + lua_State* L = m_wxlState.GetLuaState(); + // remove the last to so we don't make any holes for (i = (int)m_luaReferences.GetCount()-1; i >= 0; --i) { ! bool ok = wxluaR_unref(L, 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()); *************** *** 1244,1248 **** // 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 --- 1249,1252 ---- *************** *** 1264,1276 **** // 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 } --- 1268,1273 ---- // Clear out the old numeric references since it should be "empty" ! // though full of dead table[idx]=next_idx, where table[0] = 1; ! wxlua_lreg_createtable(L, &wxlua_lreg_debug_refs_key); } Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** wxldebug.cpp 7 Dec 2007 02:13:14 -0000 1.56 --- wxldebug.cpp 10 Dec 2007 05:39:10 -0000 1.57 *************** *** 173,177 **** // skip stack frames that do not have line number, always add first int currentLine = luaDebug.currentline; ! if (1) //(count == 0) || (currentLine != -1)) { wxString name; --- 173,177 ---- // skip stack frames that do not have line number, always add first int currentLine = luaDebug.currentline; ! if ((count == 0) || (currentLine != -1)) { wxString name; *************** *** 187,191 **** Add(new wxLuaDebugItem(name, WXLUAARG_None, wxT(""), WXLUAARG_None, source, LUA_NOREF, stack_frame, 0)); ! count++; } } --- 187,191 ---- Add(new wxLuaDebugItem(name, WXLUAARG_None, wxT(""), WXLUAARG_None, source, LUA_NOREF, stack_frame, 0)); ! ++count; } } *************** *** 234,238 **** Add(new wxLuaDebugItem(name, WXLUAARG_None, value, wxl_valuetype, source, nRef, 0, flag_type)); ! count++; name = lua2wx(lua_getlocal(L, &luaDebug, ++stack_idx)); --- 234,238 ---- Add(new wxLuaDebugItem(name, WXLUAARG_None, value, wxl_valuetype, source, nRef, 0, flag_type)); ! ++count; name = lua2wx(lua_getlocal(L, &luaDebug, ++stack_idx)); *************** *** 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 { --- 284,297 ---- if (wxlState.wxluaR_GetRef(tableRef, &wxlua_lreg_debug_refs_key)) { ! // Check to see if this is a wxLua LUA_REGISTRYINDEX table ! void *lightuserdata_reg_key = NULL; ! lua_pushlightuserdata(L, &wxlua_lreg_regtable_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); ! lua_pushvalue(L, -2); // push value (table we're iterating) ! lua_rawget(L, -2); ! lightuserdata_reg_key = lua_touserdata(L, -1); ! lua_pop(L, 2); // pop wxlua_lreg_regtable_key table and (nil or lightuserdata) + // Check if it has a metatable if (lua_getmetatable(L, -1)) // if no metatable then nothing is pushed { *************** *** 327,332 **** int nRef = RefTable(L, -1, &flag_type, references); Add(new wxLuaDebugItem(wxT(" __metatable"), WXLUAARG_Table, value, wxl_valuetype, wxT(""), nRef, nIndex, flag_type)); ! count++; lua_pop(L, 1); // pop metatable --- 302,308 ---- int nRef = RefTable(L, -1, &flag_type, references); + // leading space so it's first when sorted Add(new wxLuaDebugItem(wxT(" __metatable"), WXLUAARG_Table, value, wxl_valuetype, wxT(""), nRef, nIndex, flag_type)); ! ++count; lua_pop(L, 1); // pop metatable *************** *** 344,383 **** 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 --- 320,370 ---- GetTypeValue(wxlState, -1, &wxl_valuetype, value); ! // Handle wxLua LUA_REGISTRYINDEX tables to give more information ! if (lightuserdata_reg_key != NULL) { ! if (lightuserdata_reg_key == &wxlua_lreg_tags_key) ! { ! value += wxT(" (") + wxluaT_gettagname(L, (int)lua_tonumber(L, -2)) + wxT(")"); ! } ! else if (lightuserdata_reg_key == &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 ((lightuserdata_reg_key == &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 (lightuserdata_reg_key == &wxlua_lreg_topwindows_key) ! { ! wxWindow* win = (wxWindow*)lua_touserdata(L, -2); ! name += wxT(" ") + wxString(win->GetClassInfo()->GetClassName()); ! } ! else if (lightuserdata_reg_key == &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 = LUA_NOREF; ! // don't ref anything in this table since it's already refed ! if (lightuserdata_reg_key != &wxlua_lreg_debug_refs_key) ! 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 *************** *** 398,402 **** if (lua_istable(L, stack_idx)) { ! nRef = wxluaR_isrefed(L, stack_idx, &wxlua_lreg_debug_refs_key); // don't duplicate refs if (nRef == LUA_NOREF) --- 385,389 ---- if (lua_istable(L, stack_idx)) { ! //nRef = wxluaR_isrefed(L, stack_idx, &wxlua_lreg_debug_refs_key); // don't duplicate refs if (nRef == LUA_NOREF) *************** *** 538,541 **** --- 525,529 ---- (udata == &wxlua_lreg_wxeventtype_key) || (udata == &wxlua_lreg_wxluadebughookdata_key) || + (udata == &wxlua_lreg_regtable_key) || (udata == &wxlua_metatable_tag_key) || |