From: John L. <jr...@us...> - 2006-09-13 04:13:51
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv32141/wxLua/modules/wxluasocket/src Modified Files: dservice.cpp wxldserv.cpp wxldtarg.cpp wxlsock.cpp Log Message: Use GetCount not Count for wxArrays have wxLuaDebugData return the array as a pointer since it may not exist and add checks for it Rename wxLua socket enums so they start with wxLUASOCKET_XXX Removed wxLuaBuffer and just use wxArrayString instead Use wxInt32 wxUint32 for wxLuaSocket code not int, short, etc for 64 bit processors rework all wxLuaSocketBase::Read/Write code Index: wxldtarg.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxldtarg.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** wxldtarg.cpp 7 Sep 2006 22:42:19 -0000 1.19 --- wxldtarg.cpp 13 Sep 2006 04:13:48 -0000 1.20 *************** *** 34,44 **** // ---------------------------------------------------------------------------- ! // wxLuaBuffer ! // ---------------------------------------------------------------------------- ! ! IMPLEMENT_ABSTRACT_CLASS(wxLuaBuffer, wxObject) ! ! // ---------------------------------------------------------------------------- ! // wxLuaDebugTarget::LuaThread // ---------------------------------------------------------------------------- --- 34,38 ---- // ---------------------------------------------------------------------------- ! // wxLuaDebugTarget::LuaThread // ---------------------------------------------------------------------------- *************** *** 65,68 **** --- 59,63 ---- m_fRunning(false), m_fStopped(false), + m_fExiting(false), m_fErrorsSeen(false), m_nFramesUntilBreak(0), *************** *** 109,112 **** --- 104,109 ---- bool wxLuaDebugTarget::Run() { + wxCHECK_MSG(m_pThread == NULL, false, wxT("wxLuaDebugTarget::Run already called")); + // Assume something is going to go wrong m_fErrorsSeen = true; *************** *** 131,146 **** m_fErrorsSeen = false; ! size_t idx, count = m_bufferList.Count(); for (idx = 0; idx < count; ++idx) { int rc = LUA_ERRERR; ! const wxLuaBuffer *item = m_bufferList.Item(idx); ! ! rc = m_wxlState.LuaDoBuffer(wx2lua(item->GetBuffer()), ! item->GetBufferLength(), ! wx2lua(item->GetFileName())); ! delete item; wxString errorMsg; --- 128,142 ---- m_fErrorsSeen = false; ! size_t idx, count = m_bufferArray.GetCount(); for (idx = 0; idx < count; ++idx) { int rc = LUA_ERRERR; ! wxString luaBuffer = m_bufferArray.Item(idx); ! wxString bufFilename = luaBuffer.BeforeFirst(wxT('\0')); ! wxString buf = luaBuffer.AfterFirst(wxT('\0')); ! rc = m_wxlState.LuaDoBuffer(wx2lua(buf), buf.Length(), ! wx2lua(bufFilename)); wxString errorMsg; *************** *** 149,155 **** --- 145,154 ---- { NotifyError(errorMsg); + m_bufferArray.Clear(); break; } } + + m_bufferArray.Clear(); } } *************** *** 176,214 **** m_clientSocket.Connect(m_serverName, m_portNumber); ! m_fConnected = true; fThreadRunning = true; } ! catch(...) { } ! while (fThreadRunning && !m_pThread->TestDestroy()) { try { ! wxLuaDebugCommands_Type debugCommand = (wxLuaDebugCommands_Type)m_clientSocket.ReadByte(); switch (debugCommand) { ! case wxLUA_CMD_ADD_BREAKPOINT: { wxString fileName = m_clientSocket.ReadString(); ! int lineNumber = m_clientSocket.ReadInt(); AddBreakPoint(fileName, lineNumber); break; } ! case wxLUA_CMD_REMOVE_BREAKPOINT: { wxString fileName = m_clientSocket.ReadString(); ! int lineNumber = m_clientSocket.ReadInt(); RemoveBreakPoint(fileName, lineNumber); break; } ! case wxLUA_CMD_CLEAR_ALL_BREAKPOINTS: ClearAllBreakPoints(); break; ! ! case wxLUA_CMD_RUN_BUFFER: { wxString fileName = m_clientSocket.ReadString(); --- 175,219 ---- m_clientSocket.Connect(m_serverName, m_portNumber); ! m_fConnected = true; fThreadRunning = true; } ! catch(wxLuaSocketException &) { } ! while (fThreadRunning && !m_pThread->TestDestroy() && !m_resetRequested && !m_fExiting) { try { ! wxLuaSocketDebugCommands_Type debugCommand = (wxLuaSocketDebugCommands_Type)m_clientSocket.ReadByte(); switch (debugCommand) { ! case wxLUASOCKET_DEBUG_CMD_NONE : ! { ! // This is an error, but maybe we can continue? ! break; ! } ! case wxLUASOCKET_DEBUG_CMD_ADD_BREAKPOINT: { wxString fileName = m_clientSocket.ReadString(); ! int lineNumber = m_clientSocket.ReadInt32(); AddBreakPoint(fileName, lineNumber); break; } ! case wxLUASOCKET_DEBUG_CMD_REMOVE_BREAKPOINT: { wxString fileName = m_clientSocket.ReadString(); ! int lineNumber = m_clientSocket.ReadInt32(); RemoveBreakPoint(fileName, lineNumber); break; } ! case wxLUASOCKET_DEBUG_CMD_CLEAR_ALL_BREAKPOINTS: ! { ClearAllBreakPoints(); break; ! } ! case wxLUASOCKET_DEBUG_CMD_RUN_BUFFER: { wxString fileName = m_clientSocket.ReadString(); *************** *** 218,271 **** break; } ! case wxLUA_CMD_DEBUG_STEP: Step(); break; ! ! case wxLUA_CMD_DEBUG_STEPOVER: StepOver(); break; ! ! case wxLUA_CMD_DEBUG_STEPOUT: StepOut(); break; ! ! case wxLUA_CMD_DEBUG_CONTINUE: Continue(); break; ! ! case wxLUA_CMD_DEBUG_BREAK: Break(); break; ! ! case wxLUA_CMD_ENUMERATE_STACK: EnumerateStack(); break; ! ! case wxLUA_CMD_ENUMERATE_STACK_ENTRY: { ! int stackRef = m_clientSocket.ReadInt(); EnumerateStackEntry(stackRef); break; } ! case wxLUA_CMD_ENUMERATE_TABLE_REF: { ! int tableRef = m_clientSocket.ReadInt(); ! int index = m_clientSocket.ReadInt(); long itemNode = m_clientSocket.ReadLong(); EnumerateTable(tableRef, index, itemNode); break; } ! case wxLUA_CMD_RESET: Reset(); break; ! ! case wxLUA_CMD_EVALUATE_EXPR: { ! int exprRef = m_clientSocket.ReadInt(); wxString buffer = m_clientSocket.ReadString(); EvaluateExpr(exprRef, buffer); break; } ! case wxLUA_CMD_CLEAR_DEBUG_REFERENCES: { size_t idx, idxMax = m_references.GetCount(); --- 223,283 ---- break; } ! case wxLUASOCKET_DEBUG_CMD_DEBUG_STEP: ! { Step(); break; ! } ! case wxLUASOCKET_DEBUG_CMD_DEBUG_STEPOVER: ! { StepOver(); break; ! } ! case wxLUASOCKET_DEBUG_CMD_DEBUG_STEPOUT: ! { StepOut(); break; ! } ! case wxLUASOCKET_DEBUG_CMD_DEBUG_CONTINUE: ! { Continue(); break; ! } ! case wxLUASOCKET_DEBUG_CMD_DEBUG_BREAK: ! { Break(); break; ! } ! case wxLUASOCKET_DEBUG_CMD_ENUMERATE_STACK: ! { EnumerateStack(); break; ! } ! case wxLUASOCKET_DEBUG_CMD_ENUMERATE_STACK_ENTRY: { ! int stackRef = m_clientSocket.ReadInt32(); EnumerateStackEntry(stackRef); break; } ! case wxLUASOCKET_DEBUG_CMD_ENUMERATE_TABLE_REF: { ! int tableRef = m_clientSocket.ReadInt32(); ! int index = m_clientSocket.ReadInt32(); long itemNode = m_clientSocket.ReadLong(); EnumerateTable(tableRef, index, itemNode); break; } ! case wxLUASOCKET_DEBUG_CMD_RESET: ! { Reset(); break; ! } ! case wxLUASOCKET_DEBUG_CMD_EVALUATE_EXPR: { ! int exprRef = m_clientSocket.ReadInt32(); wxString buffer = m_clientSocket.ReadString(); EvaluateExpr(exprRef, buffer); break; } ! case wxLUASOCKET_DEBUG_CMD_CLEAR_DEBUG_REFERENCES: { size_t idx, idxMax = m_references.GetCount(); *************** *** 275,283 **** m_wxlState.tremove(iItem); } break; } ! case wxLUA_CMD_DISABLE_BREAKPOINT: break; ! case wxLUA_CMD_ENABLE_BREAKPOINT: break; } --- 287,296 ---- m_wxlState.tremove(iItem); } + // FIXME - should we also remove the array items break; } ! case wxLUASOCKET_DEBUG_CMD_DISABLE_BREAKPOINT: break; ! case wxLUASOCKET_DEBUG_CMD_ENABLE_BREAKPOINT: break; } *************** *** 290,297 **** } bool wxLuaDebugTarget::AddBreakPoint(const wxString &fileName, int lineNumber) { wxCriticalSectionLocker locker(m_breakPointListCriticalSection); ! m_breakPointList.Add(wxString::Format(wxT("%u:"), lineNumber) + fileName); return false; } --- 303,315 ---- } + wxString wxLuaDebugTarget::CreateBreakPoint(const wxString &fileName, int lineNumber) const + { + return wxString::Format(wxT("%u:"), lineNumber) + fileName; + } + bool wxLuaDebugTarget::AddBreakPoint(const wxString &fileName, int lineNumber) { wxCriticalSectionLocker locker(m_breakPointListCriticalSection); ! m_breakPointList.Add(CreateBreakPoint(fileName, lineNumber)); return false; } *************** *** 300,304 **** { wxCriticalSectionLocker locker(m_breakPointListCriticalSection); ! m_breakPointList.Remove(wxString::Format(wxT("%u:"), lineNumber) + fileName); return true; } --- 318,322 ---- { wxCriticalSectionLocker locker(m_breakPointListCriticalSection); ! m_breakPointList.Remove(CreateBreakPoint(fileName, lineNumber)); return true; } *************** *** 313,324 **** bool wxLuaDebugTarget::Run(const wxString &fileName, const wxString &buffer) { ! wxLuaBuffer *pBuffer = new wxLuaBuffer(fileName, buffer); ! ! if (pBuffer != NULL) ! { ! m_bufferList.Add(pBuffer); ! return true; ! } ! return false; } --- 331,336 ---- bool wxLuaDebugTarget::Run(const wxString &fileName, const wxString &buffer) { ! m_bufferArray.Add(fileName + wxT('\0') + buffer); ! return true; } *************** *** 567,575 **** bool wxLuaDebugTarget::NotifyBreak(const wxString &fileName, int lineNumber) { ! if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUA_EVENT_DEBUG_BREAK); m_clientSocket.WriteString(fileName); ! m_clientSocket.WriteInt(lineNumber); return true; } --- 579,587 ---- bool wxLuaDebugTarget::NotifyBreak(const wxString &fileName, int lineNumber) { ! if (WaitForConnect() && !m_resetRequested) { ! m_clientSocket.WriteByte(wxLUASOCKET_DEBUG_EVENT_BREAK); m_clientSocket.WriteString(fileName); ! m_clientSocket.WriteInt32(lineNumber); return true; } *************** *** 581,585 **** if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUA_EVENT_DEBUG_PRINT); m_clientSocket.WriteString(errorMsg); return true; --- 593,597 ---- if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUASOCKET_DEBUG_EVENT_PRINT); m_clientSocket.WriteString(errorMsg); return true; *************** *** 592,596 **** if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUA_EVENT_DEBUG_ERROR); m_clientSocket.WriteString(errorMsg); return true; --- 604,608 ---- if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUASOCKET_DEBUG_EVENT_ERROR); m_clientSocket.WriteString(errorMsg); return true; *************** *** 607,611 **** if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUA_EVENT_DEBUG_EXIT); return true; } --- 619,623 ---- if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUASOCKET_DEBUG_EVENT_EXIT); return true; } *************** *** 617,621 **** if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUA_EVENT_DEBUG_STACK_ENUM); m_clientSocket.WriteDebugData(debugData); return true; --- 629,633 ---- if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUASOCKET_DEBUG_EVENT_STACK_ENUM); m_clientSocket.WriteDebugData(debugData); return true; *************** *** 630,635 **** if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUA_EVENT_DEBUG_STACK_ENTRY_ENUM); ! m_clientSocket.WriteInt(entryRef); m_clientSocket.WriteDebugData(debugData); return true; --- 642,647 ---- if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUASOCKET_DEBUG_EVENT_STACK_ENTRY_ENUM); ! m_clientSocket.WriteInt32(entryRef); m_clientSocket.WriteDebugData(debugData); return true; *************** *** 644,648 **** if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUA_EVENT_DEBUG_TABLE_ENUM); m_clientSocket.WriteLong(itemNode); m_clientSocket.WriteDebugData(debugData); --- 656,660 ---- if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUASOCKET_DEBUG_EVENT_TABLE_ENUM); m_clientSocket.WriteLong(itemNode); m_clientSocket.WriteDebugData(debugData); *************** *** 658,663 **** if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUA_EVENT_DEBUG_EVALUATE_EXPR); ! m_clientSocket.WriteInt(exprRef); m_clientSocket.WriteString(strResult); return true; --- 670,675 ---- if (WaitForConnect()) { ! m_clientSocket.WriteByte(wxLUASOCKET_DEBUG_EVENT_EVALUATE_EXPR); ! m_clientSocket.WriteInt32(exprRef); m_clientSocket.WriteString(strResult); return true; *************** *** 679,695 **** bool fWait = false; m_fStopped = true; if (m_forceBreak) { if (m_resetRequested) { NotifyExit(); wxExit(); } ! int lineNumber = 0; ! wxString fileName = GetDebugInfo(lineNumber); ! if (NotifyBreak(fileName, lineNumber)) ! fWait = true; } else --- 691,713 ---- bool fWait = false; m_fStopped = true; + if (m_forceBreak) { if (m_resetRequested) { + fWait = true; + m_fExiting = true; NotifyExit(); wxExit(); } ! if (!m_fExiting) ! { ! int lineNumber = 0; ! wxString fileName = GetDebugInfo(lineNumber); ! if (NotifyBreak(fileName, lineNumber)) ! fWait = true; ! } } else *************** *** 770,782 **** } ! bool wxLuaDebugTarget::AtBreakPoint(const wxString &fileName, ! int lineNumber) const { wxCriticalSectionLocker locker(m_breakPointListCriticalSection); ! ! wxString breakPoint; ! breakPoint = breakPoint.Format(wxT("%u:"), lineNumber) + fileName; ! ! return (m_breakPointList.Index(breakPoint) != wxNOT_FOUND); } --- 788,795 ---- } ! bool wxLuaDebugTarget::AtBreakPoint(const wxString &fileName, int lineNumber) const { wxCriticalSectionLocker locker(m_breakPointListCriticalSection); ! return (m_breakPointList.Index(CreateBreakPoint(fileName, lineNumber)) != wxNOT_FOUND); } Index: dservice.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/dservice.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** dservice.cpp 7 Sep 2006 22:42:19 -0000 1.20 --- dservice.cpp 13 Sep 2006 04:13:48 -0000 1.21 *************** *** 68,82 **** // ---------------------------------------------------------------------------- ! int wxLuaDebugSocket::Read(char *buffer, int length) { wxCHECK_MSG(m_socket, 0, wxT("Invalid wxSocketBase")); ! m_socket->Read(buffer, (wxUint32)length); return m_socket->LastCount(); } ! int wxLuaDebugSocket::Write(const char *buffer, int length) { wxCHECK_MSG(m_socket, 0, wxT("Invalid wxSocketBase")); ! m_socket->Write(buffer, (wxUint32)length); return m_socket->LastCount(); } --- 68,82 ---- // ---------------------------------------------------------------------------- ! int wxLuaDebugSocket::Read(char *buffer, wxUint32 length) { wxCHECK_MSG(m_socket, 0, wxT("Invalid wxSocketBase")); ! m_socket->Read(buffer, length); return m_socket->LastCount(); } ! int wxLuaDebugSocket::Write(const char *buffer, wxUint32 length) { wxCHECK_MSG(m_socket, 0, wxT("Invalid wxSocketBase")); ! m_socket->Write(buffer, length); return m_socket->LastCount(); } *************** *** 226,236 **** if (debugSocket && debuggee) { ! wxLuaDebugCommands_Type debugCommand = (wxLuaDebugCommands_Type)debugSocket->ReadByte(); switch(debugCommand) { ! case wxLUA_CMD_ADD_BREAKPOINT: { wxString fileName = debugSocket->ReadString(); ! int lineNumber = debugSocket->ReadInt(); debuggee->AddBreakPoint(fileName, lineNumber); --- 226,240 ---- if (debugSocket && debuggee) { ! wxLuaSocketDebugCommands_Type debugCommand = (wxLuaSocketDebugCommands_Type)debugSocket->ReadByte(); switch(debugCommand) { ! case wxLUASOCKET_DEBUG_CMD_NONE : ! { ! break; ! } ! case wxLUASOCKET_DEBUG_CMD_ADD_BREAKPOINT: { wxString fileName = debugSocket->ReadString(); ! int lineNumber = debugSocket->ReadInt32(); debuggee->AddBreakPoint(fileName, lineNumber); *************** *** 238,245 **** break; ! case wxLUA_CMD_REMOVE_BREAKPOINT: { wxString fileName = debugSocket->ReadString(); ! int lineNumber = debugSocket->ReadInt(); debuggee->RemoveBreakPoint(fileName, lineNumber); --- 242,249 ---- break; ! case wxLUASOCKET_DEBUG_CMD_REMOVE_BREAKPOINT: { wxString fileName = debugSocket->ReadString(); ! int lineNumber = debugSocket->ReadInt32(); debuggee->RemoveBreakPoint(fileName, lineNumber); *************** *** 247,254 **** break; ! case wxLUA_CMD_DISABLE_BREAKPOINT: { wxString fileName = debugSocket->ReadString(); ! int lineNumber = debugSocket->ReadInt(); debuggee->DisableBreakPoint(fileName, lineNumber); --- 251,258 ---- break; ! case wxLUASOCKET_DEBUG_CMD_DISABLE_BREAKPOINT: { wxString fileName = debugSocket->ReadString(); ! int lineNumber = debugSocket->ReadInt32(); debuggee->DisableBreakPoint(fileName, lineNumber); *************** *** 257,264 **** ! case wxLUA_CMD_ENABLE_BREAKPOINT: { wxString fileName = debugSocket->ReadString(); ! int lineNumber = debugSocket->ReadInt(); debuggee->EnableBreakPoint(fileName, lineNumber); --- 261,268 ---- ! case wxLUASOCKET_DEBUG_CMD_ENABLE_BREAKPOINT: { wxString fileName = debugSocket->ReadString(); ! int lineNumber = debugSocket->ReadInt32(); debuggee->EnableBreakPoint(fileName, lineNumber); *************** *** 266,308 **** break; ! case wxLUA_CMD_CLEAR_ALL_BREAKPOINTS: debuggee->ClearAllBreakPoints(); break; ! case wxLUA_CMD_DEBUG_STEP: debuggee->Step(); break; ! case wxLUA_CMD_DEBUG_STEPOVER: debuggee->StepOver(); break; ! case wxLUA_CMD_DEBUG_STEPOUT: debuggee->StepOut(); break; ! case wxLUA_CMD_DEBUG_CONTINUE: debuggee->Continue(); break; ! case wxLUA_CMD_DEBUG_BREAK: debuggee->Break(); break; ! case wxLUA_CMD_ENUMERATE_STACK: debuggee->EnumerateStack(); break; ! case wxLUA_CMD_ENUMERATE_STACK_ENTRY: { ! int stackRef = debugSocket->ReadInt(); debuggee->EnumerateStackEntry(stackRef); } break; ! case wxLUA_CMD_ENUMERATE_TABLE_REF: { ! int tableRef = debugSocket->ReadInt(); ! int index = debugSocket->ReadInt(); long itemNode = debugSocket->ReadLong(); debuggee->EnumerateTable(tableRef, index, itemNode); --- 270,312 ---- break; ! case wxLUASOCKET_DEBUG_CMD_CLEAR_ALL_BREAKPOINTS: debuggee->ClearAllBreakPoints(); break; ! case wxLUASOCKET_DEBUG_CMD_DEBUG_STEP: debuggee->Step(); break; ! case wxLUASOCKET_DEBUG_CMD_DEBUG_STEPOVER: debuggee->StepOver(); break; ! case wxLUASOCKET_DEBUG_CMD_DEBUG_STEPOUT: debuggee->StepOut(); break; ! case wxLUASOCKET_DEBUG_CMD_DEBUG_CONTINUE: debuggee->Continue(); break; ! case wxLUASOCKET_DEBUG_CMD_DEBUG_BREAK: debuggee->Break(); break; ! case wxLUASOCKET_DEBUG_CMD_ENUMERATE_STACK: debuggee->EnumerateStack(); break; ! case wxLUASOCKET_DEBUG_CMD_ENUMERATE_STACK_ENTRY: { ! int stackRef = debugSocket->ReadInt32(); debuggee->EnumerateStackEntry(stackRef); } break; ! case wxLUASOCKET_DEBUG_CMD_ENUMERATE_TABLE_REF: { ! int tableRef = debugSocket->ReadInt32(); ! int index = debugSocket->ReadInt32(); long itemNode = debugSocket->ReadLong(); debuggee->EnumerateTable(tableRef, index, itemNode); *************** *** 310,320 **** break; ! case wxLUA_CMD_RESET: debuggee->Reset(); break; ! case wxLUA_CMD_EVALUATE_EXPR: { ! int exprRef = debugSocket->ReadInt(); wxString buffer = debugSocket->ReadString(); debuggee->EvaluateExpr(exprRef, buffer); --- 314,324 ---- break; ! case wxLUASOCKET_DEBUG_CMD_RESET: debuggee->Reset(); break; ! case wxLUASOCKET_DEBUG_CMD_EVALUATE_EXPR: { ! int exprRef = debugSocket->ReadInt32(); wxString buffer = debugSocket->ReadString(); debuggee->EvaluateExpr(exprRef, buffer); *************** *** 322,331 **** break; ! case wxLUA_CMD_CLEAR_DEBUG_REFERENCES: { debuggee->ClearReferences(); } break; ! case wxLUA_CMD_RUN_BUFFER: break; // FIXME - not impemented } } --- 326,335 ---- break; ! case wxLUASOCKET_DEBUG_CMD_CLEAR_DEBUG_REFERENCES: { debuggee->ClearReferences(); } break; ! case wxLUASOCKET_DEBUG_CMD_RUN_BUFFER: break; // FIXME - not impemented } } *************** *** 450,454 **** { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUA_EVENT_DEBUG_BREAK); #if wxCHECK_VERSION(2,3,0) dSocket->WriteString(fileName.GetFullPath()); --- 454,458 ---- { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUASOCKET_DEBUG_EVENT_BREAK); #if wxCHECK_VERSION(2,3,0) dSocket->WriteString(fileName.GetFullPath()); *************** *** 456,460 **** dSocket->WriteString(fileName); #endif ! dSocket->WriteInt(lineNumber); if (!dSocket->Error()) --- 460,464 ---- dSocket->WriteString(fileName); #endif ! dSocket->WriteInt32(lineNumber); if (!dSocket->Error()) *************** *** 476,480 **** { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUA_EVENT_DEBUG_ERROR); dSocket->WriteString(errorMsg); --- 480,484 ---- { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUASOCKET_DEBUG_EVENT_ERROR); dSocket->WriteString(errorMsg); *************** *** 497,501 **** { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUA_EVENT_DEBUG_ERROR); dSocket->WriteString(errorMsg); --- 501,505 ---- { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUASOCKET_DEBUG_EVENT_ERROR); dSocket->WriteString(errorMsg); *************** *** 518,522 **** { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUA_EVENT_DEBUG_EXIT); if (!dSocket->Error()) --- 522,526 ---- { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUASOCKET_DEBUG_EVENT_EXIT); if (!dSocket->Error()) *************** *** 538,542 **** { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUA_EVENT_DEBUG_STACK_ENUM); dSocket->WriteDebugData(debugData); --- 542,546 ---- { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUASOCKET_DEBUG_EVENT_STACK_ENUM); dSocket->WriteDebugData(debugData); *************** *** 559,564 **** { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUA_EVENT_DEBUG_STACK_ENTRY_ENUM); ! dSocket->WriteInt(entryRef); dSocket->WriteDebugData(debugData); --- 563,568 ---- { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUASOCKET_DEBUG_EVENT_STACK_ENTRY_ENUM); ! dSocket->WriteInt32(entryRef); dSocket->WriteDebugData(debugData); *************** *** 581,585 **** { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUA_EVENT_DEBUG_TABLE_ENUM); dSocket->WriteLong(itemNode); dSocket->WriteDebugData(debugData); --- 585,589 ---- { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUASOCKET_DEBUG_EVENT_TABLE_ENUM); dSocket->WriteLong(itemNode); dSocket->WriteDebugData(debugData); *************** *** 603,608 **** { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUA_EVENT_DEBUG_EVALUATE_EXPR); ! dSocket->WriteInt(exprRef); dSocket->WriteString(strResult); --- 607,612 ---- { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUASOCKET_DEBUG_EVENT_EVALUATE_EXPR); ! dSocket->WriteInt32(exprRef); dSocket->WriteString(strResult); *************** *** 627,631 **** { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUA_EVENT_DEBUG_BREAKPOINT_ADDED); #if wxCHECK_VERSION(2,3,0) dSocket->WriteString(breakPoint.GetFileName().GetFullPath()); --- 631,635 ---- { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUASOCKET_DEBUG_EVENT_BREAKPOINT_ADDED); #if wxCHECK_VERSION(2,3,0) dSocket->WriteString(breakPoint.GetFileName().GetFullPath()); *************** *** 633,638 **** dSocket->WriteString(breakPoint.GetFileName()); #endif ! dSocket->WriteInt(breakPoint.GetLine()); ! dSocket->WriteInt((int)breakPoint.GetEnabled()); if (!dSocket->Error()) --- 637,642 ---- dSocket->WriteString(breakPoint.GetFileName()); #endif ! dSocket->WriteInt32(breakPoint.GetLine()); ! dSocket->WriteInt32((int)breakPoint.GetEnabled()); if (!dSocket->Error()) *************** *** 657,661 **** { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUA_EVENT_DEBUG_BREAKPOINT_REMOVED); #if wxCHECK_VERSION(2,3,0) dSocket->WriteString(breakPoint.GetFileName().GetFullPath()); --- 661,665 ---- { wxLuaDebugSocket* dSocket = m_debuggerSocketList[i]; ! dSocket->WriteByte(wxLUASOCKET_DEBUG_EVENT_BREAKPOINT_REMOVED); #if wxCHECK_VERSION(2,3,0) dSocket->WriteString(breakPoint.GetFileName().GetFullPath()); *************** *** 663,668 **** dSocket->WriteString(breakPoint.GetFileName()); #endif ! dSocket->WriteInt(breakPoint.GetLine()); ! dSocket->WriteInt((int)breakPoint.GetEnabled()); if (!dSocket->Error()) --- 667,672 ---- dSocket->WriteString(breakPoint.GetFileName()); #endif ! dSocket->WriteInt32(breakPoint.GetLine()); ! dSocket->WriteInt32((int)breakPoint.GetEnabled()); if (!dSocket->Error()) *************** *** 766,770 **** // Events from Debug Service int debuggeeEvent = m_debuggerSocket->ReadByte(); ! HandleDebugEvent((wxLuaDebugEvents_Type) debuggeeEvent); // Enable input events again. --- 770,774 ---- // Events from Debug Service int debuggeeEvent = m_debuggerSocket->ReadByte(); ! HandleDebugEvent((wxLuaScoketDebugEvents_Type) debuggeeEvent); // Enable input events again. Index: wxldserv.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxldserv.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** wxldserv.cpp 7 Sep 2006 22:42:19 -0000 1.18 --- wxldserv.cpp 13 Sep 2006 04:13:48 -0000 1.19 *************** *** 25,32 **** #include "wxluasocket/include/wxldserv.h" #include "wxluasocket/include/wxlhandl.h" ! ! #if wxCHECK_VERSION(2, 3, 0) ! #include "wxluadebug/include/staktree.h" ! #endif // wxCHECK_VERSION(2, 3, 0) #if !wxCHECK_VERSION(2, 6, 0) --- 25,29 ---- #include "wxluasocket/include/wxldserv.h" #include "wxluasocket/include/wxlhandl.h" ! #include "wxluadebug/include/staktree.h" #if !wxCHECK_VERSION(2, 6, 0) *************** *** 150,161 **** { if (GetSocketBase()->IsConnected() && ! GetSocketBase()->WriteByte(wxLUA_CMD_ADD_BREAKPOINT) && GetSocketBase()->WriteString(fileName) && ! GetSocketBase()->WriteInt(lineNumber)) { return true; } } ! catch(wxLuaSocketException & /*e*/) { } --- 147,158 ---- { if (GetSocketBase()->IsConnected() && ! GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_ADD_BREAKPOINT) && GetSocketBase()->WriteString(fileName) && ! GetSocketBase()->WriteInt32(lineNumber)) { return true; } } ! catch(wxLuaSocketException &) { } *************** *** 171,182 **** { if (GetSocketBase()->IsConnected() && ! GetSocketBase()->WriteByte(wxLUA_CMD_REMOVE_BREAKPOINT) && GetSocketBase()->WriteString(fileName) && ! GetSocketBase()->WriteInt(lineNumber)) { return true; } } ! catch(wxLuaSocketException & /*e*/) { } --- 168,179 ---- { if (GetSocketBase()->IsConnected() && ! GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_REMOVE_BREAKPOINT) && GetSocketBase()->WriteString(fileName) && ! GetSocketBase()->WriteInt32(lineNumber)) { return true; } } ! catch(wxLuaSocketException &) { } *************** *** 191,202 **** try { ! if (GetSocketBase()->WriteByte(wxLUA_CMD_DISABLE_BREAKPOINT) && GetSocketBase()->WriteString(fileName) && ! GetSocketBase()->WriteInt(lineNumber)) { return true; } } ! catch(wxLuaSocketException & /*e*/) { } --- 188,199 ---- try { ! if (GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_DISABLE_BREAKPOINT) && GetSocketBase()->WriteString(fileName) && ! GetSocketBase()->WriteInt32(lineNumber)) { return true; } } ! catch(wxLuaSocketException &) { } *************** *** 211,222 **** try { ! if (GetSocketBase()->WriteByte(wxLUA_CMD_ENABLE_BREAKPOINT) && GetSocketBase()->WriteString(fileName) && ! GetSocketBase()->WriteInt(lineNumber)) { return true; } } ! catch(wxLuaSocketException & /*e*/) { } --- 208,219 ---- try { ! if (GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_ENABLE_BREAKPOINT) && GetSocketBase()->WriteString(fileName) && ! GetSocketBase()->WriteInt32(lineNumber)) { return true; } } ! catch(wxLuaSocketException &) { } *************** *** 232,241 **** { if (GetSocketBase()->IsConnected() && ! GetSocketBase()->WriteByte(wxLUA_CMD_CLEAR_ALL_BREAKPOINTS)) { return true; } } ! catch(wxLuaSocketException & /*e*/) { } --- 229,238 ---- { if (GetSocketBase()->IsConnected() && ! GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_CLEAR_ALL_BREAKPOINTS)) { return true; } } ! catch(wxLuaSocketException &) { } *************** *** 250,254 **** try { ! if (GetSocketBase()->WriteByte(wxLUA_CMD_RUN_BUFFER) && GetSocketBase()->WriteString(fileName) && GetSocketBase()->WriteString(buffer)) --- 247,251 ---- try { ! if (GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_RUN_BUFFER) && GetSocketBase()->WriteString(fileName) && GetSocketBase()->WriteString(buffer)) *************** *** 257,261 **** } } ! catch(wxLuaSocketException & /*e*/) { } --- 254,258 ---- } } ! catch(wxLuaSocketException &) { } *************** *** 270,276 **** try { ! return GetSocketBase()->WriteByte(wxLUA_CMD_DEBUG_STEP); } ! catch(wxLuaSocketException & /*e*/) { } --- 267,273 ---- try { ! return GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_DEBUG_STEP); } ! catch(wxLuaSocketException &) { } *************** *** 285,291 **** try { ! return GetSocketBase()->WriteByte(wxLUA_CMD_DEBUG_STEPOVER); } ! catch(wxLuaSocketException & /*e*/) { } --- 282,288 ---- try { ! return GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_DEBUG_STEPOVER); } ! catch(wxLuaSocketException &) { } *************** *** 300,306 **** try { ! return GetSocketBase()->WriteByte(wxLUA_CMD_DEBUG_STEPOUT); } ! catch(wxLuaSocketException & /*e*/) { } --- 297,303 ---- try { ! return GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_DEBUG_STEPOUT); } ! catch(wxLuaSocketException &) { } *************** *** 315,321 **** try { ! return GetSocketBase()->WriteByte(wxLUA_CMD_DEBUG_CONTINUE); } ! catch(wxLuaSocketException & /*e*/) { } --- 312,318 ---- try { ! return GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_DEBUG_CONTINUE); } ! catch(wxLuaSocketException &) { } *************** *** 330,336 **** try { ! return GetSocketBase()->WriteByte(wxLUA_CMD_DEBUG_BREAK); } ! catch(wxLuaSocketException & /*e*/) { } --- 327,333 ---- try { ! return GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_DEBUG_BREAK); } ! catch(wxLuaSocketException &) { } *************** *** 345,351 **** try { ! return GetSocketBase()->WriteByte(wxLUA_CMD_RESET); } ! catch(wxLuaSocketException & /*e*/) { } --- 342,348 ---- try { ! return GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_RESET); } ! catch(wxLuaSocketException &) { } *************** *** 360,366 **** try { ! return GetSocketBase()->WriteByte(wxLUA_CMD_ENUMERATE_STACK); } ! catch(wxLuaSocketException & /*e*/) { } --- 357,363 ---- try { ! return GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_ENUMERATE_STACK); } ! catch(wxLuaSocketException &) { } *************** *** 375,385 **** try { ! if (GetSocketBase()->WriteByte(wxLUA_CMD_ENUMERATE_STACK_ENTRY) && ! GetSocketBase()->WriteInt(stackEntry)) { return true; } } ! catch(wxLuaSocketException & /*e*/) { } --- 372,382 ---- try { ! if (GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_ENUMERATE_STACK_ENTRY) && ! GetSocketBase()->WriteInt32(stackEntry)) { return true; } } ! catch(wxLuaSocketException &) { } *************** *** 394,400 **** try { ! if (GetSocketBase()->WriteByte(wxLUA_CMD_ENUMERATE_TABLE_REF) && ! GetSocketBase()->WriteInt(tableRef) && ! GetSocketBase()->WriteInt(nIndex) && GetSocketBase()->WriteLong(nItemNode)) { --- 391,397 ---- try { ! if (GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_ENUMERATE_TABLE_REF) && ! GetSocketBase()->WriteInt32(tableRef) && ! GetSocketBase()->WriteInt32(nIndex) && GetSocketBase()->WriteLong(nItemNode)) { *************** *** 402,406 **** } } ! catch(wxLuaSocketException & /*e*/) { } --- 399,403 ---- } } ! catch(wxLuaSocketException &) { } *************** *** 415,424 **** try { ! if (GetSocketBase()->WriteByte(wxLUA_CMD_CLEAR_DEBUG_REFERENCES)) { return true; } } ! catch(wxLuaSocketException & /*e*/) { } --- 412,421 ---- try { ! if (GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_CLEAR_DEBUG_REFERENCES)) { return true; } } ! catch(wxLuaSocketException &) { } *************** *** 433,438 **** try { ! if (GetSocketBase()->WriteByte(wxLUA_CMD_EVALUATE_EXPR) && ! GetSocketBase()->WriteInt(exprRef) && GetSocketBase()->WriteString(strExpression)) { --- 430,435 ---- try { ! if (GetSocketBase()->WriteByte(wxLUASOCKET_DEBUG_CMD_EVALUATE_EXPR) && ! GetSocketBase()->WriteInt32(exprRef) && GetSocketBase()->WriteString(strExpression)) { *************** *** 440,444 **** } } ! catch(wxLuaSocketException & /*e*/) { } --- 437,441 ---- } } ! catch(wxLuaSocketException &) { } *************** *** 508,512 **** } ! int wxLuaDebuggerBase::HandleDebugEvent(wxLuaDebugEvents_Type event_type) { wxCHECK_MSG(GetSocketBase(), event_type, wxT("Invalid socket")); --- 505,509 ---- } ! int wxLuaDebuggerBase::HandleDebugEvent(wxLuaScoketDebugEvents_Type event_type) { wxCHECK_MSG(GetSocketBase(), event_type, wxT("Invalid socket")); *************** *** 514,521 **** switch (event_type) { ! case wxLUA_EVENT_DEBUG_BREAK: { wxString fileName = GetSocketBase()->ReadString(); ! int lineNumber = GetSocketBase()->ReadInt(); wxLuaDebugEvent debugEvent(wxEVT_WXLUA_DEBUG_BREAK, lineNumber, fileName); --- 511,518 ---- switch (event_type) { ! case wxLUASOCKET_DEBUG_EVENT_BREAK: { wxString fileName = GetSocketBase()->ReadString(); ! int lineNumber = GetSocketBase()->ReadInt32(); wxLuaDebugEvent debugEvent(wxEVT_WXLUA_DEBUG_BREAK, lineNumber, fileName); *************** *** 523,527 **** break; } ! case wxLUA_EVENT_DEBUG_PRINT: { wxString strMessage = GetSocketBase()->ReadString(); --- 520,524 ---- break; } ! case wxLUASOCKET_DEBUG_EVENT_PRINT: { wxString strMessage = GetSocketBase()->ReadString(); *************** *** 532,536 **** break; } ! case wxLUA_EVENT_DEBUG_ERROR: { wxString strMessage = GetSocketBase()->ReadString(); --- 529,533 ---- break; } ! case wxLUASOCKET_DEBUG_EVENT_ERROR: { wxString strMessage = GetSocketBase()->ReadString(); *************** *** 541,545 **** break; } ! case wxLUA_EVENT_DEBUG_EXIT: { wxLuaDebugEvent debugEvent(wxEVT_WXLUA_DEBUG_EXIT); --- 538,542 ---- break; } ! case wxLUASOCKET_DEBUG_EVENT_EXIT: { wxLuaDebugEvent debugEvent(wxEVT_WXLUA_DEBUG_EXIT); *************** *** 547,551 **** break; } ! case wxLUA_EVENT_DEBUG_STACK_ENUM: { wxLuaDebugData debugData = GetSocketBase()->ReadDebugData(); --- 544,548 ---- break; } ! case wxLUASOCKET_DEBUG_EVENT_STACK_ENUM: { wxLuaDebugData debugData = GetSocketBase()->ReadDebugData(); *************** *** 556,562 **** break; } ! case wxLUA_EVENT_DEBUG_STACK_ENTRY_ENUM: { ! int stackRef = GetSocketBase()->ReadInt(); wxLuaDebugData debugData = GetSocketBase()->ReadDebugData(); --- 553,559 ---- break; } ! case wxLUASOCKET_DEBUG_EVENT_STACK_ENTRY_ENUM: { ! int stackRef = GetSocketBase()->ReadInt32(); wxLuaDebugData debugData = GetSocketBase()->ReadDebugData(); *************** *** 566,570 **** break; } ! case wxLUA_EVENT_DEBUG_TABLE_ENUM: { long itemNode = GetSocketBase()->ReadLong(); --- 563,567 ---- break; } ! case wxLUASOCKET_DEBUG_EVENT_TABLE_ENUM: { long itemNode = GetSocketBase()->ReadLong(); *************** *** 576,582 **** break; } ! case wxLUA_EVENT_DEBUG_EVALUATE_EXPR: { ! int exprRef = GetSocketBase()->ReadInt(); wxString strResult = GetSocketBase()->ReadString(); --- 573,579 ---- break; } ! case wxLUASOCKET_DEBUG_EVENT_EVALUATE_EXPR: { ! int exprRef = GetSocketBase()->ReadInt32(); wxString strResult = GetSocketBase()->ReadString(); *************** *** 587,595 **** break; } ! case wxLUA_EVENT_DEBUG_BREAKPOINT_ADDED: { wxString fileName = GetSocketBase()->ReadString(); ! int line = GetSocketBase()->ReadInt(); ! bool enabled = GetSocketBase()->ReadInt() ? true : false; wxLuaDebugEvent debugEvent(wxEVT_WXLUA_DEBUG_BREAKPOINT_ADDED, line, fileName, enabled); --- 584,592 ---- break; } ! case wxLUASOCKET_DEBUG_EVENT_BREAKPOINT_ADDED: { wxString fileName = GetSocketBase()->ReadString(); ! int line = GetSocketBase()->ReadInt32(); ! bool enabled = GetSocketBase()->ReadInt32() ? true : false; wxLuaDebugEvent debugEvent(wxEVT_WXLUA_DEBUG_BREAKPOINT_ADDED, line, fileName, enabled); *************** *** 597,604 **** break; } ! case wxLUA_EVENT_DEBUG_BREAKPOINT_REMOVED: { wxString fileName = GetSocketBase()->ReadString(); ! int line = GetSocketBase()->ReadInt(); wxLuaDebugEvent debugEvent(wxEVT_WXLUA_DEBUG_BREAKPOINT_REMOVED, line, fileName); --- 594,601 ---- break; } ! case wxLUASOCKET_DEBUG_EVENT_BREAKPOINT_REMOVED: { wxString fileName = GetSocketBase()->ReadString(); ! int line = GetSocketBase()->ReadInt32(); wxLuaDebugEvent debugEvent(wxEVT_WXLUA_DEBUG_BREAKPOINT_REMOVED, line, fileName); *************** *** 795,805 **** { int debugEvent = m_acceptedSocket->ReadByte(); ! HandleDebugEvent((wxLuaDebugEvents_Type) debugEvent); ! if (debugEvent == wxLUA_EVENT_DEBUG_EXIT) m_fShutdown = true; } } ! catch(wxLuaSocketException & /*e*/) { } --- 792,802 ---- { int debugEvent = m_acceptedSocket->ReadByte(); ! HandleDebugEvent((wxLuaScoketDebugEvents_Type) debugEvent); ! if (debugEvent == wxLUASOCKET_DEBUG_EVENT_EXIT) m_fShutdown = true; } } ! catch(wxLuaSocketException &) { } *************** *** 815,819 **** } } ! catch(wxLuaSocketException & /*e*/) { } --- 812,816 ---- } } ! catch(wxLuaSocketException &) { } Index: wxlsock.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxlsock.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** wxlsock.cpp 8 Sep 2006 22:43:47 -0000 1.11 --- wxlsock.cpp 13 Sep 2006 04:13:48 -0000 1.12 *************** *** 30,69 **** #endif // ---------------------------------------------------------------------------- // wxLuaSocketBase // ---------------------------------------------------------------------------- ! unsigned char wxLuaSocketBase::ReadByte() { unsigned char value = 0; ! Read((char *) &value, sizeof(value)); ! return value; ! } ! ! short wxLuaSocketBase::ReadWord() ! { ! short value = 0; ! Read((char *)&value, sizeof(value)); ! return value; ! } ! ! unsigned short wxLuaSocketBase::ReadUWord() ! { ! unsigned short value = 0; ! Read((char *)&value, sizeof(value)); return value; } ! int wxLuaSocketBase::ReadInt() { ! int value = 0; ! Read((char *) &value, sizeof(value)); return value; } ! unsigned int wxLuaSocketBase::ReadUInt() { ! unsigned int value = 0; ! Read((char *) &value, sizeof(value)); return value; } --- 30,70 ---- #endif + // A simple way to debug the sockets to see if things are right + //#define DEBUG_WXLUASOCKET + + #ifdef DEBUG_WXLUASOCKET + void wxLuaSocketDebugMsg(const wxString& title, const wxString& msg) + { + wxSafeShowMessage(title, wxString::Format(wxT("PID %d TIME %s "), getpid(), wxT(__TIME__)) + msg); + } + #else + #define wxLuaSocketDebugMsg(title, msg) + #endif //DEBUG_WXLUASOCKET + // ---------------------------------------------------------------------------- // wxLuaSocketBase // ---------------------------------------------------------------------------- ! unsigned char wxLuaSocketBase::ReadByte() { unsigned char value = 0; ! Read((char *) &value, sizeof(unsigned char)); ! wxLuaSocketDebugMsg(wxT("wxLuaSocketBase::ReadByte"), wxString::Format(wxT("val %d"), (int)value)); return value; } ! wxInt32 wxLuaSocketBase::ReadInt32() { ! wxInt32 value = 0; ! Read((char *) &value, sizeof(wxInt32)); ! wxLuaSocketDebugMsg(wxT("wxLuaSocketBase::ReadInt32"), wxString::Format(wxT("val %d"), value)); return value; } ! wxUint32 wxLuaSocketBase::ReadUInt32() { ! wxUint32 value = 0; ! Read((char *) &value, sizeof(wxUint32)); ! wxLuaSocketDebugMsg(wxT("wxLuaSocketBase::ReadUInt32"), wxString::Format(wxT("val %u"), value)); return value; } *************** *** 72,83 **** { long value = 0; ! Read((char *) &value, sizeof(value)); ! return value; ! } ! ! unsigned long wxLuaSocketBase::ReadULong() ! { ! unsigned long value = 0; ! Read((char *) &value, sizeof(value)); return value; } --- 73,81 ---- { long value = 0; ! // make sure that long really works for 32 and 64 bit platforms, use a string ! char buf[65] = { 0 }; memset(buf, 0, 65); ! Read((char *) &value, 64); ! lua2wx(buf).ToLong(&value); ! wxLuaSocketDebugMsg(wxT("wxLuaSocketBase::ReadLong"), wxString::Format(wxT("val %ld"), value)); return value; } *************** *** 86,90 **** { wxString value; ! unsigned int length = ReadInt(); if (length > 0) { --- 84,90 ---- { wxString value; ! wxUint32 length = 0; ! Read((char *) &length, sizeof(wxUint32)); ! if (length > 0) { *************** *** 96,99 **** --- 96,102 ---- delete[] buffer; } + + wxLuaSocketDebugMsg(wxT("wxLuaSocketBase::ReadString"), wxString::Format(wxT("len %u val '%s'"), length, value.c_str())); + return value; } *************** *** 105,115 **** try { ! int idx, idxMax = 0; ! Read((char *) &idxMax, sizeof(int)); for (idx = 0; idx < idxMax; ++idx) { ! int bufferLength; ! Read((char *) &bufferLength, sizeof(bufferLength)); if (bufferLength > 0) { --- 108,116 ---- try { ! wxInt32 idx, idxMax = ReadInt32(); for (idx = 0; idx < idxMax; ++idx) { ! int bufferLength = ReadInt32(); if (bufferLength > 0) { *************** *** 118,129 **** Read(pMemory, bufferLength); ! int nReference = *(int *) pMemory; ! pMemory += sizeof(int); ! int nIndex = *(int *) pMemory; ! pMemory += sizeof(int); ! bool fExpanded = (0 != (*(int *) pMemory)); ! pMemory += sizeof(int); const char *pNamePtr = pMemory; --- 119,130 ---- Read(pMemory, bufferLength); ! wxInt32 nReference = *(wxInt32 *) pMemory; ! pMemory += sizeof(wxInt32); ! wxInt32 nIndex = *(wxInt32 *) pMemory; ! pMemory += sizeof(wxInt32); ! bool fExpanded = (0 != (*(wxInt32 *) pMemory)); ! pMemory += sizeof(wxInt32); const char *pNamePtr = pMemory; *************** *** 146,150 **** } } ! catch(wxLuaSocketException & /*e*/) { } --- 147,151 ---- } } ! catch(wxLuaSocketException &) { } *************** *** 153,213 **** } ! bool wxLuaSocketBase::WriteCharData(const char* value, int length) ! { ! try ! { ! Write(value, length); ! return true; ! } ! catch(wxLuaSocketException & /*e*/) ! { ! } ! return false; ! } ! bool wxLuaSocketBase::WriteByte(unsigned char value) ! { ! return WriteCharData((const char *)&value, sizeof(value)); ! } ! bool wxLuaSocketBase::WriteWord(short value) ! { ! return WriteCharData((const char *)&value, sizeof(value)); ! } ! bool wxLuaSocketBase::WriteUWord(unsigned short value) { ! return WriteCharData((const char *)&value, sizeof(value)); } ! bool wxLuaSocketBase::WriteInt(int value) { ! return WriteCharData((const char *)&value, sizeof(value)); } ! bool wxLuaSocketBase::WriteUInt(unsigned int value) { ! return WriteCharData((const char *)&value, sizeof(value)); } bool wxLuaSocketBase::WriteLong(long value) { ! return WriteCharData((const char *)&value, sizeof(value)); ! } ! bool wxLuaSocketBase::WriteULong(unsigned long value) ! { ! return WriteCharData((const char *)&value, sizeof(value)); } bool wxLuaSocketBase::WriteString(const wxString &value) { try { ! wxLuaCharBuffer buf(value); ! int buflen = buf.Length(); ! Write((const char *)&buflen, sizeof(buflen)); if (buflen > 0) { Write(buf.GetData(), buflen); } return true; } ! catch(wxLuaSocketException & /*e*/) { } return false; } --- 154,202 ---- } ! bool wxLuaSocketBase::WriteByte(char value) { ! wxLuaSocketDebugMsg(wxT("wxLuaSocketBase::WriteByte"), wxString::Format(wxT("val %d"), (int)value)); ! return Write((const char*)&value, sizeof(char)); } ! bool wxLuaSocketBase::WriteInt32(wxInt32 value) { ! wxLuaSocketDebugMsg(wxT("wxLuaSocketBase::WriteInt32"), wxString::Format(wxT("val %d"), value)); ! return Write((const char*)&value, sizeof(wxInt32)); } ! bool wxLuaSocketBase::WriteUInt32(wxUint32 value) { ! wxLuaSocketDebugMsg(wxT("wxLuaSocketBase::WriteUInt32"), wxString::Format(wxT("val %u"), value)); ! return Write((const char*)&value, sizeof(wxUint32)); } bool wxLuaSocketBase::WriteLong(long value) { ! wxLuaSocketDebugMsg(wxT("wxLuaSocketBase::WriteLong"), wxString::Format(wxT("val %ld"), value)); ! // make sure that long really works for 32 and 64 bit platforms, use a string ! char buf[65] = { 0 }; memset(buf, 0, 65); ! sprintf(buf, "%ld", value); ! return Write((const char*)&value, 64); } bool wxLuaSocketBase::WriteString(const wxString &value) { + wxLuaCharBuffer buf(value); + wxUint32 buflen = (wxUint32)buf.Length(); + + wxLuaSocketDebugMsg(wxT("wxLuaSocketBase::WriteString"), wxString::Format(wxT("len %u val '%s'"), buflen, value.c_str())); + try { ! Write((const char*)&buflen, sizeof(wxUint32)); if (buflen > ... [truncated message content] |