diff options
author | Dieter Verfaillie <dieterv@optionexplicit.be> | 2014-12-08 20:11:44 +0100 |
---|---|---|
committer | Dieter Verfaillie <dieterv@optionexplicit.be> | 2015-03-04 21:00:29 +0100 |
commit | 5a137d0b1a14f5bab6a09cbec8471557679d72f8 (patch) | |
tree | a3b976872ef80aeaf5ee4735f18194fa3eab8381 /giscanner/girparser.py | |
parent | 81aeb715f3d6d899ac310dbbb37d0c0fb15be436 (diff) | |
download | gobject-introspection-5a137d0b1a14f5bab6a09cbec8471557679d72f8.tar.gz |
giscanner: enable the --reparse-validate option for our test suite
Doing so reveals GIRParser did not yet support:
- the (skip) annotation on parameters and return values
- the (attributes) annotation
This patch fixes both issues an prevents further similar problems.
https://bugzilla.gnome.org/show_bug.cgi?id=738171
Diffstat (limited to 'giscanner/girparser.py')
-rw-r--r-- | giscanner/girparser.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/giscanner/girparser.py b/giscanner/girparser.py index 40bc49e0..d258069a 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -24,6 +24,7 @@ from xml.etree.cElementTree import parse from . import ast from .girwriter import COMPATIBLE_GIR_VERSION +from .collections import OrderedDict CORE_NS = "http://www.gtk.org/introspection/core/1.0" C_NS = "http://www.gtk.org/introspection/c/1.0" @@ -165,9 +166,18 @@ class GIRParser(object): def _parse_generic_attribs(self, node, obj): assert isinstance(obj, ast.Annotated) + skip = node.attrib.get('skip') + if skip: + try: + obj.skip = int(skip) > 0 + except ValueError: + obj.skip = False introspectable = node.attrib.get('introspectable') if introspectable: - obj.introspectable = int(introspectable) > 0 + try: + obj.introspectable = int(introspectable) > 0 + except ValueError: + obj.introspectable = False if self._types_only: return doc = node.find(_corens('doc')) @@ -195,6 +205,14 @@ class GIRParser(object): if stability_doc is not None: if stability_doc.text: obj.stability_doc = stability_doc.text + attributes = node.findall(_corens('attribute')) + if attributes: + attributes_ = OrderedDict() + for attribute in attributes: + name = attribute.attrib.get('name') + value = attribute.attrib.get('value') + attributes_[name] = value + obj.attributes = attributes_ def _parse_object_interface(self, node): parent = node.attrib.get('parent') |