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/shiboken2/libshiboken/typespec.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'sources/shiboken2/libshiboken/typespec.cpp') diff --git a/sources/shiboken2/libshiboken/typespec.cpp b/sources/shiboken2/libshiboken/typespec.cpp index a67daf12d..6dc5b00bc 100644 --- a/sources/shiboken2/libshiboken/typespec.cpp +++ b/sources/shiboken2/libshiboken/typespec.cpp @@ -599,17 +599,16 @@ offsetof(PyHeapTypeObject, as_sequence.sq_slice), PyObject * PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases) { - PyHeapTypeObject *res = (PyHeapTypeObject*)PyType_GenericAlloc(&PyType_Type, 0); + auto res = reinterpret_cast(PyType_GenericAlloc(&PyType_Type, 0)); PyTypeObject *type, *base; PyObject *modname; - char *s; - char *res_start = (char*)res; + auto res_start = reinterpret_cast(res); PyType_Slot *slot; /* Set the type name and qualname */ - s = (char *)strrchr(spec->name, '.'); // C++11 + auto s = const_cast(strrchr(spec->name, '.')); // C++11 if (s == NULL) - s = (char*)spec->name; + s = const_cast(spec->name); else s++; @@ -686,7 +685,7 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases) if (slot->slot == Py_tp_base || slot->slot == Py_tp_bases) /* Processed above */ continue; - *(void**)(res_start + slotoffsets[slot->slot]) = slot->pfunc; + *reinterpret_cast(res_start + slotoffsets[slot->slot]) = slot->pfunc; /* need to make a copy of the docstring slot, which usually points to a static string literal */ @@ -746,7 +745,7 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases) goto fail; } - return (PyObject*)res; + return reinterpret_cast(res); fail: Py_DECREF(res); @@ -770,7 +769,7 @@ PyType_GetSlot(PyTypeObject *type, int slot) /* Extension module requesting slot from a future version */ return NULL; } - return *(void**)(((char*)type) + slotoffsets[slot]); + return *reinterpret_cast(reinterpret_cast(type) + slotoffsets[slot]); } } // extern "C" -- cgit v1.2.3