summaryrefslogtreecommitdiffstats
path: root/libpyside
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-10-03 18:49:42 -0300
committerRenato Filho <renato.filho@openbossa.org>2011-10-06 15:43:31 -0300
commit5525de20d99808f4092d9dc264d3324496e68e55 (patch)
treec57f3da67d2edeea1bf76996267a1817a7bcdbb5 /libpyside
parenta50b4fb08a4a0d2d823b2a1b9361f4d5642f92a1 (diff)
downloadpyside-5525de20d99808f4092d9dc264d3324496e68e55.tar.gz
pyside-5525de20d99808f4092d9dc264d3324496e68e55.tar.xz
pyside-5525de20d99808f4092d9dc264d3324496e68e55.zip
Initia QtCore port to python3.
Diffstat (limited to 'libpyside')
-rw-r--r--libpyside/CMakeLists.txt2
-rw-r--r--libpyside/dynamicqmetaobject.cpp10
-rw-r--r--libpyside/globalreceiver.cpp9
-rw-r--r--libpyside/globalreceiverv2.cpp6
-rw-r--r--libpyside/pyside.cpp10
-rw-r--r--libpyside/pysideclassinfo.cpp7
-rw-r--r--libpyside/pysideconversions.h24
-rw-r--r--libpyside/pysidemetafunction.cpp3
-rw-r--r--libpyside/pysideproperty.cpp5
-rw-r--r--libpyside/pysidesignal.cpp32
-rw-r--r--libpyside/pysideslot.cpp9
-rw-r--r--libpyside/pysideweakref.cpp7
-rw-r--r--libpyside/signalmanager.cpp36
13 files changed, 100 insertions, 60 deletions
diff --git a/libpyside/CMakeLists.txt b/libpyside/CMakeLists.txt
index c6dd033..4fa878f 100644
--- a/libpyside/CMakeLists.txt
+++ b/libpyside/CMakeLists.txt
@@ -14,6 +14,7 @@ set(libpyside_SRC
pysidesignal.cpp
pysideslot.cpp
pysideproperty.cpp
+ pysideqflags.cpp
pysideweakref.cpp
pyside.cpp
${DESTROYLISTENER_MOC}
@@ -51,6 +52,7 @@ set(libpyside_HEADERS
pysidemetafunction.h
pysidesignal.h
pysideproperty.h
+ pysideqflags.h
pysideweakref.h
)
diff --git a/libpyside/dynamicqmetaobject.cpp b/libpyside/dynamicqmetaobject.cpp
index ec9b8bd..996ba3a 100644
--- a/libpyside/dynamicqmetaobject.cpp
+++ b/libpyside/dynamicqmetaobject.cpp
@@ -476,17 +476,17 @@ void DynamicQMetaObject::parsePythonType(PyTypeObject* type)
typedef std::pair<const char*, PyObject*> PropPair;
QLinkedList<PropPair> properties;
- Shiboken::AutoDecRef slotAttrName(PyString_FromString(PYSIDE_SLOT_LIST_ATTR));
+ Shiboken::AutoDecRef slotAttrName(Shiboken::String::fromCString(PYSIDE_SLOT_LIST_ATTR));
while (PyDict_Next(attrs, &pos, &key, &value)) {
if (Property::checkType(value)) {
// Leave the properties to be register after signals because they may depend on notify signals
- int index = d.superdata->indexOfProperty(PyString_AS_STRING(key));
+ int index = d.superdata->indexOfProperty(Shiboken::String::toCString(key));
if (index == -1)
- properties << PropPair(PyString_AS_STRING(key), value);
+ properties << PropPair(Shiboken::String::toCString(key), value);
} else if (Signal::checkType(value)) { // Register signals
PySideSignal* data = reinterpret_cast<PySideSignal*>(value);
- const char* signalName = PyString_AS_STRING(key);
+ const char* signalName = Shiboken::String::toCString(key);
data->signalName = strdup(signalName);
QByteArray sig;
sig.reserve(128);
@@ -504,7 +504,7 @@ void DynamicQMetaObject::parsePythonType(PyTypeObject* type)
PyObject* signatureList = PyObject_GetAttr(value, slotAttrName);
for(Py_ssize_t i = 0, i_max = PyList_Size(signatureList); i < i_max; ++i) {
PyObject* signature = PyList_GET_ITEM(signatureList, i);
- QByteArray sig(PyString_AS_STRING(signature));
+ QByteArray sig(Shiboken::String::toCString(signature));
//slot the slot type and signature
QList<QByteArray> slotInfo = sig.split(' ');
int index = d.superdata->indexOfSlot(slotInfo[1]);
diff --git a/libpyside/globalreceiver.cpp b/libpyside/globalreceiver.cpp
index 17f0090..05d5e4d 100644
--- a/libpyside/globalreceiver.cpp
+++ b/libpyside/globalreceiver.cpp
@@ -75,7 +75,12 @@ DynamicSlotData::DynamicSlotData(int id, PyObject* callback, GlobalReceiver* par
//Can not store calback pointe because this will be destroyed at the end of the scope
//To avoid increment intance reference keep the callback information
m_callback = PyMethod_GET_FUNCTION(callback);
+#ifdef IS_PY3K
+ m_pyClass = 0;
+#else
m_pyClass = PyMethod_GET_CLASS(callback);
+#endif
+
m_pythonSelf = PyMethod_GET_SELF(callback);
//monitor class from method lifetime
@@ -92,7 +97,11 @@ PyObject* DynamicSlotData::call(PyObject* args)
//create a callback based on method data
if (m_isMethod)
+#ifdef IS_PY3K
+ callback = PyMethod_New(callback, m_pythonSelf);
+#else
callback = PyMethod_New(callback, m_pythonSelf, m_pyClass);
+#endif
PyObject* result = PyObject_CallObject(callback, args);
diff --git a/libpyside/globalreceiverv2.cpp b/libpyside/globalreceiverv2.cpp
index 748332f..cfcf477 100644
--- a/libpyside/globalreceiverv2.cpp
+++ b/libpyside/globalreceiverv2.cpp
@@ -83,7 +83,9 @@ DynamicSlotDataV2::DynamicSlotDataV2(PyObject* callback, GlobalReceiverV2* paren
//Can not store calback pointe because this will be destroyed at the end of the scope
//To avoid increment intance reference keep the callback information
m_callback = PyMethod_GET_FUNCTION(callback);
+#ifndef IS_PY3K
m_pyClass = PyMethod_GET_CLASS(callback);
+#endif
m_pythonSelf = PyMethod_GET_SELF(callback);
//monitor class from method lifetime
@@ -121,7 +123,11 @@ PyObject* DynamicSlotDataV2::callback()
//create a callback based on method data
if (m_isMethod)
+#ifdef IS_PY3K
+ callback = PyMethod_New(m_callback, m_pythonSelf);
+#else
callback = PyMethod_New(m_callback, m_pythonSelf, m_pyClass);
+#endif
else
Py_INCREF(callback);
diff --git a/libpyside/pyside.cpp b/libpyside/pyside.cpp
index 0eb1e7a..eb6b9b9 100644
--- a/libpyside/pyside.cpp
+++ b/libpyside/pyside.cpp
@@ -68,8 +68,8 @@ bool fillQtProperties(PyObject* qObj, const QMetaObject* metaObj, PyObject* kwds
Py_ssize_t pos = 0;
while (PyDict_Next(kwds, &pos, &key, &value)) {
- if (!blackListSize || !std::binary_search(blackList, blackList + blackListSize, std::string(PyString_AS_STRING(key)))) {
- QByteArray propName(PyString_AS_STRING(key));
+ if (!blackListSize || !std::binary_search(blackList, blackList + blackListSize, std::string(Shiboken::String::toCString(key)))) {
+ QByteArray propName(Shiboken::String::toCString(key));
if (metaObj->indexOfProperty(propName) != -1) {
propName[0] = std::toupper(propName[0]);
propName.prepend("set");
@@ -185,7 +185,7 @@ void initDynamicMetaObject(SbkObjectType* type, const QMetaObject* base)
void initQObjectSubType(SbkObjectType* type, PyObject* args, PyObject* kwds)
{
PyTypeObject* qObjType = Shiboken::TypeResolver::get("QObject*")->pythonType();
- QByteArray className(PyString_AS_STRING(PyTuple_GET_ITEM(args, 0)));
+ QByteArray className(Shiboken::String::toCString(PyTuple_GET_ITEM(args, 0)));
PyObject* bases = PyTuple_GET_ITEM(args, 1);
int numBases = PyTuple_GET_SIZE(bases);
@@ -233,9 +233,9 @@ PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* nam
}
//search on metaobject (avoid internal attributes started with '__')
- if (!attr && !QString(PyString_AS_STRING(name)).startsWith("__")) {
+ if (!attr && !QString(Shiboken::String::toCString(name)).startsWith("__")) {
const QMetaObject* metaObject = cppSelf->metaObject();
- QByteArray cname(PyString_AS_STRING(name));
+ QByteArray cname(Shiboken::String::toCString(name));
cname += '(';
//signal
QList<QMetaMethod> signalList;
diff --git a/libpyside/pysideclassinfo.cpp b/libpyside/pysideclassinfo.cpp
index 023f4d7..0bd65e4 100644
--- a/libpyside/pysideclassinfo.cpp
+++ b/libpyside/pysideclassinfo.cpp
@@ -39,8 +39,7 @@ static void classInfoFree(void*);
static PyObject* classCall(PyObject*, PyObject*, PyObject*);
PyTypeObject PySideClassInfoType = {
- PyObject_HEAD_INIT(0)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(0, 0)
CLASSINFO_CLASS_NAME, /*tp_name*/
sizeof(PySideClassInfo), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -119,8 +118,8 @@ int classInfoTpInit(PyObject* self, PyObject* args, PyObject* kwds)
PyObject* value;
Py_ssize_t pos = 0;
while (PyDict_Next(kwds, &pos, &key, &value)) {
- if (PyString_Check(key) && PyString_Check(value))
- pData->m_data[PyString_AS_STRING(key)] = PyString_AS_STRING(value);
+ if (Shiboken::String::check(key) && Shiboken::String::check(value))
+ pData->m_data[Shiboken::String::toCString(key)] = Shiboken::String::toCString(value);
}
return PyErr_Occurred() ? -1 : 1;
diff --git a/libpyside/pysideconversions.h b/libpyside/pysideconversions.h
index e01d294..859868c 100644
--- a/libpyside/pysideconversions.h
+++ b/libpyside/pysideconversions.h
@@ -24,8 +24,9 @@
#define PYSIDECONVERSIONS_H
#include <Python.h>
-#include <conversions.h>
#include <QFlag>
+#include <conversions.h>
+#include <pysideqflags.h>
template <typename QtDict>
struct QtDictConverter
@@ -211,6 +212,7 @@ struct QSequenceConverter
}
};
+
template <typename T>
struct QFlagsConverter
{
@@ -232,17 +234,23 @@ struct QFlagsConverter
static inline PyObject* toPython(const T& cppObj)
{
- PyObject* qflags = Shiboken::SbkType<T>()->tp_alloc(Shiboken::SbkType<T>(), 0);
- reinterpret_cast<PyIntObject*>(qflags)->ob_ival = cppObj;
- return qflags;
+ return reinterpret_cast<PyObject*>(PySide::QFlags::newObject(cppObj, Shiboken::SbkType<T>()));
}
static inline T toCpp(PyObject* pyObj)
{
- if (Shiboken::isShibokenEnum(pyObj))
- return T(QFlag(Shiboken::Enum::getValue(pyObj)));
- else
- return T(QFlag(reinterpret_cast<PyIntObject*>(pyObj)->ob_ival));
+ long val = 0;
+ if (Shiboken::Enum::check(pyObj)) {
+ val = Shiboken::Enum::getValue(pyObj);
+ } else if (PyObject_TypeCheck(pyObj, Shiboken::SbkType<T>())) {
+ val = PySide::QFlags::getValue(reinterpret_cast<PySideQFlagsObject*>(pyObj));
+ } else if (PyNumber_Check(pyObj)) {
+ Shiboken::AutoDecRef pyLong(PyNumber_Long(pyObj));
+ val = PyLong_AsLong(pyLong.object());
+ } else {
+ PyErr_BadArgument();
+ }
+ return T(QFlag(val));
}
};
diff --git a/libpyside/pysidemetafunction.cpp b/libpyside/pysidemetafunction.cpp
index bee793c..46e20dc 100644
--- a/libpyside/pysidemetafunction.cpp
+++ b/libpyside/pysidemetafunction.cpp
@@ -41,8 +41,7 @@ static void functionFree(void*);
static PyObject* functionCall(PyObject*, PyObject*, PyObject*);
PyTypeObject PySideMetaFunctionType = {
- PyObject_HEAD_INIT(0)
- /*ob_size*/ 0,
+ PyVarObject_HEAD_INIT(0, 0)
/*tp_name*/ "PySide.MetaFunction",
/*tp_basicsize*/ sizeof(PySideMetaFunction),
/*tp_itemsize*/ 0,
diff --git a/libpyside/pysideproperty.cpp b/libpyside/pysideproperty.cpp
index af39852..ef09519 100644
--- a/libpyside/pysideproperty.cpp
+++ b/libpyside/pysideproperty.cpp
@@ -54,8 +54,7 @@ static PyMethodDef PySidePropertyMethods[] = {
};
PyTypeObject PySidePropertyType = {
- PyObject_HEAD_INIT(0)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(0, 0)
QPROPERTY_CLASS_NAME, /*tp_name*/
sizeof(PySideProperty), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -444,7 +443,7 @@ const char* getNotifyName(PySideProperty* self)
{
if (!self->d->notifySignature) {
PyObject* str = PyObject_Str(self->d->notify);
- self->d->notifySignature = strdup(PyString_AsString(str));
+ self->d->notifySignature = strdup(Shiboken::String::toCString(str));
Py_DECREF(str);
}
diff --git a/libpyside/pysidesignal.cpp b/libpyside/pysidesignal.cpp
index 084fcef..7b92493 100644
--- a/libpyside/pysidesignal.cpp
+++ b/libpyside/pysidesignal.cpp
@@ -75,8 +75,7 @@ static PyMethodDef Signal_methods[] = {
};
PyTypeObject PySideSignalMetaType = {
- PyObject_HEAD_INIT(0)
- /*ob_size*/ 0,
+ PyVarObject_HEAD_INIT(0, 0)
/*tp_name*/ "PySide.QtCore.MetaSignal",
/*tp_basicsize*/ sizeof(PyTypeObject),
/*tp_itemsize*/ 0,
@@ -110,9 +109,7 @@ PyTypeObject PySideSignalMetaType = {
};
PyTypeObject PySideSignalType = {
- PyObject_HEAD_INIT(&PySideSignalMetaType)
- //PyObject_HEAD_INIT(0)
- /*ob_size*/ 0,
+ PyVarObject_HEAD_INIT(&PySideSignalMetaType, 0)
/*tp_name*/ "PySide.QtCore."SIGNAL_CLASS_NAME,
/*tp_basicsize*/ sizeof(PySideSignal),
/*tp_itemsize*/ 0,
@@ -174,8 +171,7 @@ static PyMappingMethods SignalInstance_as_mapping = {
};
PyTypeObject PySideSignalInstanceType = {
- PyObject_HEAD_INIT(0)
- /*ob_size*/ 0,
+ PyVarObject_HEAD_INIT(0, 0)
/*tp_name*/ "PySide.QtCore."SIGNAL_INSTANCE_NAME,
/*tp_basicsize*/ sizeof(PySideSignalInstance),
/*tp_itemsize*/ 0,
@@ -244,7 +240,7 @@ int signalTpInit(PyObject* self, PyObject* args, PyObject* kwds)
for(Py_ssize_t i = 0, i_max = PyTuple_Size(args); i < i_max; i++) {
PyObject *arg = PyTuple_GET_ITEM(args, i);
- if (PySequence_Check(arg) && !PyString_Check(arg)) {
+ if (PySequence_Check(arg) && !Shiboken::String::check(arg)) {
tupledArgs = true;
PySide::Signal::appendSignature(data, PySide::Signal::parseSignature(arg));
}
@@ -290,7 +286,7 @@ PyObject* signalGetItem(PyObject* self, PyObject* key)
}
char* sig = PySide::Signal::buildSignature(data->signalName, sigKey);
free(sigKey);
- PyObject* pySignature = PyString_FromString(sig);
+ PyObject* pySignature = Shiboken::String::fromCString(sig);
free(sig);
return pySignature;
}
@@ -573,7 +569,7 @@ char* getTypeName(PyObject* type)
} else {
// Translate python types to Qt names
PyTypeObject *objType = reinterpret_cast<PyTypeObject*>(type);
- if ((objType == &PyString_Type) || (objType == &PyUnicode_Type))
+ if (Shiboken::String::checkType(objType))
typeName = strdup("QString");
else if (objType == &PyInt_Type)
typeName = strdup("int");
@@ -583,14 +579,14 @@ char* getTypeName(PyObject* type)
typeName = strdup("double");
else if (objType == &PyBool_Type)
typeName = strdup("bool");
- else if (objType->ob_type == &SbkEnumType_Type)
+ else if (Py_TYPE(objType) == &SbkEnumType_Type)
typeName = strdup(Shiboken::Enum::getCppName(objType));
else
typeName = strdup("PyObject");
}
return typeName;
- } else if (PyString_Check(type)) {
- return strdup(PyString_AS_STRING(type));
+ } else if (Shiboken::String::check(type)) {
+ return strdup(Shiboken::String::toCString(type));
} else if (type == Py_None) {
return strdup("void");
}
@@ -609,7 +605,7 @@ char* buildSignature(const char *name, const char *signature)
char* parseSignature(PyObject *args)
{
char *signature = 0;
- if (args && (PyString_Check(args) || !PySequence_Check(args)))
+ if (args && (Shiboken::String::check(args) || !PySequence_Check(args)))
return getTypeName(args);
for(Py_ssize_t i = 0, i_max = PySequence_Size(args); i < i_max; i++) {
@@ -656,7 +652,7 @@ void instanceInitialize(PySideSignalInstance* self, PyObject* name, PySideSignal
if (data->signalName)
selfPvt->signalName = strdup(data->signalName);
else {
- selfPvt->signalName = strdup(PyString_AsString(name));
+ selfPvt->signalName = strdup(Shiboken::String::toCString(name));
data->signalName = strdup(selfPvt->signalName);
}
@@ -681,7 +677,7 @@ bool connect(PyObject* source, const char* signal, PyObject* callback)
if (pyMethod.isNull())
return false;
- Shiboken::AutoDecRef pySignature(PyString_FromString(signal));
+ Shiboken::AutoDecRef pySignature(Shiboken::String::fromCString(signal));
Shiboken::AutoDecRef pyArgs(PyTuple_Pack(3, source, pySignature.object(), callback));
PyObject* result = PyObject_CallObject(pyMethod, pyArgs);
if (result == Py_False) {
@@ -824,7 +820,7 @@ PyObject* buildQtCompatible(const char* signature)
QByteArray ba;
ba.append(QT_SIGNAL_SENTINEL);
ba.append(signature);
- return PyString_FromStringAndSize(ba, ba.size());
+ return Shiboken::String::fromStringAndSize(ba, ba.size());
}
void addSignalToWrapper(SbkObjectType* wrapperType, const char* signalName, PySideSignal* signal)
@@ -882,7 +878,7 @@ QString getCallbackSignature(const char* signal, QObject* receiver, PyObject* ca
if (isMethod || isFunction) {
PyObject* function = isMethod ? PyMethod_GET_FUNCTION(callback) : callback;
PyCodeObject* objCode = reinterpret_cast<PyCodeObject*>(PyFunction_GET_CODE(function));
- functionName = PyString_AS_STRING(reinterpret_cast<PyFunctionObject*>(function)->func_name);
+ functionName = Shiboken::String::toCString(reinterpret_cast<PyFunctionObject*>(function)->func_name);
useSelf = isMethod;
numArgs = objCode->co_flags & CO_VARARGS ? -1 : objCode->co_argcount;
} else if (PyCFunction_Check(callback)) {
diff --git a/libpyside/pysideslot.cpp b/libpyside/pysideslot.cpp
index 16b891b..d2aba10 100644
--- a/libpyside/pysideslot.cpp
+++ b/libpyside/pysideslot.cpp
@@ -46,8 +46,7 @@ static PyObject* slotCall(PyObject*, PyObject*, PyObject*);
// Class Definition -----------------------------------------------
static PyTypeObject PySideSlotType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(0, 0)
"PySide.QtCore."SLOT_DEC_NAME, /*tp_name*/
sizeof(PySideSlot), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -150,7 +149,7 @@ PyObject* slotCall(PyObject* self, PyObject* args, PyObject* kw)
if (!data->slotName) {
PyObject *funcName = reinterpret_cast<PyFunctionObject*>(callback)->func_name;
- data->slotName = strdup(PyString_AS_STRING(funcName));
+ data->slotName = strdup(Shiboken::String::toCString(funcName));
}
@@ -159,9 +158,9 @@ PyObject* slotCall(PyObject* self, PyObject* args, PyObject* kw)
signature = returnType + " " + signature;
if (!pySlotName)
- pySlotName = PyString_FromString(PYSIDE_SLOT_LIST_ATTR);
+ pySlotName = Shiboken::String::fromCString(PYSIDE_SLOT_LIST_ATTR);
- PyObject *pySignature = PyString_FromString(signature);
+ PyObject *pySignature = Shiboken::String::fromCString(signature);
PyObject *signatureList = 0;
if (PyObject_HasAttr(callback, pySlotName)) {
signatureList = PyObject_GetAttr(callback, pySlotName);
diff --git a/libpyside/pysideweakref.cpp b/libpyside/pysideweakref.cpp
index eb4a6aa..195206a 100644
--- a/libpyside/pysideweakref.cpp
+++ b/libpyside/pysideweakref.cpp
@@ -12,8 +12,7 @@ typedef struct {
static PyObject* CallableObject_call(PyObject* callable_object, PyObject* args, PyObject* kw);
static PyTypeObject PySideCallableObjectType = {
- PyObject_HEAD_INIT(0)
- 0,
+ PyVarObject_HEAD_INIT(0, 0)
const_cast<char*>("PySide.Callable"),
sizeof(PySideCallableObject), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -52,9 +51,9 @@ PyObject* create(PyObject* obj, PySideWeakRefFunction func, void* userData)
if (obj == Py_None)
return 0;
- if (PySideCallableObjectType.ob_type == 0)
+ if (Py_TYPE(&PySideCallableObjectType) == 0)
{
- PySideCallableObjectType.ob_type = &PyType_Type;
+ Py_TYPE(&PySideCallableObjectType) = &PyType_Type;
PyType_Ready(&PySideCallableObjectType);
}
diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp
index 002d8f9..19beec3 100644
--- a/libpyside/signalmanager.cpp
+++ b/libpyside/signalmanager.cpp
@@ -56,10 +56,18 @@ namespace {
static bool emitShortCircuitSignal(QObject* source, int signalIndex, PyObject* args);
static bool emitNormalSignal(QObject* source, int signalIndex, const char* signal, PyObject* args, const QStringList& argTypes);
+#ifdef IS_PY3K
+ static void destroyMetaObject(PyObject* obj)
+ {
+ delete reinterpret_cast<PySide::DynamicQMetaObject*>(PyCapsule_GetPointer(obj, 0));
+ }
+
+#else
static void destroyMetaObject(void* obj)
{
delete reinterpret_cast<PySide::DynamicQMetaObject*>(obj);
}
+#endif
}
namespace PySide {
@@ -118,9 +126,15 @@ QDataStream &operator<<(QDataStream& out, const PyObjectWrapper& myObj)
}
Shiboken::AutoDecRef repr(PyObject_CallFunctionObjArgs(reduce_func, (PyObject*)myObj, NULL));
if (repr.object()) {
- char* buff;
- Py_ssize_t size;
- PyString_AsStringAndSize(repr.object(), &buff, &size);
+ const char* buff;
+ Py_ssize_t size = 0;
+ if (PyBytes_Check(repr.object())) {
+ buff = PyBytes_AS_STRING(repr.object());
+ size = PyBytes_GET_SIZE(repr.object());
+ } else if (Shiboken::String::check(repr.object())) {
+ buff = Shiboken::String::toCString(repr.object());
+ size = Shiboken::String::len(repr.object());
+ }
QByteArray data(buff, size);
out << data;
}
@@ -144,7 +158,7 @@ QDataStream &operator>>(QDataStream& in, PyObjectWrapper& myObj)
QByteArray repr;
in >> repr;
- Shiboken::AutoDecRef pyCode(PyString_FromStringAndSize(repr.data(), repr.size()));
+ Shiboken::AutoDecRef pyCode(PyBytes_FromStringAndSize(repr.data(), repr.size()));
Shiboken::AutoDecRef value(PyObject_CallFunctionObjArgs(eval_func, pyCode.object(), 0));
if (!value.object()) {
value = Py_None;
@@ -225,7 +239,7 @@ SignalManager::SignalManager() : m_d(new SignalManagerPrivate)
PySide::registerCleanupFunction(clearSignalManager);
if (!metaObjectAttr)
- metaObjectAttr = PyString_FromString("__METAOBJECT__");
+ metaObjectAttr = Shiboken::String::fromCString("__METAOBJECT__");
}
void SignalManager::clear()
@@ -353,7 +367,7 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id,
Shiboken::GilState gil;
pySelf = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(object);
Q_ASSERT(pySelf);
- pp_name = PyString_FromString(mp.name());
+ pp_name = Shiboken::String::fromCString(mp.name());
pp = Property::getObject(pySelf, pp_name);
if (!pp) {
qWarning("Invalid property: %s.", mp.name());
@@ -454,7 +468,12 @@ int SignalManager::registerMetaMethodGetIndex(QObject* source, const char* signa
// Create a instance meta object
if (!dict || !PyDict_Contains(dict, metaObjectAttr)) {
dmo = new DynamicQMetaObject(pySelf->ob_type, metaObject);
+#ifdef IS_PY3K
+ PyObject *pyDmo = PyCapsule_New(dmo, 0, destroyMetaObject);
+#else
PyObject *pyDmo = PyCObject_FromVoidPtr(dmo, destroyMetaObject);
+#endif
+
PyObject_SetAttr(pySelf, metaObjectAttr, pyDmo);
Py_DECREF(pyDmo);
} else {
@@ -484,7 +503,12 @@ const QMetaObject* SignalManager::retriveMetaObject(PyObject *self)
PyObject* dict = reinterpret_cast<SbkObject*>(self)->ob_dict;
if (dict && PyDict_Contains(dict, metaObjectAttr)) {
PyObject *pyMo = PyDict_GetItem(dict, metaObjectAttr);
+
+#ifdef IS_PY3K
+ mo = reinterpret_cast<DynamicQMetaObject*>(PyCapsule_GetPointer(pyMo, 0));
+#else
mo = reinterpret_cast<DynamicQMetaObject*>(PyCObject_AsVoidPtr(pyMo));
+#endif
} else {
mo = reinterpret_cast<DynamicQMetaObject*>(Shiboken::Object::getTypeUserData(reinterpret_cast<SbkObject*>(self)));
}