diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-05-28 11:26:04 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-09-18 22:34:21 +0200 |
| commit | ffcd3ad810feba486fd6f4001ca5c1ddad2731d5 (patch) | |
| tree | 36656bde6f4d22c0e475206a415da3a57055b616 | |
| parent | e24c1777c11c1e90972422bcf186f2f680509679 (diff) | |
Replace PepType_GetSlot() by PyType_GetSlot()
[ChangeLog][shiboken6] The helper function PepType_GetSlot() has been
removed. PyType_GetSlot() should be used instead.
Task-number: PYSIDE-2786
Change-Id: I72ba347588d720aecd5185adad6c503fde0c86b8
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| -rw-r--r-- | sources/pyside6/PySide6/glue/qtcore.cpp | 8 | ||||
| -rw-r--r-- | sources/pyside6/libpyside/dynamicqmetaobject.cpp | 2 | ||||
| -rw-r--r-- | sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp | 12 | ||||
| -rw-r--r-- | sources/shiboken6/generator/shiboken/cppgenerator.cpp | 2 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/pep384ext.h | 18 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/pep384impl.cpp | 33 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/pep384impl.h | 2 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/sbkcontainer.cpp | 6 |
8 files changed, 25 insertions, 58 deletions
diff --git a/sources/pyside6/PySide6/glue/qtcore.cpp b/sources/pyside6/PySide6/glue/qtcore.cpp index 8e2061091..7fe6e9902 100644 --- a/sources/pyside6/PySide6/glue/qtcore.cpp +++ b/sources/pyside6/PySide6/glue/qtcore.cpp @@ -1049,8 +1049,8 @@ if (msec == 0) { // %FUNCTION_NAME() - disable generation of c++ function call Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); auto *timerType = Shiboken::SbkType<QTimer>(); - auto newFunc = reinterpret_cast<newfunc>(PepType_GetSlot(timerType, Py_tp_new)); - auto initFunc = reinterpret_cast<initproc>(PepType_GetSlot(timerType, Py_tp_init)); + auto newFunc = reinterpret_cast<newfunc>(PyType_GetSlot(timerType, Py_tp_new)); + auto initFunc = reinterpret_cast<initproc>(PyType_GetSlot(timerType, Py_tp_init)); auto *pyTimer = newFunc(Shiboken::SbkType<QTimer>(), emptyTuple, nullptr); initFunc(pyTimer, emptyTuple, nullptr); @@ -1084,8 +1084,8 @@ if (msec == 0) { } else { Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); auto *timerType = Shiboken::SbkType<QTimer>(); - auto newFunc = reinterpret_cast<newfunc>(PepType_GetSlot(timerType, Py_tp_new)); - auto initFunc = reinterpret_cast<initproc>(PepType_GetSlot(timerType, Py_tp_init)); + auto newFunc = reinterpret_cast<newfunc>(PyType_GetSlot(timerType, Py_tp_new)); + auto initFunc = reinterpret_cast<initproc>(PyType_GetSlot(timerType, Py_tp_init)); auto *pyTimer = newFunc(Shiboken::SbkType<QTimer>(), emptyTuple, nullptr); initFunc(pyTimer, emptyTuple, nullptr); diff --git a/sources/pyside6/libpyside/dynamicqmetaobject.cpp b/sources/pyside6/libpyside/dynamicqmetaobject.cpp index ace83a17c..f3878b6e1 100644 --- a/sources/pyside6/libpyside/dynamicqmetaobject.cpp +++ b/sources/pyside6/libpyside/dynamicqmetaobject.cpp @@ -667,7 +667,7 @@ void MetaObjectBuilderPrivate::parsePythonType(PyTypeObject *type) const int index = m_baseObject->indexOfProperty(name); if (index == -1) addProperty(name, value); - } else if (PepType_GetSlot(Py_TYPE(value), Py_tp_call) != nullptr) { + } else if (PyType_GetSlot(Py_TYPE(value), Py_tp_call) != nullptr) { // PYSIDE-198: PyFunction_Check does not work with Nuitka. // Register slots. if (PyObject_HasAttr(value, slotAttrName)) { diff --git a/sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp b/sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp index 8f685713c..d0b2bfb96 100644 --- a/sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp +++ b/sources/pyside6/libpysideremoteobjects/pysidedynamicclass.cpp @@ -71,7 +71,8 @@ struct SourceDefs static int tp_init(PyObject *self, PyObject *args, PyObject *kwds) { - static initproc initFunc = reinterpret_cast<initproc>(PepType_GetSlot(getSbkType(), Py_tp_init)); + static initproc initFunc = reinterpret_cast<initproc>(PyType_GetSlot(getSbkType(), + Py_tp_init)); int res = initFunc(self, args, kwds); if (res < 0) { PyErr_Print(); @@ -223,7 +224,7 @@ struct ReplicaDefs static int tp_init(PyObject *self, PyObject *args, PyObject *kwds) { - static initproc initFunc = reinterpret_cast<initproc>(PepType_GetSlot(getSbkType(), + static initproc initFunc = reinterpret_cast<initproc>(PyType_GetSlot(getSbkType(), Py_tp_init)); QRemoteObjectReplica *replica = nullptr; if (PyTuple_Size(args) == 0) { @@ -347,14 +348,15 @@ struct ReplicaDefs static int DynamicType_traverse(PyObject *self, visitproc visit, void *arg) { - auto traverseProc = reinterpret_cast<traverseproc>(PepType_GetSlot(SbkObject_TypeF(), - Py_tp_traverse)); + auto traverseProc = reinterpret_cast<traverseproc>(PyType_GetSlot(SbkObject_TypeF(), + Py_tp_traverse)); return traverseProc(self, visit, arg); } static int DynamicType_clear(PyObject *self) { - auto clearProc = reinterpret_cast<inquiry>(PepType_GetSlot(SbkObject_TypeF(), Py_tp_clear)); + auto clearProc = reinterpret_cast<inquiry>(PyType_GetSlot(SbkObject_TypeF(), + Py_tp_clear)); return clearProc(self); } diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index eb88b95f2..ebc666429 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -118,7 +118,7 @@ struct pyTypeGetSlot TextStream &operator<<(TextStream &str, const pyTypeGetSlot &p) { - str << "reinterpret_cast<" << p.m_funcType << ">(PepType_GetSlot(" + str << "reinterpret_cast<" << p.m_funcType << ">(PyType_GetSlot(" << p.m_typeObject << ", " << p.m_slot << "));\n"; return str; } diff --git a/sources/shiboken6/libshiboken/pep384ext.h b/sources/shiboken6/libshiboken/pep384ext.h index 0ce53d3a7..b4fe4e3b7 100644 --- a/sources/shiboken6/libshiboken/pep384ext.h +++ b/sources/shiboken6/libshiboken/pep384ext.h @@ -9,7 +9,7 @@ /// Returns the allocator slot of the PyTypeObject. inline allocfunc PepExt_Type_GetAllocSlot(PyTypeObject *t) { - return reinterpret_cast<allocfunc>(PepType_GetSlot(t, Py_tp_alloc)); + return reinterpret_cast<allocfunc>(PyType_GetSlot(t, Py_tp_alloc)); } /// Invokes the allocator slot of the PyTypeObject. @@ -23,19 +23,19 @@ inline Type *PepExt_TypeCallAlloc(PyTypeObject *t, Py_ssize_t nitems) /// Returns the getattro slot of the PyTypeObject. inline getattrofunc PepExt_Type_GetGetAttroSlot(PyTypeObject *t) { - return reinterpret_cast<getattrofunc>(PepType_GetSlot(t, Py_tp_getattro)); + return reinterpret_cast<getattrofunc>(PyType_GetSlot(t, Py_tp_getattro)); } /// Returns the setattro slot of the PyTypeObject. inline setattrofunc PepExt_Type_GetSetAttroSlot(PyTypeObject *t) { - return reinterpret_cast<setattrofunc>(PepType_GetSlot(t, Py_tp_setattro)); + return reinterpret_cast<setattrofunc>(PyType_GetSlot(t, Py_tp_setattro)); } /// Returns the descr_get slot of the PyTypeObject. inline descrgetfunc PepExt_Type_GetDescrGetSlot(PyTypeObject *t) { - return reinterpret_cast<descrgetfunc>(PepType_GetSlot(t, Py_tp_descr_get)); + return reinterpret_cast<descrgetfunc>(PyType_GetSlot(t, Py_tp_descr_get)); } /// Invokes the descr_get slot of the PyTypeObject. @@ -47,31 +47,31 @@ inline PyObject *PepExt_Type_CallDescrGet(PyObject *self, PyObject *obj, PyObjec /// Returns the descr_set slot of the PyTypeObject. inline descrsetfunc PepExt_Type_GetDescrSetSlot(PyTypeObject *t) { - return reinterpret_cast<descrsetfunc>(PepType_GetSlot(t, Py_tp_descr_set)); + return reinterpret_cast<descrsetfunc>(PyType_GetSlot(t, Py_tp_descr_set)); } /// Returns the call slot of the PyTypeObject. inline ternaryfunc PepExt_Type_GetCallSlot(PyTypeObject *t) { - return reinterpret_cast<ternaryfunc>(PepType_GetSlot(t, Py_tp_call)); + return reinterpret_cast<ternaryfunc>(PyType_GetSlot(t, Py_tp_call)); } /// Returns the new slot of the PyTypeObject. inline newfunc PepExt_Type_GetNewSlot(PyTypeObject *t) { - return reinterpret_cast<newfunc>(PepType_GetSlot(t, Py_tp_new)); + return reinterpret_cast<newfunc>(PyType_GetSlot(t, Py_tp_new)); } /// Returns the init slot of the PyTypeObject. inline initproc PepExt_Type_GetInitSlot(PyTypeObject *t) { - return reinterpret_cast<initproc>(PepType_GetSlot(t, Py_tp_init)); + return reinterpret_cast<initproc>(PyType_GetSlot(t, Py_tp_init)); } /// Returns the free slot of the PyTypeObject. inline freefunc PepExt_Type_GetFreeSlot(PyTypeObject *t) { - return reinterpret_cast<freefunc>(PepType_GetSlot(t, Py_tp_free)); + return reinterpret_cast<freefunc>(PyType_GetSlot(t, Py_tp_free)); } /// Invokes the free slot of the PyTypeObject. diff --git a/sources/shiboken6/libshiboken/pep384impl.cpp b/sources/shiboken6/libshiboken/pep384impl.cpp index e2d76e4cd..716a0e850 100644 --- a/sources/shiboken6/libshiboken/pep384impl.cpp +++ b/sources/shiboken6/libshiboken/pep384impl.cpp @@ -1050,39 +1050,6 @@ int PepType_SetDict(PyTypeObject *type, PyObject *dict) return 0; } -// Pre 3.10, PyType_GetSlot() would only work for heap types. -// FIXME: PyType_GetSlot() can be used unconditionally when the -// minimum limited API version is >= 3.10. -void *PepType_GetSlot(PyTypeObject *type, int aSlot) -{ - static const bool is310 = _PepRuntimeVersion() >= 0x030A00; - if (is310 || (type->tp_flags & Py_TPFLAGS_HEAPTYPE) != 0) - return PyType_GetSlot(type, aSlot); - - switch (aSlot) { - case Py_tp_alloc: - return reinterpret_cast<void *>(type->tp_alloc); - case Py_tp_getattro: - return reinterpret_cast<void *>(type->tp_getattro); - case Py_tp_setattro: - return reinterpret_cast<void *>(type->tp_setattro); - case Py_tp_descr_get: - return reinterpret_cast<void *>(type->tp_descr_get); - case Py_tp_descr_set: - return reinterpret_cast<void *>(type->tp_descr_set); - case Py_tp_call: - return reinterpret_cast<void *>(type->tp_call); - case Py_tp_new: - return reinterpret_cast<void *>(type->tp_new); - case Py_tp_init: - return reinterpret_cast<void *>(type->tp_init); - case Py_tp_free: - return reinterpret_cast<void *>(type->tp_free); - } - assert(false); - return nullptr; -} - PyObject *PepEval_GetFrameGlobals() { // PyEval_GetFrameGlobals() (added to stable ABI in 3.13) returns a new reference diff --git a/sources/shiboken6/libshiboken/pep384impl.h b/sources/shiboken6/libshiboken/pep384impl.h index 509899738..18bbc4dfe 100644 --- a/sources/shiboken6/libshiboken/pep384impl.h +++ b/sources/shiboken6/libshiboken/pep384impl.h @@ -500,8 +500,6 @@ LIBSHIBOKEN_API PyObject *PepType_GetDict(PyTypeObject *type); // is no longer considered to be accessible, we treat it as such. LIBSHIBOKEN_API int PepType_SetDict(PyTypeObject *type, PyObject *dict); -LIBSHIBOKEN_API void *PepType_GetSlot(PyTypeObject *type, int aSlot); - // Runtime support for Python 3.13 stable ABI // Return dictionary of the global variables in the current execution frame diff --git a/sources/shiboken6/libshiboken/sbkcontainer.cpp b/sources/shiboken6/libshiboken/sbkcontainer.cpp index 52eb419a7..087b874cf 100644 --- a/sources/shiboken6/libshiboken/sbkcontainer.cpp +++ b/sources/shiboken6/libshiboken/sbkcontainer.cpp @@ -10,14 +10,14 @@ // and remove PepType_GetSlot() usage from the public header. ShibokenContainer *ShibokenSequenceContainerPrivateBase::allocContainer(PyTypeObject *subtype) { - allocfunc allocFunc = reinterpret_cast<allocfunc>(PepType_GetSlot(subtype, Py_tp_alloc)); + allocfunc allocFunc = reinterpret_cast<allocfunc>(PyType_GetSlot(subtype, Py_tp_alloc)); return reinterpret_cast<ShibokenContainer *>(allocFunc(subtype, 0)); } void ShibokenSequenceContainerPrivateBase::freeSelf(PyObject *pySelf) { - auto freeFunc = reinterpret_cast<freefunc>(PepType_GetSlot(Py_TYPE(pySelf)->tp_base, - Py_tp_free)); + auto freeFunc = reinterpret_cast<freefunc>(PyType_GetSlot(Py_TYPE(pySelf)->tp_base, + Py_tp_free)); freeFunc(pySelf); } |
