[glibmm] Gio::TlsClientConnection: Make the class work correctly.
- From: José Alburquerque <jaalburqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Gio::TlsClientConnection: Make the class work correctly.
- Date: Mon, 8 Apr 2013 04:32:14 +0000 (UTC)
commit ed95a3b5ddfb036e91be5d868e74f23ba304f37b
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Sun Apr 7 16:40:12 2013 -0400
Gio::TlsClientConnection: Make the class work correctly.
* tools/m4/class_interface.m4 (_CUSTOM_CTOR_CAST): Add a new macro so
that classes wrapped by the _CLASS_INTERFACE() macro can implement a
custom cast constructor. This is so that classes like
Tls[Client|Server]Connection, that derive from Glib::Interface but
should also derive from a Glib::Object derived type, though they do
not do so in the C API, don't produce warnings from an attempt to set
the non-existent properties of the GObject derived type when an
attempt to construct the C object is made in the default Glib::Object
constructor. Glib::wrap_auto_interface<>(), which is called by
Glib::wrap() for interfaces, uses the cast constructor to create the
wrapper which calls the cast constructor of Glib::Interface. If the
Glib::Object derived base class of the wrapper has a default
constructor, that constructor is then called which leads to the
Glib::Object default constructor being called, which tries to
construct the C object and set its properties thus producing the
property setting warnings. A custom cast constructor can chain up to
the cast constructor of the Glib::Object derived type thus avoiding
the call to the Glib::Object default constructor and the non-existent
property setting warnings.
* glib/glibmm/interface.cc:
* glib/glibmm/interface.h (Interface): Add a default constructor so
that in the cases above (when the cast constructor of the
Glib::Object's derived type is used), the compiler can find a
Glib::Interface default constructor to use. Using the Glib::Interface
cast constructor as well as the cast constructor of the Glib::Object
derived type would cause "ObjectBase::initialize() called twice
for the same GObject" errors.
ChangeLog | 32 ++++++++++++++++++++++++++++++++
gio/src/tlsclientconnection.ccg | 9 +++++++++
gio/src/tlsclientconnection.hg | 1 +
glib/glibmm/interface.cc | 4 ++++
glib/glibmm/interface.h | 4 ++++
tools/m4/class_interface.m4 | 11 +++++++++++
6 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ce0349d..c0d14e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2013-04-07 José Alburquerque <jaalburquerque gmail com>
+
+ Gio::TlsClientConnection: Make the class work correctly.
+
+ * tools/m4/class_interface.m4 (_CUSTOM_CTOR_CAST): Add a new macro so
+ that classes wrapped by the _CLASS_INTERFACE() macro can implement a
+ custom cast constructor. This is so that classes like
+ Tls[Client|Server]Connection, that derive from Glib::Interface but
+ should also derive from a Glib::Object derived type, though they do
+ not do so in the C API, don't produce warnings from an attempt to set
+ the non-existent properties of the GObject derived type when an
+ attempt to construct the C object is made in the default Glib::Object
+ constructor. Glib::wrap_auto_interface<>(), which is called by
+ Glib::wrap() for interfaces, uses the cast constructor to create the
+ wrapper which calls the cast constructor of Glib::Interface. If the
+ Glib::Object derived base class of the wrapper has a default
+ constructor, that constructor is then called which leads to the
+ Glib::Object default constructor being called, which tries to
+ construct the C object and set its properties thus producing the
+ property setting warnings. A custom cast constructor can chain up to
+ the cast constructor of the Glib::Object derived type thus avoiding
+ the call to the Glib::Object default constructor and the non-existent
+ property setting warnings.
+ * glib/glibmm/interface.cc:
+ * glib/glibmm/interface.h (Interface): Add a default constructor so
+ that in the cases above (when the cast constructor of the
+ Glib::Object's derived type is used), the compiler can find a
+ Glib::Interface default constructor to use. Using the Glib::Interface
+ cast constructor as well as the cast constructor of the Glib::Object
+ derived type would cause "ObjectBase::initialize() called twice
+ for the same GObject" errors.
+
2013-04-06 Murray Cumming <murrayc murrayc com>
Add a test of implementing an interface.
diff --git a/gio/src/tlsclientconnection.ccg b/gio/src/tlsclientconnection.ccg
index 0ea183e..3033364 100644
--- a/gio/src/tlsclientconnection.ccg
+++ b/gio/src/tlsclientconnection.ccg
@@ -17,3 +17,12 @@
#include <gio/gio.h>
#include <giomm/socketconnectable.h>
+
+namespace Gio
+{
+
+TlsClientConnection::TlsClientConnection(GTlsClientConnection* castitem)
+: TlsConnection(G_TLS_CONNECTION(castitem))
+{}
+
+} // namespace Gio
diff --git a/gio/src/tlsclientconnection.hg b/gio/src/tlsclientconnection.hg
index 20c8a50..e493f56 100644
--- a/gio/src/tlsclientconnection.hg
+++ b/gio/src/tlsclientconnection.hg
@@ -42,6 +42,7 @@ class TlsClientConnection
public TlsConnection
{
_CLASS_INTERFACE(TlsClientConnection, GTlsClientConnection, G_TLS_CLIENT_CONNECTION,
GTlsClientConnectionInterface)
+ _CUSTOM_CTOR_CAST
public:
//TODO: It's not possible to use _WRAP_CTOR/_WRAP_CREATE to wrap the new
diff --git a/glib/glibmm/interface.cc b/glib/glibmm/interface.cc
index c8fde23..d8d055f 100644
--- a/glib/glibmm/interface.cc
+++ b/glib/glibmm/interface.cc
@@ -73,6 +73,10 @@ Interface::Interface(GObject* castitem)
ObjectBase::initialize(castitem);
}
+Interface::Interface()
+{
+}
+
Interface::~Interface()
{}
diff --git a/glib/glibmm/interface.h b/glib/glibmm/interface.h
index 0ff2216..0639044 100644
--- a/glib/glibmm/interface.h
+++ b/glib/glibmm/interface.h
@@ -41,6 +41,10 @@ public:
typedef GTypeInterface BaseClassType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+ /** A Default constructor.
+ */
+ Interface();
+
/** Called by constructors of derived classes. Provide the result of
* the Class object's init() function to ensure that it is properly
* initialized.
diff --git a/tools/m4/class_interface.m4 b/tools/m4/class_interface.m4
index 99d1d75..a2ab274 100644
--- a/tools/m4/class_interface.m4
+++ b/tools/m4/class_interface.m4
@@ -16,6 +16,14 @@ define(`__PCAST__',`(__CPARENT__`'*)')
define(`__BOOL_IS_INTERFACE__',`1')
+dnl For classes that need custom code in their cast constructor.
+define(`_CUSTOM_CTOR_CAST',`dnl
+_PUSH()
+dnl Define this macro to be tested for later.
+define(`__BOOL_CUSTOM_CTOR_CAST__',`$1')
+_POP()
+')
+
_POP()
_SECTION(SECTION_CLASS2)
') dnl end of _CLASS_INTERFACE
@@ -178,10 +186,13 @@ __CPPNAME__::__CPPNAME__`'()
__CPPPARENT__`'(__BASE__`'_class_.init())
{}
+ifdef(`__BOOL_CUSTOM_CTOR_CAST__',`dnl
+',`dnl
__CPPNAME__::__CPPNAME__`'(__CNAME__* castitem)
:
__CPPPARENT__`'(__PCAST__`'(castitem))
{}
+')dnl
__CPPNAME__::__CPPNAME__`'(const Glib::Interface_Class& interface_class)
: __CPPPARENT__`'(interface_class)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]