summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Regier <Garrett.Regier@riftio.com>2014-08-07 12:23:54 -0400
committerGarrett Regier <Garrett.Regier@riftio.com>2014-08-07 15:53:47 -0400
commite2b96aaa46ce73812fd41e46d996cd21da18f7be (patch)
treeb109196f430566b2aa77bdc08703a082613dfd78
parenta6f199ddf1fbe1ba3ed406e40bf114c0912ef346 (diff)
downloadgobject-introspection-e2b96aaa46ce73812fd41e46d996cd21da18f7be.tar.gz
tests: Add regression test for callbacks with an inout array
https://bugzilla.gnome.org/show_bug.cgi?id=702508
-rw-r--r--tests/scanner/Regress-1.0-C-expected/Regress.TestCallbackArrayInOut.page33
-rw-r--r--tests/scanner/Regress-1.0-C-expected/Regress.test_array_inout_callback.page38
-rw-r--r--tests/scanner/Regress-1.0-Gjs-expected/Regress.TestCallbackArrayInOut.page29
-rw-r--r--tests/scanner/Regress-1.0-Gjs-expected/Regress.test_array_inout_callback.page40
-rw-r--r--tests/scanner/Regress-1.0-Python-expected/Regress.TestCallbackArrayInOut.page30
-rw-r--r--tests/scanner/Regress-1.0-Python-expected/Regress.test_array_inout_callback.page41
-rw-r--r--tests/scanner/Regress-1.0-expected.gir34
-rw-r--r--tests/scanner/regress.c31
-rw-r--r--tests/scanner/regress.h7
9 files changed, 283 insertions, 0 deletions
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestCallbackArrayInOut.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestCallbackArrayInOut.page
new file mode 100644
index 00000000..0c8be370
--- /dev/null
+++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestCallbackArrayInOut.page
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<page id="Regress.TestCallbackArrayInOut"
+ type="topic"
+ style="callback"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="index" group="callback" type="guide"/>
+ </info>
+ <title>Regress.TestCallbackArrayInOut</title>
+ <synopsis><code mime="text/x-csrc">
+void TestCallbackArrayInOut (int** ints,
+ int* length);
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>ints</code></title>
+
+</item>
+<item>
+<title><code>length</code></title>
+
+</item>
+<item>
+<title><code>Returns</code></title>
+
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.test_array_inout_callback.page b/tests/scanner/Regress-1.0-C-expected/Regress.test_array_inout_callback.page
new file mode 100644
index 00000000..9da453a0
--- /dev/null
+++ b/tests/scanner/Regress-1.0-C-expected/Regress.test_array_inout_callback.page
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<page id="Regress.test_array_inout_callback"
+ type="topic"
+ style="function"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="index" group="function" type="guide"/>
+ <api:function>
+ <api:returns>
+ <api:type>int</api:type>
+ </api:returns>
+ <api:name>regress_test_array_inout_callback</api:name>
+ <api:arg>
+ <api:type>RegressTestCallbackArrayInOut</api:type>
+ <api:name>callback</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>regress_test_array_inout_callback</title>
+ <synopsis><code mime="text/x-csrc">
+int regress_test_array_inout_callback (RegressTestCallbackArrayInOut callback);
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>callback</code></title>
+
+</item>
+<item>
+<title><code>Returns</code></title>
+
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestCallbackArrayInOut.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestCallbackArrayInOut.page
new file mode 100644
index 00000000..8b77cbb1
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestCallbackArrayInOut.page
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<page id="Regress.TestCallbackArrayInOut"
+ type="topic"
+ style="callback"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="index" group="callback" type="guide"/>
+ </info>
+ <title>Regress.TestCallbackArrayInOut</title>
+ <synopsis><code mime="text/x-gjs">
+function onTestCallbackArrayInOut(ints: Array(Number(gint))): Array(Number(gint)) {
+}
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>Returns</code></title>
+
+</item>
+<item>
+<title><code>Returns (out)</code></title>
+
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_array_inout_callback.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_array_inout_callback.page
new file mode 100644
index 00000000..e02c96da
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_array_inout_callback.page
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<page id="Regress.test_array_inout_callback"
+ type="topic"
+ style="function"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="index" group="function" type="guide"/>
+ <api:function>
+ <api:returns>
+ <api:type>Number(gint)</api:type>
+ </api:returns>
+ <api:name>regress_test_array_inout_callback</api:name>
+ <api:arg>
+ <api:type>Regress.TestCallbackArrayInOut</api:type>
+ <api:name>callback</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>Regress.test_array_inout_callback</title>
+ <synopsis><code mime="text/x-gjs">
+function test_array_inout_callback(callback: <link xref="Regress.TestCallbackArrayInOut">Regress.TestCallbackArrayInOut</link>): Number(gint) {
+ // Gjs wrapper for regress_test_array_inout_callback()
+}
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>callback</code></title>
+
+</item>
+<item>
+<title><code>Returns</code></title>
+
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.TestCallbackArrayInOut.page b/tests/scanner/Regress-1.0-Python-expected/Regress.TestCallbackArrayInOut.page
new file mode 100644
index 00000000..0b4dd602
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Python-expected/Regress.TestCallbackArrayInOut.page
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<page id="Regress.TestCallbackArrayInOut"
+ type="topic"
+ style="callback"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="index" group="callback" type="guide"/>
+ </info>
+ <title>Regress.TestCallbackArrayInOut</title>
+ <synopsis><code mime="text/x-python">
+@accepts([int], int)
+@returns(none)
+def on_TestCallbackArrayInOut(ints, length):
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>ints</code></title>
+
+</item>
+<item>
+<title><code>length</code></title>
+
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.test_array_inout_callback.page b/tests/scanner/Regress-1.0-Python-expected/Regress.test_array_inout_callback.page
new file mode 100644
index 00000000..aea60c6a
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Python-expected/Regress.test_array_inout_callback.page
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<page id="Regress.test_array_inout_callback"
+ type="topic"
+ style="function"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="index" group="function" type="guide"/>
+ <api:function>
+ <api:returns>
+ <api:type>int</api:type>
+ </api:returns>
+ <api:name>regress_test_array_inout_callback</api:name>
+ <api:arg>
+ <api:type>Regress.TestCallbackArrayInOut</api:type>
+ <api:name>callback</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>Regress.test_array_inout_callback</title>
+ <synopsis><code mime="text/x-python">
+@accepts(Regress.TestCallbackArrayInOut)
+@returns(int)
+def test_array_inout_callback(callback):
+ # Python wrapper for regress_test_array_inout_callback()
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>callback</code></title>
+
+</item>
+<item>
+<title><code>Returns</code></title>
+{formatter.format(node, node.retval.doc)}
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 89ecaa45..a907b300 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -2313,6 +2313,28 @@ use it should be.</doc>
</parameter>
</parameters>
</callback>
+ <callback name="TestCallbackArrayInOut"
+ c:type="RegressTestCallbackArrayInOut">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="ints"
+ direction="inout"
+ caller-allocates="0"
+ transfer-ownership="full">
+ <array length="1" zero-terminated="0" c:type="int**">
+ <type name="gint" c:type="int*"/>
+ </array>
+ </parameter>
+ <parameter name="length"
+ direction="inout"
+ caller-allocates="0"
+ 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"/>
@@ -4977,6 +4999,18 @@ libgnome-keyring.</doc>
</parameter>
</parameters>
</function>
+ <function name="test_array_inout_callback"
+ c:identifier="regress_test_array_inout_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="TestCallbackArrayInOut"
+ c:type="RegressTestCallbackArrayInOut"/>
+ </parameter>
+ </parameters>
+ </function>
<function name="test_array_int_full_out"
c:identifier="regress_test_array_int_full_out">
<return-value transfer-ownership="full">
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index b42e0cd0..e60b8e17 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -3363,6 +3363,37 @@ int regress_test_array_callback (RegressTestCallbackArray callback)
}
/**
+ * regress_test_array_inout_callback:
+ * @callback: (scope call):
+ *
+ */
+int
+regress_test_array_inout_callback (RegressTestCallbackArrayInOut callback)
+{
+ int *ints;
+ int length;
+
+ ints = g_new (int, 5);
+ for (length = 0; length < 5; ++length)
+ ints[length] = length - 2;
+
+ callback (&ints, &length);
+
+ g_assert_cmpint (length, ==, 4);
+ for (length = 0; length < 4; ++length)
+ g_assert_cmpint (ints[length], ==, length - 1);
+
+ callback (&ints, &length);
+
+ g_assert_cmpint (length, ==, 3);
+ for (length = 0; length < 3; ++length)
+ g_assert_cmpint (ints[length], ==, length);
+
+ g_free (ints);
+ return length;
+}
+
+/**
* regress_test_simple_callback:
* @callback: (scope call) (allow-none):
*
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index 667f1298..3bbcb991 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -713,11 +713,18 @@ typedef int (*RegressTestCallbackFull) (int foo, double bar, char *path);
* @two_length:
*/
typedef int (*RegressTestCallbackArray) (int *one, gsize one_length, const char** two, int two_length);
+/**
+ * RegressTestCallbackArrayInOut:
+ * @ints: (inout) (array length=length):
+ * @length: (inout):
+ */
+typedef void (* RegressTestCallbackArrayInOut) (int **ints, int *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_array_inout_callback (RegressTestCallbackArrayInOut callback);
int regress_test_callback_user_data (RegressTestCallbackUserData callback,
gpointer user_data);
int regress_test_callback_destroy_notify (RegressTestCallbackUserData callback,