From f24d8247b3a20cc62b4be50a0515acffd7e7d277 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Tue, 29 Nov 2011 22:02:00 -0500 Subject: [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. https://bugzilla.gnome.org/show_bug.cgi?id=600161 --- docs/reference/gobject/tut_gtype.xml | 8 ++++---- docs/reference/gobject/tut_howto.xml | 2 +- gobject/gboxed.c | 2 +- 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 | 2 +- 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, 29 insertions(+), 29 deletions(-) diff --git a/docs/reference/gobject/tut_gtype.xml b/docs/reference/gobject/tut_gtype.xml index c18fbc43e..89de1f8ff 100644 --- a/docs/reference/gobject/tut_gtype.xml +++ b/docs/reference/gobject/tut_gtype.xml @@ -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 */ diff --git a/docs/reference/gobject/tut_howto.xml b/docs/reference/gobject/tut_howto.xml index 1534838c3..9d592b8bd 100644 --- a/docs/reference/gobject/tut_howto.xml +++ b/docs/reference/gobject/tut_howto.xml @@ -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 */ diff --git a/gobject/gboxed.c b/gobject/gboxed.c index 755955c61..b321ef077 100644 --- a/gobject/gboxed.c +++ b/gobject/gboxed.c @@ -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 */ diff --git a/gobject/genums.c b/gobject/genums.c index 4346508ae..c69af7675 100644 --- a/gobject/genums.c +++ b/gobject/genums.c @@ -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 */ diff --git a/gobject/gobject.c b/gobject/gobject.c index 97b4b7252..0381a8bf7 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -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, diff --git a/gobject/gparam.c b/gobject/gparam.c index 6d136f3fc..b05e8c3b2 100644 --- a/gobject/gparam.c +++ b/gobject/gparam.c @@ -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, diff --git a/gobject/gtype.h b/gobject/gtype.h index 7d1e8ff9f..abd033acc 100644 --- a/gobject/gtype.h +++ b/gobject/gtype.h @@ -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); diff --git a/gobject/gtypemodule.c b/gobject/gtypemodule.c index d7f6bc4ad..b1a663dc9 100644 --- a/gobject/gtypemodule.c +++ b/gobject/gtypemodule.c @@ -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 */ diff --git a/gobject/gtypeplugin.c b/gobject/gtypeplugin.c index 092d36111..192f6f990 100644 --- a/gobject/gtypeplugin.c +++ b/gobject/gtypeplugin.c @@ -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 */ diff --git a/gobject/gvaluetypes.c b/gobject/gvaluetypes.c index 3afb30035..563699027 100644 --- a/gobject/gvaluetypes.c +++ b/gobject/gvaluetypes.c @@ -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 */ diff --git a/gobject/testgobject.c b/gobject/testgobject.c index 2afd8aaaa..411fb35c0 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 2ebe89055..ece9259c8 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 924e7ad60..b6aabb449 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 f57189a65..86ce2e2ad 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 eaa6d35c5..9715c955d 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 7bfef05c8..6c377e4ac 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 3724c0e9d..1c40c6474 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 39f580f8c..b57863d4b 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 87bb8b5f9..a69e3ecc3 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 862bd2f57..90ea42bf5 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 2877995f2..90bae419b 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,