[gobject-introspection] tests: Add more regression tests for (not nullable)
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] tests: Add more regression tests for (not nullable)
- Date: Fri, 6 Nov 2015 14:32:00 +0000 (UTC)
commit d8e257464bd93ea502740169887297fa62925a16
Author: Philip Withnall <philip withnall collabora co uk>
Date: Fri Nov 6 12:42:11 2015 +0100
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
giscanner/maintransformer.py | 1 +
...Obj.not_nullable_element_typed_gpointer_in.page | 56 ++++++++++++++++++++
...ess.TestObj.not_nullable_typed_gpointer_in.page | 47 ++++++++++++++++
...Obj.not_nullable_element_typed_gpointer_in.page | 36 +++++++++++++
...ess.TestObj.not_nullable_typed_gpointer_in.page | 36 +++++++++++++
...Obj.not_nullable_element_typed_gpointer_in.page | 53 ++++++++++++++++++
...ess.TestObj.not_nullable_typed_gpointer_in.page | 45 ++++++++++++++++
tests/scanner/Regress-1.0-expected.gir | 38 +++++++++++++
tests/scanner/Regress-1.0-sections-expected.txt | 2 +
tests/scanner/regress.c | 24 ++++++++
tests/scanner/regress.h | 7 +++
11 files changed, 345 insertions(+), 0 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index b4b3934..23ed410 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 0000000..ddc9007
--- /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 0000000..7e04ac5
--- /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 0000000..d14a4ad
--- /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 0000000..eac06e1
--- /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 0000000..4f60d9d
--- /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 0000000..eb0a23f
--- /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 6f991b7..06aff1d 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 e0f9a1b..c7ba75c 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 9a9ee67..fa48105 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 d77a7a9..99cd311 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))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]