diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-11-06 12:59:25 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-11-06 13:26:37 +0100 |
commit | 06e4edac7133d322fe3398502396e1cd8afd8329 (patch) | |
tree | ba4427a92c4f1eac1963a428a03edf2c0cea4248 /sources/shiboken2/libshiboken/sbkconverter_p.h | |
parent | f2063ee4737f90c5d412a9a328672fde32b033eb (diff) | |
parent | 764498b3d033a1c947a40dc1b2237e81b674992b (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.9
Change-Id: I72583df407fc5b3caa8bf35fd997889a4ac86512
Diffstat (limited to 'sources/shiboken2/libshiboken/sbkconverter_p.h')
-rw-r--r-- | sources/shiboken2/libshiboken/sbkconverter_p.h | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/sources/shiboken2/libshiboken/sbkconverter_p.h b/sources/shiboken2/libshiboken/sbkconverter_p.h index fd1f7b6b2..cfe3d7e98 100644 --- a/sources/shiboken2/libshiboken/sbkconverter_p.h +++ b/sources/shiboken2/libshiboken/sbkconverter_p.h @@ -215,22 +215,6 @@ struct OverFlowChecker<float, PY_LONG_LONG, true> : }; // Basic primitive type converters --------------------------------------------------------- -template<typename T> PyTypeObject* SbkType() { return 0; } -template<> inline PyTypeObject* SbkType<PY_LONG_LONG>() { return &PyLong_Type; } -template<> inline PyTypeObject* SbkType<bool>() { return &PyBool_Type; } -template<> inline PyTypeObject* SbkType<char>() { return &PyInt_Type; } -template<> inline PyTypeObject* SbkType<const char*>() { return &PyString_Type; } -template<> inline PyTypeObject* SbkType<double>() { return &PyFloat_Type; } -template<> inline PyTypeObject* SbkType<float>() { return &PyFloat_Type; } -template<> inline PyTypeObject* SbkType<int>() { return &PyInt_Type; } -template<> inline PyTypeObject* SbkType<long>() { return &PyLong_Type; } -template<> inline PyTypeObject* SbkType<short>() { return &PyInt_Type; } -template<> inline PyTypeObject* SbkType<signed char>() { return &PyInt_Type; } -template<> inline PyTypeObject* SbkType<unsigned PY_LONG_LONG>() { return &PyLong_Type; } -template<> inline PyTypeObject* SbkType<unsigned char>() { return &PyInt_Type; } -template<> inline PyTypeObject* SbkType<unsigned int>() { return &PyLong_Type; } -template<> inline PyTypeObject* SbkType<unsigned long>() { return &PyLong_Type; } -template<> inline PyTypeObject* SbkType<unsigned short>() { return &PyInt_Type; } template <typename T> struct Primitive {}; @@ -242,8 +226,11 @@ struct OnePrimitive static void toCpp(PyObject*, void*) {} static SbkConverter* createConverter() { - SbkConverter* converter = Shiboken::Conversions::createConverter(SbkType<T>(), Primitive<T>::toPython); - Shiboken::Conversions::addPythonToCppValueConversion(converter, Primitive<T>::toCpp, Primitive<T>::isConvertible); + SbkConverter* converter = Shiboken::Conversions::createConverter(Shiboken::SbkType<T>(), + Primitive<T>::toPython); + Shiboken::Conversions::addPythonToCppValueConversion(converter, + Primitive<T>::toCpp, + Primitive<T>::isConvertible); return converter; } }; @@ -546,31 +533,6 @@ struct Primitive<std::string> : TwoPrimitive<std::string> } }; -// Void pointer ---------------------------------------------------------------------------- - -template <> -struct Primitive<void*> : OnePrimitive<void*> -{ - static PyObject* toPython(const void* cppIn) - { - SbkDbg() << cppIn; - if (!cppIn) - Py_RETURN_NONE; - PyObject *result = reinterpret_cast<PyObject *>(const_cast<void *>(cppIn)); - Py_INCREF(result); - return result; - } - static void toCpp(PyObject* pyIn, void* cppOut) - { - SbkDbg() << pyIn; - *reinterpret_cast<void **>(cppOut) = pyIn; - } - static PythonToCppFunc isConvertible(PyObject *) - { - return toCpp; - } -}; - namespace Shiboken { namespace Conversions { SbkConverter *createConverterObject(PyTypeObject *type, @@ -580,5 +542,4 @@ SbkConverter *createConverterObject(PyTypeObject *type, CppToPythonFunc copyToPythonFunc); } // namespace Conversions } // namespace Shiboken - #endif // SBK_CONVERTER_P_H |