After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 586366 - Allow dynamic module type registration (g_type_module_register_type)
Allow dynamic module type registration (g_type_module_register_type)
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: object
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2009-06-19 11:13 UTC by Murray Cumming
Modified: 2010-03-26 09:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
glibmm_dynamic_gype.patch (8.21 KB, patch)
2009-06-19 13:33 UTC, Murray Cumming
none Details | Review

Description Murray Cumming 2009-06-19 11:13:27 UTC
We need to allow classes to use
g_type_module_register_type():
  http://library.gnome.org/devel/gobject/unstable/GTypeModule.html#g-type-module-register-type
instead of g_type_register_static(), currently used in Glib::Class::register_derived_type(), called from the derived SomeWidget_Class::init() functions.

The custom type-registration function would then be called by a plugin entry point, such as the entry point,
  void hd_plugin_module_load(HDPluginModule* plugin);
for a Hildon Desktop Widget.

Maybe we could add an optional
  _DYNAMIC_REGISTRATION()
gmmproc macro that would _add_ a 
  SomeWidget::register_dynamic_type(GTypeModule* module)
that could be called from the entry point function,
and we could check for that previous registration in our regular SomeWidget_Class::init() functions to avoid a second (static) type registration.
Comment 1 Murray Cumming 2009-06-19 13:33:29 UTC
Created attachment 137000 [details] [review]
glibmm_dynamic_gype.patch

An untested patch to implement this:

2009-06-19  Murray Cumming  <murrayc@murrayc.com>

	Allow dynamic GType registration, using g_type_module_register_type().
	
	* glib/glibmm/class.[h|cc]: Added a  register_derived_type() overload that 
	takes an extra GTypeModule* parameter, and which calls 
	g_type_module_register_type() instead of g_type_register_static().
	* tools/m4/class_gobject.m4:
	* tools/m4/class_gtkobject.m4:
	* tools/m4/class_shared.m4: Added a _DYNAMIC_GTYPE_REGISTRATION macro to 
	be used in the class in the hg file, to add a *_Class::init(GTypeModule) 
	method, and a get_type(GTypeModule*) method that calls it.
Comment 2 Murray Cumming 2009-07-17 10:10:34 UTC
I committed this, to get some testing.