diff options
author | Marco Trevisan (TreviƱo) <mail@3v1n0.net> | 2022-11-15 07:37:50 +0100 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2022-11-21 02:14:42 +0000 |
commit | 5112dff728bbc60ab3a807e647e12a88070a8f4b (patch) | |
tree | d14fe49e4a798aa4ad0402bed6cced4b642631ea /tests | |
parent | 2861c026587b868bab4730a54345b27bbbd32fcf (diff) | |
download | gobject-introspection-5112dff728bbc60ab3a807e647e12a88070a8f4b.tar.gz |
GIMarshallingTests: Add tests for caller allocated fixed size arrays
Such kind of arrays can be easily be allocated as we know the size of
each array element.
See: https://gitlab.gnome.org/GNOME/gjs/-/merge_requests/806
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gimarshallingtests.c | 30 | ||||
-rw-r--r-- | tests/gimarshallingtests.h | 6 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c index 5d0caea4..2072b9f2 100644 --- a/tests/gimarshallingtests.c +++ b/tests/gimarshallingtests.c @@ -1205,6 +1205,19 @@ gi_marshalling_tests_array_fixed_int_in (const gint *ints) } /** + * gi_marshalling_tests_array_fixed_caller_allocated_out: + * @ints: (out caller-allocates) (array fixed-size=4): + */ +void +gi_marshalling_tests_array_fixed_caller_allocated_out (gint *ints) +{ + ints[0] = -1; + ints[1] = 0; + ints[2] = 1; + ints[3] = 2; +} + +/** * gi_marshalling_tests_array_fixed_short_in: * @shorts: (array fixed-size=4): */ @@ -1252,6 +1265,23 @@ gi_marshalling_tests_array_fixed_out_struct (GIMarshallingTestsSimpleStruct **st } /** + * gi_marshalling_tests_array_fixed_caller_allocated_struct_out: + * @structs: (out caller-allocates) (array fixed-size=4): + */ +void +gi_marshalling_tests_array_fixed_caller_allocated_struct_out (GIMarshallingTestsSimpleStruct *structs) +{ + structs[0].long_ = -2; + structs[0].int8 = -1; + structs[1].long_ = 1; + structs[1].int8 = 2; + structs[2].long_ = 3; + structs[2].int8 = 4; + structs[3].long_ = 5; + structs[3].int8 = 6; +} + +/** * gi_marshalling_tests_array_fixed_inout: * @ints: (inout) (array fixed-size=4) (transfer none): */ diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h index 2f4b259b..d4901987 100644 --- a/tests/gimarshallingtests.h +++ b/tests/gimarshallingtests.h @@ -679,6 +679,9 @@ _GI_TEST_EXTERN void gi_marshalling_tests_array_fixed_int_in (const gint *ints); _GI_TEST_EXTERN +void gi_marshalling_tests_array_fixed_caller_allocated_out (gint *ints); + +_GI_TEST_EXTERN void gi_marshalling_tests_array_fixed_short_in (const gshort *shorts); @@ -689,6 +692,9 @@ void gi_marshalling_tests_array_fixed_out (gint **ints); _GI_TEST_EXTERN void gi_marshalling_tests_array_fixed_out_struct (GIMarshallingTestsSimpleStruct **structs); +_GI_TEST_EXTERN +void gi_marshalling_tests_array_fixed_caller_allocated_struct_out (GIMarshallingTestsSimpleStruct *structs); + _GI_TEST_EXTERN void gi_marshalling_tests_array_fixed_inout (gint **ints); |