summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2010-09-24 13:50:17 -0300
committerJohan Dahlin <johan@gnome.org>2010-09-24 13:53:36 -0300
commit818333247787bb1cf51b0fb13276114de9f9bfa2 (patch)
tree5b1894733fa6b4605333be54c28e5e5a0ae80f4a
parent789321d97207d6989ef77805fe5fb5920b6935cc (diff)
downloadgobject-introspection-818333247787bb1cf51b0fb13276114de9f9bfa2.tar.gz
[annotationparser] Allow param less closures
Allow closures without annotations to avoid having to duplicate the parameter name.
-rw-r--r--giscanner/annotationparser.py6
-rw-r--r--giscanner/maintransformer.py2
-rw-r--r--tests/scanner/annotation.h2
-rw-r--r--tests/warn/Makefile.am1
-rw-r--r--tests/warn/invalid-closure.h8
5 files changed, 16 insertions, 3 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 075f227d..f2bc1d4b 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -207,7 +207,11 @@ class DocTag(object):
elif option == OPT_ATTRIBUTE:
self._validate_option('attribute', value, n_params=2)
elif option == OPT_CLOSURE:
- self._validate_option('closure', value, n_params=1)
+ if value is not None and value.length() > 1:
+ message.warn(
+ 'closure takes at maximium 1 value, %d given' % (
+ value.length()), self.position)
+ continue
elif option == OPT_DESTROY:
self._validate_option('destroy', value, n_params=1)
elif option == OPT_ELEMENT_TYPE:
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 0407bbc5..e45ff795 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -600,7 +600,7 @@ usage is void (*_gtk_reserved1)(void);"""
# since we don't have a way right now to flag this callback a destroy.
destroy_param.scope = ast.PARAM_SCOPE_NOTIFIED
closure = options.get(OPT_CLOSURE)
- if closure:
+ if closure and closure.length() == 1:
param.closure_name = self._get_validate_parameter_name(parent,
closure.one(),
param)
diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h
index 559ea705..e4f29065 100644
--- a/tests/scanner/annotation.h
+++ b/tests/scanner/annotation.h
@@ -23,7 +23,7 @@ typedef GList* (*AnnotationListCallback) (GList *in);
/**
* AnnotationNotifyFunc:
- * @data: (closure data): The user data
+ * @data: (closure): The user data
*
* This is a callback with a 'closure' argument that is not named
* 'user_data' and hence has to be annotated.
diff --git a/tests/warn/Makefile.am b/tests/warn/Makefile.am
index db006e57..3cd44b00 100644
--- a/tests/warn/Makefile.am
+++ b/tests/warn/Makefile.am
@@ -5,6 +5,7 @@ TESTS = \
callback-missing-scope.h \
return-gobject.h \
invalid-array.h \
+ invalid-closure.h \
invalid-element-type.h \
invalid-option.h \
invalid-out.h \
diff --git a/tests/warn/invalid-closure.h b/tests/warn/invalid-closure.h
new file mode 100644
index 00000000..fcaf0937
--- /dev/null
+++ b/tests/warn/invalid-closure.h
@@ -0,0 +1,8 @@
+
+/**
+ * test_invalid_closure:
+ * @param: (closure a b):
+ */
+void test_invalid_closure(int param);
+
+// EXPECT:4: Warning: Test: closure takes at maximium 1 value, 2 given