From 1af53541bf90b74c350d83507932fd694a5c0283 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Mon, 5 Dec 2011 20:02:07 -0200 Subject: Fix compilation of conversion branch against Python3k. Reviewer: Marcelo Lira --- PySide/QtCore/typesystem_core.xml | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'PySide') diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index c441bf298..23763194c 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -170,6 +170,18 @@ + + + bool py2kStrCheck(PyObject* obj) + { + #ifdef IS_PY3K + return false; + #else + return PyString_Check(obj); + #endif + } + + @@ -191,9 +203,11 @@ %out = QString::fromUtf16(unicode, PyUnicode_GET_SIZE(%in)); #endif - + + #ifndef IS_PY3K const char* str = %CONVERTTOCPP[const char*](%in); %out = %OUTTYPE(str); + #endif %out = %OUTTYPE(); @@ -214,7 +228,7 @@ return %out; - + %out = %OUTTYPE(); @@ -227,7 +241,7 @@ return PyUnicode_FromWideChar(&c, 1); - + char c = %CONVERTTOCPP[char](%in); %out = %OUTTYPE(c); @@ -455,7 +469,7 @@ const char* typeName; - if (%in == (PyObject*)&PyString_Type || %in == (PyObject*)&PyUnicode_Type) + if (Shiboken::String::checkType((PyTypeObject*)%in)) typeName = "QString"; else if (%in == (PyObject*)&PyFloat_Type) typeName = "double"; // float is a UserType in QVariant. @@ -467,11 +481,8 @@ typeName = ((PyTypeObject*)%in)->tp_name; %out = QVariant::nameToType(typeName); - - %out = QVariant::nameToType(PyString_AS_STRING(%in)); - - - %out = QVariant::nameToType(PyString_AsString(%in)); + + %out = QVariant::nameToType(Shiboken::String::toCString(%in)); %out = QVariant::nameToType("QVariantMap"); @@ -2257,8 +2268,13 @@ %out = %OUTTYPE(); - - %out = %OUTTYPE(PyString_AS_STRING(%in), PyString_GET_SIZE(%in)); + + %out = %OUTTYPE(Shiboken::String::toCString(%in), Shiboken::String::len(%in)); + + + #ifdef IS_PY3K + %out = %OUTTYPE(PyBytes_AS_STRING(%in), PyBytes_GET_SIZE(%in)); + #endif -- cgit v1.2.3