diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2011-08-12 09:57:41 +0200 |
---|---|---|
committer | Johan Dahlin <jdahlin@litl.com> | 2011-08-13 09:42:37 -0300 |
commit | 74850f014aba3f3c07456a9a95c86bf9e5d0e37c (patch) | |
tree | 92869fc28ec949b01a3d39c268228381c5e4b3cc | |
parent | 5ec1477d0feeb2d7d0d91477769fa5bb9c09cd1a (diff) | |
download | gobject-introspection-74850f014aba3f3c07456a9a95c86bf9e5d0e37c.tar.gz |
Add Regress method for a closure taking and returning a GVariant
-rw-r--r-- | tests/scanner/Regress-1.0-expected.gir | 17 | ||||
-rw-r--r-- | tests/scanner/regress.c | 32 | ||||
-rw-r--r-- | tests/scanner/regress.h | 1 |
3 files changed, 50 insertions, 0 deletions
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index a85f38b3..a19969e7 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -1807,6 +1807,23 @@ call and can be released on return.</doc> </parameter> </parameters> </function> + <function name="test_closure_variant" + c:identifier="regress_test_closure_variant"> + <return-value transfer-ownership="full"> + <doc xml:whitespace="preserve">the return value of @closure</doc> + <type name="GLib.Variant" c:type="GVariant*"/> + </return-value> + <parameters> + <parameter name="closure" transfer-ownership="none"> + <doc xml:whitespace="preserve">GClosure which takes one GVariant and returns a GVariant</doc> + <type name="GObject.Closure" c:type="GClosure*"/> + </parameter> + <parameter name="arg" transfer-ownership="none"> + <doc xml:whitespace="preserve">a GVariant passed as argument to @closure</doc> + <type name="GLib.Variant" c:type="GVariant*"/> + </parameter> + </parameters> + </function> <function name="test_date_in_gvalue" c:identifier="regress_test_date_in_gvalue"> <return-value transfer-ownership="full"> diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 220bc120..c6608f40 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -213,6 +213,38 @@ regress_test_closure_one_arg (GClosure *closure, int arg) } /** + * regress_test_closure_variant: + * @closure: GClosure which takes one GVariant and returns a GVariant + * @arg: (transfer none): a GVariant passed as argument to @closure + * + * Return value: (transfer full): the return value of @closure + */ +GVariant* +regress_test_closure_variant (GClosure *closure, const GVariant* arg) +{ + GValue return_value = {0, }; + GValue arguments[1] = {{0,} }; + int ret; + + g_value_init (&return_value, G_TYPE_VARIANT); + + g_value_init (&arguments[0], G_TYPE_VARIANT); + g_value_set_variant (&arguments[0], arg); + + g_closure_invoke (closure, + &return_value, + 1, arguments, + NULL); + + ret = g_value_get_variant (&return_value); + + g_value_unset (&return_value); + g_value_unset (&arguments[0]); + + return ret; +} + +/** * regress_test_value_arg: * @v: (transfer none): a GValue expected to contain an int * diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index f3c3687b..04ebe29e 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -116,6 +116,7 @@ GHashTable *regress_test_ghash_nested_everything_return2 (void); /* closure */ int regress_test_closure (GClosure *closure); int regress_test_closure_one_arg (GClosure *closure, int arg); +GVariant *regress_test_closure_variant (GClosure *closure, const GVariant* arg); /* value */ int regress_test_int_value_arg(const GValue *v); |