[glib] Ensure that MAX_ALLOWED keeps working with the type macros



commit a4c352cd99738095ba34e04a86a2ffa9cc659cfe
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Jun 27 15:15:40 2013 +0100

    Ensure that MAX_ALLOWED keeps working with the type macros
    
    When using the GLIB_VERSION_MAX_ALLOWED macro to define the upper bound
    of allowed API the G_DEFINE_TYPE_EXTENDED starts warning about the newly
    added g_type_class_adjust_private_offset() function; this effectively
    introduces a run-time dependency on GLib 2.38 even if we don't use its
    API explicitly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=703191

 gobject/gtype.h |   32 +++++++++++++++++++++++++-------
 1 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/gobject/gtype.h b/gobject/gtype.h
index 76c79c0..b0a4fba 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1636,19 +1636,37 @@ guint     g_type_get_type_registration_serial (void);
 #define G_PRIVATE_FIELD(TypeName, inst, field_type, field_name) \
   G_STRUCT_MEMBER (field_type, inst, G_PRIVATE_OFFSET (TypeName, field_name))
 
-#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); \
-static gpointer type_name##_parent_class = NULL; \
-static gint     TypeName##_private_offset; \
+/* we need to have this macro under conditional expansion, as it references
+ * a function that has been added in 2.38. see bug:
+ * https://bugzilla.gnome.org/show_bug.cgi?id=703191
+ */
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+#define _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \
 static void     type_name##_class_intern_init (gpointer klass) \
 { \
   type_name##_parent_class = g_type_class_peek_parent (klass); \
   if (TypeName##_private_offset != 0) \
     g_type_class_adjust_private_offset (klass, &TypeName##_private_offset); \
   type_name##_class_init ((TypeName##Class*) klass); \
-} \
+}
+
+#else
+#define _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \
+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); \
+}
+#endif /* GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 */
+
+#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); \
+static gpointer type_name##_parent_class = NULL; \
+static gint     TypeName##_private_offset; \
+\
+_G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \
 \
 static inline gpointer \
 type_name##_get_instance_private (TypeName *self) \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]