[Bf-blender-cvs] [311031ecd03] master: Cleanup: Use nullptr everywhere in fluid code

Sebastián Barschkis noreply at git.blender.org
Fri Nov 6 12:06:21 CET 2020


Commit: 311031ecd03dbfbf43e1df672a395f24b2e7d4d3
Author: Sebastián Barschkis
Date:   Fri Nov 6 11:44:05 2020 +0100
Branches: master
https://developer.blender.org/rB311031ecd03dbfbf43e1df672a395f24b2e7d4d3

Cleanup: Use nullptr everywhere in fluid code

Switched from NULL to nullptr.

===================================================================

M	extern/mantaflow/helper/pwrapper/numpyWrap.cpp
M	extern/mantaflow/helper/pwrapper/pclass.cpp
M	extern/mantaflow/helper/pwrapper/pclass.h
M	extern/mantaflow/helper/pwrapper/pconvert.cpp
M	extern/mantaflow/helper/pwrapper/pconvert.h
M	extern/mantaflow/helper/pwrapper/pvec3.cpp
M	extern/mantaflow/helper/pwrapper/registry.cpp
M	extern/mantaflow/helper/util/randomstream.h
M	extern/mantaflow/helper/util/rcmatrix.h
M	extern/mantaflow/helper/util/simpleimage.cpp
M	extern/mantaflow/helper/util/simpleimage.h
M	extern/mantaflow/preprocessed/conjugategrad.cpp
M	extern/mantaflow/preprocessed/fastmarch.cpp
M	extern/mantaflow/preprocessed/fastmarch.h
M	extern/mantaflow/preprocessed/fileio/iogrids.cpp
M	extern/mantaflow/preprocessed/fileio/ioutil.cpp
M	extern/mantaflow/preprocessed/fileio/mantaio.cpp
M	extern/mantaflow/preprocessed/fileio/mantaio.h
M	extern/mantaflow/preprocessed/fluidsolver.cpp
M	extern/mantaflow/preprocessed/fluidsolver.h
M	extern/mantaflow/preprocessed/gitinfo.h
M	extern/mantaflow/preprocessed/grid.cpp
M	extern/mantaflow/preprocessed/grid.h
M	extern/mantaflow/preprocessed/grid4d.cpp
M	extern/mantaflow/preprocessed/grid4d.h
M	extern/mantaflow/preprocessed/levelset.cpp
M	extern/mantaflow/preprocessed/levelset.h
M	extern/mantaflow/preprocessed/mesh.cpp
M	extern/mantaflow/preprocessed/mesh.h
M	extern/mantaflow/preprocessed/movingobs.h
M	extern/mantaflow/preprocessed/noisefield.cpp
M	extern/mantaflow/preprocessed/noisefield.h
M	extern/mantaflow/preprocessed/particle.cpp
M	extern/mantaflow/preprocessed/particle.h
M	extern/mantaflow/preprocessed/plugin/advection.cpp
M	extern/mantaflow/preprocessed/plugin/apic.cpp
M	extern/mantaflow/preprocessed/plugin/extforces.cpp
M	extern/mantaflow/preprocessed/plugin/fire.cpp
M	extern/mantaflow/preprocessed/plugin/flip.cpp
M	extern/mantaflow/preprocessed/plugin/fluidguiding.cpp
M	extern/mantaflow/preprocessed/plugin/initplugins.cpp
M	extern/mantaflow/preprocessed/plugin/kepsilon.cpp
M	extern/mantaflow/preprocessed/plugin/meshplugins.cpp
M	extern/mantaflow/preprocessed/plugin/pressure.cpp
M	extern/mantaflow/preprocessed/plugin/ptsplugins.cpp
M	extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
M	extern/mantaflow/preprocessed/plugin/surfaceturbulence.cpp
M	extern/mantaflow/preprocessed/plugin/vortexplugins.cpp
M	extern/mantaflow/preprocessed/plugin/waveletturbulence.cpp
M	extern/mantaflow/preprocessed/plugin/waves.cpp
M	extern/mantaflow/preprocessed/shapes.h
M	extern/mantaflow/preprocessed/timing.h
M	extern/mantaflow/preprocessed/turbulencepart.h
M	extern/mantaflow/preprocessed/vortexpart.h
M	extern/mantaflow/preprocessed/vortexsheet.h

===================================================================

diff --git a/extern/mantaflow/helper/pwrapper/numpyWrap.cpp b/extern/mantaflow/helper/pwrapper/numpyWrap.cpp
index d2ddb21be70..0e2ef3f4803 100644
--- a/extern/mantaflow/helper/pwrapper/numpyWrap.cpp
+++ b/extern/mantaflow/helper/pwrapper/numpyWrap.cpp
@@ -94,7 +94,7 @@ void PyArrayContainer::ExtractData(void *_pParentPyArray)
 
 template<> PyArrayContainer fromPy<PyArrayContainer>(PyObject *obj)
 {
-  if (PyArray_API == NULL) {
+  if (PyArray_API == nullptr) {
     // python 3 uses the return value
 #if PY_VERSION_HEX >= 0x03000000
     import_array();
@@ -109,12 +109,12 @@ template<> PyArrayContainer fromPy<PyArrayContainer>(PyObject *obj)
 
   PyArrayObject *obj_p = reinterpret_cast<PyArrayObject *>(
       PyArray_CheckFromAny(obj,
-                           NULL,
+                           nullptr,
                            0,
                            0,
                            /*NPY_ARRAY_ENSURECOPY*/ NPY_ARRAY_C_CONTIGUOUS |
                                NPY_ARRAY_ENSUREARRAY | NPY_ARRAY_NOTSWAPPED,
-                           NULL));
+                           nullptr));
   PyArrayContainer container = PyArrayContainer(obj_p);
 
   return container;
diff --git a/extern/mantaflow/helper/pwrapper/pclass.cpp b/extern/mantaflow/helper/pwrapper/pclass.cpp
index a95254ebe11..ae028b0a330 100644
--- a/extern/mantaflow/helper/pwrapper/pclass.cpp
+++ b/extern/mantaflow/helper/pwrapper/pclass.cpp
@@ -98,13 +98,13 @@ string PbType::str() const
 vector<PbClass *> PbClass::mInstances;
 
 PbClass::PbClass(FluidSolver *parent, const string &name, PyObject *obj)
-    : mMutex(NULL), mParent(parent), mPyObject(obj), mName(name), mHidden(false)
+    : mMutex(nullptr), mParent(parent), mPyObject(obj), mName(name), mHidden(false)
 {
   mMutex = new QMutex();
 }
 
 PbClass::PbClass(const PbClass &a)
-    : mMutex(NULL), mParent(a.mParent), mPyObject(0), mName("_unnamed"), mHidden(false)
+    : mMutex(nullptr), mParent(a.mParent), mPyObject(0), mName("_unnamed"), mHidden(false)
 {
   mMutex = new QMutex();
 }
@@ -180,7 +180,7 @@ PbClass *PbClass::createPyObject(const string &classname,
 
 void PbClass::checkParent()
 {
-  if (getParent() == NULL) {
+  if (getParent() == nullptr) {
     errMsg("New class " + mName + ": no parent given -- specify using parent=xxx !");
   }
 }
diff --git a/extern/mantaflow/helper/pwrapper/pclass.h b/extern/mantaflow/helper/pwrapper/pclass.h
index b34103ca9a7..334ab9fb1ec 100644
--- a/extern/mantaflow/helper/pwrapper/pclass.h
+++ b/extern/mantaflow/helper/pwrapper/pclass.h
@@ -43,7 +43,7 @@ struct PbTypeVec {
 //! Base class for all classes exposed to Python
 class PbClass {
  public:
-  PbClass(FluidSolver *parent, const std::string &name = "", PyObject *obj = NULL);
+  PbClass(FluidSolver *parent, const std::string &name = "", PyObject *obj = nullptr);
   PbClass(const PbClass &a);
   virtual ~PbClass();
 
diff --git a/extern/mantaflow/helper/pwrapper/pconvert.cpp b/extern/mantaflow/helper/pwrapper/pconvert.cpp
index 861a2c070bd..7c66cdc7e72 100644
--- a/extern/mantaflow/helper/pwrapper/pconvert.cpp
+++ b/extern/mantaflow/helper/pwrapper/pconvert.cpp
@@ -491,7 +491,7 @@ template<> bool isPy<std::vector<float>>(PyObject *obj)
 //******************************************************************************
 // PbArgs class defs
 
-PbArgs PbArgs::EMPTY(NULL, NULL);
+PbArgs PbArgs::EMPTY(nullptr, nullptr);
 
 PbArgs::PbArgs(PyObject *linarg, PyObject *dict) : mLinArgs(0), mKwds(0)
 {
@@ -577,7 +577,7 @@ void PbArgs::check()
 
 FluidSolver *PbArgs::obtainParent()
 {
-  FluidSolver *solver = getPtrOpt<FluidSolver>("solver", -1, NULL);
+  FluidSolver *solver = getPtrOpt<FluidSolver>("solver", -1, nullptr);
   if (solver != 0)
     return solver;
 
@@ -585,7 +585,7 @@ FluidSolver *PbArgs::obtainParent()
     PbClass *obj = Pb::objFromPy(it->second.obj);
 
     if (obj) {
-      if (solver == NULL)
+      if (solver == nullptr)
         solver = obj->getParent();
     }
   }
@@ -593,7 +593,7 @@ FluidSolver *PbArgs::obtainParent()
     PbClass *obj = Pb::objFromPy(it->obj);
 
     if (obj) {
-      if (solver == NULL)
+      if (solver == nullptr)
         solver = obj->getParent();
     }
   }
@@ -616,7 +616,7 @@ PyObject *PbArgs::getItem(const std::string &key, bool strict, ArgLocker *lk)
   if (lu == mData.end()) {
     if (strict)
       errMsg("Argument '" + key + "' is not defined.");
-    return NULL;
+    return nullptr;
   }
   PbClass *pbo = Pb::objFromPy(lu->second.obj);
   // try to lock
@@ -629,7 +629,7 @@ PyObject *PbArgs::getItem(size_t number, bool strict, ArgLocker *lk)
 {
   if (number >= mLinData.size()) {
     if (!strict)
-      return NULL;
+      return nullptr;
     stringstream s;
     s << "Argument number #" << number << " not specified.";
     errMsg(s.str());
diff --git a/extern/mantaflow/helper/pwrapper/pconvert.h b/extern/mantaflow/helper/pwrapper/pconvert.h
index 87f4248f6f1..eda2f5b9632 100644
--- a/extern/mantaflow/helper/pwrapper/pconvert.h
+++ b/extern/mantaflow/helper/pwrapper/pconvert.h
@@ -139,9 +139,9 @@ template<> bool isPy<std::vector<float>>(PyObject *obj);
 //! Encapsulation of python arguments
 class PbArgs {
  public:
-  PbArgs(PyObject *linargs = NULL, PyObject *dict = NULL);
+  PbArgs(PyObject *linargs = nullptr, PyObject *dict = nullptr);
   ~PbArgs();
-  void setup(PyObject *linargs = NULL, PyObject *dict = NULL);
+  void setup(PyObject *linargs = nullptr, PyObject *dict = nullptr);
 
   void check();
   FluidSolver *obtainParent();
@@ -153,7 +153,7 @@ class PbArgs {
 
   inline bool has(const std::string &key)
   {
-    return getItem(key, false) != NULL;
+    return getItem(key, false) != nullptr;
   }
   inline void deleteItem(const std::string &key)
   {
@@ -177,7 +177,7 @@ class PbArgs {
     DataElement el = {toPy(arg), false};
     mData[key] = el;
   }
-  template<class T> inline T get(const std::string &key, int number = -1, ArgLocker *lk = NULL)
+  template<class T> inline T get(const std::string &key, int number = -1, ArgLocker *lk = nullptr)
   {
     visit(number, key);
     PyObject *o = getItem(key, false, lk);
@@ -189,7 +189,7 @@ class PbArgs {
     errMsg("Argument '" + key + "' is not defined.");
   }
   template<class T>
-  inline T getOpt(const std::string &key, int number, T defarg, ArgLocker *lk = NULL)
+  inline T getOpt(const std::string &key, int number, T defarg, ArgLocker *lk = nullptr)
   {
     visit(number, key);
     PyObject *o = getItem(key, false, lk);
@@ -200,7 +200,7 @@ class PbArgs {
     return (o) ? fromPy<T>(o) : defarg;
   }
   template<class T>
-  inline T *getPtrOpt(const std::string &key, int number, T *defarg, ArgLocker *lk = NULL)
+  inline T *getPtrOpt(const std::string &key, int number, T *defarg, ArgLocker *lk = nullptr)
   {
     visit(number, key);
     PyObject *o = getItem(key, false, lk);
@@ -210,7 +210,8 @@ class PbArgs {
       o = getItem(number, false, lk);
     return o ? fromPyPtr<T>(o, &mTmpStorage) : defarg;
   }
-  template<class T> inline T *getPtr(const std::string &key, int number = -1, ArgLocker *lk = NULL)
+  template<class T>
+  inline T *getPtr(const std::string &key, int number = -1, ArgLocker *lk = nullptr)
   {
     visit(number, key);
     PyObject *o = getItem(key, false, lk);
@@ -239,8 +240,8 @@ class PbArgs {
   static PbArgs EMPTY;
 
  protected:
-  PyObject *getItem(const std::string &key, bool strict, ArgLocker *lk = NULL);
-  PyObject *getItem(size_t number, bool strict, ArgLocker *lk = NULL);
+  PyObject *getItem(const std::string &key, bool strict, ArgLocker *lk = nullptr);
+  PyObject *getItem(size_t number, bool strict, ArgLocker *lk = nullptr);
 
   struct DataElement {
     PyObject *obj;
diff --git a/extern/mantaflow/helper/pwrapper/pvec3.cpp b/extern/mantaflow/helper/pwrapper/pvec3.cpp
index 69bde2a2ad0..1dca44d5e5c 100644
--- a/extern/mantaflow/helper/pwrapper/pvec3.cpp
+++ b/extern/mantaflow/helper/pwrapper/pvec3.cpp
@@ -77,13 +77,13 @@ static PyMemberDef PbVec3Members[] = {
     {(char *)"x", T_FLOAT, offsetof(PbVec3, data), 0, (char *)"X"},
     {(char *)"y", T_FLOAT, offsetof(PbVec3, data) + sizeof(float), 0, (char *)"Y"},
     {(char *)"z", T_FLOAT, offsetof(PbVec3, data) + sizeof(float) * 2, 0, (char *)"Z"},
-    {NULL}  // Sentinel
+    {nullptr}  // Sentinel
 };
 
 static PyMethodDef PbVec3Methods[] = {
     //{"name", (PyCFunction)Noddy_name, METH_NOARGS, "Return the name, combining the first and last
     //name" },
-    {NULL}  // Sentinel
+    {nullptr}  // Sentinel
 };
 
 // operator overloads
@@ -240,24 +240,24 @@ static PyNumberMethods PbVec3NumberMethods = {
 #endif
 
 PyTypeObject PbVec3Type = {
-    PyVarObject_HEAD_INIT(NULL, 0) "manta.vec3", /* tp_name */
-    sizeof(PbVec3),                              /* tp_basicsize */
-    0,                                           /* tp_itemsize */
-    (destructor)PbVec3Dealloc,                   /* tp_dealloc */
-    0,                                           /* tp_print */
-    0,                                           /* tp_getattr */
-    0,                                           /* tp_setattr */
-    0,                                           /* tp_reserved */
-    (reprfunc)PbVec3Repr,                        /* tp_repr */
-    &PbVec3NumberMethods,                        /* tp_as_number */
-    0,                                           /* tp_as_sequence */
-    0,                                           /* tp_as_mapping */
-    0,                                           /* tp_hash  */
-    0,                                           /* tp_call */
-    0,                                           /* tp_str */
-    0,                                           /* tp_getattro */
-    0,                                           /* tp_setattro */
-    0,                                           /* tp_as_buffer */
+    PyVarObject_HEAD_INIT(nullptr, 0) "manta.vec3", /* tp_name */
+    sizeof(PbVec3),                                 /* tp_basicsize */
+    0,                                              /* tp_itemsize */
+    (destructor)PbVec3Dealloc,                      /* tp_dealloc */
+    0,                                              /* tp_print */
+    0,                                           

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list