Parse boxed types.
authorJohan Dahlin <johan@gnome.org>
Sat, 16 Aug 2008 21:32:41 +0000 (21:32 +0000)
committerJohan Dahlin <johan@src.gnome.org>
Sat, 16 Aug 2008 21:32:41 +0000 (21:32 +0000)
2008-08-16  Johan Dahlin  <johan@gnome.org>

    * giscanner/girparser.py:
    Parse boxed types.

svn path=/trunk/; revision=385

ChangeLog
giscanner/girparser.py

index 65e868b81b50dd4f4bd305e68e6a5b914b349cc5..e0fd54b97296bc8e25a37cd824b77c8ece10f945 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-08-16  Johan Dahlin  <johan@gnome.org>
+
+       * giscanner/girparser.py:
+       Parse boxed types.
+
 2008-08-16  Johan Dahlin  <johan@gnome.org>
 
        * giscanner/glibtransformer.py:
index 30ed9dba79b042243e03dd0e30711fd0c6f788a1..0cb6c0840d57a14a9e6d8b5d864e43cd37f9a549 100644 (file)
@@ -21,7 +21,7 @@
 from xml.etree.cElementTree import parse
 
 from .ast import Alias, Callback, Function, Parameter, Return, Struct, Type
-from .glibast import GLibInterface, GLibObject
+from .glibast import GLibBoxed, GLibInterface, GLibObject
 
 CORE_NS = "http://www.gtk.org/introspection/core/1.0"
 C_NS = "http://www.gtk.org/introspection/c/1.0"
@@ -84,10 +84,11 @@ class GIRParser(object):
             struct = Struct(node.attrib['name'],
                             node.attrib[_cns('type')])
             self._add_node(struct)
+        elif node.tag == _glibns('boxed'):
+            self._parse_boxed(node)
         elif node.tag in [_corens('interface'),
                           _corens('enumeration'),
                           _corens('bitfield'),
-                          _glibns('boxed'),
                           ]:
             pass
 
@@ -134,3 +135,16 @@ class GIRParser(object):
             raise ValueError("failed to find type")
         return Type(typenode.attrib['name'],
                     typenode.attrib[_cns('type')])
+
+    def _parse_boxed(self, node):
+        obj = GLibBoxed(node.attrib[_glibns('name')],
+                        node.attrib[_glibns('type-name')],
+                        node.attrib[_glibns('get-type')])
+        for method in node.findall(_corens('method')):
+            obj.methods.append(self._parse_function(method, Function))
+        for ctor in node.findall(_corens('constructor')):
+            obj.constructors.append(self._parse_function(ctor, Function))
+        for callback in node.findall(_corens('callback')):
+            obj.fields.append(self._parse_function(callback, Callback))
+        self._add_node(obj)
+