[gobject-introspection] Add tests for array arguments in callbacks
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Add tests for array arguments in callbacks
- Date: Mon, 6 Feb 2012 16:15:10 +0000 (UTC)
commit 6757460e4a95f818d3a73d7904ef8a7afb6987fc
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Mon Jul 11 20:05:48 2011 +0200
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
tests/scanner/Regress-1.0-expected.gir | 34 ++++++++++++++++++++++++++++++++
tests/scanner/regress.c | 15 ++++++++++++++
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 481259c..afcaa8a 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 bda27be..ec6a187 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 bebfdac..6c5a036 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]