summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2010-09-24 10:53:12 -0300
committerJohan Dahlin <johan@gnome.org>2010-09-24 11:03:53 -0300
commit789321d97207d6989ef77805fe5fb5920b6935cc (patch)
treedb11c1cea605a1eb88520c68f67b7359a5bf6f5b /giscanner
parent7c3d1e7c5d6d209c262789b22ea6a99b0636771d (diff)
downloadgobject-introspection-789321d97207d6989ef77805fe5fb5920b6935cc.tar.gz
Add more array warnings + tests
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/annotationparser.py30
-rw-r--r--giscanner/maintransformer.py6
2 files changed, 30 insertions, 6 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index b8e8530c..075f227d 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -177,13 +177,33 @@ class DocTag(object):
elif option == OPT_ARRAY:
if value is None:
continue
- for v in value.all():
- if v not in [OPT_ARRAY_LENGTH,
- OPT_ARRAY_ZERO_TERMINATED,
- OPT_ARRAY_FIXED_SIZE]:
+ for name, v in value.all().iteritems():
+ if name in [OPT_ARRAY_ZERO_TERMINATED, OPT_ARRAY_FIXED_SIZE]:
+ try:
+ int(v)
+ except (TypeError, ValueError):
+ if v is None:
+ message.warn(
+ 'array option %s needs a value' % (
+ name, ),
+ positions=self.position)
+ else:
+ message.warn(
+ 'invalid array %s option value %r, '
+ 'must be an integer' % (name, v, ),
+ positions=self.position)
+ continue
+ elif name == OPT_ARRAY_LENGTH:
+ if v is None:
+ message.warn(
+ 'array option length needs a value',
+ positions=self.position)
+ continue
+ else:
message.warn(
'invalid array annotation value: %r' % (
- v, ), self.position)
+ name, ), self.position)
+
elif option == OPT_ATTRIBUTE:
self._validate_option('attribute', value, n_params=2)
elif option == OPT_CLOSURE:
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 605b1d1c..0407bbc5 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -353,7 +353,11 @@ usage is void (*_gtk_reserved1)(void);"""
container_type.length_param_name = param.argname
fixed = array_values.get(OPT_ARRAY_FIXED_SIZE)
if fixed:
- container_type.size = int(fixed)
+ try:
+ container_type.size = int(fixed)
+ except ValueError:
+ # Already warned in annotationparser.py
+ return
node.type = container_type
def _apply_annotations_element_type(self, parent, node, options):