summaryrefslogtreecommitdiff
path: root/tools/m4
diff options
context:
space:
mode:
Diffstat (limited to 'tools/m4')
-rw-r--r--tools/m4/class_gobject.m45
-rw-r--r--tools/m4/class_gtkobject.m45
-rw-r--r--tools/m4/class_shared.m452
3 files changed, 62 insertions, 0 deletions
diff --git a/tools/m4/class_gobject.m4 b/tools/m4/class_gobject.m4
index 50743d99..12cbec6c 100644
--- a/tools/m4/class_gobject.m4
+++ b/tools/m4/class_gobject.m4
@@ -247,6 +247,11 @@ public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
static GType get_type() G_GNUC_CONST;
+
+ifdef(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`
+ static GType get_type(GTypeModule* module) G_GNUC_CONST;
+',`')
+
static GType get_base_type() G_GNUC_CONST;
#endif
diff --git a/tools/m4/class_gtkobject.m4 b/tools/m4/class_gtkobject.m4
index cbe9529c..9c6e3e14 100644
--- a/tools/m4/class_gtkobject.m4
+++ b/tools/m4/class_gtkobject.m4
@@ -210,6 +210,11 @@ protected:
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
static GType get_type() G_GNUC_CONST;
+
+ifdef(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`
+ static GType get_type(GTypeModule* module) G_GNUC_CONST;
+',`')
+
static GType get_base_type() G_GNUC_CONST;
#endif
diff --git a/tools/m4/class_shared.m4 b/tools/m4/class_shared.m4
index 13f718c2..43e24939 100644
--- a/tools/m4/class_shared.m4
+++ b/tools/m4/class_shared.m4
@@ -50,6 +50,17 @@ define(`__BOOL_DO_NOT_DERIVE_GTYPE__',`$1')
_POP()
')
+dnl GVolumeMonitor can be broken/impeded by defining a sub-type.
+define(`_DYNAMIC_GTYPE_REGISTRATION',`dnl
+_PUSH()
+dnl Define this macro to be tested for later.
+define(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`$1')
+_POP()
+')
+
+
+
+
dnl
dnl
dnl
@@ -73,6 +84,10 @@ ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
const Glib::Class& init();
+ifdef(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`
+ const Glib::Class& init(GTypeModule* module);
+',`')
+
ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
',`dnl
static void class_init_function(void* g_class, void* class_data);
@@ -126,6 +141,34 @@ _IMPORT(SECTION_CC_IMPLEMENTS_INTERFACES)
return *this;
}
+
+ifdef(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`
+const Glib::Class& __CPPNAME__`'_Class::init(GTypeModule* module)
+{
+ if(!gtype_) // create the GType if necessary
+ {
+ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
+ // Do not derive a GType, or use a derived klass:
+ gtype_ = CppClassParent::CppObjectType::get_type();
+',`dnl
+ // Glib::Class has to know the class init function to clone custom types.
+ class_init_func_ = &__CPPNAME__`'_Class::class_init_function;
+
+ // This is actually just optimized away, apparently with no harm.
+ // Make sure that the parent type has been created.
+ //CppClassParent::CppObjectType::get_type();
+
+ // Create the wrapper type, with the same class/instance size as the base type.
+ register_derived_type(_LOWER(__CCAST__)_get_type(), module);
+
+ // Add derived versions of interfaces, if the C type implements any interfaces:
+_IMPORT(SECTION_CC_IMPLEMENTS_INTERFACES)
+')
+ }
+
+ return *this;
+',`')
+
ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
',`dnl
@@ -166,6 +209,15 @@ GType __CPPNAME__::get_type()
return __BASE__`'_class_.init().get_type();
}
+ifdef(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`
+GType __CPPNAME__::get_type(GTypeModule* module)
+{
+ return __BASE__`'_class_.init(module).get_type();
+}
+'dnl
+,`'dnl
+)
+
GType __CPPNAME__::get_base_type()
{
return _LOWER(__CCAST__)_get_type();