aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/tests/minimalbinding/typesystem_minimal.xml
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-05-22 17:50:30 +0200
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-05-22 18:20:59 +0200
commit9c333ade1a1b694fc6ce22e483f5de3e952c17ad (patch)
treed3a2e41de3501f91ebfdc8ec81a80156597c2585 /sources/shiboken2/tests/minimalbinding/typesystem_minimal.xml
parent8f3761d8eac7780393382ab54dbdb487eb4df027 (diff)
move everying into sources/shiboken2 (5.9 edition)
in preparation for a subtree merge. this should not be necessary to do in a separate commit, but git is a tad stupid about following history correctly without it.
Diffstat (limited to 'sources/shiboken2/tests/minimalbinding/typesystem_minimal.xml')
-rw-r--r--sources/shiboken2/tests/minimalbinding/typesystem_minimal.xml93
1 files changed, 93 insertions, 0 deletions
diff --git a/sources/shiboken2/tests/minimalbinding/typesystem_minimal.xml b/sources/shiboken2/tests/minimalbinding/typesystem_minimal.xml
new file mode 100644
index 000000000..968b27c53
--- /dev/null
+++ b/sources/shiboken2/tests/minimalbinding/typesystem_minimal.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+<typesystem package="minimal">
+ <primitive-type name="bool"/>
+ <primitive-type name="int"/>
+
+ <primitive-type name="MinBool" target-lang-api-name="PyBool" default-constructor="MinBool(false)">
+ <include file-name="minbool.h" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ return PyBool_FromLong(%in.value());
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyBool" check="PyBool_Check(%in)">
+ %out = %OUTTYPE(%in == Py_True);
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
+ <container-type name="std::list" type="list">
+ <include file-name="list" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ PyObject* %out = PyList_New((int) %in.size());
+ %INTYPE::const_iterator it = %in.begin();
+ for (int idx = 0; it != %in.end(); ++it, ++idx) {
+ %INTYPE_0 cppItem(*it);
+ PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[%INTYPE_0](cppItem));
+ }
+ return %out;
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PySequence">
+ Shiboken::AutoDecRef seq(PySequence_Fast(%in, 0));
+ for (int i = 0; i &lt; PySequence_Fast_GET_SIZE(seq.object()); i++) {
+ PyObject* pyItem = PySequence_Fast_GET_ITEM(seq.object(), i);
+ %OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem);
+ %out.push_back(cppItem);
+ }
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+
+ <object-type name="Obj"/>
+ <value-type name="Val">
+ <enum-type name="ValEnum"/>
+ </value-type>
+ <value-type name="ListUser"/>
+ <value-type name="MinBoolUser"/>
+
+ <container-type name="std::vector" type="vector">
+ <include file-name="vector" location="global"/>
+ <conversion-rule>
+ <native-to-target>
+ %INTYPE::size_type vectorSize = %in.size();
+ PyObject* %out = PyList_New((int) vectorSize);
+ for (%INTYPE::size_type idx = 0; idx &lt; vectorSize; ++idx) {
+ %INTYPE_0 cppItem(%in[idx]);
+ PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[%INTYPE_0](cppItem));
+ }
+ return %out;
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PySequence">
+ Shiboken::AutoDecRef seq(PySequence_Fast(%in, 0));
+ int vectorSize = PySequence_Fast_GET_SIZE(seq.object());
+ %out.reserve(vectorSize);
+ for (int idx = 0; idx &lt; vectorSize; ++idx ) {
+ PyObject* pyItem = PySequence_Fast_GET_ITEM(seq.object(), idx);
+ %OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem);
+ %out.push_back(cppItem);
+ }
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </container-type>
+ <!-- Test wrapping of a typedef -->
+ <function signature="arrayFuncInt(std::vector&lt;int&gt;)" />
+ <!-- Note manual expansion of the typedef -->
+ <function signature="arrayFuncIntTypedef(std::vector&lt;int&gt;)" />
+
+ <function signature="arrayFuncIntReturn(int)" />
+ <function signature="arrayFuncIntReturnTypedef(int)" />
+
+ <!-- Test wrapping of a typedef of a typedef -->
+ <function signature="arrayFunc(std::vector&lt;int&gt;)" />
+ <!-- Note manual expansion of the typedef -->
+ <function signature="arrayFuncTypedef(std::vector&lt;int&gt;)" />
+
+ <function signature="arrayFuncReturn(int)" />
+ <function signature="arrayFuncReturnTypedef(int)" />
+</typesystem>