summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2010-09-24 09:59:21 -0300
committerJohan Dahlin <johan@gnome.org>2010-09-24 11:03:52 -0300
commit013937b79ce3467068352e6dd0179efaf2563ac7 (patch)
tree722c7bbfa8dfc671114ca5475cfeb45480cbdea0
parentb04e0df15a67b1159752615941527023bd781a39 (diff)
downloadgobject-introspection-013937b79ce3467068352e6dd0179efaf2563ac7.tar.gz
[maintransformer] Add more warnings for element-type
-rw-r--r--giscanner/maintransformer.py33
1 files changed, 28 insertions, 5 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index fcbf1099..605b1d1c 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -358,19 +358,42 @@ usage is void (*_gtk_reserved1)(void);"""
def _apply_annotations_element_type(self, parent, node, options):
element_type_opt = options.get(OPT_ELEMENT_TYPE)
- element_type = element_type_opt.flat()
+ if element_type_opt is None:
+ message.warn(
+ 'element-type annotation takes at least one option, '
+ 'none given',
+ options.position)
+ return
+
if isinstance(node.type, ast.List):
- assert len(element_type) == 1
- node.type.element_type = self._resolve(element_type[0],
+ if element_type_opt.length() != 1:
+ message.warn(
+ 'element-type annotation for a list must have exactly '
+ 'one option, not %d options' % (element_type_opt.length(), ),
+ options.position)
+ return
+ node.type.element_type = self._resolve(element_type_opt.one(),
node.type, node, parent)
elif isinstance(node.type, ast.Map):
- assert len(element_type) == 2
+ if element_type_opt.length() != 2:
+ message.warn(
+ 'element-type annotation for a hash table must have exactly '
+ 'two options, not %d option(s)' % (element_type_opt.length(), ),
+ options.position)
+ return
+ element_type = element_type_opt.flat()
node.type.key_type = self._resolve(element_type[0],
node.type, node, parent)
node.type.value_type = self._resolve(element_type[1],
node.type, node, parent)
elif isinstance(node.type, ast.Array):
- node.type.element_type = self._resolve(element_type[0],
+ if element_type_opt.length() != 1:
+ message.warn(
+ 'element-type annotation for an array must have exactly '
+ 'one option, not %d options' % (element_type_opt.length(), ),
+ options.position)
+ return
+ node.type.element_type = self._resolve(element_type_opt.one(),
node.type, node, parent)
else:
message.warn_node(parent,