summaryrefslogtreecommitdiff
path: root/giscanner/ast.py
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2013-10-20 20:47:13 +0200
committerStef Walter <stefw@gnome.org>2013-10-28 20:54:27 +0100
commit2a569cb68ca4e4ce08ff66fc20a79bc57222c2e2 (patch)
tree49af0867f76eb5f916f417f19cd54f864dd252aa /giscanner/ast.py
parentf7acdd34e28456d706a38e51b8332569d7a0f271 (diff)
downloadgobject-introspection-2a569cb68ca4e4ce08ff66fc20a79bc57222c2e2.tar.gz
giscanner: Correctly consume field annotations on structs
A hidden exception was being thrown (which we now log), due to fields being treated as function parameters. Fixed to make field array annotations be transformed and written out to the gir correctly. https://bugzilla.gnome.org/show_bug.cgi?id=710561
Diffstat (limited to 'giscanner/ast.py')
-rw-r--r--giscanner/ast.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py
index a30a6a72..bd536c63 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -888,6 +888,18 @@ class Compound(Node, Registered):
if field.anonymous_node is not None:
field.anonymous_node.walk(callback, chain)
+ def get_field(self, name):
+ for field in self.fields:
+ if field.name == name:
+ return field
+ raise ValueError("Unknown field %s" % (name, ))
+
+ def get_field_index(self, name):
+ for i, field in enumerate(self.fields):
+ if field.name == name:
+ return i
+ raise ValueError("Unknown field %s" % (name, ))
+
class Field(Annotated):