aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2')
-rw-r--r--sources/pyside2/CMakeLists.txt41
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp2
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qbytearray_mgetitem.cpp2
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp2
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h2
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp3
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp4
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core_common.xml59
-rw-r--r--sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml2
-rw-r--r--sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp181
-rw-r--r--sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h6
-rw-r--r--sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp8
-rw-r--r--sources/pyside2/PySide2/QtQuick/pysidequickregistertype.h2
-rw-r--r--sources/pyside2/PySide2/QtScript/typesystem_script.xml7
-rw-r--r--sources/pyside2/PySide2/QtWidgets/glue/qmenu_glue.cpp6
-rw-r--r--sources/pyside2/PySide2/QtWidgets/glue/qmenubar_glue.cpp5
-rw-r--r--sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml20
-rw-r--r--sources/pyside2/PySide2/typesystem_templates.xml5
-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
-rw-r--r--sources/pyside2/plugins/customwidget.cpp2
37 files changed, 516 insertions, 655 deletions
diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt
index 77382480..08647530 100644
--- a/sources/pyside2/CMakeLists.txt
+++ b/sources/pyside2/CMakeLists.txt
@@ -400,12 +400,53 @@ else()
endif()
message(STATUS "Detected OS: ${AUTO_OS}")
+# On Windows, PYTHON_LIBRARIES can be a list. Example:
+# optimized;C:/Python36/libs/python36.lib;debug;C:/Python36/libs/python36_d.lib
+# On other platforms, this result is not used at all.
+execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c "if True:
+ for lib in '${PYTHON_LIBRARIES}'.split(';'):
+ if '/' in lib:
+ prefix, py = lib.rsplit( '/', 1)
+ if py.startswith('python3'):
+ print(prefix + '/python3.lib')
+ break
+ "
+ OUTPUT_VARIABLE PYTHON_LIMITED_LIBRARIES
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
if (WIN32)
set(PATH_SEP "\;")
else()
set(PATH_SEP ":")
endif()
+option(FORCE_LIMITED_API "Enable the limited API." "no")
+
+set(PYTHON_LIMITED_API 0)
+if(FORCE_LIMITED_API STREQUAL "yes")
+ # GREATER_EQUAL is available only from cmake 3.7 on. We mean python 3.5 .
+ if (${PYTHON_VERSION_MAJOR} EQUAL 3 AND ${PYTHON_VERSION_MINOR} GREATER 4)
+ if (WIN32)
+ set(SHIBOKEN_PYTHON_LIBRARIES ${PYTHON_LIMITED_LIBRARIES})
+ endif()
+ add_definitions("-DPy_LIMITED_API=0x03050000")
+ set(PYTHON_LIMITED_API 1)
+ endif()
+ if (CMAKE_BUILD_TYPE STREQUAL "Release")
+ add_definitions("-DNDEBUG")
+ endif()
+endif()
+
+if (PYTHON_LIMITED_API)
+ if (WIN32 AND NOT EXISTS "${PYTHON_LIMITED_LIBRARIES}")
+ message(FATAL_ERROR "The Limited API was enabled, but ${PYTHON_LIMITED_LIBRARIES} was not found!")
+ endif()
+ message(STATUS "******************************************************")
+ message(STATUS "** Limited API enabled ${PYTHON_LIMITED_LIBRARIES}")
+ message(STATUS "******************************************************")
+endif()
+
# Define supported Qt Version
set(SUPPORTED_QT_VERSION "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}")
diff --git a/sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp b/sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp
index 22825a5c..ed5fef3a 100644
--- a/sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp
+++ b/sources/pyside2/PySide2/QtCore/glue/qbytearray_bufferprotocol.cpp
@@ -47,7 +47,7 @@ extern "C" {
static Py_ssize_t SbkQByteArray_segcountproc(PyObject* self, Py_ssize_t* lenp)
{
if (lenp)
- *lenp = self->ob_type->tp_as_sequence->sq_length(self);
+ *lenp = Py_TYPE(self)->tp_as_sequence->sq_length(self);
return 1;
}
diff --git a/sources/pyside2/PySide2/QtCore/glue/qbytearray_mgetitem.cpp b/sources/pyside2/PySide2/QtCore/glue/qbytearray_mgetitem.cpp
index 6a997c85..f1d5a6bf 100644
--- a/sources/pyside2/PySide2/QtCore/glue/qbytearray_mgetitem.cpp
+++ b/sources/pyside2/PySide2/QtCore/glue/qbytearray_mgetitem.cpp
@@ -82,6 +82,6 @@ if (PyIndex_Check(_key)) {
} else {
PyErr_Format(PyExc_TypeError,
"list indices must be integers or slices, not %.200s",
- _key->ob_type->tp_name);
+ PepType((Py_TYPE(_key)))->tp_name);
return NULL;
}
diff --git a/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp b/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp
index 5d28fbf4..46a69be3 100644
--- a/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp
+++ b/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include <Python.h>
+#include <sbkpython.h>
#include <shiboken.h>
#include <pysideweakref.h>
#include <QEasingCurve>
diff --git a/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h b/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h
index 7053d808..358ea9ee 100644
--- a/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h
+++ b/sources/pyside2/PySide2/QtCore/glue/qeasingcurve_glue.h
@@ -40,7 +40,7 @@
#ifndef __QEASINGCURVE_GLUE__
#define __QEASINGCURVE_GLUE__
-#include <Python.h>
+#include <sbkpython.h>
#include <QEasingCurve>
class PySideEasingCurveFunctor
diff --git a/sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp b/sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp
index ed37cef3..20f3720b 100644
--- a/sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp
+++ b/sources/pyside2/PySide2/QtCore/glue/qobject_connect.cpp
@@ -43,8 +43,7 @@ static bool isDecorator(PyObject* method, PyObject* self)
if (!PyObject_HasAttr(self, methodName))
return true;
Shiboken::AutoDecRef otherMethod(PyObject_GetAttr(self, methodName));
- return reinterpret_cast<PyMethodObject*>(otherMethod.object())->im_func != \
- reinterpret_cast<PyMethodObject*>(method)->im_func;
+ return PyMethod_GET_FUNCTION(otherMethod.object()) != PyMethod_GET_FUNCTION(method);
}
static bool getReceiver(QObject *source, const char* signal, PyObject* callback, QObject** receiver, PyObject** self, QByteArray* callbackSig)
diff --git a/sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp b/sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp
index 464fb68b..b32d104f 100644
--- a/sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp
+++ b/sources/pyside2/PySide2/QtCore/glue/qobject_findchild.cpp
@@ -41,7 +41,7 @@ static QObject* _findChildHelper(const QObject* parent, const QString& name, PyT
{
foreach(QObject* child, parent->children()) {
Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child));
- if (PyType_IsSubtype(pyChild->ob_type, desiredType)
+ if (PyType_IsSubtype(Py_TYPE(pyChild), desiredType)
&& (name.isNull() || name == child->objectName())) {
return child;
}
@@ -71,7 +71,7 @@ static void _findChildrenHelper(const QObject* parent, const T& name, PyTypeObje
{
foreach(const QObject* child, parent->children()) {
Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child));
- if (PyType_IsSubtype(pyChild->ob_type, desiredType) && _findChildrenComparator(child, name))
+ if (PyType_IsSubtype(Py_TYPE(pyChild), desiredType) && _findChildrenComparator(child, name))
PyList_Append(result, pyChild);
_findChildrenHelper(child, name, desiredType, result);
}
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
index f0b6b964..63c3d50e 100644
--- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
+++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
@@ -291,12 +291,18 @@
</native-to-target>
<target-to-native>
<add-conversion type="PyUnicode">
- Py_UNICODE *unicode = PyUnicode_AS_UNICODE(%in);
- #if defined(Py_UNICODE_WIDE)
+ #ifndef Py_LIMITED_API
+ Py_UNICODE* unicode = PyUnicode_AS_UNICODE(%in);
+ # if defined(Py_UNICODE_WIDE)
// cast as Py_UNICODE can be a different type
%out = QString::fromUcs4((const uint*)unicode);
- #else
+ # else
%out = QString::fromUtf16((const ushort*)unicode, PyUnicode_GET_SIZE(%in));
+ # endif
+ #else
+ wchar_t *temp = PyUnicode_AsWideCharString(%in, NULL);
+ %out = QString::fromWCharArray(temp);
+ PyMem_Free(temp);
#endif
</add-conversion>
<add-conversion type="PyString" check="py2kStrCheck(%in)">
@@ -410,7 +416,7 @@
<add-conversion type="SbkObject">
// a class supported by QVariant?
int typeCode;
- const char *typeName = QVariant_resolveMetaType(%in->ob_type, &amp;typeCode);
+ const char *typeName = QVariant_resolveMetaType(Py_TYPE(%in), &amp;typeCode);
if (!typeCode || !typeName)
return;
QVariant var(typeCode, (void*)0);
@@ -435,9 +441,9 @@
<inject-code class="native" position="beginning">
static const char *QVariant_resolveMetaType(PyTypeObject *type, int *typeId)
{
- if (PyObject_TypeCheck(type, &amp;SbkObjectType_Type)) {
- SbkObjectType *sbkType = (SbkObjectType*)type;
- const char *typeName = Shiboken::ObjectType::getOriginalName(sbkType);
+ if (PyObject_TypeCheck(type, SbkObjectType_TypeF())) {
+ SbkObjectType* sbkType = (SbkObjectType*)type;
+ const char* typeName = Shiboken::ObjectType::getOriginalName(sbkType);
if (!typeName)
return 0;
bool valueType = '*' != typeName[qstrlen(typeName) - 1];
@@ -456,15 +462,16 @@
// tp_base does not always point to the first base class, but rather to the first
// that has added any python fields or slots to its object layout.
// See https://mail.python.org/pipermail/python-list/2009-January/520733.html
- if (type->tp_bases) {
- for (int i = 0; i &lt; PyTuple_GET_SIZE(type->tp_bases); ++i) {
- const char *derivedName = QVariant_resolveMetaType((PyTypeObject*)PyTuple_GET_ITEM(type->tp_bases, i), typeId);
+ if (PepType(type)->tp_bases) {
+ for (int i = 0; i &lt; PyTuple_GET_SIZE(PepType(type)->tp_bases); ++i) {
+ const char *derivedName = QVariant_resolveMetaType((PyTypeObject*)PyTuple_GET_ITEM(
+ PepType(type)->tp_bases, i), typeId);
if (derivedName)
return derivedName;
}
}
- else if (type->tp_base) {
- return QVariant_resolveMetaType(type->tp_base, typeId);
+ else if (PepType(type)->tp_base) {
+ return QVariant_resolveMetaType(PepType(type)->tp_base, typeId);
}
}
*typeId = 0;
@@ -563,16 +570,16 @@
</add-conversion>
<add-conversion type="PyTypeObject">
const char *typeName;
- if (Shiboken::String::checkType((PyTypeObject*)%in))
+ if (Shiboken::String::checkType(reinterpret_cast&lt;PyTypeObject*&gt;(%in)))
typeName = "QString";
else if (%in == reinterpret_cast&lt;PyObject*&gt;(&amp;PyFloat_Type))
typeName = "double"; // float is a UserType in QVariant.
else if (%in == reinterpret_cast&lt;PyObject*&gt;(&amp;PyLong_Type))
typeName = "int"; // long is a UserType in QVariant.
- else if (%in->ob_type == &amp;SbkObjectType_Type)
+ else if (Py_TYPE(%in) == SbkObjectType_TypeF())
typeName = Shiboken::ObjectType::getOriginalName((SbkObjectType*)%in);
else
- typeName = (reinterpret_cast&lt;PyTypeObject*&gt;(%in))->tp_name;
+ typeName = PepType((reinterpret_cast&lt;PyTypeObject*&gt;(%in)))->tp_name;
%out = QVariant::nameToType(typeName);
</add-conversion>
<add-conversion type="PyString" check="Shiboken::String::check(%in)">
@@ -2589,7 +2596,7 @@
<add-function signature="__repr__" return-type="PyObject*">
<inject-code class="target" position="beginning">
- QByteArray b((reinterpret_cast&lt;PyObject*&gt;(%PYSELF))->ob_type->tp_name);
+ QByteArray b(PepType(Py_TYPE(%PYSELF))->tp_name);
PyObject *aux = Shiboken::String::fromStringAndSize(%CPPSELF.constData(), %CPPSELF.size());
if (PyUnicode_CheckExact(aux)) {
PyObject *tmp = PyUnicode_AsASCIIString(aux);
@@ -3088,7 +3095,7 @@
<inject-code>
Py_ssize_t size;
uchar *ptr = reinterpret_cast&lt;uchar*&gt;(Shiboken::Buffer::getPointer(%PYARG_1, &amp;size));
- %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(const_cast&lt;const uchar*>(ptr), size);
+ %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(const_cast&lt;const uchar*&gt;(ptr), size);
%PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0);
</inject-code>
</modify-function>
@@ -3114,8 +3121,8 @@
// %FUNCTION_NAME() - disable generation of c++ function call
(void) %2; // remove warning about unused variable
Shiboken::AutoDecRef emptyTuple(PyTuple_New(0));
- PyObject *pyTimer = Shiboken::SbkType&lt;QTimer>()->tp_new(Shiboken::SbkType&lt;QTimer>(), emptyTuple, 0);
- Shiboken::SbkType&lt;QTimer>()->tp_init(pyTimer, emptyTuple, 0);
+ PyObject *pyTimer = PepType(Shiboken::SbkType&lt;QTimer&gt;())->tp_new(Shiboken::SbkType&lt;QTimer&gt;(), emptyTuple, 0);
+ PepType(Shiboken::SbkType&lt;QTimer&gt;())->tp_init(pyTimer, emptyTuple, 0);
QTimer* timer = %CONVERTTOCPP[QTimer*](pyTimer);
Shiboken::AutoDecRef result(
@@ -3138,14 +3145,14 @@
<inject-code class="target" position="beginning">
// %FUNCTION_NAME() - disable generation of c++ function call
Shiboken::AutoDecRef emptyTuple(PyTuple_New(0));
- PyObject *pyTimer = Shiboken::SbkType&lt;QTimer>()->tp_new(Shiboken::SbkType&lt;QTimer>(), emptyTuple, 0);
- Shiboken::SbkType&lt;QTimer>()->tp_init(pyTimer, emptyTuple, 0);
+ PyObject *pyTimer = PepType(Shiboken::SbkType&lt;QTimer&gt;())->tp_new(Shiboken::SbkType&lt;QTimer&gt;(), emptyTuple, 0);
+ PepType(Shiboken::SbkType&lt;QTimer&gt;())->tp_init(pyTimer, emptyTuple, 0);
QTimer* timer = %CONVERTTOCPP[QTimer*](pyTimer);
timer->setSingleShot(true);
- if (PyObject_TypeCheck(%2, &amp;PySideSignalInstanceType)) {
+ if (PyObject_TypeCheck(%2, PySideSignalInstanceTypeF())) {
PySideSignalInstance *signalInstance = reinterpret_cast&lt;PySideSignalInstance*&gt;(%2);
- Shiboken::AutoDecRef signalSignature(Shiboken::String::fromFormat("2%s",PySide::Signal::getSignature(signalInstance)));
+ Shiboken::AutoDecRef signalSignature(Shiboken::String::fromFormat("2%s", PySide::Signal::getSignature(signalInstance)));
Shiboken::AutoDecRef result(
PyObject_CallMethod(pyTimer,
const_cast&lt;char*&gt;("connect"),
@@ -4026,7 +4033,7 @@ s1.addTransition(button.clicked, s1h)&lt;/code>
<replace-default-expression with="0" />
</modify-argument>
<inject-code>
- if (PyObject_TypeCheck(%1, &amp;PySideSignalInstanceType)) {
+ if (PyObject_TypeCheck(%1, PySideSignalInstanceTypeF())) {
PyObject *dataSource = PySide::Signal::getObject((PySideSignalInstance*)%PYARG_1);
Shiboken::AutoDecRef obType(PyObject_Type(dataSource));
QObject* sender = %CONVERTTOCPP[QObject*](dataSource);
@@ -4082,11 +4089,11 @@ s1.addTransition(button.clicked, s1h)&lt;/code>
// since it refers to a name very tied to the generator implementation.
// Check bug #362 for more information on this
// http://bugs.openbossa.org/show_bug.cgi?id=362
- if (!PyObject_TypeCheck(%1, &amp;PySideSignalInstanceType))
+ if (!PyObject_TypeCheck(%1, PySideSignalInstanceTypeF()))
goto Sbk_%TYPEFunc_%FUNCTION_NAME_TypeError;
PySideSignalInstance *signalInstance = reinterpret_cast&lt;PySideSignalInstance*&gt;(%1);
QObject* sender = %CONVERTTOCPP[QObject*](PySide::Signal::getObject(signalInstance));
- QSignalTransition*%0 = %CPPSELF->%FUNCTION_NAME(sender,PySide::Signal::getSignature(signalInstance),%2);
+ QSignalTransition *%0 = %CPPSELF->%FUNCTION_NAME(sender, PySide::Signal::getSignature(signalInstance),%2);
%PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%0);
</inject-code>
</add-function>
diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
index 47bf6299..eee22b55 100644
--- a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
+++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
@@ -1752,7 +1752,7 @@
PyErr_Format(PyExc_TypeError, "Invalid return value in function %s, expected %s, got %s.",
"QValidator.validate",
"PySide2.QtGui.QValidator.State, (PySide2.QtGui.QValidator.State,), (PySide2.QtGui.QValidator.State, unicode) or (PySide2.QtGui.QValidator.State, unicode, int)",
- pyResult->ob_type->tp_name);
+ PepType((Py_TYPE(pyResult)))->tp_name);
return QValidator::State();
}
</template>
diff --git a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp
index d95ae225..fa9eb634 100644
--- a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp
+++ b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp
@@ -120,9 +120,9 @@ int PySide::qmlRegisterType(PyObject *pyObj, const char *uri, int versionMajor,
}
PyTypeObject *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
- if (!PySequence_Contains(pyObjType->tp_mro, reinterpret_cast<PyObject *>(qobjectType))) {
+ if (!PySequence_Contains(PepType(pyObjType)->tp_mro, reinterpret_cast<PyObject *>(qobjectType))) {
PyErr_Format(PyExc_TypeError, "A type inherited from %s expected, got %s.",
- qobjectType->tp_name, pyObjType->tp_name);
+ PepType(qobjectType)->tp_name, PepType(pyObjType)->tp_name);
return -1;
}
@@ -229,57 +229,34 @@ void propListTpFree(void* self)
PySideProperty* pySelf = reinterpret_cast<PySideProperty*>(self);
delete reinterpret_cast<QmlListProperty*>(PySide::Property::userData(pySelf));
// calls base type constructor
- Py_TYPE(pySelf)->tp_base->tp_free(self);
+ PepType(PepType(Py_TYPE(pySelf))->tp_base)->tp_free(self);
}
-PyTypeObject PropertyListType = {
- PyVarObject_HEAD_INIT(0, 0)
- "ListProperty", /*tp_name*/
- sizeof(PySideProperty), /*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 */
- 0, /*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 */
- &PySidePropertyType, /*tp_base */
- 0, /*tp_dict */
- 0, /*tp_descr_get */
- 0, /*tp_descr_set */
- 0, /*tp_dictoffset */
- propListTpInit, /*tp_init */
- 0, /*tp_alloc */
- 0, /*tp_new */
- propListTpFree, /*tp_free */
- 0, /*tp_is_gc */
- 0, /*tp_bases */
- 0, /*tp_mro */
- 0, /*tp_cache */
- 0, /*tp_subclasses */
- 0, /*tp_weaklist */
- 0, /*tp_del */
+static PyType_Slot PropertyListType_slots[] = {
+ {Py_tp_init, (void *)propListTpInit},
+ {Py_tp_free, (void *)propListTpFree},
+ {Py_tp_dealloc, (void *)SbkDummyDealloc},
+ {0, 0}
};
+static PyType_Spec PropertyListType_spec = {
+ "PySide2.QtQml.ListProperty",
+ sizeof(PySideProperty),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ PropertyListType_slots,
+};
+
+
+PyTypeObject *PropertyListTypeF(void)
+{
+ static PyTypeObject *type = nullptr;
+ if (!type) {
+ PyObject *bases = Py_BuildValue("(O)", PySidePropertyTypeF());
+ type = (PyTypeObject *)PyType_FromSpecWithBases(&PropertyListType_spec, bases);
+ Py_XDECREF(bases);
+ }
+ return type;
+}
} // extern "C"
@@ -312,7 +289,7 @@ int propListCount(QQmlListProperty<QObject> *propList)
// Check return type
int cppResult = 0;
- PythonToCppFunc pythonToCpp;
+ PythonToCppFunc pythonToCpp = 0;
if (PyErr_Occurred())
PyErr_Print();
else if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter<int>(), retVal)))
@@ -387,7 +364,7 @@ QtQml_VolatileBoolObject_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return Q_NULLPTR;
QtQml_VolatileBoolObject *self
- = reinterpret_cast<QtQml_VolatileBoolObject *>(type->tp_alloc(type, 0));
+ = reinterpret_cast<QtQml_VolatileBoolObject *>(PepType(type)->tp_alloc(type, 0));
if (self != Q_NULLPTR)
self->flag = ok;
@@ -444,10 +421,10 @@ QtQml_VolatileBoolObject_repr(QtQml_VolatileBoolObject *self)
if (self->flag)
s = PyBytes_FromFormat("%s(True)",
- Py_TYPE(self)->tp_name);
+ PepType((Py_TYPE(self)))->tp_name);
else
s = PyBytes_FromFormat("%s(False)",
- Py_TYPE(self)->tp_name);
+ PepType((Py_TYPE(self)))->tp_name);
Py_XINCREF(s);
return s;
}
@@ -459,87 +436,61 @@ QtQml_VolatileBoolObject_str(QtQml_VolatileBoolObject *self)
if (self->flag)
s = PyBytes_FromFormat("%s(True) -> %p",
- Py_TYPE(self)->tp_name, &(self->flag));
+ PepType((Py_TYPE(self)))->tp_name, &(self->flag));
else
s = PyBytes_FromFormat("%s(False) -> %p",
- Py_TYPE(self)->tp_name, &(self->flag));
+ PepType((Py_TYPE(self)))->tp_name, &(self->flag));
Py_XINCREF(s);
return s;
}
-PyTypeObject QtQml_VolatileBoolType = {
- PyVarObject_HEAD_INIT(Q_NULLPTR, 0) /*ob_size*/
- "VolatileBool", /*tp_name*/
- sizeof(QtQml_VolatileBoolObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- reinterpret_cast<reprfunc>(QtQml_VolatileBoolObject_repr), /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- reinterpret_cast<reprfunc>(QtQml_VolatileBoolObject_str), /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "VolatileBool objects contain a C++ volatile bool", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- QtQml_VolatileBoolObject_methods, /* 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 */
- QtQml_VolatileBoolObject_new, /* 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 */
-#if PY_MAJOR_VERSION > 3 || PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 4
- 0 /* tp_finalize */
-#endif
+static PyType_Slot QtQml_VolatileBoolType_slots[] = {
+ {Py_tp_repr, (void *)reinterpret_cast<reprfunc>(QtQml_VolatileBoolObject_repr)},
+ {Py_tp_str, (void *)reinterpret_cast<reprfunc>(QtQml_VolatileBoolObject_str)},
+ {Py_tp_methods, (void *)QtQml_VolatileBoolObject_methods},
+ {Py_tp_new, (void *)QtQml_VolatileBoolObject_new},
+ {Py_tp_dealloc, (void *)SbkDummyDealloc},
+ {0, 0}
};
+static PyType_Spec QtQml_VolatileBoolType_spec = {
+ "PySide2.QtQml.VolatileBool",
+ sizeof(QtQml_VolatileBoolObject),
+ 0,
+ Py_TPFLAGS_DEFAULT,
+ QtQml_VolatileBoolType_slots,
+};
+
+
+PyTypeObject *QtQml_VolatileBoolTypeF(void)
+{
+ static PyTypeObject *type = nullptr;
+ if (!type)
+ type = (PyTypeObject *)PyType_FromSpec(&QtQml_VolatileBoolType_spec);
+ return type;
+}
void PySide::initQmlSupport(PyObject* module)
{
ElementFactory<PYSIDE_MAX_QML_TYPES - 1>::init();
// Export QmlListProperty type
- if (PyType_Ready(&PropertyListType) < 0) {
+ if (PyType_Ready(PropertyListTypeF()) < 0) {
+ PyErr_Print();
qWarning() << "Error initializing PropertyList type.";
return;
}
- Py_INCREF(reinterpret_cast<PyObject *>(&PropertyListType));
- PyModule_AddObject(module, PropertyListType.tp_name,
- reinterpret_cast<PyObject *>(&PropertyListType));
+ Py_INCREF(reinterpret_cast<PyObject *>(PropertyListTypeF()));
+ PyModule_AddObject(module, PepType_GetNameStr(PropertyListTypeF()),
+ reinterpret_cast<PyObject *>(PropertyListTypeF()));
- if (PyType_Ready(&QtQml_VolatileBoolType) < 0) {
+ if (PyType_Ready(QtQml_VolatileBoolTypeF()) < 0) {
+ PyErr_Print();
qWarning() << "Error initializing VolatileBool type.";
return;
}
- Py_INCREF(&QtQml_VolatileBoolType);
- PyModule_AddObject(module, QtQml_VolatileBoolType.tp_name,
- reinterpret_cast<PyObject *>(&QtQml_VolatileBoolType));
+ Py_INCREF(QtQml_VolatileBoolTypeF());
+ PyModule_AddObject(module, PepType_GetNameStr(QtQml_VolatileBoolTypeF()),
+ reinterpret_cast<PyObject *>(QtQml_VolatileBoolTypeF()));
}
diff --git a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h
index a4ee7309..0ef6539a 100644
--- a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h
+++ b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h
@@ -40,7 +40,7 @@
#ifndef PYSIDEQMLREGISTERTYPE_H
#define PYSIDEQMLREGISTERTYPE_H
-#include <Python.h>
+#include <sbkpython.h>
struct SbkObjectType;
@@ -78,8 +78,8 @@ typedef struct {
volatile bool flag;
} QtQml_VolatileBoolObject;
-PyAPI_DATA(PyTypeObject) QtQml_VolatileBoolType;
+PyAPI_FUNC(PyTypeObject *) QtQml_VolatileBoolTypeF(void);
-#define VolatileBool_Check(op) (Py_TYPE(op) == &QtQml_VolatileBoolType)
+#define VolatileBool_Check(op) (Py_TYPE(op) == QtQml_VolatileBoolTypeF())
#endif
diff --git a/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp b/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp
index 594fa801..67ef5355 100644
--- a/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp
+++ b/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp
@@ -106,11 +106,11 @@ struct ElementFactory<0> : ElementFactoryBase<0>
typePointerName, typeListName, \
typeMetaObject, type, registered)
-bool pyTypeObjectInheritsFromClass(const PyTypeObject *pyObjType, QByteArray className)
+bool pyTypeObjectInheritsFromClass(PyTypeObject *pyObjType, QByteArray className)
{
className.append('*');
PyTypeObject *classPyType = Shiboken::Conversions::getPythonTypeObject(className.constData());
- bool isDerived = PySequence_Contains(pyObjType->tp_mro,
+ bool isDerived = PySequence_Contains(PepType(pyObjType)->tp_mro,
reinterpret_cast<PyObject *>(classPyType));
return isDerived;
}
@@ -118,7 +118,7 @@ bool pyTypeObjectInheritsFromClass(const PyTypeObject *pyObjType, QByteArray cla
template <class WrapperClass>
void registerTypeIfInheritsFromClass(
QByteArray className,
- const PyTypeObject *typeToRegister,
+ PyTypeObject *typeToRegister,
const QByteArray &typePointerName,
const QByteArray &typeListName,
QMetaObject *typeMetaObject,
@@ -190,7 +190,7 @@ bool quickRegisterType(PyObject *pyObj, const char *uri, int versionMajor, int v
PyTypeObject *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
PyTypeObject *qQuickItemPyType =
Shiboken::Conversions::getPythonTypeObject("QQuickItem*");
- bool isQuickItem = PySequence_Contains(pyObjType->tp_mro,
+ bool isQuickItem = PySequence_Contains(PepType(pyObjType)->tp_mro,
reinterpret_cast<PyObject *>(qQuickItemPyType));
// Register only classes that inherit QQuickItem or its children.
diff --git a/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.h b/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.h
index 35d3edec..1955413b 100644
--- a/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.h
+++ b/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.h
@@ -40,7 +40,7 @@
#ifndef PYSIDE_QUICK_REGISTER_TYPE_H
#define PYSIDE_QUICK_REGISTER_TYPE_H
-#include <Python.h>
+#include <sbkpython.h>
struct SbkObjectType;
diff --git a/sources/pyside2/PySide2/QtScript/typesystem_script.xml b/sources/pyside2/PySide2/QtScript/typesystem_script.xml
index ccb2e3ab..dc089a30 100644
--- a/sources/pyside2/PySide2/QtScript/typesystem_script.xml
+++ b/sources/pyside2/PySide2/QtScript/typesystem_script.xml
@@ -84,11 +84,12 @@
<add-function signature="__repr__" return-type="PyObject*">
<inject-code class="target" position="beginning">
if (%CPPSELF.isVariant() || %CPPSELF.isString()) {
- QString format = QString().sprintf("%s(\"%s\")", ((PyObject*)%PYSELF)->ob_type->tp_name, qPrintable(%CPPSELF.toString()));
+ QString format = QString().sprintf("%s(\"%s\")",
+ PepType(Py_TYPE(%PYSELF))->tp_name,
+ qPrintable(%CPPSELF.toString()));
%PYARG_0 = Shiboken::String::fromCString(qPrintable(format));
} else {
- %PYARG_0 = Shiboken::String::fromCString(
- ((PyObject* )%PYSELF)->ob_type->tp_name);
+ %PYARG_0 = Shiboken::String::fromCString(PepType(Py_TYPE(%PYSELF))->tp_name);
}
</inject-code>
</add-function>
diff --git a/sources/pyside2/PySide2/QtWidgets/glue/qmenu_glue.cpp b/sources/pyside2/PySide2/QtWidgets/glue/qmenu_glue.cpp
index 8a4b7e62..4e9c8c3b 100644
--- a/sources/pyside2/PySide2/QtWidgets/glue/qmenu_glue.cpp
+++ b/sources/pyside2/PySide2/QtWidgets/glue/qmenu_glue.cpp
@@ -50,7 +50,11 @@ inline PyObject* addActionWithPyObject(QMenu* self, const QIcon& icon, const QSt
self->addAction(act);
PyObject* pyAct = %CONVERTTOPYTHON[QAction*](act);
- Shiboken::AutoDecRef result(PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered()), callback));
+ Shiboken::AutoDecRef result(PyObject_CallMethod(pyAct,
+ const_cast<char *>("connect"),
+ const_cast<char *>("OsO"),
+ pyAct,
+ SIGNAL(triggered()), callback));
if (result.isNull()) {
Py_DECREF(pyAct);
return 0;
diff --git a/sources/pyside2/PySide2/QtWidgets/glue/qmenubar_glue.cpp b/sources/pyside2/PySide2/QtWidgets/glue/qmenubar_glue.cpp
index fdd62112..8cdbc2e0 100644
--- a/sources/pyside2/PySide2/QtWidgets/glue/qmenubar_glue.cpp
+++ b/sources/pyside2/PySide2/QtWidgets/glue/qmenubar_glue.cpp
@@ -45,7 +45,10 @@ addActionWithPyObject(QMenuBar* self, const QString& text, PyObject* callback)
self->addAction(act);
PyObject* pyAct = %CONVERTTOPYTHON[QAction*](act);
- PyObject* result = PyObject_CallMethod(pyAct, "connect", "OsO", pyAct,
+ PyObject* result = PyObject_CallMethod(pyAct,
+ const_cast<char *>("connect"),
+ const_cast<char *>("OsO"),
+ pyAct,
SIGNAL(triggered(bool)), callback);
if (result == 0 || result == Py_False) {
diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
index b4a6c245..11e6a9f7 100644
--- a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
+++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml
@@ -269,7 +269,7 @@
<enum-type name="PanelModality" since="4.6"/>
<inject-code class="target" position="end">
PyObject *userTypeConstant = PyInt_FromLong(QGraphicsItem::UserType);
- PyDict_SetItemString(Sbk_QGraphicsItem_Type.super.ht_type.tp_dict, "UserType", userTypeConstant);
+ PyDict_SetItemString(PepType(Sbk_QGraphicsItem_TypeF())->tp_dict, "UserType", userTypeConstant);
</inject-code>
<modify-function signature="setParentItem(QGraphicsItem*)">
<modify-argument index="this">
@@ -1022,7 +1022,11 @@
%0 = new %TYPE(%1, %2);
</inject-code>
<inject-code class="target" position="end">
- Shiboken::AutoDecRef result(PyObject_CallMethod(%PYSELF, "connect", "OsO", %PYSELF, SIGNAL(activated()), %PYARG_3));
+ Shiboken::AutoDecRef result(PyObject_CallMethod(%PYSELF,
+ const_cast&lt;char *&gt;("connect"),
+ const_cast&lt;char *&gt;("OsO"),
+ %PYSELF, SIGNAL(activated()), %PYARG_3)
+ );
if (!result.isNull())
Shiboken::Object::setParent(%PYARG_2, %PYSELF);
</inject-code>
@@ -3029,7 +3033,11 @@
<inject-code>
QAction *action = %CPPSELF.addAction(%1, %2);
%PYARG_0 = %CONVERTTOPYTHON[QAction*](action);
- Shiboken::AutoDecRef result(PyObject_CallMethod(%PYARG_0, "connect", "OsO", %PYARG_0, SIGNAL(triggered()), %PYARG_3));
+ Shiboken::AutoDecRef result(PyObject_CallMethod(%PYARG_0,
+ const_cast&lt;char *&gt;("connect"),
+ const_cast&lt;char *&gt;("OsO"),
+ %PYARG_0, SIGNAL(triggered()), %PYARG_3)
+ );
</inject-code>
</modify-function>
<modify-function signature="addAction(QString,const QObject*,const char*)">
@@ -3045,7 +3053,11 @@
<inject-code>
QAction *action = %CPPSELF.addAction(%1);
%PYARG_0 = %CONVERTTOPYTHON[QAction*](action);
- Shiboken::AutoDecRef result(PyObject_CallMethod(%PYARG_0, "connect", "OsO", %PYARG_0, SIGNAL(triggered()), %PYARG_2));
+ Shiboken::AutoDecRef result(PyObject_CallMethod(%PYARG_0,
+ const_cast&lt;char *&gt;("connect"),
+ const_cast&lt;char *&gt;("OsO"),
+ %PYARG_0, SIGNAL(triggered()), %PYARG_2)
+ );
</inject-code>
</modify-function>
<modify-function signature="addAction(const QString&amp;)">
diff --git a/sources/pyside2/PySide2/typesystem_templates.xml b/sources/pyside2/PySide2/typesystem_templates.xml
index 798d02dd..103d773c 100644
--- a/sources/pyside2/PySide2/typesystem_templates.xml
+++ b/sources/pyside2/PySide2/typesystem_templates.xml
@@ -314,11 +314,12 @@
<!-- templates for __repr__ -->
<template name="repr_code">
- QString format = QString().sprintf("%s(%REPR_FORMAT)", ((PyObject*)%PYSELF)->ob_type->tp_name, %REPR_ARGS);
+ QString format = QString().sprintf("%s(%REPR_FORMAT)",
+ PepType(Py_TYPE(%PYSELF))->tp_name, %REPR_ARGS);
%PYARG_0 = Shiboken::String::fromCString(qPrintable(format));
</template>
<template name="repr_code_matrix">
- QString format= QString("%1((").arg(((PyObject*)%PYSELF)->ob_type->tp_name);
+ QString format= QString("%1((").arg(PepType(Py_TYPE(%PYSELF))->tp_name);
QList&lt; %MATRIX_TYPE &gt; cppArgs;
%MATRIX_TYPE data[%MATRIX_SIZE];
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);
diff --git a/sources/pyside2/plugins/customwidget.cpp b/sources/pyside2/plugins/customwidget.cpp
index c2ed00bd..bad05f2d 100644
--- a/sources/pyside2/plugins/customwidget.cpp
+++ b/sources/pyside2/plugins/customwidget.cpp
@@ -51,7 +51,7 @@ PyCustomWidget::PyCustomWidget(PyObject* objectType)
: m_data(new PyCustomWidgetPrivate())
{
m_data->pyObject = objectType;
- m_name = QString(reinterpret_cast<PyTypeObject*>(objectType)->tp_name);
+ m_name = QString(PepType(reinterpret_cast<PyTypeObject*>(objectType))->tp_name);
}
PyCustomWidget::~PyCustomWidget()