summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2011-08-29 21:51:34 -0400
committerColin Walters <walters@verbum.org>2011-08-29 21:51:34 -0400
commitedb4146278f74030fba9bfd79e21f070f24d4434 (patch)
tree2d2b98216c82b6bd8c700d597d6b19273f86c628
parentcda0aece025c26a407e5e6c918a4312b87450754 (diff)
downloadgobject-introspection-edb4146278f74030fba9bfd79e21f070f24d4434.tar.gz
Fix warning for missing (element-type)
While looking for a different bug, I noticed that the introspectable pass lists was missing GSList. And the warning was never set up to fire anyways. Fix it and add a test.
-rw-r--r--giscanner/introspectablepass.py4
-rw-r--r--tests/warn/Makefile.am1
-rw-r--r--tests/warn/invalid-element-type.h2
-rw-r--r--tests/warn/missing-element-type.h10
4 files changed, 15 insertions, 2 deletions
diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py
index ebb1dedc..95d54b0a 100644
--- a/giscanner/introspectablepass.py
+++ b/giscanner/introspectablepass.py
@@ -84,8 +84,8 @@ class IntrospectablePass(object):
parent.introspectable = False
return
- if not isinstance(node.type, ast.List) and \
- (node.type.target_giname == 'GLib.List'):
+ if (isinstance(node.type, ast.List)
+ and node.type.element_type == ast.TYPE_ANY):
self._parameter_warning(parent, node, "Missing (element-type) annotation")
parent.introspectable = False
return
diff --git a/tests/warn/Makefile.am b/tests/warn/Makefile.am
index 7d81d9ef..5ca3d821 100644
--- a/tests/warn/Makefile.am
+++ b/tests/warn/Makefile.am
@@ -12,6 +12,7 @@ TESTS = \
invalid-option.h \
invalid-out.h \
invalid-transfer.h \
+ missing-element-type.h \
unknown-parameter.h \
unresolved-type.h
diff --git a/tests/warn/invalid-element-type.h b/tests/warn/invalid-element-type.h
index 2b424594..a3e71f53 100644
--- a/tests/warn/invalid-element-type.h
+++ b/tests/warn/invalid-element-type.h
@@ -78,3 +78,5 @@ GList* test_unresolved_element_type(void);
// EXPECT:51: Warning: Test: element-type annotation takes at least one option, none given
// EXPECT:52: Warning: Test: invalid (element-type) for a GPtrArray, must be a pointer
// EXPECT:63: Warning: Test: test_unresolved_element_type: Unknown type: 'Unresolved'
+// EXPECT:3: Warning: Test: test_invalid_list_element_type: argument l1: Missing (element-type) annotation
+// EXPECT:3: Warning: Test: test_invalid_list_element_type: argument l2: Missing (element-type) annotation
diff --git a/tests/warn/missing-element-type.h b/tests/warn/missing-element-type.h
new file mode 100644
index 00000000..1f958a74
--- /dev/null
+++ b/tests/warn/missing-element-type.h
@@ -0,0 +1,10 @@
+#include "common.h"
+
+/**
+ * test_gslist_element_type:
+ *
+ * Returns: (transfer none): Some stuff
+ */
+GSList *test_gslist_element_type(void);
+
+// EXPECT:6: Warning: Test: test_gslist_element_type: return value: Missing (element-type) annotation