From 882e34f2cee32995fddfd4f3780d3e5e8d2aff38 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 23 Mar 2022 16:57:25 +0100 Subject: [PATCH] Base: modernize C++11 * use nullptr --- src/Base/Interpreter.cpp | 2 +- src/Base/Interpreter.h | 4 ++-- src/Base/Parameter.cpp | 4 ++-- src/Base/PlacementPyImp.cpp | 4 ++-- src/Base/PyObjectBase.cpp | 4 ++-- src/Base/QuantityPyImp.cpp | 8 ++++---- src/Base/Rotation.cpp | 2 +- src/Base/RotationPyImp.cpp | 4 ++-- src/Base/TimeInfo.cpp | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 3de634ce05..3721150a9f 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -80,7 +80,7 @@ PyException::PyException() // destroyed, so we don't keep reference here to save book-keeping in // our copy constructor and destructor Py_DECREF(PP_last_exception_type); - PP_last_exception_type = 0; + PP_last_exception_type = nullptr; } diff --git a/src/Base/Interpreter.h b/src/Base/Interpreter.h index 472b74602e..c9ce6274c6 100644 --- a/src/Base/Interpreter.h +++ b/src/Base/Interpreter.h @@ -116,14 +116,14 @@ protected: PyObject *_exceptionType; }; -inline Py::Object pyCall(PyObject *callable, PyObject *args=0) { +inline Py::Object pyCall(PyObject *callable, PyObject *args=nullptr) { PyObject *result = PyObject_CallObject(callable, args); if(!result) throw Py::Exception(); return Py::asObject(result); } -inline Py::Object pyCallWithKeywords(PyObject *callable, PyObject *args, PyObject *kwds=0) { +inline Py::Object pyCallWithKeywords(PyObject *callable, PyObject *args, PyObject *kwds=nullptr) { PyObject *result = PyObject_Call(callable, args, kwds); if(!result) throw Py::Exception(); diff --git a/src/Base/Parameter.cpp b/src/Base/Parameter.cpp index 87f885d3f8..b1d5814bb0 100644 --- a/src/Base/Parameter.cpp +++ b/src/Base/Parameter.cpp @@ -595,7 +595,7 @@ std::vector > ParameterGrp::GetUnsignedMap( while ( pcTemp ) { Name = StrX(static_cast(pcTemp)->getAttributes()->getNamedItem(XStr("Name").unicodeForm())->getNodeValue()).c_str(); // check on filter condition - if (sFilter == NULL || Name.find(sFilter)!= std::string::npos) { + if (sFilter == nullptr || Name.find(sFilter)!= std::string::npos) { vrValues.emplace_back(Name, ( strtoul (StrX(static_cast(pcTemp)->getAttribute(XStr("Value").unicodeForm())).c_str(),nullptr,10) )); } @@ -940,7 +940,7 @@ void ParameterGrp::Clear(void) } // searching all non-group nodes - for (DOMNode *child = _pGroupNode->getFirstChild(); child != 0; child = child->getNextSibling()) { + for (DOMNode *child = _pGroupNode->getFirstChild(); child != nullptr; child = child->getNextSibling()) { if (XMLString::compareString(child->getNodeName(), XStr("FCParamGroup").unicodeForm()) != 0) vecNodes.push_back(child); } diff --git a/src/Base/PlacementPyImp.cpp b/src/Base/PlacementPyImp.cpp index 3aaf319445..781267fb73 100644 --- a/src/Base/PlacementPyImp.cpp +++ b/src/Base/PlacementPyImp.cpp @@ -167,7 +167,7 @@ PyObject* PlacementPy::rotate(PyObject *args) { PyObject *obj1, *obj2; double angle; if (!PyArg_ParseTuple(args, "OOd", &obj1, &obj2, &angle)) - return NULL; + return nullptr; try { Py::Sequence p1(obj1), p2(obj2); @@ -182,7 +182,7 @@ PyObject* PlacementPy::rotate(PyObject *args) { Py_Return; } catch (const Py::Exception&) { - return NULL; + return nullptr; } } diff --git a/src/Base/PyObjectBase.cpp b/src/Base/PyObjectBase.cpp index 465c419b81..773a61b259 100644 --- a/src/Base/PyObjectBase.cpp +++ b/src/Base/PyObjectBase.cpp @@ -103,13 +103,13 @@ static void PyBaseProxy_dealloc(PyObject* self) { /* Clear weakrefs first before calling any destructors */ - if (reinterpret_cast(self)->weakreflist != NULL) + if (reinterpret_cast(self)->weakreflist != nullptr) PyObject_ClearWeakRefs(self); Py_TYPE(self)->tp_free(self); } static PyTypeObject PyBaseProxyType = { - PyVarObject_HEAD_INIT(NULL, 0) + PyVarObject_HEAD_INIT(nullptr, 0) "PyBaseProxy", /*tp_name*/ sizeof(PyBaseProxy), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/src/Base/QuantityPyImp.cpp b/src/Base/QuantityPyImp.cpp index 43d09240a5..a9637bbc2e 100644 --- a/src/Base/QuantityPyImp.cpp +++ b/src/Base/QuantityPyImp.cpp @@ -345,7 +345,7 @@ static Quantity &pyToQuantity(Quantity &q, PyObject *pyobj) { PyObject* QuantityPy::number_add_handler(PyObject *self, PyObject *other) { - Quantity *pa=0, *pb=0; + Quantity *pa=nullptr, *pb=nullptr; Quantity a,b; PY_TRY { if (PyObject_TypeCheck(self, &(QuantityPy::Type))) @@ -363,7 +363,7 @@ PyObject* QuantityPy::number_add_handler(PyObject *self, PyObject *other) PyObject* QuantityPy::number_subtract_handler(PyObject *self, PyObject *other) { - Quantity *pa=0, *pb=0; + Quantity *pa=nullptr, *pb=nullptr; Quantity a,b; PY_TRY { if (PyObject_TypeCheck(self, &(QuantityPy::Type))) @@ -381,7 +381,7 @@ PyObject* QuantityPy::number_subtract_handler(PyObject *self, PyObject *other) PyObject* QuantityPy::number_multiply_handler(PyObject *self, PyObject *other) { - Quantity *pa=0, *pb=0; + Quantity *pa=nullptr, *pb=nullptr; Quantity a,b; PY_TRY { if (PyObject_TypeCheck(self, &(QuantityPy::Type))) @@ -399,7 +399,7 @@ PyObject* QuantityPy::number_multiply_handler(PyObject *self, PyObject *other) PyObject * QuantityPy::number_divide_handler (PyObject *self, PyObject *other) { - Quantity *pa=0, *pb=0; + Quantity *pa=nullptr, *pb=nullptr; Quantity a,b; PY_TRY { if (PyObject_TypeCheck(self, &(QuantityPy::Type))) diff --git a/src/Base/Rotation.cpp b/src/Base/Rotation.cpp index 2edd5bd5f1..84d08aa33e 100644 --- a/src/Base/Rotation.cpp +++ b/src/Base/Rotation.cpp @@ -849,7 +849,7 @@ const char *EulerSequenceNames[] = { const char * Rotation::eulerSequenceName(EulerSequence seq) { if (seq == Invalid || seq >= EulerSequenceLast) - return 0; + return nullptr; return EulerSequenceNames[seq-1]; } diff --git a/src/Base/RotationPyImp.cpp b/src/Base/RotationPyImp.cpp index 85da6fcab7..5200d2ef56 100644 --- a/src/Base/RotationPyImp.cpp +++ b/src/Base/RotationPyImp.cpp @@ -280,7 +280,7 @@ PyObject* RotationPy::slerp(PyObject * args) PyObject *rot; double t; if (!PyArg_ParseTuple(args, "O!d", &(RotationPy::Type), &rot, &t)) - return 0; + return nullptr; Rotation *rot0 = this->getRotationPtr(); Rotation *rot1 = static_cast(rot)->getRotationPtr(); Rotation sl = Rotation::slerp(*rot0, *rot1, t); @@ -357,7 +357,7 @@ PyObject* RotationPy::toEulerAngles(PyObject * args) PyObject* RotationPy::toMatrix(PyObject * args) { if (!PyArg_ParseTuple(args, "")) - return NULL; + return nullptr; Base::Matrix4D mat; getRotationPtr()->getValue(mat); return new MatrixPy(new Matrix4D(mat)); diff --git a/src/Base/TimeInfo.cpp b/src/Base/TimeInfo.cpp index 4782c81e83..033625bd36 100644 --- a/src/Base/TimeInfo.cpp +++ b/src/Base/TimeInfo.cpp @@ -62,7 +62,7 @@ void TimeInfo::setCurrent() { #if defined (FC_OS_BSD) || defined(FC_OS_LINUX) || defined(__MINGW32__) struct timeval t; - gettimeofday(&t, NULL); + gettimeofday(&t, nullptr); timebuffer.time = t.tv_sec; timebuffer.millitm = t.tv_usec / 1000; #elif defined(FC_OS_WIN32)