diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-10-21 16:12:43 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-08 08:14:26 +0100 |
commit | 5bfcf4b6613a364ee13d0cb5e865bb6582ab7dbb (patch) | |
tree | ff1d2f21854d8aaa036aa900730610c6061687a9 /sources/shiboken6/tests/minimalbinding | |
parent | a7a8138bae00ef1aecafed04a8ac265a9c6f07ff (diff) |
shiboken6: Add predefined templates for standard container type conversion
Add some predefined XML templates with common conversions for
various container types (STL and Qt) and PyLong.
Remove the primitive type QModelIndexList since QModelIndexList is
just a typedef.
As a drive-by:
- Fix a bug in cppmultihash_to_pymap_conversion
which would not handle multiple keys correctly (insert
several times due to iterator kit not moved past the range).
- Simplify the pySequenceToCppContainer conversion by
using PyIter_Next().
[ChangeLog][shiboken6] Pre-defined XML templates for
standard container type conversion have been added.
Task-number: PYSIDE-1666
Change-Id: Ic2e36a75f26853651718e27e0788a37519393322
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'sources/shiboken6/tests/minimalbinding')
-rw-r--r-- | sources/shiboken6/tests/minimalbinding/typesystem_minimal.xml | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/sources/shiboken6/tests/minimalbinding/typesystem_minimal.xml b/sources/shiboken6/tests/minimalbinding/typesystem_minimal.xml index 9bb7e7b7e..7dd0a3a50 100644 --- a/sources/shiboken6/tests/minimalbinding/typesystem_minimal.xml +++ b/sources/shiboken6/tests/minimalbinding/typesystem_minimal.xml @@ -20,23 +20,11 @@ <include file-name="list" location="global"/> <conversion-rule> <native-to-target> - PyObject* %out = PyList_New(Py_ssize_t(%in.size())); - Py_ssize_t idx = 0; - for (auto it = %in.cbegin(), end = %in.cend(); it != end; ++it, ++idx) { - %INTYPE_0 cppItem(*it); - PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[%INTYPE_0](cppItem)); - } - return %out; + <insert-template name="shiboken_conversion_cppsequence_to_pylist"/> </native-to-target> <target-to-native> <add-conversion type="PySequence"> - Shiboken::AutoDecRef seq(PySequence_Fast(%in, 0)); - const Py_ssize_t size = PySequence_Fast_GET_SIZE(seq.object()); - for (Py_ssize_t i = 0; i < size; ++i) { - PyObject* pyItem = PySequence_Fast_GET_ITEM(seq.object(), i); - %OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem); - %out.push_back(cppItem); - } + <insert-template name="shiboken_conversion_pyiterable_to_cppsequentialcontainer"/> </add-conversion> </target-to-native> </conversion-rule> |