summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Yuan <li.yuan@sun.com>2008-01-04 06:32:25 +0000
committerLi Yuan <liyuan@src.gnome.org>2008-01-04 06:32:25 +0000
commit4bae9088c162bee458a7ff738dee4a5f785d70a4 (patch)
treef872ce0e39cf1ef5b13208c77532480484ad915a
parent0ec654f4096c1e4d1b27ce2e68a882175c713974 (diff)
downloadatk-4bae9088c162bee458a7ff738dee4a5f785d70a4.tar.gz
Bug #502840. Derived type definition convenience macros Bug #500978. Fixes
2008-01-04 Li Yuan <li.yuan@sun.com> * atk/atkutil.h: Bug #502840. Derived type definition convenience macros * tests/Makefile.am: Bug #500978. Fixes the building of the test modules as dynamic on Cygwin and MinGW. svn path=/trunk/; revision=1217
-rw-r--r--ChangeLog8
-rwxr-xr-xatk/atkutil.h68
-rw-r--r--tests/Makefile.am7
3 files changed, 83 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index dbb8acb..342eded 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-01-04 Li Yuan <li.yuan@sun.com>
+
+ * atk/atkutil.h:
+ Bug #502840. Derived type definition convenience macros
+ * tests/Makefile.am:
+ Bug #500978. Fixes the building of the test modules
+ as dynamic on Cygwin and MinGW.
+
2007-09-24 Li Yuan <li.yuan@sun.com>
* atk/atkhyperlink.c: (atk_hyperlink_class_init):
diff --git a/atk/atkutil.h b/atk/atkutil.h
index d373b0f..e96eb64 100755
--- a/atk/atkutil.h
+++ b/atk/atkutil.h
@@ -239,6 +239,74 @@ G_CONST_RETURN gchar *atk_get_toolkit_version (void);
*/
G_CONST_RETURN gchar *atk_get_version (void);
+/* --- GType boilerplate --- */
+/* convenience macros for atk type implementations, which for a type GtkGadgetAccessible will:
+ * - prototype: static void gtk_gadget_accessible_class_init (GtkGadgetClass *klass);
+ * - prototype: static void gtk_gadget_accessible_init (GtkGadget *self);
+ * - define: static gpointer gtk_gadget_accessible_parent_class = NULL;
+ * gtk_gadget_accessible_parent_class is initialized prior to calling gtk_gadget_class_init()
+ * - implement: GType gtk_gadget_accessible_get_type (void) { ... }
+ * - support custom code in gtk_gadget_accessible_get_type() after the type is registered.
+ *
+ * macro arguments: TypeName, type_name, TYPE_PARENT, CODE
+ * example: ATK_DEFINE_TYPE_WITH_CODE (GtkGadgetAccessible, gtk_gadget_accessible, GTK_TYPE_GADGET,
+ * G_IMPLEMENT_INTERFACE (ATK_TYPE_TABLE, gtk_gadget_accessible_table_iface_init))
+ */
+
+#define ATK_DEFINE_TYPE(TN, t_n, T_P) ATK_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
+#define ATK_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _ATK_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _ATK_DEFINE_TYPE_EXTENDED_END()
+#define ATK_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P) ATK_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {})
+#define ATK_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _ATK_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT) {_C_;} _ATK_DEFINE_TYPE_EXTENDED_END()
+#define ATK_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_) _ATK_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, _f_) {_C_;} _ATK_DEFINE_TYPE_EXTENDED_END()
+
+#define _ATK_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE, flags) \
+\
+static void type_name##_init (TypeName *self); \
+static void type_name##_class_init (TypeName##Class *klass); \
+static gpointer type_name##_parent_class = NULL; \
+static void type_name##_class_intern_init (gpointer klass) \
+{ \
+ type_name##_parent_class = g_type_class_peek_parent (klass); \
+ type_name##_class_init ((TypeName##Class*) klass); \
+} \
+\
+GType \
+type_name##_get_type (void) \
+{ \
+ static volatile gsize g_define_type_id__volatile = 0; \
+ if (g_once_init_enter (&g_define_type_id__volatile)) \
+ { \
+ AtkObjectFactory *factory; \
+ GType derived_type; \
+ GTypeQuery query; \
+ GType derived_atk_type; \
+ GType g_define_type_id; \
+\
+ /* Figure out the size of the class and instance we are deriving from */ \
+ derived_type = g_type_parent (TYPE); \
+ factory = atk_registry_get_factory (atk_get_default_registry (), \
+ derived_type); \
+ derived_atk_type = atk_object_factory_get_accessible_type (factory); \
+ g_type_query (derived_atk_type, &query); \
+\
+ g_define_type_id = \
+ g_type_register_static_simple (derived_atk_type, \
+ g_intern_static_string (#TypeName), \
+ query.class_size, \
+ (GClassInitFunc) type_name##_class_intern_init, \
+ query.instance_size, \
+ (GInstanceInitFunc) type_name##_init, \
+ (GTypeFlags) flags); \
+ { /* custom code follows */
+#define _ATK_DEFINE_TYPE_EXTENDED_END() \
+ /* following custom code */ \
+ } \
+ g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
+ } \
+ return g_define_type_id__volatile; \
+} /* closes type_name##_get_type() */
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e87b07e..7758530 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,8 @@
+if PLATFORM_WIN32
+no_undefined = -no-undefined
+else
+no_undefined =
+endif
noinst_LTLIBRARIES = \
libteststateset.la \
@@ -16,6 +21,7 @@ moduledir = $(libdir)/gtk-2.0/modules
libteststateset_la_SOURCES = teststateset.c
libteststateset_la_LDFLAGS = \
-rpath $(moduledir) \
+ $(no_undefined) \
-avoid-version \
-module
libteststateset_la_LIBADD = $(libatk) $(DEP_LIBS)
@@ -23,6 +29,7 @@ libteststateset_la_LIBADD = $(libatk) $(DEP_LIBS)
libtestrelation_la_SOURCES = testrelation.c
libtestrelation_la_LDFLAGS = \
-rpath $(moduledir) \
+ $(no_undefined) \
-avoid-version \
-module
libtestrelation_la_LIBADD = $(libatk) $(DEP_LIBS)