diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index 0f5de8170..c24be3cc4 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -182,7 +182,7 @@ PyObject* DocumentPy::removeObject(PyObject *args) PyObject* DocumentPy::copyObject(PyObject *args) { - PyObject *obj, *rec=0, *keep=0; + PyObject *obj, *rec=Py_False, *keep=Py_False; if (!PyArg_ParseTuple(args, "O!|O!O!",&(DocumentObjectPy::Type),&obj,&PyBool_Type,&rec,&PyBool_Type,&keep)) return NULL; // NULL triggers exception @@ -201,7 +201,7 @@ PyObject* DocumentPy::copyObject(PyObject *args) PyObject* DocumentPy::moveObject(PyObject *args) { - PyObject *obj, *rec=0; + PyObject *obj, *rec=Py_False; if (!PyArg_ParseTuple(args, "O!|O!",&(DocumentObjectPy::Type),&obj,&PyBool_Type,&rec)) return NULL; // NULL triggers exception @@ -311,36 +311,36 @@ PyObject* DocumentPy::findObjects(PyObject *args) char *sType="App::DocumentObject", *sName=0; if (!PyArg_ParseTuple(args, "|ss",&sType, &sName)) // convert args: Python->C return NULL; // NULL triggers exception - - Base::Type type = Base::Type::fromName(sType); - if (type == Base::Type::badType()) { - PyErr_Format(PyExc_Exception, "'%s' is not a valid type", sType); - return NULL; - } - - if (!type.isDerivedFrom(App::DocumentObject::getClassTypeId())) { - PyErr_Format(PyExc_Exception, "Type '%s' does not inherit from 'App::DocumentObject'", sType); - return NULL; - } - - std::vector res; - - if (sName) { - try { - res = getDocumentPtr()->findObjects(type, sName); - } - catch (const boost::regex_error& e) { - PyErr_SetString(PyExc_RuntimeError, e.what()); - return 0; - } - } - else { - res = getDocumentPtr()->getObjectsOfType(type); - } - - Py_ssize_t index=0; - PyObject* list = PyList_New((Py_ssize_t)res.size()); - for (std::vector::const_iterator It = res.begin();It != res.end();++It, index++) + + Base::Type type = Base::Type::fromName(sType); + if (type == Base::Type::badType()) { + PyErr_Format(PyExc_Exception, "'%s' is not a valid type", sType); + return NULL; + } + + if (!type.isDerivedFrom(App::DocumentObject::getClassTypeId())) { + PyErr_Format(PyExc_Exception, "Type '%s' does not inherit from 'App::DocumentObject'", sType); + return NULL; + } + + std::vector res; + + if (sName) { + try { + res = getDocumentPtr()->findObjects(type, sName); + } + catch (const boost::regex_error& e) { + PyErr_SetString(PyExc_RuntimeError, e.what()); + return 0; + } + } + else { + res = getDocumentPtr()->getObjectsOfType(type); + } + + Py_ssize_t index=0; + PyObject* list = PyList_New((Py_ssize_t)res.size()); + for (std::vector::const_iterator It = res.begin();It != res.end();++It, index++) PyList_SetItem(list, index, (*It)->getPyObject()); return list; } diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index d8dabd075..889712108 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -464,7 +464,7 @@ Py::Object View3DInventorPy::viewRotateRight(const Py::Tuple& args) Py::Object View3DInventorPy::setCameraOrientation(const Py::Tuple& args) { PyObject* o; - PyObject* m=0; + PyObject* m=Py_False; if (!PyArg_ParseTuple(args.ptr(), "O!|O!", &PyTuple_Type, &o, &PyBool_Type, &m)) throw Py::Exception(); diff --git a/src/Main/FreeCADGuiPy.cpp b/src/Main/FreeCADGuiPy.cpp index d2040caff..7a19da8f9 100644 --- a/src/Main/FreeCADGuiPy.cpp +++ b/src/Main/FreeCADGuiPy.cpp @@ -82,7 +82,7 @@ FilterProc(int nCode, WPARAM wParam, LPARAM lParam) { static PyObject * FreeCADGui_showMainWindow(PyObject * /*self*/, PyObject *args) { - PyObject* inThread = 0; + PyObject* inThread = Py_False; if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &inThread)) return NULL; diff --git a/src/Mod/Mesh/App/MeshPyImp.cpp b/src/Mod/Mesh/App/MeshPyImp.cpp index dc4d69390..c25c6322b 100644 --- a/src/Mod/Mesh/App/MeshPyImp.cpp +++ b/src/Mod/Mesh/App/MeshPyImp.cpp @@ -127,9 +127,9 @@ PyObject* MeshPy::copy(PyObject *args) { if (!PyArg_ParseTuple(args, "")) return NULL; - + const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel(); - return new MeshPy(new MeshObject(kernel)); + return new MeshPy(new MeshObject(kernel)); } PyObject* MeshPy::read(PyObject *args) @@ -238,7 +238,7 @@ PyObject* MeshPy::offsetSpecial(PyObject *args) PyObject* MeshPy::crossSections(PyObject *args) { PyObject *obj; - PyObject *poly=0; + PyObject *poly=Py_False; float min_eps = 1.0e-2f; if (!PyArg_ParseTuple(args, "O!|fO!", &PyList_Type, &obj, &min_eps, &PyBool_Type, &poly)) return 0; diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index f6ff0c934..f817a47f0 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -1147,8 +1147,8 @@ static PyObject * makeLoft(PyObject *self, PyObject *args) return new BSplineSurfacePy(new GeomBSplineSurface(aRes)); #else PyObject *pcObj; - PyObject *psolid=0; - PyObject *pruled=0; + PyObject *psolid=Py_False; + PyObject *pruled=Py_False; if (!PyArg_ParseTuple(args, "O!|O!O!", &(PyList_Type), &pcObj, &(PyBool_Type), &psolid, &(PyBool_Type), &pruled)) diff --git a/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp b/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp index 5b0caa771..187bec3b4 100644 --- a/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp +++ b/src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp @@ -127,7 +127,7 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setAuxiliarySpine(PyObject *args) PyObject* BRepOffsetAPI_MakePipeShellPy::add(PyObject *args) { - PyObject *prof, *curv=0, *keep=0; + PyObject *prof, *curv=Py_False, *keep=Py_False; if (!PyArg_ParseTuple(args, "O!|O!O!",&Part::TopoShapePy::Type,&prof ,&PyBool_Type,&curv ,&PyBool_Type,&keep)) diff --git a/src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp b/src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp index 40ebc5276..873a29f37 100644 --- a/src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp +++ b/src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp @@ -66,7 +66,7 @@ int RectangularTrimmedSurfacePy::PyInit(PyObject* args, PyObject* /*kwd*/) PyErr_Clear(); double param1,param2; - PyObject *utrim=0, *sense=Py_True; + PyObject *utrim=Py_False, *sense=Py_True; if (PyArg_ParseTuple(args, "O!ddO!|O!",&(Part::GeometrySurfacePy::Type),&surf, ¶m1,¶m2,&PyBool_Type,&utrim,&PyBool_Type,&sense)) { Standard_Boolean UTrim = PyObject_IsTrue(utrim);