aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken/sbkconverter.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-11-06 12:59:25 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-11-06 13:26:37 +0100
commit06e4edac7133d322fe3398502396e1cd8afd8329 (patch)
treeba4427a92c4f1eac1963a428a03edf2c0cea4248 /sources/shiboken2/libshiboken/sbkconverter.h
parentf2063ee4737f90c5d412a9a328672fde32b033eb (diff)
parent764498b3d033a1c947a40dc1b2237e81b674992b (diff)
Merge remote-tracking branch 'origin/5.6' into 5.9
Diffstat (limited to 'sources/shiboken2/libshiboken/sbkconverter.h')
-rw-r--r--sources/shiboken2/libshiboken/sbkconverter.h33
1 files changed, 32 insertions, 1 deletions
diff --git a/sources/shiboken2/libshiboken/sbkconverter.h b/sources/shiboken2/libshiboken/sbkconverter.h
index 18b6bbcf3..6d40f85cc 100644
--- a/sources/shiboken2/libshiboken/sbkconverter.h
+++ b/sources/shiboken2/libshiboken/sbkconverter.h
@@ -361,7 +361,38 @@ template<> inline SbkConverter* PrimitiveTypeConverter<unsigned long>() { return
template<> inline SbkConverter* PrimitiveTypeConverter<unsigned short>() { return primitiveTypeConverter(SBK_UNSIGNEDSHORT_IDX); }
template<> inline SbkConverter* PrimitiveTypeConverter<void*>() { return primitiveTypeConverter(SBK_VOIDPTR_IDX); }
-} } // namespace Shiboken::Conversions
+} // namespace Shiboken::Conversions
+
+/**
+* This function template is used to get the PyTypeObject of a C++ type T.
+* All implementations should be provided by template specializations generated by the generator when
+* T isn't a C++ primitive type.
+* \see SpecialCastFunction
+*/
+template<typename T> PyTypeObject* SbkType() { return 0; }
+
+// Below are the template specializations for C++ primitive types.
+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<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; }
+
+} // namespace Shiboken
+
+// When the user adds a function with an argument unknown for the typesystem, the generator writes type checks as
+// TYPENAME_Check, so this macro allows users to add PyObject arguments to their added functions.
+#define PyObject_Check(X) true
+#define SbkChar_Check(X) (SbkNumber_Check(X) || Shiboken::String::checkChar(X))
struct _SbkGenericType { PyHeapTypeObject super; SbkConverter** converter; };
#define SBK_CONVERTER(pyType) (*reinterpret_cast<_SbkGenericType*>(pyType)->converter)