mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 22:16:16 +01:00
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
This commit is contained in:
parent
1f33446e1f
commit
f24d8247b3
@ -309,7 +309,7 @@ GType maman_bar_get_type (void)
|
|||||||
{
|
{
|
||||||
static GType type = 0;
|
static GType type = 0;
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
static const GTypeInfo info = {
|
const GTypeInfo info = {
|
||||||
/* You fill this structure. */
|
/* You fill this structure. */
|
||||||
};
|
};
|
||||||
type = g_type_register_static (G_TYPE_OBJECT,
|
type = g_type_register_static (G_TYPE_OBJECT,
|
||||||
@ -422,7 +422,7 @@ maman_bar_get_type (void)
|
|||||||
{
|
{
|
||||||
static GType type = 0;
|
static GType type = 0;
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
static const GTypeInfo info = {
|
const GTypeInfo info = {
|
||||||
sizeof (MamanBarClass),
|
sizeof (MamanBarClass),
|
||||||
NULL, /* base_init */
|
NULL, /* base_init */
|
||||||
NULL, /* base_finalize */
|
NULL, /* base_finalize */
|
||||||
@ -727,7 +727,7 @@ maman_baz_get_type (void)
|
|||||||
{
|
{
|
||||||
static GType type = 0;
|
static GType type = 0;
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
static const GTypeInfo info = {
|
const GTypeInfo info = {
|
||||||
sizeof (MamanBazInterface),
|
sizeof (MamanBazInterface),
|
||||||
NULL, /* base_init */
|
NULL, /* base_init */
|
||||||
NULL, /* base_finalize */
|
NULL, /* base_finalize */
|
||||||
@ -738,7 +738,7 @@ maman_baz_get_type (void)
|
|||||||
0, /* n_preallocs */
|
0, /* n_preallocs */
|
||||||
NULL /* instance_init */
|
NULL /* instance_init */
|
||||||
};
|
};
|
||||||
static const GInterfaceInfo ibaz_info = {
|
const GInterfaceInfo ibaz_info = {
|
||||||
(GInterfaceInitFunc) baz_interface_init, /* interface_init */
|
(GInterfaceInitFunc) baz_interface_init, /* interface_init */
|
||||||
NULL, /* interface_finalize */
|
NULL, /* interface_finalize */
|
||||||
NULL /* interface_data */
|
NULL /* interface_data */
|
||||||
|
@ -877,7 +877,7 @@ maman_ibaz_get_type (void)
|
|||||||
static GType iface_type = 0;
|
static GType iface_type = 0;
|
||||||
if (iface_type == 0)
|
if (iface_type == 0)
|
||||||
{
|
{
|
||||||
static const GTypeInfo info = {
|
const GTypeInfo info = {
|
||||||
sizeof (MamanIbazInterface),
|
sizeof (MamanIbazInterface),
|
||||||
maman_ibaz_base_init, /* base_init */
|
maman_ibaz_base_init, /* base_init */
|
||||||
NULL, /* base_finalize */
|
NULL, /* base_finalize */
|
||||||
|
@ -77,7 +77,7 @@ value_free (GValue *value)
|
|||||||
void
|
void
|
||||||
_g_boxed_type_init (void)
|
_g_boxed_type_init (void)
|
||||||
{
|
{
|
||||||
static const GTypeInfo info = {
|
const GTypeInfo info = {
|
||||||
0, /* class_size */
|
0, /* class_size */
|
||||||
NULL, /* base_init */
|
NULL, /* base_init */
|
||||||
NULL, /* base_destroy */
|
NULL, /* base_destroy */
|
||||||
|
@ -88,7 +88,7 @@ _g_enum_types_init (void)
|
|||||||
"p", /* lcopy_format */
|
"p", /* lcopy_format */
|
||||||
value_flags_enum_lcopy_value, /* lcopy_value */
|
value_flags_enum_lcopy_value, /* lcopy_value */
|
||||||
};
|
};
|
||||||
static GTypeInfo info = {
|
GTypeInfo info = {
|
||||||
0, /* class_size */
|
0, /* class_size */
|
||||||
NULL, /* base_init */
|
NULL, /* base_init */
|
||||||
NULL, /* base_destroy */
|
NULL, /* base_destroy */
|
||||||
|
@ -346,7 +346,7 @@ _g_object_type_init (void)
|
|||||||
static const GTypeFundamentalInfo finfo = {
|
static const GTypeFundamentalInfo finfo = {
|
||||||
G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE,
|
G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE,
|
||||||
};
|
};
|
||||||
static GTypeInfo info = {
|
GTypeInfo info = {
|
||||||
sizeof (GObjectClass),
|
sizeof (GObjectClass),
|
||||||
(GBaseInitFunc) g_object_base_class_init,
|
(GBaseInitFunc) g_object_base_class_init,
|
||||||
(GBaseFinalizeFunc) g_object_base_class_finalize,
|
(GBaseFinalizeFunc) g_object_base_class_finalize,
|
||||||
|
@ -101,7 +101,7 @@ _g_param_type_init (void)
|
|||||||
"p", /* lcopy_format */
|
"p", /* lcopy_format */
|
||||||
value_param_lcopy_value, /* lcopy_value */
|
value_param_lcopy_value, /* lcopy_value */
|
||||||
};
|
};
|
||||||
static const GTypeInfo param_spec_info = {
|
const GTypeInfo param_spec_info = {
|
||||||
sizeof (GParamSpecClass),
|
sizeof (GParamSpecClass),
|
||||||
|
|
||||||
(GBaseInitFunc) g_param_spec_class_base_init,
|
(GBaseInitFunc) g_param_spec_class_base_init,
|
||||||
|
@ -1366,7 +1366,7 @@ gpointer g_type_class_get_private (GTypeClass *klass,
|
|||||||
* (GInstanceInitFunc) gtk_gadget_init,
|
* (GInstanceInitFunc) gtk_gadget_init,
|
||||||
* (GTypeFlags) flags);
|
* (GTypeFlags) flags);
|
||||||
* {
|
* {
|
||||||
* static const GInterfaceInfo g_implement_interface_info = {
|
* const GInterfaceInfo g_implement_interface_info = {
|
||||||
* (GInterfaceInitFunc) gtk_gadget_gizmo_init
|
* (GInterfaceInitFunc) gtk_gadget_gizmo_init
|
||||||
* };
|
* };
|
||||||
* g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info);
|
* g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info);
|
||||||
|
@ -153,7 +153,7 @@ g_type_module_get_type (void)
|
|||||||
|
|
||||||
if (!type_module_type)
|
if (!type_module_type)
|
||||||
{
|
{
|
||||||
static const GTypeInfo type_module_info = {
|
const GTypeInfo type_module_info = {
|
||||||
sizeof (GTypeModuleClass),
|
sizeof (GTypeModuleClass),
|
||||||
NULL, /* base_init */
|
NULL, /* base_init */
|
||||||
NULL, /* base_finalize */
|
NULL, /* base_finalize */
|
||||||
@ -164,7 +164,7 @@ g_type_module_get_type (void)
|
|||||||
0, /* n_preallocs */
|
0, /* n_preallocs */
|
||||||
NULL, /* instance_init */
|
NULL, /* instance_init */
|
||||||
};
|
};
|
||||||
static const GInterfaceInfo iface_info = {
|
const GInterfaceInfo iface_info = {
|
||||||
(GInterfaceInitFunc) g_type_module_iface_init,
|
(GInterfaceInitFunc) g_type_module_iface_init,
|
||||||
NULL, /* interface_finalize */
|
NULL, /* interface_finalize */
|
||||||
NULL, /* interface_data */
|
NULL, /* interface_data */
|
||||||
|
@ -95,7 +95,7 @@ g_type_plugin_get_type (void)
|
|||||||
|
|
||||||
if (!type_plugin_type)
|
if (!type_plugin_type)
|
||||||
{
|
{
|
||||||
static const GTypeInfo type_plugin_info = {
|
const GTypeInfo type_plugin_info = {
|
||||||
sizeof (GTypePluginClass),
|
sizeof (GTypePluginClass),
|
||||||
NULL, /* base_init */
|
NULL, /* base_init */
|
||||||
NULL, /* base_finalize */
|
NULL, /* base_finalize */
|
||||||
|
@ -1424,7 +1424,7 @@ g_strdup_value_contents (const GValue *value)
|
|||||||
GType
|
GType
|
||||||
g_pointer_type_register_static (const gchar *name)
|
g_pointer_type_register_static (const gchar *name)
|
||||||
{
|
{
|
||||||
static const GTypeInfo type_info = {
|
const GTypeInfo type_info = {
|
||||||
0, /* class_size */
|
0, /* class_size */
|
||||||
NULL, /* base_init */
|
NULL, /* base_init */
|
||||||
NULL, /* base_finalize */
|
NULL, /* base_finalize */
|
||||||
|
@ -47,7 +47,7 @@ test_iface_get_type (void)
|
|||||||
|
|
||||||
if (!test_iface_type)
|
if (!test_iface_type)
|
||||||
{
|
{
|
||||||
static const GTypeInfo test_iface_info =
|
const GTypeInfo test_iface_info =
|
||||||
{
|
{
|
||||||
sizeof (TestIfaceClass),
|
sizeof (TestIfaceClass),
|
||||||
(GBaseInitFunc) iface_base_init, /* base_init */
|
(GBaseInitFunc) iface_base_init, /* base_init */
|
||||||
@ -163,7 +163,7 @@ test_object_get_type (void)
|
|||||||
|
|
||||||
if (!test_object_type)
|
if (!test_object_type)
|
||||||
{
|
{
|
||||||
static const GTypeInfo test_object_info =
|
const GTypeInfo test_object_info =
|
||||||
{
|
{
|
||||||
sizeof (TestObjectClass),
|
sizeof (TestObjectClass),
|
||||||
NULL, /* base_init */
|
NULL, /* base_init */
|
||||||
@ -327,7 +327,7 @@ derived_object_get_type (void)
|
|||||||
|
|
||||||
if (!derived_object_type)
|
if (!derived_object_type)
|
||||||
{
|
{
|
||||||
static const GTypeInfo derived_object_info =
|
const GTypeInfo derived_object_info =
|
||||||
{
|
{
|
||||||
sizeof (DerivedObjectClass),
|
sizeof (DerivedObjectClass),
|
||||||
NULL, /* base_init */
|
NULL, /* base_init */
|
||||||
|
@ -117,7 +117,7 @@ test_dynamic_iface_default_finalize (TestStaticIfaceClass *iface)
|
|||||||
static void
|
static void
|
||||||
test_dynamic_iface_register (GTypeModule *module)
|
test_dynamic_iface_register (GTypeModule *module)
|
||||||
{
|
{
|
||||||
static const GTypeInfo iface_info =
|
const GTypeInfo iface_info =
|
||||||
{
|
{
|
||||||
sizeof (TestDynamicIfaceClass),
|
sizeof (TestDynamicIfaceClass),
|
||||||
(GBaseInitFunc) NULL,
|
(GBaseInitFunc) NULL,
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
/* see http://bugzilla.gnome.org/show_bug.cgi?id=337128 for the purpose of this test */
|
/* 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) { \
|
#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, \
|
(GInterfaceInitFunc) iface_init, \
|
||||||
NULL, \
|
NULL, \
|
||||||
NULL \
|
NULL \
|
||||||
|
@ -151,7 +151,7 @@ main (int argc,
|
|||||||
*/
|
*/
|
||||||
g_type_class_ref (TEST_TYPE_OBJECT4);
|
g_type_class_ref (TEST_TYPE_OBJECT4);
|
||||||
{
|
{
|
||||||
static GInterfaceInfo const iface = {
|
GInterfaceInfo const iface = {
|
||||||
NULL, NULL, NULL
|
NULL, NULL, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ struct _TestObjectClass
|
|||||||
} G_STMT_END
|
} G_STMT_END
|
||||||
|
|
||||||
#define ADD_IFACE(n) G_STMT_START { \
|
#define ADD_IFACE(n) G_STMT_START { \
|
||||||
static GInterfaceInfo iface_info = { \
|
GInterfaceInfo iface_info = { \
|
||||||
(GInterfaceInitFunc)test_object_test_iface##n##_init, \
|
(GInterfaceInitFunc)test_object_test_iface##n##_init, \
|
||||||
NULL, NULL }; \
|
NULL, NULL }; \
|
||||||
\
|
\
|
||||||
|
@ -32,7 +32,7 @@ prefix ## _get_type (void) \
|
|||||||
\
|
\
|
||||||
if (!object_type) \
|
if (!object_type) \
|
||||||
{ \
|
{ \
|
||||||
static const GTypeInfo object_info = \
|
const GTypeInfo object_info = \
|
||||||
{ \
|
{ \
|
||||||
sizeof (name ## Class), \
|
sizeof (name ## Class), \
|
||||||
(GBaseInitFunc) base_init, \
|
(GBaseInitFunc) base_init, \
|
||||||
@ -68,7 +68,7 @@ prefix ## _get_type (void) \
|
|||||||
\
|
\
|
||||||
if (!iface_type) \
|
if (!iface_type) \
|
||||||
{ \
|
{ \
|
||||||
static const GTypeInfo iface_info = \
|
const GTypeInfo iface_info = \
|
||||||
{ \
|
{ \
|
||||||
sizeof (name ## Class), \
|
sizeof (name ## Class), \
|
||||||
(GBaseInitFunc) base_init, \
|
(GBaseInitFunc) base_init, \
|
||||||
@ -85,7 +85,7 @@ prefix ## _get_type (void) \
|
|||||||
|
|
||||||
#define INTERFACE_FULL(type, init_func, iface_type) \
|
#define INTERFACE_FULL(type, init_func, iface_type) \
|
||||||
{ \
|
{ \
|
||||||
static GInterfaceInfo const iface = \
|
GInterfaceInfo const iface = \
|
||||||
{ \
|
{ \
|
||||||
(GInterfaceInitFunc) init_func, NULL, NULL \
|
(GInterfaceInitFunc) init_func, NULL, NULL \
|
||||||
}; \
|
}; \
|
||||||
|
@ -37,7 +37,7 @@ my_test_get_type (void)
|
|||||||
static GType test_type = 0;
|
static GType test_type = 0;
|
||||||
|
|
||||||
if (!test_type) {
|
if (!test_type) {
|
||||||
static const GTypeInfo test_info = {
|
const GTypeInfo test_info = {
|
||||||
sizeof (GTestClass),
|
sizeof (GTestClass),
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -36,7 +36,7 @@ my_test_get_type (void)
|
|||||||
static GType test_type = 0;
|
static GType test_type = 0;
|
||||||
|
|
||||||
if (!test_type) {
|
if (!test_type) {
|
||||||
static const GTypeInfo test_info = {
|
const GTypeInfo test_info = {
|
||||||
sizeof (GTestClass),
|
sizeof (GTestClass),
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -54,7 +54,7 @@ my_test_get_type (void)
|
|||||||
static GType test_type = 0;
|
static GType test_type = 0;
|
||||||
|
|
||||||
if (!test_type) {
|
if (!test_type) {
|
||||||
static const GTypeInfo test_info = {
|
const GTypeInfo test_info = {
|
||||||
sizeof (GTestClass),
|
sizeof (GTestClass),
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -51,7 +51,7 @@ my_test_get_type (void)
|
|||||||
static GType test_type = 0;
|
static GType test_type = 0;
|
||||||
|
|
||||||
if (!test_type) {
|
if (!test_type) {
|
||||||
static const GTypeInfo test_info = {
|
const GTypeInfo test_info = {
|
||||||
sizeof (GTestClass),
|
sizeof (GTestClass),
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -68,7 +68,7 @@ my_test_get_type (void)
|
|||||||
static GType test_type = 0;
|
static GType test_type = 0;
|
||||||
|
|
||||||
if (!test_type) {
|
if (!test_type) {
|
||||||
static const GTypeInfo test_info = {
|
const GTypeInfo test_info = {
|
||||||
sizeof (GTestClass),
|
sizeof (GTestClass),
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
Loading…
Reference in New Issue
Block a user