diff options
Diffstat (limited to 'sources/shiboken6')
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"/> |