blob: ab477efc843df10ad2c7235a6ac2b8eda2ad253b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
namespace Shiboken {
template<>
class Converter<QChar>
{
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();
}
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;
}
};
}
|