summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2015-11-06 12:42:11 +0100
committerPhilip Withnall <philip.withnall@collabora.co.uk>2015-11-06 12:45:04 +0100
commitd8e257464bd93ea502740169887297fa62925a16 (patch)
treef43cd0266e2413ff5ea85dc1fb9ae523d27f7ab6
parent54a5ed77c9c1296c7709c80428dc41d535999798 (diff)
downloadgobject-introspection-d8e257464bd93ea502740169887297fa62925a16.tar.gz
tests: Add more regression tests for (not nullable)
On bug #719966, the question arose of whether parameters annotated with (element-type) but not (not nullable) are regarded as nullable or non-nullable. Add some new unit tests to Regress-1.0.gir to check the behaviour is as expected: annotating a parameter with (element-type) implicitly makes it non-nullable (unless also annotated with (nullable)). https://bugzilla.gnome.org/show_bug.cgi?id=757678
-rw-r--r--giscanner/maintransformer.py1
-rw-r--r--tests/scanner/Regress-1.0-C-expected/Regress.TestObj.not_nullable_element_typed_gpointer_in.page56
-rw-r--r--tests/scanner/Regress-1.0-C-expected/Regress.TestObj.not_nullable_typed_gpointer_in.page47
-rw-r--r--tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.not_nullable_element_typed_gpointer_in.page36
-rw-r--r--tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.not_nullable_typed_gpointer_in.page36
-rw-r--r--tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.not_nullable_element_typed_gpointer_in.page53
-rw-r--r--tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.not_nullable_typed_gpointer_in.page45
-rw-r--r--tests/scanner/Regress-1.0-expected.gir38
-rw-r--r--tests/scanner/Regress-1.0-sections-expected.txt2
-rw-r--r--tests/scanner/regress.c24
-rw-r--r--tests/scanner/regress.h7
11 files changed, 345 insertions, 0 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index b4b39345..23ed4102 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -649,6 +649,7 @@ class MainTransformer(object):
# gpointer parameters and return values are always nullable unless:
# - annotated with (type) and not also with (nullable); or
+ # - annotated with (element-type) and not also with (nullable); or
# - annotated (not nullable)
# See: https://bugzilla.gnome.org/show_bug.cgi?id=719966#c22
if node.type.is_equiv(ast.TYPE_ANY):
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestObj.not_nullable_element_typed_gpointer_in.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj.not_nullable_element_typed_gpointer_in.page
new file mode 100644
index 00000000..ddc90078
--- /dev/null
+++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj.not_nullable_element_typed_gpointer_in.page
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj.not_nullable_element_typed_gpointer_in"
+ type="topic"
+ style="method"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="Regress.TestObj" group="method" type="guide"/>
+ <api:function>
+ <api:returns>
+ <api:type>void</api:type>
+ </api:returns>
+ <api:name>regress_test_obj_not_nullable_element_typed_gpointer_in</api:name>
+ <api:arg>
+ <api:type>RegressTestObj*</api:type>
+ <api:name>obj</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>guint8*</api:type>
+ <api:name>input</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>guint</api:type>
+ <api:name>count</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>regress_test_obj_not_nullable_element_typed_gpointer_in</title>
+ <synopsis><code mime="text/x-csrc">
+void regress_test_obj_not_nullable_element_typed_gpointer_in (RegressTestObj* obj,
+ guint8* input,
+ guint count);
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>obj</code></title>
+ <p>A <link xref="Regress.TestObj"/></p>
+</item>
+<item>
+<title><code>input</code></title>
+ <p>some uint8 array</p>
+</item>
+<item>
+<title><code>count</code></title>
+ <p>length of <code>input</code></p>
+</item>
+<item>
+<title><code>Returns</code></title>
+
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestObj.not_nullable_typed_gpointer_in.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj.not_nullable_typed_gpointer_in.page
new file mode 100644
index 00000000..7e04ac54
--- /dev/null
+++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj.not_nullable_typed_gpointer_in.page
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj.not_nullable_typed_gpointer_in"
+ type="topic"
+ style="method"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="Regress.TestObj" group="method" type="guide"/>
+ <api:function>
+ <api:returns>
+ <api:type>void</api:type>
+ </api:returns>
+ <api:name>regress_test_obj_not_nullable_typed_gpointer_in</api:name>
+ <api:arg>
+ <api:type>RegressTestObj*</api:type>
+ <api:name>obj</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>gpointer</api:type>
+ <api:name>input</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>regress_test_obj_not_nullable_typed_gpointer_in</title>
+ <synopsis><code mime="text/x-csrc">
+void regress_test_obj_not_nullable_typed_gpointer_in (RegressTestObj* obj,
+ gpointer input);
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>obj</code></title>
+ <p>A <link xref="Regress.TestObj"/></p>
+</item>
+<item>
+<title><code>input</code></title>
+ <p>some <link href="../GObject-2.0/GObject.Object.html">GObject.Object</link></p>
+</item>
+<item>
+<title><code>Returns</code></title>
+
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.not_nullable_element_typed_gpointer_in.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.not_nullable_element_typed_gpointer_in.page
new file mode 100644
index 00000000..d14a4ad5
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.not_nullable_element_typed_gpointer_in.page
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj.not_nullable_element_typed_gpointer_in"
+ type="topic"
+ style="method"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="Regress.TestObj" group="method" type="guide"/>
+ <api:function>
+ <api:returns>
+ <api:type>void</api:type>
+ </api:returns>
+ <api:name>regress_test_obj_not_nullable_element_typed_gpointer_in</api:name>
+ <api:arg>
+ <api:type>ByteArray</api:type>
+ <api:name>input</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>Regress.TestObj.prototype.not_nullable_element_typed_gpointer_in</title>
+ <synopsis><code mime="text/x-gjs">
+function not_nullable_element_typed_gpointer_in(input: ByteArray): void {
+ // Gjs wrapper for regress_test_obj_not_nullable_element_typed_gpointer_in()
+}
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>input</code></title>
+ <p>some uint8 array</p>
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.not_nullable_typed_gpointer_in.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.not_nullable_typed_gpointer_in.page
new file mode 100644
index 00000000..eac06e1b
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.not_nullable_typed_gpointer_in.page
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj.not_nullable_typed_gpointer_in"
+ type="topic"
+ style="method"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="Regress.TestObj" group="method" type="guide"/>
+ <api:function>
+ <api:returns>
+ <api:type>void</api:type>
+ </api:returns>
+ <api:name>regress_test_obj_not_nullable_typed_gpointer_in</api:name>
+ <api:arg>
+ <api:type>GObject.Object</api:type>
+ <api:name>input</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>Regress.TestObj.prototype.not_nullable_typed_gpointer_in</title>
+ <synopsis><code mime="text/x-gjs">
+function not_nullable_typed_gpointer_in(input: <link href="../GObject-2.0/GObject.Object.html">GObject.Object</link>): void {
+ // Gjs wrapper for regress_test_obj_not_nullable_typed_gpointer_in()
+}
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>input</code></title>
+ <p>some <link href="../GObject-2.0/GObject.Object.html">GObject.Object</link></p>
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.not_nullable_element_typed_gpointer_in.page b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.not_nullable_element_typed_gpointer_in.page
new file mode 100644
index 00000000..4f60d9df
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.not_nullable_element_typed_gpointer_in.page
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj.not_nullable_element_typed_gpointer_in"
+ type="topic"
+ style="method"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="Regress.TestObj" group="method" type="guide"/>
+ <api:function>
+ <api:returns>
+ <api:type>none</api:type>
+ </api:returns>
+ <api:name>regress_test_obj_not_nullable_element_typed_gpointer_in</api:name>
+ <api:arg>
+ <api:type>Regress.TestObj</api:type>
+ <api:name>self</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>[guint8]</api:type>
+ <api:name>input</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>int</api:type>
+ <api:name>count</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>Regress.TestObj.not_nullable_element_typed_gpointer_in</title>
+ <synopsis><code mime="text/x-python">
+@accepts(Regress.TestObj, [guint8], int)
+@returns(none)
+def not_nullable_element_typed_gpointer_in(self, input, count):
+ # Python wrapper for regress_test_obj_not_nullable_element_typed_gpointer_in()
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>self</code></title>
+ <p>A <link xref="Regress.TestObj"/></p>
+</item>
+<item>
+<title><code>input</code></title>
+ <p>some uint8 array</p>
+</item>
+<item>
+<title><code>count</code></title>
+ <p>length of <code>input</code></p>
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.not_nullable_typed_gpointer_in.page b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.not_nullable_typed_gpointer_in.page
new file mode 100644
index 00000000..eb0a23f7
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.not_nullable_typed_gpointer_in.page
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj.not_nullable_typed_gpointer_in"
+ type="topic"
+ style="method"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="Regress.TestObj" group="method" type="guide"/>
+ <api:function>
+ <api:returns>
+ <api:type>none</api:type>
+ </api:returns>
+ <api:name>regress_test_obj_not_nullable_typed_gpointer_in</api:name>
+ <api:arg>
+ <api:type>Regress.TestObj</api:type>
+ <api:name>self</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>GObject.Object</api:type>
+ <api:name>input</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>Regress.TestObj.not_nullable_typed_gpointer_in</title>
+ <synopsis><code mime="text/x-python">
+@accepts(Regress.TestObj, GObject.Object)
+@returns(none)
+def not_nullable_typed_gpointer_in(self, input):
+ # Python wrapper for regress_test_obj_not_nullable_typed_gpointer_in()
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>self</code></title>
+ <p>A <link xref="Regress.TestObj"/></p>
+</item>
+<item>
+<title><code>input</code></title>
+ <p>some <link href="../GObject-2.0/GObject.Object.html">GObject.Object</link></p>
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 6f991b78..06aff1d4 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -3151,6 +3151,44 @@ case.</doc>
</instance-parameter>
</parameters>
</method>
+ <method name="not_nullable_element_typed_gpointer_in"
+ c:identifier="regress_test_obj_not_nullable_element_typed_gpointer_in">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <instance-parameter name="obj" transfer-ownership="none">
+ <doc xml:space="preserve">A #RegressTestObj</doc>
+ <type name="TestObj" c:type="RegressTestObj*"/>
+ </instance-parameter>
+ <parameter name="input" transfer-ownership="none">
+ <doc xml:space="preserve">some uint8 array</doc>
+ <array length="1" zero-terminated="0" c:type="gpointer">
+ <type name="guint8"/>
+ </array>
+ </parameter>
+ <parameter name="count" transfer-ownership="none">
+ <doc xml:space="preserve">length of @input</doc>
+ <type name="guint" c:type="guint"/>
+ </parameter>
+ </parameters>
+ </method>
+ <method name="not_nullable_typed_gpointer_in"
+ c:identifier="regress_test_obj_not_nullable_typed_gpointer_in">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <instance-parameter name="obj" transfer-ownership="none">
+ <doc xml:space="preserve">A #RegressTestObj</doc>
+ <type name="TestObj" c:type="RegressTestObj*"/>
+ </instance-parameter>
+ <parameter name="input" transfer-ownership="none">
+ <doc xml:space="preserve">some #GObject</doc>
+ <type name="GObject.Object" c:type="gpointer"/>
+ </parameter>
+ </parameters>
+ </method>
<method name="set_bare" c:identifier="regress_test_obj_set_bare">
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
diff --git a/tests/scanner/Regress-1.0-sections-expected.txt b/tests/scanner/Regress-1.0-sections-expected.txt
index e0f9a1b7..c7ba75c6 100644
--- a/tests/scanner/Regress-1.0-sections-expected.txt
+++ b/tests/scanner/Regress-1.0-sections-expected.txt
@@ -343,6 +343,8 @@ regress_forced_method
regress_test_obj_instance_method
regress_test_obj_instance_method_callback
regress_test_obj_instance_method_full
+regress_test_obj_not_nullable_element_typed_gpointer_in
+regress_test_obj_not_nullable_typed_gpointer_in
regress_test_obj_set_bare
regress_test_obj_skip_inout_param
regress_test_obj_skip_out_param
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index 9a9ee679..fa481054 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -3042,6 +3042,30 @@ regress_func_obj_nullable_in (RegressTestObj *obj)
}
/**
+ * regress_test_obj_not_nullable_typed_gpointer_in:
+ * @obj: A #RegressTestObj
+ * @input: (type GObject): some #GObject
+ */
+void
+regress_test_obj_not_nullable_typed_gpointer_in (RegressTestObj *obj,
+ gpointer input)
+{
+}
+
+/**
+ * regress_test_obj_not_nullable_element_typed_gpointer_in:
+ * @obj: A #RegressTestObj
+ * @input: (element-type guint8) (array length=count): some uint8 array
+ * @count: length of @input
+ */
+void
+regress_test_obj_not_nullable_element_typed_gpointer_in (RegressTestObj *obj,
+ gpointer input,
+ guint count)
+{
+}
+
+/**
* regress_test_array_fixed_out_objects:
* @objs: (out) (array fixed-size=2) (transfer full): An array of #RegressTestObj
*/
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index d77a7a97..99cd3112 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -927,6 +927,13 @@ void regress_test_obj_null_out (RegressTestObj **obj);
void regress_func_obj_nullable_in (RegressTestObj *obj);
+void regress_test_obj_not_nullable_typed_gpointer_in (RegressTestObj *obj,
+ gpointer input);
+
+void regress_test_obj_not_nullable_element_typed_gpointer_in (RegressTestObj *obj,
+ gpointer input,
+ guint count);
+
/* inheritance */
#define REGRESS_TEST_TYPE_SUB_OBJ (regress_test_sub_obj_get_type ())
#define REGRESS_TEST_SUB_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), REGRESS_TEST_TYPE_SUB_OBJ, RegressTestSubObj))