From e27c99c7504d9168ee0ddd6043f942fd230027bc Mon Sep 17 00:00:00 2001 From: David Elliott Date: Fri, 6 Aug 2004 20:56:47 +0000 Subject: [PATCH] Get rid of wxUSE_GSOCKET_CPLUSPLUS git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28680 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gsocket.h | 241 ------------------------------- include/wx/mac/carbon/gsockmac.h | 2 - include/wx/msw/gsockmsw.h | 46 ------ include/wx/unix/gsockunx.h | 52 ------- src/common/appcmn.cpp | 17 --- 5 files changed, 358 deletions(-) diff --git a/include/wx/gsocket.h b/include/wx/gsocket.h index 2e49656249..1feda83e41 100644 --- a/include/wx/gsocket.h +++ b/include/wx/gsocket.h @@ -11,12 +11,6 @@ #ifndef __GSOCKET_H #define __GSOCKET_H -#define wxUSE_GSOCKET_CPLUSPLUS 1 - -#if !defined(__cplusplus) && defined(wxUSE_GSOCKET_CPLUSPLUS) -#error "You need to compile this file (probably a GUI gsock peice) as C++" -#endif - #ifndef __GSOCKET_STANDALONE__ #include "wx/setup.h" #include "wx/platform.h" @@ -42,17 +36,12 @@ #include #endif -#ifdef wxUSE_GSOCKET_CPLUSPLUS class GSocket; -#endif #ifdef __cplusplus extern "C" { #endif -#ifndef wxUSE_GSOCKET_CPLUSPLUS -typedef struct _GSocket GSocket; -#endif typedef struct _GAddress GAddress; typedef enum { @@ -106,15 +95,6 @@ typedef void (*GSocketCallback)(GSocket *socket, GSocketEvent event, /* Functions tables for internal use by GSocket code: */ -#if !defined(__WINDOWS__) && !defined(wxUSE_GSOCKET_CPLUSPLUS) -struct GSocketBaseFunctionsTable -{ - void (*Detected_Read)(GSocket *socket); - void (*Detected_Write)(GSocket *socket); -}; -#endif - -#if defined(wxUSE_GSOCKET_CPLUSPLUS) /* Actually this is a misnomer now, but reusing this name means I don't have to ifdef app traits or common socket code */ class GSocketGUIFunctionsTable @@ -133,22 +113,6 @@ public: virtual void Disable_Events(GSocket *socket) = 0; }; -#else -struct GSocketGUIFunctionsTable -{ - int (*GUI_Init)(void); - void (*GUI_Cleanup)(void); - int (*GUI_Init_Socket)(GSocket *socket); - void (*GUI_Destroy_Socket)(GSocket *socket); -#ifndef __WINDOWS__ - void (*Install_Callback)(GSocket *socket, GSocketEvent event); - void (*Uninstall_Callback)(GSocket *socket, GSocketEvent event); -#endif - void (*Enable_Events)(GSocket *socket); - void (*Disable_Events)(GSocket *socket); -}; -#endif /* defined(wxUSE_GSOCKET_CPLUSPLUS) */ - /* Global initializers */ @@ -166,209 +130,6 @@ void GSocket_Cleanup(void); /* Constructors / Destructors */ GSocket *GSocket_new(void); -#if !defined(wxUSE_GSOCKET_CPLUSPLUS) -void GSocket_destroy(GSocket *socket); -#endif - - -#ifndef wxUSE_GSOCKET_CPLUSPLUS - -/* GSocket_Shutdown: - * Disallow further read/write operations on this socket, close - * the fd and disable all callbacks. - */ -void GSocket_Shutdown(GSocket *socket); - -/* Address handling */ - -/* GSocket_SetLocal: - * GSocket_GetLocal: - * GSocket_SetPeer: - * GSocket_GetPeer: - * Set or get the local or peer address for this socket. The 'set' - * functions return GSOCK_NOERROR on success, an error code otherwise. - * The 'get' functions return a pointer to a GAddress object on success, - * or NULL otherwise, in which case they set the error code of the - * corresponding GSocket. - * - * Error codes: - * GSOCK_INVSOCK - the socket is not valid. - * GSOCK_INVADDR - the address is not valid. - */ -GSocketError GSocket_SetLocal(GSocket *socket, GAddress *address); -GSocketError GSocket_SetPeer(GSocket *socket, GAddress *address); -GAddress *GSocket_GetLocal(GSocket *socket); -GAddress *GSocket_GetPeer(GSocket *socket); - -/* Server specific parts */ - -/* GSocket_SetServer: - * Sets up this socket as a server. The local address must have been - * set with GSocket_SetLocal() before GSocket_SetServer() is called. - * Returns GSOCK_NOERROR on success, one of the following otherwise: - * - * Error codes: - * GSOCK_INVSOCK - the socket is in use. - * GSOCK_INVADDR - the local address has not been set. - * GSOCK_IOERR - low-level error. - */ -GSocketError GSocket_SetServer(GSocket *socket); - -/* GSocket_WaitConnection: - * Waits for an incoming client connection. Returns a pointer to - * a GSocket object, or NULL if there was an error, in which case - * the last error field will be updated for the calling GSocket. - * - * Error codes (set in the calling GSocket) - * GSOCK_INVSOCK - the socket is not valid or not a server. - * GSOCK_TIMEDOUT - timeout, no incoming connections. - * GSOCK_WOULDBLOCK - the call would block and the socket is nonblocking. - * GSOCK_MEMERR - couldn't allocate memory. - * GSOCK_IOERR - low-level error. - */ -GSocket *GSocket_WaitConnection(GSocket *socket); - - -/* Client specific parts */ - -/* GSocket_Connect: - * For stream (connection oriented) sockets, GSocket_Connect() tries - * to establish a client connection to a server using the peer address - * as established with GSocket_SetPeer(). Returns GSOCK_NOERROR if the - * connection has been succesfully established, or one of the error - * codes listed below. Note that for nonblocking sockets, a return - * value of GSOCK_WOULDBLOCK doesn't mean a failure. The connection - * request can be completed later; you should use GSocket_Select() - * to poll for GSOCK_CONNECTION | GSOCK_LOST, or wait for the - * corresponding asynchronous events. - * - * For datagram (non connection oriented) sockets, GSocket_Connect() - * just sets the peer address established with GSocket_SetPeer() as - * default destination. - * - * Error codes: - * GSOCK_INVSOCK - the socket is in use or not valid. - * GSOCK_INVADDR - the peer address has not been established. - * GSOCK_TIMEDOUT - timeout, the connection failed. - * GSOCK_WOULDBLOCK - connection in progress (nonblocking sockets only) - * GSOCK_MEMERR - couldn't allocate memory. - * GSOCK_IOERR - low-level error. - */ -GSocketError GSocket_Connect(GSocket *socket, GSocketStream stream); - -/* GSocket_SetReusable: -* Simply sets the m_resuable flag on the socket. GSocket_SetServer will -* make the appropriate setsockopt() call. -* Implemented as a GSocket function because clients (ie, wxSocketServer) -* don't have access to the GSocket struct information. -* Returns TRUE if the flag was set correctly, FALSE if an error occured -* (ie, if the parameter was NULL) -*/ -int GSocket_SetReusable(GSocket *socket); - -/* Datagram sockets */ - -/* GSocket_SetNonOriented: - * Sets up this socket as a non-connection oriented (datagram) socket. - * Before using this function, the local address must have been set - * with GSocket_SetLocal(), or the call will fail. Returns GSOCK_NOERROR - * on success, or one of the following otherwise. - * - * Error codes: - * GSOCK_INVSOCK - the socket is in use. - * GSOCK_INVADDR - the local address has not been set. - * GSOCK_IOERR - low-level error. - */ -GSocketError GSocket_SetNonOriented(GSocket *socket); - - -/* Generic IO */ - -/* Like recv(), send(), ... */ - -/* For datagram sockets, the incoming / outgoing addresses - * are stored as / read from the 'peer' address field. - */ -int GSocket_Read(GSocket *socket, char *buffer, int size); -int GSocket_Write(GSocket *socket, const char *buffer, - int size); - -/* GSocket_Select: - * Polls the socket to determine its status. This function will - * check for the events specified in the 'flags' parameter, and - * it will return a mask indicating which operations can be - * performed. This function won't block, regardless of the - * mode (blocking | nonblocking) of the socket. - */ -GSocketEventFlags GSocket_Select(GSocket *socket, GSocketEventFlags flags); - -GSocketError GSocket_GetSockOpt(GSocket *socket, int level, int optname, - void *optval, int *optlen); - -GSocketError GSocket_SetSockOpt(GSocket *socket, int level, int optname, - const void *optval, int optlen); - -/* Attributes */ - -/* GSocket_SetNonBlocking: - * Sets the socket to non-blocking mode. All IO calls will return - * immediately. - */ -void GSocket_SetNonBlocking(GSocket *socket, int non_block); - -/* GSocket_SetTimeout: - * Sets the timeout for blocking calls. Time is expressed in - * milliseconds. - */ -void GSocket_SetTimeout(GSocket *socket, unsigned long millisec); - -/* GSocket_GetError: - * Returns the last error occured for this socket. Note that successful - * operations do not clear this back to GSOCK_NOERROR, so use it only - * after an error. - */ -GSocketError WXDLLIMPEXP_NET GSocket_GetError(GSocket *socket); - -/* Callbacks */ - -/* GSOCK_INPUT: - * There is data to be read in the input buffer. If, after a read - * operation, there is still data available, the callback function will - * be called again. - * GSOCK_OUTPUT: - * The socket is available for writing. That is, the next write call - * won't block. This event is generated only once, when the connection is - * first established, and then only if a call failed with GSOCK_WOULDBLOCK, - * when the output buffer empties again. This means that the app should - * assume that it can write since the first OUTPUT event, and no more - * OUTPUT events will be generated unless an error occurs. - * GSOCK_CONNECTION: - * Connection succesfully established, for client sockets, or incoming - * client connection, for server sockets. Wait for this event (also watch - * out for GSOCK_LOST) after you issue a nonblocking GSocket_Connect() call. - * GSOCK_LOST: - * The connection is lost (or a connection request failed); this could - * be due to a failure, or due to the peer closing it gracefully. - */ - -/* GSocket_SetCallback: - * Enables the callbacks specified by 'flags'. Note that 'flags' - * may be a combination of flags OR'ed toghether, so the same - * callback function can be made to accept different events. - * The callback function must have the following prototype: - * - * void function(GSocket *socket, GSocketEvent event, char *cdata) - */ -void GSocket_SetCallback(GSocket *socket, GSocketEventFlags flags, - GSocketCallback fallback, char *cdata); - -/* GSocket_UnsetCallback: - * Disables all callbacks specified by 'flags', which may be a - * combination of flags OR'ed toghether. - */ -void GSocket_UnsetCallback(GSocket *socket, GSocketEventFlags flags); - -#endif /* ndef wxUSE_GSOCKET_CPLUSPLUS */ /* GAddress */ @@ -407,7 +168,6 @@ GSocketError GAddress_UNIX_GetPath(GAddress *address, char *path, size_t sbuf); } #endif /* __cplusplus */ -#ifdef wxUSE_GSOCKET_CPLUSPLUS # if defined(__WINDOWS__) # include "wx/msw/gsockmsw.h" # elif defined(__WXMAC__) && !defined(__DARWIN__) @@ -415,7 +175,6 @@ GSocketError GAddress_UNIX_GetPath(GAddress *address, char *path, size_t sbuf); # else # include "wx/unix/gsockunx.h" # endif -#endif #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */ diff --git a/include/wx/mac/carbon/gsockmac.h b/include/wx/mac/carbon/gsockmac.h index 671a0d45cf..3bd209afe3 100644 --- a/include/wx/mac/carbon/gsockmac.h +++ b/include/wx/mac/carbon/gsockmac.h @@ -97,7 +97,6 @@ public: }; /* Compatibility methods to support old C API (from gsocket.h) */ -#ifdef wxUSE_GSOCKET_CPLUSPLUS inline void GSocket_Shutdown(GSocket *socket) { socket->Shutdown(); } inline GSocketError GSocket_SetLocal(GSocket *socket, GAddress *address) @@ -144,7 +143,6 @@ inline GSocketError GSocket_SetSockOpt(GSocket *socket, int level, int optname, inline void GSocket_destroy(GSocket *socket) { delete socket; } -#endif /* def wxUSE_GSOCKET_CPLUSPLUS */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/include/wx/msw/gsockmsw.h b/include/wx/msw/gsockmsw.h index b94dae93d1..84a6598e4d 100644 --- a/include/wx/msw/gsockmsw.h +++ b/include/wx/msw/gsockmsw.h @@ -21,12 +21,7 @@ #include "gsocket.h" #endif -#ifdef wxUSE_GSOCKET_CPLUSPLUS #include "wx/msw/wrapwin.h" -#else -#include -#include -#endif #ifndef TRUE #define TRUE 1 @@ -36,7 +31,6 @@ #define FALSE 0 #endif -#ifdef wxUSE_GSOCKET_CPLUSPLUS class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable { public: @@ -48,20 +42,10 @@ public: virtual void Enable_Events(GSocket *socket); virtual void Disable_Events(GSocket *socket); }; -#endif /* def wxUSE_GSOCKET_CPLUSPLUS */ - -#if defined(__cplusplus) && !defined wxUSE_GSOCKET_CPLUSPLUS -extern "C" { -#endif /* Definition of GSocket */ -#ifdef wxUSE_GSOCKET_CPLUSPLUS class GSocket -#else -struct _GSocket -#endif { -#ifdef wxUSE_GSOCKET_CPLUSPLUS public: GSocket(); ~GSocket(); @@ -102,7 +86,6 @@ protected: /* TODO: Make these protected */ public: -#endif /* def wxUSE_GSOCKET_CPLUSPLUS */ SOCKET m_fd; GAddress *m_local; GAddress *m_peer; @@ -123,7 +106,6 @@ public: int m_msgnumber; }; -#ifdef wxUSE_GSOCKET_CPLUSPLUS /* TODO: Fix src/common/socket.cpp to use the new API */ inline void GSocket_Shutdown(GSocket *socket) { socket->Shutdown(); } @@ -170,11 +152,6 @@ inline GSocketError GSocket_SetSockOpt(GSocket *socket, int level, int optname, { return socket->SetSockOpt(level,optname,optval,optlen); } inline void GSocket_destroy(GSocket *socket) { delete socket; } -#endif /* def wxUSE_GSOCKET_CPLUSPLUS */ - -#if defined(__cplusplus) && !defined wxUSE_GSOCKET_CPLUSPLUS -} -#endif #ifdef __cplusplus extern "C" { @@ -192,29 +169,6 @@ struct _GAddress GSocketError m_error; }; -#ifndef wxUSE_GSOCKET_CPLUSPLUS -/* Input / output */ - -GSocketError _GSocket_Input_Timeout(GSocket *socket); -GSocketError _GSocket_Output_Timeout(GSocket *socket); -GSocketError _GSocket_Connect_Timeout(GSocket *socket); -int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size); -int _GSocket_Recv_Dgram(GSocket *socket, char *buffer, int size); -int _GSocket_Send_Stream(GSocket *socket, const char *buffer, int size); -int _GSocket_Send_Dgram(GSocket *socket, const char *buffer, int size); - -/* Callbacks */ - -int _GSocket_GUI_Init(void); -void _GSocket_GUI_Cleanup(void); -int _GSocket_GUI_Init_Socket(GSocket *socket); -void _GSocket_GUI_Destroy_Socket(GSocket *socket); - -LRESULT CALLBACK _GSocket_Internal_WinProc(HWND, UINT, WPARAM, LPARAM); - -void _GSocket_Enable_Events(GSocket *socket); -void _GSocket_Disable_Events(GSocket *socket); -#endif /* ndef wxUSE_GSOCKET_CPLUSPLUS */ /* GAddress */ diff --git a/include/wx/unix/gsockunx.h b/include/wx/unix/gsockunx.h index c73a168d5b..68687afa56 100644 --- a/include/wx/unix/gsockunx.h +++ b/include/wx/unix/gsockunx.h @@ -29,7 +29,6 @@ #define FALSE 0 #endif -#ifdef wxUSE_GSOCKET_CPLUSPLUS class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable { public: @@ -43,9 +42,7 @@ public: virtual void Enable_Events(GSocket *socket); virtual void Disable_Events(GSocket *socket); }; -#endif /* def wxUSE_GSOCKET_CPLUSPLUS */ -#ifdef wxUSE_GSOCKET_CPLUSPLUS class GSocket { public: @@ -93,15 +90,6 @@ protected: public: /* DFE: We can't protect these data member until the GUI code is updated */ /* protected: */ -#else /* def wxUSE_GSOCKET_CPLUSPLUS */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ -/* Definition of GSocket */ -struct _GSocket -{ -#endif /* def wxUSE_GSOCKET_CPLUSPLUS */ int m_fd; GAddress *m_local; GAddress *m_peer; @@ -121,16 +109,7 @@ struct _GSocket char *m_gui_dependent; -#ifndef wxUSE_GSOCKET_CPLUSPLUS - /* Function pointers */ - struct GSocketBaseFunctionsTable *m_functions; -#endif /* ndef wxUSE_GSOCKET_CPLUSPLUS */ }; -#ifndef wxUSE_GSOCKET_CPLUSPLUS -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* ndef wxUSE_GSOCKET_CPLUSPLUS */ #ifdef __cplusplus extern "C" { @@ -151,7 +130,6 @@ struct _GAddress #endif /* __cplusplus */ /* Compatibility methods to support old C API (from gsocket.h) */ -#ifdef wxUSE_GSOCKET_CPLUSPLUS inline void GSocket_Shutdown(GSocket *socket) { socket->Shutdown(); } inline GSocketError GSocket_SetLocal(GSocket *socket, GAddress *address) @@ -198,41 +176,11 @@ inline GSocketError GSocket_SetSockOpt(GSocket *socket, int level, int optname, inline void GSocket_destroy(GSocket *socket) { delete socket; } -#endif /* def wxUSE_GSOCKET_CPLUSPLUS */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -/* Input / Output */ - -GSocketError _GSocket_Input_Timeout(GSocket *socket); -GSocketError _GSocket_Output_Timeout(GSocket *socket); -int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size); -int _GSocket_Recv_Dgram(GSocket *socket, char *buffer, int size); -int _GSocket_Send_Stream(GSocket *socket, const char *buffer, int size); -int _GSocket_Send_Dgram(GSocket *socket, const char *buffer, int size); - -/* Callbacks */ - -int _GSocket_GUI_Init(void); -void _GSocket_GUI_Cleanup(void); - -int _GSocket_GUI_Init_Socket(GSocket *socket); -void _GSocket_GUI_Destroy_Socket(GSocket *socket); - -void _GSocket_Enable_Events(GSocket *socket); -void _GSocket_Disable_Events(GSocket *socket); -void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event); -void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event); - -void _GSocket_Enable(GSocket *socket, GSocketEvent event); -void _GSocket_Disable(GSocket *socket, GSocketEvent event); - -#ifndef wxUSE_GSOCKET_CPLUSPLUS -void _GSocket_Detected_Read(GSocket *socket); -void _GSocket_Detected_Write(GSocket *socket); -#endif /* ndef wxUSE_GSOCKET_CPLUSPLUS */ /* GAddress */ diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index 42d33f7c79..bed9667de4 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -593,25 +593,8 @@ GSocketGUIFunctionsTable* wxGUIAppTraitsBase::GetSocketGUIFunctionsTable() // so it doesn't need this table at all return NULL; #else // !__WXMAC__ || __DARWIN__ -#if defined(wxUSE_GSOCKET_CPLUSPLUS) static GSocketGUIFunctionsTableConcrete table; return &table; -#else - static GSocketGUIFunctionsTable table = - { - _GSocket_GUI_Init, - _GSocket_GUI_Cleanup, - _GSocket_GUI_Init_Socket, - _GSocket_GUI_Destroy_Socket, -#ifndef __WINDOWS__ - _GSocket_Install_Callback, - _GSocket_Uninstall_Callback, -#endif - _GSocket_Enable_Events, - _GSocket_Disable_Events - }; - return &table; -#endif // defined(wxUSE_GSOCKET_CPLUSPLUS) #endif // !__WXMAC__ || __DARWIN__ } -- 2.45.2