Register GInitiallyUnowned
authorJohan Dahlin <johan@gnome.org>
Wed, 13 Aug 2008 21:25:15 +0000 (21:25 +0000)
committerJohan Dahlin <johan@src.gnome.org>
Wed, 13 Aug 2008 21:25:15 +0000 (21:25 +0000)
2008-08-13  Johan Dahlin  <johan@gnome.org>

    * giscanner/cgobject.py:
    Register GInitiallyUnowned
    * giscanner/girwriter.py:
    * giscanner/glibtransformer.py:
    Special case GObject/GInitially owned as they are a bit special to use.

svn path=/trunk/; revision=360

ChangeLog
giscanner/cgobject.py
giscanner/girwriter.py
giscanner/glibtransformer.py

index 01a07aa..a1a4638 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-08-13  Johan Dahlin  <johan@gnome.org>
+
+       * giscanner/cgobject.py:
+       Register GInitiallyUnowned
+       * giscanner/girwriter.py:
+       * giscanner/glibtransformer.py:
+       Special case GObject/GInitially owned as they are a bit special to use.
+
 2008-08-13  Colin Walters  <walters@verbum.org>
 
        * tests/scanner/Foo-expected.gir, tests/scanner/utility-expected.gir:
index 0805553..e591964 100644 (file)
@@ -145,6 +145,7 @@ _gobj.g_type_init()
 # which happens when trying to introspect an interface before instantiating
 # a GObject.
 _gobj.g_object_new(TYPE_OBJECT, None)
+_gobj.g_initially_unowned_get_type()
 
 # Functions
 
index 427c04f..54f169f 100644 (file)
@@ -175,7 +175,8 @@ class GIRWriter(XMLWriter):
             tag_name = 'interface'
         if isinstance(node, (GLibObject, GLibInterface)):
             attrs.append(('glib:type-name', node.type_name))
-            attrs.append(('glib:get-type', node.get_type))
+            if node.get_type:
+                attrs.append(('glib:get-type', node.get_type))
         with self.tagcontext(tag_name, attrs):
             if isinstance(node, Class):
                 for method in node.constructors:
index 9c00c71..0e45a0c 100644 (file)
@@ -250,6 +250,11 @@ class GLibTransformer(object):
         return True
 
     def _parse_struct(self, struct):
+        # This is a hack, but GObject is a rather fundamental piece so.
+        if (self._namespace_name == 'GObject' and
+            struct.name in ["Object", 'InitiallyUnowned']):
+            self._create_gobject(struct)
+            return
         node = self._output_ns.get(struct.name)
         if node is None:
             self._add_attribute(struct, replace=True)
@@ -314,6 +319,22 @@ class GLibTransformer(object):
         self._add_attribute(node, replace=True)
         self._register_internal_type(type_name, node)
 
+    def _create_gobject(self, node):
+        type_name = 'G' + node.name
+        if type_name == 'GObject':
+            parent_type_name = None
+        else:
+            print 'lookup', type_name
+            type_id = cgobject.type_from_name(type_name)
+            parent_type_name = cgobject.type_name(cgobject.type_parent(type_id))
+            print parent_type_name
+        node = GLibObject(node.name, parent_type_name, type_name, None)
+        type_id = cgobject.TYPE_OBJECT
+        self._introspect_properties(node, type_id)
+        self._introspect_signals(node, type_id)
+        self._add_attribute(node)
+        self._register_internal_type(type_name, node)
+
     def _introspect_object(self, type_id, symbol):
         type_name = cgobject.type_name(type_id)
         parent_type_name = cgobject.type_name(cgobject.type_parent(type_id))