aboutsummaryrefslogtreecommitdiffstats
path: root/tests/samplebinding
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-10-13 17:29:54 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:18:28 -0300
commit6e4789d62120ac99bc6abbd96ae1cd4cf378baaa (patch)
tree786cf229bdb64adb148ad90de23b1b6a0ac5ed12 /tests/samplebinding
parent59ed4b9d8952615d59614ba7b8e1ad51df433a84 (diff)
Added a test for a typedef of a pointer to a struct.
This is only a compilation test, no Python test was provided.
Diffstat (limited to 'tests/samplebinding')
-rw-r--r--tests/samplebinding/CMakeLists.txt1
-rw-r--r--tests/samplebinding/primitivestructpointer_conversions.h30
-rw-r--r--tests/samplebinding/typesystem_sample.xml15
3 files changed, 46 insertions, 0 deletions
diff --git a/tests/samplebinding/CMakeLists.txt b/tests/samplebinding/CMakeLists.txt
index 59163ac8a..4322c3dd9 100644
--- a/tests/samplebinding/CMakeLists.txt
+++ b/tests/samplebinding/CMakeLists.txt
@@ -67,6 +67,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/point_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/pointf_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/pointerholder_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/polygon_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/primitivestructpointerholder_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/privatector_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/privatedtor_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/protectedenumclass_wrapper.cpp
diff --git a/tests/samplebinding/primitivestructpointer_conversions.h b/tests/samplebinding/primitivestructpointer_conversions.h
new file mode 100644
index 000000000..9e1d27678
--- /dev/null
+++ b/tests/samplebinding/primitivestructpointer_conversions.h
@@ -0,0 +1,30 @@
+namespace Shiboken {
+template <>
+struct Converter<PrimitiveStructPtr>
+{
+ static bool checkType(PyObject* pyObj)
+ {
+ return false;
+ }
+
+ static bool isConvertible(PyObject* pyobj)
+ {
+ return PyCObject_Check(pyobj);
+ }
+
+ static inline PyObject* toPython(void* cppobj)
+ {
+ return 0;
+ }
+
+ static PyObject* toPython(PrimitiveStructPtr cppobj)
+ {
+ return PyCObject_FromVoidPtr(cppobj, 0);
+ }
+
+ static PrimitiveStructPtr toCpp(PyObject* pyobj)
+ {
+ return (PrimitiveStructPtr) PyCObject_AsVoidPtr(pyobj);
+ }
+};
+}
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index ae24245fc..22848c4b3 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -78,6 +78,20 @@
</conversion-rule>
</primitive-type>
+ <primitive-type name="PrimitiveStructPtr">
+ <include file-name="handle.h" location="local"/>
+ <conversion-rule file="primitivestructpointer_conversions.h">
+ <native-to-target>
+ return PyCObject_FromVoidPtr(&amp;%in, 0);
+ </native-to-target>
+ <target-to-native>
+ <add-conversion type="PyCObject">
+ %out = *((%OUTTYPE*)PyCObject_AsVoidPtr(%in));
+ </add-conversion>
+ </target-to-native>
+ </conversion-rule>
+ </primitive-type>
+
<primitive-type name="OddBool" target-lang-api-name="PyBool" default-constructor="OddBool(false)">
<include file-name="oddbool.h" location="global"/>
<include file-name="complex.h" location="global"/>
@@ -2066,6 +2080,7 @@
</value-type>
<object-type name="HandleHolder" />
+ <value-type name="PrimitiveStructPointerHolder" />
<object-type name="ObjectTypeOperators">
<add-function signature="operator!=(std::string)" return-type="bool">