diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-09-20 19:32:38 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:17:15 -0300 |
commit | 5d6f2193395afab85e444b61761484197d45a93c (patch) | |
tree | c8f56441aca76b2b076083b5c6bb3c89477fca15 | |
parent | a2d5bb825977e1f7952a89c64ed2e6e307ae1f78 (diff) |
Added SBK_PyString_FromCString and SBK_PyString_FromFormat as helper macro for Py3k port.
-rw-r--r-- | generator/cppgenerator.cpp | 2 | ||||
-rw-r--r-- | libshiboken/bindingmanager.cpp | 2 | ||||
-rw-r--r-- | libshiboken/sbkpython.h | 4 | ||||
-rw-r--r-- | tests/samplebinding/typesystem_sample.xml | 6 |
4 files changed, 9 insertions, 5 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp index ea4ab03c5..bdcf9f70e 100644 --- a/generator/cppgenerator.cpp +++ b/generator/cppgenerator.cpp @@ -1408,7 +1408,7 @@ void CppGenerator::writeErrorSection(QTextStream& s, OverloadData& overloadData) QString strArg; AbstractMetaType* argType = arg->type(); if (isCString(argType)) { - strArg = "str"; + strArg = "\"SBK_STR_NAME\""; } else if (argType->isPrimitive()) { const PrimitiveTypeEntry* ptp = reinterpret_cast<const PrimitiveTypeEntry*>(argType->typeEntry()); while (ptp->aliasedTypeEntry()) diff --git a/libshiboken/bindingmanager.cpp b/libshiboken/bindingmanager.cpp index 77a384b5f..15c478e88 100644 --- a/libshiboken/bindingmanager.cpp +++ b/libshiboken/bindingmanager.cpp @@ -241,7 +241,7 @@ PyObject* BindingManager::getOverride(const void* cptr, const char* methodName) } } - PyObject* pyMethodName = PyBytes_FromString(methodName); + PyObject* pyMethodName = SBK_PyString_FromCString(methodName); PyObject* method = PyObject_GetAttr((PyObject*)wrapper, pyMethodName); if (method && PyMethod_Check(method) diff --git a/libshiboken/sbkpython.h b/libshiboken/sbkpython.h index 007a378b7..28b320f0f 100644 --- a/libshiboken/sbkpython.h +++ b/libshiboken/sbkpython.h @@ -40,6 +40,8 @@ #define SBK_NB_BOOL(x) (x).nb_bool #define SBK_STR_NAME "bytes" #define SBK_PyMethod_New PyMethod_New + #define SBK_PyString_FromCString PyUnicode_FromString + #define SBK_PyString_FromFormat PyUnicode_FromFormat #else // Note: if there wasn't for the old-style classes, only a PyNumber_Check would suffice. #define SbkNumber_Check(X) \ @@ -47,6 +49,8 @@ #define SBK_NB_BOOL(x) (x).nb_nonzero #define SBK_STR_NAME "str" #define SBK_PyMethod_New(X, Y) PyMethod_New(X, Y, (PyObject*)Py_TYPE(Y)) + #define SBK_PyString_FromCString PyBytes_FromString + #define SBK_PyString_FromFormat PyString_FromFormat #endif #endif diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml index 1dae83e2d..a2b041a41 100644 --- a/tests/samplebinding/typesystem_sample.xml +++ b/tests/samplebinding/typesystem_sample.xml @@ -1219,7 +1219,7 @@ int x2 = ((int) (%CPPSELF.x() * 100)) - (x1 * 100); int y1 = (int) %CPPSELF.y(); int y2 = ((int) (%CPPSELF.y() * 100)) - (y1 * 100); - %PYARG_0 = PyBytes_FromFormat("Point(%d.%d, %d.%d)", x1, x2, y1, y2); + %PYARG_0 = SBK_PyString_FromFormat("Point(%d.%d, %d.%d)", x1, x2, y1, y2); </inject-code> </add-function> <add-function signature="__repr__" return-type="PyObject*"> @@ -1228,7 +1228,7 @@ int x2 = ((int) (%CPPSELF.x() * 10)) - (x1 * 10); int y1 = (int) %CPPSELF.y(); int y2 = ((int) (%CPPSELF.y() * 10)) - (y1 * 10); - %PYARG_0 = PyBytes_FromFormat("<Point object at %p: (%d.%d, %d.%d)>", %CPPSELF, x1, x2, y1, y2); + %PYARG_0 = SBK_PyString_FromFormat("<Point object at %p: (%d.%d, %d.%d)>", %CPPSELF, x1, x2, y1, y2); </inject-code> </add-function> @@ -1482,7 +1482,7 @@ <value-type name="Str" hash-function="strHash"> <add-function signature="__str__" return-type="PyObject*"> <inject-code class="target" position="beginning"> - %PYARG_0 = PyBytes_FromString(%CPPSELF.cstring()); + %PYARG_0 = SBK_PyString_FromCString(%CPPSELF.cstring()); </inject-code> </add-function> <add-function signature="__len__" > |