From: John L. <jr...@us...> - 2009-11-23 05:29:14
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv28770/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: Some cleanup for the wxLuaStackDialog Fix showing local variable tables Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** wxlstack.cpp 21 Nov 2009 20:24:02 -0000 1.34 --- wxlstack.cpp 23 Nov 2009 05:29:01 -0000 1.35 *************** *** 68,76 **** virtual wxListItemAttr *OnGetItemAttr(long item) const; - wxListItemAttr m_itemAttr; wxLuaStackDialog* m_stkDlg; }; - wxString wxLuaStackListCtrl::OnGetItemText(long item, long column) const { --- 68,74 ---- *************** *** 83,145 **** 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]; ! wxCHECK_MSG(stkListData, -1, wxT("Invalid wxLuaStackListData item")); ! wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); ! wxCHECK_MSG(debugItem, -1, wxT("Invalid wxLuaDebugItem item")); ! ! switch (column) ! { ! case wxLuaStackDialog::LIST_COL_KEY : ! { ! return m_stkDlg->GetItemImage(debugItem); ! } ! case 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; ! } ! break; ! } ! case 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; ! } ! break; ! } ! } ! } ! ! return -1; } wxListItemAttr *wxLuaStackListCtrl::OnGetItemAttr(long item) const { ! wxLuaStackListData* stkListData = (wxLuaStackListData*)m_stkDlg->m_listData[item]; ! wxCHECK_MSG(stkListData, NULL, wxT("Invalid wxLuaStackListData item")); ! wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); ! wxCHECK_MSG(debugItem, NULL, wxT("Invalid wxLuaDebugItem item")); ! ! int img = m_stkDlg->GetItemImage(debugItem); ! ! wxLuaStackListCtrl* stkCtrl = (wxLuaStackListCtrl*)this; // unconst ! ! stkCtrl->m_itemAttr.SetTextColour(m_stkDlg->m_typeColours[img]); ! ! //unsigned char c = 255 - (stkListData->m_level % 5)*22; ! //stkCtrl->m_itemAttr.SetBackgroundColour(wxColour(c,c,c)); ! ! return &stkCtrl->m_itemAttr; } --- 81,89 ---- int wxLuaStackListCtrl::OnGetItemColumnImage(long item, long column) const { ! return m_stkDlg->GetItemColumnImage(item, column); } wxListItemAttr *wxLuaStackListCtrl::OnGetItemAttr(long item) const { ! return m_stkDlg->GetItemAttr(item); } *************** *** 439,443 **** } ! int wxLuaStackDialog::GetItemImage(const wxLuaDebugItem *dbgItem) { wxCHECK_MSG(dbgItem, IMG_UNKNOWN, wxT("Invalid wxLuaDebugItem")); --- 383,387 ---- } ! int wxLuaStackDialog::GetItemImage(const wxLuaDebugItem *dbgItem) const { wxCHECK_MSG(dbgItem, IMG_UNKNOWN, wxT("Invalid wxLuaDebugItem")); *************** *** 519,522 **** --- 463,541 ---- } + int wxLuaStackDialog::GetItemColumnImage(long item, long column) const + { + if ((column == LIST_COL_KEY) || + (column == LIST_COL_KEY_TYPE) || + (column == LIST_COL_VALUE_TYPE)) + { + wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[item]; + wxCHECK_MSG(stkListData, -1, wxT("Invalid wxLuaStackListData item")); + wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); + wxCHECK_MSG(debugItem, -1, wxT("Invalid wxLuaDebugItem item")); + + switch (column) + { + case LIST_COL_KEY : + { + return GetItemImage(debugItem); + } + case LIST_COL_KEY_TYPE : + { + if (debugItem->GetFlagBit(WXLUA_DEBUGITEM_KEY_REF)) + { + if (debugItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) + return IMG_TABLE_OPEN; + else + return IMG_TABLE; + } + break; + } + case LIST_COL_VALUE_TYPE : + { + if (debugItem->GetFlagBit(WXLUA_DEBUGITEM_VALUE_REF)) + { + if (debugItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) + return IMG_TABLE_OPEN; + else + return IMG_TABLE; + } + break; + } + } + } + + return -1; + } + + wxListItemAttr *wxLuaStackDialog::GetItemAttr(long item) const + { + wxLuaStackListData* stkListData = (wxLuaStackListData*)m_listData[item]; + wxCHECK_MSG(stkListData, NULL, wxT("Invalid wxLuaStackListData item")); + wxLuaDebugItem* debugItem = stkListData->GetDebugItem(); + wxCHECK_MSG(debugItem, NULL, wxT("Invalid wxLuaDebugItem item")); + + int img = GetItemImage(debugItem); + + wxLuaStackDialog* stkDlg = (wxLuaStackDialog*)this; // unconst this + + stkDlg->m_itemAttr.SetTextColour(m_typeColours[img]); + + //unsigned char c = 255 - (stkListData->m_level % 5)*22; + //stkDlg->m_itemAttr.SetBackgroundColour(wxColour(c,c,c)); + + return &stkDlg->m_itemAttr; + } + + void wxLuaStackDialog::SelectStack(int stack_sel) + { + wxCHECK_RET((stack_sel >= 0) && (stack_sel < (int)m_stackEntries.GetCount()), wxT("Invalid stack index")); + + RemoveAllLuaReferences(); // remove them now since we're starting from scratch + + m_stack_sel = stack_sel; + int n_entry = m_stackEntries[m_stack_sel]; + EnumerateStackEntry(n_entry); + } + void wxLuaStackDialog::EnumerateStack() { *************** *** 572,576 **** wxCHECK_RET(debugData.Ok(), wxT("Invalid wxLuaDebugData in FillStackEntry")); - RemoveAllLuaReferences(); DeleteAllListItemData(); m_expandedItems.clear(); --- 591,594 ---- *************** *** 593,597 **** // If at global scope, process globals ! if (m_stack_sel == (int)m_stackEntries.GetCount() - 1) { // When used with the wxLuaDebuggerServer we get delayed responses --- 611,615 ---- // If at global scope, process globals ! //if (m_stack_sel == (int)m_stackEntries.GetCount() - 1) { // When used with the wxLuaDebuggerServer we get delayed responses *************** *** 675,680 **** wxTreeItemIdValue dummyCookie; wxTreeItemId dummyId = m_treeCtrl->GetFirstChild(treeId, dummyCookie); ! if (m_treeCtrl->GetItemText(dummyId) == DUMMY_TREEITEM) m_treeCtrl->Delete(dummyId); } } --- 693,701 ---- wxTreeItemIdValue dummyCookie; wxTreeItemId dummyId = m_treeCtrl->GetFirstChild(treeId, dummyCookie); ! if ((m_treeCtrl->GetItemText(dummyId) == DUMMY_TREEITEM) && ! (m_treeCtrl->GetItemData(dummyId) == NULL)) ! { m_treeCtrl->Delete(dummyId); + } } } *************** *** 919,930 **** } - void wxLuaStackDialog::SelectStack(int stack_sel) - { - wxCHECK_RET((stack_sel >= 0) && (stack_sel < (int)m_stackEntries.GetCount()), wxT("Invalid stack index")); - m_stack_sel = stack_sel; - int n_entry = m_stackEntries[m_stack_sel]; - EnumerateStackEntry(n_entry); - } - void wxLuaStackDialog::OnTreeItem(wxTreeEvent &event) { --- 940,943 ---- *************** *** 1038,1050 **** FillTableEntry(lc_item, stkListData->m_childrenDebugData); ! return true; // expanded = true } ! ! // 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]) // linked tables { --- 1051,1062 ---- FillTableEntry(lc_item, stkListData->m_childrenDebugData); ! expanded = true; } ! else if (debugItem->GetRef() != LUA_NOREF) { long long_key = 0; wxCHECK_MSG(debugItem->GetRefPtr(long_key), false, wxT("Invalid table item")); + // Check and block linked tables already shown, select it and return if (m_expandedItems[long_key]) // linked tables { *************** *** 1064,1068 **** } } ! else { debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); --- 1076,1080 ---- } } ! else // new item to enumerate and expand { debugItem->SetFlagBit(WXLUA_DEBUGITEM_EXPANDED, true); Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** wxldebug.cpp 21 Nov 2009 20:24:02 -0000 1.72 --- wxldebug.cpp 23 Nov 2009 05:29:00 -0000 1.73 *************** *** 232,252 **** wxString source(lua2wx(luaDebug.source)); ! GetTypeValue(L, -1, &wxl_valuetype, value); ! ! // FIXME! local tables get the right values for GetTypeValue(...) ! // but when you run wxluaR_ref() to store them they disappear ! // so that the next time wxluaR_ref() is run it reuses the same ! // index as your local table. ! // When using the stack dialog the next wxluaR_ref() is the ! // global table which is very confusing. ! int flag_type = 0; ! int nRef = LUA_NOREF; //RefTable(L, -1, &flag_type, references); ! lua_pop(L, 1); // remove variable value ! Add(new wxLuaDebugItem(name, WXLUA_TNONE, value, wxl_valuetype, source, nRef, 0, flag_type)); ++count; name = lua2wx(lua_getlocal(L, &luaDebug, ++stack_idx)); } --- 232,258 ---- wxString source(lua2wx(luaDebug.source)); ! int lua_value_type = GetTypeValue(L, -1, &wxl_valuetype, value); ! int val_flag_type = 0; ! int val_ref = LUA_NOREF; ! if (lua_value_type == LUA_TTABLE) ! { ! 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); ! } ! } ! Add(new wxLuaDebugItem(name, WXLUA_TNONE, value, wxl_valuetype, source, val_ref, 0, val_flag_type)); ++count; + lua_pop(L, 1); // remove variable value + name = lua2wx(lua_getlocal(L, &luaDebug, ++stack_idx)); } *************** *** 337,344 **** 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 the table/userdata has a metatable if (lua_getmetatable(L, -1)) // if no metatable then nothing is pushed { --- 343,350 ---- lua_pushvalue(L, -2); // push value (table we're iterating) lua_rawget(L, -2); ! lightuserdata_reg_key = lua_touserdata(L, -1); // returns NULL for nil lua_pop(L, 2); // pop wxlua_lreg_regtable_key table and (nil or lightuserdata) ! // Check if this table/userdata has a metatable if (lua_getmetatable(L, -1)) // if no metatable then nothing is pushed { *************** *** 369,373 **** int lua_value_type = GetTypeValue(L, -1, &wxl_valuetype, value); ! // Handle wxLua LUA_REGISTRYINDEX tables to give more information if (lightuserdata_reg_key != NULL) { --- 375,379 ---- int lua_value_type = GetTypeValue(L, -1, &wxl_valuetype, value); ! // Handle items within the wxLua LUA_REGISTRYINDEX tables to give more information if (lightuserdata_reg_key != NULL) { *************** *** 410,414 **** wxWindow* win = (wxWindow*)lua_touserdata(L, -2); name += wxT(" ") + wxString(win->GetClassInfo()->GetClassName()); ! } else if (lightuserdata_reg_key == &wxlua_lreg_gcobjects_key) { --- 416,420 ---- wxWindow* win = (wxWindow*)lua_touserdata(L, -2); name += wxT(" ") + wxString(win->GetClassInfo()->GetClassName()); ! } else if (lightuserdata_reg_key == &wxlua_lreg_gcobjects_key) { *************** *** 440,444 **** void* key = lua_touserdata(L, -2); ! if (key == &wxlua_metatable_type_key) { value += wxString::Format(wxT(" (%s)"), wxluaT_typename(L, (int)lua_tonumber(L, -1)).c_str()); --- 446,460 ---- void* key = lua_touserdata(L, -2); ! if (key == &wxlua_lreg_wxeventtype_key) ! { ! wxEventType eventType = (wxEventType)lua_tonumber(L, -1); ! const wxLuaBindEvent* wxlEvent = wxLuaBinding::FindBindEvent(eventType); ! ! if (wxlEvent != NULL) ! { ! value = wxString::Format(wxT("%d = %s : %s"), eventType, lua2wx(wxlEvent->name).c_str(), wxluaT_typename(L, *wxlEvent->wxluatype).c_str()); ! } ! } ! else if (key == &wxlua_metatable_type_key) { value += wxString::Format(wxT(" (%s)"), wxluaT_typename(L, (int)lua_tonumber(L, -1)).c_str()); *************** *** 502,505 **** --- 518,522 ---- } + // Add the value, but not if the value doesn't expand and the key was already added if ((key_flag_type == 0) || ((key_flag_type != 0) && (val_flag_type != 0))) { *************** *** 524,534 **** 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); --- 541,553 ---- int lua_ref = LUA_NOREF; ! ! if (lua_istable(L, stack_idx)) { ! if (flag_type) *flag_type |= (WXLUA_DEBUGITEM_IS_REFED | extra_flag); ! ! lua_ref = wxluaR_isrefed(L, stack_idx, &wxlua_lreg_debug_refs_key); // don't duplicate refs if (lua_ref == LUA_NOREF) { lua_ref = wxluaR_ref(L, stack_idx, &wxlua_lreg_debug_refs_key); references.Add(lua_ref); |