[glibmm] Gio::Socket: Move enums into class.



commit b8d14f135fd35f377e5a48d2d676b5951e219d71
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Apr 18 18:18:58 2017 +0200

    Gio::Socket: Move enums into class.

 examples/network/socket-client.cc |    6 +++---
 examples/network/socket-server.cc |    4 ++--
 gio/src/socket.ccg                |    7 +++++--
 gio/src/socket.hg                 |   20 +++++++++++---------
 gio/src/socketclient.hg           |   12 ++++++------
 gio/src/socketlistener.ccg        |    8 ++++----
 gio/src/socketlistener.hg         |    4 ++--
 tests/giomm_tls_client/main.cc    |    2 +-
 tools/m4/convert_gio.m4           |    6 +++---
 9 files changed, 37 insertions(+), 32 deletions(-)
---
diff --git a/examples/network/socket-client.cc b/examples/network/socket-client.cc
index ed312aa..aacbd6b 100644
--- a/examples/network/socket-client.cc
+++ b/examples/network/socket-client.cc
@@ -145,7 +145,7 @@ main(int argc, char* argv[])
   Glib::RefPtr<Gio::Socket> socket;
   Glib::RefPtr<Gio::SocketAddress> src_address;
   Glib::RefPtr<Gio::SocketAddress> address;
-  Gio::SocketType socket_type;
+  Gio::Socket::Type socket_type;
   Gio::SocketFamily socket_family;
   Glib::RefPtr<Gio::Cancellable> cancellable;
   Glib::RefPtr<Gio::SocketAddressEnumerator> enumerator;
@@ -188,12 +188,12 @@ main(int argc, char* argv[])
 
   loop = Glib::MainLoop::create();
 
-  socket_type = use_udp ? Gio::SocketType::DATAGRAM : Gio::SocketType::STREAM;
+  socket_type = use_udp ? Gio::Socket::Type::DATAGRAM : Gio::Socket::Type::STREAM;
   socket_family = use_ipv6 ? Gio::SocketFamily::IPV6 : Gio::SocketFamily::IPV4;
 
   try
   {
-    socket = Gio::Socket::create(socket_family, socket_type, Gio::SocketProtocol::DEFAULT);
+    socket = Gio::Socket::create(socket_family, socket_type, Gio::Socket::Protocol::DEFAULT);
   }
   catch (const Gio::Error& error)
   {
diff --git a/examples/network/socket-server.cc b/examples/network/socket-server.cc
index 436e836..59dd115 100644
--- a/examples/network/socket-server.cc
+++ b/examples/network/socket-server.cc
@@ -176,12 +176,12 @@ main(int argc, char* argv[])
 
   loop = Glib::MainLoop::create();
 
-  auto socket_type = use_udp ? Gio::SocketType::DATAGRAM : Gio::SocketType::STREAM;
+  auto socket_type = use_udp ? Gio::Socket::Type::DATAGRAM : Gio::Socket::Type::STREAM;
   auto socket_family = use_ipv6 ? Gio::SocketFamily::IPV6 : Gio::SocketFamily::IPV4;
 
   try
   {
-    socket = Gio::Socket::create(socket_family, socket_type, Gio::SocketProtocol::DEFAULT);
+    socket = Gio::Socket::create(socket_family, socket_type, Gio::Socket::Protocol::DEFAULT);
   }
   catch (const Gio::Error& error)
   {
diff --git a/gio/src/socket.ccg b/gio/src/socket.ccg
index babd1da..4e4910c 100644
--- a/gio/src/socket.ccg
+++ b/gio/src/socket.ccg
@@ -23,10 +23,13 @@
 #include <giomm/socketsource.h>
 #include "slot_async.h"
 
+using Type = Gio::Socket::Type;
+using Protocol = Gio::Socket::Protocol;
+
 namespace Gio
 {
 
-Socket::Socket(SocketFamily family, SocketType type, SocketProtocol protocol,
+Socket::Socket(SocketFamily family, Type type, Protocol protocol,
   const Glib::RefPtr<Cancellable>& cancellable)
 : _CONSTRUCT("family", int(family), "type", int(type), "protocol", int(protocol))
 {
@@ -40,7 +43,7 @@ Socket::Socket(int fd, const Glib::RefPtr<Cancellable>& cancellable) : _CONSTRUC
 
 // static
 Glib::RefPtr<Socket>
-Socket::create(SocketFamily family, SocketType type, SocketProtocol protocol,
+Socket::create(SocketFamily family, Type type, Protocol protocol,
   const Glib::RefPtr<Cancellable>& cancellable)
 {
   return Glib::make_refptr_for_instance<Socket>(new Socket(family, type, protocol, cancellable));
diff --git a/gio/src/socket.hg b/gio/src/socket.hg
index 530a1ab..55a3ce9 100644
--- a/gio/src/socket.hg
+++ b/gio/src/socket.hg
@@ -31,9 +31,6 @@ namespace Gio
 {
 class SocketSource;
 
-_WRAP_ENUM(SocketType, GSocketType)
-_WRAP_ENUM(SocketProtocol, GSocketProtocol)
-_WRAP_ENUM(SocketMsgFlags, GSocketMsgFlags)
 
 /** @defgroup NetworkIO Portable Network I/O Functionality
  */
@@ -91,8 +88,13 @@ class Socket : public Glib::Object, public Initable
   _CLASS_GOBJECT(Socket, GSocket, G_SOCKET, Glib::Object, GObject)
   _IMPLEMENTS_INTERFACE(Initable)
 
+public:
+  _WRAP_ENUM(Type, GSocketType)
+  _WRAP_ENUM(Protocol, GSocketProtocol)
+  _WRAP_ENUM(MsgFlags, GSocketMsgFlags)
+
 protected:
-  Socket(SocketFamily family, SocketType type, SocketProtocol protocol,
+  Socket(SocketFamily family, Type type, Protocol protocol,
          const Glib::RefPtr<Cancellable>& cancellable);
 
   Socket(int fd, const Glib::RefPtr<Cancellable>& cancellable);
@@ -104,7 +106,7 @@ public:
    * @throw Glib::Error
    */
   static Glib::RefPtr<Socket>
-  create(SocketFamily family, SocketType type, SocketProtocol protocol,
+  create(SocketFamily family, Type type, Protocol protocol,
          const Glib::RefPtr<Cancellable>& cancellable = Glib::RefPtr<Cancellable>());
 
   // gmmproc thinks that this function should be wrapped in this class because
@@ -278,8 +280,8 @@ public:
   _WRAP_METHOD(int get_fd() const, g_socket_get_fd)
   _WRAP_METHOD(Glib::RefPtr<SocketAddress> get_local_address() const, g_socket_get_local_address, errthrow)
   _WRAP_METHOD(Glib::RefPtr<SocketAddress> get_remote_address() const, g_socket_get_remote_address, errthrow)
-  _WRAP_METHOD(SocketProtocol get_protocol() const, g_socket_get_protocol)
-  _WRAP_METHOD(SocketType get_socket_type() const, g_socket_get_socket_type)
+  _WRAP_METHOD(Protocol get_protocol() const, g_socket_get_protocol)
+  _WRAP_METHOD(Type get_socket_type() const, g_socket_get_socket_type)
   _WRAP_METHOD(bool speaks_ipv4() const, g_socket_speaks_ipv4)
 
   _WRAP_METHOD(Glib::RefPtr<Credentials> get_credentials(), g_socket_get_credentials, errthrow)
@@ -320,9 +322,9 @@ public:
   _WRAP_PROPERTY("local-address", Glib::RefPtr<SocketAddress>)
   _WRAP_PROPERTY("remote-address", Glib::RefPtr<SocketAddress>)
   _WRAP_PROPERTY("timeout", guint)
-  _WRAP_PROPERTY("protocol", SocketProtocol)
+  _WRAP_PROPERTY("protocol", Protocol)
   _WRAP_PROPERTY("broadcast", bool)
-  _WRAP_PROPERTY("type", SocketType)
+  _WRAP_PROPERTY("type", Type)
   _WRAP_PROPERTY("ttl", guint)
   _WRAP_PROPERTY("multicast-loopback", bool)
   _WRAP_PROPERTY("multicast-ttl", guint)
diff --git a/gio/src/socketclient.hg b/gio/src/socketclient.hg
index 5867943..26f0bd6 100644
--- a/gio/src/socketclient.hg
+++ b/gio/src/socketclient.hg
@@ -61,10 +61,10 @@ public:
   _WRAP_CREATE()
   _WRAP_METHOD(SocketFamily get_family() const, g_socket_client_get_family)
   _WRAP_METHOD(void set_family(SocketFamily family), g_socket_client_set_family)
-  _WRAP_METHOD(SocketType get_socket_type() const, g_socket_client_get_socket_type)
-  _WRAP_METHOD(void set_socket_type(SocketType type), g_socket_client_set_socket_type)
-  _WRAP_METHOD(SocketProtocol get_protocol() const, g_socket_client_get_protocol)
-  _WRAP_METHOD(void set_protocol(SocketProtocol protocol), g_socket_client_set_protocol)
+  _WRAP_METHOD(Socket::Type get_socket_type() const, g_socket_client_get_socket_type)
+  _WRAP_METHOD(void set_socket_type(Socket::Type type), g_socket_client_set_socket_type)
+  _WRAP_METHOD(Socket::Protocol get_protocol() const, g_socket_client_get_protocol)
+  _WRAP_METHOD(void set_protocol(Socket::Protocol protocol), g_socket_client_set_protocol)
   _WRAP_METHOD(Glib::RefPtr<SocketAddress> get_local_address(), g_socket_client_get_local_address)
   _WRAP_METHOD(Glib::RefPtr<const SocketAddress> get_local_address() const, 
g_socket_client_get_local_address, constversion)
   _WRAP_METHOD(void set_local_address(const Glib::RefPtr<SocketAddress>& address), 
g_socket_client_set_local_address)
@@ -159,8 +159,8 @@ public:
 
   _WRAP_PROPERTY("family", SocketFamily)
   _WRAP_PROPERTY("local-address", Glib::RefPtr<SocketAddress>)
-  _WRAP_PROPERTY("protocol", SocketProtocol)
-  _WRAP_PROPERTY("type", SocketType)
+  _WRAP_PROPERTY("protocol", Socket::Protocol)
+  _WRAP_PROPERTY("type", Socket::Type)
   _WRAP_PROPERTY("timeout", guint)
   _WRAP_PROPERTY("enable-proxy", bool)
   _WRAP_PROPERTY("tls", bool)
diff --git a/gio/src/socketlistener.ccg b/gio/src/socketlistener.ccg
index 08ba099..4185651 100644
--- a/gio/src/socketlistener.ccg
+++ b/gio/src/socketlistener.ccg
@@ -36,8 +36,8 @@ SocketListener::add_socket(const Glib::RefPtr<Socket>& socket)
 }
 
 bool
-SocketListener::add_address(const Glib::RefPtr<SocketAddress>& address, SocketType type,
-  SocketProtocol protocol, const Glib::RefPtr<Glib::Object>& source_object,
+SocketListener::add_address(const Glib::RefPtr<SocketAddress>& address, Socket::Type type,
+  Socket::Protocol protocol, const Glib::RefPtr<Glib::Object>& source_object,
   Glib::RefPtr<SocketAddress>& effective_address)
 {
   GError* gerror = nullptr;
@@ -55,8 +55,8 @@ SocketListener::add_address(const Glib::RefPtr<SocketAddress>& address, SocketTy
 }
 
 bool
-SocketListener::add_address(const Glib::RefPtr<SocketAddress>& address, SocketType type,
-  SocketProtocol protocol, Glib::RefPtr<SocketAddress>& effective_address)
+SocketListener::add_address(const Glib::RefPtr<SocketAddress>& address, Socket::Type type,
+  Socket::Protocol protocol, Glib::RefPtr<SocketAddress>& effective_address)
 {
   GError* gerror = nullptr;
   GSocketAddress* retaddr = nullptr;
diff --git a/gio/src/socketlistener.hg b/gio/src/socketlistener.hg
index 9472e6a..d463e44 100644
--- a/gio/src/socketlistener.hg
+++ b/gio/src/socketlistener.hg
@@ -66,11 +66,11 @@ public:
   bool add_socket(const Glib::RefPtr<Socket>& socket);
 
   _WRAP_METHOD_DOCS_ONLY(g_socket_listener_add_address)
-bool add_address(const Glib::RefPtr<SocketAddress>& address, SocketType type, SocketProtocol protocol, const 
Glib::RefPtr<Glib::Object>& source_object, Glib::RefPtr<SocketAddress>& effective_address);
+bool add_address(const Glib::RefPtr<SocketAddress>& address, Socket::Type type, Socket::Protocol protocol, 
const Glib::RefPtr<Glib::Object>& source_object, Glib::RefPtr<SocketAddress>& effective_address);
   _IGNORE(g_socket_listener_add_address)
 
   _WRAP_METHOD_DOCS_ONLY(g_socket_listener_add_address)
-  bool add_address(const Glib::RefPtr<SocketAddress>& address, SocketType type, SocketProtocol protocol, 
Glib::RefPtr<SocketAddress>& effective_address);
+  bool add_address(const Glib::RefPtr<SocketAddress>& address, Socket::Type type, Socket::Protocol protocol, 
Glib::RefPtr<SocketAddress>& effective_address);
 
   _WRAP_METHOD(bool add_inet_port(guint16 port, const Glib::RefPtr<Glib::Object>& source_object), 
g_socket_listener_add_inet_port, errthrow)
 
diff --git a/tests/giomm_tls_client/main.cc b/tests/giomm_tls_client/main.cc
index e53c24b..a4ec05c 100644
--- a/tests/giomm_tls_client/main.cc
+++ b/tests/giomm_tls_client/main.cc
@@ -77,7 +77,7 @@ main(int, char**)
             << std::endl;
 
   auto socket = Gio::Socket::create(
-    first_inet_address->get_family(), Gio::SocketType::STREAM, Gio::SocketProtocol::TCP);
+    first_inet_address->get_family(), Gio::Socket::Type::STREAM, Gio::Socket::Protocol::TCP);
 
   auto address = Gio::InetSocketAddress::create(first_inet_address, 443);
 
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index 15ce5fd..bc975e7 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -68,9 +68,9 @@ _CONV_GIO_ENUM(ResourceLookupFlags)
 _CONV_GIO_ENUM(SettingsBindFlags)
 _CONV_GIO_ENUM(SocketClientEvent)
 _CONV_GIO_ENUM(SocketFamily)
-_CONV_GIO_ENUM(SocketMsgFlags)
-_CONV_GIO_ENUM(SocketProtocol)
-_CONV_GIO_ENUM(SocketType)
+_CONV_GIO_INCLASS_ENUM(Socket,MsgFlags)
+_CONV_GIO_INCLASS_ENUM(Socket,Protocol)
+_CONV_GIO_INCLASS_ENUM(Socket,Type)
 _CONV_GIO_ENUM(TlsCertificateFlags)
 _CONV_GIO_ENUM(TlsCertificateRequestFlags)
 _CONV_GIO_ENUM(TlsDatabaseVerifyFlags)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]