Add g_type_register_static_simple

This commit is contained in:
Matthias Clasen 2006-04-21 16:53:02 +00:00
parent 5aa4c5ef6d
commit 2e57b11a94
4 changed files with 50 additions and 13 deletions

View File

@ -1,3 +1,11 @@
2006-04-21 Matthias Clasen <mclasen@redhat.com>
* 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 <mclasen@redhat.com>
* === Released 2.10.1 ===

View File

@ -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

View File

@ -2203,6 +2203,31 @@ g_type_register_fundamental (GType type_id,
return NODE_TYPE (node);
}
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,

View File

@ -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; \