From: John L. <jr...@us...> - 2007-05-21 01:08:33
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv14147/wxLua/samples Modified Files: editor.wx.lua Log Message: Remove all code in dservice as it wasn't used Removed m_pDerivedList and put derived lua functions into the lua registry index A little more cleanup in the socket and editor.wx.lua code. Index: editor.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/editor.wx.lua,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** editor.wx.lua 19 May 2007 17:14:14 -0000 1.48 --- editor.wx.lua 21 May 2007 01:08:00 -0000 1.49 *************** *** 84,87 **** --- 84,88 ---- local ID_SHOWHIDEWINDOW = NewID() local ID_CLEAROUTPUT = NewID() + local ID_DEBUGGER_PORT = NewID() -- Help menu local ID_ABOUT = wx.wxID_ABOUT *************** *** 1647,1651 **** { }, { ID_SHOWHIDEWINDOW, "View &Output Window\tF8", "View or Hide the output window" }, ! { ID_CLEAROUTPUT, "C&lear output", "Clear the output window" } } menuBar:Append(debugMenu, "&Debug") --- 1648,1654 ---- { }, { ID_SHOWHIDEWINDOW, "View &Output Window\tF8", "View or Hide the output window" }, ! { ID_CLEAROUTPUT, "C&lear Output Window", "Clear the output window before compiling or debugging", wx.wxITEM_CHECK }, ! --{ }, { ID_DEBUGGER_PORT, "Set debugger socket port...", "Chose what port to use for debugger sockets." } ! } menuBar:Append(debugMenu, "&Debug") *************** *** 1720,1724 **** local filePath = MakeDebugFileName(editor, openDocuments[id].filePath) local ret, errMsg, line_num = wx.CompileLuaScript(editorText, filePath) ! --ClearOutput() maybe you want to view last error? if line_num > -1 then --- 1723,1729 ---- local filePath = MakeDebugFileName(editor, openDocuments[id].filePath) local ret, errMsg, line_num = wx.CompileLuaScript(editorText, filePath) ! if menuBar:IsChecked(ID_CLEAROUTPUT) then ! ClearOutput() ! end if line_num > -1 then *************** *** 1788,1792 **** local id = editor:GetId(); ! local console = iff( menuBar:IsChecked(ID_USECONSOLE), " -c ", "") local cmd = '"'..programName..'" '..console..openDocuments[id].filePath --- 1793,1797 ---- local id = editor:GetId(); ! local console = iff(menuBar:IsChecked(ID_USECONSOLE), " -c ", "") local cmd = '"'..programName..'" '..console..openDocuments[id].filePath *************** *** 1818,1822 **** DisplayOutput("Unable to create debugger server.\n") end ! debuggerPortNumber = debuggerPortNumber + 1 end) frame:Connect(ID_ATTACH_DEBUG, wx.wxEVT_UPDATE_UI, --- 1823,1827 ---- DisplayOutput("Unable to create debugger server.\n") end ! NextDebuggerPort() end) frame:Connect(ID_ATTACH_DEBUG, wx.wxEVT_UPDATE_UI, *************** *** 1826,1829 **** --- 1831,1843 ---- end) + function NextDebuggerPort() + -- limit the number if ports we use, for people who need to open + -- their firewall + debuggerPortNumber = debuggerPortNumber + 1 + if (debuggerPortNumber > 1559) then + debuggerPortNumber = 1551 + end + end + function CreateDebuggerServer() if (debuggerServer) then *************** *** 1832,1835 **** --- 1846,1850 ---- local ds = debuggerServer debuggerServer = nil + ds:Reset() ds:StopServer() ds:Delete() *************** *** 1839,1849 **** debuggerServer = wx.wxLuaDebuggerServer(debuggerPortNumber) - local ok = debuggerServer:StartServer() - if not ok then - DestroyDebuggerServer() - DisplayOutput("Error starting the debug server.\n") - return nil - end - debuggerServer:Connect(wx.wxEVT_WXLUA_DEBUGGER_DEBUGGEE_CONNECTED, function (event) --- 1854,1857 ---- *************** *** 1859,1864 **** local nextLine = editor:MarkerNext(0, BREAKPOINT_MARKER_VALUE) ! while nextLine ~= -1 do ! debuggerServer:AddBreakPoint(fileName, nextLine) nextLine = editor:MarkerNext(nextLine + 1, BREAKPOINT_MARKER_VALUE) end --- 1867,1872 ---- local nextLine = editor:MarkerNext(0, BREAKPOINT_MARKER_VALUE) ! while ok and (nextLine ~= -1) do ! ok = debuggerServer:AddBreakPoint(fileName, nextLine) nextLine = editor:MarkerNext(nextLine + 1, BREAKPOINT_MARKER_VALUE) end *************** *** 1993,1996 **** --- 2001,2011 ---- end) + local ok = debuggerServer:StartServer() + if not ok then + DestroyDebuggerServer() + DisplayOutput("Error starting the debug server.\n") + return nil + end + return debuggerServer end *************** *** 2010,2025 **** debugger_destroy = debugger_destroy + 1 end ! if (debugger_destroy > 5) then debuggee_running = false debuggerServer_:StopServer() end ! if (debugger_destroy > 10) then debugger_destroy = 0; local ds = debuggerServer_ debuggerServer_ = nil - debuggee_running = false - ds:Delete() - if (debuggee_pid > 0) then if wx.wxProcess_Exists(debuggee_pid) then --- 2025,2045 ---- debugger_destroy = debugger_destroy + 1 end ! ! if (debugger_destroy == 5) then ! -- stop the server and let it end gracefully debuggee_running = false debuggerServer_:StopServer() end ! if (debugger_destroy == 10) then ! -- delete the server and let it die gracefully ! debuggee_running = false ! debuggerServer_:Delete() ! end ! if (debugger_destroy > 15) then ! -- finally, kill the debugee process if it still exists debugger_destroy = 0; local ds = debuggerServer_ debuggerServer_ = nil if (debuggee_pid > 0) then if wx.wxProcess_Exists(debuggee_pid) then *************** *** 2027,2030 **** --- 2047,2052 ---- if (ret ~= wx.wxKILL_OK) then DisplayOutput("Unable to kill debuggee process "..debuggee_pid..", code "..tostring(ret)..".\n") + else + DisplayOutput("Killed debuggee process "..debuggee_pid..".\n") end end *************** *** 2059,2063 **** end ! debuggerPortNumber = debuggerPortNumber + 1 end) frame:Connect(ID_START_DEBUG, wx.wxEVT_UPDATE_UI, --- 2081,2085 ---- end ! NextDebuggerPort() end) frame:Connect(ID_START_DEBUG, wx.wxEVT_UPDATE_UI, *************** *** 2193,2200 **** end ! frame:Connect(ID_CLEAROUTPUT, wx.wxEVT_COMMAND_MENU_SELECTED, ClearOutput) ! frame:Connect(ID_CLEAROUTPUT, wx.wxEVT_UPDATE_UI, function(event) ! event:Enable(errorLog and errorLog:IsShown()) end) --- 2215,2224 ---- end ! frame:Connect(ID_DEBUGGER_PORT, wx.wxEVT_COMMAND_MENU_SELECTED, function(event) ! end) ! frame:Connect(ID_DEBUGGER_PORT, wx.wxEVT_UPDATE_UI, ! function(event) ! event:Enable(debuggerServer == nil) end) |