diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index 31a9420f5f..d41fe6f25f 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include "Application.h" @@ -1475,7 +1476,7 @@ PyObject* Application::sReload(PyObject * /*self*/, PyObject *args) PyObject* Application::sLoadFile(PyObject * /*self*/, PyObject *args) { - char *path, *mod = ""; + const char *path, *mod = ""; if (!PyArg_ParseTuple(args, "s|s", &path, &mod)) return nullptr; diff --git a/src/Gui/CommandPyImp.cpp b/src/Gui/CommandPyImp.cpp index 448effd2a6..335d10b105 100644 --- a/src/Gui/CommandPyImp.cpp +++ b/src/Gui/CommandPyImp.cpp @@ -34,6 +34,7 @@ #include "Selection.h" #include "Window.h" #include "PythonWrapper.h" +#include // inclusion of the generated files (generated out of CommandPy.xml) #include "CommandPy.h" @@ -296,10 +297,12 @@ PyObject* CommandPy::createCustomCommand(PyObject* args, PyObject* kw) const char* statustipTxt = nullptr; const char* pixmapTxt = nullptr; const char* shortcutTxt = nullptr; - static char* kwlist[] = {"macroFile", "menuText", "toolTip", "whatsThis","statusTip", "pixmap", "shortcut", nullptr}; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|zzzzzz", kwlist, ¯oFile, &menuTxt, - &tooltipTxt, &whatsthisTxt, &statustipTxt, &pixmapTxt, &shortcutTxt)) + static const std::array kwlist{"macroFile", "menuText", "toolTip", "whatsThis", "statusTip", + "pixmap", "shortcut", nullptr}; + if (!Base::Wrapped_ParseTupleAndKeywords(args, kw, "s|zzzzzz", kwlist, ¯oFile, &menuTxt, + &tooltipTxt, &whatsthisTxt, &statustipTxt, &pixmapTxt, &shortcutTxt)) { return nullptr; + } auto name = Application::Instance->commandManager().newMacroName(); CommandManager& commandManager = Application::Instance->commandManager(); diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index d74f499f9c..a38283cc03 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include "Selection.h" #include "SelectionObject.h" @@ -2102,9 +2103,9 @@ PyObject *SelectionSingleton::sSetPreselection(PyObject * /*self*/, PyObject *ar char* subname = nullptr; float x = 0, y = 0, z = 0; int type = 1; - static char *kwlist[] = {"obj","subname","x","y","z","tp",nullptr}; - if (PyArg_ParseTupleAndKeywords(args, kwd, "O!|sfffi", kwlist, - &(App::DocumentObjectPy::Type),&object,&subname,&x,&y,&z,&type)) { + static const std::array kwlist{"obj", "subname", "x", "y", "z", "tp", nullptr}; + if (Base::Wrapped_ParseTupleAndKeywords(args, kwd, "O!|sfffi", kwlist, &(App::DocumentObjectPy::Type), &object, + &subname, &x, &y, &z, &type)) { auto docObjPy = static_cast(object); App::DocumentObject* docObj = docObjPy->getDocumentObjectPtr(); if (!docObj || !docObj->getNameInDocument()) { diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index db4cebe041..8f29d71e1f 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -368,11 +369,12 @@ Py::Object View3DInventorPy::fitAll(const Py::Tuple& args) Py::Object View3DInventorPy::boxZoom(const Py::Tuple& args, const Py::Dict& kwds) { - static char* kwds_box[] = {"XMin", "YMin", "XMax", "YMax", nullptr}; + static const std::array kwds_box{"XMin", "YMin", "XMax", "YMax", nullptr}; short xmin, ymin, xmax, ymax; - if (!PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "hhhh", kwds_box, - &xmin, &ymin, &xmax, &ymax)) + if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "hhhh", kwds_box, + &xmin, &ymin, &xmax, &ymax)) { throw Py::Exception(); + } SbBox2s box(xmin, ymin, xmax, ymax); getView3DIventorPtr()->getViewer()->boxZoom(box); @@ -2476,15 +2478,16 @@ Py::Object View3DInventorPy::setName(const Py::Tuple& args) Py::Object View3DInventorPy::toggleClippingPlane(const Py::Tuple& args, const Py::Dict& kwds) { - static char* keywords[] = {"toggle", "beforeEditing", "noManip", "pla", nullptr}; + static const std::array keywords {"toggle", "beforeEditing", "noManip", "pla", nullptr}; int toggle = -1; PyObject *beforeEditing = Py_False; PyObject *noManip = Py_True; PyObject *pyPla = Py_None; - if (!PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "|iO!O!O!", keywords, + if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "|iO!O!O!", keywords, &toggle, &PyBool_Type, &beforeEditing, &PyBool_Type, &noManip, - &Base::PlacementPy::Type, &pyPla)) + &Base::PlacementPy::Type, &pyPla)) { throw Py::Exception(); + } Base::Placement pla; if(pyPla!=Py_None) diff --git a/src/Gui/ViewProviderPyImp.cpp b/src/Gui/ViewProviderPyImp.cpp index 8b94c02cc6..2e9f49c8d5 100644 --- a/src/Gui/ViewProviderPyImp.cpp +++ b/src/Gui/ViewProviderPyImp.cpp @@ -32,6 +32,7 @@ #endif #include +#include #include "PythonWrapper.h" #include "SoFCDB.h" @@ -185,10 +186,11 @@ PyObject* ViewProviderPy::canDropObject(PyObject *args, PyObject *kw) PyObject *owner = Py_None; PyObject *pyElements = Py_None; const char *subname = nullptr; - static char* kwlist[] = {"obj","owner","subname","elem",nullptr}; - if (!PyArg_ParseTupleAndKeywords(args, kw, "|OOsO", kwlist, - &obj, &owner, &subname, &pyElements)) + static const std::array kwlist{"obj", "owner", "subname", "elem", nullptr}; + if (!Base::Wrapped_ParseTupleAndKeywords(args, kw, "|OOsO", kwlist, + &obj, &owner, &subname, &pyElements)) { return nullptr; + } PY_TRY { Base::PyTypeCheck(&obj, &App::DocumentObjectPy::Type, "expecting 'obj' to be of type App.DocumentObject or None"); @@ -245,10 +247,11 @@ PyObject* ViewProviderPy::dropObject(PyObject *args, PyObject *kw) PyObject *owner = Py_None; PyObject *pyElements = Py_None; const char *subname = nullptr; - static char* kwlist[] = {"obj","owner","subname","elem",nullptr}; - if (!PyArg_ParseTupleAndKeywords(args, kw, "O!|OsO", kwlist, - &App::DocumentObjectPy::Type, &obj, &owner, &subname, &pyElements)) + static const std::array kwlist{"obj", "owner", "subname", "elem", nullptr}; + if (!Base::Wrapped_ParseTupleAndKeywords(args, kw, "O!|OsO", kwlist, + &App::DocumentObjectPy::Type, &obj, &owner, &subname, &pyElements)) { return nullptr; + } PY_TRY { Base::PyTypeCheck(&owner, &App::DocumentObjectPy::Type, "expecting 'owner' to be of type App.DocumentObject or None");