diff options
author | Jasper St. Pierre <jstpierre@mecheye.net> | 2012-02-03 10:54:19 -0500 |
---|---|---|
committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2012-02-03 11:52:33 -0500 |
commit | 3c0cfdc992caa5c19a7e2f0820dc5286a7e14dbb (patch) | |
tree | d7df3d2fda536f4b6ff74aa7c860570926b0ac7f | |
parent | e089f7413ba3b191776037a89d3fc8f72582811b (diff) | |
download | gobject-introspection-3c0cfdc992caa5c19a7e2f0820dc5286a7e14dbb.tar.gz |
tests: Add marshalling tests for various kinds of callbacks
-rw-r--r-- | tests/gimarshallingtests.c | 65 | ||||
-rw-r--r-- | tests/gimarshallingtests.h | 51 |
2 files changed, 115 insertions, 1 deletions
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c index b57f36d3..196b7394 100644 --- a/tests/gimarshallingtests.c +++ b/tests/gimarshallingtests.c @@ -3057,6 +3057,71 @@ gi_marshalling_tests_gclosure_return (void) return closure; } + +/** + * gi_marshalling_tests_callback_return_value_only: + * @callback: (scope call): + */ +glong +gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback) +{ + return callback (); +} + +/** + * gi_marshalling_tests_callback_one_out_parameter: + * @callback: (scope call): + * @a: (out): + */ +void +gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter callback, + gfloat *a) +{ + callback (a); +} + +/** + * gi_marshalling_tests_callback_multiple_out_parameters: + * @callback: (scope call): + * @a: (out): + * @b: (out): + */ +void +gi_marshalling_tests_callback_multiple_out_parameters (GIMarshallingTestsCallbackMultipleOutParameters callback, + gfloat *a, + gfloat *b) +{ + callback (a, b); +} + +/** + * gi_marshalling_tests_callback_return_value_and_one_out_parameter: + * @callback: (scope call): + * @a: (out): + */ +glong +gi_marshalling_tests_callback_return_value_and_one_out_parameter (GIMarshallingTestsCallbackReturnValueAndOneOutParameter callback, + glong *a) +{ + return callback (a); +} + +/** + * gi_marshalling_tests_callback_return_value_and_multiple_out_parameters: + * @callback: (scope call): + * @a: (out): + * @b: (out): + */ +glong +gi_marshalling_tests_callback_return_value_and_multiple_out_parameters (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters callback, + glong *a, + glong *b) +{ + return callback (a, b); +} + + + /** * gi_marshalling_tests_pointer_in_return: * diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h index d5ddd3f2..3a2fd12a 100644 --- a/tests/gimarshallingtests.h +++ b/tests/gimarshallingtests.h @@ -547,6 +547,55 @@ GValue *gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one, void gi_marshalling_tests_gclosure_in (GClosure *closure); GClosure *gi_marshalling_tests_gclosure_return (void); +/* Callback return values */ + +/** + * GIMarshallingTestsCallbackReturnValueOnly: + */ +typedef glong (* GIMarshallingTestsCallbackReturnValueOnly) (); + +glong gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback); + +/** + * GIMarshallingTestsCallbackOneOutParameter: + * @a: (out): + */ +typedef void (* GIMarshallingTestsCallbackOneOutParameter) (gfloat *a); + +void gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter callback, + gfloat *a); + +/** + * GIMarshallingTestsCallbackMultipleOutParameters: + * @a: (out): + * @b: (out): + */ +typedef void (* GIMarshallingTestsCallbackMultipleOutParameters) (gfloat *a, gfloat *b); + +void gi_marshalling_tests_callback_multiple_out_parameters (GIMarshallingTestsCallbackMultipleOutParameters callback, + gfloat *a, + gfloat *b); + +/** + * GIMarshallingTestsCallbackReturnValueAndOneOutParameter: + * @a: (out): + */ +typedef glong (* GIMarshallingTestsCallbackReturnValueAndOneOutParameter) (glong *a); + +glong gi_marshalling_tests_callback_return_value_and_one_out_parameter (GIMarshallingTestsCallbackReturnValueAndOneOutParameter callback, + glong *a); + +/** + * GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters: + * @a: (out): + * @b: (out): + */ +typedef glong (* GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters) (glong *a, glong *b); + +glong gi_marshalling_tests_callback_return_value_and_multiple_out_parameters (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters callback, + glong *a, + glong *b); + /* Pointer */ gpointer gi_marshalling_tests_pointer_in_return (gpointer pointer); @@ -617,7 +666,7 @@ void gi_marshalling_tests_union_inout (GIMarshallingTestsUnion **union_); void gi_marshalling_tests_union_method (GIMarshallingTestsUnion *union_); -/* Object */ + /* Object */ #define GI_MARSHALLING_TESTS_TYPE_OBJECT (gi_marshalling_tests_object_get_type ()) #define GI_MARSHALLING_TESTS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GI_MARSHALLING_TESTS_TYPE_OBJECT, GIMarshallingTestsObject)) |