summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2016-02-06 20:59:11 -0800
committerPhilip Chimento <philip.chimento@gmail.com>2016-02-07 20:48:17 -0800
commitb20ac732d096c1140d856d99f4cf64f6c708de50 (patch)
treeb9ffcd72dda0abd1a67d966a3fe9b1dd8e3247ec
parentc2f0c7bce052af6107dfe676b956b60550786c56 (diff)
downloadgobject-introspection-b20ac732d096c1140d856d99f4cf64f6c708de50.tar.gz
tests: Add regression test for out array of struct
This is a regression test for returning out arrays of structs, like gdk_keymap_get_entries_for_keyval() for example. https://bugzilla.gnome.org/show_bug.cgi?id=761658
-rw-r--r--tests/scanner/Regress-1.0-C-expected/Regress.test_array_struct_out.page47
-rw-r--r--tests/scanner/Regress-1.0-Gjs-expected/Regress.test_array_struct_out.page32
-rw-r--r--tests/scanner/Regress-1.0-Python-expected/Regress.test_array_struct_out.page45
-rw-r--r--tests/scanner/Regress-1.0-expected.gir23
-rw-r--r--tests/scanner/Regress-1.0-sections-expected.txt1
-rw-r--r--tests/scanner/regress.c17
-rw-r--r--tests/scanner/regress.h3
7 files changed, 168 insertions, 0 deletions
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.test_array_struct_out.page b/tests/scanner/Regress-1.0-C-expected/Regress.test_array_struct_out.page
new file mode 100644
index 00000000..84aee10f
--- /dev/null
+++ b/tests/scanner/Regress-1.0-C-expected/Regress.test_array_struct_out.page
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<page id="Regress.test_array_struct_out"
+ 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>void</api:type>
+ </api:returns>
+ <api:name>regress_test_array_struct_out</api:name>
+ <api:arg>
+ <api:type>RegressTestStructA**</api:type>
+ <api:name>arr</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>int*</api:type>
+ <api:name>len</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>regress_test_array_struct_out</title>
+ <synopsis><code mime="text/x-csrc">
+void regress_test_array_struct_out (RegressTestStructA** arr,
+ int* len);
+ </code></synopsis>
+<p>This is similar to gdk_keymap_get_entries_for_keyval().</p>
+
+<terms>
+<item>
+<title><code>arr</code></title>
+
+</item>
+<item>
+<title><code>len</code></title>
+
+</item>
+<item>
+<title><code>Returns</code></title>
+
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_array_struct_out.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_array_struct_out.page
new file mode 100644
index 00000000..46c7c13c
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_array_struct_out.page
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<page id="Regress.test_array_struct_out"
+ 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>void</api:type>
+ </api:returns>
+ <api:name>regress_test_array_struct_out</api:name>
+ </api:function>
+ </info>
+ <title>Regress.test_array_struct_out</title>
+ <synopsis><code mime="text/x-gjs">
+function test_array_struct_out(): Array(<link xref="Regress.TestStructA">Regress.TestStructA</link>) {
+ // Gjs wrapper for regress_test_array_struct_out()
+}
+ </code></synopsis>
+<p>This is similar to gdk_keymap_get_entries_for_keyval().</p>
+
+<terms>
+<item>
+<title><code>Returns</code></title>
+
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.test_array_struct_out.page b/tests/scanner/Regress-1.0-Python-expected/Regress.test_array_struct_out.page
new file mode 100644
index 00000000..5ca13632
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Python-expected/Regress.test_array_struct_out.page
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<page id="Regress.test_array_struct_out"
+ 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>none</api:type>
+ </api:returns>
+ <api:name>regress_test_array_struct_out</api:name>
+ <api:arg>
+ <api:type>[Regress.TestStructA]</api:type>
+ <api:name>arr</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>int</api:type>
+ <api:name>len</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>Regress.test_array_struct_out</title>
+ <synopsis><code mime="text/x-python">
+@accepts([Regress.TestStructA], int)
+@returns(none)
+def test_array_struct_out(arr, len):
+ # Python wrapper for regress_test_array_struct_out()
+ </code></synopsis>
+<p>This is similar to gdk_keymap_get_entries_for_keyval().</p>
+
+<terms>
+<item>
+<title><code>arr</code></title>
+
+</item>
+<item>
+<title><code>len</code></title>
+
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 06aff1d4..321a7c60 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -5291,6 +5291,29 @@ libgnome-keyring.</doc>
</parameter>
</parameters>
</function>
+ <function name="test_array_struct_out"
+ c:identifier="regress_test_array_struct_out">
+ <doc xml:space="preserve">This is similar to gdk_keymap_get_entries_for_keyval().</doc>
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="arr"
+ direction="out"
+ caller-allocates="0"
+ transfer-ownership="full">
+ <array length="1" zero-terminated="0" c:type="RegressTestStructA**">
+ <type name="TestStructA" c:type="RegressTestStructA*"/>
+ </array>
+ </parameter>
+ <parameter name="len"
+ direction="out"
+ caller-allocates="0"
+ transfer-ownership="full">
+ <type name="gint" c:type="int*"/>
+ </parameter>
+ </parameters>
+ </function>
<function name="test_async_ready_callback"
c:identifier="regress_test_async_ready_callback">
<return-value transfer-ownership="none">
diff --git a/tests/scanner/Regress-1.0-sections-expected.txt b/tests/scanner/Regress-1.0-sections-expected.txt
index c7ba75c6..26ace9ab 100644
--- a/tests/scanner/Regress-1.0-sections-expected.txt
+++ b/tests/scanner/Regress-1.0-sections-expected.txt
@@ -73,6 +73,7 @@ regress_test_array_int_none_out
regress_test_array_int_null_in
regress_test_array_int_null_out
regress_test_array_int_out
+regress_test_array_struct_out
regress_test_async_ready_callback
regress_test_boolean
regress_test_boolean_false
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index fa481054..6eac6f7b 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -1740,6 +1740,23 @@ regress_test_struct_a_parse (RegressTestStructA *a_out,
}
/**
+ * regress_test_array_struct_out:
+ * @arr: (out) (array length=len) (transfer full):
+ * @len: (out)
+ *
+ * This is similar to gdk_keymap_get_entries_for_keyval().
+ */
+void
+regress_test_array_struct_out (RegressTestStructA **arr, int *len)
+{
+ *arr = g_new0(RegressTestStructA, 3);
+ (*arr)[0].some_int = 22;
+ (*arr)[1].some_int = 33;
+ (*arr)[2].some_int = 44;
+ *len = 3;
+}
+
+/**
* regress_test_struct_b_clone:
* @b: the structure
* @b_out: (out): the cloned structure
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index 99cd3112..780f8e21 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -541,6 +541,9 @@ void regress_test_struct_a_clone (RegressTestStructA *a,
_GI_TEST_EXTERN
void regress_test_struct_a_parse (RegressTestStructA *a_out, const gchar *string);
+_GI_TEST_EXTERN
+void regress_test_array_struct_out (RegressTestStructA **arr, int *len);
+
struct _RegressTestStructB
{
gint8 some_int8;