diff options
author | Cristián Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2024-11-06 11:10:03 +0100 |
---|---|---|
committer | Cristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2024-11-08 14:24:28 +0100 |
commit | 65a9ae9a853fa68ff997edbe3d6fd4eed022f1a0 (patch) | |
tree | 735b82851430560a81ec28a848cdd09fdb2c36c0 /sources/pyside6/libpyside | |
parent | c951f11196d0572b7250a74197937c02b74604dd (diff) |
limited api: Remove PyTuple_GET_ITEM, PyTuple_SET_ITEM, and PyTuple_GET_SIZE macros
Removing old macros for compatibility with the limited api,
and refactoring some of their usages
Change-Id: I33954199d2ef9884c64b963863b97aed851c440f
Pick-to: 6.8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/libpyside')
-rw-r--r-- | sources/pyside6/libpyside/dynamicqmetaobject.cpp | 6 | ||||
-rw-r--r-- | sources/pyside6/libpyside/feature_select.cpp | 8 | ||||
-rw-r--r-- | sources/pyside6/libpyside/pyside.cpp | 13 | ||||
-rw-r--r-- | sources/pyside6/libpyside/pysideclassdecorator.cpp | 4 | ||||
-rw-r--r-- | sources/pyside6/libpyside/pysideclassinfo.cpp | 2 | ||||
-rw-r--r-- | sources/pyside6/libpyside/pysideproperty.cpp | 14 | ||||
-rw-r--r-- | sources/pyside6/libpyside/pysidesignal.cpp | 10 | ||||
-rw-r--r-- | sources/pyside6/libpyside/pysideslot.cpp | 2 | ||||
-rw-r--r-- | sources/pyside6/libpyside/pysideweakref.cpp | 2 | ||||
-rw-r--r-- | sources/pyside6/libpyside/signalmanager.cpp | 2 |
10 files changed, 31 insertions, 32 deletions
diff --git a/sources/pyside6/libpyside/dynamicqmetaobject.cpp b/sources/pyside6/libpyside/dynamicqmetaobject.cpp index 94ce20226..95acab869 100644 --- a/sources/pyside6/libpyside/dynamicqmetaobject.cpp +++ b/sources/pyside6/libpyside/dynamicqmetaobject.cpp @@ -582,8 +582,8 @@ void MetaObjectBuilderPrivate::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 Py_ssize_t basesCount = PyTuple_GET_SIZE(mro); + PyObject *mro = type->tp_mro; + const Py_ssize_t basesCount = PyTuple_Size(mro); std::vector<PyTypeObject *> basesToCheck; // Prepend the actual type that we are parsing. @@ -593,7 +593,7 @@ void MetaObjectBuilderPrivate::parsePythonType(PyTypeObject *type) auto *sbkObjTypeF = SbkObject_TypeF(); auto *baseObjType = reinterpret_cast<PyTypeObject *>(&PyBaseObject_Type); for (Py_ssize_t i = 0; i < basesCount; ++i) { - auto *baseType = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, i)); + auto *baseType = reinterpret_cast<PyTypeObject *>(PyTuple_GetItem(mro, i)); if (baseType != sbkObjTypeF && baseType != baseObjType && !PySide::isQObjectDerived(baseType, false)) { basesToCheck.push_back(baseType); diff --git a/sources/pyside6/libpyside/feature_select.cpp b/sources/pyside6/libpyside/feature_select.cpp index 3d61f148f..305095d1f 100644 --- a/sources/pyside6/libpyside/feature_select.cpp +++ b/sources/pyside6/libpyside/feature_select.cpp @@ -347,10 +347,10 @@ static inline void SelectFeatureSet(PyTypeObject *type) last_select_id = select_id; auto *mro = type->tp_mro; - const Py_ssize_t n = PyTuple_GET_SIZE(mro); + const Py_ssize_t n = PyTuple_Size(mro); // We leave 'Shiboken.Object' and 'object' alone, therefore "n - 2". for (Py_ssize_t idx = 0; idx < n - 2; idx++) { - auto *sub_type = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, idx)); + auto *sub_type = reinterpret_cast<PyTypeObject *>(PyTuple_GetItem(mro, idx)); SelectFeatureSetSubtype(sub_type, select_id); } // PYSIDE-1436: Clear all caches for the type and subtypes. @@ -627,10 +627,10 @@ static QByteArrayList GetPropertyStringsMro(PyTypeObject *type) auto res = QByteArrayList(); PyObject *mro = type->tp_mro; - const Py_ssize_t n = PyTuple_GET_SIZE(mro); + const Py_ssize_t n = PyTuple_Size(mro); // We leave 'Shiboken.Object' and 'object' alone, therefore "n - 2". for (Py_ssize_t idx = 0; idx < n - 2; idx++) { - auto *subType = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, idx)); + auto *subType = reinterpret_cast<PyTypeObject *>(PyTuple_GetItem(mro, idx)); auto *props = SbkObjectType_GetPropertyStrings(subType); if (props != nullptr) for (; *props != nullptr; ++props) diff --git a/sources/pyside6/libpyside/pyside.cpp b/sources/pyside6/libpyside/pyside.cpp index fe1da77a1..272a006fc 100644 --- a/sources/pyside6/libpyside/pyside.cpp +++ b/sources/pyside6/libpyside/pyside.cpp @@ -222,10 +222,10 @@ static QByteArrayList _SbkType_LookupProperty(PyTypeObject *type, if (origName.isEmpty()) return QByteArrayList{}; PyObject *mro = type->tp_mro; - auto n = PyTuple_GET_SIZE(mro); + auto n = PyTuple_Size(mro); auto len = std::strlen(origName); for (Py_ssize_t idx = 0; idx < n; idx++) { - auto *base = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, idx)); + auto *base = reinterpret_cast<PyTypeObject *>(PyTuple_GetItem(mro, idx)); if (!SbkObjectType_Check(base)) continue; auto *props = SbkObjectType_GetPropertyStrings(base); @@ -499,20 +499,19 @@ void initQObjectSubType(PyTypeObject *type, PyObject *args, PyObject * /* kwds * { PyTypeObject *qObjType = Shiboken::Conversions::getPythonTypeObject("QObject*"); - PyObject *bases = PyTuple_GET_ITEM(args, 1); - int numBases = PyTuple_GET_SIZE(bases); + PyObject *bases = PyTuple_GetItem(args, 1); TypeUserData *userData = nullptr; - for (int i = 0; i < numBases; ++i) { - auto *base = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(bases, i)); + for (Py_ssize_t i = 0, numBases = PyTuple_Size(bases); i < numBases; ++i) { + auto *base = reinterpret_cast<PyTypeObject *>(PyTuple_GetItem(bases, i)); if (PyType_IsSubtype(base, qObjType)) { userData = retrieveTypeUserData(base); break; } } if (!userData) { - const char *className = Shiboken::String::toCString(PyTuple_GET_ITEM(args, 0)); + const char *className = Shiboken::String::toCString(PyTuple_GetItem(args, 0)); qWarning("Sub class of QObject not inheriting QObject!? Crash will happen when using %s.", className); return; diff --git a/sources/pyside6/libpyside/pysideclassdecorator.cpp b/sources/pyside6/libpyside/pysideclassdecorator.cpp index eee49939a..4386dcba6 100644 --- a/sources/pyside6/libpyside/pysideclassdecorator.cpp +++ b/sources/pyside6/libpyside/pysideclassdecorator.cpp @@ -59,7 +59,7 @@ int StringDecoratorPrivate::convertToString(PyObject *self, PyObject *args) { int result = -1; if (PyTuple_Size(args) == 1) { - PyObject *arg = PyTuple_GET_ITEM(args, 0); + PyObject *arg = PyTuple_GetItem(args, 0); if (PyUnicode_Check(arg)) { auto *pData = DecoratorPrivate::get<StringDecoratorPrivate>(self); result = 0; @@ -90,7 +90,7 @@ int TypeDecoratorPrivate::convertToType(PyObject *self, PyObject *args) int result = -1; const auto argsCount = PyTuple_Size(args); if (argsCount == 1) { - PyObject *arg = PyTuple_GET_ITEM(args, 0); + PyObject *arg = PyTuple_GetItem(args, 0); if (PyType_Check(arg)) { result = 0; auto *pData = DecoratorPrivate::get<TypeDecoratorPrivate>(self); diff --git a/sources/pyside6/libpyside/pysideclassinfo.cpp b/sources/pyside6/libpyside/pysideclassinfo.cpp index d2067e96c..db643df92 100644 --- a/sources/pyside6/libpyside/pysideclassinfo.cpp +++ b/sources/pyside6/libpyside/pysideclassinfo.cpp @@ -69,7 +69,7 @@ int ClassInfoPrivate::tp_init(PyObject *self, PyObject *args, PyObject *kwds) PyObject *infoDict = nullptr; auto size = PyTuple_Size(args); if (size == 1 && kwds == nullptr) { - PyObject *tmp = PyTuple_GET_ITEM(args, 0); + PyObject *tmp = PyTuple_GetItem(args, 0); if (PyDict_Check(tmp)) infoDict = tmp; } else if (size == 0 && kwds && PyDict_Check(kwds)) { diff --git a/sources/pyside6/libpyside/pysideproperty.cpp b/sources/pyside6/libpyside/pysideproperty.cpp index bbc289231..7c0400051 100644 --- a/sources/pyside6/libpyside/pysideproperty.cpp +++ b/sources/pyside6/libpyside/pysideproperty.cpp @@ -99,7 +99,7 @@ PyObject *PySidePropertyPrivate::getValue(PyObject *source) const if (fget) { Shiboken::AutoDecRef args(PyTuple_New(1)); Py_INCREF(source); - PyTuple_SET_ITEM(args, 0, source); + PyTuple_SetItem(args, 0, source); return PyObject_CallObject(fget, args); } return nullptr; @@ -109,8 +109,8 @@ int PySidePropertyPrivate::setValue(PyObject *source, PyObject *value) { if (fset && value) { Shiboken::AutoDecRef args(PyTuple_New(2)); - PyTuple_SET_ITEM(args, 0, source); - PyTuple_SET_ITEM(args, 1, value); + PyTuple_SetItem(args, 0, source); + PyTuple_SetItem(args, 1, value); Py_INCREF(source); Py_INCREF(value); Shiboken::AutoDecRef result(PyObject_CallObject(fset, args)); @@ -118,7 +118,7 @@ int PySidePropertyPrivate::setValue(PyObject *source, PyObject *value) } if (fdel) { Shiboken::AutoDecRef args(PyTuple_New(1)); - PyTuple_SET_ITEM(args, 0, source); + PyTuple_SetItem(args, 0, source); Py_INCREF(source); Shiboken::AutoDecRef result(PyObject_CallObject(fdel, args)); return (result.isNull() ? -1 : 0); @@ -132,7 +132,7 @@ int PySidePropertyPrivate::reset(PyObject *source) if (freset) { Shiboken::AutoDecRef args(PyTuple_New(1)); Py_INCREF(source); - PyTuple_SET_ITEM(args, 0, source); + PyTuple_SetItem(args, 0, source); Shiboken::AutoDecRef result(PyObject_CallObject(freset, args)); return (result.isNull() ? -1 : 0); } @@ -456,9 +456,9 @@ static PyObject *getFromType(PyTypeObject *type, PyObject *name) auto *attr = PyDict_GetItem(tpDict.object(), name); if (!attr) { PyObject *bases = type->tp_bases; - const Py_ssize_t size = PyTuple_GET_SIZE(bases); + const Py_ssize_t size = PyTuple_Size(bases); for (Py_ssize_t i = 0; i < size; ++i) { - PyObject *base = PyTuple_GET_ITEM(bases, i); + PyObject *base = PyTuple_GetItem(bases, i); attr = getFromType(reinterpret_cast<PyTypeObject *>(base), name); if (attr) return attr; diff --git a/sources/pyside6/libpyside/pysidesignal.cpp b/sources/pyside6/libpyside/pysidesignal.cpp index aaffc9548..0ce9fda61 100644 --- a/sources/pyside6/libpyside/pysidesignal.cpp +++ b/sources/pyside6/libpyside/pysidesignal.cpp @@ -277,7 +277,7 @@ static int signalTpInit(PyObject *obSelf, PyObject *args, PyObject *kwds) self->data->signalArguments = argumentNamesOpt.value(); for (Py_ssize_t i = 0, i_max = PyTuple_Size(args); i < i_max; i++) { - PyObject *arg = PyTuple_GET_ITEM(args, i); + PyObject *arg = PyTuple_GetItem(args, i); if (PySequence_Check(arg) && !Shiboken::String::check(arg) && !PyEnumMeta_Check(arg)) { tupledArgs = true; self->data->signatures.append(PySide::Signal::parseSignature(arg)); @@ -677,8 +677,8 @@ static PyObject *signalInstanceDisconnect(PyObject *self, PyObject *args) Shiboken::AutoDecRef pyArgs(PyList_New(0)); PyObject *slot = Py_None; - if (PyTuple_Check(args) && PyTuple_GET_SIZE(args)) - slot = PyTuple_GET_ITEM(args, 0); + if (PyTuple_Check(args) && PyTuple_Size(args)) + slot = PyTuple_GetItem(args, 0); bool match = false; if (Py_TYPE(slot) == PySideSignalInstance_TypeF()) { @@ -802,10 +802,10 @@ static PyObject *_getHomonymousMethod(PySideSignalInstance *inst) auto signalName = inst->d->signalName; Shiboken::AutoDecRef name(Shiboken::String::fromCString(signalName)); auto *mro = Py_TYPE(inst->d->source)->tp_mro; - const Py_ssize_t n = PyTuple_GET_SIZE(mro); + const Py_ssize_t n = PyTuple_Size(mro); for (Py_ssize_t idx = 0; idx < n; idx++) { - auto *sub_type = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, idx)); + auto *sub_type = reinterpret_cast<PyTypeObject *>(PyTuple_GetItem(mro, idx)); Shiboken::AutoDecRef tpDict(PepType_GetDict(sub_type)); auto *hom = PyDict_GetItem(tpDict, name); if (hom != nullptr && PyCallable_Check(hom) != 0) { diff --git a/sources/pyside6/libpyside/pysideslot.cpp b/sources/pyside6/libpyside/pysideslot.cpp index 0a448852e..5232b4e4c 100644 --- a/sources/pyside6/libpyside/pysideslot.cpp +++ b/sources/pyside6/libpyside/pysideslot.cpp @@ -88,7 +88,7 @@ int slotTpInit(PyObject *self, PyObject *args, PyObject *kw) if (!data->slotData) data->slotData = new SlotData; for(Py_ssize_t i = 0, i_max = PyTuple_Size(args); i < i_max; i++) { - PyObject *argType = PyTuple_GET_ITEM(args, i); + PyObject *argType = PyTuple_GetItem(args, i); const auto typeName = PySide::Signal::getTypeName(argType); if (typeName.isEmpty()) { PyErr_Format(PyExc_TypeError, "Unknown signal argument type: %s", Py_TYPE(argType)->tp_name); diff --git a/sources/pyside6/libpyside/pysideweakref.cpp b/sources/pyside6/libpyside/pysideweakref.cpp index e4d6a9a3d..48f9b3d03 100644 --- a/sources/pyside6/libpyside/pysideweakref.cpp +++ b/sources/pyside6/libpyside/pysideweakref.cpp @@ -45,7 +45,7 @@ static PyObject *CallableObject_call(PyObject *callable_object, PyObject *args, auto *obj = reinterpret_cast<PySideCallableObject *>(callable_object); obj->weakref_func(obj->user_data); - Py_XDECREF(PyTuple_GET_ITEM(args, 0)); //kill weak ref object + Py_XDECREF(PyTuple_GetItem(args, 0)); //kill weak ref object Py_RETURN_NONE; } diff --git a/sources/pyside6/libpyside/signalmanager.cpp b/sources/pyside6/libpyside/signalmanager.cpp index c3d66f3bc..3fe7416a4 100644 --- a/sources/pyside6/libpyside/signalmanager.cpp +++ b/sources/pyside6/libpyside/signalmanager.cpp @@ -473,7 +473,7 @@ static int callPythonMetaMethodHelper(const QByteArrayList ¶mTypes, Shiboken::Conversions::SpecificConverter converter(param.constData()); if (!converter.isValid()) return CallResult::CallArgumentError + int(i); - PyTuple_SET_ITEM(preparedArgs, i, converter.toPython(data)); + PyTuple_SetItem(preparedArgs, i, converter.toPython(data)); } QScopedPointer<Shiboken::Conversions::SpecificConverter> retConverter; |