From: John L. <jr...@us...> - 2009-11-15 17:56:13
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv32122/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: Speedup the wxLuaStackDialog by passing the lua_State instead of the wxLuaState and use wxString::Printf() instead of wxString::Format() Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** wxlstack.cpp 5 Oct 2009 02:51:29 -0000 1.31 --- wxlstack.cpp 15 Nov 2009 17:56:04 -0000 1.32 *************** *** 511,515 **** wxBusyCursor wait; wxLuaDebugData debugData(true); ! debugData.EnumerateStack(m_wxlState); FillStackCombobox(debugData); } --- 511,515 ---- wxBusyCursor wait; wxLuaDebugData debugData(true); ! debugData.EnumerateStack(m_wxlState.GetLuaState()); FillStackCombobox(debugData); } *************** *** 519,523 **** wxBusyCursor wait; wxLuaDebugData debugData(true); ! debugData.EnumerateStackEntry(m_wxlState, nEntry, m_luaReferences); FillStackEntry(nEntry, debugData); } --- 519,523 ---- wxBusyCursor wait; wxLuaDebugData debugData(true); ! debugData.EnumerateStackEntry(m_wxlState.GetLuaState(), nEntry, m_luaReferences); FillStackEntry(nEntry, debugData); } *************** *** 527,531 **** wxBusyCursor wait; wxLuaDebugData debugData(true); ! debugData.EnumerateTable(m_wxlState, nRef, nEntry, m_luaReferences); FillTableEntry(lc_item, debugData); } --- 527,531 ---- wxBusyCursor wait; wxLuaDebugData debugData(true); ! debugData.EnumerateTable(m_wxlState.GetLuaState(), nRef, nEntry, m_luaReferences); FillTableEntry(lc_item, debugData); } *************** *** 571,575 **** wxLuaDebugItem* localItem = new wxLuaDebugItem(_("Locals"), WXLUA_TNONE, wxString::Format(wxT("%d Items"), (int)debugData.GetCount()), WXLUA_TNONE, ! wxT(""), LUA_NOREF, 0, WXLUA_DEBUGITEM_EXPANDED|WXLUA_DEBUGITEM_LOCALS|WXLUA_DEBUGITEM_VALUE_REF); wxLuaDebugData localData(true); // this deletes the items localData.Add(localItem); --- 571,575 ---- wxLuaDebugItem* localItem = new wxLuaDebugItem(_("Locals"), WXLUA_TNONE, wxString::Format(wxT("%d Items"), (int)debugData.GetCount()), WXLUA_TNONE, ! wxEmptyString, LUA_NOREF, 0, WXLUA_DEBUGITEM_EXPANDED|WXLUA_DEBUGITEM_LOCALS|WXLUA_DEBUGITEM_VALUE_REF); wxLuaDebugData localData(true); // this deletes the items localData.Add(localItem); *************** *** 1100,1104 **** if ((n > lc_item) && (stkListData_n->m_level <= level)) break; ! if (counter % 20 == 0) { if (!dlg->Pulse(wxString::Format(wxT("Expanding nodes : %d"), counter))) --- 1100,1104 ---- if ((n > lc_item) && (stkListData_n->m_level <= level)) break; ! if (counter % 50 == 0) { if (!dlg->Pulse(wxString::Format(wxT("Expanding nodes : %d"), counter))) *************** *** 1124,1128 **** { wxCHECK_MSG((lc_item >= 0) && (lc_item < m_listCtrl->GetItemCount()), false, ! wxT("Invalid list item to expand")); bool collapsed = false; --- 1124,1128 ---- { wxCHECK_MSG((lc_item >= 0) && (lc_item < m_listCtrl->GetItemCount()), false, ! wxT("Invalid list item to collapse")); bool collapsed = false; *************** *** 1132,1142 **** wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); wxCHECK_MSG((debugItem != NULL), false, wxT("Invalid debug item")); - wxLuaDebugData childData = stkListData->m_childrenDebugData; - - BeginBatch(); // Collapse the item, remove children if (debugItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) { if (childData.Ok()) { --- 1132,1142 ---- wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); wxCHECK_MSG((debugItem != NULL), false, wxT("Invalid debug item")); // Collapse the item, remove children if (debugItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) { + BeginBatch(); + wxLuaDebugData childData = stkListData->m_childrenDebugData; + if (childData.Ok()) { *************** *** 1189,1197 **** if (debugItem->GetRefPtr(long_key)) m_expandedItems.erase(long_key); - } ! EndBatch(); ! ! m_listCtrl->SetItemCount(m_listData.GetCount()); return collapsed; --- 1189,1196 ---- if (debugItem->GetRefPtr(long_key)) m_expandedItems.erase(long_key); ! m_listCtrl->SetItemCount(m_listData.GetCount()); ! EndBatch(); ! } return collapsed; *************** *** 1260,1267 **** 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. ! //wxLuaCheckStack cs(L, wxT("wxLuaStackDialog::RemoveAllLuaReferences")); lua_pushlightuserdata(L, &wxlua_lreg_debug_refs_key); // push name of table to get as key --- 1259,1267 ---- 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. ! if (0) { //wxLuaCheckStack cs(L, wxT("wxLuaStackDialog::RemoveAllLuaReferences")); lua_pushlightuserdata(L, &wxlua_lreg_debug_refs_key); // push name of table to get as key *************** *** 1281,1285 **** lua_pop(L, 1); // pop ref table ! // Clear out the old numeric references since it should be "empty" // though full of dead table[idx]=next_idx, where table[0] = 1; --- 1281,1285 ---- lua_pop(L, 1); // pop ref table ! } // Clear out the old numeric references since it should be "empty" // though full of dead table[idx]=next_idx, where table[0] = 1; Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** wxldebug.cpp 5 Oct 2009 02:51:29 -0000 1.69 --- wxldebug.cpp 15 Nov 2009 17:56:04 -0000 1.70 *************** *** 169,179 **** } ! int wxLuaDebugData::EnumerateStack(const wxLuaState& wxlState_) { ! wxCHECK_MSG(wxlState_.Ok(), 0, wxT("Invalid wxLuaState")); wxCHECK_MSG(M_DEBUGREFDATA != NULL, 0, wxT("Invalid ref data")); - wxLuaState wxlState(wxlState_); // unconst the state - lua_State* L = wxlState.GetLuaState(); lua_Debug luaDebug = INIT_LUA_DEBUG; int stack_frame = 0; --- 169,177 ---- } ! int wxLuaDebugData::EnumerateStack(lua_State* L) { ! wxCHECK_MSG(L, 0, wxT("Invalid lua_State")); wxCHECK_MSG(M_DEBUGREFDATA != NULL, 0, wxT("Invalid ref data")); lua_Debug luaDebug = INIT_LUA_DEBUG; int stack_frame = 0; *************** *** 197,205 **** 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, WXLUA_TNONE, wxT(""), WXLUA_TNONE, source, LUA_NOREF, stack_frame, WXLUA_DEBUGITEM_LOCALS)); ++count; } --- 195,203 ---- if (luaDebug.name != NULL) ! name.Printf(_("function %s line %d"), lua2wx(luaDebug.name).c_str(), currentLine); else ! name.Printf(_("line %d"), currentLine); ! Add(new wxLuaDebugItem(name, WXLUA_TNONE, wxEmptyString, WXLUA_TNONE, source, LUA_NOREF, stack_frame, WXLUA_DEBUGITEM_LOCALS)); ++count; } *************** *** 212,222 **** } ! int wxLuaDebugData::EnumerateStackEntry(const wxLuaState& wxlState_, int stack_frame, wxArrayInt& references) { ! wxCHECK_MSG(wxlState_.Ok(), 0, wxT("Invalid wxLuaState")); wxCHECK_MSG(M_DEBUGREFDATA != NULL, 0, wxT("Invalid ref data")); - wxLuaState wxlState(wxlState_); // unconst the state - lua_State* L = wxlState.GetLuaState(); lua_Debug luaDebug = INIT_LUA_DEBUG; int count = 0; --- 210,218 ---- } ! int wxLuaDebugData::EnumerateStackEntry(lua_State* L, int stack_frame, wxArrayInt& references) { ! wxCHECK_MSG(L, 0, wxT("Invalid lua_State")); wxCHECK_MSG(M_DEBUGREFDATA != NULL, 0, wxT("Invalid ref data")); lua_Debug luaDebug = INIT_LUA_DEBUG; int count = 0; *************** *** 234,238 **** wxString source(lua2wx(luaDebug.source)); ! GetTypeValue(wxlState, -1, &wxl_valuetype, value); // FIXME! local tables get the right values for GetTypeValue(...) --- 230,234 ---- wxString source(lua2wx(luaDebug.source)); ! GetTypeValue(L, -1, &wxl_valuetype, value); // FIXME! local tables get the right values for GetTypeValue(...) *************** *** 275,285 **** } ! int wxLuaDebugData::EnumerateTable(const wxLuaState& wxlState_, int tableRef, int nIndex, wxArrayInt& references) { ! wxCHECK_MSG(wxlState_.Ok(), 0, wxT("Invalid wxLuaState")); wxCHECK_MSG(M_DEBUGREFDATA != NULL, 0, wxT("Invalid ref data")); - wxLuaState wxlState(wxlState_); // unconst the state - lua_State* L = wxlState.GetLuaState(); int count = 0; --- 271,279 ---- } ! int wxLuaDebugData::EnumerateTable(lua_State* L, int tableRef, int nIndex, wxArrayInt& references) { ! wxCHECK_MSG(L, 0, wxT("Invalid lua_State")); wxCHECK_MSG(M_DEBUGREFDATA != NULL, 0, wxT("Invalid ref data")); int count = 0; *************** *** 292,296 **** { lua_pushvalue(L, LUA_GLOBALSINDEX); ! GetTypeValue(wxlState, -1, &wxl_valuetype, value); int flag_type = 0; --- 286,290 ---- { lua_pushvalue(L, LUA_GLOBALSINDEX); ! GetTypeValue(L, -1, &wxl_valuetype, value); int flag_type = 0; *************** *** 298,307 **** lua_pop(L, 1); // pop globals table ! Add(new wxLuaDebugItem(wxT("Globals"), WXLUA_TNONE, value, WXLUA_TTABLE, wxT(""), val_ref, 0, flag_type)); } else if (tableRef == LUA_ENVIRONINDEX) { lua_pushvalue(L, LUA_ENVIRONINDEX); ! GetTypeValue(wxlState, -1, &wxl_valuetype, value); int flag_type = 0; --- 292,301 ---- lua_pop(L, 1); // pop globals table ! Add(new wxLuaDebugItem(wxT("Globals"), WXLUA_TNONE, value, WXLUA_TTABLE, wxEmptyString, val_ref, 0, flag_type)); } else if (tableRef == LUA_ENVIRONINDEX) { lua_pushvalue(L, LUA_ENVIRONINDEX); ! GetTypeValue(L, -1, &wxl_valuetype, value); int flag_type = 0; *************** *** 309,318 **** lua_pop(L, 1); // pop environment table ! Add(new wxLuaDebugItem(wxT("Environment"), WXLUA_TNONE, value, WXLUA_TTABLE, wxT(""), val_ref, 0, flag_type)); } else if (tableRef == LUA_REGISTRYINDEX) { lua_pushvalue(L, LUA_REGISTRYINDEX); ! GetTypeValue(wxlState, -1, &wxl_valuetype, value); int flag_type = 0; --- 303,312 ---- lua_pop(L, 1); // pop environment table ! Add(new wxLuaDebugItem(wxT("Environment"), WXLUA_TNONE, value, WXLUA_TTABLE, wxEmptyString, val_ref, 0, flag_type)); } else if (tableRef == LUA_REGISTRYINDEX) { lua_pushvalue(L, LUA_REGISTRYINDEX); ! GetTypeValue(L, -1, &wxl_valuetype, value); int flag_type = 0; *************** *** 320,324 **** lua_pop(L, 1); // pop registry table ! Add(new wxLuaDebugItem(wxT("Registry"), WXLUA_TNONE, value, WXLUA_TTABLE, wxT(""), val_ref, 0, flag_type)); } else --- 314,318 ---- lua_pop(L, 1); // pop registry table ! Add(new wxLuaDebugItem(wxT("Registry"), WXLUA_TNONE, value, WXLUA_TTABLE, wxEmptyString, val_ref, 0, flag_type)); } else *************** *** 348,352 **** { // get the type and value ! GetTypeValue(wxlState, -1, &wxl_valuetype, value); int flag_type = 0; --- 342,346 ---- { // get the type and value ! GetTypeValue(L, -1, &wxl_valuetype, value); int flag_type = 0; *************** *** 354,358 **** // leading space so it's first when sorted ! Add(new wxLuaDebugItem(wxT(" __metatable"), WXLUA_TTABLE, value, wxl_valuetype, wxT(""), val_ref, nIndex, flag_type)); ++count; --- 348,352 ---- // leading space so it's first when sorted ! Add(new wxLuaDebugItem(wxT(" __metatable"), WXLUA_TTABLE, value, wxl_valuetype, wxEmptyString, val_ref, nIndex, flag_type)); ++count; *************** *** 369,375 **** // get the key type and value ! int lua_key_type = GetTypeValue(wxlState, -2, &wxl_keytype, name); // get the value type and value ! int lua_value_type = GetTypeValue(wxlState, -1, &wxl_valuetype, value); // Handle wxLua LUA_REGISTRYINDEX tables to give more information --- 363,369 ---- // get the key type and value ! int lua_key_type = GetTypeValue(L, -2, &wxl_keytype, name); // get the value type and value ! int lua_value_type = GetTypeValue(L, -1, &wxl_valuetype, value); // Handle wxLua LUA_REGISTRYINDEX tables to give more information *************** *** 418,422 **** { int wxl_type_ = (int)lua_tonumber(L, -1); ! name = wxString::Format(wxT("%s(%s)"), wxluaT_typename(L, wxl_type_).c_str(), name.c_str()); } else if (lightuserdata_reg_key == &wxlua_lreg_weakobjects_key) --- 412,416 ---- { int wxl_type_ = (int)lua_tonumber(L, -1); ! name.Printf(wxT("%s(%s)"), wxluaT_typename(L, wxl_type_).c_str(), name.c_str()); } else if (lightuserdata_reg_key == &wxlua_lreg_weakobjects_key) *************** *** 435,439 **** } ! name = wxString::Format(wxT("%s (%s)"), names_weak.c_str(), name.c_str()); } } --- 429,433 ---- } ! name.Printf(wxT("%s (%s)"), names_weak.c_str(), name.c_str()); } } *************** *** 480,484 **** if (key_flag_type != 0) { ! Add(new wxLuaDebugItem(name, wxl_keytype, value, wxl_valuetype, wxT(""), key_ref, nIndex, key_flag_type)); ++count; } --- 474,478 ---- if (key_flag_type != 0) { ! Add(new wxLuaDebugItem(name, wxl_keytype, value, wxl_valuetype, wxEmptyString, key_ref, nIndex, key_flag_type)); ++count; } *************** *** 504,508 **** if ((key_flag_type == 0) || ((key_flag_type != 0) && (val_flag_type != 0))) { ! Add(new wxLuaDebugItem(name, wxl_keytype, value, wxl_valuetype, wxT(""), val_ref, nIndex, val_flag_type)); ++count; } --- 498,502 ---- if ((key_flag_type == 0) || ((key_flag_type != 0) && (val_flag_type != 0))) { ! Add(new wxLuaDebugItem(name, wxl_keytype, value, wxl_valuetype, wxEmptyString, val_ref, nIndex, val_flag_type)); ++count; } *************** *** 539,547 **** } ! int wxLuaDebugData::GetTypeValue(const wxLuaState& wxlState, int stack_idx, int* wxl_type_, wxString& value) { ! wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); - lua_State* L = wxlState.GetLuaState(); int l_type = lua_type(L, stack_idx); int wxl_type = wxlua_luatowxluatype(l_type); --- 533,540 ---- } ! int wxLuaDebugData::GetTypeValue(lua_State *L, int stack_idx, int* wxl_type_, wxString& value) { ! wxCHECK_MSG(L, 0, wxT("Invalid lua_State")); int l_type = lua_type(L, stack_idx); int wxl_type = wxlua_luatowxluatype(l_type); *************** *** 568,572 **** case LUA_TLIGHTUSERDATA: { ! value = GetUserDataInfo(wxlState, stack_idx, false); break; } --- 561,565 ---- case LUA_TLIGHTUSERDATA: { ! value = GetUserDataInfo(L, stack_idx, false); break; } *************** *** 576,582 **** if ((long)num == num) ! value = wxString::Format(wxT("%ld (0x%lx)"), (long)num, (unsigned long)num); else ! value = wxString::Format(wxT("%g"), num); break; --- 569,575 ---- if ((long)num == num) ! value.Printf(wxT("%ld (0x%lx)"), (long)num, (unsigned long)num); else ! value.Printf(wxT("%g"), num); break; *************** *** 589,593 **** case LUA_TTABLE: { ! value = GetTableInfo(wxlState, stack_idx); break; } --- 582,586 ---- case LUA_TTABLE: { ! value = GetTableInfo(L, stack_idx); break; } *************** *** 603,607 **** case LUA_TUSERDATA: { ! value = GetUserDataInfo(wxlState, stack_idx, true); break; } --- 596,600 ---- case LUA_TUSERDATA: { ! value = GetUserDataInfo(L, stack_idx, true); break; } *************** *** 621,648 **** } ! wxString wxLuaDebugData::GetTableInfo(const wxLuaState& wxlState, int stack_idx) { ! wxCHECK_MSG(wxlState.Ok(), wxEmptyString, wxT("Invalid wxLuaState")); ! lua_State* L = wxlState.GetLuaState(); - int wxl_type = wxluaT_type(L, stack_idx); int nItems = luaL_getn(L, stack_idx); const void *pItem = lua_topointer(L, stack_idx); - wxString s(wxString::Format(wxT("%p"), pItem)); - if (nItems > 0) ! s += wxString::Format(wxT(" (approx %d items)"), nItems); ! ! if (wxlua_iswxuserdatatype(wxl_type)) ! s += wxString::Format(wxT(" (wxltype %d)"), wxl_type); ! return s; } ! wxString wxLuaDebugData::GetUserDataInfo(const wxLuaState& wxlState, int stack_idx, bool full_userdata) { ! wxCHECK_MSG(wxlState.Ok(), wxEmptyString, wxT("Invalid wxLuaState")); ! lua_State* L = wxlState.GetLuaState(); void* udata = lua_touserdata(L, stack_idx); --- 614,633 ---- } ! wxString wxLuaDebugData::GetTableInfo(lua_State *L, int stack_idx) { ! wxCHECK_MSG(L, wxEmptyString, wxT("Invalid lua_State")); int nItems = luaL_getn(L, stack_idx); const void *pItem = lua_topointer(L, stack_idx); if (nItems > 0) ! return wxString::Format(wxT("%p (%d array items)"), pItem, nItems); ! return wxString::Format(wxT("%p"), pItem); } ! wxString wxLuaDebugData::GetUserDataInfo(lua_State *L, int stack_idx, bool full_userdata) { ! wxCHECK_MSG(L, wxEmptyString, wxT("Invalid lua_State")); void* udata = lua_touserdata(L, stack_idx); *************** *** 744,748 **** int wxl_type = 0; wxString value; ! int l_type = wxLuaDebugData::GetTypeValue(wxlState, i, &wxl_type, value); str.Printf(wxT(" idx %d: l_type = %d, wxl_type = %d : '%s'='%s'\n"), --- 729,733 ---- int wxl_type = 0; wxString value; ! int l_type = wxLuaDebugData::GetTypeValue(L, i, &wxl_type, value); str.Printf(wxT(" idx %d: l_type = %d, wxl_type = %d : '%s'='%s'\n"), *************** *** 855,860 **** wxString key, value; ! wxLuaDebugData::GetTypeValue(wxlState, -2, &keyType, key); ! wxLuaDebugData::GetTypeValue(wxlState, -1, &valueType, value); wxString info = wxString::Format(wxT("%s%-32s\t%-16s\t%-20s\t%-16s\n"), --- 840,845 ---- wxString key, value; ! wxLuaDebugData::GetTypeValue(L, -2, &keyType, key); ! wxLuaDebugData::GetTypeValue(L, -1, &valueType, value); wxString info = wxString::Format(wxT("%s%-32s\t%-16s\t%-20s\t%-16s\n"), |