summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <johnp@redhat.com>2011-03-16 17:31:47 -0400
committerJohn (J5) Palmieri <johnp@redhat.com>2011-03-16 17:31:47 -0400
commit30e66074ef6268b4e332049e86d904c52d9bd1db (patch)
tree13c9526f49da12fd7e2a4cd9cb75451c6b96b90f
parent2d39aac59cb245b81e7c92abf816b90d8916aace (diff)
downloadgobject-introspection-30e66074ef6268b4e332049e86d904c52d9bd1db.tar.gz
[tests] add a gclosure_return method to test passing GClosures between methods
-rw-r--r--tests/gimarshallingtests.c37
-rw-r--r--tests/gimarshallingtests.h2
2 files changed, 38 insertions, 1 deletions
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index aa9fb7c2..3c7311cd 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -2411,6 +2411,43 @@ gi_marshalling_tests_gclosure_in (GClosure *closure)
g_value_unset(&return_value);
}
+static gint
+_closure_return_42 (void)
+{
+ return 42;
+}
+
+static void
+_marshal_INT__VOID (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gint (*GMarshalFunc_INT__VOID) (void);
+ register GMarshalFunc_INT__VOID callback;
+ register GCClosure *cc = (GCClosure*) closure;
+
+ callback = (GMarshalFunc_INT__VOID) cc->callback;
+ g_value_set_int(return_value, callback());
+}
+
+/**
+ * gi_marshalling_tests_gclosure_return:
+ *
+ * Return: a #GClosure
+ */
+GClosure *
+gi_marshalling_tests_gclosure_return (void)
+{
+ GClosure *closure = g_cclosure_new ((GCallback *)_closure_return_42,
+ NULL, NULL);
+ g_closure_set_marshal (closure, _marshal_INT__VOID);
+
+ return closure;
+}
+
/**
* gi_marshalling_tests_pointer_in_return:
*
diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h
index 6ab99da7..752147b6 100644
--- a/tests/gimarshallingtests.h
+++ b/tests/gimarshallingtests.h
@@ -409,7 +409,7 @@ void gi_marshalling_tests_gvalue_inout (GValue **value);
/* GClosure */
void gi_marshalling_tests_gclosure_in (GClosure *closure);
-
+GClosure *gi_marshalling_tests_gclosure_return (void);
/* Pointer */