aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-02-27 10:54:01 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-03-20 09:37:04 +0100
commit667cb4a4ee3fac1cd818b9689886470c1dffdac9 (patch)
treeb7a152d307d74c356f9fe327259c146a3cd6a782 /sources
parent58a7066609938c04f5d5214a326d6220e8c062e0 (diff)
shiboken6: Test opaque container for span
Task-number: PYSIDE-2174 Change-Id: I812bef400ef2a006eb6aaca749d8961dc3aa7330 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources')
-rw-r--r--sources/shiboken6/tests/libminimal/spanuser.cpp6
-rw-r--r--sources/shiboken6/tests/libminimal/spanuser.h1
-rw-r--r--sources/shiboken6/tests/minimalbinding/spanuser_test.py9
-rw-r--r--sources/shiboken6/tests/minimalbinding/typesystem_minimal.xml15
4 files changed, 30 insertions, 1 deletions
diff --git a/sources/shiboken6/tests/libminimal/spanuser.cpp b/sources/shiboken6/tests/libminimal/spanuser.cpp
index e2e1ca1f5..fea9cd68e 100644
--- a/sources/shiboken6/tests/libminimal/spanuser.cpp
+++ b/sources/shiboken6/tests/libminimal/spanuser.cpp
@@ -35,6 +35,12 @@ ConstIntSpan3 SpanUser::getConstIntSpan3()
return ConstIntSpan3(civ);
}
+IntSpan3 SpanUser::getIntSpan3_OpaqueContainer()
+{
+ static int iv[] = {1, 2, 3};
+ return IntSpan3(iv);
+}
+
int SpanUser::sumIntSpan3(IntSpan3 isp3)
{
return std::accumulate(isp3.begin(), isp3.end(), 0);
diff --git a/sources/shiboken6/tests/libminimal/spanuser.h b/sources/shiboken6/tests/libminimal/spanuser.h
index 810aa9f84..c78ba35e7 100644
--- a/sources/shiboken6/tests/libminimal/spanuser.h
+++ b/sources/shiboken6/tests/libminimal/spanuser.h
@@ -24,6 +24,7 @@ struct LIBMINIMAL_API SpanUser
static IntSpan3 getIntSpan3();
static IntSpan getIntSpan();
static ConstIntSpan3 getConstIntSpan3();
+ static IntSpan3 getIntSpan3_OpaqueContainer();
static int sumIntSpan3(IntSpan3 isp3);
static int sumIntSpan(IntSpan isp);
diff --git a/sources/shiboken6/tests/minimalbinding/spanuser_test.py b/sources/shiboken6/tests/minimalbinding/spanuser_test.py
index 8473ad6af..6db6aa616 100644
--- a/sources/shiboken6/tests/minimalbinding/spanuser_test.py
+++ b/sources/shiboken6/tests/minimalbinding/spanuser_test.py
@@ -28,6 +28,15 @@ class IntSpanTest(unittest.TestCase):
self.assertEqual(SpanUser.sumIntSpan(expected), 6)
self.assertEqual(SpanUser.sumConstIntSpan3(expected), 6)
+ def testSpanOpaqueContainer(self):
+ if not SpanUser.enabled():
+ return
+ oc = SpanUser.getIntSpan3_OpaqueContainer() # 1,2,3
+ oc[1] = 10
+ oc = SpanUser.getIntSpan3_OpaqueContainer()
+ # note: This converts to std::vector
+ self.assertEqual(SpanUser.sumIntSpan3(oc), 14)
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken6/tests/minimalbinding/typesystem_minimal.xml b/sources/shiboken6/tests/minimalbinding/typesystem_minimal.xml
index ef317f415..e18bf8686 100644
--- a/sources/shiboken6/tests/minimalbinding/typesystem_minimal.xml
+++ b/sources/shiboken6/tests/minimalbinding/typesystem_minimal.xml
@@ -21,6 +21,10 @@
<opaque-container name="std::array" opaque-containers="int,3:StdIntArray"/>
+ <?if c++20?> <!-- FIXME PYSIDE 7: Remove "if" -->
+ <opaque-container name="std::span" opaque-containers="int,3:StdIntSpan3"/>
+ <?endif?>
+
<object-type name="Obj"/>
<value-type name="Val">
<enum-type name="ValEnum"/>
@@ -38,7 +42,16 @@
</modify-argument>
</modify-function>
</value-type>
- <value-type name="SpanUser"/>
+
+ <value-type name="SpanUser">
+ <?if c++20?> <!-- FIXME PYSIDE 7: Remove "if" -->
+ <modify-function signature="getIntSpan3_OpaqueContainer()">
+ <modify-argument index="return">
+ <replace-type modified-type="StdIntSpan3"/>
+ </modify-argument>
+ </modify-function>
+ <?endif?>
+ </value-type>
<value-type name="MinBoolUser"/>