summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2015-03-01 21:36:12 +0100
committerDieter Verfaillie <dieterv@optionexplicit.be>2015-03-03 22:07:45 +0100
commit50dfb465658a5c1705cac51a31f145fee8b6b168 (patch)
treec5ebae7ac13589e4ef74138076792faa25ba46ec /giscanner
parent7e41a4c31acf729cba6e071692d03779eba77eea (diff)
downloadgobject-introspection-50dfb465658a5c1705cac51a31f145fee8b6b168.tar.gz
scanner: allow (array zero-terminated) instead of (array zero-terminated=1)
What we already had: - (array zero-terminated=1) > array which is NULL terminated - (array zero-terminated=0) > array which is not NULL terminated - (array) > array which is not NULL terminated - (array zero-terminated=X) > array which is not NULL terminated where X can be anything What this patch adds: - (array zero-terminated) > array which is NULL terminated https://bugzilla.gnome.org/show_bug.cgi?id=657754
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/annotationparser.py7
-rw-r--r--giscanner/maintransformer.py10
2 files changed, 13 insertions, 4 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index afeca9ce..907039c4 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -652,7 +652,7 @@ class GtkDocAnnotatable(object):
return
for option, value in options.items():
- if option in [OPT_ARRAY_ZERO_TERMINATED, OPT_ARRAY_FIXED_SIZE]:
+ if option == OPT_ARRAY_FIXED_SIZE:
try:
int(value)
except (TypeError, ValueError):
@@ -663,6 +663,11 @@ class GtkDocAnnotatable(object):
warn('invalid "%s" annotation option "%s" value "%s", must be an integer' %
(ann_name, option, value),
position)
+ elif option == OPT_ARRAY_ZERO_TERMINATED:
+ if value is not None and value not in ['0', '1']:
+ warn('invalid "%s" annotation option "%s" value "%s", must be 0 or 1' %
+ (ann_name, option, value),
+ position)
elif option == OPT_ARRAY_LENGTH:
if value is None:
warn('"%s" annotation option "length" needs a value' % (ann_name, ),
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 4326374f..df598adf 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -386,10 +386,14 @@ class MainTransformer(object):
array_options = annotations.get(ANN_ARRAY)
container_type = ast.Array(array_type, element_type_node, ctype=node.type.ctype,
is_const=node.type.is_const)
- if OPT_ARRAY_ZERO_TERMINATED in array_options:
- container_type.zeroterminated = array_options.get(OPT_ARRAY_ZERO_TERMINATED) == '1'
- else:
+ if array_options.get(OPT_ARRAY_ZERO_TERMINATED, '0') == '0':
container_type.zeroterminated = False
+ else:
+ if (OPT_ARRAY_ZERO_TERMINATED in array_options
+ or array_options.get(OPT_ARRAY_ZERO_TERMINATED) == '1'):
+ container_type.zeroterminated = True
+ else:
+ container_type.zeroterminated = False
length = array_options.get(OPT_ARRAY_LENGTH)
if length: