Fix compilation of conversion branch against Python3k.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
This commit is contained in:
parent
2a87b74bfe
commit
1af53541bf
2 changed files with 27 additions and 14 deletions
|
|
@ -170,6 +170,18 @@
|
||||||
<!-- FIXME This is a workaround to include some headers needed by some includes (nothing to do with QBool) -->
|
<!-- FIXME This is a workaround to include some headers needed by some includes (nothing to do with QBool) -->
|
||||||
<include file-name="QtConcurrentFilter" location="global"/>
|
<include file-name="QtConcurrentFilter" location="global"/>
|
||||||
</primitive-type>
|
</primitive-type>
|
||||||
|
|
||||||
|
<inject-code class="native" position="beginning">
|
||||||
|
bool py2kStrCheck(PyObject* obj)
|
||||||
|
{
|
||||||
|
#ifdef IS_PY3K
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return PyString_Check(obj);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
</inject-code>
|
||||||
|
|
||||||
<primitive-type name="QString" target-lang-api-name="PyUnicode">
|
<primitive-type name="QString" target-lang-api-name="PyUnicode">
|
||||||
<include file-name="QString" location="global"/>
|
<include file-name="QString" location="global"/>
|
||||||
<conversion-rule file="qstring_conversions.h">
|
<conversion-rule file="qstring_conversions.h">
|
||||||
|
|
@ -191,9 +203,11 @@
|
||||||
%out = QString::fromUtf16(unicode, PyUnicode_GET_SIZE(%in));
|
%out = QString::fromUtf16(unicode, PyUnicode_GET_SIZE(%in));
|
||||||
#endif
|
#endif
|
||||||
</add-conversion>
|
</add-conversion>
|
||||||
<add-conversion type="PyString">
|
<add-conversion type="PyString" check="py2kStrCheck(%in)">
|
||||||
|
#ifndef IS_PY3K
|
||||||
const char* str = %CONVERTTOCPP[const char*](%in);
|
const char* str = %CONVERTTOCPP[const char*](%in);
|
||||||
%out = %OUTTYPE(str);
|
%out = %OUTTYPE(str);
|
||||||
|
#endif
|
||||||
</add-conversion>
|
</add-conversion>
|
||||||
<add-conversion type="Py_None">
|
<add-conversion type="Py_None">
|
||||||
%out = %OUTTYPE();
|
%out = %OUTTYPE();
|
||||||
|
|
@ -214,7 +228,7 @@
|
||||||
return %out;
|
return %out;
|
||||||
</native-to-target>
|
</native-to-target>
|
||||||
<target-to-native>
|
<target-to-native>
|
||||||
<add-conversion type="PyObject" check="PyUnicode_Check(%in)||PyString_Check(%in)||%in == Py_None">
|
<add-conversion type="PyObject" check="Shiboken::String::check(%in) || %in == Py_None">
|
||||||
%out = %OUTTYPE();
|
%out = %OUTTYPE();
|
||||||
</add-conversion>
|
</add-conversion>
|
||||||
</target-to-native>
|
</target-to-native>
|
||||||
|
|
@ -227,7 +241,7 @@
|
||||||
return PyUnicode_FromWideChar(&c, 1);
|
return PyUnicode_FromWideChar(&c, 1);
|
||||||
</native-to-target>
|
</native-to-target>
|
||||||
<target-to-native>
|
<target-to-native>
|
||||||
<add-conversion type="PyString" check="PyString_Check(%in) && PyString_Size(%in) == 1">
|
<add-conversion type="PyString" check="Shiboken::String::checkChar(%in)">
|
||||||
char c = %CONVERTTOCPP[char](%in);
|
char c = %CONVERTTOCPP[char](%in);
|
||||||
%out = %OUTTYPE(c);
|
%out = %OUTTYPE(c);
|
||||||
</add-conversion>
|
</add-conversion>
|
||||||
|
|
@ -455,7 +469,7 @@
|
||||||
</add-conversion>
|
</add-conversion>
|
||||||
<add-conversion type="PyTypeObject">
|
<add-conversion type="PyTypeObject">
|
||||||
const char* typeName;
|
const char* typeName;
|
||||||
if (%in == (PyObject*)&PyString_Type || %in == (PyObject*)&PyUnicode_Type)
|
if (Shiboken::String::checkType((PyTypeObject*)%in))
|
||||||
typeName = "QString";
|
typeName = "QString";
|
||||||
else if (%in == (PyObject*)&PyFloat_Type)
|
else if (%in == (PyObject*)&PyFloat_Type)
|
||||||
typeName = "double"; // float is a UserType in QVariant.
|
typeName = "double"; // float is a UserType in QVariant.
|
||||||
|
|
@ -467,11 +481,8 @@
|
||||||
typeName = ((PyTypeObject*)%in)->tp_name;
|
typeName = ((PyTypeObject*)%in)->tp_name;
|
||||||
%out = QVariant::nameToType(typeName);
|
%out = QVariant::nameToType(typeName);
|
||||||
</add-conversion>
|
</add-conversion>
|
||||||
<add-conversion type="PyString">
|
<add-conversion type="PyString" check="Shiboken::String::check(%in)">
|
||||||
%out = QVariant::nameToType(PyString_AS_STRING(%in));
|
%out = QVariant::nameToType(Shiboken::String::toCString(%in));
|
||||||
</add-conversion>
|
|
||||||
<add-conversion type="PyUnicode">
|
|
||||||
%out = QVariant::nameToType(PyString_AsString(%in));
|
|
||||||
</add-conversion>
|
</add-conversion>
|
||||||
<add-conversion type="PyDict" check="PyDict_Check(%in) && QVariantType_checkAllStringKeys(%in)">
|
<add-conversion type="PyDict" check="PyDict_Check(%in) && QVariantType_checkAllStringKeys(%in)">
|
||||||
%out = QVariant::nameToType("QVariantMap");
|
%out = QVariant::nameToType("QVariantMap");
|
||||||
|
|
@ -2257,8 +2268,13 @@
|
||||||
<add-conversion type="Py_None">
|
<add-conversion type="Py_None">
|
||||||
%out = %OUTTYPE();
|
%out = %OUTTYPE();
|
||||||
</add-conversion>
|
</add-conversion>
|
||||||
<add-conversion type="PyString">
|
<add-conversion type="PyString" check="Shiboken::String::check(%in)">
|
||||||
%out = %OUTTYPE(PyString_AS_STRING(%in), PyString_GET_SIZE(%in));
|
%out = %OUTTYPE(Shiboken::String::toCString(%in), Shiboken::String::len(%in));
|
||||||
|
</add-conversion>
|
||||||
|
<add-conversion type="PyBytes">
|
||||||
|
#ifdef IS_PY3K
|
||||||
|
%out = %OUTTYPE(PyBytes_AS_STRING(%in), PyBytes_GET_SIZE(%in));
|
||||||
|
#endif
|
||||||
</add-conversion>
|
</add-conversion>
|
||||||
</target-to-native>
|
</target-to-native>
|
||||||
</conversion-rule>
|
</conversion-rule>
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,6 @@ class QVariantTypeTest(unittest.TestCase):
|
||||||
f = QSqlField("name", str)
|
f = QSqlField("name", str)
|
||||||
self.assertEqual(f.type(), py3k.unicode)
|
self.assertEqual(f.type(), py3k.unicode)
|
||||||
|
|
||||||
f = QSqlField("name", str)
|
|
||||||
self.assertEqual(f.type(), py3k.unicode)
|
|
||||||
|
|
||||||
f = QSqlField("name", "QString")
|
f = QSqlField("name", "QString")
|
||||||
self.assertEqual(f.type(), py3k.unicode)
|
self.assertEqual(f.type(), py3k.unicode)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue