Add a workaround for a glib bug interface introspection bug
authorJohan Dahlin <johan@gnome.org>
Mon, 21 Apr 2008 21:01:50 +0000 (21:01 +0000)
committerJohan Dahlin <johan@src.gnome.org>
Mon, 21 Apr 2008 21:01:50 +0000 (21:01 +0000)
2008-04-21  Johan Dahlin  <johan@gnome.org>

* giscanner/cgobject.py:
Add a workaround for a glib bug interface introspection bug
(object_interface_list_properties, object_class_list_properties):
Cast the return value to GParamSpec.

svn path=/trunk/; revision=204

ChangeLog
giscanner/cgobject.py

index 97392376ef151fbe15c783ea1fdb2907001e031d..3f1b90eb4dcf205f4cc3ce4721986b6d58da2861 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2008-04-21  Johan Dahlin  <johan@gnome.org>
 
+       * giscanner/cgobject.py:
+       Add a workaround for a glib bug interface introspection bug
+       (object_interface_list_properties, object_class_list_properties):
+       Cast the return value to GParamSpec.
+
        * tests/parser/Foo-expected.gidl: Update
        * tests/parser/foo.c: Add a string property
 
index 9dfd560b2fc8ba5fa8e7a3274a92cb942bd7d82b..106e46df5e427122c2a6b7a6b4f2421f5f9ad68d 100644 (file)
@@ -13,6 +13,7 @@ import ctypes
 
 # Constants
 
+# FIXME: Are these stable?
 TYPE_INVALID = 0
 TYPE_INTERFACE = 8
 TYPE_ENUM = 48
@@ -88,6 +89,12 @@ class GParamSpec(ctypes.Structure):
 _gobj = ctypes.cdll.LoadLibrary('libgobject-2.0.so')
 _gobj.g_type_init()
 
+# Workaround this error:
+#   GLib-GObject-CRITICAL **: g_param_spec_pool_list:
+#   assertion `pool != NULL' failed
+# which happens when trying to introspect an interface before instantiating
+# a GObject.
+_gobj.g_object_new(TYPE_OBJECT, None)
 
 # Functions
 
@@ -126,7 +133,7 @@ def object_class_list_properties(type_id):
     n = ctypes.c_uint()
     pspecs = _gobj.g_object_class_list_properties(klass, ctypes.byref(n))
     for i in range(n.value):
-        yield pspecs[i]
+        yield ctypes.cast(pspecs[i], ctypes.POINTER(GParamSpec)).contents
 
 _gobj.g_object_interface_list_properties.restype = ctypes.POINTER(
     ctypes.POINTER(GParamSpec))
@@ -135,7 +142,7 @@ def object_interface_list_properties(type_id):
     n = ctypes.c_uint()
     pspecs = _gobj.g_object_interface_list_properties(iface, ctypes.byref(n))
     for i in range(n.value):
-        yield pspecs[i]
+        yield ctypes.cast(pspecs[i], ctypes.POINTER(GParamSpec)).contents
 
 _gobj.g_type_interfaces.restype = ctypes.POINTER(ctypes.c_int)
 def type_interfaces(type_id):