summaryrefslogtreecommitdiff
path: root/giscanner/maintransformer.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/maintransformer.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/maintransformer.py')
-rw-r--r--giscanner/maintransformer.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index d0eae900..08783131 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -130,6 +130,20 @@ class MainTransformer(object):
return param.argname
+ def _get_validate_field_name(self, parent, field_name, origin):
+ try:
+ field = parent.get_field(field_name)
+ except ValueError:
+ field = None
+ if field is None:
+ origin_name = 'field %s' % (origin.name, )
+ message.log_node(
+ message.FATAL, parent,
+ "can't find field %s referenced by %s of %r"
+ % (field_name, origin_name, parent.name))
+
+ return field.name
+
def _apply_annotation_rename_to(self, node, chain, block):
if not block:
return
@@ -375,13 +389,17 @@ class MainTransformer(object):
length = array_options.get(OPT_ARRAY_LENGTH)
if length:
- paramname = self._get_validate_parameter_name(parent, length, node)
+ if isinstance(parent, ast.Compound):
+ paramname = self._get_validate_field_name(parent, length, node)
+ else:
+ paramname = self._get_validate_parameter_name(parent, length, node)
+ if paramname:
+ param = parent.get_parameter(paramname)
+ param.direction = node.direction
+ if param.direction == ast.PARAM_DIRECTION_OUT:
+ param.transfer = ast.PARAM_TRANSFER_FULL
if paramname:
- param = parent.get_parameter(paramname)
- param.direction = node.direction
- if param.direction == ast.PARAM_DIRECTION_OUT:
- param.transfer = ast.PARAM_TRANSFER_FULL
- container_type.length_param_name = param.argname
+ container_type.length_param_name = paramname
fixed = array_options.get(OPT_ARRAY_FIXED_SIZE)
if fixed:
try:
@@ -728,8 +746,8 @@ class MainTransformer(object):
try:
self._adjust_container_type(parent, field, tag.annotations)
- except AttributeError:
- pass
+ except AttributeError, ex:
+ print ex
def _apply_annotations_property(self, parent, prop):
prefix = self._get_annotation_name(parent)