aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/smartbinding/typesystem_smart.xml
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/tests/smartbinding/typesystem_smart.xml')
-rw-r--r--sources/shiboken6/tests/smartbinding/typesystem_smart.xml57
1 files changed, 57 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/smartbinding/typesystem_smart.xml b/sources/shiboken6/tests/smartbinding/typesystem_smart.xml
new file mode 100644
index 000000000..46cb08267
--- /dev/null
+++ b/sources/shiboken6/tests/smartbinding/typesystem_smart.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<typesystem package="smart">
+ <primitive-type name="int" />
+ <primitive-type name="char" />
+ <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 &amp;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 &lt; 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>
+
+ <custom-type name="std::shared_ptr" />
+
+ <!-- Used in tests to check what C++ objects are allocated. -->
+ <object-type name="Registry" />
+
+ <!-- Current limitation: shared pointer python objects can only be instantiated from API usage,
+ like when they are returned as a result of a method, or passed as arguments. It is not
+ possible to explicitly instantiate a new shared pointer in python e.g. o = SharedPtr_Foo()
+ won't work.
+ -->
+ <smart-pointer-type name="SharedPtr" type="shared" getter="data" ref-count-method="useCount"
+ instantiations="Integer,Smart::Integer2,Obj"/>
+
+ <object-type name="Obj" />
+ <value-type name="Integer" />
+ <namespace-type name="Smart" generate="no">
+ <value-type name="Integer2" />
+ </namespace-type>
+ <!-- Just used to silence the warnings that shiboken doens't know what to do with this type -->
+ <custom-type name="RefData" />
+</typesystem>