Mercurial > pytave
changeset 406:16e79a1e96b8
Eliminate all remaining uses of "using namespace"
* octave_to_python.cc, pycall.cc, pyeval.cc, pyexec.cc, python_to_octave.cc:
Eliminate all remaining uses of "using namespace", use fully qualified class
and function names from Boost.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Mon, 01 May 2017 08:41:01 -0700 |
parents | 478d83448b0b |
children | 78448e4de20a |
files | octave_to_python.cc pycall.cc pyeval.cc pyexec.cc python_to_octave.cc |
diffstat | 5 files changed, 14 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/octave_to_python.cc Sat Apr 29 15:43:42 2017 -0700 +++ b/octave_to_python.cc Mon May 01 08:41:01 2017 -0700 @@ -40,8 +40,6 @@ #include "oct-py-types.h" #include "oct-py-util.h" -using namespace boost::python; - namespace pytave { @@ -155,7 +153,8 @@ const octave_value& octvalue) { PyArrayObject *pyarr = octvalue_to_pyarrobj (octvalue); - py_object = object (handle<PyObject> ((PyObject *)pyarr)); + py_object = boost::python::object + { boost::python::handle<> ((PyObject *)pyarr) }; } void octvalue_to_pyobj (boost::python::object& py_object, @@ -170,23 +169,23 @@ else if (octvalue.is_string ()) { PyObject *obj = make_py_str (octvalue.string_value ()); - py_object = object (handle<PyObject> (obj)); + py_object = boost::python::object { boost::python::handle<> (obj) }; } else if (octvalue.is_scalar_type ()) { PyObject *obj = make_py_numeric_value (octvalue); - py_object = object (handle<PyObject> (obj)); + py_object = boost::python::object { boost::python::handle<> (obj) }; } else if (octvalue.is_cell ()) { PyObject *obj = make_py_tuple (octvalue.cell_value ()); - py_object = object (handle<PyObject> (obj)); + py_object = boost::python::object { boost::python::handle<> (obj) }; } else if (octvalue.is_numeric_type () && octvalue.ndims () == 2 && (octvalue.columns () <= 1 || octvalue.rows () <= 1)) { PyObject *obj = make_py_array (octvalue); - py_object = object (handle<PyObject> (obj)); + py_object = boost::python::object { boost::python::handle<> (obj) }; } else if (octvalue.is_numeric_type () || octvalue.is_string () || octvalue.is_bool_type ()) @@ -194,12 +193,12 @@ else if (octvalue.is_map () && octvalue.numel () == 1) { PyObject *obj = make_py_dict (octvalue.scalar_map_value ()); - py_object = object (handle<PyObject> (obj)); + py_object = boost::python::object { boost::python::handle<> (obj) }; } else if (octvalue.is_object () && octvalue.class_name () == "pyobject") { PyObject *obj = pyobject_unwrap_object (octvalue); - py_object = object (handle<PyObject> (obj)); + py_object = boost::python::object { boost::python::handle<> (obj) }; } else throw value_convert_exception (
--- a/pycall.cc Sat Apr 29 15:43:42 2017 -0700 +++ b/pycall.cc Mon May 01 08:41:01 2017 -0700 @@ -38,8 +38,6 @@ #include "octave_to_python.h" #include "python_to_octave.h" -using namespace boost::python; - DEFUN_DLD (pycall, args, nargout, "-*- texinfo -*-\n\ @deftypefn {} {} pycall (@var{func})\n\ @@ -114,7 +112,7 @@ octave_value_list arglist = args.slice (1, nargin - 1); PyObject *result = pytave::py_call_function (callable, arglist); - object res = object (handle<PyObject> (result)); + boost::python::object res { boost::python::handle<> (result) }; // Ensure reasonable "ans" behaviour, consistent with Python's "_". if (nargout > 0 || ! res.is_none ()) @@ -132,7 +130,7 @@ { error ("pycall: error in argument type conversion"); } - catch (error_already_set const &) + catch (boost::python::error_already_set const &) { std::string message = pytave::fetch_exception_message (); error ("pycall: %s", message.c_str ());
--- a/pyeval.cc Sat Apr 29 15:43:42 2017 -0700 +++ b/pyeval.cc Mon May 01 08:41:01 2017 -0700 @@ -37,8 +37,6 @@ #include "oct-py-util.h" #include "python_to_octave.h" -using namespace boost::python; - DEFUN_DLD (pyeval, args, nargout, "-*- texinfo -*-\n\ @deftypefn {} {} pyeval (@var{expr})\n\ @@ -102,7 +100,7 @@ { error ("pyexec: error in return value type conversion"); } - catch (error_already_set const &) + catch (boost::python::error_already_set const &) { std::string message = pytave::fetch_exception_message (); error ("pyeval: %s", message.c_str ());
--- a/pyexec.cc Sat Apr 29 15:43:42 2017 -0700 +++ b/pyexec.cc Mon May 01 08:41:01 2017 -0700 @@ -36,8 +36,6 @@ #include "oct-py-util.h" #include "python_to_octave.h" -using namespace boost::python; - DEFUN_DLD (pyexec, args, nargout, "-*- texinfo -*-\n\ @deftypefn {} {} pyexec (@var{expr})\n\ @@ -90,7 +88,7 @@ { error ("pyexec: error in return value type conversion"); } - catch (error_already_set const &) + catch (boost::python::error_already_set const &) { std::string message = pytave::fetch_exception_message (); error ("pyexec: %s", message.c_str ());
--- a/python_to_octave.cc Sat Apr 29 15:43:42 2017 -0700 +++ b/python_to_octave.cc Mon May 01 08:41:01 2017 -0700 @@ -44,8 +44,6 @@ #include "oct-py-util.h" #include "python_to_octave.h" -using namespace boost::python; - namespace pytave { template <class PythonPrimitive, class OctaveBase> @@ -295,7 +293,7 @@ // Create a new view of the NumPy array. PyArrayObject *view = (PyArrayObject *)PyArray_View (pyarr, view_descr, 0); // Store in a handle to ensure proper destruction. - handle<PyObject> view_handle (allow_null ((PyObject *)view)); + boost::python::handle<> view_handle (boost::python::allow_null ((PyObject *)view)); // Call recursively. pyarr_to_octvalue (octvalue, view); } @@ -313,7 +311,7 @@ void pyobj_to_octvalue (octave_value& oct_value, const boost::python::object& py_object) { - extract<numeric::array> arrayx (py_object); + boost::python::extract<boost::python::numeric::array> arrayx (py_object); if (PyBool_Check (py_object.ptr ())) oct_value = extract_py_bool (py_object.ptr ());