[gobject-introspection] Add Regress method for a closure taking and returning a GVariant
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Add Regress method for a closure taking and returning a GVariant
- Date: Fri, 12 Aug 2011 13:56:38 +0000 (UTC)
commit f45b703af3868136eedf66b54dd326b62c10e900
Author: Martin Pitt <martin pitt ubuntu com>
Date: Fri Aug 12 09:57:41 2011 +0200
Add Regress method for a closure taking and returning a GVariant
tests/scanner/Regress-1.0-expected.gir | 17 +++++++++++++++++
tests/scanner/regress.c | 32 ++++++++++++++++++++++++++++++++
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 a85f38b..a19969e 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 220bc12..c6608f4 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 f3c3687..04ebe29 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]