From: John L. <jr...@us...> - 2005-12-01 06:44:01
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24710/wxLua/modules/wxluasocket/src Modified Files: Makefile dservice.cpp wxldserv.cpp wxldtarg.cpp Log Message: Make wxLuaDebugData have functions to BuildStack, BuildStackList, BuildTableList These replace the same functions in wxLuaInterface Replaces EnumerateStack, EnumerateStackEntry, EnumerateTable in wxLuaTarget and wxLuaDebugee moved helper functions MakeNumber, MakeBoolean, GetTableInfo, GetUserDataInfo as well Index: wxldtarg.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxldtarg.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** wxldtarg.cpp 1 Dec 2005 04:17:29 -0000 1.4 --- wxldtarg.cpp 1 Dec 2005 06:43:54 -0000 1.5 *************** *** 415,457 **** { wxLuaDebugData *pSortedList = new wxLuaDebugData(); ! if (pSortedList != NULL) ! { ! int nIndex = 0; ! bool fFirst = true; ! lua_Debug luaDebug; ! lua_State* L = m_wxlState.GetLuaState(); ! ! wxLuaHandler::GetHandler().EnterLuaCriticalSection(); ! ! while (lua_getstack(L, nIndex, &luaDebug) != 0) ! { ! if (lua_getinfo(L, "Sln", &luaDebug)) ! { ! wxString stackItem; ! ! // skip stack frames that do not have line number ! int currentLine = luaDebug.currentline; ! if (!fFirst || (currentLine != -1)) ! { ! if (currentLine == -1) ! currentLine = 0; ! ! if (luaDebug.name != NULL) ! stackItem.Printf(wxT("function %s line %u"), luaDebug.name, currentLine); ! else ! stackItem.Printf(wxT("line %u"), currentLine); ! ! wxLuaDebugDataItem *item = new wxLuaDebugDataItem(stackItem, wxT(""), wxT(""), wxT(""), nIndex, 0); ! if (item != NULL) ! pSortedList->Add(item); ! fFirst = false; ! } ! } - ++nIndex; - } - wxLuaHandler::GetHandler().LeaveLuaCriticalSection(); - } return NotifyStackEnumeration(pSortedList); } --- 415,425 ---- { wxLuaDebugData *pSortedList = new wxLuaDebugData(); ! if (pSortedList == NULL) ! return false; ! wxLuaHandler::GetHandler().EnterLuaCriticalSection(); ! pSortedList->BuildStack(m_wxlState); ! wxLuaHandler::GetHandler().LeaveLuaCriticalSection(); return NotifyStackEnumeration(pSortedList); } *************** *** 460,555 **** { wxLuaDebugData *pSortedList = new wxLuaDebugData; ! if (pSortedList != NULL) ! { ! wxLuaHandler::GetHandler().EnterLuaCriticalSection(); ! { ! lua_State* L = m_wxlState.GetLuaState(); ! lua_Debug luaDebug; ! if (lua_getstack(L, stackRef, &luaDebug) != 0) ! { ! int idx = 1; ! wxString name = lua2wx(lua_getlocal(L, &luaDebug, idx)); ! while (!name.IsEmpty()) ! { ! bool fIsTable = false; ! wxString type; ! wxString value; ! ! switch (lua_type(L, -1)) ! { ! case LUA_TNIL: ! type = wxT("Nil"); ! value = wxT("nil"); ! break; ! ! case LUA_TBOOLEAN: ! type = wxT("Boolean"); ! value = MakeBoolean(lua_toboolean(L, -1)); ! break; ! ! case LUA_TNUMBER: ! type = wxT("Number"); ! value = MakeNumber(lua_tonumber(L, -1)); ! break; ! ! case LUA_TSTRING: ! type = wxT("String"); ! value = lua2wx(lua_tostring(L, -1)); ! break; ! ! case LUA_TTABLE: ! type = wxT("Table"); ! value = GetTableInfo(-1); ! fIsTable = true; ! break; ! ! case LUA_TFUNCTION: ! if (lua_iscfunction(L, -1)) ! { ! type = wxT("C Function"); ! value.Printf(wxT("%p"), lua_tocfunction(L, -1)); ! } ! else ! { ! type = wxT("Lua Function"); ! value.Printf(wxT("%p"), lua_topointer(L, -1)); ! } ! break; ! ! case LUA_TUSERDATA: ! type = wxT("User Data"); ! value = GetUserDataInfo(-1); ! break; ! ! case LUA_TLIGHTUSERDATA: ! type = wxT("Light User Data"); ! value = GetUserDataInfo(-1, false); ! break; ! ! case LUA_TTHREAD: ! type = wxT("Thread"); ! value.Printf(wxT("%p"), lua_topointer(L, -1)); ! break; ! } ! ! int nRef = LUA_NOREF; ! ! if (lua_istable(L, -1)) ! { ! lua_pushvalue(L, -1); ! nRef = m_wxlState.tinsert(-1); ! m_references.Add(nRef); ! } ! wxLuaDebugDataItem *item = new wxLuaDebugDataItem(name, type, value, wxT(""), nRef, 0); ! if (item != NULL) ! pSortedList->Add(item); - name = lua2wx(lua_getlocal(L, &luaDebug, ++idx)); - } - } - } - wxLuaHandler::GetHandler().LeaveLuaCriticalSection(); - } return NotifyStackEntryEnumeration(stackRef, pSortedList); } --- 428,438 ---- { wxLuaDebugData *pSortedList = new wxLuaDebugData; ! if (pSortedList == NULL) ! return false; ! wxLuaHandler::GetHandler().EnterLuaCriticalSection(); ! pSortedList->BuildStackList(m_wxlState, stackRef, m_references); ! wxLuaHandler::GetHandler().LeaveLuaCriticalSection(); return NotifyStackEntryEnumeration(stackRef, pSortedList); } *************** *** 558,716 **** { wxLuaDebugData *pSortedList = new wxLuaDebugData(); ! if (pSortedList != NULL) ! { ! wxLuaHandler::GetHandler().EnterLuaCriticalSection(); ! { ! lua_State* L = m_wxlState.GetLuaState(); ! ! if (tableRef == -1) ! { ! lua_pushvalue(L, LUA_GLOBALSINDEX); ! int nRef = m_wxlState.tinsert(-1); ! pSortedList->Add(new wxLuaDebugDataItem(wxT("Globals"), ! wxT(""), ! wxT(""), ! wxT(""), ! nRef, ! 0)); ! m_references.Add(nRef); ! } ! else ! { ! if (m_wxlState.tget(tableRef) != 0) ! { ! int nTop = lua_gettop(L); ! ! // start iterating ! lua_pushnil(L); ! while (lua_next(L, nTop) != 0) ! { ! bool fIsTable = false; ! wxString type; ! wxString value; ! wxString name; ! ! // get the index ! switch (lua_type(L, -2)) ! { ! case LUA_TNIL: ! name = wxT("Nil"); ! break; ! ! case LUA_TBOOLEAN: ! name = MakeBoolean(lua_toboolean(L, -2)); ! break; ! ! case LUA_TNUMBER: ! name = MakeNumber(lua_tonumber(L, -2)); ! break; ! ! case LUA_TSTRING: ! name = lua2wx(lua_tostring(L, -2)); ! break; ! ! case LUA_TTABLE: ! name = GetTableInfo(-2); ! break; ! ! case LUA_TFUNCTION: ! if (lua_iscfunction(L, -2)) ! name.Printf(wxT("%p"), lua_tocfunction(L, -2)); ! else ! name.Printf(wxT("%p"), lua_topointer(L, -2)); ! break; ! ! case LUA_TUSERDATA: ! name = GetUserDataInfo(-2); ! break; ! ! case LUA_TLIGHTUSERDATA: ! name = GetUserDataInfo(-2, false); ! break; ! ! case LUA_TTHREAD: ! name.Printf(wxT("%p"), lua_topointer(L, -2)); ! break; ! } ! ! // get the value ! switch (lua_type(L, -1)) ! { ! case LUA_TNIL: ! type = wxT("Nil"); ! value = wxT("nil"); ! break; ! ! case LUA_TBOOLEAN: ! value = MakeBoolean(lua_toboolean(L, -1)); ! type = wxT("Boolean"); ! break; ! ! case LUA_TNUMBER: ! value = MakeNumber(lua_tonumber(L, -1)); ! type = wxT("Number"); ! break; ! ! case LUA_TSTRING: ! type = wxT("String"); ! value = lua2wx(lua_tostring(L, -1)); ! break; ! ! case LUA_TTABLE: ! type = wxT("Table"); ! value = GetTableInfo(-1); ! fIsTable = true; ! break; ! ! case LUA_TFUNCTION: ! if (lua_iscfunction(L, -1)) ! { ! type = wxT("C Function"); ! value.Printf(wxT("%p"), lua_tocfunction(L, -1)); ! } ! else ! { ! type = wxT("Lua Function"); ! value.Printf(wxT("%p"), lua_topointer(L, -1)); ! } ! break; ! ! case LUA_TUSERDATA: ! type = wxT("User Data"); ! value = GetUserDataInfo(-1); ! break; ! ! case LUA_TLIGHTUSERDATA: ! type = wxT("Light User Data"); ! value = GetUserDataInfo(-1, false); ! break; ! ! case LUA_TTHREAD: ! type = wxT("Thread"); ! value.Printf(wxT("%p"), lua_topointer(L, -1)); ! break; ! } ! ! int nRef = LUA_NOREF; ! if (fIsTable) ! { ! nRef = m_wxlState.tinsert(-1); ! m_references.Add(nRef); ! } ! else ! lua_pop(L, 1); ! wxLuaDebugDataItem *item = new wxLuaDebugDataItem(name, type, value, wxT(""), nRef, nIndex); ! if (item != NULL) ! pSortedList->Add(item); ! } - // remove reference - lua_pop(L, 1); - } - } - } - wxLuaHandler::GetHandler().LeaveLuaCriticalSection(); - } return NotifyTableEnumeration(nItemNode, pSortedList); } --- 441,451 ---- { wxLuaDebugData *pSortedList = new wxLuaDebugData(); ! if (pSortedList == NULL) ! return false; ! wxLuaHandler::GetHandler().EnterLuaCriticalSection(); ! pSortedList->BuildTableList(m_wxlState, tableRef, nIndex, m_references); ! wxLuaHandler::GetHandler().LeaveLuaCriticalSection(); return NotifyTableEnumeration(nItemNode, pSortedList); } *************** *** 810,818 **** case LUA_TBOOLEAN: ! strResult = MakeBoolean(lua_toboolean(L, -1)); break; case LUA_TNUMBER: ! strResult = MakeNumber(lua_tonumber(L, -1)); break; --- 545,553 ---- case LUA_TBOOLEAN: ! strResult = wxLuaDebugData::MakeBoolean(lua_toboolean(L, -1)); break; case LUA_TNUMBER: ! strResult = wxLuaDebugData::MakeNumber(lua_tonumber(L, -1)); break; *************** *** 888,910 **** } - wxString wxLuaDebugTarget::MakeNumber(double dnum) - { - long num = (long) dnum; - if ((double) num == dnum) - { - if (num >= 0) - return wxString::Format(wxT("%lu (0x%lx)"), num, num); - - return wxString::Format(wxT("%ld (0x%lx)"), num, num); - } - - return wxString::Format(wxT("%g"), dnum); - } - - wxString wxLuaDebugTarget::MakeBoolean(int num) - { - return num != 0 ? wxT("True") : wxT("False"); - } - bool wxLuaDebugTarget::NotifyBreak(const wxString &fileName, int lineNumber) { --- 623,626 ---- Index: dservice.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/dservice.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dservice.cpp 1 Dec 2005 04:17:29 -0000 1.5 --- dservice.cpp 1 Dec 2005 06:43:54 -0000 1.6 *************** *** 34,39 **** #include "wxluasocket/include/dservice.h" ! #include <wx/listimpl.cpp> static const char *debugName = "__wxLuaDebug__"; --- 34,40 ---- #include "wxluasocket/include/dservice.h" + #include "wxluasocket/include/wxlhandl.h" ! #include "wx/listimpl.cpp" static const char *debugName = "__wxLuaDebug__"; *************** *** 144,148 **** wxLuaDebugData *pSortedList = new wxLuaDebugData(); ! size_t idx, idxMax; m_Socket->Read((char *) &idxMax, sizeof(idxMax)); --- 145,149 ---- wxLuaDebugData *pSortedList = new wxLuaDebugData(); ! size_t idx, idxMax = 0; m_Socket->Read((char *) &idxMax, sizeof(idxMax)); *************** *** 451,455 **** if (debugSocket && debuggee) { ! debugCommands debugCommand = (debugCommands)debugSocket->ReadByte(); switch(debugCommand) { --- 452,456 ---- if (debugSocket && debuggee) { ! wxLuaDebugCommands_Type debugCommand = (wxLuaDebugCommands_Type)debugSocket->ReadByte(); switch(debugCommand) { *************** *** 1117,1121 **** return (m_debuggerSocket->WriteByte(wxLUA_CMD_ADD_BREAKPOINT) && ! m_debuggerSocket->WriteString(fileName) && m_debuggerSocket->WriteInt(lineNumber)); } --- 1118,1122 ---- return (m_debuggerSocket->WriteByte(wxLUA_CMD_ADD_BREAKPOINT) && ! m_debuggerSocket->WriteString(fileName) && m_debuggerSocket->WriteInt(lineNumber)); } *************** *** 1127,1131 **** return (m_debuggerSocket->WriteByte(wxLUA_CMD_REMOVE_BREAKPOINT) && ! m_debuggerSocket->WriteString(fileName) && m_debuggerSocket->WriteInt(lineNumber)); } --- 1128,1132 ---- return (m_debuggerSocket->WriteByte(wxLUA_CMD_REMOVE_BREAKPOINT) && ! m_debuggerSocket->WriteString(fileName) && m_debuggerSocket->WriteInt(lineNumber)); } *************** *** 1137,1141 **** return (m_debuggerSocket->WriteByte(wxLUA_CMD_DISABLE_BREAKPOINT) && ! m_debuggerSocket->WriteString(fileName) && m_debuggerSocket->WriteInt(lineNumber)); } --- 1138,1142 ---- return (m_debuggerSocket->WriteByte(wxLUA_CMD_DISABLE_BREAKPOINT) && ! m_debuggerSocket->WriteString(fileName) && m_debuggerSocket->WriteInt(lineNumber)); } *************** *** 1147,1151 **** return (m_debuggerSocket->WriteByte(wxLUA_CMD_ENABLE_BREAKPOINT) && ! m_debuggerSocket->WriteString(fileName) && m_debuggerSocket->WriteInt(lineNumber)); } --- 1148,1152 ---- return (m_debuggerSocket->WriteByte(wxLUA_CMD_ENABLE_BREAKPOINT) && ! m_debuggerSocket->WriteString(fileName) && m_debuggerSocket->WriteInt(lineNumber)); } *************** *** 1230,1235 **** return (m_debuggerSocket->WriteByte(wxLUA_CMD_ENUMERATE_TABLE_REF) && ! m_debuggerSocket->WriteInt(tableRef) && ! m_debuggerSocket->WriteInt(nIndex) && m_debuggerSocket->WriteInt(nItemNode)); } --- 1231,1236 ---- return (m_debuggerSocket->WriteByte(wxLUA_CMD_ENUMERATE_TABLE_REF) && ! m_debuggerSocket->WriteInt(tableRef) && ! m_debuggerSocket->WriteInt(nIndex) && m_debuggerSocket->WriteInt(nItemNode)); } *************** *** 1259,1263 **** wxLuaDebuggee::wxLuaDebuggee(wxLuaDebugService* debugService, lua_State* luaState) : m_debugService(debugService), ! m_luaState(luaState), m_breakPointList(wxKEY_STRING), m_forceBreak(false), --- 1260,1264 ---- wxLuaDebuggee::wxLuaDebuggee(wxLuaDebugService* debugService, lua_State* luaState) : m_debugService(debugService), ! m_wxlState(luaState), m_breakPointList(wxKEY_STRING), m_forceBreak(false), *************** *** 1268,1278 **** m_Wait(false) { ! lua_pushlightuserdata(m_luaState, this); ! lua_setglobal(m_luaState, debugName); ! lua_sethook(m_luaState, LuaDebugHook, LUA_MASKCALL | LUA_MASKLINE | LUA_MASKRET, 0); ! lua_pushcfunction(m_luaState, LuaPrint); ! lua_setglobal(m_luaState, "print"); wxLuaHandler::GetHandler().EnterLuaCriticalSection(); --- 1269,1280 ---- m_Wait(false) { ! lua_State* L = m_wxlState.GetLuaState(); ! lua_pushlightuserdata(L, this); ! lua_setglobal(L, debugName); ! lua_sethook(L, LuaDebugHook, LUA_MASKCALL | LUA_MASKLINE | LUA_MASKRET, 0); ! lua_pushcfunction(L, LuaPrint); ! lua_setglobal(L, "print"); wxLuaHandler::GetHandler().EnterLuaCriticalSection(); *************** *** 1297,1303 **** // Unhook ! lua_sethook(m_luaState, LuaDebugHook, 0, 0); ! ! } --- 1299,1303 ---- // Unhook ! lua_sethook(m_wxlState.GetLuaState(), LuaDebugHook, 0, 0); } *************** *** 1360,1364 **** { int lineNumber = 0; ! wxFileName fileName = GetDebugInfo(lineNumber); if (m_debugService->NotifyBreak(fileName, lineNumber)) --- 1360,1364 ---- { int lineNumber = 0; ! wxFileName fileName = GetDebugInfo(lineNumber); if (m_debugService->NotifyBreak(fileName, lineNumber)) *************** *** 1371,1375 **** { int lineNumber = 0; ! wxFileName fileName = GetDebugInfo(lineNumber); if (m_debugService->NotifyBreak(fileName, lineNumber)) --- 1371,1375 ---- { int lineNumber = 0; ! wxFileName fileName = GetDebugInfo(lineNumber); if (m_debugService->NotifyBreak(fileName, lineNumber)) *************** *** 1382,1386 **** { int lineNumber = 0; ! wxFileName fileName = GetDebugInfo(lineNumber); if (AtBreakPoint(fileName, lineNumber) && --- 1382,1386 ---- { int lineNumber = 0; ! wxFileName fileName = GetDebugInfo(lineNumber); if (AtBreakPoint(fileName, lineNumber) && *************** *** 1445,1449 **** { int iItem = m_references.Item(idx); ! tremove(m_luaState, iItem); } } --- 1445,1449 ---- { int iItem = m_references.Item(idx); ! m_wxlState.tremove(iItem); } } *************** *** 1459,1463 **** { LuaBreakPoint* breakPoint = new LuaBreakPoint(fileName, lineNumber); - m_breakPointList.Append(breakPointKey, breakPoint); --- 1459,1462 ---- *************** *** 1486,1490 **** { LuaBreakPoint* breakPoint = node->GetData(); - m_breakPointList.DeleteNode(node); --- 1485,1488 ---- *************** *** 1583,1627 **** { wxLuaDebugData *pSortedList = new wxLuaDebugData(); ! if (pSortedList != NULL) ! { ! int nIndex = 0; ! bool fFirst = true; ! lua_Debug luaDebug; ! ! wxLuaHandler::GetHandler().EnterLuaCriticalSection(); ! ! while (lua_getstack(m_luaState, nIndex, &luaDebug) != 0) ! { ! if (lua_getinfo(m_luaState, "Sln", &luaDebug)) ! { ! wxString name = lua2wx(luaDebug.name); ! wxString source = lua2wx(luaDebug.source); ! ! wxString stackItem; ! ! // skip stack frames that do not have line number ! int currentLine = luaDebug.currentline; ! if (!fFirst || currentLine != -1) ! { ! if (currentLine == -1) ! currentLine = 0; ! ! if (luaDebug.name != NULL) ! stackItem = wxString::Format(_("function %s line %u"), name.c_str(), currentLine); ! else ! stackItem = wxString::Format(_("line %u"), currentLine); ! ! wxLuaDebugDataItem *item = new wxLuaDebugDataItem(stackItem, wxT(""), wxT(""), source, nIndex, 0); ! if (item != NULL) ! pSortedList->Add(item); ! ! fFirst = false; ! } ! } ! ++nIndex; ! } ! wxLuaHandler::GetHandler().LeaveLuaCriticalSection(); ! } return m_debugService->NotifyStackEnumeration(pSortedList); --- 1581,1590 ---- { wxLuaDebugData *pSortedList = new wxLuaDebugData(); ! if (pSortedList == NULL) ! return false; ! wxLuaHandler::GetHandler().EnterLuaCriticalSection(); ! pSortedList->BuildStack(m_wxlState); ! wxLuaHandler::GetHandler().LeaveLuaCriticalSection(); return m_debugService->NotifyStackEnumeration(pSortedList); *************** *** 1631,1726 **** { wxLuaDebugData *pSortedList = new wxLuaDebugData; ! if (pSortedList != NULL) ! { ! wxLuaHandler::GetHandler().EnterLuaCriticalSection(); ! { ! lua_Debug luaDebug; ! if (lua_getstack(m_luaState, stackRef, &luaDebug) != 0) ! { ! int idx = 1; ! wxString name = lua2wx(lua_getlocal(m_luaState, &luaDebug, idx)); ! while (!name.IsEmpty()) ! { ! bool fIsTable = false; ! wxString type; ! wxString value; ! wxString source = lua2wx(luaDebug.source); ! ! switch (lua_type(m_luaState, -1)) ! { ! case LUA_TNIL: ! type = wxT("Nil"); ! value = wxT("nil"); ! break; ! ! case LUA_TBOOLEAN: ! type = wxT("Boolean"); ! value = MakeBoolean(lua_toboolean(m_luaState, -1)); ! break; ! ! case LUA_TNUMBER: ! type = wxT("Number"); ! value = MakeNumber(lua_tonumber(m_luaState, -1)); ! break; ! ! case LUA_TSTRING: ! type = wxT("String"); ! value = lua2wx(lua_tostring(m_luaState, -1)); ! break; ! ! case LUA_TTABLE: ! type = wxT("Table"); ! value = GetTableInfo(-1); ! fIsTable = true; ! break; ! ! case LUA_TFUNCTION: ! if (lua_iscfunction(m_luaState, -1)) ! { ! type = wxT("C Function"); ! value.Printf(wxT("%p"), lua_tocfunction(m_luaState, -1)); ! } ! else ! { ! type = wxT("Lua Function"); ! value.Printf(wxT("%p"), lua_topointer(m_luaState, -1)); ! } ! break; ! ! case LUA_TUSERDATA: ! type = wxT("User Data"); ! value = GetUserDataInfo(-1); ! break; ! ! case LUA_TLIGHTUSERDATA: ! type = wxT("Light User Data"); ! value = GetUserDataInfo(-1, false); ! break; ! ! case LUA_TTHREAD: ! type = wxT("Thread"); ! value.Printf(wxT("%p"), lua_topointer(m_luaState, -1)); ! break; ! } ! ! int nRef = LUA_NOREF; ! ! if (lua_istable(m_luaState, -1)) ! { ! lua_pushvalue(m_luaState, -1); ! nRef = tinsert(m_luaState, -1); ! m_references.Add(nRef); ! } ! ! wxLuaDebugDataItem *item = new wxLuaDebugDataItem(name, type, value, source, nRef, 0); ! if (item != NULL) ! pSortedList->Add(item); ! name = lua2wx(lua_getlocal(m_luaState, &luaDebug, ++idx)); ! } ! } ! } ! wxLuaHandler::GetHandler().LeaveLuaCriticalSection(); ! } return m_debugService->NotifyStackEntryEnumeration(stackRef, pSortedList); --- 1594,1603 ---- { wxLuaDebugData *pSortedList = new wxLuaDebugData; ! if (pSortedList == NULL) ! return false; ! wxLuaHandler::GetHandler().EnterLuaCriticalSection(); ! pSortedList->BuildStackList(m_wxlState, stackRef, m_references); ! wxLuaHandler::GetHandler().LeaveLuaCriticalSection(); return m_debugService->NotifyStackEntryEnumeration(stackRef, pSortedList); *************** *** 1730,1887 **** { wxLuaDebugData *pSortedList = new wxLuaDebugData(); ! if (pSortedList != NULL) ! { ! wxLuaHandler::GetHandler().EnterLuaCriticalSection(); ! { ! if (tableRef == -1) ! { ! lua_pushvalue(m_luaState, LUA_GLOBALSINDEX); ! int nRef = tinsert(m_luaState, -1); ! pSortedList->Add(new wxLuaDebugDataItem(wxT("Globals"), ! wxT(""), ! wxT(""), ! wxT(""), ! nRef, ! 0)); ! m_references.Add(nRef); ! } ! else ! { ! if (tget(m_luaState, tableRef) != 0) ! { ! int nTop = lua_gettop(m_luaState); ! ! // start iterating ! lua_pushnil(m_luaState); ! while (lua_next(m_luaState, nTop) != 0) ! { ! bool fIsTable = false; ! wxString type; ! wxString value; ! wxString name; ! wxString source; ! ! // get the index ! switch (lua_type(m_luaState, -2)) ! { ! case LUA_TNIL: ! name = wxT("Nil"); ! break; ! ! case LUA_TBOOLEAN: ! name = MakeBoolean(lua_toboolean(m_luaState, -2)); ! break; ! ! case LUA_TNUMBER: ! name = MakeNumber(lua_tonumber(m_luaState, -2)); ! break; ! ! case LUA_TSTRING: ! name = lua2wx(lua_tostring(m_luaState, -2)); ! break; ! ! case LUA_TTABLE: ! name = GetTableInfo(-2); ! break; ! ! case LUA_TFUNCTION: ! if (lua_iscfunction(m_luaState, -2)) ! name.Printf(wxT("%p"), lua_tocfunction(m_luaState, -2)); ! else ! name.Printf(wxT("%p"), lua_topointer(m_luaState, -2)); ! break; ! ! case LUA_TUSERDATA: ! name = GetUserDataInfo(-2); ! break; ! ! case LUA_TLIGHTUSERDATA: ! name = GetUserDataInfo(-2, false); ! break; ! ! case LUA_TTHREAD: ! name.Printf(wxT("%p"), lua_topointer(m_luaState, -2)); ! break; ! } ! ! // get the value ! switch (lua_type(m_luaState, -1)) ! { ! case LUA_TNIL: ! type = wxT("Nil"); ! value = wxT("nil"); ! break; ! ! case LUA_TBOOLEAN: ! value = MakeBoolean(lua_toboolean(m_luaState, -1)); ! type = wxT("Boolean"); ! break; ! ! case LUA_TNUMBER: ! value = MakeNumber(lua_tonumber(m_luaState, -1)); ! type = wxT("Number"); ! break; ! ! case LUA_TSTRING: ! type = wxT("String"); ! value = lua2wx(lua_tostring(m_luaState, -1)); ! break; ! ! case LUA_TTABLE: ! type = wxT("Table"); ! value = GetTableInfo(-1); ! fIsTable = true; ! break; ! ! case LUA_TFUNCTION: ! if (lua_iscfunction(m_luaState, -1)) ! { ! type = wxT("C Function"); ! value.Printf(wxT("%p"), lua_tocfunction(m_luaState, -1)); ! } ! else ! { ! type = wxT("Lua Function"); ! value.Printf(wxT("%p"), lua_topointer(m_luaState, -1)); ! } ! break; ! ! case LUA_TUSERDATA: ! type = wxT("User Data"); ! value = GetUserDataInfo(-1); ! break; ! ! case LUA_TLIGHTUSERDATA: ! type = wxT("Light User Data"); ! value = GetUserDataInfo(-1, false); ! break; ! ! case LUA_TTHREAD: ! type = wxT("Thread"); ! value.Printf(wxT("%p"), lua_topointer(m_luaState, -1)); ! break; ! } ! ! int nRef = LUA_NOREF; ! if (fIsTable) ! { ! nRef = tinsert(m_luaState, -1); ! m_references.Add(nRef); ! } ! else ! lua_pop(m_luaState, 1); ! ! wxLuaDebugDataItem *item = new wxLuaDebugDataItem(name, type, value, source, nRef, nIndex); ! if (item != NULL) ! pSortedList->Add(item); ! } ! // remove reference ! lua_pop(m_luaState, 1); ! } ! } ! } ! wxLuaHandler::GetHandler().LeaveLuaCriticalSection(); ! } return m_debugService->NotifyTableEnumeration(nItemNode, pSortedList); --- 1607,1616 ---- { wxLuaDebugData *pSortedList = new wxLuaDebugData(); ! if (pSortedList == NULL) ! return false; ! wxLuaHandler::GetHandler().EnterLuaCriticalSection(); ! pSortedList->BuildTableList(m_wxlState, tableRef, nIndex, m_references); ! wxLuaHandler::GetHandler().LeaveLuaCriticalSection(); return m_debugService->NotifyTableEnumeration(nItemNode, pSortedList); *************** *** 1895,1937 **** wxLuaHandler::GetHandler().EnterLuaCriticalSection(); { if (wxStrpbrk(strExpr.c_str(), wxT(" ~=<>+-*/%(){}[]:;,.\"'")) != NULL) { // an expression ! int nOldTop = lua_gettop(m_luaState); LuaCharBuffer charbuf(strExpr); ! int nResult = luaL_loadbuffer(m_luaState, charbuf.GetData(), charbuf.Length(), "debug"); if (nResult == 0) ! nResult = lua_pcall(m_luaState, 0, LUA_MULTRET, 0); /* call main */ switch (nResult) { default: ! if (lua_gettop(m_luaState) == nOldTop) { ! lua_pushliteral(m_luaState, "OK"); } break; case LUA_ERRRUN: ! lua_pushliteral(m_luaState, "Error while running the chunk"); break; case LUA_ERRSYNTAX: ! lua_pushliteral(m_luaState, "Syntax error during pre-compilation"); break; case LUA_ERRMEM: ! lua_pushliteral(m_luaState, "Memory allocation error"); break; case LUA_ERRERR: ! lua_pushliteral(m_luaState, "Unexpected error occurred while running the error message handler"); break; } ! nReference = tinsert(m_luaState, -1); ! lua_settop(m_luaState, nOldTop); } else --- 1624,1668 ---- wxLuaHandler::GetHandler().EnterLuaCriticalSection(); { + lua_State* L = m_wxlState.GetLuaState(); + if (wxStrpbrk(strExpr.c_str(), wxT(" ~=<>+-*/%(){}[]:;,.\"'")) != NULL) { // an expression ! int nOldTop = lua_gettop(L); LuaCharBuffer charbuf(strExpr); ! int nResult = luaL_loadbuffer(L, charbuf.GetData(), charbuf.Length(), "debug"); if (nResult == 0) ! nResult = lua_pcall(L, 0, LUA_MULTRET, 0); /* call main */ switch (nResult) { default: ! if (lua_gettop(L) == nOldTop) { ! lua_pushliteral(L, "OK"); } break; case LUA_ERRRUN: ! lua_pushliteral(L, "Error while running the chunk"); break; case LUA_ERRSYNTAX: ! lua_pushliteral(L, "Syntax error during pre-compilation"); break; case LUA_ERRMEM: ! lua_pushliteral(L, "Memory allocation error"); break; case LUA_ERRERR: ! lua_pushliteral(L, "Unexpected error occurred while running the error message handler"); break; } ! nReference = m_wxlState.tinsert(-1); ! lua_settop(L, nOldTop); } else *************** *** 1941,1958 **** bool fFound = false; ! while (lua_getstack(m_luaState, iLevel++, &ar) != 0) { int iIndex = 0; ! wxString name = lua2wx(lua_getlocal(m_luaState, &ar, ++iIndex)); while (!name.IsEmpty()) { if (strExpr == name) { ! nReference = tinsert(m_luaState, -1); fFound = true; break; } else ! lua_pop(m_luaState, 1); } --- 1672,1689 ---- bool fFound = false; ! while (lua_getstack(L, iLevel++, &ar) != 0) { int iIndex = 0; ! wxString name = lua2wx(lua_getlocal(L, &ar, ++iIndex)); while (!name.IsEmpty()) { if (strExpr == name) { ! nReference = m_wxlState.tinsert(-1); fFound = true; break; } else ! lua_pop(L, 1); } *************** *** 1960,1997 **** break; ! name = lua2wx(lua_getlocal(m_luaState, &ar, ++iIndex)); } if (!fFound) { ! int nOldTop = lua_gettop(m_luaState); ! lua_pushvalue(m_luaState, LUA_GLOBALSINDEX); ! lua_pushnil(m_luaState); ! while (lua_next(m_luaState, -2) != 0) { ! if (lua_type(m_luaState, -2) == LUA_TSTRING) { ! wxString name = lua2wx(lua_tostring(m_luaState, -2)); if (strExpr == name) { ! nReference = tinsert(m_luaState, -1); // reference value and pop it. ! lua_pop(m_luaState, 1); // pop index fFound = true; break; } else ! lua_pop(m_luaState, 1); // removes `value'; } else ! lua_pop(m_luaState, 1); // removes `value'; } ! lua_settop(m_luaState, nOldTop); // the table of globals. } } ! if (nReference != LUA_NOREF && tget(m_luaState, nReference) != 0) { ! tremove(m_luaState, nReference); ! switch (lua_type(m_luaState, -1)) { case LUA_TNIL: --- 1691,1728 ---- break; ! name = lua2wx(lua_getlocal(L, &ar, ++iIndex)); } if (!fFound) { ! int nOldTop = lua_gettop(L); ! lua_pushvalue(L, LUA_GLOBALSINDEX); ! lua_pushnil(L); ! while (lua_next(L, -2) != 0) { ! if (lua_type(L, -2) == LUA_TSTRING) { ! wxString name = lua2wx(lua_tostring(L, -2)); if (strExpr == name) { ! nReference = m_wxlState.tinsert(-1); // reference value and pop it. ! lua_pop(L, 1); // pop index fFound = true; break; } else ! lua_pop(L, 1); // removes `value'; } else ! lua_pop(L, 1); // removes `value'; } ! lua_settop(L, nOldTop); // the table of globals. } } ! if (nReference != LUA_NOREF && (m_wxlState.tget(nReference) != 0)) { ! m_wxlState.tremove(nReference); ! switch (lua_type(L, -1)) { case LUA_TNIL: *************** *** 2000,2012 **** case LUA_TBOOLEAN: ! strResult = MakeBoolean(lua_toboolean(m_luaState, -1)); break; case LUA_TNUMBER: ! strResult = MakeNumber(lua_tonumber(m_luaState, -1)); break; case LUA_TSTRING: ! strResult = wxString::Format(wxT("\"%s\""), lua_tostring(m_luaState, -1)); break; --- 1731,1743 ---- case LUA_TBOOLEAN: ! strResult = wxLuaDebugData::MakeBoolean(lua_toboolean(L, -1)); break; case LUA_TNUMBER: ! strResult = wxLuaDebugData::MakeNumber(lua_tonumber(L, -1)); break; case LUA_TSTRING: ! strResult = wxString::Format(wxT("\"%s\""), lua_tostring(L, -1)); break; *************** *** 2016,2023 **** case LUA_TFUNCTION: ! if (lua_iscfunction(m_luaState, -1)) ! strResult = wxString::Format(wxT("C-function %p"), lua_tocfunction(m_luaState, -1)); else ! strResult = wxString::Format(wxT("lua function %p"), lua_topointer(m_luaState, -1)); break; --- 1747,1754 ---- case LUA_TFUNCTION: ! if (lua_iscfunction(L, -1)) ! strResult = wxString::Format(wxT("C-function %p"), lua_tocfunction(L, -1)); else ! strResult = wxString::Format(wxT("lua function %p"), lua_topointer(L, -1)); break; *************** *** 2031,2035 **** case LUA_TTHREAD: ! strResult = wxString::Format(wxT("thread %p"), lua_topointer(m_luaState, -1)); break; --- 1762,1766 ---- case LUA_TTHREAD: ! strResult = wxString::Format(wxT("thread %p"), lua_topointer(L, -1)); break; *************** *** 2038,2042 **** } ! lua_pop(m_luaState, 1); } } --- 1769,1773 ---- } ! lua_pop(L, 1); } } *************** *** 2048,2053 **** wxString wxLuaDebuggee::GetTableInfo(int index) { ! int nItems = luaL_getn(m_luaState, index); ! const void *pItem = lua_topointer(m_luaState, index); if (nItems == 0) --- 1779,1784 ---- wxString wxLuaDebuggee::GetTableInfo(int index) { ! int nItems = luaL_getn(m_wxlState.GetLuaState(), index); ! const void *pItem = lua_topointer(m_wxlState.GetLuaState(), index); if (nItems == 0) *************** *** 2061,2099 **** if (full) { ! int nTag = ttag(m_luaState, index); const char *pTagName = NULL; if (nTag != TLUA_NOTAG) ! pTagName = GetLuaTagName(m_luaState, nTag); if (pTagName != NULL) ! return wxString::Format(wxT("%p (%s)"), lua_touserdata(m_luaState, index), pTagName); ! ! return wxString::Format(wxT("%p (%u)"), lua_touserdata(m_luaState, index), nTag); ! } ! ! return wxString::Format(wxT("%p"), lua_touserdata(m_luaState, index)); ! } ! ! wxString wxLuaDebuggee::MakeNumber(double dnum) ! { ! long num = (long) dnum; ! if ((double) num == dnum) ! { ! if (num >= 0) ! return wxString::Format(wxT("%lu (0x%lx)"), num, num); ! return wxString::Format(wxT("%ld (0x%lx)"), num, num); } ! return wxString::Format(wxT("%g"), dnum); ! } ! ! wxString wxLuaDebuggee::MakeBoolean(int num) ! { ! if (num) ! return wxT("True"); ! ! return wxT("False"); } --- 1792,1808 ---- if (full) { ! int nTag = m_wxlState.ttag(index); const char *pTagName = NULL; if (nTag != TLUA_NOTAG) ! pTagName = m_wxlState.GetLuaTagName(nTag); if (pTagName != NULL) ! return wxString::Format(wxT("%p (%s)"), lua_touserdata(m_wxlState.GetLuaState(), index), pTagName); ! return wxString::Format(wxT("%p (%u)"), lua_touserdata(m_wxlState.GetLuaState(), index), nTag); } ! return wxString::Format(wxT("%p"), lua_touserdata(m_wxlState.GetLuaState(), index)); } *************** *** 2101,2106 **** { lua_Debug luaDebug; ! lua_getstack(m_luaState, 0, &luaDebug); ! lua_getinfo(m_luaState, "Sln", &luaDebug); lineNumber = luaDebug.currentline - 1; --- 1810,1816 ---- { lua_Debug luaDebug; ! lua_State* L = m_wxlState.GetLuaState(); ! lua_getstack(L, 0, &luaDebug); ! lua_getinfo(L, "Sln", &luaDebug); lineNumber = luaDebug.currentline - 1; *************** *** 2108,2112 **** wxString source = lua2wx(luaDebug.source); ! if (!source.IsEmpty() && source.GetChar(0) == wxT('@')) fileName = source.Mid(1); else --- 1818,1822 ---- wxString source = lua2wx(luaDebug.source); ! if (!source.IsEmpty() && (source.GetChar(0) == wxT('@'))) fileName = source.Mid(1); else Index: Makefile =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/Makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile 25 Nov 2005 19:22:58 -0000 1.4 --- Makefile 1 Dec 2005 06:43:54 -0000 1.5 *************** *** 55,59 **** ../include/wxldtarg.h \ ../include/wxlsock.h \ ! ../include/wxlhandl.h SOURCES = \ --- 55,60 ---- ../include/wxldtarg.h \ ../include/wxlsock.h \ ! ../include/wxlhandl.h \ ! ../include/dservice.h SOURCES = \ *************** *** 62,66 **** wxldtarg.cpp \ wxlsock.cpp \ ! wxlhandl.cpp OBJECTS=$(SOURCES:.cpp=.o) --- 63,68 ---- wxldtarg.cpp \ wxlsock.cpp \ ! wxlhandl.cpp \ ! dservice.cpp OBJECTS=$(SOURCES:.cpp=.o) Index: wxldserv.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxldserv.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** wxldserv.cpp 1 Dec 2005 04:17:29 -0000 1.4 --- wxldserv.cpp 1 Dec 2005 06:43:54 -0000 1.5 *************** *** 39,42 **** --- 39,56 ---- // ---------------------------------------------------------------------------- + // wxLuaDebugServerThread + // ---------------------------------------------------------------------------- + + void *wxLuaDebugServerThread::Entry() + { + m_pServer->ThreadFunction(); + return 0; + } + + void wxLuaDebugServerThread::OnExit() + { + } + + // ---------------------------------------------------------------------------- // wxLuaDebugServer // ---------------------------------------------------------------------------- *************** *** 100,104 **** if (!m_fShutdown) { ! m_pThread = new wxLuaThread(this); return ((m_pThread != NULL) && --- 114,118 ---- if (!m_fShutdown) { ! m_pThread = new wxLuaDebugServerThread(this); return ((m_pThread != NULL) && *************** *** 498,507 **** } - void *wxLuaThread::Entry() - { - m_pServer->ThreadFunction(); - return 0; - } - void wxLuaDebugServer::ThreadFunction() { --- 512,515 ---- *************** *** 649,656 **** } - void wxLuaThread::OnExit() - { - } - #if wxCHECK_VERSION(2, 3, 0) bool wxLuaDebugServer::DisplayStackDialog(wxWindow *pParent) --- 657,660 ---- |