diff options
author | Hugo Lima <hugo.lima@openbossa.org> | 2009-12-16 15:14:16 -0200 |
---|---|---|
committer | Hugo Lima <hugo.lima@openbossa.org> | 2009-12-16 15:39:12 -0200 |
commit | 41ecfb5863ff4242f49d20071d3ea872caffc9df (patch) | |
tree | f2899a06610ba526d9c3391e6d6f724f77603939 /libshiboken | |
parent | 0133a99f71e88c9e0642f05a7d55ef798275260a (diff) |
Added template specializations for SbkType<T> when T is a primitive type.
Diffstat (limited to 'libshiboken')
-rw-r--r-- | libshiboken/conversions.h | 86 |
1 files changed, 81 insertions, 5 deletions
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h index 93d777fcd..8faad93b9 100644 --- a/libshiboken/conversions.h +++ b/libshiboken/conversions.h @@ -49,15 +49,91 @@ namespace Shiboken { /** -* This function template is used to get the PyObjectType of a C++ type T. -* It's main usage is to handle multiple inheritance casts. +* 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> -inline PyTypeObject* SbkType() +PyTypeObject* SbkType(); + +template<> +inline PyTypeObject* SbkType<int>() +{ + return &PyInt_Type; +} + +template<> +inline PyTypeObject* SbkType<unsigned int>() +{ + return &PyLong_Type; +} + +template<> +inline PyTypeObject* SbkType<short>() +{ + return &PyInt_Type; +} + +template<> +inline PyTypeObject* SbkType<unsigned short>() +{ + return &PyInt_Type; +} + +template<> +inline PyTypeObject* SbkType<long>() +{ + return &PyLong_Type; +} + +template<> +inline PyTypeObject* SbkType<unsigned long>() +{ + return &PyLong_Type; +} + + +template<> +inline PyTypeObject* SbkType<long long>() +{ + return &PyLong_Type; +} + +template<> +inline PyTypeObject* SbkType<unsigned long long>() +{ + return &PyLong_Type; +} + +template<> +inline PyTypeObject* SbkType<bool>() +{ + return &PyBool_Type; +} + +template<> +inline PyTypeObject* SbkType<float>() +{ + return &PyFloat_Type; +} + +template<> +inline PyTypeObject* SbkType<double>() +{ + return &PyFloat_Type; +} + +template<> +inline PyTypeObject* SbkType<char>() +{ + return &PyInt_Type; +} + +template<> +inline PyTypeObject* SbkType<unsigned char>() { - assert(false); // This *SHOULD* never be called. - return 0; + return &PyInt_Type; } /** |