diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-07 15:05:32 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-25 10:44:14 +0200 |
commit | 3680a489521e4c13488b4f3f462b8e34cebd0e47 (patch) | |
tree | 82b18a72a18c2db7e4d046af0f6c5d3dd3f80f68 /sources | |
parent | 7be4e64b4bac6e6b5a90eec74b9f2b661c60db3a (diff) |
shiboken: Replace C-style casts by C++ casts
Also change some reinterpret_cast<> to static_cast<> and use
standard types for pointer arithmetics.
Change-Id: Iafeeab5abffbca87d6f9767da9836bac342058c2
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/shiboken2/libshiboken/basewrapper.cpp | 23 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/bindingmanager.cpp | 4 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/qapp_macro.cpp | 2 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/sbkconverter.cpp | 4 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/sbkconverter_p.h | 2 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/voidptr.cpp | 4 |
6 files changed, 19 insertions, 20 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index 6d7bd0c24..1762a969f 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -86,13 +86,12 @@ static PyGetSetDef SbkObjectType_Type_getsetlist[] = { }; static PyType_Slot SbkObjectType_Type_slots[] = { - {Py_tp_dealloc, (void *)SbkObjectTypeDealloc}, - {Py_tp_setattro, (void *)PyObject_GenericSetAttr}, - {Py_tp_base, (void *)&PyType_Type}, - {Py_tp_alloc, (void *)PyType_GenericAlloc}, - {Py_tp_getset, (void *)SbkObjectType_Type_getsetlist}, - {Py_tp_new, (void *)SbkObjectTypeTpNew}, - {Py_tp_free, (void *)PyObject_GC_Del}, + {Py_tp_dealloc, reinterpret_cast<void *>(SbkObjectTypeDealloc)}, + {Py_tp_setattro, reinterpret_cast<void *>(PyObject_GenericSetAttr)}, + {Py_tp_base, static_cast<void *>(&PyType_Type)}, + {Py_tp_alloc, reinterpret_cast<void *>(PyType_GenericAlloc)}, + {Py_tp_new, reinterpret_cast<void *>(SbkObjectTypeTpNew)}, + {Py_tp_free, reinterpret_cast<void *>(PyObject_GC_Del)}, {0, nullptr} }; static PyType_Spec SbkObjectType_Type_spec = { @@ -261,11 +260,11 @@ static int SbkObject_clear(PyObject *self) } static PyType_Slot SbkObject_Type_slots[] = { - {Py_tp_dealloc, (void *)SbkDeallocWrapperWithPrivateDtor}, - {Py_tp_traverse, (void *)SbkObject_traverse}, - {Py_tp_clear, (void *)SbkObject_clear}, + {Py_tp_dealloc, reinterpret_cast<void *>(SbkDeallocWrapperWithPrivateDtor)}, + {Py_tp_traverse, reinterpret_cast<void *>(SbkObject_traverse)}, + {Py_tp_clear, reinterpret_cast<void *>(SbkObject_clear)}, // unsupported: {Py_tp_weaklistoffset, (void *)offsetof(SbkObject, weakreflist)}, - {Py_tp_getset, (void *)SbkObjectGetSetList}, + {Py_tp_getset, reinterpret_cast<void *>(SbkObjectGetSetList)}, // unsupported: {Py_tp_dictoffset, (void *)offsetof(SbkObject, ob_dict)}, {0, nullptr} }; @@ -427,7 +426,7 @@ PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *k PyObject *dict; static const char *kwlist[] = { "name", "bases", "dict", nullptr}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO!O!:sbktype", (char **)kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO!O!:sbktype", const_cast<char **>(kwlist), &name, &PyTuple_Type, &pyBases, &PyDict_Type, &dict)) diff --git a/sources/shiboken2/libshiboken/bindingmanager.cpp b/sources/shiboken2/libshiboken/bindingmanager.cpp index b6660a5bc..725150e87 100644 --- a/sources/shiboken2/libshiboken/bindingmanager.cpp +++ b/sources/shiboken2/libshiboken/bindingmanager.cpp @@ -224,7 +224,7 @@ void BindingManager::registerWrapper(SbkObject *pyObj, void *cptr) int *offset = d->mi_offsets; while (*offset != -1) { if (*offset > 0) - m_d->assignWrapper(pyObj, reinterpret_cast<void *>((std::size_t) cptr + (*offset))); + m_d->assignWrapper(pyObj, reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(cptr) + *offset)); offset++; } } @@ -244,7 +244,7 @@ void BindingManager::releaseWrapper(SbkObject *sbkObj) int *offset = d->mi_offsets; while (*offset != -1) { if (*offset > 0) - m_d->releaseWrapper(reinterpret_cast<void *>((std::size_t) cptr + (*offset)), sbkObj); + m_d->releaseWrapper(reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(cptr) + *offset), sbkObj); offset++; } } diff --git a/sources/shiboken2/libshiboken/qapp_macro.cpp b/sources/shiboken2/libshiboken/qapp_macro.cpp index cab205970..df24a8052 100644 --- a/sources/shiboken2/libshiboken/qapp_macro.cpp +++ b/sources/shiboken2/libshiboken/qapp_macro.cpp @@ -88,7 +88,7 @@ static SbkObject _Py_ChameleonQAppWrapper_Struct = { }; static PyObject *qApp_var = nullptr; -static PyObject *qApp_content = (PyObject *)&_Py_ChameleonQAppWrapper_Struct; +static PyObject *qApp_content = reinterpret_cast<PyObject *>(&_Py_ChameleonQAppWrapper_Struct); static PyObject *qApp_moduledicts[5] = {nullptr, nullptr, nullptr, nullptr, nullptr}; static int qApp_var_ref = 0; static int qApp_content_ref = 0; diff --git a/sources/shiboken2/libshiboken/sbkconverter.cpp b/sources/shiboken2/libshiboken/sbkconverter.cpp index a7b66b8cc..29eb19715 100644 --- a/sources/shiboken2/libshiboken/sbkconverter.cpp +++ b/sources/shiboken2/libshiboken/sbkconverter.cpp @@ -287,7 +287,7 @@ PythonToCppFunc isPythonToCppReferenceConvertible(SbkObjectType *type, PyObject void nonePythonToCppNullPtr(PyObject *, void *cppOut) { assert(cppOut); - *reinterpret_cast<void **>(cppOut) = nullptr; + *static_cast<void **>(cppOut) = nullptr; } void *cppPointer(PyTypeObject *desiredType, SbkObject *pyIn) @@ -568,7 +568,7 @@ PyObject *SpecificConverter::toPython(const void *cppIn) case CopyConversion: return copyToPython(m_converter, cppIn); case PointerConversion: - return pointerToPython(m_converter, *((const void **)cppIn)); + return pointerToPython(m_converter, *static_cast<const void * const *>(cppIn)); case ReferenceConversion: return referenceToPython(m_converter, cppIn); default: diff --git a/sources/shiboken2/libshiboken/sbkconverter_p.h b/sources/shiboken2/libshiboken/sbkconverter_p.h index 5af1b3fd5..3490a5c38 100644 --- a/sources/shiboken2/libshiboken/sbkconverter_p.h +++ b/sources/shiboken2/libshiboken/sbkconverter_p.h @@ -331,7 +331,7 @@ struct Primitive<unsigned PY_LONG_LONG> : OnePrimitive<unsigned PY_LONG_LONG> { static PyObject *toPython(const void *cppIn) { - return PyLong_FromUnsignedLongLong(*reinterpret_cast<const unsigned PY_LONG_LONG *>(cppIn)); + return PyLong_FromUnsignedLongLong(*static_cast<const unsigned PY_LONG_LONG *>(cppIn)); } static void toCpp(PyObject *pyIn, void *cppOut) { diff --git a/sources/shiboken2/libshiboken/voidptr.cpp b/sources/shiboken2/libshiboken/voidptr.cpp index 2728b24c8..1bba9b4f7 100644 --- a/sources/shiboken2/libshiboken/voidptr.cpp +++ b/sources/shiboken2/libshiboken/voidptr.cpp @@ -275,7 +275,7 @@ static int SbkVoidPtrObject_getbuffer(PyObject *obj, Py_buffer *view, int flags) view->itemsize = 1; view->format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) - view->format = "B"; + view->format = const_cast<char *>("B"); view->ndim = 1; view->shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) @@ -354,7 +354,7 @@ PyTypeObject *SbkVoidPtrTypeF(void) { static PyTypeObject *type = nullptr; if (!type) - type = (PyTypeObject *)PyType_FromSpec(&SbkVoidPtrType_spec); + type = reinterpret_cast<PyTypeObject *>(PyType_FromSpec(&SbkVoidPtrType_spec)); #if PY_VERSION_HEX < 0x03000000 type->tp_as_buffer = &SbkVoidPtrObjectBufferProc; |