diff options
Diffstat (limited to 'sources/shiboken6/libshiboken')
-rw-r--r-- | sources/shiboken6/libshiboken/basewrapper.cpp | 80 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/basewrapper.h | 6 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/basewrapper_p.h | 1 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/bindingmanager.cpp | 8 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/bindingmanager.h | 1 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/pep384impl.h | 5 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/sbkconverter.cpp | 8 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/sbkconverter.h | 1 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/sbkenum.cpp | 11 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/sbkenum.h | 2 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/sbkfeature_base.cpp | 12 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/sbkpython.h | 2 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/voidptr.cpp | 2 |
13 files changed, 55 insertions, 84 deletions
diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp index 809f4c25d..4ee2eda23 100644 --- a/sources/shiboken6/libshiboken/basewrapper.cpp +++ b/sources/shiboken6/libshiboken/basewrapper.cpp @@ -259,7 +259,7 @@ SbkObjectType *SbkObject_TypeF(void) type->tp_weaklistoffset = offsetof(SbkObject, weakreflist); type->tp_dictoffset = offsetof(SbkObject, ob_dict); } - return reinterpret_cast<SbkObjectType *>(type); + return type; } static int mainThreadDeletionHandler(void *) @@ -273,7 +273,6 @@ static void SbkDeallocWrapperCommon(PyObject *pyObj, bool canDelete) { auto *sbkObj = reinterpret_cast<SbkObject *>(pyObj); PyTypeObject *pyType = Py_TYPE(pyObj); - auto *sbkType = reinterpret_cast<SbkObjectType *>(pyType); // Need to decref the type if this is the dealloc func; if type // is subclassed, that dealloc func will decref (see subtype_dealloc @@ -319,7 +318,7 @@ static void SbkDeallocWrapperCommon(PyObject *pyObj, bool canDelete) PyObject_ClearWeakRefs(pyObj); // If I have ownership and is valid delete C++ pointer - auto *sotp = PepType_SOTP(sbkType); + auto *sotp = PepType_SOTP(pyType); canDelete &= sbkObj->d->hasOwnership && sbkObj->d->validCppObject; if (canDelete) { if (sotp->delete_in_main_thread && Shiboken::currentThreadId() != Shiboken::mainThreadId()) { @@ -391,11 +390,10 @@ void SbkDeallocWrapperWithPrivateDtor(PyObject *self) SbkDeallocWrapperCommon(self, false); } -void SbkObjectTypeDealloc(PyTypeObject *type) +void SbkObjectTypeDealloc(PyTypeObject *sbkType) { - SbkObjectType *sbkType = reinterpret_cast<SbkObjectType *>(type); SbkObjectTypePrivate *sotp = PepType_SOTP(sbkType); - auto pyObj = reinterpret_cast<PyObject *>(type); + auto pyObj = reinterpret_cast<PyObject *>(sbkType); PyObject_GC_UnTrack(pyObj); #ifndef Py_LIMITED_API @@ -408,7 +406,7 @@ void SbkObjectTypeDealloc(PyTypeObject *type) } free(sotp->original_name); sotp->original_name = nullptr; - if (!Shiboken::ObjectType::isUserType(type)) + if (!Shiboken::ObjectType::isUserType(sbkType)) Shiboken::Conversions::deleteConverter(sotp->converter); PepType_SOTP_delete(sbkType); } @@ -505,7 +503,7 @@ static PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyOb PyObject_GetAttr(reinterpret_cast<PyObject *>(&PyType_Type), Shiboken::PyName::mro())); auto hold = PyMethodDescr_TypePtr->tp_flags; PyMethodDescr_TypePtr->tp_flags &= ~Py_TPFLAGS_METHOD_DESCRIPTOR; - auto *newType = reinterpret_cast<SbkObjectType *>(type_new(metatype, args, kwds)); + auto *newType = reinterpret_cast<PyTypeObject *>(type_new(metatype, args, kwds)); PyMethodDescr_TypePtr->tp_flags = hold; if (!newType) @@ -513,7 +511,7 @@ static PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyOb SbkObjectTypePrivate *sotp = PepType_SOTP(newType); - const auto bases = Shiboken::getCppBaseClasses(&newType->type); + const auto bases = Shiboken::getCppBaseClasses(newType); if (bases.size() == 1) { SbkObjectTypePrivate *parentType = PepType_SOTP(bases.front()); sotp->mi_offsets = parentType->mi_offsets; @@ -558,7 +556,7 @@ static PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyOb static PyObject *_setupNew(SbkObject *self, PyTypeObject *subtype) { auto *obSubtype = reinterpret_cast<PyObject *>(subtype); - auto *sbkSubtype = reinterpret_cast<SbkObjectType *>(subtype); + auto *sbkSubtype = subtype; auto *obSelf = reinterpret_cast<PyObject *>(self); Py_INCREF(obSubtype); @@ -712,9 +710,8 @@ bool walkThroughClassHierarchy(PyTypeObject *currentType, HierarchyVisitor *visi for (int i = 0; !result && i < numBases; ++i) { auto type = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(bases, i)); if (PyType_IsSubtype(type, reinterpret_cast<PyTypeObject *>(SbkObject_TypeF()))) { - auto sbkType = reinterpret_cast<SbkObjectType *>(type); - result = PepType_SOTP(sbkType)->is_user_type - ? walkThroughClassHierarchy(type, visitor) : visitor->visit(sbkType); + result = PepType_SOTP(type)->is_user_type + ? walkThroughClassHierarchy(type, visitor) : visitor->visit(type); } } return result; @@ -740,7 +737,7 @@ bool BaseAccumulatorVisitor::visit(SbkObjectType *node) bool GetIndexVisitor::visit(SbkObjectType *node) { m_index++; - return PyType_IsSubtype(reinterpret_cast<PyTypeObject *>(node), m_desiredType); + return PyType_IsSubtype(node, m_desiredType); } bool DtorAccumulatorVisitor::visit(SbkObjectType *node) @@ -774,7 +771,7 @@ void init() if (PyType_Ready(SbkObjectType_TypeF()) < 0) Py_FatalError("[libshiboken] Failed to initialize Shiboken.BaseWrapperType metatype."); - if (PyType_Ready(reinterpret_cast<PyTypeObject *>(SbkObject_TypeF())) < 0) + if (PyType_Ready(SbkObject_TypeF()) < 0) Py_FatalError("[libshiboken] Failed to initialize Shiboken.BaseWrapper type."); VoidPtr::init(); @@ -785,7 +782,7 @@ void init() // PYSIDE-1415: Publish Shiboken objects. void initSignature(PyObject *module) { - auto type = reinterpret_cast<PyTypeObject *>(SbkObject_TypeF()); + auto *type = SbkObject_TypeF(); if (InitSignatureStrings(type, SbkObject_SignatureStrings) < 0) return; @@ -807,7 +804,7 @@ public: bool visit(SbkObjectType *node) override { - return reinterpret_cast<PyTypeObject *>(node) == m_typeToFind; + return node == m_typeToFind; } private: @@ -844,13 +841,12 @@ namespace ObjectType bool checkType(PyTypeObject *type) { - return PyType_IsSubtype(type, reinterpret_cast<PyTypeObject *>(SbkObject_TypeF())) != 0; + return PyType_IsSubtype(type, SbkObject_TypeF()) != 0; } bool isUserType(PyTypeObject *type) { - auto *objType = reinterpret_cast<SbkObjectType *>(type); - return checkType(type) && PepType_SOTP(objType)->is_user_type; + return checkType(type) && PepType_SOTP(type)->is_user_type; } bool canCallConstructor(PyTypeObject *myType, PyTypeObject *ctorType) @@ -871,8 +867,7 @@ bool hasCast(SbkObjectType *type) void *cast(SbkObjectType *sourceType, SbkObject *obj, PyTypeObject *pyTargetType) { auto *sotp = PepType_SOTP(sourceType); - auto *targetType = reinterpret_cast<SbkObjectType *>(pyTargetType); - return sotp->mi_specialcast(Object::cppPointer(obj, pyTargetType), targetType); + return sotp->mi_specialcast(Object::cppPointer(obj, pyTargetType), pyTargetType); } void setCastFunction(SbkObjectType *type, SpecialCastFunction func) @@ -938,16 +933,18 @@ introduceWrapperType(PyObject *enclosingObject, PyObject *heaptype = SbkType_FromSpecWithBases(typeSpec, baseTypes); Py_TYPE(heaptype) = SbkObjectType_TypeF(); Py_INCREF(Py_TYPE(heaptype)); - auto *type = reinterpret_cast<SbkObjectType *>(heaptype); + auto *type = reinterpret_cast<PyTypeObject *>(heaptype); if (baseType) { if (baseTypes) { - for (int i = 0; i < PySequence_Fast_GET_SIZE(baseTypes); ++i) - BindingManager::instance().addClassInheritance(reinterpret_cast<SbkObjectType *>(PySequence_Fast_GET_ITEM(baseTypes, i)), type); + for (int i = 0; i < PySequence_Fast_GET_SIZE(baseTypes); ++i) { + auto *st = reinterpret_cast<PyTypeObject *>(PySequence_Fast_GET_ITEM(baseTypes, i)); + BindingManager::instance().addClassInheritance(st, type); + } } else { BindingManager::instance().addClassInheritance(baseType, type); } } - if (PyType_Ready(reinterpret_cast<PyTypeObject *>(type)) < 0) + if (PyType_Ready(type) < 0) return nullptr; auto sotp = PepType_SOTP(type); @@ -995,7 +992,7 @@ SbkObjectType *typeForTypeName(const char *typeName) SbkObjectType *result{}; if (typeName) { if (PyTypeObject *pyType = Shiboken::Conversions::getPythonTypeObject(typeName)) - result = reinterpret_cast<SbkObjectType *>(pyType); + result = pyType; } return result; } @@ -1092,8 +1089,7 @@ void callCppDestructors(SbkObject *pyObj) return; } PyTypeObject *type = Py_TYPE(pyObj); - auto *sbkType = reinterpret_cast<SbkObjectType *>(type); - auto *sotp = PepType_SOTP(sbkType); + auto *sotp = PepType_SOTP(type); if (sotp->is_multicpp) { Shiboken::DtorAccumulatorVisitor visitor(pyObj); Shiboken::walkThroughClassHierarchy(type, &visitor); @@ -1152,7 +1148,7 @@ void getOwnership(PyObject *pyObj) void releaseOwnership(SbkObject *self) { // skip if the ownership have already moved to c++ - auto *selfType = reinterpret_cast<SbkObjectType *>(Py_TYPE(self)); + auto *selfType = Py_TYPE(self); if (!self->d->hasOwnership || Shiboken::Conversions::pythonTypeIsValueType(PepType_SOTP(selfType)->converter)) return; @@ -1258,8 +1254,7 @@ void makeValid(SbkObject *self) void *cppPointer(SbkObject *pyObj, PyTypeObject *desiredType) { PyTypeObject *pyType = Py_TYPE(pyObj); - auto *type = reinterpret_cast<SbkObjectType *>(pyType); - auto *sotp = PepType_SOTP(type); + auto *sotp = PepType_SOTP(pyType); int idx = 0; if (sotp->is_multicpp) idx = getTypeIndexOnHierarchy(pyType, desiredType); @@ -1281,9 +1276,8 @@ std::vector<void *> cppPointers(SbkObject *pyObj) bool setCppPointer(SbkObject *sbkObj, PyTypeObject *desiredType, void *cptr) { PyTypeObject *type = Py_TYPE(sbkObj); - auto *sbkType = reinterpret_cast<SbkObjectType *>(type); int idx = 0; - if (PepType_SOTP(sbkType)->is_multicpp) + if (PepType_SOTP(type)->is_multicpp) idx = getTypeIndexOnHierarchy(type, desiredType); const bool alreadyInitialized = sbkObj->d->cptr[idx] != nullptr; @@ -1346,7 +1340,7 @@ bool isValid(SbkObject *pyObj, bool throwPyError) bool isValid(PyObject *pyObj, bool throwPyError) { if (!pyObj || pyObj == Py_None || - !PyType_IsSubtype(Py_TYPE(pyObj), reinterpret_cast<PyTypeObject *>(SbkObject_TypeF()))) { + !PyType_IsSubtype(Py_TYPE(pyObj), SbkObject_TypeF())) { return true; } return isValid(reinterpret_cast<SbkObject *>(pyObj), throwPyError); @@ -1422,7 +1416,7 @@ PyObject *newObject(SbkObjectType *instanceType, } if (shouldCreate) { - self = reinterpret_cast<SbkObject *>(SbkObjectTpNew(reinterpret_cast<PyTypeObject *>(instanceType), nullptr, nullptr)); + self = reinterpret_cast<SbkObject *>(SbkObjectTpNew(instanceType, nullptr, nullptr)); self->d->cptr[0] = cptr; self->d->hasOwnership = hasOwnership; self->d->validCppObject = 1; @@ -1607,8 +1601,7 @@ void deallocData(SbkObject *self, bool cleanup) void setTypeUserData(SbkObject *wrapper, void *userData, DeleteUserDataFunc d_func) { auto *type = Py_TYPE(wrapper); - auto *sbkType = reinterpret_cast<SbkObjectType *>(type); - auto *sotp = PepType_SOTP(sbkType); + auto *sotp = PepType_SOTP(type); if (sotp->user_data) sotp->d_func(sotp->user_data); @@ -1619,8 +1612,7 @@ void setTypeUserData(SbkObject *wrapper, void *userData, DeleteUserDataFunc d_fu void *getTypeUserData(SbkObject *wrapper) { auto *type = Py_TYPE(wrapper); - auto *sbkType = reinterpret_cast<SbkObjectType *>(type); - return PepType_SOTP(sbkType)->user_data; + return PepType_SOTP(type)->user_data; } static inline bool isNone(const PyObject *o) @@ -1695,13 +1687,11 @@ std::string info(SbkObject *self) if (ObjectType::isUserType(Py_TYPE(self))) bases = getCppBaseClasses(Py_TYPE(self)); else - bases.push_back(reinterpret_cast<SbkObjectType *>(Py_TYPE(self))); + bases.push_back(Py_TYPE(self)); s << "C++ address....... "; - for (size_t i = 0, size = bases.size(); i < size; ++i) { - auto base = reinterpret_cast<PyTypeObject *>(bases[i]); - s << base->tp_name << '/' << self->d->cptr[i] << ' '; - } + for (size_t i = 0, size = bases.size(); i < size; ++i) + s << bases[i]->tp_name << '/' << self->d->cptr[i] << ' '; s << "\n"; } else { diff --git a/sources/shiboken6/libshiboken/basewrapper.h b/sources/shiboken6/libshiboken/basewrapper.h index 2406d5288..9e2183ec8 100644 --- a/sources/shiboken6/libshiboken/basewrapper.h +++ b/sources/shiboken6/libshiboken/basewrapper.h @@ -72,8 +72,6 @@ LIBSHIBOKEN_API void SbkDeallocWrapper(PyObject *pyObj); LIBSHIBOKEN_API void SbkDeallocQAppWrapper(PyObject *pyObj); LIBSHIBOKEN_API void SbkDeallocWrapperWithPrivateDtor(PyObject *self); -struct SbkObjectType; - /// Function signature for the multiple inheritance information initializers that should be provided by classes with multiple inheritance. typedef int *(*MultipleInheritanceInitFunction)(const void *); @@ -119,10 +117,6 @@ extern LIBSHIBOKEN_API SbkObjectType *SbkObject_TypeF(void); struct SbkObjectTypePrivate; /// PyTypeObject extended with C++ multiple inheritance information. -struct LIBSHIBOKEN_API SbkObjectType -{ - PyTypeObject type; -}; LIBSHIBOKEN_API PyObject *SbkObjectTpNew(PyTypeObject *subtype, PyObject *, PyObject *); diff --git a/sources/shiboken6/libshiboken/basewrapper_p.h b/sources/shiboken6/libshiboken/basewrapper_p.h index 478a7d52e..c565e32c5 100644 --- a/sources/shiboken6/libshiboken/basewrapper_p.h +++ b/sources/shiboken6/libshiboken/basewrapper_p.h @@ -49,7 +49,6 @@ #include <vector> struct SbkObject; -struct SbkObjectType; struct SbkConverter; namespace Shiboken diff --git a/sources/shiboken6/libshiboken/bindingmanager.cpp b/sources/shiboken6/libshiboken/bindingmanager.cpp index 37ef39a15..13b33942b 100644 --- a/sources/shiboken6/libshiboken/bindingmanager.cpp +++ b/sources/shiboken6/libshiboken/bindingmanager.cpp @@ -79,10 +79,10 @@ public: file << "digraph D {\n"; for (auto i = m_edges.begin(), end = m_edges.end(); i != end; ++i) { - auto node1 = reinterpret_cast<const PyTypeObject *>(i->first); + auto *node1 = i->first; const NodeList &nodeList = i->second; for (const SbkObjectType *o : nodeList) { - auto node2 = reinterpret_cast<const PyTypeObject *>(o); + auto *node2 = o; file << '"' << node2->tp_name << "\" -> \"" << node1->tp_name << "\"\n"; } @@ -213,7 +213,7 @@ bool BindingManager::hasWrapper(const void *cptr) void BindingManager::registerWrapper(SbkObject *pyObj, void *cptr) { - auto *instanceType = reinterpret_cast<SbkObjectType *>(Py_TYPE(pyObj)); + auto *instanceType = Py_TYPE(pyObj); auto *d = PepType_SOTP(instanceType); if (!d) @@ -234,7 +234,7 @@ void BindingManager::registerWrapper(SbkObject *pyObj, void *cptr) void BindingManager::releaseWrapper(SbkObject *sbkObj) { - auto *sbkType = reinterpret_cast<SbkObjectType *>(Py_TYPE(sbkObj)); + auto *sbkType = Py_TYPE(sbkObj); auto *d = PepType_SOTP(sbkType); int numBases = ((d && d->is_multicpp) ? getNumberOfCppBaseClasses(Py_TYPE(sbkObj)) : 1); diff --git a/sources/shiboken6/libshiboken/bindingmanager.h b/sources/shiboken6/libshiboken/bindingmanager.h index 5b2246685..ab0ad79de 100644 --- a/sources/shiboken6/libshiboken/bindingmanager.h +++ b/sources/shiboken6/libshiboken/bindingmanager.h @@ -45,7 +45,6 @@ #include "shibokenmacros.h" struct SbkObject; -struct SbkObjectType; namespace Shiboken { diff --git a/sources/shiboken6/libshiboken/pep384impl.h b/sources/shiboken6/libshiboken/pep384impl.h index d326141d6..cd62fbdc6 100644 --- a/sources/shiboken6/libshiboken/pep384impl.h +++ b/sources/shiboken6/libshiboken/pep384impl.h @@ -161,11 +161,10 @@ LIBSHIBOKEN_API PyObject *_PepType_Lookup(PyTypeObject *type, PyObject *name); * */ -struct SbkObjectType; struct SbkObjectTypePrivate; -LIBSHIBOKEN_API SbkObjectTypePrivate *PepType_SOTP(SbkObjectType *type); -LIBSHIBOKEN_API void PepType_SOTP_delete(SbkObjectType *type); +LIBSHIBOKEN_API SbkObjectTypePrivate *PepType_SOTP(PyTypeObject *type); +LIBSHIBOKEN_API void PepType_SOTP_delete(PyTypeObject *type); struct SbkEnumType; struct SbkEnumTypePrivate; diff --git a/sources/shiboken6/libshiboken/sbkconverter.cpp b/sources/shiboken6/libshiboken/sbkconverter.cpp index 87b4bda63..983a1deb5 100644 --- a/sources/shiboken6/libshiboken/sbkconverter.cpp +++ b/sources/shiboken6/libshiboken/sbkconverter.cpp @@ -134,7 +134,7 @@ SbkConverter *createConverter(SbkObjectType *type, CppToPythonFunc copyToPythonFunc) { SbkConverter *converter = - createConverterObject(reinterpret_cast<PyTypeObject *>(type), + createConverterObject(type, toCppPointerConvFunc, toCppPointerCheckFunc, pointerToPythonFunc, copyToPythonFunc); PepType_SOTP(type)->converter = converter; @@ -306,7 +306,7 @@ void *cppPointer(PyTypeObject *desiredType, SbkObject *pyIn) assert(pyIn); if (!ObjectType::checkType(desiredType)) return pyIn; - auto *inType = reinterpret_cast<SbkObjectType *>(Py_TYPE(pyIn)); + auto *inType = Py_TYPE(pyIn); if (ObjectType::hasCast(inType)) return ObjectType::cast(inType, pyIn, desiredType); return Object::cppPointer(pyIn, desiredType); @@ -319,7 +319,7 @@ void pythonToCppPointer(SbkObjectType *type, PyObject *pyIn, void *cppOut) assert(cppOut); *reinterpret_cast<void **>(cppOut) = pyIn == Py_None ? nullptr - : cppPointer(reinterpret_cast<PyTypeObject *>(type), reinterpret_cast<SbkObject *>(pyIn)); + : cppPointer(type, reinterpret_cast<SbkObject *>(pyIn)); } void pythonToCppPointer(const SbkConverter *converter, PyObject *pyIn, void *cppOut) @@ -329,7 +329,7 @@ void pythonToCppPointer(const SbkConverter *converter, PyObject *pyIn, void *cpp assert(cppOut); *reinterpret_cast<void **>(cppOut) = pyIn == Py_None ? nullptr - : cppPointer(reinterpret_cast<PyTypeObject *>(converter->pythonType), reinterpret_cast<SbkObject *>(pyIn)); + : cppPointer(converter->pythonType, reinterpret_cast<SbkObject *>(pyIn)); } static void _pythonToCppCopy(const SbkConverter *converter, PyObject *pyIn, void *cppOut) diff --git a/sources/shiboken6/libshiboken/sbkconverter.h b/sources/shiboken6/libshiboken/sbkconverter.h index 5bf006738..43f0643b4 100644 --- a/sources/shiboken6/libshiboken/sbkconverter.h +++ b/sources/shiboken6/libshiboken/sbkconverter.h @@ -50,7 +50,6 @@ #include <string> struct SbkObject; -struct SbkObjectType; /** * This is a convenience macro identical to Python's PyObject_TypeCheck, diff --git a/sources/shiboken6/libshiboken/sbkenum.cpp b/sources/shiboken6/libshiboken/sbkenum.cpp index 648254b4d..3789fe298 100644 --- a/sources/shiboken6/libshiboken/sbkenum.cpp +++ b/sources/shiboken6/libshiboken/sbkenum.cpp @@ -494,12 +494,12 @@ PyTypeObject *createGlobalEnum(PyObject *module, const char *name, const char *f PyTypeObject *createScopedEnum(SbkObjectType *scope, const char *name, const char *fullName, const char *cppName, PyTypeObject *flagsType) { PyTypeObject *enumType = createEnum(fullName, cppName, flagsType); - if (enumType && PyDict_SetItemString(reinterpret_cast<PyTypeObject *>(scope)->tp_dict, name, + if (enumType && PyDict_SetItemString(scope->tp_dict, name, reinterpret_cast<PyObject *>(enumType)) < 0) { Py_DECREF(enumType); return nullptr; } - if (flagsType && PyDict_SetItemString(reinterpret_cast<PyTypeObject *>(scope)->tp_dict, + if (flagsType && PyDict_SetItemString(scope->tp_dict, PepType_GetNameStr(flagsType), reinterpret_cast<PyObject *>(flagsType)) < 0) { Py_DECREF(enumType); @@ -534,16 +534,11 @@ bool createScopedEnumItem(PyTypeObject *enumType, PyTypeObject *scope, PyObject *enumItem = createEnumItem(enumType, itemName, itemValue); if (!enumItem) return false; - int ok = PyDict_SetItemString(reinterpret_cast<PyTypeObject *>(scope)->tp_dict, itemName, enumItem); + int ok = PyDict_SetItemString(scope->tp_dict, itemName, enumItem); Py_DECREF(enumItem); return ok >= 0; } -bool createScopedEnumItem(PyTypeObject *enumType, SbkObjectType *scope, const char *itemName, long itemValue) -{ - return createScopedEnumItem(enumType, reinterpret_cast<PyTypeObject *>(scope), itemName, itemValue); -} - PyObject * newItem(PyTypeObject *enumType, long itemValue, const char *itemName) { diff --git a/sources/shiboken6/libshiboken/sbkenum.h b/sources/shiboken6/libshiboken/sbkenum.h index fd0fcb904..f97997ae0 100644 --- a/sources/shiboken6/libshiboken/sbkenum.h +++ b/sources/shiboken6/libshiboken/sbkenum.h @@ -50,7 +50,6 @@ extern "C" LIBSHIBOKEN_API void init_enum(); extern LIBSHIBOKEN_API PyTypeObject *SbkEnumType_TypeF(void); -struct SbkObjectType; struct SbkConverter; struct SbkEnumType; struct SbkEnumTypePrivate; @@ -102,7 +101,6 @@ namespace Enum /// This function does the same as createGlobalEnumItem, but adds the enum to a Shiboken type or namespace. LIBSHIBOKEN_API bool createScopedEnumItem(PyTypeObject *enumType, PyTypeObject *scope, const char *itemName, long itemValue); - LIBSHIBOKEN_API bool createScopedEnumItem(PyTypeObject *enumType, SbkObjectType *scope, const char *itemName, long itemValue); LIBSHIBOKEN_API PyObject *newItem(PyTypeObject *enumType, long itemValue, const char *itemName = nullptr); diff --git a/sources/shiboken6/libshiboken/sbkfeature_base.cpp b/sources/shiboken6/libshiboken/sbkfeature_base.cpp index e015ac0c8..6b2037ecd 100644 --- a/sources/shiboken6/libshiboken/sbkfeature_base.cpp +++ b/sources/shiboken6/libshiboken/sbkfeature_base.cpp @@ -162,26 +162,22 @@ int SbkObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value) // Caching the select Id. int SbkObjectType_GetReserved(PyTypeObject *type) { - auto *sbkType = reinterpret_cast<SbkObjectType *>(type); - return PepType_SOTP(sbkType)->pyside_reserved_bits; + return PepType_SOTP(type)->pyside_reserved_bits; } void SbkObjectType_SetReserved(PyTypeObject *type, int value) { - auto *sbkType = reinterpret_cast<SbkObjectType *>(type); - PepType_SOTP(sbkType)->pyside_reserved_bits = value; + PepType_SOTP(type)->pyside_reserved_bits = value; } const char **SbkObjectType_GetPropertyStrings(PyTypeObject *type) { - auto *sbkType = reinterpret_cast<SbkObjectType *>(type); - return PepType_SOTP(sbkType)->propertyStrings; + return PepType_SOTP(type)->propertyStrings; } void SbkObjectType_SetPropertyStrings(PyTypeObject *type, const char **strings) { - auto *sbkType = reinterpret_cast<SbkObjectType *>(type); - PepType_SOTP(sbkType)->propertyStrings = strings; + PepType_SOTP(type)->propertyStrings = strings; } // PYSIDE-1626: Enforcing a context switch without further action. diff --git a/sources/shiboken6/libshiboken/sbkpython.h b/sources/shiboken6/libshiboken/sbkpython.h index 60997814f..d74918b62 100644 --- a/sources/shiboken6/libshiboken/sbkpython.h +++ b/sources/shiboken6/libshiboken/sbkpython.h @@ -107,4 +107,6 @@ extern "C" { #undef Py_TPFLAGS_HAVE_VERSION_TAG #define Py_TPFLAGS_HAVE_VERSION_TAG (0) +using SbkObjectType = PyTypeObject; // FIXME PYSIDE 7 remove + #endif diff --git a/sources/shiboken6/libshiboken/voidptr.cpp b/sources/shiboken6/libshiboken/voidptr.cpp index 6a69c39fd..a7eeb359c 100644 --- a/sources/shiboken6/libshiboken/voidptr.cpp +++ b/sources/shiboken6/libshiboken/voidptr.cpp @@ -332,7 +332,7 @@ static int voidPointerInitialized = false; void init() { - if (PyType_Ready(reinterpret_cast<PyTypeObject *>(SbkVoidPtrTypeF())) < 0) + if (PyType_Ready(SbkVoidPtrTypeF()) < 0) Py_FatalError("[libshiboken] Failed to initialize Shiboken.VoidPtr type."); else voidPointerInitialized = true; |