Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp1
-rw-r--r--sources/shiboken6/libshiboken/basewrapper.cpp47
-rw-r--r--sources/shiboken6/libshiboken/basewrapper.h1
-rw-r--r--sources/shiboken6/libshiboken/bindingmanager.cpp10
-rw-r--r--sources/shiboken6/libshiboken/pep384impl.cpp20
-rw-r--r--sources/shiboken6/libshiboken/sbkarrayconverter.h2
-rw-r--r--sources/shiboken6/libshiboken/sbkconverter.cpp2
-rw-r--r--sources/shiboken6/libshiboken/sbkenum.cpp6
-rw-r--r--sources/shiboken6/libshiboken/sbkmodule.cpp6
-rw-r--r--sources/shiboken6/libshiboken/sbkstring.h10
-rw-r--r--sources/shiboken6/libshiboken/shiboken.h1
-rw-r--r--sources/shiboken6/libshiboken/shibokenbuffer.h8
-rw-r--r--sources/shiboken6/libshiboken/signature/signature.cpp13
-rw-r--r--sources/shiboken6/libshiboken/signature/signature_extend.cpp24
-rw-r--r--sources/shiboken6/libshiboken/signature/signature_globals.cpp10
-rw-r--r--sources/shiboken6/libshiboken/signature/signature_helper.cpp23
-rw-r--r--sources/shiboken6/libshiboken/voidptr.cpp3
17 files changed, 88 insertions, 99 deletions
diff --git a/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp b/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp
index ca3dfebed..2cab76b47 100644
--- a/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp
+++ b/sources/pyside6/PySide6/QtQml/pysideqmlvolatilebool.cpp
@@ -5,6 +5,7 @@
#include <pep384ext.h>
#include <signature.h>
+#include <sbktypefactory.h>
#include <QtCore/QDebug>
diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp
index 0ce80d0c6..8443af33d 100644
--- a/sources/shiboken6/libshiboken/basewrapper.cpp
+++ b/sources/shiboken6/libshiboken/basewrapper.cpp
@@ -7,13 +7,12 @@
#include "helper.h"
#include "pep384ext.h"
#include "sbkconverter.h"
-#include "sbkenum.h"
#include "sbkerrors.h"
#include "sbkfeature_base.h"
-#include "sbkmodule.h"
#include "sbkstring.h"
#include "sbkstaticstrings.h"
#include "sbkstaticstrings_p.h"
+#include "sbktypefactory.h"
#include "autodecref.h"
#include "gilstate.h"
#include <string>
@@ -50,7 +49,7 @@ bool walkThroughBases(PyTypeObject *currentType, Predicate predicate)
const Py_ssize_t numBases = PyTuple_Size(bases);
bool result = false;
for (Py_ssize_t i = 0; !result && i < numBases; ++i) {
- auto type = reinterpret_cast<PyTypeObject *>(PyTuple_GetItem(bases, i));
+ auto *type = reinterpret_cast<PyTypeObject *>(PyTuple_GetItem(bases, i));
if (PyType_IsSubtype(type, SbkObject_TypeF()) != 0) {
result = PepType_SOTP(type)->is_user_type
? walkThroughBases(type, predicate) : predicate(type);
@@ -249,7 +248,7 @@ PyTypeObject *SbkObjectType_TypeF(void)
static PyObject *SbkObjectGetDict(PyObject *pObj, void *)
{
- auto ret = SbkObject_GetDict_NoRef(pObj);
+ auto *ret = SbkObject_GetDict_NoRef(pObj);
Py_XINCREF(ret);
return ret;
}
@@ -264,17 +263,15 @@ static int SbkObject_tp_traverse(PyObject *self, visitproc visit, void *arg)
auto *sbkSelf = reinterpret_cast<SbkObject *>(self);
//Visit children
- Shiboken::ParentInfo *pInfo = sbkSelf->d->parentInfo;
- if (pInfo) {
+ if (auto *pInfo = sbkSelf->d->parentInfo) {
for (SbkObject *c : pInfo->children)
Py_VISIT(c);
}
//Visit refs
- Shiboken::RefCountMap *rInfo = sbkSelf->d->referredObjects;
- if (rInfo) {
- for (auto it = rInfo->begin(), end = rInfo->end(); it != end; ++it)
- Py_VISIT(it->second);
+ if (auto *rInfo = sbkSelf->d->referredObjects) {
+ for (const auto &p : *rInfo)
+ Py_VISIT(p.second);
}
if (sbkSelf->ob_dict)
@@ -422,7 +419,9 @@ static void SbkDeallocWrapperCommon(PyObject *pyObj, bool canDelete)
}
}
- PyObject *error_type, *error_value, *error_traceback;
+ PyObject *error_type{};
+ PyObject *error_value{};
+ PyObject *error_traceback{};
/* Save the current exception, if any. */
PyErr_Fetch(&error_type, &error_value, &error_traceback);
@@ -537,7 +536,7 @@ PyObject *MakeQAppWrapper(PyTypeObject *type)
static PyObject *qApp_last = nullptr;
// protecting from multiple application instances
- if (!(type == nullptr || qApp_last == Py_None)) {
+ if (type != nullptr && qApp_last != Py_None) {
const char *res_name = qApp_last != nullptr
? PepType_GetNameStr(Py_TYPE(qApp_last)) : "<Unknown>";
const char *type_name = PepType_GetNameStr(type);
@@ -575,9 +574,9 @@ static PyTypeObject *SbkObjectType_tp_new(PyTypeObject *metatype, PyObject *args
// Before we changed to heap types, it was sufficient to remove the
// Py_TPFLAGS_BASETYPE flag. That does not work, because PySide does
// not respect this flag itself!
- PyObject *name;
- PyObject *pyBases;
- PyObject *dict;
+ PyObject *name{};
+ PyObject *pyBases{};
+ PyObject *dict{};
static const char *kwlist[] = { "name", "bases", "dict", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO!O!:sbktype", const_cast<char **>(kwlist),
@@ -696,9 +695,8 @@ PyObject *SbkQApp_tp_new(PyTypeObject *subtype, PyObject *, PyObject *)
auto *self = reinterpret_cast<SbkObject *>(obSelf);
if (self == nullptr)
return nullptr;
- auto ret = _setupNew(obSelf, subtype);
- auto priv = self->d;
- priv->isQAppSingleton = 1;
+ auto *ret = _setupNew(obSelf, subtype);
+ self->d->isQAppSingleton = 1;
return ret;
}
@@ -716,7 +714,7 @@ PyObject *FallbackRichCompare(PyObject *self, PyObject *other, int op)
{
// This is a very simple implementation that supplies a simple identity.
static const char * const opstrings[] = {"<", "<=", "==", "!=", ">", ">="};
- PyObject *res;
+ PyObject *res{};
switch (op) {
@@ -1002,7 +1000,7 @@ introduceWrapperType(PyObject *enclosingObject,
auto *type = SbkType_FromSpecBasesMeta(typeSpec, bases, SbkObjectType_TypeF());
- auto sotp = PepType_SOTP(type);
+ auto *sotp = PepType_SOTP(type);
if (wrapperFlags & DeleteInMainThread)
sotp->delete_in_main_thread = 1;
sotp->type_behaviour = (wrapperFlags & Value) != 0
@@ -1170,7 +1168,7 @@ bool wasCreatedByPython(SbkObject *pyObj)
void callCppDestructors(SbkObject *pyObj)
{
- auto priv = pyObj->d;
+ auto *priv = pyObj->d;
if (priv->isQAppSingleton && DestroyQApplication) {
// PYSIDE-1470: Allow to destroy the application from Shiboken.
DestroyQApplication();
@@ -1304,10 +1302,9 @@ static void recursive_invalidate(SbkObject *self, std::set<SbkObject *> &seen)
}
// If has ref to other objects invalidate all
- if (self->d->referredObjects) {
- RefCountMap &refCountMap = *(self->d->referredObjects);
- for (auto it = refCountMap.begin(), end = refCountMap.end(); it != end; ++it)
- recursive_invalidate(it->second, seen);
+ if (auto *rInfo = self->d->referredObjects) {
+ for (const auto &p : *rInfo)
+ recursive_invalidate(p.second, seen);
}
}
diff --git a/sources/shiboken6/libshiboken/basewrapper.h b/sources/shiboken6/libshiboken/basewrapper.h
index ec5545aea..5e77d0c4f 100644
--- a/sources/shiboken6/libshiboken/basewrapper.h
+++ b/sources/shiboken6/libshiboken/basewrapper.h
@@ -6,7 +6,6 @@
#include "sbkpython.h"
#include "shibokenmacros.h"
-#include "sbktypefactory.h"
#include <vector>
#include <string>
diff --git a/sources/shiboken6/libshiboken/bindingmanager.cpp b/sources/shiboken6/libshiboken/bindingmanager.cpp
index 83c927ae5..df1079af8 100644
--- a/sources/shiboken6/libshiboken/bindingmanager.cpp
+++ b/sources/shiboken6/libshiboken/bindingmanager.cpp
@@ -230,10 +230,9 @@ void BindingManager::BindingManagerPrivate::assignWrapper(SbkObject *wrapper, co
}
}
-BindingManager::BindingManager()
+BindingManager::BindingManager() :
+ m_d(new BindingManager::BindingManagerPrivate)
{
- m_d = new BindingManager::BindingManagerPrivate;
-
#ifdef SHIBOKEN_INSTALL_FREE_DEBUG_HOOK
debugInstallFreeHook();
#endif
@@ -504,10 +503,11 @@ bool callInheritedInit(PyObject *self, PyObject *args, PyObject *kwds,
auto *startType = Py_TYPE(self);
auto *mro = startType->tp_mro;
- Py_ssize_t idx, n = PyTuple_GET_SIZE(mro);
+ Py_ssize_t idx = 0;
+ const Py_ssize_t n = PyTuple_GET_SIZE(mro);
auto classNameLen = std::strrchr(fullName, '.') - fullName;
/* No need to check the last one: it's gonna be skipped anyway. */
- for (idx = 0; idx + 1 < n; ++idx) {
+ for ( ; idx + 1 < n; ++idx) {
auto *lookType = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, idx));
const char *lookName = lookType->tp_name;
auto lookLen = long(std::strlen(lookName));
diff --git a/sources/shiboken6/libshiboken/pep384impl.cpp b/sources/shiboken6/libshiboken/pep384impl.cpp
index 5310207a3..f51296851 100644
--- a/sources/shiboken6/libshiboken/pep384impl.cpp
+++ b/sources/shiboken6/libshiboken/pep384impl.cpp
@@ -896,15 +896,13 @@ PepRun_GetResult(const char *command)
/*
* Evaluate a string and return the variable `result`
*/
- PyObject *d, *v, *res;
-
- d = PyDict_New();
+ PyObject *d = PyDict_New();
if (d == nullptr
|| PyDict_SetItem(d, Shiboken::PyMagicName::builtins(), PyEval_GetBuiltins()) < 0) {
return nullptr;
}
- v = PyRun_String(command, Py_file_input, d, d);
- res = v ? PyDict_GetItem(d, Shiboken::PyName::result()) : nullptr;
+ PyObject *v = PyRun_String(command, Py_file_input, d, d);
+ PyObject *res = v ? PyDict_GetItem(d, Shiboken::PyName::result()) : nullptr;
Py_XDECREF(v);
Py_DECREF(d);
return res;
@@ -912,7 +910,7 @@ PepRun_GetResult(const char *command)
PyTypeObject *PepType_Type_tp_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
{
- auto ret = PyType_Type.tp_new(metatype, args, kwds);
+ auto *ret = PyType_Type.tp_new(metatype, args, kwds);
return reinterpret_cast<PyTypeObject *>(ret);
}
@@ -941,7 +939,7 @@ _Pep_PrivateMangle(PyObject *self, PyObject *name)
Py_INCREF(name);
return name;
}
- size_t nlen = PyUnicode_GET_LENGTH(name);
+ const Py_ssize_t nlen = PyUnicode_GET_LENGTH(name);
/* Don't mangle __id__ or names with dots. */
if ((PyUnicode_READ_CHAR(name, nlen-1) == '_' &&
PyUnicode_READ_CHAR(name, nlen-2) == '_') ||
@@ -955,9 +953,9 @@ _Pep_PrivateMangle(PyObject *self, PyObject *name)
// PYSIDE-1436: _Py_Mangle is no longer exposed; implement it always.
// The rest of this function is our own implementation of _Py_Mangle.
// Please compare the original function in compile.c .
- size_t plen = PyUnicode_GET_LENGTH(privateobj.object());
+ Py_ssize_t plen = PyUnicode_GET_LENGTH(privateobj.object());
/* Strip leading underscores from class name */
- size_t ipriv = 0;
+ Py_ssize_t ipriv = 0;
while (PyUnicode_READ_CHAR(privateobj.object(), ipriv) == '_')
ipriv++;
if (ipriv == plen) {
@@ -971,8 +969,8 @@ _Pep_PrivateMangle(PyObject *self, PyObject *name)
"private identifier too large to be mangled");
return nullptr;
}
- size_t const amount = ipriv + 1 + plen + nlen;
- size_t const big_stack = 1000;
+ const Py_ssize_t amount = ipriv + 1 + plen + nlen;
+ const Py_ssize_t big_stack = 1000;
wchar_t bigbuf[big_stack];
wchar_t *resbuf = amount <= big_stack ? bigbuf : (wchar_t *)malloc(sizeof(wchar_t) * amount);
if (!resbuf)
diff --git a/sources/shiboken6/libshiboken/sbkarrayconverter.h b/sources/shiboken6/libshiboken/sbkarrayconverter.h
index f07cb1d70..dcb9bfb38 100644
--- a/sources/shiboken6/libshiboken/sbkarrayconverter.h
+++ b/sources/shiboken6/libshiboken/sbkarrayconverter.h
@@ -70,7 +70,7 @@ template <class T, int columns>
class Array2Handle
{
public:
- typedef T RowType[columns];
+ using RowType = T[columns];
Array2Handle() = default;
diff --git a/sources/shiboken6/libshiboken/sbkconverter.cpp b/sources/shiboken6/libshiboken/sbkconverter.cpp
index 9ab674415..dac3fb638 100644
--- a/sources/shiboken6/libshiboken/sbkconverter.cpp
+++ b/sources/shiboken6/libshiboken/sbkconverter.cpp
@@ -180,7 +180,7 @@ SbkConverter *createConverterObject(PyTypeObject *type,
CppToPythonFunc pointerToPythonFunc,
CppToPythonFunc copyToPythonFunc)
{
- auto converter = new SbkConverter;
+ auto *converter = new SbkConverter;
converter->pythonType = type;
// PYSIDE-595: All types are heaptypes now, so provide reference.
Py_XINCREF(type);
diff --git a/sources/shiboken6/libshiboken/sbkenum.cpp b/sources/shiboken6/libshiboken/sbkenum.cpp
index 4c0597bda..d43756249 100644
--- a/sources/shiboken6/libshiboken/sbkenum.cpp
+++ b/sources/shiboken6/libshiboken/sbkenum.cpp
@@ -9,8 +9,7 @@
#include "sbkconverter.h"
#include "basewrapper.h"
#include "autodecref.h"
-#include "sbkpython.h"
-#include "signature.h"
+#include "sbktypefactory.h"
#include <cstring>
#include <vector>
@@ -143,7 +142,8 @@ static PyObject *missing_func(PyObject * /* self */ , PyObject *args)
static auto *const _mro = Shiboken::String::createStaticString("__mro__");
static auto *const _class = Shiboken::String::createStaticString("__class__");
- PyObject *klass{}, *value{};
+ PyObject *klass{};
+ PyObject *value{};
if (!PyArg_UnpackTuple(args, "missing", 2, 2, &klass, &value))
Py_RETURN_NONE;
if (!PyLong_Check(value))
diff --git a/sources/shiboken6/libshiboken/sbkmodule.cpp b/sources/shiboken6/libshiboken/sbkmodule.cpp
index a94fbe279..acadc60fa 100644
--- a/sources/shiboken6/libshiboken/sbkmodule.cpp
+++ b/sources/shiboken6/libshiboken/sbkmodule.cpp
@@ -192,7 +192,7 @@ static PyObject *PyModule_lazyGetAttro(PyObject *module, PyObject *name)
// - check if the attribute is present and return it.
auto *attr = PyObject_GenericGetAttr(module, name);
// - we handle AttributeError, only.
- if (!(attr == nullptr && PyErr_ExceptionMatches(PyExc_AttributeError)))
+ if (attr != nullptr || PyErr_ExceptionMatches(PyExc_AttributeError) == 0)
return attr;
PyErr_Clear();
@@ -280,7 +280,7 @@ static bool isImportStar(PyObject *module)
AutoDecRef dec_co_code(PyObject_GetAttr(dec_f_code, _co_code));
AutoDecRef dec_f_lasti(PyObject_GetAttr(dec_frame, _f_lasti));
Py_ssize_t f_lasti = PyLong_AsSsize_t(dec_f_lasti);
- Py_ssize_t code_len;
+ Py_ssize_t code_len{};
char *co_code{};
PyBytes_AsStringAndSize(dec_co_code, &co_code, &code_len);
uint8_t opcode2 = co_code[f_lasti];
@@ -401,7 +401,7 @@ void AddTypeCreationFunction(PyObject *module,
auto nit = nameToFunc.find(containerName);
// - insert namePath into the subtype vector of the main type.
- nit->second.subtypeNames.push_back(namePath);
+ nit->second.subtypeNames.emplace_back(namePath);
// - insert it also as its own entry.
nit = nameToFunc.find(namePath);
TypeCreationStruct tcStruct{func, {}};
diff --git a/sources/shiboken6/libshiboken/sbkstring.h b/sources/shiboken6/libshiboken/sbkstring.h
index ebc5428c7..3ff2805e2 100644
--- a/sources/shiboken6/libshiboken/sbkstring.h
+++ b/sources/shiboken6/libshiboken/sbkstring.h
@@ -7,9 +7,7 @@
#include "sbkpython.h"
#include "shibokenmacros.h"
-namespace Shiboken
-{
-namespace String
+namespace Shiboken::String
{
LIBSHIBOKEN_API bool check(PyObject *obj);
LIBSHIBOKEN_API bool checkIterable(PyObject *obj);
@@ -33,10 +31,6 @@ namespace String
LIBSHIBOKEN_API PyObject *getSnakeCaseName(PyObject *name, bool lower);
LIBSHIBOKEN_API PyObject *repr(PyObject *o);
-} // namespace String
-} // namespace Shiboken
-
+} // namespace Shiboken::String
#endif
-
-
diff --git a/sources/shiboken6/libshiboken/shiboken.h b/sources/shiboken6/libshiboken/shiboken.h
index fcf777ae0..27ba05fa7 100644
--- a/sources/shiboken6/libshiboken/shiboken.h
+++ b/sources/shiboken6/libshiboken/shiboken.h
@@ -19,6 +19,7 @@
#include "sbkmodule.h"
#include "sbkstring.h"
#include "sbkstaticstrings.h"
+#include "sbktypefactory.h"
#include "shibokenmacros.h"
#include "shibokenbuffer.h"
#include "signature.h"
diff --git a/sources/shiboken6/libshiboken/shibokenbuffer.h b/sources/shiboken6/libshiboken/shibokenbuffer.h
index 6b17eb6eb..068a5e9fd 100644
--- a/sources/shiboken6/libshiboken/shibokenbuffer.h
+++ b/sources/shiboken6/libshiboken/shibokenbuffer.h
@@ -7,10 +7,7 @@
#include "sbkpython.h"
#include "shibokenmacros.h"
-namespace Shiboken
-{
-
-namespace Buffer
+namespace Shiboken::Buffer
{
enum Type {
ReadOnly,
@@ -51,7 +48,6 @@ namespace Buffer
*/
LIBSHIBOKEN_API void *copyData(PyObject *pyObj, Py_ssize_t *size = nullptr);
-} // namespace Buffer
-} // namespace Shiboken
+} // namespace Shiboken::Buffer
#endif
diff --git a/sources/shiboken6/libshiboken/signature/signature.cpp b/sources/shiboken6/libshiboken/signature/signature.cpp
index 3255cb56d..45269844e 100644
--- a/sources/shiboken6/libshiboken/signature/signature.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature.cpp
@@ -424,7 +424,9 @@ static int PySide_FinishSignatures(PyObject *module, const char *signatures[])
* to the PyCFunction attributes. Therefore I simplified things
* and always use our own mapping.
*/
- PyObject *key, *func, *obdict = PyModule_GetDict(module);
+ PyObject *key{};
+ PyObject *func{};
+ PyObject *obdict = PyModule_GetDict(module);
Py_ssize_t pos = 0;
while (PyDict_Next(obdict, &pos, &key, &func))
@@ -538,7 +540,7 @@ static PyObject *adjustFuncName(const char *func_name)
assert(PyType_Check(obtype)); // This was not true for __init__!
// Find the feature flags
- auto type = reinterpret_cast<PyTypeObject *>(obtype.object());
+ auto *type = reinterpret_cast<PyTypeObject *>(obtype.object());
AutoDecRef dict(PepType_GetDict(type));
int id = currentSelectId(type);
id = id < 0 ? 0 : id; // if undefined, set to zero
@@ -585,7 +587,9 @@ void SetError_Argument(PyObject *args, const char *func_name, PyObject *info)
// PYSIDE-1305: Handle errors set by fillQtProperties.
if (PyErr_Occurred()) {
- PyObject *e, *v, *t;
+ PyObject *e{};
+ PyObject *v{};
+ PyObject *t{};
// Note: These references are all borrowed.
PyErr_Fetch(&e, &v, &t);
Py_DECREF(e);
@@ -606,7 +610,8 @@ void SetError_Argument(PyObject *args, const char *func_name, PyObject *info)
PyErr_Print();
Py_FatalError("seterror_argument did not receive a result");
}
- PyObject *err, *msg;
+ PyObject *err{};
+ PyObject *msg{};
if (!PyArg_UnpackTuple(res, func_name, 2, 2, &err, &msg)) {
PyErr_Print();
Py_FatalError("unexpected failure in seterror_argument");
diff --git a/sources/shiboken6/libshiboken/signature/signature_extend.cpp b/sources/shiboken6/libshiboken/signature/signature_extend.cpp
index 7292f8216..3ce9e21e3 100644
--- a/sources/shiboken6/libshiboken/signature/signature_extend.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature_extend.cpp
@@ -120,12 +120,10 @@ static int handle_doc_in_progress = 0;
static PyObject *handle_doc(PyObject *ob, PyObject *old_descr)
{
AutoDecRef ob_type_mod(GetClassOrModOf(ob));
- const char *name;
bool isModule = PyModule_Check(ob_type_mod.object());
- if (isModule)
- name = PyModule_GetName(ob_type_mod.object());
- else
- name = reinterpret_cast<PyTypeObject *>(ob_type_mod.object())->tp_name;
+ const char *name = isModule
+ ? PyModule_GetName(ob_type_mod.object())
+ : reinterpret_cast<PyTypeObject *>(ob_type_mod.object())->tp_name;
PyObject *res{};
if (handle_doc_in_progress || name == nullptr
@@ -205,14 +203,14 @@ int PySide_PatchTypes(void)
AutoDecRef wrap_descr(PyObject_GetAttrString(
reinterpret_cast<PyObject *>(Py_TYPE(Py_True)), "__add__"));
// abbreviations for readability
- auto md_gs = new_PyMethodDescr_getsets;
- auto md_doc = &old_md_doc_descr;
- auto cf_gs = new_PyCFunction_getsets;
- auto cf_doc = &old_cf_doc_descr;
- auto sm_gs = new_PyStaticMethod_getsets;
- auto sm_doc = &old_sm_doc_descr;
- auto wd_gs = new_PyWrapperDescr_getsets;
- auto wd_doc = &old_wd_doc_descr;
+ auto *md_gs = new_PyMethodDescr_getsets;
+ auto *md_doc = &old_md_doc_descr;
+ auto *cf_gs = new_PyCFunction_getsets;
+ auto *cf_doc = &old_cf_doc_descr;
+ auto *sm_gs = new_PyStaticMethod_getsets;
+ auto *sm_doc = &old_sm_doc_descr;
+ auto *wd_gs = new_PyWrapperDescr_getsets;
+ auto *wd_doc = &old_wd_doc_descr;
if (meth_descr.isNull() || wrap_descr.isNull()
|| PyType_Ready(Py_TYPE(meth_descr)) < 0
diff --git a/sources/shiboken6/libshiboken/signature/signature_globals.cpp b/sources/shiboken6/libshiboken/signature/signature_globals.cpp
index 3a79a12d5..0a08309cc 100644
--- a/sources/shiboken6/libshiboken/signature/signature_globals.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature_globals.cpp
@@ -120,7 +120,7 @@ static safe_globals_struc *init_phase_1()
return p;
- } while (0);
+ } while (false);
PyErr_Print();
Py_FatalError("could not initialize part 1");
@@ -130,10 +130,8 @@ static safe_globals_struc *init_phase_1()
static int init_phase_2(safe_globals_struc *p, PyMethodDef *methods)
{
do {
- PyMethodDef *ml;
-
// The single function to be called, but maybe more to come.
- for (ml = methods; ml->ml_name != nullptr; ml++) {
+ for (PyMethodDef *ml = methods; ml->ml_name != nullptr; ++ml) {
PyObject *v = PyCFunction_NewEx(ml, nullptr, nullptr);
if (v == nullptr
|| PyObject_SetAttrString(p->helper_module, ml->ml_name, v) != 0)
@@ -220,10 +218,8 @@ static int init_phase_2(safe_globals_struc *p, PyMethodDef *methods)
static void handler(int sig) {
#if defined(__GLIBC__)
void *array[30];
- size_t size;
-
// get void *'s for all entries on the stack
- size = backtrace(array, 30);
+ const int size = backtrace(array, 30);
// print out all the frames to stderr
#endif
diff --git a/sources/shiboken6/libshiboken/signature/signature_helper.cpp b/sources/shiboken6/libshiboken/signature/signature_helper.cpp
index cf84cfa13..9aab7a6a9 100644
--- a/sources/shiboken6/libshiboken/signature/signature_helper.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature_helper.cpp
@@ -17,6 +17,8 @@
#include "signature_p.h"
+#include <cstring>
+
using namespace Shiboken;
extern "C" {
@@ -115,11 +117,11 @@ static PyObject *_func_with_new_name(PyTypeObject *type,
* but does not create a descriptor.
* XXX Maybe we can get rid of this, completely?
*/
- auto obtype = reinterpret_cast<PyObject *>(type);
- int len = strlen(new_name);
- auto name = new char[len + 1];
- strcpy(name, new_name);
- auto new_meth = new PyMethodDef;
+ auto *obtype = reinterpret_cast<PyObject *>(type);
+ const size_t len = std::strlen(new_name);
+ auto *name = new char[len + 1];
+ std::strcpy(name, new_name);
+ auto *new_meth = new PyMethodDef;
new_meth->ml_name = name;
new_meth->ml_meth = meth->ml_meth;
new_meth->ml_flags = meth->ml_flags;
@@ -196,8 +198,8 @@ static PyObject *_build_new_entry(PyObject *new_name, PyObject *value)
if (list.isNull())
return nullptr;
for (int idx = 0; idx < len; ++idx) {
- auto multi_entry = PyList_GetItem(multi, idx);
- auto dup = PyDict_Copy(multi_entry);
+ auto *multi_entry = PyList_GetItem(multi, idx);
+ auto *dup = PyDict_Copy(multi_entry);
if (PyDict_SetItem(dup, PyName::name(), new_name) < 0)
return nullptr;
if (PyList_SetItem(list, idx, dup) < 0)
@@ -215,7 +217,8 @@ static PyObject *_build_new_entry(PyObject *new_name, PyObject *value)
int insert_snake_case_variants(PyObject *dict)
{
AutoDecRef snake_dict(PyDict_New());
- PyObject *key, *value;
+ PyObject *key{};
+ PyObject *value{};
Py_ssize_t pos = 0;
while (PyDict_Next(dict, &pos, &key, &value)) {
AutoDecRef name(String::getSnakeCaseName(key, true));
@@ -363,8 +366,8 @@ int _build_func_to_type(PyObject *obtype)
if (descr == nullptr)
return -1;
char mangled_name[200];
- strcpy(mangled_name, meth->ml_name);
- strcat(mangled_name, ".overload");
+ std::strcpy(mangled_name, meth->ml_name);
+ std::strcat(mangled_name, ".overload");
if (PyDict_SetItemString(dict, mangled_name, descr) < 0)
return -1;
if (meth->ml_flags & METH_STATIC) {
diff --git a/sources/shiboken6/libshiboken/voidptr.cpp b/sources/shiboken6/libshiboken/voidptr.cpp
index 8bb3f6ac8..ce85d4946 100644
--- a/sources/shiboken6/libshiboken/voidptr.cpp
+++ b/sources/shiboken6/libshiboken/voidptr.cpp
@@ -6,6 +6,7 @@
#include "sbkconverter.h"
#include "basewrapper.h"
#include "basewrapper_p.h"
+#include "sbktypefactory.h"
extern "C"
{
@@ -41,7 +42,7 @@ PyObject *SbkVoidPtrObject_new(PyTypeObject *type, PyObject * /* args */, PyObje
int SbkVoidPtrObject_init(PyObject *self, PyObject *args, PyObject *kwds)
{
- PyObject *addressObject;
+ PyObject *addressObject{};
Py_ssize_t size = -1;
int isWritable = 0;
auto *sbkSelf = reinterpret_cast<SbkVoidPtrObject *>(self);