diff options
author | Alexander Larsson <alexl@redhat.com> | 2009-11-24 09:53:15 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2009-11-26 11:20:18 +0100 |
commit | 7d51c96e5e39e8f3b403884f286ef781f0c952d6 (patch) | |
tree | 8a6ac133a3a7761ee92e04f8ddae4c04abd831f5 /gobject/gtypemodule.h | |
parent | b3156508c49f5274805de1d0d9bc5a69f43de1e9 (diff) | |
download | glib-7d51c96e5e39e8f3b403884f286ef781f0c952d6.tar.gz |
Add G_IMPLEMENT_INTERFACE_DYNAMIC
Convenience macro to easy interface addition for dynamic types.
https://bugzilla.gnome.org/show_bug.cgi?id=508157
Diffstat (limited to 'gobject/gtypemodule.h')
-rw-r--r-- | gobject/gtypemodule.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/gobject/gtypemodule.h b/gobject/gtypemodule.h index a7c3cf9b2..a1eec3e12 100644 --- a/gobject/gtypemodule.h +++ b/gobject/gtypemodule.h @@ -119,8 +119,8 @@ struct _GTypeModuleClass * gtk_gadget, * GTK_TYPE_THING, * 0, - * G_IMPLEMENT_INTERFACE (TYPE_GIZMO, - * gtk_gadget_gizmo_init)); + * G_IMPLEMENT_INTERFACE_DYNAMIC (TYPE_GIZMO, + * gtk_gadget_gizmo_init)); * ]| * expands to * |[ @@ -167,7 +167,7 @@ struct _GTypeModuleClass * const GInterfaceInfo g_implement_interface_info = { * (GInterfaceInitFunc) gtk_gadget_gizmo_init * }; - * g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info); + * g_type_module_add_interface (type_module, g_define_type_id, TYPE_GIZMO, &g_implement_interface_info); * } * } * ]| @@ -215,6 +215,27 @@ type_name##_register_type (GTypeModule *type_module) \ { CODE ; } \ } +/** + * G_IMPLEMENT_INTERFACE_DYNAMIC: + * @TYPE_IFACE: The #GType of the interface to add + * @iface_init: The interface init function + * + * A convenience macro to ease interface addition in the @_C_ section + * of G_DEFINE_DYNAMIC_TYPE_EXTENDED(). See G_DEFINE_DYNAMIC_TYPE_EXTENDED() + * for an example. + * + * Note that this macro can only be used together with the + * G_DEFINE_DYNAMIC_TYPE_EXTENDED macros, since it depends on variable + * names from that macro. + * + * Since: 2.24 + */ +#define G_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init) { \ + const GInterfaceInfo g_implement_interface_info = { \ + iface_init, NULL, NULL \ + }; \ + g_type_module_add_interface (type_module, g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \ +} GType g_type_module_get_type (void) G_GNUC_CONST; gboolean g_type_module_use (GTypeModule *module); |