From: Matthias Clasen Date: Fri, 21 Apr 2006 16:53:02 +0000 (+0000) Subject: Add g_type_register_static_simple X-Git-Tag: GLIB_2_11_0~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e57b11a94221a62cd510d623baffea8949a6c0d;p=platform%2Fupstream%2Fglib.git Add g_type_register_static_simple --- diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 90b9816..62f6607 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,11 @@ +2006-04-21 Matthias Clasen + + * gobject.symbols: + * gtype.[hc]: Add a g_type_register_static_simple + variant of g_type_register_static that does not take + a relocation-causing GTypeInfo struct, and use it + in G_DEFINE_TYPE. + 2006-03-07 Matthias Clasen * === Released 2.10.1 === diff --git a/gobject/gobject.symbols b/gobject/gobject.symbols index 7d2648f..24db318 100644 --- a/gobject/gobject.symbols +++ b/gobject/gobject.symbols @@ -16,6 +16,7 @@ g_boxed_copy g_boxed_free g_boxed_type_register_static +g_boxed_type_register_static_simple g_date_get_type G_GNUC_CONST g_gstring_get_type G_GNUC_CONST g_strv_get_type G_GNUC_CONST diff --git a/gobject/gtype.c b/gobject/gtype.c index 95518f1..45d7590 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -2204,6 +2204,31 @@ g_type_register_fundamental (GType type_id, } GType +g_type_register_static_simple (GType parent_type, + const gchar *type_name, + guint class_size, + GClassInitFunc class_init, + guint instance_size, + GInstanceInitFunc instance_init, + GTypeFlags flags) +{ + GTypeInfo info; + + info.class_size = class_size; + info.base_init = NULL; + info.base_finalize = NULL; + info.class_init = class_init; + info.class_finalize = NULL; + info.class_data = NULL; + info.instance_size = instance_size; + info.n_preallocs = 0; + info.instance_init = instance_init; + info.value_table = NULL; + + g_type_register_static (parent_type, type_name, &info, flags); +} + +GType g_type_register_static (GType parent_type, const gchar *type_name, const GTypeInfo *info, diff --git a/gobject/gtype.h b/gobject/gtype.h index 4ab0367..538d641 100644 --- a/gobject/gtype.h +++ b/gobject/gtype.h @@ -287,6 +287,14 @@ GType g_type_register_static (GType parent_type, const gchar *type_name, const GTypeInfo *info, GTypeFlags flags); +GType g_type_register_static_simple (GType parent_type, + const gchar *type_name, + guint class_size, + GClassInitFunc class_init, + guint instance_size, + GInstanceInitFunc instance_init, + GTypeFlags flags); + GType g_type_register_dynamic (GType parent_type, const gchar *type_name, GTypePlugin *plugin, @@ -362,19 +370,14 @@ type_name##_get_type (void) \ static GType g_define_type_id = 0; \ if (G_UNLIKELY (g_define_type_id == 0)) \ { \ - static const GTypeInfo g_define_type_info = { \ - sizeof (TypeName##Class), \ - (GBaseInitFunc) NULL, \ - (GBaseFinalizeFunc) NULL, \ - (GClassInitFunc) type_name##_class_intern_init, \ - (GClassFinalizeFunc) NULL, \ - NULL, /* class_data */ \ - sizeof (TypeName), \ - 0, /* n_preallocs */ \ - (GInstanceInitFunc) type_name##_init, \ - NULL /* value_table */ \ - }; \ - g_define_type_id = g_type_register_static (TYPE_PARENT, g_intern_static_string (#TypeName), &g_define_type_info, (GTypeFlags) flags); \ + g_define_type_id = \ + g_type_register_static_simple (TYPE_PARENT, \ + g_intern_static_string (#TypeName), \ + sizeof (TypeName##Class), \ + type_name##_class_intern_init, \ + sizeof (TypeName), \ + type_name##_init, \ + (GTypeFlags) flags); \ { CODE ; } \ } \ return g_define_type_id; \