Re: PATCH: G_DEFINE_INTERFACE_TYPE macro
- From: Tiago Cogumbreiro <cogumbreiro linus uac pt>
- To: Gtk+ Devel <gtk-devel-list gnome org>
- Cc: timj gtk org
- Subject: Re: PATCH: G_DEFINE_INTERFACE_TYPE macro
- Date: Wed, 25 Aug 2004 16:07:48 +0000
Added _WITH_CODE variants, pointed out by rambokid
On Wed, 2004-08-25 at 15:58, Tiago Cogumbreiro wrote:
> I've added support for class_init in the macro (pointed out by Owen).
> On Wed, 2004-08-25 at 15:42, Tiago Cogumbreiro wrote:
> > After some suggestions on #gtk+ I've made some changes to the macro
> > definition, hope it's better now :)
> >
> > On Wed, 2004-08-25 at 15:26, Tiago Cogumbreiro wrote:
> > > I've implemented a macro that i find it to be missing to the
> > > G_DEFINE_*_TYPE: G_DEFINE_INTERFACE_TYPE
> > >
> > > As the name infers it's supposed to define the get_type function which
> > > defines an interface.
> > >
> > >
> > > ______________________________________________________________________
> > > _______________________________________________
> > > gtk-devel-list mailing list
> > > gtk-devel-list gnome org
> > > http://mail.gnome.org/mailman/listinfo/gtk-devel-list
> >
> > ______________________________________________________________________
> > _______________________________________________
> > gtk-devel-list mailing list
> > gtk-devel-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtk-devel-list
>
> ______________________________________________________________________
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
--- /home/tiago/Downloads/gtype.h 2004-08-25 14:49:54.201027072 +0000
+++ gtype.h 2004-08-25 16:05:33.111007872 +0000
@@ -344,6 +344,30 @@ gpointer g_type_instance_get_private
}; \
g_type_add_interface_static (g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \
}
+/*
+ * Convenience macro to ease the interface definition. Works like G_DEFINE_TYPE.
+ */
+#define G_DEFINE_INTERFACE_TYPE(TN,t_n) G_DEFINE_INTERFACE_TYPE_WITH_CODE (TN, t_n, {})
+#define G_DEFINE_INTERFACE_TYPE_WITH_CODE(TypeName, type_name, CODE) \
+static void type_name##_class_init (TypeName##Class *klass); \
+\
+GType \
+type_name##_get_type (void) \
+{ \
+ static GType g_define_type_id = 0; \
+ if (G_UNLIKELY (g_define_type_id == 0)) \
+ { \
+ static const GTypeInfo g_define_type_info = { \
+ sizeof (TypeName##Class), \
+ (GBaseInitFunc) NULL, \
+ (GBaseFinalizeFunc) NULL, \
+ (GClassInitFunc) type_name##_class_init, \
+ }; \
+ g_define_type_id = g_type_register_static (G_TYPE_INTERFACE, #TypeName, &g_define_type_info, 0); \
+ } \
+ { CODE ;} \
+ return g_define_type_id; \
+}
#define G_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE) \
\
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]