aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-09-13 13:34:21 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-09-13 23:12:38 +0200
commite55c87131a66e1cd11b13663b66582412cd38788 (patch)
treeac1e0d801502cd016fa0ba564bf54a2e623a0415
parent009bc0f4bee5a39e08aaae6ef31c17e30f58bf91 (diff)
Remove some C-style casts
Change-Id: Ib600eff6f4a2baa32dbda781c0c95286e9ba5c58 Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/pyside6/PySide6/glue/qtcore.cpp8
-rw-r--r--sources/pyside6/PySide6/glue/qtstatemachine.cpp5
-rw-r--r--sources/pyside6/PySide6/templates/opengl_common.xml2
-rw-r--r--sources/pyside6/libpyside/signalmanager.cpp3
-rw-r--r--sources/shiboken6/libshiboken/sbkconverter_p.h2
-rw-r--r--sources/shiboken6/libshiboken/signature/signature_globals.cpp2
-rw-r--r--sources/shiboken6/shibokenmodule/typesystem_shiboken.xml10
-rw-r--r--sources/shiboken6/tests/samplebinding/typesystem_sample.xml2
8 files changed, 18 insertions, 16 deletions
diff --git a/sources/pyside6/PySide6/glue/qtcore.cpp b/sources/pyside6/PySide6/glue/qtcore.cpp
index 2cbc3c11a..2b5729a69 100644
--- a/sources/pyside6/PySide6/glue/qtcore.cpp
+++ b/sources/pyside6/PySide6/glue/qtcore.cpp
@@ -1549,11 +1549,11 @@ QString &res = *%0;
// @snippet return-readData
%RETURN_TYPE %0 = 0;
if (PyBytes_Check(%PYARG_0)) {
- %0 = PyBytes_GET_SIZE((PyObject *)%PYARG_0);
- memcpy(%1, PyBytes_AS_STRING((PyObject *)%PYARG_0), %0);
+ %0 = PyBytes_GET_SIZE(%PYARG_0);
+ memcpy(%1, PyBytes_AS_STRING(%PYARG_0), %0);
} else if (Shiboken::String::check(%PYARG_0)) {
- %0 = Shiboken::String::len((PyObject *)%PYARG_0);
- memcpy(%1, Shiboken::String::toCString((PyObject *)%PYARG_0), %0);
+ %0 = Shiboken::String::len(%PYARG_0);
+ memcpy(%1, Shiboken::String::toCString(%PYARG_0), %0);
}
// @snippet return-readData
diff --git a/sources/pyside6/PySide6/glue/qtstatemachine.cpp b/sources/pyside6/PySide6/glue/qtstatemachine.cpp
index 8a00bd3fd..16b096b5d 100644
--- a/sources/pyside6/PySide6/glue/qtstatemachine.cpp
+++ b/sources/pyside6/PySide6/glue/qtstatemachine.cpp
@@ -43,12 +43,13 @@
// @snippet qsignaltransition
if (PyObject_TypeCheck(%1, PySideSignalInstanceTypeF())) {
- PyObject *dataSource = PySide::Signal::getObject((PySideSignalInstance *)%PYARG_1);
+ auto *signalInstance = reinterpret_cast<PySideSignalInstance *>(%PYARG_1);
+ PyObject *dataSource = PySide::Signal::getObject(signalInstance);
Shiboken::AutoDecRef obType(PyObject_Type(dataSource));
QObject * sender = %CONVERTTOCPP[QObject *](dataSource);
//XXX /|\ omitting this space crashes shiboken!
if (sender) {
- const char *dataSignature = PySide::Signal::getSignature((PySideSignalInstance *)%PYARG_1);
+ const char *dataSignature = PySide::Signal::getSignature(signalInstance);
QByteArray signature(dataSignature); // Append SIGNAL flag (2)
signature.prepend('2');
%0 = new QSignalTransitionWrapper(sender, signature, %2);
diff --git a/sources/pyside6/PySide6/templates/opengl_common.xml b/sources/pyside6/PySide6/templates/opengl_common.xml
index e4e15e770..8160a13ba 100644
--- a/sources/pyside6/PySide6/templates/opengl_common.xml
+++ b/sources/pyside6/PySide6/templates/opengl_common.xml
@@ -55,7 +55,7 @@
%CPPSELF.%FUNCTION_NAME(%1, _list, $ARG0);
delete[] _list;
} else {
- %CPPSELF.%FUNCTION_NAME(%1, ($ATTR_TYPE*)nullptr, $ARG1);
+ %CPPSELF.%FUNCTION_NAME(%1, reinterpret_cast&lt;$ATTR_TYPE*&gt;(nullptr), $ARG1);
}
</template>
<template name="glGetString_return_QString">
diff --git a/sources/pyside6/libpyside/signalmanager.cpp b/sources/pyside6/libpyside/signalmanager.cpp
index 87726facb..26f80dff4 100644
--- a/sources/pyside6/libpyside/signalmanager.cpp
+++ b/sources/pyside6/libpyside/signalmanager.cpp
@@ -165,7 +165,8 @@ QDataStream &operator<<(QDataStream &out, const PyObjectWrapper &myObj)
Shiboken::AutoDecRef pickleModule(PyImport_ImportModule("pickle"));
reduce_func = PyObject_GetAttr(pickleModule, Shiboken::PyName::dumps());
}
- Shiboken::AutoDecRef repr(PyObject_CallFunctionObjArgs(reduce_func, (PyObject *)myObj, NULL));
+ PyObject *pyObj = myObj;
+ Shiboken::AutoDecRef repr(PyObject_CallFunctionObjArgs(reduce_func, pyObj, nullptr));
if (repr.object()) {
const char *buff = nullptr;
Py_ssize_t size = 0;
diff --git a/sources/shiboken6/libshiboken/sbkconverter_p.h b/sources/shiboken6/libshiboken/sbkconverter_p.h
index 98f39bfea..3a1689d93 100644
--- a/sources/shiboken6/libshiboken/sbkconverter_p.h
+++ b/sources/shiboken6/libshiboken/sbkconverter_p.h
@@ -465,7 +465,7 @@ struct Primitive<const char *> : TwoPrimitive<const char *>
}
static void toCpp(PyObject *, void *cppOut)
{
- *((const char **)cppOut) = nullptr;
+ *reinterpret_cast<const char **>(cppOut) = nullptr;
}
static PythonToCppFunc isConvertible(PyObject *pyIn)
{
diff --git a/sources/shiboken6/libshiboken/signature/signature_globals.cpp b/sources/shiboken6/libshiboken/signature/signature_globals.cpp
index f456e6a54..744ce0407 100644
--- a/sources/shiboken6/libshiboken/signature/signature_globals.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature_globals.cpp
@@ -129,7 +129,7 @@ static safe_globals_struc *init_phase_1(PyMethodDef *init_meth)
* They will be loaded later with the zipimporter.
* Due to MSVC's limitation to 64k strings, we need to assemble pieces.
*/
- const char **block_ptr = (const char **)PySide_CompressedSignaturePackage;
+ auto **block_ptr = reinterpret_cast<const char **>(PySide_CompressedSignaturePackage);
int npieces = 0;
PyObject *piece, *zipped_string_sequence = PyList_New(0);
if (zipped_string_sequence == nullptr)
diff --git a/sources/shiboken6/shibokenmodule/typesystem_shiboken.xml b/sources/shiboken6/shibokenmodule/typesystem_shiboken.xml
index b1b1f3212..74f9d0856 100644
--- a/sources/shiboken6/shibokenmodule/typesystem_shiboken.xml
+++ b/sources/shiboken6/shibokenmodule/typesystem_shiboken.xml
@@ -34,7 +34,7 @@
<add-function signature="getCppPointer(PyObject*)" return-type="PyObject*">
<inject-code>
if (Shiboken::Object::checkType(%1)) {
- std::vector&lt;void*> ptrs = Shiboken::Object::cppPointers((SbkObject*)%1);
+ std::vector&lt;void*> ptrs = Shiboken::Object::cppPointers(reinterpret_cast&lt;SbkObject *&gt;(%1));
%PYARG_0 = PyTuple_New(ptrs.size());
for (std::size_t i = 0; i &lt; ptrs.size(); ++i)
PyTuple_SET_ITEM(%PYARG_0, i, PyLong_FromVoidPtr(ptrs[i]));
@@ -47,7 +47,7 @@
<add-function signature="delete(PyObject*)">
<inject-code>
if (Shiboken::Object::checkType(%1)) {
- Shiboken::Object::callCppDestructors((SbkObject*)%1);
+ Shiboken::Object::callCppDestructors(reinterpret_cast&lt;SbkObject *&gt;(%1));
} else {
PyErr_SetString(PyExc_TypeError, "You need a shiboken-based type.");
}
@@ -57,7 +57,7 @@
<add-function signature="ownedByPython(PyObject*)" return-type="bool">
<inject-code>
if (Shiboken::Object::checkType(%1)) {
- bool hasOwnership = Shiboken::Object::hasOwnership((SbkObject*)%1);
+ bool hasOwnership = Shiboken::Object::hasOwnership(reinterpret_cast&lt;SbkObject *&gt;(%1));
%PYARG_0 = %CONVERTTOPYTHON[bool](hasOwnership);
} else {
PyErr_SetString(PyExc_TypeError, "You need a shiboken-based type.");
@@ -68,7 +68,7 @@
<add-function signature="createdByPython(PyObject*)" return-type="bool">
<inject-code>
if (Shiboken::Object::checkType(%1)) {
- bool wasCreatedByPython = Shiboken::Object::wasCreatedByPython((SbkObject*)%1);
+ bool wasCreatedByPython = Shiboken::Object::wasCreatedByPython(reinterpret_cast&lt;SbkObject *&gt;(%1));
%PYARG_0 = %CONVERTTOPYTHON[bool](wasCreatedByPython);
} else {
PyErr_SetString(PyExc_TypeError, "You need a shiboken-based type.");
@@ -81,7 +81,7 @@
if (!Shiboken::Object::checkType(%1)) {
%PYARG_0 = Shiboken::String::fromCString("Ordinary Python type.");
} else {
- std::string str = Shiboken::Object::info((SbkObject*)%1);
+ std::string str = Shiboken::Object::info(reinterpret_cast&lt;SbkObject *&gt;(%1));
%PYARG_0 = Shiboken::String::fromCString(str.c_str());
}
</inject-code>
diff --git a/sources/shiboken6/tests/samplebinding/typesystem_sample.xml b/sources/shiboken6/tests/samplebinding/typesystem_sample.xml
index 1a0f01264..bc5052e49 100644
--- a/sources/shiboken6/tests/samplebinding/typesystem_sample.xml
+++ b/sources/shiboken6/tests/samplebinding/typesystem_sample.xml
@@ -132,7 +132,7 @@
<target-to-native>
<add-conversion check="checkPyCapsuleOrPyCObject(%in)" type="PyObject">
void *ptr = PyCapsule_GetPointer(%in, nullptr);
- %out = *((%OUTTYPE*)ptr);
+ %out = *reinterpret_cast&lt;%OUTTYPE*&gt;(ptr);
</add-conversion>
</target-to-native>
</conversion-rule>