diff options
author | Matthias Clasen <mclasen@redhat.com> | 2006-12-29 06:12:11 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2006-12-29 06:12:11 +0000 |
commit | d7b7c44e4012ed6a5f7343293db70ac2b3b29acd (patch) | |
tree | 464f242fd7ae1b1cc38ea20ab01e1ba61eb2e399 /gobject/gtypemodule.h | |
parent | b1e4310d6f50bf71b56368323810105717f8e2bb (diff) |
Define G_DEFINE_DYNAMIC_TYPE and and _EXTENDED variant. (#334437)
2006-12-29 Matthias Clasen <mclasen@redhat.com>
* gtypemodule.h: Define G_DEFINE_DYNAMIC_TYPE and
and _EXTENDED variant. (#334437)
Diffstat (limited to 'gobject/gtypemodule.h')
-rw-r--r-- | gobject/gtypemodule.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/gobject/gtypemodule.h b/gobject/gtypemodule.h index 7809c9599..a99238976 100644 --- a/gobject/gtypemodule.h +++ b/gobject/gtypemodule.h @@ -66,6 +66,47 @@ struct _GTypeModuleClass void (*reserved4) (void); }; +#define G_DEFINE_DYNAMIC_TYPE(TN, t_n, T_P) G_DEFINE_DYNAMIC_TYPE_EXTENDED (TN, t_n, T_P, 0, {}) +#define G_DEFINE_DYNAMIC_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE) \ +static void type_name##_init (TypeName *self); \ +static void type_name##_class_init (TypeName##Class *klass); \ +static void type_name##_class_finalize (TypeName##Class *klass); \ +static gpointer type_name##_parent_class = NULL; \ +static GType type_name##_type_id = 0; \ +static void type_name##_class_intern_init (gpointer klass) \ +{ \ + type_name##_parent_class = g_type_class_peek_parent (klass); \ + type_name##_class_init ((TypeName##Class*) klass); \ +} \ +GType \ +type_name##_get_type (void) \ +{ \ + return type_name##_type_id; \ +} \ +static void \ +type_name##_register_type (GTypeModule *type_module) \ +{ \ + const GTypeInfo g_define_type_info = { \ + sizeof (TypeName##Class), \ + (GBaseInitFunc) NULL, \ + (GBaseFinalizeFunc) NULL, \ + (GClassInitFunc) type_name##_class_intern_init, \ + (GClassFinalizeFunc) type_name##_class_finalize, \ + NULL, /* class_data */ \ + sizeof (TypeName), \ + 0, /* n_preallocs */ \ + (GInstanceInitFunc) type_name##_init, \ + NULL /* value_table */ \ + }; \ + type_name##_type_id = g_type_module_register_type (type_module, \ + TYPE_PARENT, \ + #TypeName, \ + &g_define_type_info, \ + (GTypeFlags) flags); \ + { CODE ; } \ +} + + GType g_type_module_get_type (void) G_GNUC_CONST; gboolean g_type_module_use (GTypeModule *module); void g_type_module_unuse (GTypeModule *module); |