|
|
@ -752,7 +752,6 @@ PyObject *PyTQt_tqt_PyObject_FromTQString(const TQString *tqstr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PyObject *obj;
|
|
|
|
PyObject *obj;
|
|
|
|
|
|
|
|
|
|
|
|
#if PY_VERSION_HEX >= 0x03030000
|
|
|
|
|
|
|
|
// We have to work out exactly which kind to use. We assume ASCII while we
|
|
|
|
// We have to work out exactly which kind to use. We assume ASCII while we
|
|
|
|
// are checking so that we only go through the string once in the most
|
|
|
|
// are checking so that we only go through the string once in the most
|
|
|
|
// common case. Note that we can't use PyUnicode_FromKindAndData() because
|
|
|
|
// common case. Note that we can't use PyUnicode_FromKindAndData() because
|
|
|
@ -787,24 +786,6 @@ PyObject *PyTQt_tqt_PyObject_FromTQString(const TQString *tqstr)
|
|
|
|
Py_UCS4 uch = tqstr->at(tqt_i).unicode();
|
|
|
|
Py_UCS4 uch = tqstr->at(tqt_i).unicode();
|
|
|
|
PyUnicode_WRITE(kind, data, tqt_i, uch);
|
|
|
|
PyUnicode_WRITE(kind, data, tqt_i, uch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#elif defined(Py_UNICODE_WIDE)
|
|
|
|
|
|
|
|
// Note that this doesn't handle code points greater than 0xffff. It could
|
|
|
|
|
|
|
|
// but it's only an issue for old versions of TQt.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((obj = PyUnicode_FromUnicode(NULL, tqstr->length())) == NULL)
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Py_UNICODE *pyu = PyUnicode_AS_UNICODE(obj);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < tqstr->length(); ++i)
|
|
|
|
|
|
|
|
*pyu++ = (tqstr->at(i)).unicode();
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
if ((obj = PyUnicode_FromUnicode(NULL, tqstr->length())) == NULL)
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(PyUnicode_AS_UNICODE(obj), tqstr->ucs2(),
|
|
|
|
|
|
|
|
tqstr->length() * sizeof (Py_UNICODE));
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -821,7 +802,6 @@ TQString *PyTQt_tqt_PyObject_AsTQString(PyObject *obj)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (PyUnicode_Check(obj))
|
|
|
|
if (PyUnicode_Check(obj))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#if PY_VERSION_HEX >= 0x03030000
|
|
|
|
|
|
|
|
SIP_SSIZE_T len = PyUnicode_GET_LENGTH(obj);
|
|
|
|
SIP_SSIZE_T len = PyUnicode_GET_LENGTH(obj);
|
|
|
|
|
|
|
|
|
|
|
|
switch (PyUnicode_KIND(obj))
|
|
|
|
switch (PyUnicode_KIND(obj))
|
|
|
@ -848,21 +828,6 @@ TQString *PyTQt_tqt_PyObject_AsTQString(PyObject *obj)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
#else
|
|
|
|
|
|
|
|
TQString *tqstr = new TQString;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ifdef Py_UNICODE_WIDE
|
|
|
|
|
|
|
|
Py_UNICODE *ucode = PyUnicode_AS_UNICODE(obj);
|
|
|
|
|
|
|
|
SIP_SSIZE_T len = PyUnicode_GET_SIZE(obj);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (SIP_SSIZE_T i = 0; i < len; ++i)
|
|
|
|
|
|
|
|
tqstr->append(TQChar((uint)ucode[i]));
|
|
|
|
|
|
|
|
# else
|
|
|
|
|
|
|
|
tqstr->setUnicodeCodes((ushort *)PyUnicode_AS_UNICODE(obj),PyUnicode_GET_SIZE(obj));
|
|
|
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return tqstr;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (PyBytes_Check(obj))
|
|
|
|
else if (PyBytes_Check(obj))
|
|
|
|
{
|
|
|
|
{
|
|
|
|