split up G_DEFINE_*TYPE macro definitions so C CODE arguments are not

Tue May  2 14:51:03 2006  Tim Janik  <timj@gtk.org>

        * gtype.h: split up G_DEFINE_*TYPE macro definitions so C CODE arguments
        are not passed on to nested macro calls. patch mostly courtesy of Behdad
        Esfahbod, fixes #337128.
This commit is contained in:
Tim Janik 2006-05-02 13:00:52 +00:00 committed by Tim Janik
parent 34ee852317
commit f2649abe84
2 changed files with 19 additions and 9 deletions

View File

@ -1,3 +1,9 @@
Tue May 2 14:51:03 2006 Tim Janik <timj@gtk.org>
* gtype.h: split up G_DEFINE_*TYPE macro definitions so C CODE arguments
are not passed on to nested macro calls. patch mostly courtesy of Behdad
Esfahbod, fixes #337128.
2006-04-23 Matthias Clasen <mclasen@redhat.com>
* gobject.symbols: Fix a typo.

View File

@ -333,10 +333,11 @@ gpointer g_type_instance_get_private (GTypeInstance *instance,
* example: G_DEFINE_TYPE_WITH_CODE (GtkGadget, gtk_gadget, GTK_TYPE_WIDGET,
* g_print ("GtkGadget-id: %lu\n", g_define_type_id));
*/
#define G_DEFINE_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
#define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, _C_)
#define G_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {})
#define G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, _C_)
#define G_DEFINE_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
#define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
#define G_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {})
#define G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
#define G_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, _f_) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
/* convenience macro to ease interface addition in the CODE
* section of G_DEFINE_TYPE_WITH_CODE() (this macro relies on
@ -353,7 +354,7 @@ gpointer g_type_instance_get_private (GTypeInstance *instance,
g_type_add_interface_static (g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \
}
#define G_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE) \
#define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
\
static void type_name##_init (TypeName *self); \
static void type_name##_class_init (TypeName##Class *klass); \
@ -378,10 +379,13 @@ type_name##_get_type (void) \
sizeof (TypeName), \
(GInstanceInitFunc)type_name##_init, \
(GTypeFlags) flags); \
{ CODE ; } \
} \
return g_define_type_id; \
}
{ /* custom code follows */
#define _G_DEFINE_TYPE_EXTENDED_END() \
/* following custom code */ \
} \
} \
return g_define_type_id; \
} /* closes type_name##_get_type() */
/* --- protected (for fundamental type implementations) --- */