Do not use static GTypeInfo and GInterfaceInfo
authorNicola Fontana <ntd@entidi.it>
Wed, 30 Nov 2011 03:02:00 +0000 (22:02 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 30 Nov 2011 03:03:25 +0000 (22:03 -0500)
Either g_type_register_static_simple (used by G_DEFINE_TYPE_EXTENDED)
and G_IMPLEMENT_INTERFACE use automatic variables for GTypeInfo and
GInterfaceInfo structs, while tutorials and source code often use
static variables. This commit consistently adopts the former method.

https://bugzilla.gnome.org/show_bug.cgi?id=600161

21 files changed:
docs/reference/gobject/tut_gtype.xml
docs/reference/gobject/tut_howto.xml
gobject/gboxed.c
gobject/genums.c
gobject/gobject.c
gobject/gparam.c
gobject/gtype.h
gobject/gtypemodule.c
gobject/gtypeplugin.c
gobject/gvaluetypes.c
gobject/testgobject.c
tests/gobject/defaultiface.c
tests/gobject/deftype.c
tests/gobject/ifacecheck.c
tests/gobject/ifaceinit.c
tests/gobject/testcommon.h
tests/refcount/objects.c
tests/refcount/objects2.c
tests/refcount/properties.c
tests/refcount/properties2.c
tests/refcount/signals.c

index c18fbc4..89de1f8 100644 (file)
@@ -309,7 +309,7 @@ GType maman_bar_get_type (void)
 {
   static GType type = 0;
   if (type == 0) {
-    static const GTypeInfo info = {
+    const GTypeInfo info = {
       /* You fill this structure. */
     };
     type = g_type_register_static (G_TYPE_OBJECT,
@@ -422,7 +422,7 @@ maman_bar_get_type (void)
 {
   static GType type = 0;
   if (type == 0) {
-    static const GTypeInfo info = {
+    const GTypeInfo info = {
       sizeof (MamanBarClass),
       NULL,           /* base_init */
       NULL,           /* base_finalize */
@@ -727,7 +727,7 @@ maman_baz_get_type (void)
 {
   static GType type = 0;
   if (type == 0) {
-    static const GTypeInfo info = {
+    const GTypeInfo info = {
       sizeof (MamanBazInterface),
       NULL,   /* base_init */
       NULL,   /* base_finalize */
@@ -738,7 +738,7 @@ maman_baz_get_type (void)
       0,      /* n_preallocs */
       NULL    /* instance_init */
     };
-    static const GInterfaceInfo ibaz_info = {
+    const GInterfaceInfo ibaz_info = {
       (GInterfaceInitFunc) baz_interface_init,    /* interface_init */
       NULL,               /* interface_finalize */
       NULL          /* interface_data */
index 1534838..9d592b8 100644 (file)
@@ -877,7 +877,7 @@ maman_ibaz_get_type (void)
   static GType iface_type = 0;
   if (iface_type == 0)
     {
-      static const GTypeInfo info = {
+      const GTypeInfo info = {
         sizeof (MamanIbazInterface),
         maman_ibaz_base_init,   /* base_init */
         NULL,   /* base_finalize */
index 755955c..b321ef0 100644 (file)
@@ -77,7 +77,7 @@ value_free (GValue *value)
 void
 _g_boxed_type_init (void)
 {
-  static const GTypeInfo info = {
+  const GTypeInfo info = {
     0,                          /* class_size */
     NULL,                       /* base_init */
     NULL,                       /* base_destroy */
index 4346508..c69af76 100644 (file)
@@ -88,7 +88,7 @@ _g_enum_types_init (void)
     "p",                           /* lcopy_format */
     value_flags_enum_lcopy_value,   /* lcopy_value */
   };
-  static GTypeInfo info = {
+  GTypeInfo info = {
     0,                          /* class_size */
     NULL,                       /* base_init */
     NULL,                       /* base_destroy */
index 97b4b72..0381a8b 100644 (file)
@@ -346,7 +346,7 @@ _g_object_type_init (void)
   static const GTypeFundamentalInfo finfo = {
     G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE,
   };
-  static GTypeInfo info = {
+  GTypeInfo info = {
     sizeof (GObjectClass),
     (GBaseInitFunc) g_object_base_class_init,
     (GBaseFinalizeFunc) g_object_base_class_finalize,
index 6d136f3..b05e8c3 100644 (file)
@@ -101,7 +101,7 @@ _g_param_type_init (void)
     "p",                       /* lcopy_format */
     value_param_lcopy_value,    /* lcopy_value */
   };
-  static const GTypeInfo param_spec_info = {
+  const GTypeInfo param_spec_info = {
     sizeof (GParamSpecClass),
 
     (GBaseInitFunc) g_param_spec_class_base_init,
index 7d1e8ff..abd033a 100644 (file)
@@ -1366,7 +1366,7 @@ gpointer  g_type_class_get_private      (GTypeClass                   *klass,
  *                                        (GInstanceInitFunc) gtk_gadget_init,
  *                                        (GTypeFlags) flags);
  *       {
- *         static const GInterfaceInfo g_implement_interface_info = {
+ *         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);
index d7f6bc4..b1a663d 100644 (file)
@@ -153,7 +153,7 @@ g_type_module_get_type (void)
 
   if (!type_module_type)
     {
-      static const GTypeInfo type_module_info = {
+      const GTypeInfo type_module_info = {
         sizeof (GTypeModuleClass),
         NULL,           /* base_init */
         NULL,           /* base_finalize */
@@ -164,7 +164,7 @@ g_type_module_get_type (void)
         0,              /* n_preallocs */
         NULL,           /* instance_init */
       };
-      static const GInterfaceInfo iface_info = {
+      const GInterfaceInfo iface_info = {
         (GInterfaceInitFunc) g_type_module_iface_init,
         NULL,               /* interface_finalize */
         NULL,               /* interface_data */
index 092d361..192f6f9 100644 (file)
@@ -95,7 +95,7 @@ g_type_plugin_get_type (void)
   
   if (!type_plugin_type)
     {
-      static const GTypeInfo type_plugin_info = {
+      const GTypeInfo type_plugin_info = {
        sizeof (GTypePluginClass),
        NULL,           /* base_init */
        NULL,           /* base_finalize */
index 3afb300..5636990 100644 (file)
@@ -1424,7 +1424,7 @@ g_strdup_value_contents (const GValue *value)
 GType
 g_pointer_type_register_static (const gchar *name)
 {
-  static const GTypeInfo type_info = {
+  const GTypeInfo type_info = {
     0,                 /* class_size */
     NULL,              /* base_init */
     NULL,              /* base_finalize */
index 2afd8aa..411fb35 100644 (file)
@@ -47,7 +47,7 @@ test_iface_get_type (void)
 
   if (!test_iface_type)
     {
-      static const GTypeInfo test_iface_info =
+      const GTypeInfo test_iface_info =
       {
        sizeof (TestIfaceClass),
        (GBaseInitFunc) iface_base_init,                /* base_init */
@@ -163,7 +163,7 @@ test_object_get_type (void)
 
   if (!test_object_type)
     {
-      static const GTypeInfo test_object_info =
+      const GTypeInfo test_object_info =
       {
        sizeof (TestObjectClass),
        NULL,           /* base_init */
@@ -327,7 +327,7 @@ derived_object_get_type (void)
 
   if (!derived_object_type)
     {
-      static const GTypeInfo derived_object_info =
+      const GTypeInfo derived_object_info =
       {
        sizeof (DerivedObjectClass),
        NULL,           /* base_init */
index 2ebe890..ece9259 100644 (file)
@@ -117,7 +117,7 @@ test_dynamic_iface_default_finalize (TestStaticIfaceClass *iface)
 static void
 test_dynamic_iface_register (GTypeModule *module)
 {
-  static const GTypeInfo iface_info =                  
+  const GTypeInfo iface_info =                 
     {                                                          
       sizeof (TestDynamicIfaceClass),
       (GBaseInitFunc)     NULL,
index 924e7ad..b6aabb4 100644 (file)
@@ -21,7 +21,7 @@
 /* see http://bugzilla.gnome.org/show_bug.cgi?id=337128 for the purpose of this test */
 
 #define MY_G_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init)       { \
-  static const GInterfaceInfo g_implement_interface_info = { \
+  const GInterfaceInfo g_implement_interface_info = { \
       (GInterfaceInitFunc) iface_init, \
       NULL, \
       NULL \
index f57189a..86ce2e2 100644 (file)
@@ -151,7 +151,7 @@ main (int   argc,
    */
   g_type_class_ref (TEST_TYPE_OBJECT4);
   {
-    static GInterfaceInfo const iface = {
+    GInterfaceInfo const iface = {
       NULL, NULL, NULL
     };
     
index eaa6d35..9715c95 100644 (file)
@@ -160,7 +160,7 @@ struct _TestObjectClass
 } G_STMT_END
 
 #define ADD_IFACE(n)  G_STMT_START {                           \
-  static GInterfaceInfo iface_info = {                         \
+  GInterfaceInfo iface_info = {                                \
     (GInterfaceInitFunc)test_object_test_iface##n##_init,      \
     NULL, NULL };                                              \
                                                                \
index 7bfef05..6c377e4 100644 (file)
@@ -32,7 +32,7 @@ prefix ## _get_type (void)                                    \
                                                                \
   if (!object_type)                                            \
     {                                                          \
-      static const GTypeInfo object_info =                     \
+      const GTypeInfo object_info =                    \
        {                                                       \
          sizeof (name ## Class),                               \
          (GBaseInitFunc) base_init,                            \
@@ -68,7 +68,7 @@ prefix ## _get_type (void)                                    \
                                                                \
   if (!iface_type)                                             \
     {                                                          \
-      static const GTypeInfo iface_info =                      \
+      const GTypeInfo iface_info =                     \
       {                                                                \
        sizeof (name ## Class),                                 \
        (GBaseInitFunc) base_init,                              \
@@ -85,7 +85,7 @@ prefix ## _get_type (void)                                    \
 
 #define INTERFACE_FULL(type, init_func, iface_type)            \
 {                                                              \
-  static GInterfaceInfo const iface =                          \
+  GInterfaceInfo const iface =                         \
     {                                                          \
       (GInterfaceInitFunc) init_func, NULL, NULL               \
     };                                                         \
index 3724c0e..1c40c64 100644 (file)
@@ -37,7 +37,7 @@ my_test_get_type (void)
   static GType test_type = 0;
 
   if (!test_type) {
-    static const GTypeInfo test_info = {
+    const GTypeInfo test_info = {
       sizeof (GTestClass),
       NULL,
       NULL,
index 39f580f..b57863d 100644 (file)
@@ -36,7 +36,7 @@ my_test_get_type (void)
   static GType test_type = 0;
 
   if (!test_type) {
-    static const GTypeInfo test_info = {
+    const GTypeInfo test_info = {
       sizeof (GTestClass),
       NULL,
       NULL,
index 87bb8b5..a69e3ec 100644 (file)
@@ -54,7 +54,7 @@ my_test_get_type (void)
   static GType test_type = 0;
 
   if (!test_type) {
-    static const GTypeInfo test_info = {
+    const GTypeInfo test_info = {
       sizeof (GTestClass),
       NULL,
       NULL,
index 862bd2f..90ea42b 100644 (file)
@@ -51,7 +51,7 @@ my_test_get_type (void)
   static GType test_type = 0;
 
   if (!test_type) {
-    static const GTypeInfo test_info = {
+    const GTypeInfo test_info = {
       sizeof (GTestClass),
       NULL,
       NULL,
index 2877995..90bae41 100644 (file)
@@ -68,7 +68,7 @@ my_test_get_type (void)
   static GType test_type = 0;
 
   if (!test_type) {
-    static const GTypeInfo test_info = {
+    const GTypeInfo test_info = {
       sizeof (GTestClass),
       NULL,
       NULL,