diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2020-03-16 23:03:44 +0100 |
---|---|---|
committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2020-03-16 23:03:44 +0100 |
commit | d716945125543b999f892fbf6297ff6a37ee111f (patch) | |
tree | dc814584a9da1e77cf5706f0c7f781a5edc452e6 /tests | |
parent | 137952c03abd2acd454b834d8cc7ae10915c8aa0 (diff) | |
download | gobject-introspection-d716945125543b999f892fbf6297ff6a37ee111f.tar.gz |
gimarshallingtests: Add marshalling tests for virtual functions with inout parameters
Virtual functions may use input/output parameters but this is not currently
well handled by gjs, so adding test cases to gobject-introspection to verify
that virtual functions correctly receive valid input values and can return
them.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gimarshallingtests.c | 58 | ||||
-rw-r--r-- | tests/gimarshallingtests.h | 38 |
2 files changed, 96 insertions, 0 deletions
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c index 92868016..44971506 100644 --- a/tests/gimarshallingtests.c +++ b/tests/gimarshallingtests.c @@ -4584,6 +4584,33 @@ gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *s } /** + * gi_marshalling_tests_object_vfunc_one_inout_parameter: + * @a: (inout): + */ +void +gi_marshalling_tests_object_vfunc_one_inout_parameter (GIMarshallingTestsObject *self, gfloat *a) +{ + /* make sure that local variables don't get smashed */ + gulong local = 0x12345678; + GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_inout_parameter (self, a); + g_assert_cmpint (local, ==, 0x12345678); +} + +/** + * gi_marshalling_tests_object_vfunc_multiple_inout_parameters: + * @a: (inout): + * @b: (inout): + */ +void +gi_marshalling_tests_object_vfunc_multiple_inout_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b) +{ + /* make sure that local variables don't get smashed */ + gulong local = 0x12345678; + GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_inout_parameters (self, a, b); + g_assert_cmpint (local, ==, 0x12345678); +} + +/** * gi_marshalling_tests_object_vfunc_multiple_out_parameters: * @a: (out): * @b: (out): @@ -4652,6 +4679,37 @@ glong } /** + * gi_marshalling_tests_object_vfunc_return_value_and_one_inout_parameter: + * @a: (inout): + */ +glong gi_marshalling_tests_object_vfunc_return_value_and_one_inout_parameter (GIMarshallingTestsObject *self, glong *a) +{ + /* make sure that local variables don't get smashed */ + gulong return_value; + gulong local = 0x12345678; + return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_inout_parameter (self, a); + g_assert_cmpint (local, ==, 0x12345678); + return return_value; +} + +/** + * gi_marshalling_tests_object_vfunc_return_value_and_multiple_inout_parameters: + * @a: (inout): + * @b: (inout): + */ +glong + gi_marshalling_tests_object_vfunc_return_value_and_multiple_inout_parameters + (GIMarshallingTestsObject *self, glong *a, glong *b) +{ + gulong return_value; + gulong local = 0x12345678; + return_value = + GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_inout_parameters (self, a, b); + g_assert_cmpint (local, ==, 0x12345678); + return return_value; +} + +/** * gi_marshalling_tests_callback_owned_boxed: * @callback: (scope call) (closure callback_data): * @callback_data: (allow-none): diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h index d5357ec9..747a075d 100644 --- a/tests/gimarshallingtests.h +++ b/tests/gimarshallingtests.h @@ -1410,6 +1410,19 @@ struct _GIMarshallingTestsObjectClass void (* vfunc_multiple_out_parameters) (GIMarshallingTestsObject *self, gfloat *a, gfloat *b); /** + * GIMarshallingTestsObjectClass::vfunc_one_inout_parameter: + * @a: (inout): + */ + void (* vfunc_one_inout_parameter) (GIMarshallingTestsObject *self, gfloat *a); + + /** + * GIMarshallingTestsObjectClass::vfunc_multiple_inout_parameters: + * @a: (inout): + * @b: (inout): + */ + void (* vfunc_multiple_inout_parameters) (GIMarshallingTestsObject *self, gfloat *a, gfloat *b); + + /** * GIMarshallingTestsObjectClass::vfunc_caller_allocated_out_parameter: * @a: (out): */ @@ -1435,6 +1448,19 @@ struct _GIMarshallingTestsObjectClass glong (* vfunc_return_value_and_multiple_out_parameters) (GIMarshallingTestsObject *self, glong *a, glong *b); /** + * GIMarshallingTestsObjectClass::vfunc_return_value_and_one_inout_parameter: + * @a: (inout): + */ + glong (* vfunc_return_value_and_one_inout_parameter) (GIMarshallingTestsObject *self, glong *a); + + /** + * GIMarshallingTestsObjectClass::vfunc_return_value_and_multiple_inout_parameters: + * @a: (inout): + * @b: (inout): + */ + glong (* vfunc_return_value_and_multiple_inout_parameters) (GIMarshallingTestsObject *self, glong *a, glong *b); + + /** * GIMarshallingTestsObjectClass::vfunc_meth_with_err: * @x: * @error: A #GError @@ -1561,6 +1587,12 @@ _GI_TEST_EXTERN void gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b); _GI_TEST_EXTERN +void gi_marshalling_tests_object_vfunc_one_inout_parameter (GIMarshallingTestsObject *self, gfloat *a); + +_GI_TEST_EXTERN +void gi_marshalling_tests_object_vfunc_multiple_inout_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b); + +_GI_TEST_EXTERN void gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter (GIMarshallingTestsObject *self, GValue *a); _GI_TEST_EXTERN @@ -1573,6 +1605,12 @@ _GI_TEST_EXTERN glong gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters (GIMarshallingTestsObject *self, glong *a, glong *b); _GI_TEST_EXTERN +glong gi_marshalling_tests_object_vfunc_return_value_and_one_inout_parameter (GIMarshallingTestsObject *self, glong *a); + +_GI_TEST_EXTERN +glong gi_marshalling_tests_object_vfunc_return_value_and_multiple_inout_parameters (GIMarshallingTestsObject *self, glong *a, glong *b); + +_GI_TEST_EXTERN gboolean gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *object, gint x, GError **error); |