diff options
Diffstat (limited to 'PySide/QtCore/qchar_conversions.h')
-rw-r--r-- | PySide/QtCore/qchar_conversions.h | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/PySide/QtCore/qchar_conversions.h b/PySide/QtCore/qchar_conversions.h index 6347c9311..ab477efc8 100644 --- a/PySide/QtCore/qchar_conversions.h +++ b/PySide/QtCore/qchar_conversions.h @@ -1,30 +1,30 @@ namespace Shiboken { -inline bool Shiboken::Converter<QChar >::isConvertible(PyObject* pyObj) -{ - return PyObject_TypeCheck(pyObj, SbkType<QChar>()) - || SbkPySide_QtCore_QChar_SpecialCharacter_Check(pyObj) - || SbkQLatin1Char_Check(pyObj) - || (PyString_Check(pyObj) && (PyString_Size(pyObj) == 1)) - || PyInt_Check(pyObj); -} -inline QChar Shiboken::Converter<QChar >::toCpp(PyObject* pyObj) +template<> +class Converter<QChar> { - if (!Shiboken_TypeCheck(pyObj, QChar)) { - if (SbkPySide_QtCore_QChar_SpecialCharacter_Check(pyObj)) - return QChar(Shiboken::Converter<QChar::SpecialCharacter >::toCpp(pyObj)); - else if (SbkQLatin1Char_Check(pyObj)) - return QChar(Shiboken::Converter<QLatin1Char >::toCpp(pyObj)); - else if (PyString_Check(pyObj) && PyString_Size(pyObj) == 1) +public: + static bool isConvertible(PyObject* pyObj) + { + return (PyString_Check(pyObj) && (PyString_Size(pyObj) == 1)) + || PyInt_Check(pyObj); + } + + static QChar toCpp(PyObject* pyObj) + { + if (PyString_Check(pyObj) && PyString_Size(pyObj) == 1) return QChar(Shiboken::Converter<char >::toCpp(pyObj)); else if (PyInt_Check(pyObj)) return QChar(Shiboken::Converter<int >::toCpp(pyObj)); + return QChar(); } - return *Converter<QChar*>::toCpp(pyObj); -} -inline PyObject* Converter<QChar>::toPython(const QChar& cppObj) -{ - return ValueTypeConverter<QChar>::toPython(cppObj); -} + static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<QChar*>(cppObj)); } + static PyObject* toPython(const QChar& cppObj) + { + wchar_t c = (wchar_t)cppObj.unicode(); + PyObject* pyObj = PyUnicode_FromWideChar(&c, 1); + return pyObj; + } +}; } |