aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/libpyside
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/libpyside')
-rw-r--r--sources/pyside2/libpyside/dynamicqmetaobject.cpp10
-rw-r--r--sources/pyside2/libpyside/globalreceiverv2.h1
-rw-r--r--sources/pyside2/libpyside/pyside.cpp8
-rw-r--r--sources/pyside2/libpyside/pysideclassinfo.cpp83
-rw-r--r--sources/pyside2/libpyside/pysideclassinfo.h2
-rw-r--r--sources/pyside2/libpyside/pysidemetafunction.cpp76
-rw-r--r--sources/pyside2/libpyside/pysidemetafunction.h2
-rw-r--r--sources/pyside2/libpyside/pysideproperty.cpp92
-rw-r--r--sources/pyside2/libpyside/pysideproperty.h2
-rw-r--r--sources/pyside2/libpyside/pysideqflags.cpp70
-rw-r--r--sources/pyside2/libpyside/pysideqflags.h2
-rw-r--r--sources/pyside2/libpyside/pysidesignal.cpp301
-rw-r--r--sources/pyside2/libpyside/pysidesignal.h4
-rw-r--r--sources/pyside2/libpyside/pysidesignal_p.h2
-rw-r--r--sources/pyside2/libpyside/pysideslot.cpp80
-rw-r--r--sources/pyside2/libpyside/pysideweakref.cpp74
-rw-r--r--sources/pyside2/libpyside/signalmanager.cpp.in2
-rw-r--r--sources/pyside2/libpyside/signalmanager.h1
18 files changed, 327 insertions, 485 deletions
diff --git a/sources/pyside2/libpyside/dynamicqmetaobject.cpp b/sources/pyside2/libpyside/dynamicqmetaobject.cpp
index 63b52744..5b426ae8 100644
--- a/sources/pyside2/libpyside/dynamicqmetaobject.cpp
+++ b/sources/pyside2/libpyside/dynamicqmetaobject.cpp
@@ -388,7 +388,7 @@ DynamicQMetaObject::DynamicQMetaObject(PyTypeObject* type, const QMetaObject* ba
d.relatedMetaObjects = NULL;
d.static_metacall = NULL;
- m_d->m_className = QByteArray(type->tp_name).split('.').last();
+ m_d->m_className = QByteArray(PepType(type)->tp_name).split('.').last();
m_d->m_methodOffset = base->methodCount() - 1;
m_d->m_propertyOffset = base->propertyCount() - 1;
parsePythonType(type);
@@ -591,14 +591,14 @@ void DynamicQMetaObject::parsePythonType(PyTypeObject *type)
// This enforces registering of all signals and slots at type parsing time, and not later at
// signal connection time, thus making sure no method indices change which would break
// existing connections.
- const PyObject *mro = type->tp_mro;
+ const PyObject *mro = PepType(type)->tp_mro;
const Py_ssize_t basesCount = PyTuple_GET_SIZE(mro);
PyTypeObject *qObjectType = Shiboken::Conversions::getPythonTypeObject("QObject*");
QVector<PyTypeObject *> basesToCheck;
for (Py_ssize_t i = 0; i < basesCount; ++i) {
PyTypeObject *baseType = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, i));
if (PyType_IsSubtype(baseType, qObjectType)
- || baseType == reinterpret_cast<PyTypeObject *>(&SbkObject_Type)
+ || baseType == reinterpret_cast<PyTypeObject *>(SbkObject_TypeF())
|| baseType == reinterpret_cast<PyTypeObject *>(&PyBaseObject_Type)) {
continue;
} else {
@@ -611,7 +611,7 @@ void DynamicQMetaObject::parsePythonType(PyTypeObject *type)
// PYSIDE-315: Handle all signals first, in all involved types.
for (int baseIndex = 0, baseEnd = basesToCheck.size(); baseIndex < baseEnd; ++baseIndex) {
PyTypeObject *baseType = basesToCheck[baseIndex];
- PyObject *attrs = baseType->tp_dict;
+ PyObject *attrs = PepType(baseType)->tp_dict;
PyObject *key = 0;
PyObject *value = 0;
Py_ssize_t pos = 0;
@@ -643,7 +643,7 @@ void DynamicQMetaObject::parsePythonType(PyTypeObject *type)
// We check for this using "is_sorted()". Sorting no longer happens at all.
for (int baseIndex = 0, baseEnd = basesToCheck.size(); baseIndex < baseEnd; ++baseIndex) {
PyTypeObject *baseType = basesToCheck[baseIndex];
- PyObject *attrs = baseType->tp_dict;
+ PyObject *attrs = PepType(baseType)->tp_dict;
PyObject *key = 0;
PyObject *value = 0;
Py_ssize_t pos = 0;
diff --git a/sources/pyside2/libpyside/globalreceiverv2.h b/sources/pyside2/libpyside/globalreceiverv2.h
index af860fe1..880719d6 100644
--- a/sources/pyside2/libpyside/globalreceiverv2.h
+++ b/sources/pyside2/libpyside/globalreceiverv2.h
@@ -140,7 +140,6 @@ private:
DynamicQMetaObject m_metaObject;
DynamicSlotDataV2 *m_data;
QList<const QObject*> m_refs;
- int m_ref;
SharedMap m_sharedMap;
};
diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp
index 6bdaf65f..15be3876 100644
--- a/sources/pyside2/libpyside/pyside.cpp
+++ b/sources/pyside2/libpyside/pyside.cpp
@@ -265,7 +265,7 @@ PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* nam
}
//mutate native signals to signal instance type
- if (attr && PyObject_TypeCheck(attr, &PySideSignalType)) {
+ if (attr && PyObject_TypeCheck(attr, PySideSignalTypeF())) {
PyObject* signal = reinterpret_cast<PyObject*>(Signal::initialize(reinterpret_cast<PySideSignal*>(attr), name, self));
PyObject_SetAttr(self, name, reinterpret_cast<PyObject*>(signal));
return signal;
@@ -309,10 +309,10 @@ PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* nam
bool inherits(PyTypeObject* objType, const char* class_name)
{
- if (strcmp(objType->tp_name, class_name) == 0)
+ if (strcmp(PepType(objType)->tp_name, class_name) == 0)
return true;
- PyTypeObject* base = (objType)->tp_base;
+ PyTypeObject* base = PepType(objType)->tp_base;
if (base == 0)
return false;
@@ -400,7 +400,7 @@ QString pyStringToQString(PyObject *str) {
#ifdef IS_PY3K
if (PyUnicode_Check(str)) {
- const char *unicodeBuffer = _PyUnicode_AsString(str);
+ const char *unicodeBuffer = _PepUnicode_AsString(str);
if (unicodeBuffer)
return QString::fromUtf8(unicodeBuffer);
}
diff --git a/sources/pyside2/libpyside/pysideclassinfo.cpp b/sources/pyside2/libpyside/pysideclassinfo.cpp
index c5e0b548..5e0ffed3 100644
--- a/sources/pyside2/libpyside/pysideclassinfo.cpp
+++ b/sources/pyside2/libpyside/pysideclassinfo.cpp
@@ -55,55 +55,30 @@ static int classInfoTpInit(PyObject*, PyObject*, PyObject*);
static void classInfoFree(void*);
static PyObject* classCall(PyObject*, PyObject*, PyObject*);
-PyTypeObject PySideClassInfoType = {
- PyVarObject_HEAD_INIT(0, 0)
- "PySide2.QtCore." CLASSINFO_CLASS_NAME, /*tp_name*/
- sizeof(PySideClassInfo), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- classCall, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc */
- 0, /*tp_traverse */
- 0, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- 0, /*tp_iter */
- 0, /*tp_iternext */
- 0, /*tp_methods */
- 0, /*tp_members */
- 0, /*tp_getset */
- 0, /*tp_base */
- 0, /*tp_dict */
- 0, /*tp_descr_get */
- 0, /*tp_descr_set */
- 0, /*tp_dictoffset */
- classInfoTpInit, /*tp_init */
- 0, /*tp_alloc */
- classInfoTpNew, /*tp_new */
- classInfoFree, /*tp_free */
- 0, /*tp_is_gc */
- 0, /*tp_bases */
- 0, /*tp_mro */
- 0, /*tp_cache */
- 0, /*tp_subclasses */
- 0, /*tp_weaklist */
- 0, /*tp_del */
- 0, /*tp_version_tag */
+static PyType_Slot PySideClassInfoType_slots[] = {
+ {Py_tp_call, (void *)classCall},
+ {Py_tp_init, (void *)classInfoTpInit},
+ {Py_tp_new, (void *)classInfoTpNew},
+ {Py_tp_free, (void *)classInfoFree},
+ {Py_tp_dealloc, (void *)SbkDummyDealloc},
+ {0, 0}
};
+static PyType_Spec PySideClassInfoType_spec = {
+ "PySide2.QtCore." CLASSINFO_CLASS_NAME,
+ sizeof(PySideClassInfo),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideClassInfoType_slots,
+};
+
+
+PyTypeObject *PySideClassInfoTypeF(void)
+{
+ static PyTypeObject *type = nullptr;
+ if (!type)
+ type = (PyTypeObject *)PyType_FromSpec(&PySideClassInfoType_spec);
+ return type;
+}
PyObject *classCall(PyObject *self, PyObject *args, PyObject * /* kw */)
{
@@ -152,7 +127,7 @@ PyObject *classCall(PyObject *self, PyObject *args, PyObject * /* kw */)
static PyObject *classInfoTpNew(PyTypeObject *subtype, PyObject * /* args */, PyObject * /* kwds */)
{
- PySideClassInfo* me = reinterpret_cast<PySideClassInfo*>(subtype->tp_alloc(subtype, 0));
+ PySideClassInfo* me = reinterpret_cast<PySideClassInfo*>(PepType(subtype)->tp_alloc(subtype, 0));
me->d = new PySideClassInfoPrivate;
me->d->m_alreadyWrapped = false;
@@ -195,7 +170,7 @@ void classInfoFree(void *self)
PySideClassInfo* data = reinterpret_cast<PySideClassInfo*>(self);
delete data->d;
- pySelf->ob_type->tp_base->tp_free(self);
+ PepType(PepType(Py_TYPE(pySelf))->tp_base)->tp_free(self);
}
@@ -206,17 +181,17 @@ namespace PySide { namespace ClassInfo {
void init(PyObject* module)
{
- if (PyType_Ready(&PySideClassInfoType) < 0)
+ if (PyType_Ready(PySideClassInfoTypeF()) < 0)
return;
- Py_INCREF(&PySideClassInfoType);
- PyModule_AddObject(module, CLASSINFO_CLASS_NAME, reinterpret_cast<PyObject *>(&PySideClassInfoType));
+ Py_INCREF(PySideClassInfoTypeF());
+ PyModule_AddObject(module, CLASSINFO_CLASS_NAME, reinterpret_cast<PyObject *>(PySideClassInfoTypeF()));
}
bool checkType(PyObject* pyObj)
{
if (pyObj)
- return PyType_IsSubtype(pyObj->ob_type, &PySideClassInfoType);
+ return PyType_IsSubtype(Py_TYPE(pyObj), PySideClassInfoTypeF());
return false;
}
diff --git a/sources/pyside2/libpyside/pysideclassinfo.h b/sources/pyside2/libpyside/pysideclassinfo.h
index 91e01471..910dd9f8 100644
--- a/sources/pyside2/libpyside/pysideclassinfo.h
+++ b/sources/pyside2/libpyside/pysideclassinfo.h
@@ -47,7 +47,7 @@
extern "C"
{
- extern PYSIDE_API PyTypeObject PySideClassInfoType;
+ extern PYSIDE_API PyTypeObject *PySideClassInfoTypeF(void);
struct PySideClassInfoPrivate;
struct PYSIDE_API PySideClassInfo
diff --git a/sources/pyside2/libpyside/pysidemetafunction.cpp b/sources/pyside2/libpyside/pysidemetafunction.cpp
index a0f4b056..9839a109 100644
--- a/sources/pyside2/libpyside/pysidemetafunction.cpp
+++ b/sources/pyside2/libpyside/pysidemetafunction.cpp
@@ -58,55 +58,29 @@ struct PySideMetaFunctionPrivate
static void functionFree(void*);
static PyObject* functionCall(PyObject*, PyObject*, PyObject*);
-PyTypeObject PySideMetaFunctionType = {
- PyVarObject_HEAD_INIT(0, 0)
- /*tp_name*/ "PySide.MetaFunction",
- /*tp_basicsize*/ sizeof(PySideMetaFunction),
- /*tp_itemsize*/ 0,
- /*tp_dealloc*/ 0,
- /*tp_print*/ 0,
- /*tp_getattr*/ 0,
- /*tp_setattr*/ 0,
- /*tp_compare*/ 0,
- /*tp_repr*/ 0,
- /*tp_as_number*/ 0,
- /*tp_as_sequence*/ 0,
- /*tp_as_mapping*/ 0,
- /*tp_hash*/ 0,
- /*tp_call*/ functionCall,
- /*tp_str*/ 0,
- /*tp_getattro*/ 0,
- /*tp_setattro*/ 0,
- /*tp_as_buffer*/ 0,
- /*tp_flags*/ Py_TPFLAGS_DEFAULT,
- /*tp_doc*/ "MetaFunction",
- /*tp_traverse*/ 0,
- /*tp_clear*/ 0,
- /*tp_richcompare*/ 0,
- /*tp_weaklistoffset*/ 0,
- /*tp_iter*/ 0,
- /*tp_iternext*/ 0,
- /*tp_methods*/ 0,
- /*tp_members*/ 0,
- /*tp_getset*/ 0,
- /*tp_base*/ 0,
- /*tp_dict*/ 0,
- /*tp_descr_get*/ 0,
- /*tp_descr_set*/ 0,
- /*tp_dictoffset*/ 0,
- /*tp_init*/ 0,
- /*tp_alloc*/ 0,
- /*tp_new*/ PyType_GenericNew,
- /*tp_free*/ functionFree,
- /*tp_is_gc*/ 0,
- /*tp_bases*/ 0,
- /*tp_mro*/ 0,
- /*tp_cache*/ 0,
- /*tp_subclasses*/ 0,
- /*tp_weaklist*/ 0,
- /*tp_del*/ 0,
- /*tp_version_tag*/ 0
+static PyType_Slot PySideMetaFunctionType_slots[] = {
+ {Py_tp_call, (void *)functionCall},
+ {Py_tp_new, (void *)PyType_GenericNew},
+ {Py_tp_free, (void *)functionFree},
+ {Py_tp_dealloc, (void *)SbkDummyDealloc},
+ {0, 0}
};
+static PyType_Spec PySideMetaFunctionType_spec = {
+ "PySide.MetaFunction",
+ sizeof(PySideMetaFunction),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideMetaFunctionType_slots,
+};
+
+
+PyTypeObject *PySideMetaFunctionTypeF(void)
+{
+ static PyTypeObject *type = nullptr;
+ if (!type)
+ type = (PyTypeObject *)PyType_FromSpec(&PySideMetaFunctionType_spec);
+ return type;
+}
void functionFree(void *self)
{
@@ -130,10 +104,10 @@ namespace PySide { namespace MetaFunction {
void init(PyObject* module)
{
- if (PyType_Ready(&PySideMetaFunctionType) < 0)
+ if (PyType_Ready(PySideMetaFunctionTypeF()) < 0)
return;
- PyModule_AddObject(module, "MetaFunction", reinterpret_cast<PyObject *>(&PySideMetaFunctionType));
+ PyModule_AddObject(module, "MetaFunction", reinterpret_cast<PyObject *>(PySideMetaFunctionTypeF()));
}
PySideMetaFunction* newObject(QObject* source, int methodIndex)
@@ -144,7 +118,7 @@ PySideMetaFunction* newObject(QObject* source, int methodIndex)
QMetaMethod method = source->metaObject()->method(methodIndex);
if ((method.methodType() == QMetaMethod::Slot) ||
(method.methodType() == QMetaMethod::Method)) {
- PySideMetaFunction* function = PyObject_New(PySideMetaFunction, &PySideMetaFunctionType);
+ PySideMetaFunction* function = PyObject_New(PySideMetaFunction, PySideMetaFunctionTypeF());
function->d = new PySideMetaFunctionPrivate();
function->d->qobject = source;
function->d->methodIndex = methodIndex;
diff --git a/sources/pyside2/libpyside/pysidemetafunction.h b/sources/pyside2/libpyside/pysidemetafunction.h
index 9a4072de..020f02d4 100644
--- a/sources/pyside2/libpyside/pysidemetafunction.h
+++ b/sources/pyside2/libpyside/pysidemetafunction.h
@@ -49,7 +49,7 @@
extern "C"
{
- extern PYSIDE_API PyTypeObject PySideMetaFunctionType;
+ extern PYSIDE_API PyTypeObject *PySideMetaFunctionTypeF(void);
struct PySideMetaFunctionPrivate;
struct PYSIDE_API PySideMetaFunction
diff --git a/sources/pyside2/libpyside/pysideproperty.cpp b/sources/pyside2/libpyside/pysideproperty.cpp
index de85686c..ccec8a2c 100644
--- a/sources/pyside2/libpyside/pysideproperty.cpp
+++ b/sources/pyside2/libpyside/pysideproperty.cpp
@@ -72,55 +72,33 @@ static PyMethodDef PySidePropertyMethods[] = {
{0, 0, 0, 0}
};
-PyTypeObject PySidePropertyType = {
- PyVarObject_HEAD_INIT(0, 0)
- QPROPERTY_CLASS_NAME, /*tp_name*/
- sizeof(PySideProperty), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- qpropertyDeAlloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- qPropertyCall, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc */
- qpropertyTraverse, /*tp_traverse */
- qpropertyClear, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- 0, /*tp_iter */
- 0, /*tp_iternext */
- PySidePropertyMethods, /*tp_methods */
- 0, /*tp_members */
- 0, /*tp_getset */
- 0, /*tp_base */
- 0, /*tp_dict */
- 0, /*tp_descr_get */
- 0, /*tp_descr_set */
- 0, /*tp_dictoffset */
- qpropertyTpInit, /*tp_init */
- 0, /*tp_alloc */
- qpropertyTpNew, /*tp_new */
- 0, /*tp_free */
- 0, /*tp_is_gc */
- 0, /*tp_bases */
- 0, /*tp_mro */
- 0, /*tp_cache */
- 0, /*tp_subclasses */
- 0, /*tp_weaklist */
- 0, /*tp_del */
- 0 /*tp_version_tag */
+static PyType_Slot PySidePropertyType_slots[] = {
+ {Py_tp_dealloc, (void *)qpropertyDeAlloc},
+ {Py_tp_call, (void *)qPropertyCall},
+ {Py_tp_traverse, (void *)qpropertyTraverse},
+ {Py_tp_clear, (void *)qpropertyClear},
+ {Py_tp_methods, (void *)PySidePropertyMethods},
+ {Py_tp_init, (void *)qpropertyTpInit},
+ {Py_tp_new, (void *)qpropertyTpNew},
+ {0, 0}
};
+// Dotted modulename is crucial for PyType_FromSpec to work. Is this name right?
+static PyType_Spec PySidePropertyType_spec = {
+ "PySide2.QtCore." QPROPERTY_CLASS_NAME,
+ sizeof(PySideProperty),
+ 0,
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_BASETYPE,
+ PySidePropertyType_slots,
+};
+
+
+PyTypeObject *PySidePropertyTypeF(void)
+{
+ static PyTypeObject *type = nullptr;
+ if (!type)
+ type = (PyTypeObject *)PyType_FromSpec(&PySidePropertyType_spec);
+ return type;
+}
static void qpropertyMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::Call call, void** args)
{
@@ -174,7 +152,7 @@ static void qpropertyMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::C
static PyObject *qpropertyTpNew(PyTypeObject *subtype, PyObject * /* args */, PyObject * /* kwds */)
{
- PySideProperty* me = reinterpret_cast<PySideProperty*>(subtype->tp_alloc(subtype, 0));
+ PySideProperty* me = reinterpret_cast<PySideProperty*>(PepType(subtype)->tp_alloc(subtype, 0));
me->d = new PySidePropertyPrivate;
memset(me->d, 0, sizeof(PySidePropertyPrivate));
PySidePropertyPrivate* pData = me->d;
@@ -232,7 +210,7 @@ int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds)
void qpropertyDeAlloc(PyObject* self)
{
qpropertyClear(self);
- Py_TYPE(self)->tp_free(self);
+ PepType(Py_TYPE(self))->tp_free(self);
}
PyObject *qPropertyCall(PyObject *self, PyObject *args, PyObject * /* kw */)
@@ -329,9 +307,9 @@ namespace {
static PyObject* getFromType(PyTypeObject* type, PyObject* name)
{
PyObject* attr = 0;
- attr = PyDict_GetItem(type->tp_dict, name);
+ attr = PyDict_GetItem(PepType(type)->tp_dict, name);
if (!attr) {
- PyObject* bases = type->tp_bases;
+ PyObject* bases = PepType(type)->tp_bases;
int size = PyTuple_GET_SIZE(bases);
for(int i=0; i < size; i++) {
PyObject* base = PyTuple_GET_ITEM(bases, i);
@@ -350,17 +328,17 @@ namespace PySide { namespace Property {
void init(PyObject* module)
{
- if (PyType_Ready(&PySidePropertyType) < 0)
+ if (PyType_Ready(PySidePropertyTypeF()) < 0)
return;
- Py_INCREF(&PySidePropertyType);
- PyModule_AddObject(module, QPROPERTY_CLASS_NAME, reinterpret_cast<PyObject *>(&PySidePropertyType));
+ Py_INCREF(PySidePropertyTypeF());
+ PyModule_AddObject(module, QPROPERTY_CLASS_NAME, reinterpret_cast<PyObject *>(PySidePropertyTypeF()));
}
bool checkType(PyObject* pyObj)
{
if (pyObj) {
- return PyType_IsSubtype(pyObj->ob_type, &PySidePropertyType);
+ return PyType_IsSubtype(Py_TYPE(pyObj), PySidePropertyTypeF());
}
return false;
}
@@ -427,7 +405,7 @@ PySideProperty* getObject(PyObject* source, PyObject* name)
attr = PyDict_GetItem(dict, name);
}
- attr = getFromType(source->ob_type, name);
+ attr = getFromType(Py_TYPE(source), name);
if (attr && checkType(attr)) {
Py_INCREF(attr);
return reinterpret_cast<PySideProperty*>(attr);
diff --git a/sources/pyside2/libpyside/pysideproperty.h b/sources/pyside2/libpyside/pysideproperty.h
index d8cafc6c..d77416ab 100644
--- a/sources/pyside2/libpyside/pysideproperty.h
+++ b/sources/pyside2/libpyside/pysideproperty.h
@@ -46,7 +46,7 @@
extern "C"
{
- extern PYSIDE_API PyTypeObject PySidePropertyType;
+ extern PYSIDE_API PyTypeObject *PySidePropertyTypeF(void);
struct PySidePropertyPrivate;
struct PYSIDE_API PySideProperty
diff --git a/sources/pyside2/libpyside/pysideqflags.cpp b/sources/pyside2/libpyside/pysideqflags.cpp
index d3806985..11db70bb 100644
--- a/sources/pyside2/libpyside/pysideqflags.cpp
+++ b/sources/pyside2/libpyside/pysideqflags.cpp
@@ -44,14 +44,17 @@
extern "C" {
struct SbkConverter;
+ struct PySideQFlagsTypePrivate
+ {
+ SbkConverter** converterPtr;
+ SbkConverter* converter;
+ };
/**
* Type of all QFlags
*/
struct PySideQFlagsType
{
- PyHeapTypeObject super;
- SbkConverter** converterPtr;
- SbkConverter* converter;
+ PepTypeObject type;
};
#define PYSIDE_QFLAGS(X) reinterpret_cast<PySideQFlagsObject*>(X)
@@ -131,20 +134,61 @@ namespace PySide
{
namespace QFlags
{
- PyTypeObject* create(const char* name, PyNumberMethods* numberMethods)
+ static PyType_Slot SbkNewQFlagsType_slots[] = {
+#ifdef IS_PY3K
+ {Py_nb_bool, 0},
+#else
+ {Py_nb_nonzero, 0},
+ {Py_nb_long, 0},
+#endif
+ {Py_nb_invert, 0},
+ {Py_nb_and, 0},
+ {Py_nb_xor, 0},
+ {Py_nb_or, 0},
+ {Py_nb_int, 0},
+#ifndef IS_PY3K
+ {Py_nb_long, 0},
+#endif
+ {Py_tp_new, (void *)PySideQFlagsNew},
+ {Py_tp_richcompare, (void *)PySideQFlagsRichCompare},
+ {Py_tp_dealloc, (void *)SbkDummyDealloc},
+ {0, 0}
+ };
+ static PyType_Spec SbkNewQFlagsType_spec = {
+ "missing QFlags name", // to be inserted later
+ sizeof(PySideQFlagsObject),
+ 0,
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES,
+ SbkNewQFlagsType_slots,
+ };
+
+ PyTypeObject *create(const char* name, PyType_Slot numberMethods[])
{
- PyTypeObject* type = reinterpret_cast<PyTypeObject*>(new PySideQFlagsType);
- ::memset(type, 0, sizeof(PySideQFlagsType));
+ char qualname[200];
+ strcpy(qualname, "PySide2.libpyside.");
+ strcat(qualname, name);
+ // Careful: PyType_FromSpec does not allocate the string.
+ PyType_Spec *newspec = new PyType_Spec;
+ newspec->name = strdup(qualname);
+ newspec->basicsize = SbkNewQFlagsType_spec.basicsize;
+ newspec->itemsize = SbkNewQFlagsType_spec.itemsize;
+ newspec->flags = SbkNewQFlagsType_spec.flags;
+ int idx = -1;
+#ifdef IS_PY3K
+# define SLOT slot
+#else
+# define SLOT slot_
+#endif
+ while (numberMethods[++idx].SLOT) {
+ assert(SbkNewQFlagsType_slots[idx].SLOT == numberMethods[idx].SLOT);
+ SbkNewQFlagsType_slots[idx].pfunc = numberMethods[idx].pfunc;
+ }
+ newspec->slots = SbkNewQFlagsType_spec.slots;
+ PyTypeObject *type = (PyTypeObject *)PyType_FromSpec(newspec);
Py_TYPE(type) = &PyType_Type;
- type->tp_basicsize = sizeof(PySideQFlagsObject);
- type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES;
- type->tp_name = name;
- type->tp_new = &PySideQFlagsNew;
- type->tp_as_number = numberMethods;
- type->tp_richcompare = &PySideQFlagsRichCompare;
PySideQFlagsType* flagsType = reinterpret_cast<PySideQFlagsType*>(type);
- flagsType->converterPtr = &flagsType->converter;
+ PepType_PFTP(flagsType)->converterPtr = &PepType_PFTP(flagsType)->converter;
if (PyType_Ready(type) < 0)
return 0;
diff --git a/sources/pyside2/libpyside/pysideqflags.h b/sources/pyside2/libpyside/pysideqflags.h
index e0598798..71f30808 100644
--- a/sources/pyside2/libpyside/pysideqflags.h
+++ b/sources/pyside2/libpyside/pysideqflags.h
@@ -63,7 +63,7 @@ namespace QFlags
/**
* Creates a new QFlags type.
*/
- PYSIDE_API PyTypeObject* create(const char* name, PyNumberMethods* numberMethods);
+ PYSIDE_API PyTypeObject *create(const char* name, PyType_Slot *numberMethods);
/**
* Creates a new QFlags instance of type \p type and value \p value.
*/
diff --git a/sources/pyside2/libpyside/pysidesignal.cpp b/sources/pyside2/libpyside/pysidesignal.cpp
index 76ef65b5..483e9e05 100644
--- a/sources/pyside2/libpyside/pysidesignal.cpp
+++ b/sources/pyside2/libpyside/pysidesignal.cpp
@@ -93,117 +93,73 @@ static PyObject* signalCall(PyObject*, PyObject*, PyObject*);
static PyObject* metaSignalCheck(PyObject*, PyObject*);
-static PyMappingMethods Signal_as_mapping = {
- 0,
- signalGetItem,
- 0
-};
static PyMethodDef Signal_methods[] = {
{"__instancecheck__", (PyCFunction)metaSignalCheck, METH_O, NULL},
{0, 0, 0, 0}
};
-PyTypeObject PySideSignalMetaType = {
- PyVarObject_HEAD_INIT(0, 0)
- /*tp_name*/ "PySide2.QtCore.MetaSignal",
- /*tp_basicsize*/ sizeof(PyTypeObject),
- /*tp_itemsize*/ 0,
- /*tp_dealloc*/ 0,
- /*tp_print*/ 0,
- /*tp_getattr*/ 0,
- /*tp_setattr*/ 0,
- /*tp_compare*/ 0,
- /*tp_repr*/ 0,
- /*tp_as_number*/ 0,
- /*tp_as_sequence*/ 0,
- /*tp_as_mapping*/ 0,
- /*tp_hash*/ 0,
- /*tp_call*/ 0,
- /*tp_str*/ 0,
- /*tp_getattro*/ 0,
- /*tp_setattro*/ 0,
- /*tp_as_buffer*/ 0,
- /*tp_flags*/ Py_TPFLAGS_DEFAULT,
- /*tp_doc*/ 0,
- /*tp_traverse*/ 0,
- /*tp_clear*/ 0,
- /*tp_richcompare*/ 0,
- /*tp_weaklistoffset*/ 0,
- /*tp_iter*/ 0,
- /*tp_iternext*/ 0,
- /*tp_methods*/ Signal_methods,
- /*tp_members*/ 0,
- /*tp_getset*/ 0,
- /*tp_base*/ &PyType_Type,
- /*tp_dict*/ 0,
- /*tp_descr_get*/ 0,
- /*tp_descr_set*/ 0,
- /*tp_dictoffset*/ 0,
- /*tp_init*/ 0,
- /*tp_alloc*/ 0,
- /*tp_new*/ 0,
- /*tp_free*/ 0,
- /*tp_is_gc*/ 0,
- /*tp_bases*/ 0,
- /*tp_mro*/ 0,
- /*tp_cache*/ 0,
- /*tp_subclasses*/ 0,
- /*tp_weaklist*/ 0,
- /*tp_del*/ 0,
- /*tp_version_tag*/ 0
+static PyType_Slot PySideSignalMetaType_slots[] = {
+ {Py_tp_methods, (void *)Signal_methods},
+ {Py_tp_base, (void *)&PyType_Type},
+ {Py_tp_free, (void *)PyObject_GC_Del},
+ {Py_tp_dealloc, (void *)SbkDummyDealloc},
+ {0, 0}
+};
+static PyType_Spec PySideSignalMetaType_spec = {
+ "PySide2.QtCore.MetaSignal",
+ 0,
+ // sizeof(PyHeapTypeObject) is filled in by PyType_FromSpecWithBases
+ // which calls PyType_Ready which calls inherit_special.
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideSignalMetaType_slots,
};
-PyTypeObject PySideSignalType = {
- PyVarObject_HEAD_INIT(&PySideSignalMetaType, 0)
- /*tp_name*/ "PySide2.QtCore." SIGNAL_CLASS_NAME,
- /*tp_basicsize*/ sizeof(PySideSignal),
- /*tp_itemsize*/ 0,
- /*tp_dealloc*/ 0,
- /*tp_print*/ 0,
- /*tp_getattr*/ 0,
- /*tp_setattr*/ 0,
- /*tp_compare*/ 0,
- /*tp_repr*/ 0,
- /*tp_as_number*/ 0,
- /*tp_as_sequence*/ 0,
- /*tp_as_mapping*/ &Signal_as_mapping,
- /*tp_hash*/ 0,
- /*tp_call*/ signalCall,
- /*tp_str*/ signalToString,
- /*tp_getattro*/ 0,
- /*tp_setattro*/ 0,
- /*tp_as_buffer*/ 0,
- /*tp_flags*/ Py_TPFLAGS_DEFAULT,
- /*tp_doc*/ SIGNAL_CLASS_NAME,
- /*tp_traverse*/ 0,
- /*tp_clear*/ 0,
- /*tp_richcompare*/ 0,
- /*tp_weaklistoffset*/ 0,
- /*tp_iter*/ 0,
- /*tp_iternext*/ 0,
- /*tp_methods*/ 0,
- /*tp_members*/ 0,
- /*tp_getset*/ 0,
- /*tp_base*/ 0,
- /*tp_dict*/ 0,
- /*tp_descr_get*/ 0,
- /*tp_descr_set*/ 0,
- /*tp_dictoffset*/ 0,
- /*tp_init*/ signalTpInit,
- /*tp_alloc*/ 0,
- /*tp_new*/ PyType_GenericNew,
- /*tp_free*/ signalFree,
- /*tp_is_gc*/ 0,
- /*tp_bases*/ 0,
- /*tp_mro*/ 0,
- /*tp_cache*/ 0,
- /*tp_subclasses*/ 0,
- /*tp_weaklist*/ 0,
- /*tp_del*/ 0,
- /*tp_version_tag*/ 0
+
+PyTypeObject *PySideSignalMetaTypeF(void)
+{
+ static PyTypeObject *type = nullptr;
+ if (!type) {
+ PyObject *bases = Py_BuildValue("(O)", &PyType_Type);
+ type = (PyTypeObject *)PyType_FromSpecWithBases(&PySideSignalMetaType_spec, bases);
+ Py_XDECREF(bases);
+ }
+ return type;
+}
+
+static PyType_Slot PySideSignalType_slots[] = {
+ {Py_mp_subscript, (void *)signalGetItem},
+ {Py_tp_call, (void *)signalCall},
+ {Py_tp_str, (void *)signalToString},
+ {Py_tp_init, (void *)signalTpInit},
+ {Py_tp_new, (void *)PyType_GenericNew},
+ {Py_tp_free, (void *)signalFree},
+ {Py_tp_dealloc, (void *)SbkDummyDealloc},
+ {0, 0}
+};
+static PyType_Spec PySideSignalType_spec = {
+ "PySide2.QtCore." SIGNAL_CLASS_NAME,
+ sizeof(PySideSignal),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideSignalType_slots,
};
+
+PyTypeObject *PySideSignalTypeF(void)
+{
+ static PyTypeObject *type = nullptr;
+ if (!type) {
+ type = (PyTypeObject *)PyType_FromSpec(&PySideSignalType_spec);
+ PyTypeObject *hold = Py_TYPE(type);
+ Py_TYPE(type) = PySideSignalMetaTypeF();
+ Py_INCREF(Py_TYPE(type));
+ Py_DECREF(hold);
+ }
+ return type;
+}
+
static PyMethodDef SignalInstance_methods[] = {
{"connect", (PyCFunction)signalInstanceConnect, METH_VARARGS|METH_KEYWORDS, 0},
{"disconnect", signalInstanceDisconnect, METH_VARARGS, 0},
@@ -211,61 +167,31 @@ static PyMethodDef SignalInstance_methods[] = {
{0, 0, 0, 0} /* Sentinel */
};
-static PyMappingMethods SignalInstance_as_mapping = {
+static PyType_Slot PySideSignalInstanceType_slots[] = {
+ //{Py_tp_as_mapping, (void *)&SignalInstance_as_mapping},
+ {Py_mp_subscript, (void *)signalInstanceGetItem},
+ {Py_tp_call, (void *)signalInstanceCall},
+ {Py_tp_methods, (void *)SignalInstance_methods},
+ {Py_tp_new, (void *)PyType_GenericNew},
+ {Py_tp_free, (void *)signalInstanceFree},
+ {Py_tp_dealloc, (void *)SbkDummyDealloc},
+ {0, 0}
+};
+static PyType_Spec PySideSignalInstanceType_spec = {
+ "PySide2.QtCore." SIGNAL_INSTANCE_NAME,
+ sizeof(PySideSignalInstance),
0,
- signalInstanceGetItem,
- 0
+ Py_TPFLAGS_DEFAULT,
+ PySideSignalInstanceType_slots,
};
-PyTypeObject PySideSignalInstanceType = {
- PyVarObject_HEAD_INIT(0, 0)
- /*tp_name*/ "PySide2.QtCore." SIGNAL_INSTANCE_NAME,
- /*tp_basicsize*/ sizeof(PySideSignalInstance),
- /*tp_itemsize*/ 0,
- /*tp_dealloc*/ 0,
- /*tp_print*/ 0,
- /*tp_getattr*/ 0,
- /*tp_setattr*/ 0,
- /*tp_compare*/ 0,
- /*tp_repr*/ 0,
- /*tp_as_number*/ 0,
- /*tp_as_sequence*/ 0,
- /*tp_as_mapping*/ &SignalInstance_as_mapping,
- /*tp_hash*/ 0,
- /*tp_call*/ signalInstanceCall,
- /*tp_str*/ 0,
- /*tp_getattro*/ 0,
- /*tp_setattro*/ 0,
- /*tp_as_buffer*/ 0,
- /*tp_flags*/ Py_TPFLAGS_DEFAULT,
- /*tp_doc*/ SIGNAL_INSTANCE_NAME,
- /*tp_traverse*/ 0,
- /*tp_clear*/ 0,
- /*tp_richcompare*/ 0,
- /*tp_weaklistoffset*/ 0,
- /*tp_iter*/ 0,
- /*tp_iternext*/ 0,
- /*tp_methods*/ SignalInstance_methods,
- /*tp_members*/ 0,
- /*tp_getset*/ 0,
- /*tp_base*/ 0,
- /*tp_dict*/ 0,
- /*tp_descr_get*/ 0,
- /*tp_descr_set*/ 0,
- /*tp_dictoffset*/ 0,
- /*tp_init*/ 0,
- /*tp_alloc*/ 0,
- /*tp_new*/ PyType_GenericNew,
- /*tp_free*/ signalInstanceFree,
- /*tp_is_gc*/ 0,
- /*tp_bases*/ 0,
- /*tp_mro*/ 0,
- /*tp_cache*/ 0,
- /*tp_subclasses*/ 0,
- /*tp_weaklist*/ 0,
- /*tp_del*/ 0,
- /*tp_version_tag*/ 0
-};
+
+PyTypeObject *PySideSignalInstanceTypeF(void)
+{
+ static PyTypeObject *type =
+ (PyTypeObject *)PyType_FromSpec(&PySideSignalInstanceType_spec);
+ return type;
+}
int signalTpInit(PyObject* self, PyObject* args, PyObject* kwds)
{
@@ -327,7 +253,7 @@ void signalFree(void* self)
Py_XDECREF(data->homonymousMethod);
data->homonymousMethod = 0;
- pySelf->ob_type->tp_base->tp_free(self);
+ PepType(PepType(Py_TYPE(pySelf))->tp_base)->tp_free(self);
}
PyObject* signalGetItem(PyObject* self, PyObject* key)
@@ -372,7 +298,7 @@ void signalInstanceFree(void* self)
}
delete dataPvt;
data->d = 0;
- pySelf->ob_type->tp_base->tp_free(self);
+ PepType(PepType(Py_TYPE(pySelf))->tp_base)->tp_free(self);
}
PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds)
@@ -389,7 +315,7 @@ PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds)
Shiboken::AutoDecRef pyArgs(PyList_New(0));
bool match = false;
- if (slot->ob_type == &PySideSignalInstanceType) {
+ if (Py_TYPE(slot) == PySideSignalInstanceTypeF()) {
PySideSignalInstance* sourceWalk = source;
PySideSignalInstance* targetWalk;
@@ -427,9 +353,9 @@ PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds)
PyObject *function = isMethod ? PyMethod_GET_FUNCTION(slot) : slot;
PyCodeObject *objCode = reinterpret_cast<PyCodeObject *>(PyFunction_GET_CODE(function));
PyFunctionObject *function_obj = reinterpret_cast<PyFunctionObject *>(function);
- functionName = Shiboken::String::toCString(function_obj->func_name);
+ functionName = Shiboken::String::toCString(PepFunction_GetName(function_obj));
useSelf = isMethod;
- slotArgs = objCode->co_flags & CO_VARARGS ? -1 : objCode->co_argcount;
+ slotArgs = PepCode_GET_FLAGS(objCode) & CO_VARARGS ? -1 : PepCode_GET_ARGCOUNT(objCode);
if (useSelf)
slotArgs -= 1;
@@ -574,7 +500,7 @@ PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args)
slot = Py_None;
bool match = false;
- if (slot->ob_type == &PySideSignalInstanceType) {
+ if (Py_TYPE(slot) == PySideSignalInstanceTypeF()) {
PySideSignalInstance* target = reinterpret_cast<PySideSignalInstance*>(slot);
if (QMetaObject::checkConnectArgs(source->d->signature, target->d->signature)) {
PyList_Append(pyArgs, source->d->source);
@@ -626,7 +552,7 @@ PyObject* signalCall(PyObject* self, PyObject* args, PyObject* kw)
return 0;
}
- descrgetfunc getDescriptor = signal->homonymousMethod->ob_type->tp_descr_get;
+ descrgetfunc getDescriptor = PepType(Py_TYPE(signal->homonymousMethod))->tp_descr_get;
// Check if there exists a method with the same name as the signal, which is also a static
// method in C++ land.
@@ -637,7 +563,7 @@ PyObject* signalCall(PyObject* self, PyObject* args, PyObject* kw)
}
// Assumes homonymousMethod is not a static method.
- ternaryfunc callFunc = signal->homonymousMethod->ob_type->tp_call;
+ ternaryfunc callFunc = PepType(Py_TYPE(signal->homonymousMethod))->tp_call;
return callFunc(homonymousMethod, args, kw);
}
@@ -649,14 +575,14 @@ PyObject* signalInstanceCall(PyObject* self, PyObject* args, PyObject* kw)
return 0;
}
- descrgetfunc getDescriptor = PySideSignal->d->homonymousMethod->ob_type->tp_descr_get;
+ descrgetfunc getDescriptor = PepType(Py_TYPE(PySideSignal->d->homonymousMethod))->tp_descr_get;
Shiboken::AutoDecRef homonymousMethod(getDescriptor(PySideSignal->d->homonymousMethod, PySideSignal->d->source, 0));
return PyCFunction_Call(homonymousMethod, args, kw);
}
static PyObject *metaSignalCheck(PyObject * /* klass */, PyObject* args)
{
- if (PyType_IsSubtype(args->ob_type, &PySideSignalInstanceType))
+ if (PyType_IsSubtype(Py_TYPE(args), PySideSignalInstanceTypeF()))
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
@@ -669,25 +595,25 @@ namespace Signal {
void init(PyObject* module)
{
- if (PyType_Ready(&PySideSignalMetaType) < 0)
+ if (PyType_Ready(PySideSignalMetaTypeF()) < 0)
return;
- if (PyType_Ready(&PySideSignalType) < 0)
+ if (PyType_Ready(PySideSignalTypeF()) < 0)
return;
- Py_INCREF(&PySideSignalType);
- PyModule_AddObject(module, SIGNAL_CLASS_NAME, reinterpret_cast<PyObject *>(&PySideSignalType));
+ Py_INCREF(PySideSignalTypeF());
+ PyModule_AddObject(module, SIGNAL_CLASS_NAME, reinterpret_cast<PyObject *>(PySideSignalTypeF()));
- if (PyType_Ready(&PySideSignalInstanceType) < 0)
+ if (PyType_Ready(PySideSignalInstanceTypeF()) < 0)
return;
- Py_INCREF(&PySideSignalInstanceType);
+ Py_INCREF(PySideSignalInstanceTypeF());
}
bool checkType(PyObject* pyObj)
{
if (pyObj)
- return PyType_IsSubtype(pyObj->ob_type, &PySideSignalType);
+ return PyType_IsSubtype(Py_TYPE(pyObj), PySideSignalTypeF());
return false;
}
@@ -699,9 +625,9 @@ void updateSourceObject(PyObject* source)
PyObject* value;
PyObject* key;
- while (PyDict_Next(objType->tp_dict, &pos, &key, &value)) {
- if (PyObject_TypeCheck(value, &PySideSignalType)) {
- Shiboken::AutoDecRef signalInstance(reinterpret_cast<PyObject *>(PyObject_New(PySideSignalInstance, &PySideSignalInstanceType)));
+ while (PyDict_Next(PepType(objType)->tp_dict, &pos, &key, &value)) {
+ if (PyObject_TypeCheck(value, PySideSignalTypeF())) {
+ Shiboken::AutoDecRef signalInstance(reinterpret_cast<PyObject *>(PyObject_New(PySideSignalInstance, PySideSignalInstanceTypeF())));
instanceInitialize(signalInstance.cast<PySideSignalInstance*>(), key, reinterpret_cast<PySideSignal*>(value), source, 0);
PyObject_SetAttr(source, key, signalInstance);
}
@@ -714,7 +640,8 @@ char* getTypeName(PyObject* type)
{
if (PyType_Check(type)) {
char* typeName = NULL;
- if (PyType_IsSubtype(reinterpret_cast<PyTypeObject*>(type), reinterpret_cast<PyTypeObject*>(&SbkObject_Type))) {
+ if (PyType_IsSubtype(reinterpret_cast<PyTypeObject*>(type),
+ reinterpret_cast<PyTypeObject*>(SbkObject_TypeF()))) {
SbkObjectType* objType = reinterpret_cast<SbkObjectType*>(type);
typeName = strdup(Shiboken::ObjectType::getOriginalName(objType));
} else {
@@ -730,7 +657,7 @@ char* getTypeName(PyObject* type)
typeName = strdup("double");
else if (objType == &PyBool_Type)
typeName = strdup("bool");
- else if (Py_TYPE(objType) == &SbkEnumType_Type)
+ else if (Py_TYPE(objType) == SbkEnumType_TypeF())
typeName = strdup(Shiboken::Enum::getCppName(objType));
else
typeName = strdup("PyObject");
@@ -763,7 +690,7 @@ char* parseSignature(PyObject* args)
return getTypeName(args);
for (Py_ssize_t i = 0, i_max = PySequence_Size(args); i < i_max; i++) {
- Shiboken::AutoDecRef arg(PySequence_ITEM(args, i));
+ Shiboken::AutoDecRef arg(PySequence_GetItem(args, i));
char* typeName = getTypeName(arg);
if (typeName) {
if (signature) {
@@ -796,7 +723,7 @@ void appendSignature(PySideSignal* self, const SignalSignature &signature)
PySideSignalInstance* initialize(PySideSignal* self, PyObject* name, PyObject* object)
{
- PySideSignalInstance* instance = PyObject_New(PySideSignalInstance, &PySideSignalInstanceType);
+ PySideSignalInstance* instance = PyObject_New(PySideSignalInstance, PySideSignalInstanceTypeF());
SbkObject* sbkObj = reinterpret_cast<SbkObject*>(object);
if (!Shiboken::Object::wasCreatedByPython(sbkObj))
Py_INCREF(object); // PYSIDE-79: this flag was crucial for a wrapper call.
@@ -827,7 +754,7 @@ void instanceInitialize(PySideSignalInstance* self, PyObject* name, PySideSignal
index++;
if (index < data->signaturesSize) {
- selfPvt->next = PyObject_New(PySideSignalInstance, &PySideSignalInstanceType);
+ selfPvt->next = PyObject_New(PySideSignalInstance, PySideSignalInstanceTypeF());
instanceInitialize(selfPvt->next, name, data, source, index);
}
}
@@ -854,7 +781,7 @@ PySideSignalInstance* newObjectFromMethod(PyObject* source, const QList<QMetaMet
PySideSignalInstance* root = 0;
PySideSignalInstance* previous = 0;
foreach (const QMetaMethod &m, methodList) {
- PySideSignalInstance* item = PyObject_New(PySideSignalInstance, &PySideSignalInstanceType);
+ PySideSignalInstance* item = PyObject_New(PySideSignalInstance, PySideSignalInstanceTypeF());
if (!root)
root = item;
@@ -881,7 +808,7 @@ PySideSignal* newObject(const char* name, ...)
{
va_list listSignatures;
char* sig = 0;
- PySideSignal* self = PyObject_New(PySideSignal, &PySideSignalType);
+ PySideSignal* self = PyObject_New(PySideSignal, PySideSignalTypeF());
self->signalName = strdup(name);
self->signaturesSize = 0;
self->signatures = 0;
@@ -928,7 +855,7 @@ static typename T::value_type join(T t, const char* sep)
static void _addSignalToWrapper(SbkObjectType* wrapperType, const char* signalName, PySideSignal* signal)
{
- PyObject* typeDict = wrapperType->super.ht_type.tp_dict;
+ PyObject* typeDict = PepType(wrapperType)->tp_dict;
PyObject* homonymousMethod;
if ((homonymousMethod = PyDict_GetItemString(typeDict, signalName))) {
Py_INCREF(homonymousMethod);
@@ -964,7 +891,7 @@ void registerSignals(SbkObjectType* pyObj, const QMetaObject* metaObject)
SignalSigMap::Iterator it = signalsFound.begin();
SignalSigMap::Iterator end = signalsFound.end();
for (; it != end; ++it) {
- PySideSignal* self = PyObject_New(PySideSignal, &PySideSignalType);
+ PySideSignal* self = PyObject_New(PySideSignal, PySideSignalTypeF());
self->signalName = strdup(it.key().constData());
self->signaturesSize = 0;
self->signatures = 0;
@@ -1047,14 +974,14 @@ 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 = Shiboken::String::toCString(reinterpret_cast<PyFunctionObject*>(function)->func_name);
+ functionName = Shiboken::String::toCString(PepFunction_GetName(function));
useSelf = isMethod;
- numArgs = objCode->co_flags & CO_VARARGS ? -1 : objCode->co_argcount;
+ numArgs = PepCode_GET_FLAGS(objCode) & CO_VARARGS ? -1 : PepCode_GET_ARGCOUNT(objCode);
} else if (PyCFunction_Check(callback)) {
const PyCFunctionObject *funcObj = reinterpret_cast<const PyCFunctionObject *>(callback);
- functionName = funcObj->m_ml->ml_name;
- useSelf = funcObj->m_self;
- const int flags = funcObj->m_ml->ml_flags;
+ functionName = PepCFunction_GET_NAMESTR(funcObj);
+ useSelf = PyCFunction_GET_SELF(funcObj);
+ const int flags = PyCFunction_GET_FLAGS(funcObj);
if (receiver) {
//Search for signature on metaobject
diff --git a/sources/pyside2/libpyside/pysidesignal.h b/sources/pyside2/libpyside/pysidesignal.h
index f5365098..abbefbb1 100644
--- a/sources/pyside2/libpyside/pysidesignal.h
+++ b/sources/pyside2/libpyside/pysidesignal.h
@@ -50,8 +50,8 @@
extern "C"
{
- extern PYSIDE_API PyTypeObject PySideSignalType;
- extern PYSIDE_API PyTypeObject PySideSignalInstanceType;
+ extern PYSIDE_API PyTypeObject *PySideSignalTypeF(void);
+ extern PYSIDE_API PyTypeObject *PySideSignalInstanceTypeF(void);
// Internal object
struct PYSIDE_API PySideSignal;
diff --git a/sources/pyside2/libpyside/pysidesignal_p.h b/sources/pyside2/libpyside/pysidesignal_p.h
index e2e28b3d..24cbde50 100644
--- a/sources/pyside2/libpyside/pysidesignal_p.h
+++ b/sources/pyside2/libpyside/pysidesignal_p.h
@@ -44,7 +44,7 @@
extern "C"
{
- extern PyTypeObject PySideSignalType;
+ extern PyTypeObject *PySideSignalTypeF(void);
struct PySideSignal {
PyObject_HEAD
diff --git a/sources/pyside2/libpyside/pysideslot.cpp b/sources/pyside2/libpyside/pysideslot.cpp
index 8f307260..db1a7d9e 100644
--- a/sources/pyside2/libpyside/pysideslot.cpp
+++ b/sources/pyside2/libpyside/pysideslot.cpp
@@ -62,55 +62,29 @@ static int slotTpInit(PyObject*, PyObject*, PyObject*);
static PyObject* slotCall(PyObject*, PyObject*, PyObject*);
// Class Definition -----------------------------------------------
-static PyTypeObject PySideSlotType = {
- PyVarObject_HEAD_INIT(0, 0)
- "PySide2.QtCore." SLOT_DEC_NAME, /*tp_name*/
- sizeof(PySideSlot), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- slotCall, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- SLOT_DEC_NAME, /*tp_doc */
- 0, /*tp_traverse */
- 0, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- 0, /*tp_iter */
- 0, /*tp_iternext */
- 0, /*tp_methods */
- 0, /*tp_members */
- 0, /*tp_getset */
- 0, /*tp_base */
- 0, /*tp_dict */
- 0, /*tp_descr_get */
- 0, /*tp_descr_set */
- 0, /*tp_dictoffset */
- slotTpInit, /*tp_init */
- 0, /*tp_alloc */
- PyType_GenericNew, /*tp_new */
- 0, /*tp_free */
- 0, /*tp_is_gc */
- 0, /*tp_bases */
- 0, /*tp_mro */
- 0, /*tp_cache */
- 0, /*tp_subclasses */
- 0, /*tp_weaklist */
- 0, /*tp_del */
- 0 /*tp_version_tag*/
+static PyType_Slot PySideSlotType_slots[] = {
+ {Py_tp_call, (void *)slotCall},
+ {Py_tp_init, (void *)slotTpInit},
+ {Py_tp_new, (void *)PyType_GenericNew},
+ {Py_tp_dealloc, (void *)SbkDummyDealloc},
+ {0, 0}
};
+static PyType_Spec PySideSlotType_spec = {
+ "PySide2.QtCore." SLOT_DEC_NAME,
+ sizeof(PySideSlot),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideSlotType_slots,
+};
+
+
+static PyTypeObject *PySideSlotTypeF(void)
+{
+ static PyTypeObject *type = nullptr;
+ if (!type)
+ type = (PyTypeObject *)PyType_FromSpec(&PySideSlotType_spec);
+ return type;
+}
int slotTpInit(PyObject *self, PyObject *args, PyObject *kw)
{
@@ -139,7 +113,7 @@ int slotTpInit(PyObject *self, PyObject *args, PyObject *kw)
data->args = typeName;
}
} else {
- PyErr_Format(PyExc_TypeError, "Unknown signal argument type: %s", argType->ob_type->tp_name);
+ PyErr_Format(PyExc_TypeError, "Unknown signal argument type: %s", PepType((Py_TYPE(argType)))->tp_name);
return -1;
}
}
@@ -166,7 +140,7 @@ PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */)
PySideSlot *data = reinterpret_cast<PySideSlot*>(self);
if (!data->slotName) {
- PyObject *funcName = reinterpret_cast<PyFunctionObject*>(callback)->func_name;
+ PyObject *funcName = PepFunction_GetName(callback);
data->slotName = strdup(Shiboken::String::toCString(funcName));
}
@@ -209,11 +183,11 @@ namespace PySide { namespace Slot {
void init(PyObject* module)
{
- if (PyType_Ready(&PySideSlotType) < 0)
+ if (PyType_Ready(PySideSlotTypeF()) < 0)
return;
- Py_INCREF(&PySideSlotType);
- PyModule_AddObject(module, SLOT_DEC_NAME, reinterpret_cast<PyObject *>(&PySideSlotType));
+ Py_INCREF(PySideSlotTypeF());
+ PyModule_AddObject(module, SLOT_DEC_NAME, reinterpret_cast<PyObject *>(PySideSlotTypeF()));
}
} // namespace Slot
diff --git a/sources/pyside2/libpyside/pysideweakref.cpp b/sources/pyside2/libpyside/pysideweakref.cpp
index c31334ee..906aafd7 100644
--- a/sources/pyside2/libpyside/pysideweakref.cpp
+++ b/sources/pyside2/libpyside/pysideweakref.cpp
@@ -40,6 +40,7 @@
#include "pysideweakref.h"
#include <sbkpython.h>
+#include <shiboken.h>
typedef struct {
PyObject_HEAD
@@ -50,56 +51,27 @@ typedef struct {
static PyObject* CallableObject_call(PyObject* callable_object, PyObject* args, PyObject* kw);
-static PyTypeObject PySideCallableObjectType = {
- PyVarObject_HEAD_INIT(0, 0)
+static PyType_Slot PySideCallableObjectType_slots[] = {
+ {Py_tp_call, (void *)CallableObject_call},
+ {Py_tp_dealloc, (void *)SbkDummyDealloc},
+ {0, 0}
+};
+static PyType_Spec PySideCallableObjectType_spec = {
const_cast<char*>("PySide.Callable"),
- sizeof(PySideCallableObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- CallableObject_call, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
- 0, /* tp_del */
- 0 /* tp_version_tag */
+ sizeof(PySideCallableObject),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PySideCallableObjectType_slots,
};
+
+static PyTypeObject *PySideCallableObjectTypeF(void)
+{
+ static PyTypeObject *type =
+ (PyTypeObject *)PyType_FromSpec(&PySideCallableObjectType_spec);
+ return type;
+}
+
static PyObject *CallableObject_call(PyObject *callable_object, PyObject *args, PyObject * /* kw */)
{
PySideCallableObject* obj = reinterpret_cast<PySideCallableObject *>(callable_object);
@@ -116,13 +88,13 @@ PyObject* create(PyObject* obj, PySideWeakRefFunction func, void* userData)
if (obj == Py_None)
return 0;
- if (Py_TYPE(&PySideCallableObjectType) == 0)
+ if (Py_TYPE(PySideCallableObjectTypeF()) == 0)
{
- Py_TYPE(&PySideCallableObjectType) = &PyType_Type;
- PyType_Ready(&PySideCallableObjectType);
+ Py_TYPE(PySideCallableObjectTypeF()) = &PyType_Type;
+ PyType_Ready(PySideCallableObjectTypeF());
}
- PySideCallableObject* callable = PyObject_New(PySideCallableObject, &PySideCallableObjectType);
+ PySideCallableObject* callable = PyObject_New(PySideCallableObject, PySideCallableObjectTypeF());
if (!callable || PyErr_Occurred())
return 0;
diff --git a/sources/pyside2/libpyside/signalmanager.cpp.in b/sources/pyside2/libpyside/signalmanager.cpp.in
index 50f43613..c67bc636 100644
--- a/sources/pyside2/libpyside/signalmanager.cpp.in
+++ b/sources/pyside2/libpyside/signalmanager.cpp.in
@@ -590,7 +590,7 @@ 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);
+ dmo = new DynamicQMetaObject(Py_TYPE(pySelf), metaObject);
#ifdef IS_PY3K
PyObject* pyDmo = PyCapsule_New(dmo, 0, destroyMetaObject);
#else
diff --git a/sources/pyside2/libpyside/signalmanager.h b/sources/pyside2/libpyside/signalmanager.h
index 4f286745..5948a7df 100644
--- a/sources/pyside2/libpyside/signalmanager.h
+++ b/sources/pyside2/libpyside/signalmanager.h
@@ -61,7 +61,6 @@ public:
PyObjectWrapper& operator=(const PyObjectWrapper &other);
private:
PyObject* m_me;
- void* m_data; //future
};
PYSIDE_API QDataStream &operator<<(QDataStream& out, const PyObjectWrapper& myObj);