diff options
author | Giovanni Campagna <gcampagna@src.gnome.org> | 2011-06-01 16:59:17 +0200 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2011-06-04 15:15:12 -0400 |
commit | 3e0292cd66752489d5b05bed57abffec0315b3ae (patch) | |
tree | 3b0c9e2cb1f8dde640e0525b2f6ad588000fe9c3 /giscanner/girwriter.py | |
parent | 7c93dc9534a4de5599f574043dcb688b8443ebad (diff) | |
download | gobject-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/girwriter.py')
-rw-r--r-- | giscanner/girwriter.py | 6 |
1 files changed, 6 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: |