changeset 26401:b4621f3c276e

Add G_DEFINE_TYPE compatibility define from gobjectification branch.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Wed, 01 Apr 2009 23:43:38 +0000
parents 84d09c6499f1
children 081a819bc710
files libpurple/internal.h
diffstat 1 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/internal.h	Wed Apr 01 19:01:31 2009 +0000
+++ b/libpurple/internal.h	Wed Apr 01 23:43:38 2009 +0000
@@ -222,6 +222,41 @@
 #	endif
 #endif
 
+#include <glib.h>
+#include <glib-object.h>
+
+#ifndef G_DEFINE_TYPE
+#define G_DEFINE_TYPE(TypeName, type_name, TYPE_PARENT) \
+\
+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 GType g_define_type_id = 0; \
+  if (G_UNLIKELY (g_define_type_id == 0)) \
+    { \
+      g_define_type_id = \
+        g_type_register_static_simple (TYPE_PARENT, \
+                                       g_intern_static_string (#TypeName), \
+                                       sizeof (TypeName##Class), \
+                                       (GClassInitFunc)type_name##_class_intern_init, \
+                                       sizeof (TypeName), \
+                                       (GInstanceInitFunc)type_name##_init, \
+                                       (GTypeFlags) 0); \
+    }					\
+  return g_define_type_id;		\
+} /* closes type_name##_get_type() */
+
+#endif
+
 /* Safer ways to work with static buffers. When using non-static
  * buffers, either use g_strdup_* functions (preferred) or use
  * g_strlcpy/g_strlcpy directly. */