diff options
author | Colin Walters <walters@src.gnome.org> | 2008-09-06 20:33:51 +0000 |
---|---|---|
committer | Colin Walters <walters@src.gnome.org> | 2008-09-06 20:33:51 +0000 |
commit | e28078c70cbf4a57c7dbd39626f43f9bd2674145 (patch) | |
tree | 1ab870b5a41cbc3e3a8a70f62b83f6e419049737 /giscanner/girparser.py | |
parent | c5eb6a47cedf58210b4d3d73baced9a253e8ae51 (diff) | |
download | gobject-introspection-e28078c70cbf4a57c7dbd39626f43f9bd2674145.tar.gz |
Allow both union and struct to be boxed or not
* girepository/girnode.c: Allow gtype_name
and gtype_init in struct and union.
* girepository/girparser.c: Parse glib:
boxed bits for both structure and union.
* girepository/gtypelib.c: Don't barf
if structure is boxed.
* giscanner/girparser.py: Parse new XML
format.
* giscanner/girwriter.py: Write out new
XML format.
* giscanner/glibast.py: Define new classes
which are both Boxed and Struct/Union, as
well as an "Other" for everything else.
* giscanner/glibtransformer.py: Handle
boxed types specially; we try to merge
them with a struct/union if one exists,
otherwise fall back to generic boxed.
* tests/*: Update.
* tools/generate.c: Write out new format.
svn path=/trunk/; revision=575
Diffstat (limited to 'giscanner/girparser.py')
-rw-r--r-- | giscanner/girparser.py | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/giscanner/girparser.py b/giscanner/girparser.py index 5c2f121a..e344fb42 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -20,9 +20,11 @@ from xml.etree.cElementTree import parse -from .ast import Alias, Callback, Function, Parameter, Return, Struct, Type -from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember, GLibFlags, - GLibInterface, GLibObject) +from .ast import (Alias, Callback, Function, Parameter, Return, Union, + Struct, Type) +from .glibast import (GLibEnum, GLibEnumMember, GLibFlags, + GLibInterface, GLibObject, GLibBoxedStruct, + GLibBoxedUnion, GLibBoxedOther) CORE_NS = "http://www.gtk.org/introspection/core/1.0" C_NS = "http://www.gtk.org/introspection/c/1.0" @@ -90,6 +92,8 @@ class GIRParser(object): self._parse_object_interface(node) elif node.tag == _corens('record'): self._parse_struct(node) + elif node.tag == _corens('union'): + self._parse_union(node) elif node.tag == _glibns('boxed'): self._parse_boxed(node) elif node.tag in [_corens('enumeration'), @@ -137,8 +141,23 @@ class GIRParser(object): return klass(name, retval, parameters, identifier) def _parse_struct(self, node): - struct = Struct(node.attrib['name'], - node.attrib[_cns('type')]) + if _glibns('type-name') in node.attrib: + struct = GLibBoxedStruct(node.attrib['name'], + node.attrib[_glibns('type-name')], + node.attrib[_glibns('get-type')]) + else: + struct = Struct(node.attrib['name'], + node.attrib[_cns('type')]) + self._add_node(struct) + + def _parse_union(self, node): + if _glibns('type-name') in node.attrib: + struct = GLibBoxedUnion(node.attrib['name'], + node.attrib[_glibns('type-name')], + node.attrib[_glibns('get-type')]) + else: + struct = Union(node.attrib['name'], + node.attrib[_cns('type')]) self._add_node(struct) def _parse_type(self, node): @@ -149,10 +168,9 @@ class GIRParser(object): 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')], - node.attrib.get(_cns('type'))) + obj = GLibBoxedOther(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')): |