changeset 403:3644df6564bc

maint: use C++11 nullptr rather than 0 or NULL * __py_struct_from_dict__.cc, oct-py-eval.cc, oct-py-eval.h, oct-py-object.h, oct-py-types.cc, oct-py-util.cc, pycall.cc, pyeval.cc, pyexec.cc: Use C++11 nullptr rather than 0 or NULL.
author Mike Miller <mtmiller@octave.org>
date Fri, 28 Apr 2017 14:19:49 -0700
parents c4b78e449c62
children aef165ff92b0
files __py_struct_from_dict__.cc oct-py-eval.cc oct-py-eval.h oct-py-object.h oct-py-types.cc oct-py-util.cc pycall.cc pyeval.cc pyexec.cc
diffstat 9 files changed, 20 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/__py_struct_from_dict__.cc	Fri Apr 28 14:07:57 2017 -0700
+++ b/__py_struct_from_dict__.cc	Fri Apr 28 14:19:49 2017 -0700
@@ -323,7 +323,7 @@
   boost::python::numeric::array::set_module_and_type ("numpy", "ndarray");
   _import_array ();
   // FIXME: PyObject *obj = convert argument to Python (args(0));
-  PyObject *obj = 0;
+  PyObject *obj = nullptr;
   try
     {
       boost::python::object arg;
@@ -368,7 +368,7 @@
 
   if (PyBytes_Check (obj) || PyUnicode_Check (obj))
     str = pytave::extract_py_str (obj);
-  else if (Py_TYPE (obj)->tp_str != NULL)
+  else if (Py_TYPE (obj)->tp_str != nullptr)
     {
       PyObject *s = PyObject_Str (obj);
       str = pytave::extract_py_str (s);
--- a/oct-py-eval.cc	Fri Apr 28 14:07:57 2017 -0700
+++ b/oct-py-eval.cc	Fri Apr 28 14:19:49 2017 -0700
@@ -57,7 +57,7 @@
   PyObject *
   py_call_function (PyObject *callable, const octave_value_list& args)
   {
-    PyObject *kwargs = 0;
+    PyObject *kwargs = nullptr;
     PyObject *args_list = PyList_New (0);
     if (! args_list)
       octave_throw_bad_alloc ();
--- a/oct-py-eval.h	Fri Apr 28 14:07:57 2017 -0700
+++ b/oct-py-eval.h	Fri Apr 28 14:19:49 2017 -0700
@@ -56,7 +56,7 @@
   //! @return return value of @a func
   PyObject *
   py_call_function (const std::string& func, PyObject *args,
-                    PyObject *kwargs = 0);
+                    PyObject *kwargs = nullptr);
 
   //! Call a Python function with the given argument list.
   //!
@@ -76,15 +76,16 @@
   //! @param kwargs dictionary of keyword arguments
   //! @return return value of @a func
   PyObject *
-  py_call_function (PyObject *callable, PyObject *args, PyObject *kwargs = 0);
+  py_call_function (PyObject *callable, PyObject *args,
+                    PyObject *kwargs = nullptr);
 
   PyObject *
-  py_eval_string (const std::string& expr, PyObject *globals = 0,
-                  PyObject *locals = 0);
+  py_eval_string (const std::string& expr, PyObject *globals = nullptr,
+                  PyObject *locals = nullptr);
 
   PyObject *
-  py_exec_string (const std::string& expr, PyObject *globals = 0,
-                  PyObject *locals = 0);
+  py_exec_string (const std::string& expr, PyObject *globals = nullptr,
+                  PyObject *locals = nullptr);
 
 }
 
--- a/oct-py-object.h	Fri Apr 28 14:07:57 2017 -0700
+++ b/oct-py-object.h	Fri Apr 28 14:19:49 2017 -0700
@@ -31,10 +31,10 @@
   class python_object
   {
   public:
-    python_object (PyObject *obj = 0)
+    python_object (PyObject *obj = nullptr)
     {
       pyobj = obj;
-      isowned = pyobj != 0;
+      isowned = pyobj != nullptr;
     }
 
     python_object (const python_object& oth)
@@ -69,7 +69,7 @@
       if (isowned)
         Py_DECREF (pyobj);
       pyobj = obj;
-      isowned = pyobj != 0;
+      isowned = pyobj != nullptr;
       if (isowned)
         Py_INCREF (pyobj);
       return *this;
@@ -96,7 +96,7 @@
     {
       isowned = false;
       PyObject *ret = pyobj;
-      pyobj = 0;
+      pyobj = nullptr;
       return ret;
     }
 
--- a/oct-py-types.cc	Fri Apr 28 14:07:57 2017 -0700
+++ b/oct-py-types.cc	Fri Apr 28 14:19:49 2017 -0700
@@ -344,8 +344,8 @@
     octave_scalar_map map;
 
     Py_ssize_t pos = 0;
-    PyObject *py_key = 0;
-    PyObject *py_value = 0;
+    PyObject *py_key = nullptr;
+    PyObject *py_value = nullptr;
 
     while (PyDict_Next (obj, &pos, &py_key, &py_value))
       {
--- a/oct-py-util.cc	Fri Apr 28 14:07:57 2017 -0700
+++ b/oct-py-util.cc	Fri Apr 28 14:19:49 2017 -0700
@@ -151,7 +151,7 @@
   }
 
   // FIXME: could make this into a class/singleton wrapper a la Octave core
-  PyObject *objstore = 0;
+  PyObject *objstore = nullptr;
 
   inline PyObject *
   py_objstore ()
--- a/pycall.cc	Fri Apr 28 14:07:57 2017 -0700
+++ b/pycall.cc	Fri Apr 28 14:19:49 2017 -0700
@@ -100,7 +100,7 @@
 
   try
     {
-      PyObject *callable = 0;
+      PyObject *callable = nullptr;
       if (args(0).is_string ())
         {
           callable = pytave::py_find_function (args(0).string_value ());
--- a/pyeval.cc	Fri Apr 28 14:07:57 2017 -0700
+++ b/pyeval.cc	Fri Apr 28 14:19:49 2017 -0700
@@ -79,7 +79,7 @@
 
   Py_Initialize ();
 
-  PyObject *local_namespace = 0;
+  PyObject *local_namespace = nullptr;
   if (nargin > 1)
     {
       local_namespace = pytave::pyobject_unwrap_object (args(1));
--- a/pyexec.cc	Fri Apr 28 14:07:57 2017 -0700
+++ b/pyexec.cc	Fri Apr 28 14:19:49 2017 -0700
@@ -73,7 +73,7 @@
 
   Py_Initialize ();
 
-  PyObject *local_namespace = 0;
+  PyObject *local_namespace = nullptr;
   if (nargin > 1)
     {
       local_namespace = pytave::pyobject_unwrap_object (args(1));