diff options
author | Christian Tismer <tismer@stackless.com> | 2019-06-16 12:05:39 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-24 11:25:31 +0200 |
commit | 380c65e62de0e60da667dc0d87935171b91b9c6c (patch) | |
tree | 480c872f247316a66e446ba196a5bd1a339a0bcd /sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp | |
parent | 992ff1f7925009b7ead6d6f005cafcf2e57ed44e (diff) |
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 <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp')
-rw-r--r-- | sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp index 9d9ddc799..2386620ca 100644 --- a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp +++ b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp @@ -54,19 +54,19 @@ #ifndef PYSIDE_MAX_QML_TYPES // Maximum number of different Qt QML types the user can export to QML using // qmlRegisterType. This limit exists because the QML engine instantiates objects -// by calling a function with one argument (a void* pointer where the object should +// by calling a function with one argument (a void *pointer where the object should // be created), and thus does not allow us to choose which object to create. Thus // we create a C++ factory function for each new registered type at compile time. #define PYSIDE_MAX_QML_TYPES 50 #endif // Forward declarations. -static void propListMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::Call call, +static void propListMetaCall(PySideProperty *pp, PyObject *self, QMetaObject::Call call, void **args); // All registered python types and their creation functions. -static PyObject* pyTypes[PYSIDE_MAX_QML_TYPES]; -static void (*createFuncs[PYSIDE_MAX_QML_TYPES])(void*); +static PyObject *pyTypes[PYSIDE_MAX_QML_TYPES]; +static void (*createFuncs[PYSIDE_MAX_QML_TYPES])(void *); // Mutex used to avoid race condition on PySide::nextQObjectMemoryAddr. static QMutex nextQmlElementMutex; @@ -74,12 +74,12 @@ static QMutex nextQmlElementMutex; template<int N> struct ElementFactoryBase { - static void createInto(void* memory) + static void createInto(void *memory) { QMutexLocker locker(&nextQmlElementMutex); PySide::setNextQObjectMemoryAddr(memory); Shiboken::GilState state; - PyObject* obj = PyObject_CallObject(pyTypes[N], 0); + PyObject *obj = PyObject_CallObject(pyTypes[N], 0); if (!obj || PyErr_Occurred()) PyErr_Print(); PySide::setNextQObjectMemoryAddr(0); @@ -152,7 +152,7 @@ int PySide::qmlRegisterType(PyObject *pyObj, const char *uri, int versionMajor, pyTypes[nextType] = pyObj; // FIXME: Fix this to assign new type ids each time. - type.typeId = qMetaTypeId<QObject*>(); + type.typeId = qMetaTypeId<QObject *>(); type.listId = qMetaTypeId<QQmlListProperty<QObject> >(); type.attachedPropertiesFunction = QQmlPrivate::attachedPropertiesFunc<QObject>(); type.attachedPropertiesMetaObject = QQmlPrivate::attachedPropertiesMetaObject<QObject>(); @@ -194,22 +194,22 @@ extern "C" // This is the user data we store in the property. struct QmlListProperty { - PyTypeObject* type; - PyObject* append; - PyObject* at; - PyObject* clear; - PyObject* count; + PyTypeObject *type; + PyObject *append; + PyObject *at; + PyObject *clear; + PyObject *count; }; -static int propListTpInit(PyObject* self, PyObject* args, PyObject* kwds) +static int propListTpInit(PyObject *self, PyObject *args, PyObject *kwds) { static const char *kwlist[] = {"type", "append", "at", "clear", "count", 0}; - PySideProperty* pySelf = reinterpret_cast<PySideProperty*>(self); - QmlListProperty* data = new QmlListProperty; + PySideProperty *pySelf = reinterpret_cast<PySideProperty *>(self); + QmlListProperty *data = new QmlListProperty; memset(data, 0, sizeof(QmlListProperty)); if (!PyArg_ParseTupleAndKeywords(args, kwds, - "OO|OOO:QtQml.ListProperty", (char**) kwlist, + "OO|OOO:QtQml.ListProperty", (char **) kwlist, &data->type, &data->append, &data->at, @@ -224,10 +224,10 @@ static int propListTpInit(PyObject* self, PyObject* args, PyObject* kwds) return 1; } -void propListTpFree(void* self) +void propListTpFree(void *self) { - PySideProperty* pySelf = reinterpret_cast<PySideProperty*>(self); - delete reinterpret_cast<QmlListProperty*>(PySide::Property::userData(pySelf)); + auto pySelf = reinterpret_cast<PySideProperty *>(self); + delete reinterpret_cast<QmlListProperty *>(PySide::Property::userData(pySelf)); // calls base type constructor Py_TYPE(pySelf)->tp_base->tp_free(self); } @@ -266,10 +266,10 @@ void propListAppender(QQmlListProperty<QObject> *propList, QObject *item) Shiboken::GilState state; Shiboken::AutoDecRef args(PyTuple_New(2)); - PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], propList->object)); - PyTuple_SET_ITEM(args, 1, Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], item)); + PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType *)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], propList->object)); + PyTuple_SET_ITEM(args, 1, Shiboken::Conversions::pointerToPython((SbkObjectType *)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], item)); - QmlListProperty* data = reinterpret_cast<QmlListProperty*>(propList->data); + auto data = reinterpret_cast<QmlListProperty *>(propList->data); Shiboken::AutoDecRef retVal(PyObject_CallObject(data->append, args)); if (PyErr_Occurred()) @@ -282,9 +282,9 @@ int propListCount(QQmlListProperty<QObject> *propList) Shiboken::GilState state; Shiboken::AutoDecRef args(PyTuple_New(1)); - PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], propList->object)); + PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType *)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], propList->object)); - QmlListProperty* data = reinterpret_cast<QmlListProperty*>(propList->data); + auto data = reinterpret_cast<QmlListProperty *>(propList->data); Shiboken::AutoDecRef retVal(PyObject_CallObject(data->count, args)); // Check return type @@ -303,17 +303,17 @@ QObject *propListAt(QQmlListProperty<QObject> *propList, int index) Shiboken::GilState state; Shiboken::AutoDecRef args(PyTuple_New(2)); - PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], propList->object)); + PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType *)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], propList->object)); PyTuple_SET_ITEM(args, 1, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<int>(), &index)); - QmlListProperty* data = reinterpret_cast<QmlListProperty*>(propList->data); + auto data = reinterpret_cast<QmlListProperty *>(propList->data); Shiboken::AutoDecRef retVal(PyObject_CallObject(data->at, args)); QObject *result = 0; if (PyErr_Occurred()) PyErr_Print(); else if (PyType_IsSubtype(Py_TYPE(retVal), data->type)) - Shiboken::Conversions::pythonToCppPointer((SbkObjectType*)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], retVal, &result); + Shiboken::Conversions::pythonToCppPointer((SbkObjectType *)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], retVal, &result); return result; } @@ -323,9 +323,9 @@ void propListClear(QQmlListProperty<QObject> * propList) Shiboken::GilState state; Shiboken::AutoDecRef args(PyTuple_New(1)); - PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], propList->object)); + PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType *)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], propList->object)); - QmlListProperty* data = reinterpret_cast<QmlListProperty*>(propList->data); + auto data = reinterpret_cast<QmlListProperty *>(propList->data); Shiboken::AutoDecRef retVal(PyObject_CallObject(data->clear, args)); if (PyErr_Occurred()) @@ -333,18 +333,18 @@ void propListClear(QQmlListProperty<QObject> * propList) } // qt_metacall specialization for ListProperties -static void propListMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::Call call, void** args) +static void propListMetaCall(PySideProperty *pp, PyObject *self, QMetaObject::Call call, void **args) { if (call != QMetaObject::ReadProperty) return; - QmlListProperty* data = reinterpret_cast<QmlListProperty*>(PySide::Property::userData(pp)); - QObject* qobj; - Shiboken::Conversions::pythonToCppPointer((SbkObjectType*)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], self, &qobj); + auto data = reinterpret_cast<QmlListProperty *>(PySide::Property::userData(pp)); + QObject *qobj; + Shiboken::Conversions::pythonToCppPointer((SbkObjectType *)SbkPySide2_QtCoreTypes[SBK_QOBJECT_IDX], self, &qobj); QQmlListProperty<QObject> declProp(qobj, data, &propListAppender, &propListCount, &propListAt, &propListClear); // Copy the data to the memory location requested by the meta call - void* v = args[0]; + void *v = args[0]; *reinterpret_cast<QQmlListProperty<QObject> *>(v) = declProp; } @@ -469,7 +469,7 @@ PyTypeObject *QtQml_VolatileBoolTypeF(void) return type; } -void PySide::initQmlSupport(PyObject* module) +void PySide::initQmlSupport(PyObject *module) { ElementFactory<PYSIDE_MAX_QML_TYPES - 1>::init(); |