diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-03-01 08:19:26 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-03-01 08:19:26 +0100 |
commit | 639c5df6ad397ba98ca727c744278372087b2d46 (patch) | |
tree | 31e84eab330cb8a0a1f1236c85c8fad968918ceb /sources/shiboken2/tests/smartbinding/typesystem_smart.xml | |
parent | b97ccab8c268d260f704e11b33d64fa31f74e258 (diff) | |
parent | 099f3f46ca9ec1362f211278df4b3e4949b0a339 (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I0f3c2de6195b863dc60ecbb988e4e14182e3ad03
Diffstat (limited to 'sources/shiboken2/tests/smartbinding/typesystem_smart.xml')
-rw-r--r-- | sources/shiboken2/tests/smartbinding/typesystem_smart.xml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sources/shiboken2/tests/smartbinding/typesystem_smart.xml b/sources/shiboken2/tests/smartbinding/typesystem_smart.xml index b2deb18cb..aea1c2f73 100644 --- a/sources/shiboken2/tests/smartbinding/typesystem_smart.xml +++ b/sources/shiboken2/tests/smartbinding/typesystem_smart.xml @@ -5,6 +5,36 @@ <primitive-type name="float" /> <primitive-type name="bool" /> + <template name="cpplist_to_pylist_convertion"> + PyObject *%out = PyList_New(int(%in.size())); + int idx = 0; + for (const auto &cppItem : %in) + PyList_SET_ITEM(%out, idx++, %CONVERTTOPYTHON[%INTYPE_0](cppItem)); + return %out; + </template> + <template name="pyseq_to_cpplist_convertion"> + Shiboken::AutoDecRef seq(PySequence_Fast(%in, 0)); + for (int i = 0, size = PySequence_Fast_GET_SIZE(seq.object()); i < size; ++i) { + PyObject* pyItem = PySequence_Fast_GET_ITEM(seq.object(), i); + %OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem); + %out.push_back(cppItem); + } + </template> + <container-type name="std::vector" type="list"> + <include file-name="list" location="global"/> + <conversion-rule> + <native-to-target> + <insert-template name="cpplist_to_pylist_convertion"/> + </native-to-target> + <target-to-native> + <add-conversion type="PySequence"> + <insert-template name="pyseq_to_cpplist_convertion"/> + </add-conversion> + </target-to-native> + </conversion-rule> + </container-type> + + <!-- Used in tests to check what C++ objects are allocated. --> <object-type name="Registry" /> |