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/globalreceiverv2.cpp | 52 +++++++++++++------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'sources/pyside2/libpyside/globalreceiverv2.cpp') 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 -- cgit v1.2.3