aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/libpyside/pysideclassinfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/libpyside/pysideclassinfo.cpp')
-rw-r--r--sources/pyside2/libpyside/pysideclassinfo.cpp83
1 files changed, 29 insertions, 54 deletions
diff --git a/sources/pyside2/libpyside/pysideclassinfo.cpp b/sources/pyside2/libpyside/pysideclassinfo.cpp
index c5e0b5484..5e0ffed39 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;
}