Add g_type_register_static_simple
authorMatthias Clasen <matthiasc@src.gnome.org>
Fri, 21 Apr 2006 16:53:02 +0000 (16:53 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 21 Apr 2006 16:53:02 +0000 (16:53 +0000)
gobject/ChangeLog
gobject/gobject.symbols
gobject/gtype.c
gobject/gtype.h

index 90b9816..62f6607 100644 (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 ===
index 7d2648f..24db318 100644 (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
index 95518f1..45d7590 100644 (file)
@@ -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,
index 4ab0367..538d641 100644 (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; \