diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-12-12 14:37:56 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:18:34 -0300 |
commit | fb37b84fa723af8fa911910932090b6569589e0f (patch) | |
tree | 1714c7bf2fba9b217aa991606ca55323159d223f /tests/samplebinding | |
parent | 4f1b77a6310d77f521f484bbf567e7c75b9890ca (diff) |
Fix conversion for HANDLE type.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'tests/samplebinding')
-rw-r--r-- | tests/samplebinding/handle_conversions.h | 57 | ||||
-rw-r--r-- | tests/samplebinding/typesystem_sample.xml | 4 |
2 files changed, 2 insertions, 59 deletions
diff --git a/tests/samplebinding/handle_conversions.h b/tests/samplebinding/handle_conversions.h deleted file mode 100644 index 6e1093f6b..000000000 --- a/tests/samplebinding/handle_conversions.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _HANDLE_CONVERSION_H_ -#define _HANDLE_CONVERSION_H_ - - -namespace Shiboken { -template<> -struct Converter<HANDLE> -{ - static inline bool checkType(PyObject* pyObj) - { - return false; - } - - static inline bool isConvertible(PyObject* pyObj) - { - if (pyObj == Py_None) - return true; -#ifdef IS_PY3K - return PyCapsule_CheckExact(pyObj); -#else - return PyCObject_Check(pyObj); -#endif - } - - static inline PyObject* toPython(void* cppobj) - { - assert(true); - return 0; - } - - static inline PyObject* toPython(HANDLE cppobj) - { - if (!cppobj) - Py_RETURN_NONE; -#ifdef IS_PY3K - return PyCapsule_New(cppobj, 0, 0); -#else - return PyCObject_FromVoidPtr(cppobj, 0); -#endif - } - - static inline HANDLE toCpp(PyObject* pyobj) - { - if (pyobj == Py_None) - return (HANDLE) 0; - -#ifdef IS_PY3K - return (HANDLE) PyCapsule_GetPointer(pyobj, 0); -#else - return (HANDLE) PyCObject_AsVoidPtr(pyobj); -#endif - } -}; -} - - -#endif diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml index d1e4d1b21..d3ae3e4d1 100644 --- a/tests/samplebinding/typesystem_sample.xml +++ b/tests/samplebinding/typesystem_sample.xml @@ -66,7 +66,7 @@ <primitive-type name="HANDLE" target-lang-api-name="PyComplex"> <include file-name="handle.h" location="local"/> - <conversion-rule file="handle_conversions.h"> + <conversion-rule> <native-to-target> if (!%in) Py_RETURN_NONE; @@ -87,7 +87,7 @@ #else ptr = PyCObject_AsVoidPtr(%in); #endif - %out = *((%OUTTYPE*)ptr); + %out = (%OUTTYPE)ptr; </add-conversion> </target-to-native> </conversion-rule> |