summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2011-06-01 16:59:17 +0200
committerColin Walters <walters@verbum.org>2011-06-04 15:15:12 -0400
commit3e0292cd66752489d5b05bed57abffec0315b3ae (patch)
tree3b0c9e2cb1f8dde640e0525b2f6ad588000fe9c3 /giscanner
parent7c93dc9534a4de5599f574043dcb688b8443ebad (diff)
downloadgobject-introspection-3e0292cd66752489d5b05bed57abffec0315b3ae.tar.gz
Always add a zero-terminated attribute when it cannot be implied
g-ir-compiler assumes that an array is zero terminated when the attribute is absent and there is no other attribute (length and fixed-size), but g-ir-scanner only added the attribute when it is 0. This means that an explicit zero-terminated=1 annotation would have had no effect. Fix that and at the same time ensure that all other arrays are not zero-terminated by default. https://bugzilla.gnome.org/show_bug.cgi?id=646635
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/girwriter.py6
-rw-r--r--giscanner/maintransformer.py2
2 files changed, 8 insertions, 0 deletions
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index ad601eeb..4a6c47e0 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -278,8 +278,14 @@ and/or use gtk-doc annotations. ''')
elif isinstance(ntype, ast.Array):
if ntype.array_type != ast.Array.C:
attrs.insert(0, ('name', ntype.array_type))
+ # we insert an explicit 'zero-terminated' attribute
+ # when it is false, or when it would not be implied
+ # by the absence of length and fixed-size
if not ntype.zeroterminated:
attrs.insert(0, ('zero-terminated', '0'))
+ elif (ntype.zeroterminated
+ and (ntype.size is not None or ntype.length_param_name is not None)):
+ attrs.insert(0, ('zero-terminated', '1'))
if ntype.size is not None:
attrs.append(('fixed-size', '%d' % (ntype.size, )))
if ntype.length_param_name is not None:
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index dd20af1e..fd0cc6c6 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -346,6 +346,8 @@ usage is void (*_gtk_reserved1)(void);"""
if OPT_ARRAY_ZERO_TERMINATED in array_values:
container_type.zeroterminated = array_values.get(
OPT_ARRAY_ZERO_TERMINATED) == '1'
+ else:
+ container_type.zeroterminated = False
length = array_values.get(OPT_ARRAY_LENGTH)
if length is not None:
paramname = self._get_validate_parameter_name(parent, length, node)