From 380c65e62de0e60da667dc0d87935171b91b9c6c Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sun, 16 Jun 2019 12:05:39 +0200 Subject: Cleanup pointer whitespace everywhere Among other files to fix, basewrapper.(cpp|h) was full of uncommon pointer whitespace. After fixing that, I could not resist and fixed also libshiboken, generators, and after acceptance also PySide. Most of the time, this regex worked fine (\w\w+)([*&]+)[ ]*(?![&*]*[/=]) replaced with \1 \2 but everything was checked by hand. I did not touch the shiboken tests which are quite hairy. It turned out that inserting a space between a variable and asterisk causes a crash of shiboken, if the same line contains "CONVERTTOCPP". This was temporarily fixed by adding another space after it. Example.. sources/pyside2/PySide2/glue/qtcore.cpp line 977 QByteArray * cppSelf = %CONVERTTOCPP[QByteArray *](obj); //XXX /|\ omitting this space crashes shiboken! cppgenerator.cpp was special, since it was modified to _generate_ correct pointer whitespace. This caused a few testcases to fail, which had to be adjusted, again. This was difficult since some internal names must end on "*" and generated code normally not. Removing the last errors involved binary search on path sets... Apply C++ 11 fixits to the changed code, where applicable. Done-with: Friedemann.Kleint@qt.io Task-number: PYSIDE-1037 Change-Id: I4ac070f52c5efb296c05d581c9d46e6f397a6c81 Reviewed-by: Qt CI Bot Reviewed-by: Friedemann Kleint --- sources/pyside2/libpyside/destroylistener.cpp | 12 +- sources/pyside2/libpyside/destroylistener.h | 10 +- sources/pyside2/libpyside/globalreceiverv2.cpp | 52 +++--- sources/pyside2/libpyside/globalreceiverv2.h | 16 +- sources/pyside2/libpyside/pyside.cpp | 88 ++++----- sources/pyside2/libpyside/pyside.h | 20 +- sources/pyside2/libpyside/pysideclassinfo.cpp | 36 ++-- sources/pyside2/libpyside/pysidemetafunction.cpp | 30 +-- sources/pyside2/libpyside/pysidemetafunction.h | 4 +- sources/pyside2/libpyside/pysidemetafunction_p.h | 4 +- sources/pyside2/libpyside/pysideproperty.cpp | 127 +++++++------ sources/pyside2/libpyside/pysideqflags.cpp | 26 +-- sources/pyside2/libpyside/pysidesignal.cpp | 224 +++++++++++------------ sources/pyside2/libpyside/pysideslot.cpp | 24 +-- sources/pyside2/libpyside/pysideweakref.cpp | 14 +- sources/pyside2/libpyside/signalmanager.cpp | 132 ++++++------- 16 files changed, 409 insertions(+), 410 deletions(-) (limited to 'sources/pyside2/libpyside') diff --git a/sources/pyside2/libpyside/destroylistener.cpp b/sources/pyside2/libpyside/destroylistener.cpp index c6dc54713..319a126cf 100644 --- a/sources/pyside2/libpyside/destroylistener.cpp +++ b/sources/pyside2/libpyside/destroylistener.cpp @@ -42,7 +42,7 @@ #include -PySide::DestroyListener* PySide::DestroyListener::m_instance = 0; +PySide::DestroyListener *PySide::DestroyListener::m_instance = nullptr; namespace PySide { @@ -53,7 +53,7 @@ struct DestroyListenerPrivate }; -DestroyListener* DestroyListener::instance() +DestroyListener *DestroyListener::instance() { if (!m_instance) m_instance = new DestroyListener(0); @@ -71,19 +71,19 @@ void DestroyListener::destroy() void DestroyListener::listen(QObject *obj) { - SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(obj); + SbkObject *wrapper = Shiboken::BindingManager::instance().retrieveWrapper(obj); if (!wrapper) // avoid problem with multiple inheritance return; if (Py_IsInitialized() == 0) onObjectDestroyed(obj); else - QObject::connect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(onObjectDestroyed(QObject*)), Qt::DirectConnection); + QObject::connect(obj, SIGNAL(destroyed(QObject *)), this, SLOT(onObjectDestroyed(QObject *)), Qt::DirectConnection); } -void DestroyListener::onObjectDestroyed(QObject* obj) +void DestroyListener::onObjectDestroyed(QObject *obj) { - SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(obj); + SbkObject *wrapper = Shiboken::BindingManager::instance().retrieveWrapper(obj); if (wrapper) //make sure the object exists before destroy Shiboken::Object::destroy(wrapper, obj); } diff --git a/sources/pyside2/libpyside/destroylistener.h b/sources/pyside2/libpyside/destroylistener.h index b1a0597c5..dedcca662 100644 --- a/sources/pyside2/libpyside/destroylistener.h +++ b/sources/pyside2/libpyside/destroylistener.h @@ -52,16 +52,16 @@ class PYSIDE_API DestroyListener : public QObject { Q_OBJECT public: - PYSIDE_DEPRECATED(static DestroyListener* instance()); + PYSIDE_DEPRECATED(static DestroyListener *instance()); static void destroy(); - void listen(QObject* obj); + void listen(QObject *obj); public Q_SLOTS: - void onObjectDestroyed(QObject* obj); + void onObjectDestroyed(QObject *obj); private: - static DestroyListener* m_instance; - DestroyListenerPrivate* m_d; + static DestroyListener *m_instance; + DestroyListenerPrivate *m_d; DestroyListener(QObject *parent); ~DestroyListener() override; }; diff --git a/sources/pyside2/libpyside/globalreceiverv2.cpp b/sources/pyside2/libpyside/globalreceiverv2.cpp index 43ce50a75..170cbf22f 100644 --- a/sources/pyside2/libpyside/globalreceiverv2.cpp +++ b/sources/pyside2/libpyside/globalreceiverv2.cpp @@ -62,27 +62,27 @@ class DynamicSlotDataV2 { Q_DISABLE_COPY(DynamicSlotDataV2) public: - DynamicSlotDataV2(PyObject* callback, GlobalReceiverV2* parent); + DynamicSlotDataV2(PyObject *callback, GlobalReceiverV2 *parent); ~DynamicSlotDataV2(); - int addSlot(const char* signature); - int id(const char* signature) const; - PyObject* callback(); + int addSlot(const char *signature); + int id(const char *signature) const; + PyObject *callback(); QByteArray hash() const; void notify(); - static void onCallbackDestroyed(void* data); + static void onCallbackDestroyed(void *data); static QByteArray hash(PyObject *callback); private: bool m_isMethod; - PyObject* m_callback; - PyObject* m_pythonSelf; - PyObject* m_pyClass; - PyObject* m_weakRef; + PyObject *m_callback; + PyObject *m_pythonSelf; + PyObject *m_pyClass; + PyObject *m_weakRef; QMap m_signatures; - GlobalReceiverV2* m_parent; + GlobalReceiverV2 *m_parent; QByteArray m_hash; }; @@ -90,7 +90,7 @@ class DynamicSlotDataV2 using namespace PySide; -DynamicSlotDataV2::DynamicSlotDataV2(PyObject* callback, GlobalReceiverV2* parent) +DynamicSlotDataV2::DynamicSlotDataV2(PyObject *callback, GlobalReceiverV2 *parent) : m_pythonSelf(0), m_pyClass(0), m_weakRef(0), m_parent(parent) { Shiboken::GilState gil; @@ -124,7 +124,7 @@ QByteArray DynamicSlotDataV2::hash() const return m_hash; } -QByteArray DynamicSlotDataV2::hash(PyObject* callback) +QByteArray DynamicSlotDataV2::hash(PyObject *callback) { Shiboken::GilState gil; if (PyMethod_Check(callback)) { @@ -134,9 +134,9 @@ QByteArray DynamicSlotDataV2::hash(PyObject* callback) return QByteArray::number(qlonglong(PyObject_Hash(callback))); } -PyObject* DynamicSlotDataV2::callback() +PyObject *DynamicSlotDataV2::callback() { - PyObject* callback = m_callback; + PyObject *callback = m_callback; //create a callback based on method data if (m_isMethod) @@ -151,13 +151,13 @@ PyObject* DynamicSlotDataV2::callback() return callback; } -int DynamicSlotDataV2::id(const char* signature) const +int DynamicSlotDataV2::id(const char *signature) const { const auto it = m_signatures.constFind(signature); return it != m_signatures.cend() ? it.value() : -1; } -int DynamicSlotDataV2::addSlot(const char* signature) +int DynamicSlotDataV2::addSlot(const char *signature) { int index = id(signature); if (index == -1) @@ -167,7 +167,7 @@ int DynamicSlotDataV2::addSlot(const char* signature) void DynamicSlotDataV2::onCallbackDestroyed(void *data) { - DynamicSlotDataV2* self = reinterpret_cast(data); + auto self = reinterpret_cast(data); self->m_weakRef = 0; Py_BEGIN_ALLOW_THREADS delete self->m_parent; @@ -222,12 +222,12 @@ GlobalReceiverV2::~GlobalReceiverV2() delete data; } -int GlobalReceiverV2::addSlot(const char* signature) +int GlobalReceiverV2::addSlot(const char *signature) { return m_data->addSlot(signature); } -void GlobalReceiverV2::incRef(const QObject* link) +void GlobalReceiverV2::incRef(const QObject *link) { if (link) { if (!m_refs.contains(link)) { @@ -247,7 +247,7 @@ void GlobalReceiverV2::incRef(const QObject* link) } } -void GlobalReceiverV2::decRef(const QObject* link) +void GlobalReceiverV2::decRef(const QObject *link) { if (m_refs.empty()) return; @@ -273,7 +273,7 @@ void GlobalReceiverV2::decRef(const QObject* link) } -int GlobalReceiverV2::refCount(const QObject* link) const +int GlobalReceiverV2::refCount(const QObject *link) const { if (link) return m_refs.count(link); @@ -283,7 +283,7 @@ int GlobalReceiverV2::refCount(const QObject* link) const void GlobalReceiverV2::notify() { - const auto objSet = QSet::fromList(m_refs); + const auto objSet = QSet::fromList(m_refs); Py_BEGIN_ALLOW_THREADS for (const QObject *o : objSet) { QMetaObject::disconnect(o, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID); @@ -297,17 +297,17 @@ QByteArray GlobalReceiverV2::hash() const return m_data->hash(); } -QByteArray GlobalReceiverV2::hash(PyObject* callback) +QByteArray GlobalReceiverV2::hash(PyObject *callback) { return DynamicSlotDataV2::hash(callback); } -const QMetaObject* GlobalReceiverV2::metaObject() const +const QMetaObject *GlobalReceiverV2::metaObject() const { return const_cast(this)->m_metaObject.update(); } -int GlobalReceiverV2::qt_metacall(QMetaObject::Call call, int id, void** args) +int GlobalReceiverV2::qt_metacall(QMetaObject::Call call, int id, void **args) { Shiboken::GilState gil; Q_ASSERT(call == QMetaObject::InvokeMetaMethod); @@ -328,7 +328,7 @@ int GlobalReceiverV2::qt_metacall(QMetaObject::Call call, int id, void** args) if (id == DESTROY_SLOT_ID) { if (m_refs.empty()) return -1; - QObject *obj = *reinterpret_cast(args[1]); + auto obj = *reinterpret_cast(args[1]); incRef(); //keep the object live (safe ref) m_refs.removeAll(obj); // remove all refs to this object decRef(); //remove the safe ref diff --git a/sources/pyside2/libpyside/globalreceiverv2.h b/sources/pyside2/libpyside/globalreceiverv2.h index b92be93a8..433f587a9 100644 --- a/sources/pyside2/libpyside/globalreceiverv2.h +++ b/sources/pyside2/libpyside/globalreceiverv2.h @@ -82,8 +82,8 @@ public: /** * Reimplemented function from QObject **/ - int qt_metacall(QMetaObject::Call call, int id, void** args) override; - const QMetaObject* metaObject() const override; + int qt_metacall(QMetaObject::Call call, int id, void **args) override; + const QMetaObject *metaObject() const override; /** * Add a extra slot to this object @@ -91,7 +91,7 @@ public: * @param signature The signature of the slot to be added * @return The index of this slot on metaobject **/ - int addSlot(const char* signature); + int addSlot(const char *signature); /** * Notify to GlobalReceiver about when a new connection was made @@ -103,14 +103,14 @@ public: * * @param link This is a optional paramenter used to link the ref to some QObject life **/ - void incRef(const QObject* link = 0); + void incRef(const QObject *link = nullptr); /** * Used to decrement the reference of the GlobalReceiver object * * @param link This is a optional paramenter used to dismiss the link ref to some QObject **/ - void decRef(const QObject* link = 0); + void decRef(const QObject *link = nullptr); /* * Return the count of refs which the GlobalReceiver has @@ -118,7 +118,7 @@ public: * @param link If any QObject was passed, the function return the number of references relative to this 'link' object * @return The number of references **/ - int refCount(const QObject* link) const; + int refCount(const QObject *link) const; /** * Use to retrieve the unique hash of this GlobalReceiver object @@ -133,7 +133,7 @@ public: * @param callback The Python callable object used to calculate the id * @return a string with a unique id based on GlobalReceiver contents **/ - static QByteArray hash(PyObject* callback); + static QByteArray hash(PyObject *callback); const MetaObjectBuilder &metaObjectBuilder() const { return m_metaObject; } MetaObjectBuilder &metaObjectBuilder() { return m_metaObject; } @@ -141,7 +141,7 @@ public: private: MetaObjectBuilder m_metaObject; DynamicSlotDataV2 *m_data; - QList m_refs; + QList m_refs; SharedMap m_sharedMap; }; diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp index fff28a9e7..9ee20f461 100644 --- a/sources/pyside2/libpyside/pyside.cpp +++ b/sources/pyside2/libpyside/pyside.cpp @@ -72,7 +72,7 @@ #include static QStack cleanupFunctionList; -static void* qobjectNextAddr; +static void *qobjectNextAddr; QT_BEGIN_NAMESPACE extern bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, @@ -94,7 +94,7 @@ void init(PyObject *module) SignalManager::instance(); } -static bool _setProperty(PyObject* qObj, PyObject *name, PyObject *value, bool *accept) +static bool _setProperty(PyObject *qObj, PyObject *name, PyObject *value, bool *accept) { QByteArray propName(Shiboken::String::toCString(name)); propName[0] = std::toupper(propName[0]); @@ -112,14 +112,14 @@ static bool _setProperty(PyObject* qObj, PyObject *name, PyObject *value, bool * Shiboken::AutoDecRef attr(PyObject_GenericGetAttr(qObj, name)); if (PySide::Property::checkType(attr)) { *accept = true; - if (PySide::Property::setValue(reinterpret_cast(attr.object()), qObj, value) < 0) + if (PySide::Property::setValue(reinterpret_cast(attr.object()), qObj, value) < 0) return false; } } return true; } -bool fillQtProperties(PyObject* qObj, const QMetaObject* metaObj, PyObject* kwds, const char** blackList, unsigned int blackListSize) +bool fillQtProperties(PyObject *qObj, const QMetaObject *metaObj, PyObject *kwds, const char **blackList, unsigned int blackListSize) { PyObject *key, *value; @@ -170,11 +170,11 @@ void runCleanupFunctions() PySide::DestroyListener::destroy(); } -static void destructionVisitor(SbkObject* pyObj, void* data) +static void destructionVisitor(SbkObject *pyObj, void *data) { - void** realData = reinterpret_cast(data); - SbkObject* pyQApp = reinterpret_cast(realData[0]); - PyTypeObject* pyQObjectType = reinterpret_cast(realData[1]); + auto realData = reinterpret_cast(data); + auto pyQApp = reinterpret_cast(realData[0]); + auto pyQObjectType = reinterpret_cast(realData[1]); if (pyObj != pyQApp && PyObject_TypeCheck(pyObj, pyQObjectType)) { if (Shiboken::Object::hasOwnership(pyObj) && Shiboken::Object::isValid(pyObj, false)) { @@ -190,17 +190,17 @@ static void destructionVisitor(SbkObject* pyObj, void* data) void destroyQCoreApplication() { - QCoreApplication* app = QCoreApplication::instance(); + QCoreApplication *app = QCoreApplication::instance(); if (!app) return; SignalManager::instance().clear(); - Shiboken::BindingManager& bm = Shiboken::BindingManager::instance(); - SbkObject* pyQApp = bm.retrieveWrapper(app); - PyTypeObject* pyQObjectType = Shiboken::Conversions::getPythonTypeObject("QObject*"); + Shiboken::BindingManager &bm = Shiboken::BindingManager::instance(); + SbkObject *pyQApp = bm.retrieveWrapper(app); + PyTypeObject *pyQObjectType = Shiboken::Conversions::getPythonTypeObject("QObject*"); assert(pyQObjectType); - void* data[2] = {pyQApp, pyQObjectType}; + void *data[2] = {pyQApp, pyQObjectType}; bm.visitAllPyObjects(&destructionVisitor, &data); // in the end destroy app @@ -214,26 +214,26 @@ void destroyQCoreApplication() MakeSingletonQAppWrapper(NULL); } -std::size_t getSizeOfQObject(SbkObjectType* type) +std::size_t getSizeOfQObject(SbkObjectType *type) { return retrieveTypeUserData(type)->cppObjSize; } -void initDynamicMetaObject(SbkObjectType* type, const QMetaObject* base, std::size_t cppObjSize) +void initDynamicMetaObject(SbkObjectType *type, const QMetaObject *base, std::size_t cppObjSize) { //create DynamicMetaObject based on python type auto userData = - new TypeUserData(reinterpret_cast(type), base, cppObjSize); + new TypeUserData(reinterpret_cast(type), base, cppObjSize); userData->mo.update(); Shiboken::ObjectType::setTypeUserData(type, userData, Shiboken::callCppDestructor); //initialize staticQMetaObject property void *metaObjectPtr = const_cast(userData->mo.update()); - static SbkConverter* converter = Shiboken::Conversions::getConverter("QMetaObject"); + static SbkConverter *converter = Shiboken::Conversions::getConverter("QMetaObject"); if (!converter) return; Shiboken::AutoDecRef pyMetaObject(Shiboken::Conversions::pointerToPython(converter, metaObjectPtr)); - PyObject_SetAttrString(reinterpret_cast(type), "staticMetaObject", pyMetaObject); + PyObject_SetAttrString(reinterpret_cast(type), "staticMetaObject", pyMetaObject); } TypeUserData *retrieveTypeUserData(SbkObjectType *sbkTypeObj) @@ -266,23 +266,23 @@ const QMetaObject *retrieveMetaObject(PyObject *pyObj) return retrieveMetaObject(pyTypeObj); } -void initDynamicMetaObject(SbkObjectType* type, const QMetaObject* base) +void initDynamicMetaObject(SbkObjectType *type, const QMetaObject *base) { initDynamicMetaObject(type, base, 0); } void initQObjectSubType(SbkObjectType *type, PyObject *args, PyObject * /* kwds */) { - PyTypeObject* qObjType = Shiboken::Conversions::getPythonTypeObject("QObject*"); + PyTypeObject *qObjType = Shiboken::Conversions::getPythonTypeObject("QObject*"); QByteArray className(Shiboken::String::toCString(PyTuple_GET_ITEM(args, 0))); - PyObject* bases = PyTuple_GET_ITEM(args, 1); + PyObject *bases = PyTuple_GET_ITEM(args, 1); int numBases = PyTuple_GET_SIZE(bases); TypeUserData *userData = nullptr; for (int i = 0; i < numBases; ++i) { - PyTypeObject* base = reinterpret_cast(PyTuple_GET_ITEM(bases, i)); + auto base = reinterpret_cast(PyTuple_GET_ITEM(bases, i)); if (PyType_IsSubtype(base, qObjType)) { userData = retrieveTypeUserData(base); break; @@ -295,14 +295,14 @@ void initQObjectSubType(SbkObjectType *type, PyObject *args, PyObject * /* kwds initDynamicMetaObject(type, userData->mo.update(), userData->cppObjSize); } -PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* name) +PyObject *getMetaDataFromQObject(QObject *cppSelf, PyObject *self, PyObject *name) { - PyObject* attr = PyObject_GenericGetAttr(self, name); - if (!Shiboken::Object::isValid(reinterpret_cast(self), false)) + PyObject *attr = PyObject_GenericGetAttr(self, name); + if (!Shiboken::Object::isValid(reinterpret_cast(self), false)) return attr; if (attr && Property::checkType(attr)) { - PyObject *value = Property::getValue(reinterpret_cast(attr), self); + PyObject *value = Property::getValue(reinterpret_cast(attr), self); Py_DECREF(attr); if (!value) return 0; @@ -312,17 +312,17 @@ PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* nam //mutate native signals to signal instance type if (attr && PyObject_TypeCheck(attr, PySideSignalTypeF())) { - PyObject* signal = reinterpret_cast(Signal::initialize(reinterpret_cast(attr), name, self)); - PyObject_SetAttr(self, name, reinterpret_cast(signal)); + PyObject *signal = reinterpret_cast(Signal::initialize(reinterpret_cast(attr), name, self)); + PyObject_SetAttr(self, name, reinterpret_cast(signal)); return signal; } //search on metaobject (avoid internal attributes started with '__') if (!attr) { - const char* cname = Shiboken::String::toCString(name); + const char *cname = Shiboken::String::toCString(name); uint cnameLen = qstrlen(cname); if (std::strncmp("__", cname, 2)) { - const QMetaObject* metaObject = cppSelf->metaObject(); + const QMetaObject *metaObject = cppSelf->metaObject(); //signal QList signalList; for(int i=0, i_max = metaObject->methodCount(); i < i_max; i++) { @@ -334,7 +334,7 @@ PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* nam if (method.methodType() == QMetaMethod::Signal) { signalList.append(method); } else { - PySideMetaFunction* func = MetaFunction::newObject(cppSelf, i); + PySideMetaFunction *func = MetaFunction::newObject(cppSelf, i); if (func) { PyObject *result = reinterpret_cast(func); PyObject_SetAttr(self, name, result); @@ -344,7 +344,7 @@ PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* nam } } if (!signalList.empty()) { - PyObject* pySignal = reinterpret_cast(Signal::newObjectFromMethod(self, signalList)); + PyObject *pySignal = reinterpret_cast(Signal::newObjectFromMethod(self, signalList)); PyObject_SetAttr(self, name, pySignal); return pySignal; } @@ -353,24 +353,24 @@ PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* nam return attr; } -bool inherits(PyTypeObject* objType, const char* class_name) +bool inherits(PyTypeObject *objType, const char *class_name) { if (strcmp(objType->tp_name, class_name) == 0) return true; - PyTypeObject* base = objType->tp_base; + PyTypeObject *base = objType->tp_base; if (base == 0) return false; return inherits(base, class_name); } -void* nextQObjectMemoryAddr() +void *nextQObjectMemoryAddr() { return qobjectNextAddr; } -void setNextQObjectMemoryAddr(void* addr) +void setNextQObjectMemoryAddr(void *addr) { qobjectNextAddr = addr; } @@ -379,27 +379,27 @@ void setNextQObjectMemoryAddr(void* addr) // A QSharedPointer is used with a deletion function to invalidate a pointer // when the property value is cleared. This should be a QSharedPointer with -// a void* pointer, but that isn't allowed +// a void *pointer, but that isn't allowed typedef char any_t; Q_DECLARE_METATYPE(QSharedPointer); namespace PySide { -static void invalidatePtr(any_t* object) +static void invalidatePtr(any_t *object) { Shiboken::GilState state; - SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(object); + SbkObject *wrapper = Shiboken::BindingManager::instance().retrieveWrapper(object); if (wrapper != NULL) Shiboken::BindingManager::instance().releaseWrapper(wrapper); } static const char invalidatePropertyName[] = "_PySideInvalidatePtr"; -PyObject* getWrapperForQObject(QObject* cppSelf, SbkObjectType* sbk_type) +PyObject *getWrapperForQObject(QObject *cppSelf, SbkObjectType *sbk_type) { - PyObject* pyOut = reinterpret_cast(Shiboken::BindingManager::instance().retrieveWrapper(cppSelf)); + PyObject *pyOut = reinterpret_cast(Shiboken::BindingManager::instance().retrieveWrapper(cppSelf)); if (pyOut) { Py_INCREF(pyOut); return pyOut; @@ -410,7 +410,7 @@ PyObject* getWrapperForQObject(QObject* cppSelf, SbkObjectType* sbk_type) // set and check if it's created after the set call QVariant existing = cppSelf->property(invalidatePropertyName); if (!existing.isValid()) { - QSharedPointer shared_with_del(reinterpret_cast(cppSelf), invalidatePtr); + QSharedPointer shared_with_del(reinterpret_cast(cppSelf), invalidatePtr); cppSelf->setProperty(invalidatePropertyName, QVariant::fromValue(shared_with_del)); pyOut = reinterpret_cast(Shiboken::BindingManager::instance().retrieveWrapper(cppSelf)); if (pyOut) { @@ -419,7 +419,7 @@ PyObject* getWrapperForQObject(QObject* cppSelf, SbkObjectType* sbk_type) } } - const char* typeName = typeid(*cppSelf).name(); + const char *typeName = typeid(*cppSelf).name(); pyOut = Shiboken::Object::newObject(sbk_type, cppSelf, false, false, typeName); return pyOut; @@ -509,7 +509,7 @@ bool registerInternalQtConf() #if PY_MAJOR_VERSION >= 3 QString::fromWCharArray(Py_GetProgramFullPath()); #else - // Python 2 unfortunately returns a char* array instead of a wchar*, which means that on + // Python 2 unfortunately returns a char * array instead of a wchar *, which means that on // Windows if the executable path contains unicode characters, the returned path will be // invalid. We can't use QCoreApplication::applicationFilePath because it requires an // existing QCoreApplication instance despite being a static method. diff --git a/sources/pyside2/libpyside/pyside.h b/sources/pyside2/libpyside/pyside.h index b53048eba..1529d79c9 100644 --- a/sources/pyside2/libpyside/pyside.h +++ b/sources/pyside2/libpyside/pyside.h @@ -76,7 +76,7 @@ inline uint hash(const T& value) * \param kwds key->value dictonary. * \return True if everything goes well, false with a Python error setted otherwise. */ -PYSIDE_API bool fillQtProperties(PyObject* qObj, const QMetaObject* metaObj, PyObject* kwds, const char** blackList, unsigned int blackListSize); +PYSIDE_API bool fillQtProperties(PyObject *qObj, const QMetaObject *metaObj, PyObject *kwds, const char **blackList, unsigned int blackListSize); /** * If the type \p T was registered on Qt meta type system with Q_DECLARE_METATYPE macro, this class will initialize @@ -99,13 +99,13 @@ template struct initQtMetaType { }; -PYSIDE_DEPRECATED(PYSIDE_API void initDynamicMetaObject(SbkObjectType* type, const QMetaObject* base)); -PYSIDE_API void initDynamicMetaObject(SbkObjectType* type, const QMetaObject* base, +PYSIDE_DEPRECATED(PYSIDE_API void initDynamicMetaObject(SbkObjectType *type, const QMetaObject *base)); +PYSIDE_API void initDynamicMetaObject(SbkObjectType *type, const QMetaObject *base, std::size_t cppObjSize); -PYSIDE_API void initQObjectSubType(SbkObjectType* type, PyObject* args, PyObject* kwds); +PYSIDE_API void initQObjectSubType(SbkObjectType *type, PyObject *args, PyObject *kwds); /// Return the size in bytes of a type that inherits QObject. -PYSIDE_API std::size_t getSizeOfQObject(SbkObjectType* type); +PYSIDE_API std::size_t getSizeOfQObject(SbkObjectType *type); typedef void (*CleanupFunction)(void); @@ -127,7 +127,7 @@ PYSIDE_API void destroyQCoreApplication(); * \param name Name of the argument which the function will try retrieve from MetaData * \return The Python object which contains the Data obtained in metaObject or the Python attribute related with name */ -PYSIDE_API PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* name); +PYSIDE_API PyObject *getMetaDataFromQObject(QObject *cppSelf, PyObject *self, PyObject *name); /** * Check if self inherits from class_name @@ -135,12 +135,12 @@ PYSIDE_API PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, Py * \param class_name strict with the class name * \return Returns true if self object inherits from class_name, otherwise returns false */ -PYSIDE_API bool inherits(PyTypeObject* self, const char* class_name); +PYSIDE_API bool inherits(PyTypeObject *self, const char *class_name); -PYSIDE_API void* nextQObjectMemoryAddr(); -PYSIDE_API void setNextQObjectMemoryAddr(void* addr); +PYSIDE_API void *nextQObjectMemoryAddr(); +PYSIDE_API void setNextQObjectMemoryAddr(void *addr); -PYSIDE_API PyObject* getWrapperForQObject(QObject* cppSelf, SbkObjectType* sbk_type); +PYSIDE_API PyObject *getWrapperForQObject(QObject *cppSelf, SbkObjectType *sbk_type); #ifdef PYSIDE_QML_SUPPORT // Used by QtQuick module to notify QtQml that custom QtQuick items can be registered. diff --git a/sources/pyside2/libpyside/pysideclassinfo.cpp b/sources/pyside2/libpyside/pysideclassinfo.cpp index 4edf0fa91..bf2a1307f 100644 --- a/sources/pyside2/libpyside/pysideclassinfo.cpp +++ b/sources/pyside2/libpyside/pysideclassinfo.cpp @@ -51,10 +51,10 @@ extern "C" { -static PyObject* classInfoTpNew(PyTypeObject* subtype, PyObject* args, PyObject* kwds); -static int classInfoTpInit(PyObject*, PyObject*, PyObject*); -static void classInfoFree(void*); -static PyObject* classCall(PyObject*, PyObject*, PyObject*); +static PyObject *classInfoTpNew(PyTypeObject *subtype, PyObject *args, PyObject *kwds); +static int classInfoTpInit(PyObject *, PyObject *, PyObject *); +static void classInfoFree(void *); +static PyObject *classCall(PyObject *, PyObject *, PyObject *); static PyType_Slot PySideClassInfoType_slots[] = { {Py_tp_call, (void *)classCall}, @@ -89,8 +89,8 @@ PyObject *classCall(PyObject *self, PyObject *args, PyObject * /* kw */) return 0; } - PySideClassInfo* data = reinterpret_cast(self); - PySideClassInfoPrivate* pData = data->d; + PySideClassInfo *data = reinterpret_cast(self); + PySideClassInfoPrivate *pData = data->d; if (pData->m_alreadyWrapped) { PyErr_SetString(PyExc_TypeError, "This instance of ClassInfo() was already used to wrap an object"); @@ -106,7 +106,7 @@ PyObject *classCall(PyObject *self, PyObject *args, PyObject * /* kw */) return 0; } - PyTypeObject *klassType = reinterpret_cast(klass); + PyTypeObject *klassType = reinterpret_cast(klass); if (Shiboken::ObjectType::checkType(klassType)) { if (auto userData = PySide::retrieveTypeUserData(klassType)) { PySide::MetaObjectBuilder &mo = userData->mo; @@ -127,7 +127,7 @@ PyObject *classCall(PyObject *self, PyObject *args, PyObject * /* kw */) static PyObject *classInfoTpNew(PyTypeObject *subtype, PyObject * /* args */, PyObject * /* kwds */) { - PySideClassInfo* me = reinterpret_cast(subtype->tp_alloc(subtype, 0)); + PySideClassInfo *me = reinterpret_cast(subtype->tp_alloc(subtype, 0)); me->d = new PySideClassInfoPrivate; me->d->m_alreadyWrapped = false; @@ -135,18 +135,18 @@ static PyObject *classInfoTpNew(PyTypeObject *subtype, PyObject * /* args */, Py return reinterpret_cast(me); } -int classInfoTpInit(PyObject* self, PyObject* args, PyObject* kwds) +int classInfoTpInit(PyObject *self, PyObject *args, PyObject *kwds) { if (PyTuple_Check(args) && PyTuple_Size(args) > 0) { PyErr_Format(PyExc_TypeError, "ClassInfo() takes exactly 0 positional arguments (%zd given)", PyTuple_Size(args)); return -1; } - PySideClassInfo* data = reinterpret_cast(self); - PySideClassInfoPrivate* pData = data->d; + PySideClassInfo *data = reinterpret_cast(self); + PySideClassInfoPrivate *pData = data->d; - PyObject* key; - PyObject* value; + PyObject *key; + PyObject *value; Py_ssize_t pos = 0; // PyDict_Next causes a segfault if kwds is empty @@ -166,8 +166,8 @@ int classInfoTpInit(PyObject* self, PyObject* args, PyObject* kwds) void classInfoFree(void *self) { - PyObject* pySelf = reinterpret_cast(self); - PySideClassInfo* data = reinterpret_cast(self); + auto pySelf = reinterpret_cast(self); + auto data = reinterpret_cast(self); delete data->d; Py_TYPE(pySelf)->tp_base->tp_free(self); @@ -179,7 +179,7 @@ void classInfoFree(void *self) namespace PySide { namespace ClassInfo { -void init(PyObject* module) +void init(PyObject *module) { if (PyType_Ready(PySideClassInfoTypeF()) < 0) return; @@ -188,14 +188,14 @@ void init(PyObject* module) PyModule_AddObject(module, CLASSINFO_CLASS_NAME, reinterpret_cast(PySideClassInfoTypeF())); } -bool checkType(PyObject* pyObj) +bool checkType(PyObject *pyObj) { if (pyObj) return PyType_IsSubtype(Py_TYPE(pyObj), PySideClassInfoTypeF()); return false; } -QMap getMap(PySideClassInfo* obj) +QMap getMap(PySideClassInfo *obj) { return obj->d->m_data; } diff --git a/sources/pyside2/libpyside/pysidemetafunction.cpp b/sources/pyside2/libpyside/pysidemetafunction.cpp index 4cdc7ec16..346117201 100644 --- a/sources/pyside2/libpyside/pysidemetafunction.cpp +++ b/sources/pyside2/libpyside/pysidemetafunction.cpp @@ -49,13 +49,13 @@ extern "C" struct PySideMetaFunctionPrivate { - QObject* qobject; + QObject *qobject; int methodIndex; }; //methods -static void functionFree(void*); -static PyObject* functionCall(PyObject*, PyObject*, PyObject*); +static void functionFree(void *); +static PyObject *functionCall(PyObject *, PyObject *, PyObject *); static PyType_Slot PySideMetaFunctionType_slots[] = { {Py_tp_call, (void *)functionCall}, @@ -83,15 +83,15 @@ PyTypeObject *PySideMetaFunctionTypeF(void) void functionFree(void *self) { - PySideMetaFunction* function = reinterpret_cast(self); + PySideMetaFunction *function = reinterpret_cast(self); delete function->d; } PyObject *functionCall(PyObject *self, PyObject *args, PyObject * /* kw */) { - PySideMetaFunction* function = reinterpret_cast(self); + PySideMetaFunction *function = reinterpret_cast(self); - PyObject* retVal; + PyObject *retVal; if (!PySide::MetaFunction::call(function->d->qobject, function->d->methodIndex, args, &retVal)) return 0; return retVal; @@ -101,7 +101,7 @@ PyObject *functionCall(PyObject *self, PyObject *args, PyObject * /* kw */) namespace PySide { namespace MetaFunction { -void init(PyObject* module) +void init(PyObject *module) { if (PyType_Ready(PySideMetaFunctionTypeF()) < 0) return; @@ -109,7 +109,7 @@ void init(PyObject* module) PyModule_AddObject(module, "MetaFunction", reinterpret_cast(PySideMetaFunctionTypeF())); } -PySideMetaFunction* newObject(QObject* source, int methodIndex) +PySideMetaFunction *newObject(QObject *source, int methodIndex) { if (methodIndex >= source->metaObject()->methodCount()) return 0; @@ -117,7 +117,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, PySideMetaFunctionTypeF()); + PySideMetaFunction *function = PyObject_New(PySideMetaFunction, PySideMetaFunctionTypeF()); function->d = new PySideMetaFunctionPrivate(); function->d->qobject = source; function->d->methodIndex = methodIndex; @@ -126,7 +126,7 @@ PySideMetaFunction* newObject(QObject* source, int methodIndex) return 0; } -bool call(QObject* self, int methodIndex, PyObject* args, PyObject** retVal) +bool call(QObject *self, int methodIndex, PyObject *args, PyObject **retVal) { QMetaMethod method = self->metaObject()->method(methodIndex); @@ -150,11 +150,11 @@ bool call(QObject* self, int methodIndex, PyObject* args, PyObject** retVal) return false; } - QVariant* methValues = new QVariant[numArgs]; - void** methArgs = new void*[numArgs]; + QVariant *methValues = new QVariant[numArgs]; + void **methArgs = new void *[numArgs]; // Prepare room for return type - const char* returnType = method.typeName(); + const char *returnType = method.typeName(); if (returnType && std::strcmp("void", returnType)) argTypes.prepend(returnType); else @@ -162,7 +162,7 @@ bool call(QObject* self, int methodIndex, PyObject* args, PyObject** retVal) int i; for (i = 0; i < numArgs; ++i) { - const QByteArray& typeName = argTypes[i]; + const QByteArray &typeName = argTypes.at(i); // This must happen only when the method hasn't return type. if (typeName.isEmpty()) { methArgs[i] = 0; @@ -204,7 +204,7 @@ bool call(QObject* self, int methodIndex, PyObject* args, PyObject** retVal) if (retVal) { if (methArgs[0]) { - static SbkConverter* qVariantTypeConverter = Shiboken::Conversions::getConverter("QVariant"); + static SbkConverter *qVariantTypeConverter = Shiboken::Conversions::getConverter("QVariant"); Q_ASSERT(qVariantTypeConverter); *retVal = Shiboken::Conversions::copyToPython(qVariantTypeConverter, &methValues[0]); } else { diff --git a/sources/pyside2/libpyside/pysidemetafunction.h b/sources/pyside2/libpyside/pysidemetafunction.h index 1085ecb5e..f7cc5307b 100644 --- a/sources/pyside2/libpyside/pysidemetafunction.h +++ b/sources/pyside2/libpyside/pysidemetafunction.h @@ -54,7 +54,7 @@ extern "C" struct PYSIDE_API PySideMetaFunction { PyObject_HEAD - PySideMetaFunctionPrivate* d; + PySideMetaFunctionPrivate *d; }; }; //extern "C" @@ -67,7 +67,7 @@ namespace PySide { namespace MetaFunction { * @param methodIndex The index of this function on MetaObject * @return Return a new reference of PySideMetaFunction **/ -PYSIDE_API PySideMetaFunction* newObject(QObject* obj, int methodIndex); +PYSIDE_API PySideMetaFunction *newObject(QObject *obj, int methodIndex); } //namespace MetaFunction } //namespace PySide diff --git a/sources/pyside2/libpyside/pysidemetafunction_p.h b/sources/pyside2/libpyside/pysidemetafunction_p.h index 442e05ea7..c67233857 100644 --- a/sources/pyside2/libpyside/pysidemetafunction_p.h +++ b/sources/pyside2/libpyside/pysidemetafunction_p.h @@ -50,11 +50,11 @@ QT_END_NAMESPACE namespace PySide { namespace MetaFunction { - void init(PyObject* module); + void init(PyObject *module); /** * Does a Qt metacall on a QObject */ - bool call(QObject* self, int methodIndex, PyObject* args, PyObject** retVal = 0); + bool call(QObject *self, int methodIndex, PyObject *args, PyObject **retVal = nullptr); } //namespace MetaFunction } //namespace PySide diff --git a/sources/pyside2/libpyside/pysideproperty.cpp b/sources/pyside2/libpyside/pysideproperty.cpp index c48a6f882..a2bf5fd2b 100644 --- a/sources/pyside2/libpyside/pysideproperty.cpp +++ b/sources/pyside2/libpyside/pysideproperty.cpp @@ -51,16 +51,16 @@ extern "C" { -static PyObject* qpropertyTpNew(PyTypeObject* subtype, PyObject* args, PyObject* kwds); -static int qpropertyTpInit(PyObject*, PyObject*, PyObject*); -static void qpropertyDeAlloc(PyObject* self); +static PyObject *qpropertyTpNew(PyTypeObject *subtype, PyObject *args, PyObject *kwds); +static int qpropertyTpInit(PyObject *, PyObject *, PyObject *); +static void qpropertyDeAlloc(PyObject *self); //methods -static PyObject* qPropertyCall(PyObject*, PyObject*, PyObject*); -static PyObject* qPropertySetter(PyObject*, PyObject*); -static PyObject* qPropertyGetter(PyObject*, PyObject*); -static int qpropertyTraverse(PyObject* self, visitproc visit, void* arg); -static int qpropertyClear(PyObject* self); +static PyObject *qPropertyCall(PyObject *, PyObject *, PyObject *); +static PyObject *qPropertySetter(PyObject *, PyObject *); +static PyObject *qPropertyGetter(PyObject *, PyObject *); +static int qpropertyTraverse(PyObject *self, visitproc visit, void *arg); +static int qpropertyClear(PyObject *self); static PyMethodDef PySidePropertyMethods[] = { {"setter", (PyCFunction)qPropertySetter, METH_O, 0}, @@ -98,7 +98,7 @@ PyTypeObject *PySidePropertyTypeF(void) return type; } -static void qpropertyMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::Call call, void** args) +static void qpropertyMetaCall(PySideProperty *pp, PyObject *self, QMetaObject::Call call, void **args) { Shiboken::Conversions::SpecificConverter converter(pp->d->typeName); Q_ASSERT(converter); @@ -109,7 +109,7 @@ static void qpropertyMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::C case QMetaObject::ReadProperty: { Shiboken::GilState gil; - PyObject* value = PySide::Property::getValue(pp, self); + PyObject *value = PySide::Property::getValue(pp, self); if (value) { converter.toCpp(value, args[0]); Py_DECREF(value); @@ -150,16 +150,16 @@ static void qpropertyMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::C static PyObject *qpropertyTpNew(PyTypeObject *subtype, PyObject * /* args */, PyObject * /* kwds */) { - PySideProperty* me = reinterpret_cast(subtype->tp_alloc(subtype, 0)); + PySideProperty *me = reinterpret_cast(subtype->tp_alloc(subtype, 0)); me->d = new PySidePropertyPrivate; return reinterpret_cast(me); } -int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds) +int qpropertyTpInit(PyObject *self, PyObject *args, PyObject *kwds) { - PyObject* type = 0; - PySideProperty* data = reinterpret_cast(self); - PySidePropertyPrivate* pData = data->d; + PyObject *type = nullptr; + auto data = reinterpret_cast(self); + PySidePropertyPrivate *pData = data->d; pData->metaCallHandler = &qpropertyMetaCall; static const char *kwlist[] = {"type", "fget", "fset", "freset", "fdel", "doc", "notify", @@ -169,7 +169,7 @@ int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds) if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOOsObbbbbb:QtCore.QProperty", - const_cast(kwlist), + const_cast(kwlist), /*OO*/ &type, &(pData->fget), /*OOO*/ &(pData->fset), &(pData->freset), &(pData->fdel), /*s*/ &doc, @@ -208,7 +208,7 @@ int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds) return -1; } -void qpropertyDeAlloc(PyObject* self) +void qpropertyDeAlloc(PyObject *self) { qpropertyClear(self); Py_TYPE(self)->tp_free(self); @@ -218,8 +218,8 @@ PyObject *qPropertyCall(PyObject *self, PyObject *args, PyObject * /* kw */) { PyObject *callback = PyTuple_GetItem(args, 0); if (PyFunction_Check(callback)) { - PySideProperty *prop = reinterpret_cast(self); - PySidePropertyPrivate* pData = prop->d; + auto prop = reinterpret_cast(self); + PySidePropertyPrivate *pData = prop->d; Py_INCREF(callback); pData->fget = callback; @@ -231,11 +231,11 @@ PyObject *qPropertyCall(PyObject *self, PyObject *args, PyObject * /* kw */) return nullptr; } -PyObject* qPropertySetter(PyObject* self, PyObject* callback) +PyObject *qPropertySetter(PyObject *self, PyObject *callback) { if (PyFunction_Check(callback)) { - PySideProperty *prop = reinterpret_cast(self); - PySidePropertyPrivate* pData = prop->d; + PySideProperty *prop = reinterpret_cast(self); + PySidePropertyPrivate *pData = prop->d; Py_INCREF(callback); pData->fset = callback; @@ -247,11 +247,11 @@ PyObject* qPropertySetter(PyObject* self, PyObject* callback) return nullptr; } -PyObject* qPropertyGetter(PyObject* self, PyObject* callback) +PyObject *qPropertyGetter(PyObject *self, PyObject *callback) { if (PyFunction_Check(callback)) { - PySideProperty *prop = reinterpret_cast(self); - PySidePropertyPrivate* pData = prop->d; + PySideProperty *prop = reinterpret_cast(self); + PySidePropertyPrivate *pData = prop->d; Py_INCREF(callback); pData->fget = callback; @@ -263,9 +263,9 @@ PyObject* qPropertyGetter(PyObject* self, PyObject* callback) return nullptr; } -static int qpropertyTraverse(PyObject* self, visitproc visit, void* arg) +static int qpropertyTraverse(PyObject *self, visitproc visit, void *arg) { - PySidePropertyPrivate* data = reinterpret_cast(self)->d; + PySidePropertyPrivate *data = reinterpret_cast(self)->d; if (!data) return 0; @@ -277,9 +277,9 @@ static int qpropertyTraverse(PyObject* self, visitproc visit, void* arg) return 0; } -static int qpropertyClear(PyObject* self) +static int qpropertyClear(PyObject *self) { - PySidePropertyPrivate* data = reinterpret_cast(self)->d; + PySidePropertyPrivate *data = reinterpret_cast(self)->d; if (!data) return 0; @@ -291,7 +291,7 @@ static int qpropertyClear(PyObject* self) delete data; - reinterpret_cast(self)->d = 0; + reinterpret_cast(self)->d = nullptr; return 0; } @@ -299,16 +299,16 @@ static int qpropertyClear(PyObject* self) namespace { -static PyObject* getFromType(PyTypeObject* type, PyObject* name) +static PyObject *getFromType(PyTypeObject *type, PyObject *name) { - PyObject* attr = 0; + PyObject *attr = nullptr; attr = PyDict_GetItem(type->tp_dict, name); if (!attr) { - PyObject* bases = type->tp_bases; + PyObject *bases = type->tp_bases; int size = PyTuple_GET_SIZE(bases); for(int i=0; i < size; i++) { - PyObject* base = PyTuple_GET_ITEM(bases, i); - attr = getFromType(reinterpret_cast(base), name); + PyObject *base = PyTuple_GET_ITEM(bases, i); + attr = getFromType(reinterpret_cast(base), name); if (attr) return attr; } @@ -321,7 +321,7 @@ static PyObject* getFromType(PyTypeObject* type, PyObject* name) namespace PySide { namespace Property { -void init(PyObject* module) +void init(PyObject *module) { if (PyType_Ready(PySidePropertyTypeF()) < 0) return; @@ -330,7 +330,7 @@ void init(PyObject* module) PyModule_AddObject(module, QPROPERTY_CLASS_NAME, reinterpret_cast(PySidePropertyTypeF())); } -bool checkType(PyObject* pyObj) +bool checkType(PyObject *pyObj) { if (pyObj) { return PyType_IsSubtype(Py_TYPE(pyObj), PySidePropertyTypeF()); @@ -338,14 +338,14 @@ bool checkType(PyObject* pyObj) return false; } -bool isPropertyType(PyObject* pyObj) +bool isPropertyType(PyObject *pyObj) { return checkType(pyObj); } -int setValue(PySideProperty* self, PyObject* source, PyObject* value) +int setValue(PySideProperty *self, PyObject *source, PyObject *value) { - PyObject* fset = self->d->fset; + PyObject *fset = self->d->fset; if (fset) { Shiboken::AutoDecRef args(PyTuple_New(2)); PyTuple_SET_ITEM(args, 0, source); @@ -360,9 +360,9 @@ int setValue(PySideProperty* self, PyObject* source, PyObject* value) return -1; } -PyObject* getValue(PySideProperty* self, PyObject* source) +PyObject *getValue(PySideProperty *self, PyObject *source) { - PyObject* fget = self->d->fget; + PyObject *fget = self->d->fget; if (fget) { Shiboken::AutoDecRef args(PyTuple_New(1)); Py_INCREF(source); @@ -372,9 +372,9 @@ PyObject* getValue(PySideProperty* self, PyObject* source) return 0; } -int reset(PySideProperty* self, PyObject* source) +int reset(PySideProperty *self, PyObject *source) { - PyObject* freset = self->d->freset; + PyObject *freset = self->d->freset; if (freset) { Shiboken::AutoDecRef args(PyTuple_New(1)); Py_INCREF(source); @@ -385,25 +385,24 @@ int reset(PySideProperty* self, PyObject* source) return -1; } -const char* getTypeName(const PySideProperty* self) +const char *getTypeName(const PySideProperty *self) { return self->d->typeName; } -PySideProperty* getObject(PyObject* source, PyObject* name) +PySideProperty *getObject(PyObject *source, PyObject *name) { - PyObject* attr = 0; + PyObject *attr = nullptr; if (Shiboken::Object::isUserType(source)) { - PyObject* dict = reinterpret_cast(source)->ob_dict; - if (dict) + if (auto dict = reinterpret_cast(source)->ob_dict) attr = PyDict_GetItem(dict, name); } attr = getFromType(Py_TYPE(source), name); if (attr && checkType(attr)) { Py_INCREF(attr); - return reinterpret_cast(attr); + return reinterpret_cast(attr); } if (!attr) @@ -417,50 +416,50 @@ bool isReadable(const PySideProperty * /* self */) return true; } -bool isWritable(const PySideProperty* self) +bool isWritable(const PySideProperty *self) { return (self->d->fset != 0); } -bool hasReset(const PySideProperty* self) +bool hasReset(const PySideProperty *self) { return (self->d->freset != 0); } -bool isDesignable(const PySideProperty* self) +bool isDesignable(const PySideProperty *self) { return self->d->designable; } -bool isScriptable(const PySideProperty* self) +bool isScriptable(const PySideProperty *self) { return self->d->scriptable; } -bool isStored(const PySideProperty* self) +bool isStored(const PySideProperty *self) { return self->d->stored; } -bool isUser(const PySideProperty* self) +bool isUser(const PySideProperty *self) { return self->d->user; } -bool isConstant(const PySideProperty* self) +bool isConstant(const PySideProperty *self) { return self->d->constant; } -bool isFinal(const PySideProperty* self) +bool isFinal(const PySideProperty *self) { return self->d->final; } -const char* getNotifyName(PySideProperty* self) +const char *getNotifyName(PySideProperty *self) { if (self->d->notifySignature.isEmpty()) { - PyObject* str = PyObject_Str(self->d->notify); + PyObject *str = PyObject_Str(self->d->notify); self->d->notifySignature = Shiboken::String::toCString(str); Py_DECREF(str); } @@ -469,22 +468,22 @@ const char* getNotifyName(PySideProperty* self) ? nullptr : self->d->notifySignature.constData(); } -void setMetaCallHandler(PySideProperty* self, MetaCallHandler handler) +void setMetaCallHandler(PySideProperty *self, MetaCallHandler handler) { self->d->metaCallHandler = handler; } -void setTypeName(PySideProperty* self, const char* typeName) +void setTypeName(PySideProperty *self, const char *typeName) { self->d->typeName = typeName; } -void setUserData(PySideProperty* self, void* data) +void setUserData(PySideProperty *self, void *data) { self->d->userData = data; } -void* userData(PySideProperty* self) +void *userData(PySideProperty *self) { return self->d->userData; } diff --git a/sources/pyside2/libpyside/pysideqflags.cpp b/sources/pyside2/libpyside/pysideqflags.cpp index cb57031b0..fd0ed005f 100644 --- a/sources/pyside2/libpyside/pysideqflags.cpp +++ b/sources/pyside2/libpyside/pysideqflags.cpp @@ -47,8 +47,8 @@ extern "C" { struct PySideQFlagsTypePrivate { - SbkConverter** converterPtr; - SbkConverter* converter; + SbkConverter **converterPtr; + SbkConverter *converter; }; /** * Type of all QFlags @@ -58,13 +58,13 @@ extern "C" { PyTypeObject type; }; - #define PYSIDE_QFLAGS(X) reinterpret_cast(X) + #define PYSIDE_QFLAGS(X) reinterpret_cast(X) PyObject *PySideQFlagsNew(PyTypeObject *type, PyObject *args, PyObject * /* kwds */) { long val = 0; if (PyTuple_GET_SIZE(args)) { - PyObject* arg = PyTuple_GET_ITEM(args, 0); + PyObject *arg = PyTuple_GET_ITEM(args, 0); if (Shiboken::isShibokenEnum(arg)) {// faster call val = Shiboken::Enum::getValue(arg); } else if (PyNumber_Check(arg)) { @@ -75,18 +75,18 @@ extern "C" { return 0; } } - PySideQFlagsObject* self = PyObject_New(PySideQFlagsObject, type); + PySideQFlagsObject *self = PyObject_New(PySideQFlagsObject, type); self->ob_value = val; - return reinterpret_cast(self); + return reinterpret_cast(self); } - static long getNumberValue(PyObject* v) + static long getNumberValue(PyObject *v) { Shiboken::AutoDecRef number(PyNumber_Long(v)); return PyLong_AsLong(number); } - PyObject* PySideQFlagsRichCompare(PyObject* self, PyObject* other, int op) + PyObject *PySideQFlagsRichCompare(PyObject *self, PyObject *other, int op) { int result = 0; if (!PyNumber_Check(other)) { @@ -163,7 +163,7 @@ namespace QFlags SbkNewQFlagsType_slots, }; - PyTypeObject *create(const char* name, PyType_Slot numberMethods[]) + PyTypeObject *create(const char *name, PyType_Slot numberMethods[]) { char qualname[200]; // PYSIDE-747: Here we insert now the full class name. @@ -183,7 +183,7 @@ namespace QFlags PyTypeObject *type = (PyTypeObject *)PyType_FromSpec(newspec); Py_TYPE(type) = &PyType_Type; - PySideQFlagsType* flagsType = reinterpret_cast(type); + PySideQFlagsType *flagsType = reinterpret_cast(type); PepType_PFTP(flagsType)->converterPtr = &PepType_PFTP(flagsType)->converter; if (PyType_Ready(type) < 0) @@ -192,14 +192,14 @@ namespace QFlags return type; } - PySideQFlagsObject* newObject(long value, PyTypeObject* type) + PySideQFlagsObject *newObject(long value, PyTypeObject *type) { - PySideQFlagsObject* qflags = PyObject_New(PySideQFlagsObject, type); + PySideQFlagsObject *qflags = PyObject_New(PySideQFlagsObject, type); qflags->ob_value = value; return qflags; } - long getValue(PySideQFlagsObject* self) + long getValue(PySideQFlagsObject *self) { return self->ob_value; } diff --git a/sources/pyside2/libpyside/pysidesignal.cpp b/sources/pyside2/libpyside/pysidesignal.cpp index 0f1993e79..169028f0c 100644 --- a/sources/pyside2/libpyside/pysidesignal.cpp +++ b/sources/pyside2/libpyside/pysidesignal.cpp @@ -71,11 +71,11 @@ namespace Signal { QMetaMethod::Attributes m_attributes = QMetaMethod::Compatibility; }; - static QByteArray buildSignature(const QByteArray &, const QByteArray &); - static void appendSignature(PySideSignal*, const SignalSignature &); - static void instanceInitialize(PySideSignalInstance*, PyObject*, PySideSignal*, PyObject*, int); - static QByteArray parseSignature(PyObject *); - static PyObject* buildQtCompatible(const QByteArray &); + static QByteArray buildSignature(const QByteArray &, const QByteArray &); + static void appendSignature(PySideSignal *, const SignalSignature &); + static void instanceInitialize(PySideSignalInstance *, PyObject *, PySideSignal *, PyObject *, int); + static QByteArray parseSignature(PyObject *); + static PyObject *buildQtCompatible(const QByteArray &); } } @@ -83,22 +83,22 @@ extern "C" { // Signal methods -static int signalTpInit(PyObject*, PyObject*, PyObject*); -static void signalFree(void*); -static void signalInstanceFree(void*); -static PyObject* signalGetItem(PyObject* self, PyObject* key); -static PyObject* signalToString(PyObject* self); +static int signalTpInit(PyObject *, PyObject *, PyObject *); +static void signalFree(void *); +static void signalInstanceFree(void *); +static PyObject *signalGetItem(PyObject *self, PyObject *key); +static PyObject *signalToString(PyObject *self); // Signal Instance methods -static PyObject* signalInstanceConnect(PyObject*, PyObject*, PyObject*); -static PyObject* signalInstanceDisconnect(PyObject*, PyObject*); -static PyObject* signalInstanceEmit(PyObject*, PyObject*); -static PyObject* signalInstanceGetItem(PyObject*, PyObject*); +static PyObject *signalInstanceConnect(PyObject *, PyObject *, PyObject *); +static PyObject *signalInstanceDisconnect(PyObject *, PyObject *); +static PyObject *signalInstanceEmit(PyObject *, PyObject *); +static PyObject *signalInstanceGetItem(PyObject *, PyObject *); -static PyObject* signalInstanceCall(PyObject* self, PyObject* args, PyObject* kw); -static PyObject* signalCall(PyObject*, PyObject*, PyObject*); +static PyObject *signalInstanceCall(PyObject *self, PyObject *args, PyObject *kw); +static PyObject *signalCall(PyObject *, PyObject *, PyObject *); -static PyObject* metaSignalCheck(PyObject*, PyObject*); +static PyObject *metaSignalCheck(PyObject *, PyObject *); static PyMethodDef Signal_methods[] = { @@ -200,28 +200,28 @@ PyTypeObject *PySideSignalInstanceTypeF(void) return type; } -int signalTpInit(PyObject* self, PyObject* args, PyObject* kwds) +int signalTpInit(PyObject *self, PyObject *args, PyObject *kwds) { - static PyObject* emptyTuple = 0; - static const char* kwlist[] = {"name", 0}; - char* argName = 0; + static PyObject *emptyTuple = nullptr; + static const char *kwlist[] = {"name", nullptr}; + char *argName = nullptr; if (emptyTuple == 0) emptyTuple = PyTuple_New(0); if (!PyArg_ParseTupleAndKeywords(emptyTuple, kwds, - "|s:QtCore." SIGNAL_CLASS_NAME, const_cast(kwlist), &argName)) + "|s:QtCore." SIGNAL_CLASS_NAME, const_cast(kwlist), &argName)) return 0; bool tupledArgs = false; - PySideSignal* data = reinterpret_cast(self); + PySideSignal *data = reinterpret_cast(self); if (!data->data) data->data = new PySideSignalData; if (argName) data->data->signalName = argName; 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_GET_ITEM(args, i); if (PySequence_Check(arg) && !Shiboken::String::check(arg)) { tupledArgs = true; const auto sig = PySide::Signal::parseSignature(arg); @@ -241,10 +241,10 @@ int signalTpInit(PyObject* self, PyObject* args, PyObject* kwds) return 1; } -void signalFree(void* self) +void signalFree(void *self) { - PyObject* pySelf = reinterpret_cast(self); - PySideSignal* data = reinterpret_cast(self); + auto pySelf = reinterpret_cast(self); + auto data = reinterpret_cast(self); delete data->data; data->data = nullptr; Py_XDECREF(data->homonymousMethod); @@ -253,9 +253,9 @@ void signalFree(void* self) Py_TYPE(pySelf)->tp_base->tp_free(self); } -PyObject* signalGetItem(PyObject* self, PyObject* key) +PyObject *signalGetItem(PyObject *self, PyObject *key) { - PySideSignal* data = reinterpret_cast(self); + auto data = reinterpret_cast(self); QByteArray sigKey; if (key) { sigKey = PySide::Signal::parseSignature(key); @@ -268,17 +268,17 @@ PyObject* signalGetItem(PyObject* self, PyObject* key) } -PyObject* signalToString(PyObject* self) +PyObject *signalToString(PyObject *self) { return signalGetItem(self, 0); } -void signalInstanceFree(void* self) +void signalInstanceFree(void *self) { - PyObject* pySelf = reinterpret_cast(self); - PySideSignalInstance* data = reinterpret_cast(self); + auto pySelf = reinterpret_cast(self); + auto data = reinterpret_cast(self); - PySideSignalInstancePrivate* dataPvt = data->d; + PySideSignalInstancePrivate *dataPvt = data->d; Py_XDECREF(dataPvt->homonymousMethod); @@ -291,27 +291,27 @@ void signalInstanceFree(void* self) Py_TYPE(pySelf)->tp_base->tp_free(self); } -PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds) +PyObject *signalInstanceConnect(PyObject *self, PyObject *args, PyObject *kwds) { - PyObject* slot = 0; - PyObject* type = 0; - static const char* kwlist[] = {"slot", "type", 0}; + PyObject *slot = nullptr; + PyObject *type = nullptr; + static const char *kwlist[] = {"slot", "type", nullptr}; if (!PyArg_ParseTupleAndKeywords(args, kwds, - "O|O:" SIGNAL_INSTANCE_NAME, const_cast(kwlist), &slot, &type)) + "O|O:" SIGNAL_INSTANCE_NAME, const_cast(kwlist), &slot, &type)) return 0; - PySideSignalInstance* source = reinterpret_cast(self); + PySideSignalInstance *source = reinterpret_cast(self); Shiboken::AutoDecRef pyArgs(PyList_New(0)); bool match = false; if (Py_TYPE(slot) == PySideSignalInstanceTypeF()) { - PySideSignalInstance* sourceWalk = source; - PySideSignalInstance* targetWalk; + PySideSignalInstance *sourceWalk = source; + PySideSignalInstance *targetWalk; //find best match while (sourceWalk && !match) { - targetWalk = reinterpret_cast(slot); + targetWalk = reinterpret_cast(slot); while (targetWalk && !match) { if (QMetaObject::checkConnectArgs(sourceWalk->d->signature, targetWalk->d->signature)) { PyList_Append(pyArgs, sourceWalk->d->source); @@ -324,9 +324,9 @@ PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds) match = true; } - targetWalk = reinterpret_cast(targetWalk->d->next); + targetWalk = reinterpret_cast(targetWalk->d->next); } - sourceWalk = reinterpret_cast(sourceWalk->d->next); + sourceWalk = reinterpret_cast(sourceWalk->d->next); } } else { // Check signature of the slot (method or function) to match signal @@ -399,7 +399,7 @@ PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds) PyErr_SetString(PyExc_RuntimeError, "method 'connect' vanished!"); return 0; } - PyObject* result = PyObject_CallObject(pyMethod, tupleArgs); + PyObject *result = PyObject_CallObject(pyMethod, tupleArgs); if (result == Py_True || result == Py_False) return result; Py_XDECREF(result); @@ -415,9 +415,9 @@ int argCountInSignature(const char *signature) return QByteArray(signature).count(",") + 1; } -PyObject* signalInstanceEmit(PyObject* self, PyObject* args) +PyObject *signalInstanceEmit(PyObject *self, PyObject *args) { - PySideSignalInstance* source = reinterpret_cast(self); + PySideSignalInstance *source = reinterpret_cast(self); Shiboken::AutoDecRef pyArgs(PyList_New(0)); int numArgsGiven = PySequence_Fast_GET_SIZE(args); @@ -453,15 +453,15 @@ PyObject* signalInstanceEmit(PyObject* self, PyObject* args) return PyObject_CallObject(pyMethod, tupleArgs); } -PyObject* signalInstanceGetItem(PyObject* self, PyObject* key) +PyObject *signalInstanceGetItem(PyObject *self, PyObject *key) { - PySideSignalInstance* data = reinterpret_cast(self); + auto data = reinterpret_cast(self); const auto sigName = data->d->signalName; const auto sigKey = PySide::Signal::parseSignature(key); const auto sig = PySide::Signal::buildSignature(sigName, sigKey); while (data) { if (data->d->signature == sig) { - PyObject* result = reinterpret_cast(data); + PyObject *result = reinterpret_cast(data); Py_INCREF(result); return result; } @@ -473,12 +473,12 @@ PyObject* signalInstanceGetItem(PyObject* self, PyObject* key) return 0; } -PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args) +PyObject *signalInstanceDisconnect(PyObject *self, PyObject *args) { - PySideSignalInstance* source = reinterpret_cast(self); + auto source = reinterpret_cast(self); Shiboken::AutoDecRef pyArgs(PyList_New(0)); - PyObject* slot; + PyObject *slot; if (PyTuple_Check(args) && PyTuple_GET_SIZE(args)) slot = PyTuple_GET_ITEM(args, 0); else @@ -486,7 +486,7 @@ PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args) bool match = false; if (Py_TYPE(slot) == PySideSignalInstanceTypeF()) { - PySideSignalInstance* target = reinterpret_cast(slot); + PySideSignalInstance *target = reinterpret_cast(slot); if (QMetaObject::checkConnectArgs(source->d->signature, target->d->signature)) { PyList_Append(pyArgs, source->d->source); Shiboken::AutoDecRef source_signature(PySide::Signal::buildQtCompatible(source->d->signature)); @@ -513,7 +513,7 @@ PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args) if (match) { Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs)); Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->d->source, "disconnect")); - PyObject* result = PyObject_CallObject(pyMethod, tupleArgs); + PyObject *result = PyObject_CallObject(pyMethod, tupleArgs); if (!result || result == Py_True) return result; else @@ -525,9 +525,9 @@ PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args) return 0; } -PyObject* signalCall(PyObject* self, PyObject* args, PyObject* kw) +PyObject *signalCall(PyObject *self, PyObject *args, PyObject *kw) { - PySideSignal* signal = reinterpret_cast(self); + auto signal = reinterpret_cast(self); // Native C++ signals can't be called like functions, thus we throw an exception. // The only way calling a signal can succeed (the Python equivalent of C++'s operator() ) @@ -553,9 +553,9 @@ PyObject* signalCall(PyObject* self, PyObject* args, PyObject* kw) return callFunc(homonymousMethod, args, kw); } -PyObject* signalInstanceCall(PyObject* self, PyObject* args, PyObject* kw) +PyObject *signalInstanceCall(PyObject *self, PyObject *args, PyObject *kw) { - PySideSignalInstance* PySideSignal = reinterpret_cast(self); + auto PySideSignal = reinterpret_cast(self); if (!PySideSignal->d->homonymousMethod) { PyErr_SetString(PyExc_TypeError, "native Qt signal is not callable"); return 0; @@ -566,7 +566,7 @@ PyObject* signalInstanceCall(PyObject* self, PyObject* args, PyObject* kw) return PyCFunction_Call(homonymousMethod, args, kw); } -static PyObject *metaSignalCheck(PyObject * /* klass */, PyObject* args) +static PyObject *metaSignalCheck(PyObject * /* klass */, PyObject *args) { if (PyType_IsSubtype(Py_TYPE(args), PySideSignalInstanceTypeF())) Py_RETURN_TRUE; @@ -579,7 +579,7 @@ static PyObject *metaSignalCheck(PyObject * /* klass */, PyObject* args) namespace PySide { namespace Signal { -void init(PyObject* module) +void init(PyObject *module) { if (PyType_Ready(PySideSignalMetaTypeF()) < 0) return; @@ -596,25 +596,25 @@ void init(PyObject* module) Py_INCREF(PySideSignalInstanceTypeF()); } -bool checkType(PyObject* pyObj) +bool checkType(PyObject *pyObj) { if (pyObj) return PyType_IsSubtype(Py_TYPE(pyObj), PySideSignalTypeF()); return false; } -void updateSourceObject(PyObject* source) +void updateSourceObject(PyObject *source) { - PyTypeObject* objType = reinterpret_cast(PyObject_Type(source)); + PyTypeObject *objType = reinterpret_cast(PyObject_Type(source)); Py_ssize_t pos = 0; - PyObject* value; - PyObject* key; + PyObject *value; + PyObject *key; while (PyDict_Next(objType->tp_dict, &pos, &key, &value)) { if (PyObject_TypeCheck(value, PySideSignalTypeF())) { Shiboken::AutoDecRef signalInstance(reinterpret_cast(PyObject_New(PySideSignalInstance, PySideSignalInstanceTypeF()))); - instanceInitialize(signalInstance.cast(), key, reinterpret_cast(value), source, 0); + instanceInitialize(signalInstance.cast(), key, reinterpret_cast(value), source, 0); PyObject_SetAttr(source, key, signalInstance); } } @@ -625,13 +625,13 @@ void updateSourceObject(PyObject* source) QByteArray getTypeName(PyObject *type) { if (PyType_Check(type)) { - if (PyType_IsSubtype(reinterpret_cast(type), - reinterpret_cast(SbkObject_TypeF()))) { - SbkObjectType* objType = reinterpret_cast(type); + if (PyType_IsSubtype(reinterpret_cast(type), + reinterpret_cast(SbkObject_TypeF()))) { + auto objType = reinterpret_cast(type); return Shiboken::ObjectType::getOriginalName(objType); } // Translate python types to Qt names - PyTypeObject* objType = reinterpret_cast(type); + auto objType = reinterpret_cast(type); if (Shiboken::String::checkType(objType)) return QByteArrayLiteral("QString"); if (objType == &PyInt_Type) @@ -662,7 +662,7 @@ QByteArray buildSignature(const QByteArray &name, const QByteArray &signature) return QMetaObject::normalizedSignature(name + '(' + signature + ')'); } -QByteArray parseSignature(PyObject* args) +QByteArray parseSignature(PyObject *args) { if (args && (Shiboken::String::check(args) || !PySequence_Check(args))) return getTypeName(args); @@ -680,25 +680,25 @@ QByteArray parseSignature(PyObject* args) return signature; } -void appendSignature(PySideSignal* self, const SignalSignature &signature) +void appendSignature(PySideSignal *self, const SignalSignature &signature) { self->data->signatures.append({signature.m_parameterTypes, signature.m_attributes}); } -PySideSignalInstance* initialize(PySideSignal* self, PyObject* name, PyObject* object) +PySideSignalInstance *initialize(PySideSignal *self, PyObject *name, PyObject *object) { - PySideSignalInstance* instance = PyObject_New(PySideSignalInstance, PySideSignalInstanceTypeF()); - SbkObject* sbkObj = reinterpret_cast(object); + PySideSignalInstance *instance = PyObject_New(PySideSignalInstance, PySideSignalInstanceTypeF()); + auto sbkObj = reinterpret_cast(object); if (!Shiboken::Object::wasCreatedByPython(sbkObj)) Py_INCREF(object); // PYSIDE-79: this flag was crucial for a wrapper call. instanceInitialize(instance, name, self, object, 0); return instance; } -void instanceInitialize(PySideSignalInstance* self, PyObject* name, PySideSignal* data, PyObject* source, int index) +void instanceInitialize(PySideSignalInstance *self, PyObject *name, PySideSignal *data, PyObject *source, int index) { self->d = new PySideSignalInstancePrivate; - PySideSignalInstancePrivate* selfPvt = self->d; + PySideSignalInstancePrivate *selfPvt = self->d; selfPvt->next = nullptr; if (data->data->signalName.isEmpty()) data->data->signalName = Shiboken::String::toCString(name); @@ -721,7 +721,7 @@ void instanceInitialize(PySideSignalInstance* self, PyObject* name, PySideSignal } } -bool connect(PyObject* source, const char* signal, PyObject* callback) +bool connect(PyObject *source, const char *signal, PyObject *callback) { Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source, "connect")); if (pyMethod.isNull()) @@ -729,7 +729,7 @@ bool connect(PyObject* source, const char* signal, PyObject* callback) Shiboken::AutoDecRef pySignature(Shiboken::String::fromCString(signal)); Shiboken::AutoDecRef pyArgs(PyTuple_Pack(3, source, pySignature.object(), callback)); - PyObject* result = PyObject_CallObject(pyMethod, pyArgs); + PyObject *result = PyObject_CallObject(pyMethod, pyArgs); if (result == Py_False) { PyErr_Format(PyExc_RuntimeError, "Failed to connect signal %s, to python callable object.", signal); Py_DECREF(result); @@ -738,12 +738,12 @@ bool connect(PyObject* source, const char* signal, PyObject* callback) return result; } -PySideSignalInstance* newObjectFromMethod(PyObject* source, const QList& methodList) +PySideSignalInstance *newObjectFromMethod(PyObject *source, const QList& methodList) { - PySideSignalInstance* root = 0; - PySideSignalInstance* previous = 0; + PySideSignalInstance *root = nullptr; + PySideSignalInstance *previous = nullptr; for (const QMetaMethod &m : methodList) { - PySideSignalInstance* item = PyObject_New(PySideSignalInstance, PySideSignalInstanceTypeF()); + PySideSignalInstance *item = PyObject_New(PySideSignalInstance, PySideSignalInstanceTypeF()); if (!root) root = item; @@ -751,7 +751,7 @@ PySideSignalInstance* newObjectFromMethod(PyObject* source, const QListd->next = item; item->d = new PySideSignalInstancePrivate; - PySideSignalInstancePrivate* selfPvt = item->d; + PySideSignalInstancePrivate *selfPvt = item->d; selfPvt->source = source; Py_INCREF(selfPvt->source); // PYSIDE-79: an INCREF is missing. QByteArray cppName(m.methodSignature()); @@ -766,17 +766,17 @@ PySideSignalInstance* newObjectFromMethod(PyObject* source, const QListdata = new PySideSignalData; self->data->signalName = name; self->homonymousMethod = 0; va_start(listSignatures, name); - sig = va_arg(listSignatures, char*); + sig = va_arg(listSignatures, char *); while (sig != NULL) { if (strcmp(sig, "void") == 0) @@ -784,7 +784,7 @@ PySideSignal* newObject(const char* name, ...) else appendSignature(self, SignalSignature(sig)); - sig = va_arg(listSignatures, char*); + sig = va_arg(listSignatures, char *); } va_end(listSignatures); @@ -793,7 +793,7 @@ PySideSignal* newObject(const char* name, ...) } template -static typename T::value_type join(T t, const char* sep) +static typename T::value_type join(T t, const char *sep) { typename T::value_type res; if (t.isEmpty()) @@ -812,15 +812,15 @@ static typename T::value_type join(T t, const char* sep) return res; } -static void _addSignalToWrapper(SbkObjectType* wrapperType, const char* signalName, PySideSignal* signal) +static void _addSignalToWrapper(SbkObjectType *wrapperType, const char *signalName, PySideSignal *signal) { - PyObject* typeDict = reinterpret_cast(wrapperType)->tp_dict; - PyObject* homonymousMethod; + auto typeDict = reinterpret_cast(wrapperType)->tp_dict; + PyObject *homonymousMethod; if ((homonymousMethod = PyDict_GetItemString(typeDict, signalName))) { Py_INCREF(homonymousMethod); signal->homonymousMethod = homonymousMethod; } - PyDict_SetItemString(typeDict, signalName, reinterpret_cast(signal)); + PyDict_SetItemString(typeDict, signalName, reinterpret_cast(signal)); } // This function is used by qStableSort to promote empty signatures @@ -829,7 +829,7 @@ static bool compareSignals(const SignalSignature &sig1, const SignalSignature &) return sig1.m_parameterTypes.isEmpty(); } -void registerSignals(SbkObjectType* pyObj, const QMetaObject* metaObject) +void registerSignals(SbkObjectType *pyObj, const QMetaObject *metaObject) { typedef QHash > SignalSigMap; SignalSigMap signalsFound; @@ -850,7 +850,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, PySideSignalTypeF()); + PySideSignal *self = PyObject_New(PySideSignal, PySideSignalTypeF()); self->data = new PySideSignalData; self->data->signalName = it.key(); self->homonymousMethod = 0; @@ -869,28 +869,28 @@ void registerSignals(SbkObjectType* pyObj, const QMetaObject* metaObject) } } -PyObject* buildQtCompatible(const QByteArray &signature) +PyObject *buildQtCompatible(const QByteArray &signature) { const auto ba = QT_SIGNAL_SENTINEL + signature; return Shiboken::String::fromStringAndSize(ba, ba.size()); } -void addSignalToWrapper(SbkObjectType* wrapperType, const char* signalName, PySideSignal* signal) +void addSignalToWrapper(SbkObjectType *wrapperType, const char *signalName, PySideSignal *signal) { _addSignalToWrapper(wrapperType, signalName, signal); } -PyObject* getObject(PySideSignalInstance* signal) +PyObject *getObject(PySideSignalInstance *signal) { return signal->d->source; } -const char* getSignature(PySideSignalInstance* signal) +const char *getSignature(PySideSignalInstance *signal) { return signal->d->signature; } -QStringList getArgsFromSignature(const char* signature, bool* isShortCircuit) +QStringList getArgsFromSignature(const char *signature, bool *isShortCircuit) { const QString qsignature = QLatin1String(signature); QStringList result; @@ -910,7 +910,7 @@ QStringList getArgsFromSignature(const char* signature, bool* isShortCircuit) return result; } -QString getCallbackSignature(const char* signal, QObject* receiver, PyObject* callback, bool encodeName) +QString getCallbackSignature(const char *signal, QObject *receiver, PyObject *callback, bool encodeName) { QByteArray functionName; int numArgs = -1; @@ -919,8 +919,8 @@ QString getCallbackSignature(const char* signal, QObject* receiver, PyObject* ca bool isFunction = PyFunction_Check(callback); if (isMethod || isFunction) { - PyObject* function = isMethod ? PyMethod_GET_FUNCTION(callback) : callback; - PyCodeObject* objCode = reinterpret_cast(PyFunction_GET_CODE(function)); + PyObject *function = isMethod ? PyMethod_GET_FUNCTION(callback) : callback; + auto objCode = reinterpret_cast(PyFunction_GET_CODE(function)); functionName = Shiboken::String::toCString(PepFunction_GetName(function)); useSelf = isMethod; numArgs = PepCode_GET_FLAGS(objCode) & CO_VARARGS ? -1 : PepCode_GET_ARGCOUNT(objCode); @@ -932,7 +932,7 @@ QString getCallbackSignature(const char* signal, QObject* receiver, PyObject* ca if (receiver) { //Search for signature on metaobject - const QMetaObject* mo = receiver->metaObject(); + const QMetaObject *mo = receiver->metaObject(); QByteArray prefix(functionName); prefix += '('; for (int i = 0; i < mo->methodCount(); i++) { @@ -976,12 +976,12 @@ QString getCallbackSignature(const char* signal, QObject* receiver, PyObject* ca return signature; } -bool isQtSignal(const char* signal) +bool isQtSignal(const char *signal) { return (signal && signal[0] == QT_SIGNAL_SENTINEL); } -bool checkQtSignal(const char* signal) +bool checkQtSignal(const char *signal) { if (!isQtSignal(signal)) { PyErr_SetString(PyExc_TypeError, "Use the function PySide2.QtCore.SIGNAL on signals"); @@ -990,11 +990,11 @@ bool checkQtSignal(const char* signal) return true; } -QString codeCallbackName(PyObject* callback, const QString& funcName) +QString codeCallbackName(PyObject *callback, const QString &funcName) { if (PyMethod_Check(callback)) { - PyObject* self = PyMethod_GET_SELF(callback); - PyObject* func = PyMethod_GET_FUNCTION(callback); + PyObject *self = PyMethod_GET_SELF(callback); + PyObject *func = PyMethod_GET_FUNCTION(callback); return funcName + QString::number(quint64(self), 16) + QString::number(quint64(func), 16); } return funcName + QString::number(quint64(callback), 16); diff --git a/sources/pyside2/libpyside/pysideslot.cpp b/sources/pyside2/libpyside/pysideslot.cpp index 4104c090d..2cdf32626 100644 --- a/sources/pyside2/libpyside/pysideslot.cpp +++ b/sources/pyside2/libpyside/pysideslot.cpp @@ -64,8 +64,8 @@ typedef struct extern "C" { -static int slotTpInit(PyObject*, PyObject*, PyObject*); -static PyObject* slotCall(PyObject*, PyObject*, PyObject*); +static int slotTpInit(PyObject *, PyObject *, PyObject *); +static PyObject *slotCall(PyObject *, PyObject *, PyObject *); // Class Definition ----------------------------------------------- static PyType_Slot PySideSlotType_slots[] = { @@ -94,20 +94,20 @@ static PyTypeObject *PySideSlotTypeF(void) int slotTpInit(PyObject *self, PyObject *args, PyObject *kw) { - static PyObject *emptyTuple = 0; - static const char *kwlist[] = {"name", "result", 0}; - char* argName = 0; - PyObject* argResult = 0; + static PyObject *emptyTuple = nullptr; + static const char *kwlist[] = {"name", "result", nullptr}; + char *argName = nullptr; + PyObject *argResult = nullptr; if (emptyTuple == 0) emptyTuple = PyTuple_New(0); if (!PyArg_ParseTupleAndKeywords(emptyTuple, kw, "|sO:QtCore." SLOT_DEC_NAME, - const_cast(kwlist), &argName, &argResult)) { + const_cast(kwlist), &argName, &argResult)) { return 0; } - PySideSlot *data = reinterpret_cast(self); + PySideSlot *data = reinterpret_cast(self); if (!data->slotData) data->slotData = new SlotData; for(Py_ssize_t i = 0, i_max = PyTuple_Size(args); i < i_max; i++) { @@ -133,13 +133,13 @@ int slotTpInit(PyObject *self, PyObject *args, PyObject *kw) PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */) { - static PyObject* pySlotName = 0; - PyObject* callback; + static PyObject *pySlotName = nullptr; + PyObject *callback; callback = PyTuple_GetItem(args, 0); Py_INCREF(callback); if (PyFunction_Check(callback)) { - PySideSlot *data = reinterpret_cast(self); + PySideSlot *data = reinterpret_cast(self); if (!data->slotData) data->slotData = new SlotData; @@ -179,7 +179,7 @@ PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */) namespace PySide { namespace Slot { -void init(PyObject* module) +void init(PyObject *module) { if (PyType_Ready(PySideSlotTypeF()) < 0) return; diff --git a/sources/pyside2/libpyside/pysideweakref.cpp b/sources/pyside2/libpyside/pysideweakref.cpp index 6b5073db8..2b27f9545 100644 --- a/sources/pyside2/libpyside/pysideweakref.cpp +++ b/sources/pyside2/libpyside/pysideweakref.cpp @@ -46,10 +46,10 @@ typedef struct { PyObject_HEAD /* Type-specific fields go here. */ PySideWeakRefFunction weakref_func; - void* user_data; + void *user_data; } PySideCallableObject; -static PyObject* CallableObject_call(PyObject* callable_object, PyObject* args, PyObject* kw); +static PyObject *CallableObject_call(PyObject *callable_object, PyObject *args, PyObject *kw); static PyType_Slot PySideCallableObjectType_slots[] = { {Py_tp_call, (void *)CallableObject_call}, @@ -57,7 +57,7 @@ static PyType_Slot PySideCallableObjectType_slots[] = { {0, 0} }; static PyType_Spec PySideCallableObjectType_spec = { - const_cast("PySide.Callable"), + const_cast("PySide.Callable"), sizeof(PySideCallableObject), 0, Py_TPFLAGS_DEFAULT, @@ -74,7 +74,7 @@ static PyTypeObject *PySideCallableObjectTypeF() static PyObject *CallableObject_call(PyObject *callable_object, PyObject *args, PyObject * /* kw */) { - PySideCallableObject* obj = reinterpret_cast(callable_object); + PySideCallableObject *obj = reinterpret_cast(callable_object); obj->weakref_func(obj->user_data); Py_XDECREF(PyTuple_GET_ITEM(args, 0)); //kill weak ref object @@ -83,7 +83,7 @@ static PyObject *CallableObject_call(PyObject *callable_object, PyObject *args, namespace PySide { namespace WeakRef { -PyObject* create(PyObject* obj, PySideWeakRefFunction func, void* userData) +PyObject *create(PyObject *obj, PySideWeakRefFunction func, void *userData) { if (obj == Py_None) return 0; @@ -94,11 +94,11 @@ PyObject* create(PyObject* obj, PySideWeakRefFunction func, void* userData) PyType_Ready(PySideCallableObjectTypeF()); } - PySideCallableObject* callable = PyObject_New(PySideCallableObject, PySideCallableObjectTypeF()); + PySideCallableObject *callable = PyObject_New(PySideCallableObject, PySideCallableObjectTypeF()); if (!callable || PyErr_Occurred()) return 0; - PyObject* weak = PyWeakref_NewRef(obj, reinterpret_cast(callable)); + PyObject *weak = PyWeakref_NewRef(obj, reinterpret_cast(callable)); if (!weak || PyErr_Occurred()) return 0; diff --git a/sources/pyside2/libpyside/signalmanager.cpp b/sources/pyside2/libpyside/signalmanager.cpp index 8925ffd35..0895cc682 100644 --- a/sources/pyside2/libpyside/signalmanager.cpp +++ b/sources/pyside2/libpyside/signalmanager.cpp @@ -82,26 +82,26 @@ namespace { static PyObject *metaObjectAttr = 0; - static int callMethod(QObject* object, int id, void** args); - static PyObject* parseArguments(const QList< QByteArray >& paramTypes, void** args); - static bool emitShortCircuitSignal(QObject* source, int signalIndex, PyObject* args); + static int callMethod(QObject *object, int id, void **args); + static PyObject *parseArguments(const QList< QByteArray >& paramTypes, void **args); + static bool emitShortCircuitSignal(QObject *source, int signalIndex, PyObject *args); #ifdef IS_PY3K - static void destroyMetaObject(PyObject* obj) + static void destroyMetaObject(PyObject *obj) { - void* ptr = PyCapsule_GetPointer(obj, 0); - auto meta = reinterpret_cast(ptr); - SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(meta); + void *ptr = PyCapsule_GetPointer(obj, 0); + auto meta = reinterpret_cast(ptr); + SbkObject *wrapper = Shiboken::BindingManager::instance().retrieveWrapper(meta); if (wrapper) Shiboken::BindingManager::instance().releaseWrapper(wrapper); delete meta; } #else - static void destroyMetaObject(void* obj) + static void destroyMetaObject(void *obj) { - auto meta = reinterpret_cast(obj); - SbkObject* wrapper = Shiboken::BindingManager::instance().retrieveWrapper(meta); + auto meta = reinterpret_cast(obj); + SbkObject *wrapper = Shiboken::BindingManager::instance().retrieveWrapper(meta); if (wrapper) Shiboken::BindingManager::instance().releaseWrapper(wrapper); delete meta; @@ -118,7 +118,7 @@ PyObjectWrapper::PyObjectWrapper() Py_XINCREF(m_me); } -PyObjectWrapper::PyObjectWrapper(PyObject* me) +PyObjectWrapper::PyObjectWrapper(PyObject *me) : m_me(me) { Py_XINCREF(m_me); @@ -148,18 +148,18 @@ void PyObjectWrapper::reset(PyObject *o) m_me = o; } -PyObjectWrapper& PyObjectWrapper::operator=(const PySide::PyObjectWrapper& other) +PyObjectWrapper &PyObjectWrapper::operator=(const PySide::PyObjectWrapper &other) { reset(other.m_me); return *this; } -PyObjectWrapper::operator PyObject*() const +PyObjectWrapper::operator PyObject *() const { return m_me; } -QDataStream &operator<<(QDataStream& out, const PyObjectWrapper& myObj) +QDataStream &operator<<(QDataStream &out, const PyObjectWrapper &myObj) { if (Py_IsInitialized() == 0) { qWarning() << "Stream operator for PyObject called without python interpreter."; @@ -173,9 +173,9 @@ QDataStream &operator<<(QDataStream& out, const PyObjectWrapper& myObj) Shiboken::AutoDecRef pickleModule(PyImport_ImportModule("pickle")); reduce_func = PyObject_GetAttrString(pickleModule, "dumps"); } - Shiboken::AutoDecRef repr(PyObject_CallFunctionObjArgs(reduce_func, (PyObject*)myObj, NULL)); + Shiboken::AutoDecRef repr(PyObject_CallFunctionObjArgs(reduce_func, (PyObject *)myObj, NULL)); if (repr.object()) { - const char* buff = 0; + const char *buff = nullptr; Py_ssize_t size = 0; if (PyBytes_Check(repr.object())) { buff = PyBytes_AS_STRING(repr.object()); @@ -190,7 +190,7 @@ QDataStream &operator<<(QDataStream& out, const PyObjectWrapper& myObj) return out; } -QDataStream &operator>>(QDataStream& in, PyObjectWrapper& myObj) +QDataStream &operator>>(QDataStream &in, PyObjectWrapper &myObj) { if (Py_IsInitialized() == 0) { qWarning() << "Stream operator for PyObject called without python interpreter."; @@ -225,7 +225,7 @@ struct SignalManager::SignalManagerPrivate SignalManagerPrivate() { - m_globalReceivers = SharedMap( new QMap() ); + m_globalReceivers = SharedMap( new QMap() ); } ~SignalManagerPrivate() @@ -246,17 +246,17 @@ static void clearSignalManager() PySide::SignalManager::instance().clear(); } -static void PyObject_PythonToCpp_PyObject_PTR(PyObject* pyIn, void* cppOut) +static void PyObject_PythonToCpp_PyObject_PTR(PyObject *pyIn, void *cppOut) { - *((PyObject**)cppOut) = pyIn; + *reinterpret_cast(cppOut) = pyIn; } -static PythonToCppFunc is_PyObject_PythonToCpp_PyObject_PTR_Convertible(PyObject* pyIn) +static PythonToCppFunc is_PyObject_PythonToCpp_PyObject_PTR_Convertible(PyObject *pyIn) { return PyObject_PythonToCpp_PyObject_PTR; } -static PyObject* PyObject_PTR_CppToPython_PyObject(const void* cppIn) +static PyObject *PyObject_PTR_CppToPython_PyObject(const void *cppIn) { - PyObject* pyOut = (PyObject*)cppIn; + auto pyOut = reinterpret_cast(const_cast(cppIn)); if (pyOut) Py_INCREF(pyOut); return pyOut; @@ -273,7 +273,7 @@ SignalManager::SignalManager() : m_d(new SignalManagerPrivate) qRegisterMetaTypeStreamOperators("PyObjectWrapper"); qRegisterMetaTypeStreamOperators("PySide::PyObjectWrapper"); - SbkConverter* converter = Shiboken::Conversions::createConverter(&PyBaseObject_Type, 0); + SbkConverter *converter = Shiboken::Conversions::createConverter(&PyBaseObject_Type, nullptr); Shiboken::Conversions::setCppPointerToPythonFunction(converter, PyObject_PTR_CppToPython_PyObject); Shiboken::Conversions::setPythonToCppPointerFunctions(converter, PyObject_PythonToCpp_PyObject_PTR, is_PyObject_PythonToCpp_PyObject_PTR_Convertible); Shiboken::Conversions::registerConverterName(converter, PYTHON_TYPE); @@ -298,17 +298,17 @@ SignalManager::~SignalManager() delete m_d; } -SignalManager& SignalManager::instance() +SignalManager &SignalManager::instance() { static SignalManager me; return me; } -QObject* SignalManager::globalReceiver(QObject *sender, PyObject *callback) +QObject *SignalManager::globalReceiver(QObject *sender, PyObject *callback) { SharedMap globalReceivers = m_d->m_globalReceivers; QByteArray hash = GlobalReceiverV2::hash(callback); - GlobalReceiverV2* gr = 0; + GlobalReceiverV2 *gr = nullptr; auto it = globalReceivers->find(hash); if (it == globalReceivers->end()) { gr = new GlobalReceiverV2(callback, globalReceivers); @@ -323,7 +323,7 @@ QObject* SignalManager::globalReceiver(QObject *sender, PyObject *callback) gr->incRef(sender); } - return reinterpret_cast(gr); + return reinterpret_cast(gr); } int SignalManager::countConnectionsWith(const QObject *object) @@ -336,23 +336,23 @@ int SignalManager::countConnectionsWith(const QObject *object) return count; } -void SignalManager::notifyGlobalReceiver(QObject* receiver) +void SignalManager::notifyGlobalReceiver(QObject *receiver) { - reinterpret_cast(receiver)->notify(); + reinterpret_cast(receiver)->notify(); } -void SignalManager::releaseGlobalReceiver(const QObject* source, QObject* receiver) +void SignalManager::releaseGlobalReceiver(const QObject *source, QObject *receiver) { - GlobalReceiverV2* gr = reinterpret_cast(receiver); + auto gr = reinterpret_cast(receiver); gr->decRef(source); } -int SignalManager::globalReceiverSlotIndex(QObject* receiver, const char* signature) const +int SignalManager::globalReceiverSlotIndex(QObject *receiver, const char *signature) const { - return reinterpret_cast(receiver)->addSlot(signature); + return reinterpret_cast(receiver)->addSlot(signature); } -bool SignalManager::emitSignal(QObject* source, const char* signal, PyObject* args) +bool SignalManager::emitSignal(QObject *source, const char *signal, PyObject *args) { if (!Signal::checkQtSignal(signal)) return false; @@ -372,13 +372,13 @@ bool SignalManager::emitSignal(QObject* source, const char* signal, PyObject* ar return false; } -int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id, void** args) +int SignalManager::qt_metacall(QObject *object, QMetaObject::Call call, int id, void **args) { - const QMetaObject* metaObject = object->metaObject(); - PySideProperty* pp = 0; - PyObject* pp_name = 0; + const QMetaObject *metaObject = object->metaObject(); + PySideProperty *pp = nullptr; + PyObject *pp_name = nullptr; QMetaProperty mp; - PyObject* pySelf = 0; + PyObject *pySelf = nullptr; int methodCount = metaObject->methodCount(); int propertyCount = metaObject->propertyCount(); @@ -389,7 +389,7 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id, } Shiboken::GilState gil; - pySelf = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(object); + pySelf = reinterpret_cast(Shiboken::BindingManager::instance().retrieveWrapper(object)); Q_ASSERT(pySelf); pp_name = Shiboken::String::fromCString(mp.name()); pp = Property::getObject(pySelf, pp_name); @@ -504,22 +504,22 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id, return id; } -int SignalManager::callPythonMetaMethod(const QMetaMethod& method, void** args, PyObject* pyMethod, bool isShortCuit) +int SignalManager::callPythonMetaMethod(const QMetaMethod &method, void **args, PyObject *pyMethod, bool isShortCuit) { Q_ASSERT(pyMethod); Shiboken::GilState gil; - PyObject* pyArguments = 0; + PyObject *pyArguments = nullptr; if (isShortCuit){ - pyArguments = reinterpret_cast(args[1]); + pyArguments = reinterpret_cast(args[1]); } else { pyArguments = parseArguments(method.parameterTypes(), args); } if (pyArguments) { - Shiboken::Conversions::SpecificConverter* retConverter = NULL; - const char* returnType = method.typeName(); + Shiboken::Conversions::SpecificConverter *retConverter = nullptr; + const char *returnType = method.typeName(); if (returnType && std::strcmp("", returnType) && std::strcmp("void", returnType)) { retConverter = new Shiboken::Conversions::SpecificConverter(returnType); if (!retConverter || !*retConverter) { @@ -543,13 +543,13 @@ int SignalManager::callPythonMetaMethod(const QMetaMethod& method, void** args, return -1; } -bool SignalManager::registerMetaMethod(QObject* source, const char* signature, QMetaMethod::MethodType type) +bool SignalManager::registerMetaMethod(QObject *source, const char *signature, QMetaMethod::MethodType type) { int ret = registerMetaMethodGetIndex(source, signature, type); return (ret != -1); } -static MetaObjectBuilder *metaBuilderFromDict(PyObject* dict) +static MetaObjectBuilder *metaBuilderFromDict(PyObject *dict) { if (!dict || !PyDict_Contains(dict, metaObjectAttr)) return nullptr; @@ -562,33 +562,33 @@ static MetaObjectBuilder *metaBuilderFromDict(PyObject* dict) #endif } -int SignalManager::registerMetaMethodGetIndex(QObject* source, const char* signature, QMetaMethod::MethodType type) +int SignalManager::registerMetaMethodGetIndex(QObject *source, const char *signature, QMetaMethod::MethodType type) { if (!source) { qWarning("SignalManager::registerMetaMethodGetIndex(\"%s\") called with source=nullptr.", signature); return -1; } - const QMetaObject* metaObject = source->metaObject(); + const QMetaObject *metaObject = source->metaObject(); int methodIndex = metaObject->indexOfMethod(signature); // Create the dynamic signal is needed if (methodIndex == -1) { - SbkObject* self = Shiboken::BindingManager::instance().retrieveWrapper(source); + SbkObject *self = Shiboken::BindingManager::instance().retrieveWrapper(source); if (!Shiboken::Object::hasCppWrapper(self)) { qWarning() << "Invalid Signal signature:" << signature; return -1; } else { - PyObject *pySelf = reinterpret_cast(self); - PyObject* dict = self->ob_dict; + auto pySelf = reinterpret_cast(self); + PyObject *dict = self->ob_dict; MetaObjectBuilder *dmo = metaBuilderFromDict(dict); // Create a instance meta object if (!dmo) { dmo = new MetaObjectBuilder(Py_TYPE(pySelf), metaObject); #ifdef IS_PY3K - PyObject* pyDmo = PyCapsule_New(dmo, 0, destroyMetaObject); + PyObject *pyDmo = PyCapsule_New(dmo, 0, destroyMetaObject); #else - PyObject* pyDmo = PyCObject_FromVoidPtr(dmo, destroyMetaObject); + PyObject *pyDmo = PyCObject_FromVoidPtr(dmo, destroyMetaObject); #endif PyObject_SetAttr(pySelf, metaObjectAttr, pyDmo); @@ -604,12 +604,12 @@ int SignalManager::registerMetaMethodGetIndex(QObject* source, const char* signa return methodIndex; } -const QMetaObject* SignalManager::retrieveMetaObject(PyObject *self) +const QMetaObject *SignalManager::retrieveMetaObject(PyObject *self) { Shiboken::GilState gil; Q_ASSERT(self); - MetaObjectBuilder *builder = metaBuilderFromDict(reinterpret_cast(self)->ob_dict); + MetaObjectBuilder *builder = metaBuilderFromDict(reinterpret_cast(self)->ob_dict); if (!builder) builder = &(retrieveTypeUserData(self)->mo); @@ -618,9 +618,9 @@ const QMetaObject* SignalManager::retrieveMetaObject(PyObject *self) namespace { -static int callMethod(QObject* object, int id, void** args) +static int callMethod(QObject *object, int id, void **args) { - const QMetaObject* metaObject = object->metaObject(); + const QMetaObject *metaObject = object->metaObject(); QMetaMethod method = metaObject->method(id); if (method.methodType() == QMetaMethod::Signal) { @@ -628,7 +628,7 @@ static int callMethod(QObject* object, int id, void** args) QMetaObject::activate(object, id, args); } else { Shiboken::GilState gil; - PyObject* self = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(object); + auto self = reinterpret_cast(Shiboken::BindingManager::instance().retrieveWrapper(object)); QByteArray methodName = method.methodSignature(); methodName.truncate(methodName.indexOf('(')); Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(self, methodName)); @@ -638,14 +638,14 @@ static int callMethod(QObject* object, int id, void** args) } -static PyObject* parseArguments(const QList& paramTypes, void** args) +static PyObject *parseArguments(const QList& paramTypes, void **args) { int argsSize = paramTypes.count(); - PyObject* preparedArgs = PyTuple_New(argsSize); + PyObject *preparedArgs = PyTuple_New(argsSize); for (int i = 0, max = argsSize; i < max; ++i) { - void* data = args[i+1]; - const char* dataType = paramTypes[i].constData(); + void *data = args[i+1]; + const char *dataType = paramTypes[i].constData(); Shiboken::Conversions::SpecificConverter converter(dataType); if (converter) { PyTuple_SET_ITEM(preparedArgs, i, converter.toPython(data)); @@ -658,9 +658,9 @@ static PyObject* parseArguments(const QList& paramTypes, void** args return preparedArgs; } -static bool emitShortCircuitSignal(QObject* source, int signalIndex, PyObject* args) +static bool emitShortCircuitSignal(QObject *source, int signalIndex, PyObject *args) { - void* signalArgs[2] = {0, args}; + void *signalArgs[2] = {nullptr, args}; source->qt_metacall(QMetaObject::InvokeMetaMethod, signalIndex, signalArgs); return true; } -- cgit v1.2.3