[gobject-introspection/wip/transformer] Parse records and unions as anonymous nodes
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/wip/transformer] Parse records and unions as anonymous nodes
- Date: Fri, 23 Jul 2010 10:35:53 +0000 (UTC)
commit e2032c6818b7d468270b8733d6aabfb026c1193d
Author: Colin Walters <walters verbum org>
Date: Thu Jul 22 20:35:26 2010 -0400
Parse records and unions as anonymous nodes
giscanner/annotationparser.py | 4 ++--
giscanner/girparser.py | 18 +++++++++++++-----
giscanner/girwriter.py | 4 ++++
3 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 0e98556..0a460ac 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -550,8 +550,8 @@ class AnnotationApplier(object):
self._parse_callable(vfunc, block)
def _parse_field(self, parent, field, block=None):
- if isinstance(field, Callback):
- self._parse_callback(field)
+ if field.anonymous_node and isinstance(field.anonymous_node, Callback):
+ self._parse_callback(field.anonymous_node)
else:
if not block:
return
diff --git a/giscanner/girparser.py b/giscanner/girparser.py
index d969c5b..67ab800 100644
--- a/giscanner/girparser.py
+++ b/giscanner/girparser.py
@@ -434,12 +434,20 @@ class GIRParser(object):
self._parse_function_common(callback, Callback))
def _parse_field(self, node):
- callback_node = self._find_first_child(node, _corens('callback'))
- if callback_node:
- anonymous_node = self._parse_function_common(callback_node, Callback)
- type_node = None
+ anonymous_node = None
+ type_node = None
+ for name in ('callback', 'record', 'union'):
+ anonymous_elt = self._find_first_child(node, _corens(name))
+ if anonymous_elt:
+ break
+ if anonymous_elt:
+ if anonymous_elt.tag == 'callback':
+ anonymous_node = self._parse_function_common(anonymous_elt, Callback)
+ elif anonymous_elt.tag == 'record':
+ anonymous_node = self._parse_record(anonymous_elt)
+ elif anonymous_elt.tag == 'union':
+ anonymous_node = self._parse_union(anonymous_elt)
else:
- anonymous_node = None
type_node = self._parse_type(node)
field = Field(node.attrib['name'],
type_node,
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 09d27bd..e547f2a 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -494,6 +494,10 @@ and/or use gtk-doc annotations. ''')
self._write_generic(field)
if isinstance(field.anonymous_node, Callback):
self._write_callback(field.anonymous_node)
+ elif isinstance(field.anonymous_node, Record):
+ self._write_record(field.anonymous_node)
+ elif isinstance(field.anonymous_node, Union):
+ self._write_union(field.anonymous_node)
else:
raise AssertionError("Unknown field anonymous: %r" \
% (field.anonymous_node, ))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]