From 4a8757aa34ec96b8ec6c887bb9442ebf1e752b0e Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Tue, 19 Aug 2008 21:55:26 +0000 Subject: Add basic support for union, base the code much on Struct. Add a testcase. 2008-08-19 Johan Dahlin * giscanner/ast.py: * giscanner/girwriter.py: * giscanner/glibtransformer.py: * giscanner/transformer.py: * tests/scanner/Foo-expected.gir: Add basic support for union, base the code much on Struct. Add a testcase. svn path=/trunk/; revision=404 --- giscanner/girwriter.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'giscanner/girwriter.py') diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 996893e3..a5e8ffc2 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -21,7 +21,7 @@ from __future__ import with_statement from .ast import (Callback, Class, Enum, Function, Interface, Member, - Sequence, Struct, Alias) + Sequence, Struct, Alias, Union) from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember, GLibFlags, GLibObject, GLibInterface) from .xmlwriter import XMLWriter @@ -62,6 +62,8 @@ class GIRWriter(XMLWriter): self._write_callback(node) elif isinstance(node, Struct): self._write_record(node) + elif isinstance(node, Union): + self._write_union(node) elif isinstance(node, Member): # FIXME: atk_misc_instance singleton pass @@ -227,6 +229,16 @@ class GIRWriter(XMLWriter): else: self.write_tag('record', attrs) + def _write_union(self, union): + attrs = [('name', union.name), + ('c:type', union.symbol)] + if union.fields: + with self.tagcontext('union', attrs): + for field in union.fields: + self._write_field(field) + else: + self.write_tag('union', attrs) + def _write_field(self, field): # FIXME: Just function if isinstance(field, (Callback, Function)): -- cgit v1.2.1