[PATCH] Do not use static GTypeInfo and GInterfaceInfo



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.
---
 docs/reference/gobject/tut_gtype.xml |    8 ++++----
 docs/reference/gobject/tut_howto.xml |    2 +-
 gobject/gboxed.c                     |    4 ++--
 gobject/genums.c                     |    2 +-
 gobject/gobject.c                    |    2 +-
 gobject/gparam.c                     |    2 +-
 gobject/gtype.h                      |    2 +-
 gobject/gtypemodule.c                |    4 ++--
 gobject/gtypeplugin.c                |    2 +-
 gobject/gvaluetypes.c                |    4 ++--
 gobject/testgobject.c                |    6 +++---
 tests/gobject/defaultiface.c         |    2 +-
 tests/gobject/deftype.c              |    2 +-
 tests/gobject/ifacecheck.c           |    2 +-
 tests/gobject/ifaceinit.c            |    2 +-
 tests/gobject/testcommon.h           |    6 +++---
 tests/refcount/objects.c             |    2 +-
 tests/refcount/objects2.c            |    2 +-
 tests/refcount/properties.c          |    2 +-
 tests/refcount/properties2.c         |    2 +-
 tests/refcount/signals.c             |    2 +-
 21 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/docs/reference/gobject/tut_gtype.xml b/docs/reference/gobject/tut_gtype.xml
index 2ea2bf3..df40e33 100644
--- a/docs/reference/gobject/tut_gtype.xml
+++ b/docs/reference/gobject/tut_gtype.xml
@@ -306,7 +306,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,
@@ -419,7 +419,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 */
@@ -723,7 +723,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 */
@@ -734,7 +734,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 */
diff --git a/docs/reference/gobject/tut_howto.xml b/docs/reference/gobject/tut_howto.xml
index 319d951..0c89614 100644
--- a/docs/reference/gobject/tut_howto.xml
+++ b/docs/reference/gobject/tut_howto.xml
@@ -872,7 +872,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 */
diff --git a/gobject/gboxed.c b/gobject/gboxed.c
index e3a6170..e246e53 100644
--- a/gobject/gboxed.c
+++ b/gobject/gboxed.c
@@ -114,7 +114,7 @@ value_free (gpointer boxed)
 void
 g_boxed_type_init (void)
 {
-  static const GTypeInfo info = {
+  const GTypeInfo info = {
     0,                          /* class_size */
     NULL,                       /* base_init */
     NULL,                       /* base_destroy */
@@ -429,7 +429,7 @@ g_boxed_type_register_static (const gchar   *name,
     "p",
     boxed_proxy_lcopy_value,
   };
-  static const GTypeInfo type_info = {
+  const GTypeInfo type_info = {
     0,			/* class_size */
     NULL,		/* base_init */
     NULL,		/* base_finalize */
diff --git a/gobject/genums.c b/gobject/genums.c
index b49cae5..6471785 100644
--- a/gobject/genums.c
+++ b/gobject/genums.c
@@ -90,7 +90,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 */
diff --git a/gobject/gobject.c b/gobject/gobject.c
index f906d31..2b15969 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -237,7 +237,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,
diff --git a/gobject/gparam.c b/gobject/gparam.c
index 139baa0..abe9128 100644
--- a/gobject/gparam.c
+++ b/gobject/gparam.c
@@ -105,7 +105,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,
diff --git a/gobject/gtype.h b/gobject/gtype.h
index 860b518..699f9c3 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1326,7 +1326,7 @@ gpointer g_type_instance_get_private    (GTypeInstance              *instance,
  *                                        (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);
diff --git a/gobject/gtypemodule.c b/gobject/gtypemodule.c
index 1ba64ad..90a39ac 100644
--- a/gobject/gtypemodule.c
+++ b/gobject/gtypemodule.c
@@ -154,7 +154,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 */
@@ -165,7 +165,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 */
diff --git a/gobject/gtypeplugin.c b/gobject/gtypeplugin.c
index 3dbd13e..54f2797 100644
--- a/gobject/gtypeplugin.c
+++ b/gobject/gtypeplugin.c
@@ -96,7 +96,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 */
diff --git a/gobject/gvaluetypes.c b/gobject/gvaluetypes.c
index 5713e48..f0929fd 100644
--- a/gobject/gvaluetypes.c
+++ b/gobject/gvaluetypes.c
@@ -1057,7 +1057,7 @@ g_value_get_pointer (const GValue *value)
 GType
 g_gtype_get_type (void)
 {
-  static const GTypeInfo type_info = { 0, };
+  const GTypeInfo type_info = { 0, };
   static GType type;
   if (!type)
     type = g_type_register_static (G_TYPE_POINTER, g_intern_static_string ("GType"), &type_info, 0);
@@ -1186,7 +1186,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 */
diff --git a/gobject/testgobject.c b/gobject/testgobject.c
index 2723764..601dddb 100644
--- a/gobject/testgobject.c
+++ b/gobject/testgobject.c
@@ -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 */
diff --git a/tests/gobject/defaultiface.c b/tests/gobject/defaultiface.c
index 2ebe890..ece9259 100644
--- a/tests/gobject/defaultiface.c
+++ b/tests/gobject/defaultiface.c
@@ -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,
diff --git a/tests/gobject/deftype.c b/tests/gobject/deftype.c
index 924e7ad..b6aabb4 100644
--- a/tests/gobject/deftype.c
+++ b/tests/gobject/deftype.c
@@ -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 \
diff --git a/tests/gobject/ifacecheck.c b/tests/gobject/ifacecheck.c
index f57189a..86ce2e2 100644
--- a/tests/gobject/ifacecheck.c
+++ b/tests/gobject/ifacecheck.c
@@ -151,7 +151,7 @@ main (int   argc,
    */
   g_type_class_ref (TEST_TYPE_OBJECT4);
   {
-    static GInterfaceInfo const iface = {
+    GInterfaceInfo const iface = {
       NULL, NULL, NULL
     };
     
diff --git a/tests/gobject/ifaceinit.c b/tests/gobject/ifaceinit.c
index eaa6d35..9715c95 100644
--- a/tests/gobject/ifaceinit.c
+++ b/tests/gobject/ifaceinit.c
@@ -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 };						\
 								\
diff --git a/tests/gobject/testcommon.h b/tests/gobject/testcommon.h
index 7bfef05..6c377e4 100644
--- a/tests/gobject/testcommon.h
+++ b/tests/gobject/testcommon.h
@@ -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		\
     };								\
diff --git a/tests/refcount/objects.c b/tests/refcount/objects.c
index 9638045..483a8b2 100644
--- a/tests/refcount/objects.c
+++ b/tests/refcount/objects.c
@@ -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,
diff --git a/tests/refcount/objects2.c b/tests/refcount/objects2.c
index bbd4a82..3218a96 100644
--- a/tests/refcount/objects2.c
+++ b/tests/refcount/objects2.c
@@ -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,
diff --git a/tests/refcount/properties.c b/tests/refcount/properties.c
index c4c165c..64ab071 100644
--- a/tests/refcount/properties.c
+++ b/tests/refcount/properties.c
@@ -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,
diff --git a/tests/refcount/properties2.c b/tests/refcount/properties2.c
index bb79105..2cfa883 100644
--- a/tests/refcount/properties2.c
+++ b/tests/refcount/properties2.c
@@ -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,
diff --git a/tests/refcount/signals.c b/tests/refcount/signals.c
index 1a2a2ba..5758fb8 100644
--- a/tests/refcount/signals.c
+++ b/tests/refcount/signals.c
@@ -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,
-- 
1.6.5.2


--MP_/K9ID+SMHflL9cewWSWeM_ab
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=0001-Do-not-use-static-GTypeInfo-and-GInterfaceInfo.patch



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]