diff options
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/annotationparser.py | 30 | ||||
-rw-r--r-- | giscanner/maintransformer.py | 6 |
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): |