From: John L. <jr...@us...> - 2007-12-13 00:48:00
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv15370/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: * Allowed using wxObject:DynamicCast() on an object and be able to use the object as both types. The problem was that wxEvent:GetEventObject() returned a wxObject which overwrote the wxWindow (perhaps) that you had as a userdata in Lua already. Additionally, if you delete an object all of the userdata that wrap it have their metatables cleared for safety. Functions renamed since they didn't do the same thing or behave the same. wxluaO_istrackedobject -> wxluaO_isgcobject wxluaO_addtrackedobject -> wxluaO_addgcobject wxluaO_removetrackedobject -> wxluaO_deletegcobject - Created a central luauserdata:delete() function for the bindings to reduce code. wxLua_wxluabind_delete(L) wxLuaStackDialog: You can expand both key and values of a table and more information is provided about items wxLua knows about. Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** wxlstack.cpp 10 Dec 2007 23:20:19 -0000 1.27 --- wxlstack.cpp 13 Dec 2007 00:47:53 -0000 1.28 *************** *** 82,86 **** int wxLuaStackListCtrl::OnGetItemColumnImage(long item, long column) const { ! if (column == 0) { wxLuaStackListData* stkListData = (wxLuaStackListData*)m_stkDlg->m_listData[item]; --- 82,88 ---- int wxLuaStackListCtrl::OnGetItemColumnImage(long item, long column) const { ! if ((column == wxLuaStackDialog::LIST_COL_KEY) || ! (column == wxLuaStackDialog::LIST_COL_KEY_TYPE) || ! (column == wxLuaStackDialog::LIST_COL_VALUE_TYPE)) { wxLuaStackListData* stkListData = (wxLuaStackListData*)m_stkDlg->m_listData[item]; *************** *** 88,93 **** wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); wxCHECK_MSG(debugItem, NULL, wxT("Invalid wxLuaDebugItem item")); ! ! return m_stkDlg->GetItemImage(debugItem); } --- 90,116 ---- wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); wxCHECK_MSG(debugItem, NULL, wxT("Invalid wxLuaDebugItem item")); ! ! if (column == wxLuaStackDialog::LIST_COL_KEY) ! return m_stkDlg->GetItemImage(debugItem); ! else if (column == wxLuaStackDialog::LIST_COL_KEY_TYPE) ! { ! if (debugItem->GetFlagBit(WXLUA_DEBUGITEM_KEY_REF)) ! { ! if (debugItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) ! return wxLuaStackDialog::IMG_TABLE_OPEN; ! else ! return wxLuaStackDialog::IMG_TABLE; ! } ! } ! else if (column == wxLuaStackDialog::LIST_COL_VALUE_TYPE) ! { ! if (debugItem->GetFlagBit(WXLUA_DEBUGITEM_VALUE_REF)) ! { ! if (debugItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) ! return wxLuaStackDialog::IMG_TABLE_OPEN; ! else ! return wxLuaStackDialog::IMG_TABLE; ! } ! } } *************** *** 113,117 **** } - // ---------------------------------------------------------------------------- // wxLuaStackDialog --- 136,139 ---- *************** *** 154,157 **** --- 176,180 ---- m_imageList = NULL; + m_img_font_size = 15; // largest font size we'll use is 14 m_show_dup_expand_msg = true; *************** *** 311,325 **** m_listCtrl->SetImageList(m_imageList, wxIMAGE_LIST_SMALL); ! m_listCtrl->InsertColumn(0, wxT("Name"), wxLIST_FORMAT_LEFT, -1); ! m_listCtrl->InsertColumn(1, wxT("Level"), wxLIST_FORMAT_LEFT, -1); ! m_listCtrl->InsertColumn(2, wxT("Key Type"), wxLIST_FORMAT_LEFT, -1); ! m_listCtrl->InsertColumn(3, wxT("Value Type"), wxLIST_FORMAT_LEFT, -1); ! m_listCtrl->InsertColumn(4, wxT("Value"), wxLIST_FORMAT_LEFT, -1); int txt_width = 0, txt_height = 0; ! m_listCtrl->GetTextExtent(wxT("WWWWWWWWWWWWWWWWWWWW"), &txt_width, &txt_height); m_listCtrl->SetColumnWidth(0, txt_width); ! m_listCtrl->SetColumnWidth(4, txt_width); // make it wide since it's the last m_listCtrl->GetTextExtent(wxT("555:5555"), &txt_width, &txt_height); m_listCtrl->SetColumnWidth(1, txt_width); --- 334,350 ---- m_listCtrl->SetImageList(m_imageList, wxIMAGE_LIST_SMALL); ! m_listCtrl->InsertColumn(LIST_COL_KEY, wxT("Name"), wxLIST_FORMAT_LEFT, -1); ! m_listCtrl->InsertColumn(LIST_COL_LEVEL, wxT("Level"), wxLIST_FORMAT_LEFT, -1); ! m_listCtrl->InsertColumn(LIST_COL_KEY_TYPE, wxT("Key Type"), wxLIST_FORMAT_LEFT, -1); ! m_listCtrl->InsertColumn(LIST_COL_VALUE_TYPE, wxT("Value Type"), wxLIST_FORMAT_LEFT, -1); ! m_listCtrl->InsertColumn(LIST_COL_VALUE, wxT("Value"), wxLIST_FORMAT_LEFT, -1); int txt_width = 0, txt_height = 0; ! m_listCtrl->GetTextExtent(wxString(wxT('W'), 25), &txt_width, &txt_height); ! ! m_listCtrl->SetColumnWidth(0, txt_width); ! m_listCtrl->SetColumnWidth(4, 4*txt_width); // make it wide since it's the last m_listCtrl->GetTextExtent(wxT("555:5555"), &txt_width, &txt_height); m_listCtrl->SetColumnWidth(1, txt_width); *************** *** 379,397 **** dc.SelectObject(bmp); wxCoord w = 0, h = 0; ! for (int n = 14; n > 3; n--) { ! wxFont f(n, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); ! dc.GetTextExtent(s, &w, &h, NULL, NULL, &f); if ((w < bmp_w) && (h < bmp_h)) - { - dc.SetFont(f); break; ! } } dc.DrawText(s, (bmp_w-w)/2, (bmp_h-h)/2); - dc.SelectObject(wxNullBitmap); --- 404,423 ---- dc.SelectObject(bmp); + wxFont font(m_img_font_size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); wxCoord w = 0, h = 0; ! ! // after first time to find font size, run once to get the text extent ! for ( ; m_img_font_size > 3; --m_img_font_size) { ! dc.GetTextExtent(s, &w, &h, NULL, NULL, &font); if ((w < bmp_w) && (h < bmp_h)) break; ! ! font.SetPointSize(m_img_font_size); } + dc.SetFont(font); dc.DrawText(s, (bmp_w-w)/2, (bmp_h-h)/2); dc.SelectObject(wxNullBitmap); *************** *** 408,411 **** --- 434,439 ---- if (dbgItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) img = IMG_TABLE_OPEN; + else if (dbgItem->GetFlagBit(WXLUA_DEBUGITEM_LOCALS)) + img = IMG_TABLE; else { *************** *** 440,444 **** switch (column) { ! case 0: { if (exact_value) --- 468,472 ---- switch (column) { ! case LIST_COL_KEY: { if (exact_value) *************** *** 455,465 **** 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) --- 483,493 ---- return debugItem->GetKey(); } ! case LIST_COL_LEVEL: return wxString::Format(wxT("%d:%d"), stkListData->m_level+1, stkListData->m_item_idx+1); ! case LIST_COL_KEY_TYPE: return debugItem->GetKeyTypeString(); ! case LIST_COL_VALUE_TYPE: return debugItem->GetValueTypeString(); ! case LIST_COL_VALUE: { if (exact_value) *************** *** 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 localData.Add(localItem); --- 577,582 ---- // Add the locals, fake a debug item to get it setup right wxLuaDebugItem* localItem = new wxLuaDebugItem(_("Locals"), WXLUAARG_None, ! wxString::Format(wxT("%d Items"), (int)debugData.GetCount()), WXLUAARG_None, ! wxT(""), LUA_NOREF, 0, WXLUA_DEBUGITEM_EXPANDED|WXLUA_DEBUGITEM_LOCALS|WXLUA_DEBUGITEM_VALUE_REF); wxLuaDebugData localData(true); // this deletes the items localData.Add(localItem); *************** *** 624,628 **** int img = GetItemImage(debugItem); ! if (debugItem->GetReference() != LUA_NOREF) { wxTreeItemId id = m_treeCtrl->AppendItem(treeId, debugItem->GetKey(), -1, -1, new wxLuaStackTreeData(stkListData)); --- 652,657 ---- int img = GetItemImage(debugItem); ! if ((debugItem->GetRef() != LUA_NOREF) || ! debugItem->GetFlagBit(WXLUA_DEBUGITEM_LOCALS)) { wxTreeItemId id = m_treeCtrl->AppendItem(treeId, debugItem->GetKey(), -1, -1, new wxLuaStackTreeData(stkListData)); *************** *** 990,994 **** wxCHECK_MSG(debugItem != NULL, false, wxT("Invalid debug item")); ! int nRef = debugItem->GetReference(); if (!debugItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) --- 1019,1023 ---- wxCHECK_MSG(debugItem != NULL, false, wxT("Invalid debug item")); ! int nRef = debugItem->GetRef(); if (!debugItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) *************** *** 999,1006 **** 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); --- 1028,1034 ---- debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); ! long long_key = 0; ! if (debugItem->GetRefPtr(long_key)) ! m_expandedItems[long_key] = (long)stkListData; FillTableEntry(lc_item, stkListData->m_childrenDebugData); *************** *** 1010,1020 **** // Check and block linked tables already shown, select it and return ! 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) --- 1038,1047 ---- // Check and block linked tables already shown, select it and return ! if (debugItem->GetRef() != LUA_NOREF) { ! long long_key = 0; ! wxCHECK_MSG(debugItem->GetRefPtr(long_key), false, wxT("Invalid table item")); ! if (m_expandedItems[long_key]) { if (m_show_dup_expand_msg) *************** *** 1023,1027 **** 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.")); --- 1050,1054 ---- wxT("wxLua Stack"), wxOK | wxCENTRE, this); ! int n = m_listData.Index((void*)m_expandedItems[long_key]); wxCHECK_MSG(n != wxNOT_FOUND, false, wxT("Unable to find hash of expanded items.")); *************** *** 1039,1046 **** debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); ! 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; --- 1066,1072 ---- debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); ! long long_key = 0; ! wxCHECK_MSG(debugItem->GetRefPtr(long_key), false, wxT("Invalid table item")); ! m_expandedItems[long_key] = (long)stkListData; int nIndex = debugItem->GetIndex() + 1; *************** *** 1136,1143 **** 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); --- 1162,1168 ---- stkListData_n->GetDebugItem()->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) { ! long long_key = 0; ! if (stkListData_n->GetDebugItem()->GetRefPtr(long_key)) ! m_expandedItems.erase(long_key); CollapseItem(n); *************** *** 1170,1177 **** debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, false); ! wxString val(debugItem->GetValue()); ! long vkey = 0; ! if (val.BeforeFirst(wxT(' ')).ToLong(&vkey, 16)) ! m_expandedItems.erase(vkey); } --- 1195,1201 ---- debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, false); ! long long_key = 0; ! if (debugItem->GetRefPtr(long_key)) ! m_expandedItems.erase(long_key); } *************** *** 1217,1224 **** wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); ! if (debugItem && (debugItem->GetReference() != LUA_NOREF) && debugItem->GetFlagBit(WXLUA_DEBUGITEM_LUAREFED)) { ! int lua_ref = debugItem->GetReference(); int ok = m_wxlState.wxluaR_Unref(lua_ref); debugItem->SetReference(LUA_NOREF); --- 1241,1248 ---- wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); ! if (debugItem && (debugItem->GetRef() != LUA_NOREF) && debugItem->GetFlagBit(WXLUA_DEBUGITEM_LUAREFED)) { ! int lua_ref = debugItem->GetRef(); int ok = m_wxlState.wxluaR_Unref(lua_ref); debugItem->SetReference(LUA_NOREF); *************** *** 1228,1232 **** 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); } } --- 1252,1256 ---- 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->GetRef(), m_luaReferences.GetCount(), idx); } } Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** wxldebug.cpp 10 Dec 2007 23:20:19 -0000 1.58 --- wxldebug.cpp 13 Dec 2007 00:47:53 -0000 1.59 *************** *** 29,40 **** const wxString &itemValue, int itemValueType, const wxString &itemSource, ! int lua_ref, ! int idx, ! int flag) :m_itemKey(itemKey), m_itemKeyType(itemKeyType), m_itemValue(itemValue), m_itemValueType(itemValueType), m_itemSource(itemSource), ! m_lua_ref(lua_ref), m_index(idx), ! m_flag(flag) { } --- 29,37 ---- const wxString &itemValue, int itemValueType, const wxString &itemSource, ! int lua_ref, int idx, int flag) :m_itemKey(itemKey), m_itemKeyType(itemKeyType), m_itemValue(itemValue), m_itemValueType(itemValueType), m_itemSource(itemSource), ! m_lua_ref(lua_ref), m_index(idx), m_flag(flag) { } *************** *** 49,52 **** --- 46,61 ---- } + bool wxLuaDebugItem::GetRefPtr(long& ptr) const + { + bool key_ref = GetFlagBit(WXLUA_DEBUGITEM_KEY_REF); + bool val_ref = GetFlagBit(WXLUA_DEBUGITEM_VALUE_REF); + + // sanity checks + wxCHECK_MSG((key_ref || val_ref), false, wxT("wxLuaDebugItem has neither key or value reference")); + wxCHECK_MSG(!(key_ref && val_ref), false, wxT("wxLuaDebugItem has both key and value reference")); + + return wxString(key_ref ? m_itemKey: m_itemValue).BeforeFirst(wxT(' ')).ToLong(&ptr, 16); + } + // ---------------------------------------------------------------------------- // wxLuaDebugData - Debug Info sent via socket to debugger client *************** *** 140,151 **** if (ret == 0) // can be true for unnamed "(*temporary)" vars { ! ret = elem1->GetKeyType() - elem2->GetKeyType(); if (ret == 0) { ! ret = elem1->GetValueType() - elem2->GetValueType(); if (ret == 0) ! ret = elem1->GetValue().Cmp(elem2->GetValue()); } } --- 149,166 ---- if (ret == 0) // can be true for unnamed "(*temporary)" vars { ! ret = elem1->m_itemKeyType - elem2->m_itemKeyType; if (ret == 0) { ! ret = elem1->m_itemValueType - elem2->m_itemValueType; if (ret == 0) ! { ! ret = elem1->m_itemValue.Cmp(elem2->m_itemValue); ! ! if (ret == 0) ! ret = int(elem2->GetFlagBit(WXLUA_DEBUGITEM_KEY_REF)) - ! int(elem1->GetFlagBit(WXLUA_DEBUGITEM_KEY_REF)); ! } } } *************** *** 186,190 **** name = wxString::Format(_("line %d"), currentLine); ! Add(new wxLuaDebugItem(name, WXLUAARG_None, wxT(""), WXLUAARG_None, source, LUA_NOREF, stack_frame, 0)); ++count; } --- 201,205 ---- name = wxString::Format(_("line %d"), currentLine); ! Add(new wxLuaDebugItem(name, WXLUAARG_None, wxT(""), WXLUAARG_None, source, LUA_NOREF, stack_frame, WXLUA_DEBUGITEM_LOCALS)); ++count; } *************** *** 273,280 **** int flag_type = 0; ! int nRef = RefTable(L, -1, &flag_type, references); lua_pop(L, 1); // pop globals table ! Add(new wxLuaDebugItem(wxT("Globals"), WXLUAARG_None, value, WXLUAARG_Table, wxT(""), nRef, 0, flag_type)); } else if (tableRef == LUA_REGISTRYINDEX) --- 288,295 ---- int flag_type = 0; ! int val_ref = RefTable(L, -1, &flag_type, WXLUA_DEBUGITEM_VALUE_REF, references); lua_pop(L, 1); // pop globals table ! Add(new wxLuaDebugItem(wxT("Globals"), WXLUAARG_None, value, WXLUAARG_Table, wxT(""), val_ref, 0, flag_type)); } else if (tableRef == LUA_REGISTRYINDEX) *************** *** 284,291 **** int flag_type = 0; ! int nRef = RefTable(L, -1, &flag_type, references); lua_pop(L, 1); // pop registry table ! Add(new wxLuaDebugItem(wxT("Registry"), WXLUAARG_None, value, WXLUAARG_Table, wxT(""), nRef, 0, WXLUA_DEBUGITEM_LUAREFED)); } else --- 299,306 ---- int flag_type = 0; ! int val_ref = RefTable(L, -1, &flag_type, WXLUA_DEBUGITEM_VALUE_REF, references); lua_pop(L, 1); // pop registry table ! Add(new wxLuaDebugItem(wxT("Registry"), WXLUAARG_None, value, WXLUAARG_Table, wxT(""), val_ref, 0, flag_type)); } else *************** *** 318,325 **** int flag_type = 0; ! 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; --- 333,340 ---- int flag_type = 0; ! int val_ref = RefTable(L, -1, &flag_type, WXLUA_DEBUGITEM_VALUE_REF, references); // leading space so it's first when sorted ! Add(new wxLuaDebugItem(wxT(" __metatable"), WXLUAARG_Table, value, wxl_valuetype, wxT(""), val_ref, nIndex, flag_type)); ++count; *************** *** 377,381 **** name += wxT(" ") + wxString(win->GetClassInfo()->GetClassName()); } ! else if (lightuserdata_reg_key == &wxlua_lreg_delobjects_key) { wxObject* obj = (wxObject*)lua_touserdata(L, -1); --- 392,396 ---- name += wxT(" ") + wxString(win->GetClassInfo()->GetClassName()); } ! else if (lightuserdata_reg_key == &wxlua_lreg_gcobjects_key) { wxObject* obj = (wxObject*)lua_touserdata(L, -1); *************** *** 400,419 **** } ! int flag_type = 0; ! int nRef = LUA_NOREF; // don't ref anything in this table since it's already refed if ((lua_value_type == LUA_TTABLE) && (lightuserdata_reg_key != &wxlua_lreg_debug_refs_key)) ! nRef = RefTable(L, -1, &flag_type, references); else if (lua_value_type == LUA_TUSERDATA) { if (lua_getmetatable(L, -1)) // doesn't push anything if nil { ! 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; lua_pop(L, 1); // pop value, leave key --- 415,466 ---- } ! // ---------------------------------------------------------- ! // Handle the key ! ! int key_flag_type = 0; ! int key_ref = LUA_NOREF; ! ! // don't ref anything in this table since it's already refed ! if ((lua_key_type == LUA_TTABLE) && (lightuserdata_reg_key != &wxlua_lreg_debug_refs_key)) ! key_ref = RefTable(L, -2, &key_flag_type, WXLUA_DEBUGITEM_KEY_REF, references); ! else if (lua_key_type == LUA_TUSERDATA) ! { ! if (lua_getmetatable(L, -2)) // doesn't push anything if nil ! { ! key_ref = RefTable(L, -2, &key_flag_type, WXLUA_DEBUGITEM_KEY_REF, references); ! lua_pop(L, 1); ! } ! } ! ! // only add the key if we refed it so it can be viewed in the stack dialog ! if (key_flag_type != 0) ! { ! Add(new wxLuaDebugItem(name, wxl_keytype, value, wxl_valuetype, wxT(""), key_ref, nIndex, key_flag_type)); ! ++count; ! } ! ! // ---------------------------------------------------------- ! // Handle the value ! ! int val_flag_type = 0; ! int val_ref = LUA_NOREF; ! // don't ref anything in this table since it's already refed if ((lua_value_type == LUA_TTABLE) && (lightuserdata_reg_key != &wxlua_lreg_debug_refs_key)) ! val_ref = RefTable(L, -1, &val_flag_type, WXLUA_DEBUGITEM_VALUE_REF, references); else if (lua_value_type == LUA_TUSERDATA) { if (lua_getmetatable(L, -1)) // doesn't push anything if nil { ! val_ref = RefTable(L, -1, &val_flag_type, WXLUA_DEBUGITEM_VALUE_REF, references); lua_pop(L, 1); } } ! 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; ! } lua_pop(L, 1); // pop value, leave key *************** *** 428,449 **** } ! int wxLuaDebugData::RefTable(lua_State* L, int stack_idx, int* flag_type, wxArrayInt& references) { wxCHECK_MSG(L, LUA_NOREF, wxT("Invalid lua_State")); ! int nRef = LUA_NOREF; //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) { ! if (flag_type) *flag_type |= WXLUA_DEBUGITEM_LUAREFED; ! nRef = wxluaR_ref(L, -1, &wxlua_lreg_debug_refs_key); ! references.Add(nRef); } } ! return nRef; } --- 475,496 ---- } ! int wxLuaDebugData::RefTable(lua_State* L, int stack_idx, int* flag_type, int extra_flag, wxArrayInt& references) { wxCHECK_MSG(L, LUA_NOREF, wxT("Invalid lua_State")); ! int lua_ref = LUA_NOREF; //if (lua_istable(L, stack_idx)) { //nRef = wxluaR_isrefed(L, stack_idx, &wxlua_lreg_debug_refs_key); // don't duplicate refs ! if (lua_ref == LUA_NOREF) { ! if (flag_type) *flag_type |= (WXLUA_DEBUGITEM_IS_REFED | extra_flag); ! lua_ref = wxluaR_ref(L, stack_idx, &wxlua_lreg_debug_refs_key); ! references.Add(lua_ref); } } ! return lua_ref; } *************** *** 569,573 **** (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) || --- 616,620 ---- (udata == &wxlua_lreg_wxluastate_key) || (udata == &wxlua_lreg_weakobjects_key) || ! (udata == &wxlua_lreg_gcobjects_key) || (udata == &wxlua_lreg_evtcallbacks_key) || (udata == &wxlua_lreg_windestroycallbacks_key) || *************** *** 626,629 **** --- 673,678 ---- m_luaState, m_msg.c_str(), msg.c_str(), m_top, lua_gettop(m_luaState)); + if (m_top != lua_gettop(m_luaState)) s += wxT(" **********"); // easy to find + OutputMsg(s); |