diff options
author | Giovanni Campagna <gcampagna@src.gnome.org> | 2011-07-11 20:05:48 +0200 |
---|---|---|
committer | Giovanni Campagna <gcampagna@src.gnome.org> | 2012-02-06 17:14:26 +0100 |
commit | 6757460e4a95f818d3a73d7904ef8a7afb6987fc (patch) | |
tree | e6f3c53dfd9fcd3871213c2ac8089a896e394d62 /tests/scanner | |
parent | b9bd2026f0772bde2739cff86ab5cfb462d43f26 (diff) | |
download | gobject-introspection-6757460e4a95f818d3a73d7904ef8a7afb6987fc.tar.gz |
Add tests for array arguments in callbacks
Add a test that accepts a callback receiving array arguments
https://bugzilla.gnome.org/show_bug.cgi?id=654406
Diffstat (limited to 'tests/scanner')
-rw-r--r-- | tests/scanner/Regress-1.0-expected.gir | 34 | ||||
-rw-r--r-- | tests/scanner/regress.c | 15 | ||||
-rw-r--r-- | tests/scanner/regress.h | 9 |
3 files changed, 58 insertions, 0 deletions
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index 481259c9..afcaa8aa 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -180,6 +180,29 @@ use it should be.</doc> <type name="gint" c:type="int"/> </return-value> </callback> + <callback name="TestCallbackArray" c:type="RegressTestCallbackArray"> + <return-value transfer-ownership="none"> + <type name="gint" c:type="int"/> + </return-value> + <parameters> + <parameter name="one" transfer-ownership="none"> + <array length="1" zero-terminated="0" c:type="int*"> + <type name="gint" c:type="int"/> + </array> + </parameter> + <parameter name="one_length" transfer-ownership="none"> + <type name="gsize" c:type="gsize"/> + </parameter> + <parameter name="two" transfer-ownership="none"> + <array length="3" zero-terminated="0" c:type="char**"> + <type name="utf8"/> + </array> + </parameter> + <parameter name="two_length" transfer-ownership="none"> + <type name="gint" c:type="int"/> + </parameter> + </parameters> + </callback> <callback name="TestCallbackFull" c:type="RegressTestCallbackFull"> <return-value transfer-ownership="none"> <type name="gint" c:type="int"/> @@ -1547,6 +1570,17 @@ Use with regress_test_obj_emit_sig_with_obj</doc> </parameter> </parameters> </function> + <function name="test_array_callback" + c:identifier="regress_test_array_callback"> + <return-value transfer-ownership="none"> + <type name="gint" c:type="int"/> + </return-value> + <parameters> + <parameter name="callback" transfer-ownership="none" scope="call"> + <type name="TestCallbackArray" c:type="RegressTestCallbackArray"/> + </parameter> + </parameters> + </function> <function name="test_array_fixed_size_int_in" c:identifier="regress_test_array_fixed_size_int_in"> <return-value transfer-ownership="none"> diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index bda27bef..ec6a187f 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -2872,7 +2872,22 @@ regress_test_multi_callback (RegressTestCallback callback) return sum; } +/** + * regress_test_array_callback: + * @callback: (scope call): + * + **/ +int regress_test_array_callback (RegressTestCallbackArray callback) +{ + static const char *strings[] = { "one", "two", "three" }; + static int ints[] = { -1, 0, 1, 2 }; + int sum = 0; + + sum += callback(ints, 4, strings, 3); + sum += callback(ints, 4, strings, 3); + return sum; +} /** * regress_test_simple_callback: diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index bebfdacb..6c5a0361 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -550,10 +550,19 @@ typedef void (*RegressTestCallbackOwnedGError) (GError *error); * @path: (type filename): Path to file */ typedef int (*RegressTestCallbackFull) (int foo, double bar, char *path); +/** + * RegressTestCallbackArray: + * @one: (array length=one_length): + * @one_length: + * @two: (array length=two_length) (element-type utf8): + * @two_length: + */ +typedef int (*RegressTestCallbackArray) (int *one, gsize one_length, const char** two, int two_length); void regress_test_simple_callback (RegressTestSimpleCallback callback); int regress_test_callback (RegressTestCallback callback); int regress_test_multi_callback (RegressTestCallback callback); +int regress_test_array_callback (RegressTestCallbackArray callback); int regress_test_callback_user_data (RegressTestCallbackUserData callback, gpointer user_data); int regress_test_callback_destroy_notify (RegressTestCallbackUserData callback, |