From: John L. <jr...@us...> - 2006-10-04 02:49:21
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv31238/wxLua/modules/wxluasocket/include Modified Files: dservice.h wxldserv.h wxldtarg.h wxlhandl.h wxlsock.h Log Message: Index: dservice.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/dservice.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** dservice.h 13 Sep 2006 04:13:47 -0000 1.16 --- dservice.h 28 Sep 2006 22:26:05 -0000 1.17 *************** *** 179,182 **** --- 179,187 ---- bool m_InDebugHook; bool m_Wait; + wxCriticalSection m_luaCriticalSection; + + // Enter/Leave critical section for the threaded sockets + void EnterLuaCriticalSection() { m_luaCriticalSection.Enter(); } + void LeaveLuaCriticalSection() { m_luaCriticalSection.Leave(); } mutable wxCriticalSection m_breakPointListCriticalSection; Index: wxldserv.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/wxldserv.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** wxldserv.h 15 Sep 2006 00:10:56 -0000 1.14 --- wxldserv.h 28 Sep 2006 22:26:05 -0000 1.15 *************** *** 21,28 **** class WXDLLIMPEXP_WXLUASOCKET wxLuaDebuggerServer; class WXDLLIMPEXP_WXLUASOCKET wxLuaDebuggerEvent; ! class WXDLLIMPEXP_WXLUADEBUG wxLuaStackDialog; // ---------------------------------------------------------------------------- ! // wxLuaSocketDebuggeeEvents_Type - socket events sent from debuggee to debugger // ---------------------------------------------------------------------------- --- 21,29 ---- class WXDLLIMPEXP_WXLUASOCKET wxLuaDebuggerServer; class WXDLLIMPEXP_WXLUASOCKET wxLuaDebuggerEvent; ! class WXDLLIMPEXP_WXLUADEBUG wxLuaStackDialog; // ---------------------------------------------------------------------------- ! // wxLuaSocketDebuggeeEvents_Type - These are socket events sent from debuggee ! // to debugger to notify the debugger that action has been taken. // ---------------------------------------------------------------------------- *************** *** 45,49 **** // ---------------------------------------------------------------------------- ! // wxLuaSocketDebuggerCommands_Type - socket commands sent from debugger to debuggee // ---------------------------------------------------------------------------- --- 46,52 ---- // ---------------------------------------------------------------------------- ! // wxLuaSocketDebuggerCommands_Type - These are socket commands sent from the ! // debugger to debuggee to direct the debuggee to take action, which will ! // then return with a wxLuaSocketDebuggeeEvents_Type when done. // ---------------------------------------------------------------------------- *************** *** 52,56 **** wxLUASOCKET_DEBUGGER_CMD_NONE = 0, // a socket error probably ! wxLUASOCKET_DEBUGGER_CMD_ADD_BREAKPOINT = 100, wxLUASOCKET_DEBUGGER_CMD_REMOVE_BREAKPOINT, wxLUASOCKET_DEBUGGER_CMD_CLEAR_ALL_BREAKPOINTS, --- 55,59 ---- wxLUASOCKET_DEBUGGER_CMD_NONE = 0, // a socket error probably ! wxLUASOCKET_DEBUGGER_CMD_ADD_BREAKPOINT = 100, // shifted for debugging wxLUASOCKET_DEBUGGER_CMD_REMOVE_BREAKPOINT, wxLUASOCKET_DEBUGGER_CMD_CLEAR_ALL_BREAKPOINTS, *************** *** 94,97 **** --- 97,101 ---- // ---------------------------------------------------------------------------- // wxLuaDebuggerBase - Debugger interface base class + // // ---------------------------------------------------------------------------- *************** *** 99,105 **** { public: ! wxLuaDebuggerBase() {} virtual ~wxLuaDebuggerBase() {} virtual bool AddBreakPoint(const wxString &fileName, int lineNumber); virtual bool RemoveBreakPoint(const wxString &fileName, int lineNumber); --- 103,112 ---- { public: ! wxLuaDebuggerBase() : wxEvtHandler(), m_stackDialog(NULL) {} virtual ~wxLuaDebuggerBase() {} + // These functions all send socket commands wxLUASOCKET_DEBUGGER_CMD_XXX + // and the appropriate data to the debuggee. + virtual bool AddBreakPoint(const wxString &fileName, int lineNumber); virtual bool RemoveBreakPoint(const wxString &fileName, int lineNumber); *************** *** 120,132 **** virtual bool EvaluateExpr(int exprRef, const wxString &strExpression); ! virtual bool Compile(const wxString &fileName, const wxString &buffer); ! virtual void NotifyError(const wxString &msg); ! virtual int HandleDebugEvent(wxLuaSocketDebuggeeEvents_Type event_type); ! virtual wxLuaSocketBase* GetSocketBase() { return NULL; } private: DECLARE_ABSTRACT_CLASS(wxLuaDebuggerBase) }; --- 127,153 ---- virtual bool EvaluateExpr(int exprRef, const wxString &strExpression); ! // compile the buffer in a temp lua_State returning true on success. ! // Always sends a wxEVT_WXLUA_DEBUGGER_ERROR event with a message. ! bool Compile(const wxString &fileName, const wxString &buffer); ! virtual int HandleDebuggeeEvent(wxLuaSocketDebuggeeEvents_Type event_type); ! // Get the debugger socket to read/write data to ! virtual wxLuaSocketBase* GetSocketBase() = 0; ! // Get/Set the wxLuaStackDialog to show the stack of the debugged program ! wxLuaStackDialog* GetStackDialog() { return m_stackDialog; } ! void SetStackDialog(wxLuaStackDialog *stackDialog) { m_stackDialog = stackDialog; } ! ! // Handle the stack dialog events using the internal wxLuaStackDialog ! void OnDebugStackEnum(wxLuaDebuggerEvent &event); ! void OnDebugTableEnum(wxLuaDebuggerEvent &event); ! void OnDebugStackEntryEnum(wxLuaDebuggerEvent &event); ! ! protected: ! wxLuaStackDialog *m_stackDialog; private: + DECLARE_EVENT_TABLE(); DECLARE_ABSTRACT_CLASS(wxLuaDebuggerBase) }; *************** *** 184,188 **** wxProcess *m_pProcess; wxLuaDebuggerServer::LuaThread *m_pThread; - wxLuaStackDialog *m_pStackDialog; bool m_fShutdown; --- 205,208 ---- *************** *** 203,212 **** wxLuaDebuggerEvent(const wxLuaDebuggerEvent& event); wxLuaDebuggerEvent(wxEventType eventType = wxEVT_NULL, int lineNumber = 0, const wxString &fileName = wxEmptyString, bool enabledFlag = false); - virtual ~wxLuaDebuggerEvent(); - void SetMessage(const wxString &message); void SetDebugData(long nReference, const wxLuaDebugData& pDebugData = wxLuaDebugData()); --- 223,231 ---- wxLuaDebuggerEvent(const wxLuaDebuggerEvent& event); wxLuaDebuggerEvent(wxEventType eventType = wxEVT_NULL, + wxObject* eventObject = NULL, int lineNumber = 0, const wxString &fileName = wxEmptyString, bool enabledFlag = false); void SetMessage(const wxString &message); void SetDebugData(long nReference, const wxLuaDebugData& pDebugData = wxLuaDebugData()); Index: wxlsock.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/wxlsock.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** wxlsock.h 25 Sep 2006 22:24:46 -0000 1.13 --- wxlsock.h 28 Sep 2006 22:26:05 -0000 1.14 *************** *** 34,41 **** #endif // !WIN32 #ifndef SD_RECEIVE ! #define SD_RECEIVE 0 ! #define SD_SEND 1 ! #define SD_BOTH 2 #endif // SD_RECEIVE --- 34,42 ---- #endif // !WIN32 + // This is the MSW version of SHUT_RDWR for ::shutdown(sock, how=SHUT_RDWR) #ifndef SD_RECEIVE ! #define SD_RECEIVE SHUT_RD ! #define SD_SEND SHUT_WR ! #define SD_BOTH SHUT_RDWR #endif // SD_RECEIVE *************** *** 43,51 **** // ---------------------------------------------------------------------------- // wxLuaSocketBase - a base class for different socket implementations ! // ! // You must override virtual int Read(...) and virtual int Write(...) // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUASOCKET wxLuaSocketBase { public: --- 44,53 ---- // ---------------------------------------------------------------------------- // wxLuaSocketBase - a base class for different socket implementations ! // The derived socket class must override virtual int Read(...) and ! // virtual int Write(...) which all the other ReadXXX and WriteXXX functions ! // of this class use. // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUASOCKET wxLuaSocketBase : public wxObject { public: *************** *** 57,85 **** // Read the number of bytes length into buffer buffer from the socket virtual int Read(char *buffer, wxUint32 length) = 0; // Write the whole buffer of number of bytes length to the socket virtual int Write(const char *buffer, wxUint32 length) = 0; // Read data from the socket, calls virtual int Read(...) ! bool ReadByte(unsigned char& value); bool ReadInt32(wxInt32& value); ! bool ReadUInt32(wxUint32& value); ! bool ReadLong(long& value); bool ReadString(wxString& value); bool ReadDebugData(wxLuaDebugData& data); // Write data to the socket, calls virtual void Write(...) ! bool WriteByte(char value); bool WriteInt32(wxInt32 value); ! bool WriteUInt32(wxUint32 value); ! bool WriteLong(long value); bool WriteString(const wxString &value); bool WriteDebugData(const wxLuaDebugData& debugData); ! wxString m_name; // a name for the socket, for debugging }; // ---------------------------------------------------------------------------- ! // wxLuaSocket // ---------------------------------------------------------------------------- --- 59,89 ---- // Read the number of bytes length into buffer buffer from the socket + // the buffer must be large enough to hold the data. virtual int Read(char *buffer, wxUint32 length) = 0; // Write the whole buffer of number of bytes length to the socket virtual int Write(const char *buffer, wxUint32 length) = 0; + // Note: Read/WriteCmd reads/writes a byte and if debugging prints the cmd/event type + // Read data from the socket, calls virtual int Read(...) ! // false is returned on failure and the input var is not modified ! bool ReadCmd(unsigned char& value); bool ReadInt32(wxInt32& value); ! bool ReadLong(long& value); // reads platform independent long using a string bool ReadString(wxString& value); bool ReadDebugData(wxLuaDebugData& data); // Write data to the socket, calls virtual void Write(...) ! bool WriteCmd(char value); bool WriteInt32(wxInt32 value); ! bool WriteLong(long value); // write platform independent long using a string bool WriteString(const wxString &value); bool WriteDebugData(const wxLuaDebugData& debugData); ! wxString m_name; // a readable name for the socket, for debugging }; // ---------------------------------------------------------------------------- ! // wxLuaSocket - a c socket implementation // ---------------------------------------------------------------------------- *************** *** 122,126 **** wxLuaSocket(const wxLuaAcceptedSocket &acceptedSocket); - // destructor virtual ~wxLuaSocket(); --- 126,129 ---- *************** *** 160,171 **** // Get the port number of the socket int GetPort() const; ! // Read the whole buffer of size length into buffer buffer from the socket virtual int Read(char *buffer, wxUint32 length); ! // Write the whole buffer of size length to the socket virtual int Write(const char *buffer, wxUint32 length); ! // Shutdown the socket in an orderly fashion ! void Shutdown(int how); ! // Close the open socket ! void Close(); private: --- 163,175 ---- // Get the port number of the socket int GetPort() const; ! // Read the whole buffer of byte size length into buffer from the socket virtual int Read(char *buffer, wxUint32 length); ! // Write the whole buffer of byte size length to the socket virtual int Write(const char *buffer, wxUint32 length); ! // Shutdown the socket in an orderly fashion, ::shutdown(sock, how) ! // returns true on success, if false then check errno ! bool Shutdown(int how = SD_BOTH); ! // Close the open socket, returns true on success ! bool Close(); private: Index: wxldtarg.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/wxldtarg.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** wxldtarg.h 15 Sep 2006 00:10:56 -0000 1.16 --- wxldtarg.h 28 Sep 2006 22:26:05 -0000 1.17 *************** *** 52,55 **** --- 52,56 ---- void ThreadFunction(); + int HandleDebuggerCmd(int cmd); void DisplayError(const wxString &strError); *************** *** 85,88 **** --- 86,94 ---- LuaThread *m_pThread; wxArrayInt m_references; + wxCriticalSection m_luaCriticalSection; + + // Enter/Leave critical section for the threaded sockets + void EnterLuaCriticalSection() { m_luaCriticalSection.Enter(); } + void LeaveLuaCriticalSection() { m_luaCriticalSection.Leave(); } void ExitThread(); Index: wxlhandl.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/wxlhandl.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** wxlhandl.h 15 Sep 2006 00:10:56 -0000 1.9 --- wxlhandl.h 28 Sep 2006 22:26:05 -0000 1.10 *************** *** 16,55 **** #endif - #include "wx/thread.h" #include "wxluasocket/include/wxluasocketdefs.h" - class WXDLLIMPEXP_WXLUASOCKET wxLuaDebuggerEvent; - class WXDLLIMPEXP_WXLUADEBUG wxLuaStackDialog; - - // ---------------------------------------------------------------------------- - // wxLuaHandler - Allow for Custom Lua Handler (an alternative to wxLuaApp) - // ---------------------------------------------------------------------------- - - class WXDLLIMPEXP_WXLUASOCKET wxLuaHandler - { - public: - wxLuaHandler(); - virtual ~wxLuaHandler(); - - virtual void AddPendingEvent(wxEvent& event) = 0; - virtual bool ProcessEvent(wxEvent& event) = 0; - virtual void DisplayError(const wxString &strError) const = 0; - - void SetStackDialog(wxLuaStackDialog *stackDialog) { m_stackDialog = stackDialog; } - wxLuaStackDialog* GetStackDialog() { return m_stackDialog; } - - void EnterLuaCriticalSection() { m_luaCriticalSection.Enter(); } - void LeaveLuaCriticalSection() { m_luaCriticalSection.Leave(); } - - // Get the single global wxLuaHandler - // note: if sm_luahandler = NULL let this fail hard, it should NEVER happen - static wxLuaHandler& GetHandler() { return *sm_luaHandler; } - - protected: - wxLuaStackDialog *m_stackDialog; - - static wxLuaHandler* sm_luaHandler; - wxCriticalSection m_luaCriticalSection; - }; - #endif //_WXLHANDL_H_ --- 16,20 ---- |