[gjs] [value] Add workaround to avoid glib 2.22 dep



commit 9d9457f03130baba6037d1ba9497c2e40f3453fa
Author: Johan Dahlin <johan gnome org>
Date:   Tue Jun 22 15:11:03 2010 -0300

    [value] Add workaround to avoid glib 2.22 dep
    
    Use type names instead of types to avoid a glib 2.22 dependency

 gi/value.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gi/value.c b/gi/value.c
index 674f1b1..0d84593 100644
--- a/gi/value.c
+++ b/gi/value.c
@@ -36,6 +36,9 @@
 
 #include <girepository.h>
 
+static GType _byte_array_type = G_TYPE_INVALID;
+static GType _ptr_array_type = G_TYPE_INVALID;
+
 static JSBool gjs_value_from_g_value_internal(JSContext    *context,
                                               jsval        *value_p,
                                               const GValue *gvalue,
@@ -575,8 +578,8 @@ gjs_value_from_g_value_internal(JSContext    *context,
         }
     } else if (g_type_is_a(gtype, G_TYPE_HASH_TABLE) ||
                g_type_is_a(gtype, G_TYPE_ARRAY) ||
-               g_type_is_a(gtype, G_TYPE_BYTE_ARRAY) ||
-               g_type_is_a(gtype, G_TYPE_PTR_ARRAY)) {
+               g_type_is_a(gtype, _byte_array_type) ||
+               g_type_is_a(gtype, _ptr_array_type)) {
         gjs_throw(context,
                   "Unable to introspect element-type of container in GValue");
         return JS_FALSE;
@@ -673,3 +676,10 @@ gjs_value_from_g_value(JSContext    *context,
 {
     return gjs_value_from_g_value_internal(context, value_p, gvalue, FALSE);
 }
+
+__attribute__((constructor)) void
+_gjs_value_init_types(void)
+{
+    _byte_array_type = g_type_from_name("GByteArray");
+    _ptr_array_type = g_type_from_name("GPtrArray");
+}



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