summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2014-12-08 20:11:44 +0100
committerDieter Verfaillie <dieterv@optionexplicit.be>2015-03-04 21:00:29 +0100
commit5a137d0b1a14f5bab6a09cbec8471557679d72f8 (patch)
treea3b976872ef80aeaf5ee4735f18194fa3eab8381
parent81aeb715f3d6d899ac310dbbb37d0c0fb15be436 (diff)
downloadgobject-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
-rw-r--r--giscanner/girparser.py20
-rw-r--r--tests/scanner/Makefile.am2
2 files changed, 20 insertions, 2 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')
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am
index 92ab12a3..c7a1b32c 100644
--- a/tests/scanner/Makefile.am
+++ b/tests/scanner/Makefile.am
@@ -5,7 +5,7 @@ include $(top_srcdir)/Makefile.introspection
SUBDIRS = . annotationparser
-INTROSPECTION_SCANNER_ARGS += --warn-all
+INTROSPECTION_SCANNER_ARGS += --warn-all --reparse-validate
CLEANFILES =