From: John L. <jr...@us...> - 2006-09-06 05:33:13
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv25350/wxLua/modules/wxluasocket/include Modified Files: dservice.h wxldbgio.h wxldserv.h wxldtarg.h wxlhandl.h wxlsock.h Log Message: simplify socket code to use a wxLuaSocketBase for all IO operations remove wxLuaDebugIO class, in wxLuaSocketBase First step to using wxSockets and/or C sockets transparently Index: wxldserv.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/wxldserv.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** wxldserv.h 5 Sep 2006 21:48:11 -0000 1.9 --- wxldserv.h 6 Sep 2006 05:33:08 -0000 1.10 *************** *** 18,22 **** #include "wxluadebug/include/wxldebug.h" #include "wxluasocket/include/wxlsock.h" - #include "wxluasocket/include/wxldbgio.h" class WXDLLIMPEXP_WXLUASOCKET wxLuaDebugServer; --- 18,21 ---- *************** *** 144,148 **** // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUASOCKET wxLuaDebugServer : public wxLuaDebuggerBase, public wxLuaDebugIO { public: --- 143,147 ---- // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUASOCKET wxLuaDebugServer : public wxLuaDebuggerBase { public: Index: wxldbgio.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/wxldbgio.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** wxldbgio.h 5 Sep 2006 21:48:11 -0000 1.4 --- wxldbgio.h 6 Sep 2006 05:33:08 -0000 1.5 *************** *** 16,52 **** #include "wxluasocket/include/wxluasocketdefs.h" - class WXDLLIMPEXP_WXLUADEBUG wxLuaDebugData; - class WXDLLIMPEXP_WXLUASOCKET wxLuaSocket; - - // ---------------------------------------------------------------------------- - // wxLuaDebugIO - A mixin class that merely provides a means to read/write - // to a wxLuaSocket. - // ---------------------------------------------------------------------------- - - class WXDLLIMPEXP_WXLUASOCKET 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 WriteCharData(wxLuaSocket *, const char* data, int length); - 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 --- 16,18 ---- Index: dservice.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/dservice.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** dservice.h 28 Aug 2006 05:26:21 -0000 1.12 --- dservice.h 6 Sep 2006 05:33:08 -0000 1.13 *************** *** 25,42 **** #include "wx/dynarray.h" #include "wx/socket.h" ! ! #if wxCHECK_VERSION(2,3,0) ! #include "wx/filename.h" ! #else ! // FIXME: for wxWidgets 2.2.9 which does not implement wxFileName ! // This is a quick hack to test if I can compile the ! // lua wrapper for 2.2.9. I am not going to do anything ! // more for 2.2.9, but if anyone requires it, they may wish ! // fix and test the wxWidgets lua wrapper. RG ! typedef wxString wxFileName; ! #endif #include "wxlua/include/wxlua.h" #include "wxluasocket/include/wxldserv.h" #define ID_WXLUA_SERVER 1200 --- 25,33 ---- #include "wx/dynarray.h" #include "wx/socket.h" ! #include "wx/filename.h" #include "wxlua/include/wxlua.h" #include "wxluasocket/include/wxldserv.h" + #include "wxluasocket/include/wxlsock.h" #define ID_WXLUA_SERVER 1200 *************** *** 53,57 **** // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUASOCKET wxLuaDebugSocket { public: --- 44,48 ---- // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUASOCKET wxLuaDebugSocket : public wxLuaSocketBase { public: *************** *** 86,110 **** bool WaitForRead(long seconds = 0, long milliseconds = 300) { return m_socket && m_socket->WaitForRead(seconds, milliseconds); } ! // Read Data ! unsigned char ReadByte(); ! short ReadWord(); ! unsigned short ReadUWord(); ! int ReadInt(); ! unsigned int ReadUInt(); ! long ReadLong(); ! unsigned long ReadULong(); ! wxString ReadString(); ! wxLuaDebugData* ReadDebugData(); ! ! // Write Data ! bool WriteByte(unsigned char value); ! bool WriteWord(short value); ! bool WriteUWord(unsigned short value); ! bool WriteInt(int value); ! bool WriteUInt(unsigned int value); ! bool WriteLong(long value); ! bool WriteULong(unsigned long value); ! bool WriteString(const wxString &value); ! bool WriteDebugData(const wxLuaDebugData *pSortedList); // operators --- 77,84 ---- bool WaitForRead(long seconds = 0, long milliseconds = 300) { return m_socket && m_socket->WaitForRead(seconds, milliseconds); } ! // Read the whole buffer of size length into buffer buffer from the socket ! virtual int Read(char *buffer, int length); ! // Write the whole buffer of size length to the socket ! virtual int Write(const char *buffer, int length); // operators Index: wxlsock.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/wxlsock.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** wxlsock.h 20 May 2006 19:57:59 -0000 1.6 --- wxlsock.h 6 Sep 2006 05:33:08 -0000 1.7 *************** *** 17,20 **** --- 17,22 ---- #include "wxluasocket/include/wxluasocketdefs.h" + class WXDLLIMPEXP_WXLUADEBUG wxLuaDebugData; + #ifdef WIN32 typedef int socklen_t; *************** *** 38,46 **** #endif // SD_RECEIVE // ---------------------------------------------------------------------------- // wxLuaSocket // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUASOCKET wxLuaSocket { #ifdef WIN32 --- 40,90 ---- #endif // SD_RECEIVE + + // ---------------------------------------------------------------------------- + // wxLuaSocketBase - a base class for different socket implementations + // + // You must override virtual int Read(...) and virtual int Write(...) + // ---------------------------------------------------------------------------- + + class WXDLLIMPEXP_WXLUASOCKET wxLuaSocketBase + { + public: + wxLuaSocketBase() {} + virtual ~wxLuaSocketBase() {} + + // Read the whole buffer of size length into buffer buffer from the socket + virtual int Read(char *buffer, int length) = 0; + // Write the whole buffer of size length to the socket + virtual int Write(const char *buffer, int length) = 0; + + // Read data from the socket, calls virtual int Read(...) + unsigned char ReadByte(); + short ReadWord(); + unsigned short ReadUWord(); + int ReadInt(); + unsigned int ReadUInt(); + long ReadLong(); + unsigned long ReadULong(); + wxString ReadString(); + wxLuaDebugData *ReadDebugData(); + + // Write data to the socket, calls virtual void Write(...) + bool WriteCharData(const char* data, int length); + bool WriteByte(unsigned char value); + bool WriteWord(short value); + bool WriteUWord(unsigned short value); + bool WriteInt(int value); + bool WriteUInt(unsigned int value); + bool WriteLong(long value); + bool WriteULong(unsigned long value); + bool WriteString(const wxString &value); + bool WriteDebugData(const wxLuaDebugData *pData); + }; + // ---------------------------------------------------------------------------- // wxLuaSocket // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUASOCKET wxLuaSocket : public wxLuaSocketBase { #ifdef WIN32 *************** *** 117,123 **** 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 in an orderly fashion void Shutdown(int how); --- 161,167 ---- int GetPort() const; // Read the whole buffer of size length into buffer buffer from the socket ! virtual int Read(char *buffer, int length); // Write the whole buffer of size length to the socket ! virtual int Write(const char *buffer, int length); // Shutdown the socket in an orderly fashion void Shutdown(int how); Index: wxldtarg.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/wxldtarg.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** wxldtarg.h 28 Aug 2006 05:26:21 -0000 1.11 --- wxldtarg.h 6 Sep 2006 05:33:08 -0000 1.12 *************** *** 19,23 **** #include "wxlua/include/wxlua.h" #include "wxluadebug/include/wxldebug.h" - #include "wxluasocket/include/wxldbgio.h" #include "wxluasocket/include/wxlsock.h" --- 19,22 ---- *************** *** 54,58 **** // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUASOCKET wxLuaDebugTarget : public wxObject, public wxLuaDebugIO { private: --- 53,57 ---- // ---------------------------------------------------------------------------- ! class WXDLLIMPEXP_WXLUASOCKET wxLuaDebugTarget : public wxObject { private: Index: wxlhandl.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/include/wxlhandl.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** wxlhandl.h 5 Sep 2006 21:48:11 -0000 1.6 --- wxlhandl.h 6 Sep 2006 05:33:08 -0000 1.7 *************** *** 42,49 **** // 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: ! static wxLuaHandler* sm_luahandler; wxCriticalSection m_luaCriticalSection; }; --- 42,49 ---- // 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: ! static wxLuaHandler* sm_luaHandler; wxCriticalSection m_luaCriticalSection; }; |