[gobject-introspection] [tests] add a gclosure_return method to test passing GClosures between methods
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] [tests] add a gclosure_return method to test passing GClosures between methods
- Date: Wed, 16 Mar 2011 21:33:25 +0000 (UTC)
commit 30e66074ef6268b4e332049e86d904c52d9bd1db
Author: John (J5) Palmieri <johnp redhat com>
Date: Wed Mar 16 17:31:47 2011 -0400
[tests] add a gclosure_return method to test passing GClosures between methods
tests/gimarshallingtests.c | 37 +++++++++++++++++++++++++++++++++++++
tests/gimarshallingtests.h | 2 +-
2 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index aa9fb7c..3c7311c 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 6ab99da..752147b 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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]