Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23333/wxLua/modules/wxluasocket/include Added Files: wxldbgio.h wxldserv.h wxldtarg.h wxlsock.h Removed Files: debugio.h dserver.h dtarget.h socket.h Log Message: rename wxluasocket files to wxl* for consistency and make it easier to find them --- NEW FILE: wxldserv.h --- ///////////////////////////////////////////////////////////////////////////// // Purpose: Implements the debugger end of wxLua debugging session // Author: J. Winwood // Created: May 2002 // Copyright: (c) 2002 Lomtick Software. All rights reserved. // Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// #ifndef WX_LUA_DEBUG_SERVER_H #define WX_LUA_DEBUG_SERVER_H #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma interface "wxldserv.h" #endif #include "wx/process.h" #include "wxlua/include/wxldefs.h" #include "wxluadebug/include/debug.h" #include "wxluasocket/include/wxlsock.h" #include "wxluasocket/include/wxldbgio.h" class WXDLLIMPEXP_WXLUA wxLuaDebugServer; class WXDLLIMPEXP_WXLUA wxLuaDebugEvent; class WXDLLIMPEXP_WXLUA wxLuaStackFrame; WXDLLIMPEXP_DATA_WXLUA(extern wxString) g_strProgramName; WXDLLIMPEXP_DATA_WXLUA(extern wxString) g_strNetworkName; // ---------------------------------------------------------------------------- // wxLuaThread // ---------------------------------------------------------------------------- class WXDLLIMPEXP_WXLUA wxLuaThread : public wxThread { public: wxLuaThread(wxLuaDebugServer *pServer) : wxThread(wxTHREAD_JOINABLE) { m_pServer = pServer; } protected: // thread execution starts here virtual void *Entry(); // called when the thread exits virtual void OnExit(); private: wxLuaDebugServer *m_pServer; }; // ---------------------------------------------------------------------------- // wxLuaDebugServer // ---------------------------------------------------------------------------- class WXDLLIMPEXP_WXLUA wxLuaDebugServer : public wxLuaDebuggerBase, public wxLuaDebugIO { public: wxLuaDebugServer(int portNumber); virtual ~wxLuaDebugServer(); bool StartServer(); bool StopServer(); bool StartClient(); bool StartServerThread(); bool WaitForConnect(int timeOut); bool AddBreakPoint(const wxString &fileName, int lineNumber); bool RemoveBreakPoint(const wxString &fileName, int lineNumber); bool ClearAllBreakPoints(); bool Run(const wxString &fileName, const wxString &buffer); bool Step(); bool StepOver(); bool StepOut(); bool Continue(); bool Break(); bool Reset(); bool EnumerateStack(); bool EnumerateStackEntry(int stackEntry); bool EnumerateTable(int tableRef, int nIndex, int nItemNode); bool CleanupDebugReferences(); void ThreadFunction(); #if wxCHECK_VERSION(2, 3, 0) bool DisplayStackDialog(wxWindow *pParent); #endif bool EvaluateExpr(int exprRef, const wxString &pExpression); static bool Compile(const wxString &fileName, const wxString &buffer); protected: wxLuaSocket *m_serverSocket; wxLuaSocket *m_acceptedSocket; int m_processID; int m_portNumber; wxProcess *m_pProcess; wxLuaThread *m_pThread; wxLuaStackFrame *m_pStackFrameDialog; bool m_fShutdown; private: static void NotifyError(const wxString &msg); static int LuaCompileError (lua_State *L); DECLARE_CLASS(wxLuaDebugServer) }; #endif // WX_LUA_DEBUG_SERVER_H --- NEW FILE: wxldbgio.h --- ///////////////////////////////////////////////////////////////////////////// // Purpose: Implements the debugger end of wxLua debugging session // Author: J. Winwood // Created: April 2002 // Copyright: (c) 2002 Lomtick Software. All rights reserved. // Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// #ifndef WX_LUA_DEBUG_IO_H #define WX_LUA_DEBUG_IO_H #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma interface "wxldbgio.h" #endif #include "wxlua/include/wxldefs.h" class WXDLLIMPEXP_WXLUA wxLuaDebugData; class WXDLLIMPEXP_WXLUA wxLuaSocket; // ---------------------------------------------------------------------------- // wxLuaDebugIO // ---------------------------------------------------------------------------- class WXDLLIMPEXP_WXLUA wxLuaDebugIO { protected: unsigned char ReadByte(wxLuaSocket *); short ReadWord(wxLuaSocket *); unsigned short ReadUWord(wxLuaSocket *); int ReadInt(wxLuaSocket *); unsigned int ReadUInt(wxLuaSocket *); long ReadLong(wxLuaSocket *); unsigned long ReadULong(wxLuaSocket *); wxString ReadString(wxLuaSocket *); wxLuaDebugData *ReadDebugData(wxLuaSocket *); bool WriteByte(wxLuaSocket *, unsigned char value); bool WriteWord(wxLuaSocket *, short value); bool WriteUWord(wxLuaSocket *, unsigned short value); bool WriteInt(wxLuaSocket *, int value); bool WriteUInt(wxLuaSocket *, unsigned int value); bool WriteLong(wxLuaSocket *, long value); bool WriteULong(wxLuaSocket *, unsigned long value); bool WriteString(wxLuaSocket *, const wxString &value); bool WriteDebugData(wxLuaSocket *, const wxLuaDebugData *pData); }; #endif // WX_LUA_DEBUG_IO_H --- debugio.h DELETED --- --- dtarget.h DELETED --- --- dserver.h DELETED --- --- NEW FILE: wxlsock.h --- ///////////////////////////////////////////////////////////////////////////// // Name: wxLuaSocket.h // Purpose: wxLua Socket interfaces // Author: J. Winwood // Created: March 2002 // Copyright: (c) 2002 Lomtick Software. All rights reserved. // Licence: wxWidgets licence. ///////////////////////////////////////////////////////////////////////////// #ifndef WX_LUA_SOCKET_H_ #define WX_LUA_SOCKET_H_ #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma interface "wxlsock.h" #endif #include "wxlua/include/wxldefs.h" #ifdef WIN32 typedef int socklen_t; #include <winsock.h> #else #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <cerrno> #include <netdb.h> #include <arpa/inet.h> #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #endif // !WIN32 #ifndef SD_RECEIVE #define SD_RECEIVE 0 #define SD_SEND 1 #define SD_BOTH 2 #endif // SD_RECEIVE // ---------------------------------------------------------------------------- // wxLuaSocket // ---------------------------------------------------------------------------- class WXDLLIMPEXP_WXLUA wxLuaSocket { #ifdef WIN32 typedef SOCKET socket_type; #else typedef int socket_type; #endif // proxy class for accept class wxLuaAcceptedSocket { public: // constructor wxLuaAcceptedSocket(socket_type socket, sockaddr_in address); wxLuaAcceptedSocket(const wxLuaAcceptedSocket &); wxLuaAcceptedSocket& operator=(const wxLuaAcceptedSocket &); private: socket_type m_sock; sockaddr_in m_addr; friend class wxLuaSocket; }; public: enum SocketState { SOCKET_CLOSED, SOCKET_LISTENING, SOCKET_ACCEPTING, SOCKET_ACCEPTED, SOCKET_CONNECTED, SOCKET_WRITE_BLOCKED }; // constructors wxLuaSocket(); wxLuaSocket(const wxLuaAcceptedSocket &acceptedSocket); // destructor ~wxLuaSocket(); // server: bind and listen for client connections void Listen(u_short port, int backLog = 100); // server: accept a connection from a client wxLuaAcceptedSocket Accept(); // client: connect a client to a server void Connect(const wxString &address, u_short port); // Get the socket state SocketState GetState() const { return m_sockstate; } // Get the socket handle int GetSocket() const { return m_sock; } // Test if the socket is readable bool IsReadable () const { return (m_sockstate == SOCKET_CONNECTED || m_sockstate == SOCKET_ACCEPTING); } // Test if the socket is writeable bool IsWritable () const { return (m_sockstate != SOCKET_CONNECTED || m_sockstate == SOCKET_WRITE_BLOCKED); } // Get the address of the socket wxString GetAddress() const; // Get the port number of the socket int GetPort() const; // Read the whole buffer of size length into buffer buffer from the socket int Read(char *buffer, int length); // Write the whole buffer of size length to the socket void Write(const char *buffer, int length); // Shutdown the socket void Shutdown(int how); // Close the socket void Close(); private: // Prevent copying and assignment of this class wxLuaSocket(const wxLuaSocket&); wxLuaSocket& operator=(const wxLuaSocket&); socket_type m_sock; sockaddr_in m_sockaddress; SocketState m_sockstate; }; // ---------------------------------------------------------------------------- // wxLuaSocketException // ---------------------------------------------------------------------------- class WXDLLIMPEXP_WXLUA wxLuaSocketException { public: enum SocketErrorCode { SOCKET_NOT_CLOSED, SOCKET_NOT_CONNECTED, SOCKET_NOT_LISTENING, SOCKET_INVALID_SOCKET, SOCKET_ADDRESS_NOT_RESOLVED, SOCKET_INCOMPATIBLE_TYPE, SOCKET_SET_BLOCKING_FAILED, SOCKET_ACCEPT_FAILED, SOCKET_CONNECT_FAILED, SOCKET_BIND_FAILED, SOCKET_LISTEN_FAILED, SOCKET_SEND_FAILED, SOCKET_RECEIVE_FAILED, SOCKET_CLOSE_FAILED }; // constructors wxLuaSocketException(SocketErrorCode code) : m_code(code) { #ifdef WIN32 m_errnum = ::WSAGetLastError(); switch(m_errnum) { case WSANOTINITIALISED: m_description = _("A successful WSAStartup must occur before using this function."); break; case WSAENETDOWN: m_description = _("The network subsystem or the associated service provider has failed."); break; case WSAEAFNOSUPPORT: m_description = _("The specified address family is not supported."); break; case WSAEINPROGRESS: m_description = _("A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function."); break; case WSAEMFILE: m_description = _("No more socket descriptors are available."); break; case WSAENOBUFS: m_description = _("No buffer space is available. The socket cannot be created."); break; case WSAEPROTONOSUPPORT: m_description = _("The specified protocol is not supported."); break; case WSAEPROTOTYPE: m_description = _("The specified protocol is the wrong type for this socket."); break; case WSAESOCKTNOSUPPORT: m_description = _("The specified socket type is not supported in this address family."); break; } #else m_errnum = errno; #endif if (m_description.IsEmpty()) m_description = _("Socket Error"); } wxLuaSocketException(const wxLuaSocketException &e) : m_code(e.m_code), m_errnum(e.m_errnum) { } SocketErrorCode GetCode() const { return m_code; } int errnum() const { return m_errnum; } const wxString& description() { return m_description; } private: wxLuaSocketException& operator=(const wxLuaSocketException& e); SocketErrorCode m_code; int m_errnum; wxString m_description; }; #endif // WX_LUA_SOCKET_H_ --- NEW FILE: wxldtarg.h --- ///////////////////////////////////////////////////////////////////////////// // Purpose: Implements the client end of wxLua debugging session // Author: J. Winwood // Created: May 2002 // RCS-ID: $Id: wxldtarg.h,v 1.1 2005/11/25 19:22:58 jrl1 Exp $ // Copyright: (c) 2002 Lomtick Software. All rights reserved. // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef LUA_DEBUG_TARGET_H #define LUA_DEBUG_TARGET_H #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma interface "wxldtarg.h" #endif #include "wx/dynarray.h" #include "wxlua/include/wxldefs.h" #include "wxlua/include/wxlua.h" #include "wxlua/include/internal.h" #include "wxluadebug/include/debug.h" #include "wxluadebug/include/staktree.h" #include "wxluasocket/include/wxldbgio.h" #include "wxluasocket/include/wxlsock.h" // ---------------------------------------------------------------------------- // LuaDebugTarget - Handles Debugger/Debuggee IO // ---------------------------------------------------------------------------- class LuaDebugTarget : public wxObject, public wxLuaDebugIO { private: class LuaThread : public wxThread { public: LuaThread(LuaDebugTarget *pTarget) : wxThread(wxTHREAD_JOINABLE), m_pTarget(pTarget) {} bool TestDestroy(); protected: // thread execution starts here virtual void *Entry(); // called when the thread exits virtual void OnExit(); private: LuaDebugTarget *m_pTarget; }; class BreakPointObject : public wxObject { public: BreakPointObject(const wxString &fileName, int lineNumber) : m_fileName(fileName), m_lineNumber(lineNumber) {} const wxString &GetFileName() const { return m_fileName; } int GetLineNumber() const { return m_lineNumber; } private: wxString m_fileName; int m_lineNumber; }; public: LuaDebugTarget(lua_State *state, const wxString &serverName, int portNumber); ~LuaDebugTarget(); bool Run(); void Stop(); void ThreadFunction(); void DisplayError(const wxString &strError); protected: enum debugOperations { DEBUG_STEP, DEBUG_STEPOVER, DEBUG_STEPOUT, DEBUG_GO }; lua_State *m_luaState; int m_portNumber; wxString m_serverName; wxSortedArrayString m_breakPointList; #if wxCHECK_VERSION(2, 3, 3) wxMutex m_debugMutex; #endif wxCondition m_debugCondition; wxLuaSocket m_clientSocket; debugOperations m_nextOperation; bool m_forceBreak; bool m_resetRequested; bool m_fConnected; bool m_fRunning; bool m_fStopped; bool m_fErrorsSeen; int m_nFramesUntilBreak; #if wxCHECK_VERSION(2, 3, 3) wxMutex m_runMutex; #endif wxCondition m_runCondition; wxLuaBufferArray m_bufferList; LuaThread *m_pThread; wxArrayInt m_references; void ExitThread(); mutable wxCriticalSection m_breakPointListCriticalSection; bool AddBreakPoint(const wxString &fileName, int lineNumber); bool RemoveBreakPoint(const wxString &fileName, int lineNumber); bool ClearAllBreakPoints(); bool Run(const wxString &fileName, const wxString &buffer); bool Step(); bool StepOver(); bool StepOut(); bool Continue(); bool Break(); bool Reset(); bool EnumerateStack(); bool EnumerateStackEntry(int stackRef); bool EnumerateTable(int tableRef, int nIndex, int itemNode); bool EvaluateExpr(int exprRef, const wxString &strExpr); bool NotifyBreak(const wxString &fileName, int lineNumber); bool NotifyPrint(const wxString &errorMsg); bool NotifyError(const wxString &errorMsg); bool NotifyExit(); bool NotifyStackEnumeration(wxLuaDebugData *pDebugData); bool NotifyStackEntryEnumeration(int stackRef, wxLuaDebugData *pDebugData); bool NotifyTableEnumeration(int itemNode, wxLuaDebugData *pDebugData); bool NotifyEvaluateExpr(int exprRef, const wxString &strResult); bool DebugHook(int event); private: bool WaitForConnect() const; bool AtBreakPoint(const wxString &fileName, int lineNumber) const; wxString GetTableInfo(int index); wxString GetUserDataInfo(int index, bool full = true); wxString MakeBoolean(int num); wxString MakeNumber(double dnum); wxString GetDebugInfo(int &lineNumber) const; static void LUACALL LuaDebugHook(lua_State *state, lua_Debug *debug); static int LUACALL LuaPrint (lua_State *L); }; #endif // LUA_DEBUG_TARGET_H --- socket.h DELETED --- |