From: John L. <jr...@us...> - 2007-11-08 23:47:19
|
Update of /cvsroot/wxlua/wxLua/modules/wxluadebug/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv10188/wxLua/modules/wxluadebug/src Modified Files: wxldebug.cpp wxlstack.cpp Log Message: Add storage for key and value datatype in wxLuaDebugItem and show it in the stack dialog Index: wxlstack.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxlstack.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** wxlstack.cpp 8 Aug 2007 22:49:32 -0000 1.15 --- wxlstack.cpp 8 Nov 2007 23:47:15 -0000 1.16 *************** *** 41,44 **** --- 41,46 ---- + #define WXLUAARG_WXLUADATA (WXLUAARG__MIN - 100) + // ---------------------------------------------------------------------------- // wxLuaStackDialog *************** *** 95,100 **** wxBitmap bmp(wxArtProvider::GetIcon(wxART_NORMAL_FILE, wxART_TOOLBAR, wxSize(16,16))); - m_imageList->Add(bmp); // IMG_UNKNOWN m_imageList->Add(bmp); // IMG_NONE m_imageList->Add(CreateBmpString(bmp, wxT("0"))); // IMG_NIL m_imageList->Add(CreateBmpString(bmp, wxT("b"))); // IMG_BOOLEAN --- 97,102 ---- wxBitmap bmp(wxArtProvider::GetIcon(wxART_NORMAL_FILE, wxART_TOOLBAR, wxSize(16,16))); m_imageList->Add(bmp); // IMG_NONE + m_imageList->Add(bmp); // IMG_UNKNOWN m_imageList->Add(CreateBmpString(bmp, wxT("0"))); // IMG_NIL m_imageList->Add(CreateBmpString(bmp, wxT("b"))); // IMG_BOOLEAN *************** *** 106,109 **** --- 108,112 ---- m_imageList->Add(CreateBmpString(bmp, wxT("u"))); // IMG_USERDATA m_imageList->Add(CreateBmpString(bmp, wxT("t"))); // IMG_THREAD + m_imageList->Add(CreateBmpString(bmp, wxT("1"))); // IMG_INTEGER m_imageList->Add(CreateBmpString(bmp, wxT("c"))); // IMG_CFUNCTION m_imageList->Add(wxArtProvider::GetIcon(wxART_NEW_DIR, wxART_TOOLBAR, wxSize(16,16))); // IMG_TABLE_OPEN *************** *** 111,116 **** // ----------------------------------------------------------------------- - m_typeColours[IMG_UNKNOWN] = wxColour(wxT("DARK TURQUOISE")); m_typeColours[IMG_NONE] = wxColour(wxT("DARK TURQUOISE")); m_typeColours[IMG_NIL] = wxColour(wxT("BLACK")); m_typeColours[IMG_BOOLEAN] = wxColour(wxT("FIREBRICK")); --- 114,119 ---- // ----------------------------------------------------------------------- m_typeColours[IMG_NONE] = wxColour(wxT("DARK TURQUOISE")); + m_typeColours[IMG_UNKNOWN] = wxColour(wxT("DARK TURQUOISE")); m_typeColours[IMG_NIL] = wxColour(wxT("BLACK")); m_typeColours[IMG_BOOLEAN] = wxColour(wxT("FIREBRICK")); *************** *** 122,125 **** --- 125,129 ---- m_typeColours[IMG_USERDATA] = wxColour(wxT("CORNFLOWER BLUE")); m_typeColours[IMG_THREAD] = wxColour(wxT("BLACK")); + m_typeColours[IMG_INTEGER] = wxColour(wxT("DARK ORCHID")); m_typeColours[IMG_CFUNCTION] = wxColour(wxT("FOREST GREEN")); m_typeColours[IMG_TABLE_OPEN] = wxColour(wxT("BLUE")); *************** *** 205,213 **** wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_HRULES|wxLC_VRULES ); ! 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("Type"), wxLIST_FORMAT_LEFT, -1); ! m_listCtrl->InsertColumn(3, wxT("Value"), wxLIST_FORMAT_LEFT, -1); int txt_width = 0, txt_height = 0; --- 209,218 ---- wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_HRULES|wxLC_VRULES ); ! 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; *************** *** 215,223 **** m_listCtrl->GetTextExtent(wxT("WWWWWWWWWWWWWWWWWWWW"), &txt_width, &txt_height); m_listCtrl->SetColumnWidth(0, txt_width); ! m_listCtrl->SetColumnWidth(3, 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); m_listCtrl->GetTextExtent(wxT("Light User DataX"), &txt_width, &txt_height); m_listCtrl->SetColumnWidth(2, txt_width); // ----------------------------------------------------------------------- --- 220,229 ---- 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); m_listCtrl->GetTextExtent(wxT("Light User DataX"), &txt_width, &txt_height); m_listCtrl->SetColumnWidth(2, txt_width); + m_listCtrl->SetColumnWidth(3, txt_width); // ----------------------------------------------------------------------- *************** *** 281,290 **** wxCHECK_MSG(dbgItem, IMG_UNKNOWN, wxT("Invalid wxLuaDebugItem")); ! int img = dbgItem->GetTypeN(); // now fix up the images for special cases if (dbgItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) img = IMG_TABLE_OPEN; ! else if (dbgItem->GetType() == wxT("wxLuaData")) // our internal data structs img = IMG_TABLE; --- 287,314 ---- wxCHECK_MSG(dbgItem, IMG_UNKNOWN, wxT("Invalid wxLuaDebugItem")); ! //int img = WXLUAARG_TO_POSINDEX(dbgItem->GetValueType()); ! int img = IMG_NONE; ! ! switch (dbgItem->GetValueType()) ! { ! case WXLUAARG_None : img = IMG_NONE; break; ! case WXLUAARG_Unknown : img = IMG_UNKNOWN; break; ! case WXLUAARG_Nil : img = IMG_NIL; break; ! case WXLUAARG_Boolean : img = IMG_BOOLEAN; break; ! case WXLUAARG_LightUserData : img = IMG_LIGHTUSERDATA; break; ! case WXLUAARG_Number : img = IMG_NUMBER; break; ! case WXLUAARG_String : img = IMG_STRING; break; ! case WXLUAARG_Table : img = IMG_TABLE; break; ! case WXLUAARG_Function : img = IMG_LUAFUNCTION; break; ! case WXLUAARG_UserData : img = IMG_USERDATA; break; ! case WXLUAARG_Thread : img = IMG_THREAD; break; ! case WXLUAARG_Integer : img = IMG_INTEGER; break; ! case WXLUAARG_CFunction : img = IMG_CFUNCTION; break; ! } // now fix up the images for special cases if (dbgItem->GetFlagBit(WXLUA_DEBUGITEM_EXPANDED)) img = IMG_TABLE_OPEN; ! else if (dbgItem->GetValueType() == WXLUAARG_WXLUADATA) // our internal data structs img = IMG_TABLE; *************** *** 356,360 **** const wxLuaDebugItem *item = debugData.Item(n); m_stackEntries.Add(item->GetIndex()); ! wxString name(item->GetName()); if (n == count - 1) name += wxT(" (Globals)"); m_stackChoice->Append(name); --- 380,384 ---- const wxLuaDebugItem *item = debugData.Item(n); m_stackEntries.Add(item->GetIndex()); ! wxString name(item->GetKey()); if (n == count - 1) name += wxT(" (Globals)"); m_stackChoice->Append(name); *************** *** 381,386 **** // Add the locals, fake a debug item to get it setup right ! wxLuaDebugItem* localItem = new wxLuaDebugItem(_("Locals"), wxT("table"), ! wxString::Format(wxT("Count %d"), (int)debugData.GetCount()), wxT(""), LUA_NOREF, 0, WXLUA_DEBUGITEM_EXPANDED); wxLuaDebugData localData(true); // this deletes the items --- 405,410 ---- // Add the locals, fake a debug item to get it setup right ! wxLuaDebugItem* localItem = new wxLuaDebugItem(_("Locals"), WXLUAARG_Table, ! wxString::Format(wxT("Count %d"), (int)debugData.GetCount()), WXLUAARG_Table, wxT(""), LUA_NOREF, 0, WXLUA_DEBUGITEM_EXPANDED); wxLuaDebugData localData(true); // this deletes the items *************** *** 461,465 **** wxListItem info; info.SetId(lc_item+1); ! info.SetText(levelStr + item->GetName()); wxLuaStackListData* stkListData = new wxLuaStackListData(n, debugData); info.SetData(stkListData); // we must delete this --- 485,489 ---- wxListItem info; info.SetId(lc_item+1); ! info.SetText(levelStr + item->GetKey()); wxLuaStackListData* stkListData = new wxLuaStackListData(n, debugData); info.SetData(stkListData); // we must delete this *************** *** 468,472 **** if ((img == IMG_TABLE) || (img == IMG_TABLE_OPEN)) { ! wxTreeItemId id = m_treeCtrl->AppendItem(treeId, item->GetName(), -1, -1, new wxLuaStackTreeData(stkListData)); m_treeCtrl->SetItemHasChildren(id); stkListData->m_treeId = id; --- 492,496 ---- if ((img == IMG_TABLE) || (img == IMG_TABLE_OPEN)) { ! wxTreeItemId id = m_treeCtrl->AppendItem(treeId, item->GetKey(), -1, -1, new wxLuaStackTreeData(stkListData)); m_treeCtrl->SetItemHasChildren(id); stkListData->m_treeId = id; *************** *** 488,492 **** m_listCtrl->SetItem(lc_item, 1, wxString::Format(wxT("%d:%d"), level+1, n+1)); ! m_listCtrl->SetItem(lc_item, 2, item->GetType()); // generic listctrl doesn't like showing huge strings, nor \n --- 512,517 ---- m_listCtrl->SetItem(lc_item, 1, wxString::Format(wxT("%d:%d"), level+1, n+1)); ! m_listCtrl->SetItem(lc_item, 2, item->GetKeyTypeString()); ! m_listCtrl->SetItem(lc_item, 3, item->GetValueTypeString()); // generic listctrl doesn't like showing huge strings, nor \n *************** *** 495,499 **** value.Replace(wxT("\n"), wxT("\\n")); value.Replace(wxT("\r"), wxT("\\r")); ! m_listCtrl->SetItem(lc_item, 3, value); } --- 520,524 ---- value.Replace(wxT("\n"), wxT("\\n")); value.Replace(wxT("\r"), wxT("\\r")); ! m_listCtrl->SetItem(lc_item, 4, value); } *************** *** 521,528 **** // note: don't have spaces here since we use them to mark expanded levels ! wxLuaDebugItem* trackedItem = new wxLuaDebugItem(_("Tracked User Data"), wxT("wxLuaData"), wxString::Format(wxT("Count %d"), trackedCount), wxT(""), LUA_NOREF, 0); ! wxLuaDebugItem* callbackItem = new wxLuaDebugItem(_("wxEvent Callbacks"), wxT("wxLuaData"), wxString::Format(wxT("Count %d"), callbackCount), wxT(""), LUA_NOREF, 0); ! wxLuaDebugItem* windowItem = new wxLuaDebugItem(_("Top Level wxWindows"), wxT("wxLuaData"), wxString::Format(wxT("Count %d"), windowCount), wxT(""), LUA_NOREF, 0); ! wxLuaDebugItem* destroyItem = new wxLuaDebugItem(_("wxWindow Destroy List"), wxT("wxLuaData"), wxString::Format(wxT("Count %d"), destroyCount), wxT(""), LUA_NOREF, 0); wxLuaDebugData dataArr(true); // this deletes the items --- 546,553 ---- // 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 *************** *** 814,818 **** // Check and block linked tables already shown, select it and return ! if (debugItem->GetType() == wxT("table")) { wxString val = debugItem->GetValue(); --- 839,843 ---- // Check and block linked tables already shown, select it and return ! if (debugItem->GetValueType() == WXLUAARG_Table) { wxString val = debugItem->GetValue(); *************** *** 846,864 **** // Check our special variables for the wxLuaState data if (m_wxlState.Ok() && ! ((debugItem->GetName() == _("Tracked User Data")) || ! (debugItem->GetName() == _("wxEvent Callbacks")) || ! (debugItem->GetName() == _("Top Level wxWindows")) || ! (debugItem->GetName() == _("wxWindow Destroy List")))) { wxLuaState wxlState(m_wxlState); wxArrayString strArr; ! if (debugItem->GetName() == _("Tracked User Data")) strArr = wxlState.GetTrackedObjectStrings(); ! else if (debugItem->GetName() == _("wxEvent Callbacks")) strArr = wxlState.GetTrackedCallbackStrings(); ! else if (debugItem->GetName() == _("Top Level wxWindows")) strArr = wxlState.GetTrackedWindowStrings(); ! else if (debugItem->GetName() == _("wxWindow Destroy List")) strArr = wxlState.GetTrackedWinDestroyCallbackStrings(); --- 871,889 ---- // Check our special variables for the wxLuaState data if (m_wxlState.Ok() && ! ((debugItem->GetKey() == _("Tracked User Data")) || ! (debugItem->GetKey() == _("wxEvent Callbacks")) || ! (debugItem->GetKey() == _("Top Level wxWindows")) || ! (debugItem->GetKey() == _("wxWindow Destroy List")))) { 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(); *************** *** 870,874 **** for (n = 0; n < count; n++) { ! wxLuaDebugItem *item = new wxLuaDebugItem(strArr[n].BeforeLast(wxT(' ')), wxT(""), wxT("Count ")+strArr[n].AfterLast(wxT(' ')), wxT(""), LUA_NOREF, debugItem->GetIndex() + 1); dataArr.Add(item); } --- 895,899 ---- for (n = 0; n < count; n++) { ! wxLuaDebugItem *item = new wxLuaDebugItem(strArr[n].BeforeLast(wxT(' ')), WXLUAARG_None, wxT("Count ")+strArr[n].AfterLast(wxT(' ')), WXLUAARG_None, wxT(""), LUA_NOREF, debugItem->GetIndex() + 1); dataArr.Add(item); } Index: wxldebug.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluadebug/src/wxldebug.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** wxldebug.cpp 10 Aug 2007 01:41:08 -0000 1.45 --- wxldebug.cpp 8 Nov 2007 23:47:15 -0000 1.46 *************** *** 30,42 **** // wxLuaDebugItem // ---------------------------------------------------------------------------- ! wxLuaDebugItem::wxLuaDebugItem(const wxString &itemName, ! const wxString &itemType, ! const wxString &itemValue, const wxString &itemSource, int lua_ref, int idx, int flag) ! :m_itemName(itemName), m_itemType(itemType), ! m_itemValue(itemValue), m_itemSource(itemSource), m_lua_ref(lua_ref), m_index(idx), m_flag(flag) --- 30,42 ---- // wxLuaDebugItem // ---------------------------------------------------------------------------- ! wxLuaDebugItem::wxLuaDebugItem(const wxString &itemKey, int itemKeyType, ! 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) *************** *** 45,50 **** wxLuaDebugItem::wxLuaDebugItem(const wxLuaDebugItem &dataItem) ! :m_itemName(dataItem.m_itemName), m_itemType(dataItem.m_itemType), ! m_itemValue(dataItem.m_itemValue), m_itemSource(dataItem.m_itemSource), m_lua_ref(dataItem.m_lua_ref), m_index(dataItem.m_index), m_flag(dataItem.m_flag) --- 45,51 ---- wxLuaDebugItem::wxLuaDebugItem(const wxLuaDebugItem &dataItem) ! :m_itemKey(dataItem.m_itemKey), m_itemKeyType(dataItem.m_itemKeyType), ! m_itemValue(dataItem.m_itemValue), m_itemValueType(dataItem.m_itemValueType), ! m_itemSource(dataItem.m_itemSource), m_lua_ref(dataItem.m_lua_ref), m_index(dataItem.m_index), m_flag(dataItem.m_flag) *************** *** 79,95 **** if (create) m_refData = new wxLuaDebugDataRefData; - - // Sanity check to make sure that Lua hasn't changed the items on us - wxCHECK_RET((WXLUA_DEBUGITEM_TNONE == WXLUA_DEBUGITEM_T_SHIFT + LUA_TNONE) || - (WXLUA_DEBUGITEM_TNIL == WXLUA_DEBUGITEM_T_SHIFT + LUA_TNIL) || - (WXLUA_DEBUGITEM_TBOOLEAN == WXLUA_DEBUGITEM_T_SHIFT + LUA_TBOOLEAN) || - (WXLUA_DEBUGITEM_TLIGHTUSERDATA == WXLUA_DEBUGITEM_T_SHIFT + LUA_TLIGHTUSERDATA) || - (WXLUA_DEBUGITEM_TNUMBER == WXLUA_DEBUGITEM_T_SHIFT + LUA_TNUMBER) || - (WXLUA_DEBUGITEM_TSTRING == WXLUA_DEBUGITEM_T_SHIFT + LUA_TSTRING) || - (WXLUA_DEBUGITEM_TTABLE == WXLUA_DEBUGITEM_T_SHIFT + LUA_TTABLE) || - (WXLUA_DEBUGITEM_TFUNCTION == WXLUA_DEBUGITEM_T_SHIFT + LUA_TFUNCTION) || - (WXLUA_DEBUGITEM_TUSERDATA == WXLUA_DEBUGITEM_T_SHIFT + LUA_TUSERDATA) || - (WXLUA_DEBUGITEM_TTHREAD == WXLUA_DEBUGITEM_T_SHIFT + LUA_TTHREAD), - wxT("Lua has changed the order of their types.")); } --- 80,83 ---- *************** *** 141,150 **** int wxLuaDebugData::SortFunction(wxLuaDebugItem *elem1, wxLuaDebugItem *elem2 ) { ! int ret = elem1->GetName().Cmp(elem2->GetName()); if (ret == 0) // can be true for unnamed "(*temporary)" vars { ! ret = elem1->GetType().Cmp(elem2->GetType()); if (ret == 0) ! ret = elem1->GetValue().Cmp(elem2->GetValue()); } --- 129,145 ---- int wxLuaDebugData::SortFunction(wxLuaDebugItem *elem1, wxLuaDebugItem *elem2 ) { ! int ret = elem1->GetKey().Cmp(elem2->GetKey()); ! if (ret == 0) // can be true for unnamed "(*temporary)" vars { ! ret = elem1->GetKeyType() - elem2->GetKeyType(); // shouldn't happen ! if (ret == 0) ! { ! ret = elem1->GetValueType() - elem2->GetValueType(); ! ! if (ret == 0) ! ret = elem1->GetValue().Cmp(elem2->GetValue()); ! } } *************** *** 184,188 **** name = wxString::Format(_("line %u"), currentLine); ! Add(new wxLuaDebugItem(name, wxT(""), wxT(""), source, LUA_NOREF, nIndex, 0)); count++; } --- 179,183 ---- name = wxString::Format(_("line %u"), currentLine); ! Add(new wxLuaDebugItem(name, WXLUAARG_None, wxT(""), WXLUAARG_None, source, LUA_NOREF, nIndex, 0)); count++; } *************** *** 213,222 **** //wxPrintf(wxString(lua_Debug_to_String(luaDebug) + wxT(" lua_getlocal :") + name + wxT("\n")).c_str()); ! wxString type; wxString value; wxString source(lua2wx(luaDebug.source)); ! int flag_type = WXLUA_DEBUGITEM_TUNKNOWN; ! GetTypeValue(wxlState, -1, type, value, &flag_type); int nRef = LUA_NOREF; --- 208,217 ---- //wxPrintf(wxString(lua_Debug_to_String(luaDebug) + wxT(" lua_getlocal :") + name + wxT("\n")).c_str()); ! int wxl_type = WXLUAARG_None; wxString value; wxString source(lua2wx(luaDebug.source)); ! int flag_type = 0; ! GetTypeValue(wxlState, -1, &wxl_type, value); int nRef = LUA_NOREF; *************** *** 236,240 **** lua_pop(L, 1); // remove variable value ! Add(new wxLuaDebugItem(name, type, value, source, nRef, 0, flag_type)); count++; --- 231,235 ---- lua_pop(L, 1); // remove variable value ! Add(new wxLuaDebugItem(name, WXLUAARG_None, value, wxl_type, source, nRef, 0, flag_type)); count++; *************** *** 255,269 **** int count = 0; ! wxString type; wxString value; wxString name; - int flag_type = WXLUA_DEBUGITEM_TUNKNOWN; if ((tableRef == -1) || (tableRef == LUA_GLOBALSINDEX)) { wxlState.GetGlobals(); ! GetTypeValue(wxlState, -1, type, value, &flag_type); int nRef = wxlua_tinsert(L, -1); ! Add(new wxLuaDebugItem(wxT("Globals"), wxT("table"), value, wxT(""), nRef, 0, WXLUA_DEBUGITEM_TTABLE|WXLUA_DEBUGITEM_LUAREFED)); references.Add(nRef); } --- 250,265 ---- int count = 0; ! int wxl_keytype = WXLUAARG_None; ! int wxl_valuetype = WXLUAARG_None; ! int flag_type = 0; wxString value; wxString name; if ((tableRef == -1) || (tableRef == LUA_GLOBALSINDEX)) { wxlState.GetGlobals(); ! GetTypeValue(wxlState, -1, &wxl_valuetype, value); int nRef = wxlua_tinsert(L, -1); ! Add(new wxLuaDebugItem(wxT("Globals"), WXLUAARG_None, value, WXLUAARG_Table, wxT(""), nRef, 0, WXLUA_DEBUGITEM_LUAREFED)); references.Add(nRef); } *************** *** 271,277 **** { wxlState.lua_PushValue(LUA_REGISTRYINDEX); ! GetTypeValue(wxlState, -1, type, value, &flag_type); int nRef = wxlua_tinsert(L, -1); ! Add(new wxLuaDebugItem(wxT("Lua Registry"), wxT("table"), value, wxT(""), nRef, 0, WXLUA_DEBUGITEM_TTABLE|WXLUA_DEBUGITEM_LUAREFED)); references.Add(nRef); } --- 267,273 ---- { wxlState.lua_PushValue(LUA_REGISTRYINDEX); ! GetTypeValue(wxlState, -1, &wxl_valuetype, value); int nRef = wxlua_tinsert(L, -1); ! Add(new wxLuaDebugItem(wxT("Lua Registry"), WXLUAARG_None, value, WXLUAARG_Table, wxT(""), nRef, 0, WXLUA_DEBUGITEM_LUAREFED)); references.Add(nRef); } *************** *** 288,294 **** { // get the index, just want the name=value, type is dummy here ! GetTypeValue(wxlState, -2, type, name); // get the type and value ! GetTypeValue(wxlState, -1, type, value, &flag_type); //wxPrintf(wxT("wxLuaDebugData::EnumerateTable %d type='%s' key='%s' val='%s'\n"), count, type.c_str(), name.c_str(), value.c_str()); --- 284,290 ---- { // get the index, just want the name=value, type is dummy here ! GetTypeValue(wxlState, -2, &wxl_keytype, name); // get the type and value ! GetTypeValue(wxlState, -1, &wxl_valuetype, value); //wxPrintf(wxT("wxLuaDebugData::EnumerateTable %d type='%s' key='%s' val='%s'\n"), count, type.c_str(), name.c_str(), value.c_str()); *************** *** 311,315 **** lua_pop(L, 1); ! Add(new wxLuaDebugItem(name, type, value, wxT(""), nRef, nIndex, flag_type)); count++; } --- 307,311 ---- lua_pop(L, 1); ! Add(new wxLuaDebugItem(name, wxl_keytype, value, wxl_valuetype, wxT(""), nRef, nIndex)); count++; } *************** *** 322,334 **** } ! int wxLuaDebugData::GetTypeValue(const wxLuaState& wxlState, int index, wxString& type, wxString& value, int* flag_type_) { wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); ! lua_State* L = wxlState.GetLuaState(); ! int l_type = lua_type(L, index); ! int flag_type = WXLUA_DEBUGITEM_TUNKNOWN; ! ! type = wxlua_getwxluatypename(wxlua_getwxluatype(l_type)); switch (l_type) --- 318,328 ---- } ! int wxLuaDebugData::GetTypeValue(const wxLuaState& wxlState, int index, int* wxl_type_, wxString& value) { wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); ! lua_State* L = wxlState.GetLuaState(); ! int l_type = lua_type(L, index); ! int wxl_type = wxlua_getwxluatype(l_type); switch (l_type) *************** *** 336,370 **** case LUA_TNONE: value = wxEmptyString; - flag_type = WXLUA_DEBUGITEM_TNONE; break; case LUA_TNIL: value = wxT("nil"); - flag_type = WXLUA_DEBUGITEM_TNIL; break; case LUA_TBOOLEAN: value = MakeBoolean(lua_toboolean(L, index)); - flag_type = WXLUA_DEBUGITEM_TBOOLEAN; break; case LUA_TLIGHTUSERDATA: value = GetUserDataInfo(wxlState, index, false); - flag_type = WXLUA_DEBUGITEM_TLIGHTUSERDATA; break; case LUA_TNUMBER: value = MakeNumber(lua_tonumber(L, index)); - flag_type = WXLUA_DEBUGITEM_TNUMBER; break; case LUA_TSTRING: value = lua2wx(lua_tostring(L, index)); - flag_type = WXLUA_DEBUGITEM_TSTRING; break; case LUA_TTABLE: value = GetTableInfo(wxlState, index); - flag_type = WXLUA_DEBUGITEM_TTABLE; break; --- 330,357 ---- *************** *** 372,383 **** if (lua_iscfunction(L, index)) { ! type = wxT("cfunction"); value.Printf(wxT("%p"), lua_tocfunction(L, index)); - flag_type = WXLUA_DEBUGITEM_TCFUNCTION; } else { value.Printf(wxT("%p"), lua_topointer(L, index)); - flag_type = WXLUA_DEBUGITEM_TFUNCTION; } break; --- 359,368 ---- if (lua_iscfunction(L, index)) { ! wxl_type = WXLUAARG_CFunction; value.Printf(wxT("%p"), lua_tocfunction(L, index)); } else { value.Printf(wxT("%p"), lua_topointer(L, index)); } break; *************** *** 385,404 **** case LUA_TUSERDATA: value = GetUserDataInfo(wxlState, index, true); - flag_type = WXLUA_DEBUGITEM_TUSERDATA; break; case LUA_TTHREAD: value.Printf(wxT("%p"), lua_topointer(L, index)); - flag_type = WXLUA_DEBUGITEM_TTHREAD; break; default : - type = wxT("Unknown Data Type?"); value = wxEmptyString; - flag_type = WXLUA_DEBUGITEM_TUNKNOWN; break; } ! if (flag_type_) *flag_type_ = flag_type; return l_type; --- 370,385 ---- case LUA_TUSERDATA: value = GetUserDataInfo(wxlState, index, true); break; case LUA_TTHREAD: value.Printf(wxT("%p"), lua_topointer(L, index)); break; default : value = wxEmptyString; break; } ! if (wxl_type_) *wxl_type_ = wxl_type; return l_type; *************** *** 560,582 **** while(lua_next(L, index) != 0) { ! wxString indexType, indexValue; ! wxString valueType, value; ! wxLuaDebugData::GetTypeValue(wxlState, -2, indexType, indexValue); ! wxLuaDebugData::GetTypeValue(wxlState, -1, valueType, value); ! wxString info = wxString::Format(wxT("%s%-32s\t%-15s\t%-20s\t%-10s"), ! indentStr.c_str(), ! indexValue.c_str(), ! indexType.c_str(), ! valueType.c_str(), ! value.c_str()); OutputMsg(info); if (tableArray.Index(value) == wxNOT_FOUND) { ! if (valueType == wxT("table")) { ! wxString tname = wxString::Format(wxT("%s.%s"), tablename.c_str(), indexValue.c_str()); tableArray.Add(value); int tableIndex = lua_gettop(L); --- 541,559 ---- while(lua_next(L, index) != 0) { ! int keyType = 0, valueType = 0; ! wxString key, value; ! wxLuaDebugData::GetTypeValue(wxlState, -2, &keyType, key); ! wxLuaDebugData::GetTypeValue(wxlState, -1, &valueType, value); ! wxString info = wxString::Format(wxT("%s%-32s\t%d\t%-20s\t%d"), ! indentStr.c_str(), key.c_str(), keyType, value.c_str(), valueType); OutputMsg(info); if (tableArray.Index(value) == wxNOT_FOUND) { ! if (valueType == WXLUAARG_Table) { ! wxString tname = wxString::Format(wxT("%s.%s"), tablename.c_str(), key.c_str()); tableArray.Add(value); int tableIndex = lua_gettop(L); *************** *** 617,623 **** //wxPrintf(wxT("Stack item %d of %d : type %d '%s'\n"), i, argCount, type, lua2wx(lua_typename(L, type)).c_str()); ! wxString type, value; ! int i_type = wxLuaDebugData::GetTypeValue(wxlState, i, type, value); ! OutputMsg(wxString::Format(wxT("item %d: i_type %d '%s' = '%s'\n"), i, i_type, type.c_str(), value.c_str())); } } --- 594,601 ---- //wxPrintf(wxT("Stack item %d of %d : type %d '%s'\n"), i, argCount, type, lua2wx(lua_typename(L, type)).c_str()); ! int wxl_type = 0; ! wxString value; ! int l_type = wxLuaDebugData::GetTypeValue(wxlState, i, &wxl_type, value); ! OutputMsg(wxString::Format(wxT("item %d: lua_type %d wxlua_type %d = '%s'\n"), i, l_type, wxl_type, value.c_str())); } } |