Mercurial > pytave
diff pyeval.cc @ 411:3613ffbd52b2
Overhaul implicit conversion of arguments and return values
* oct-py-types.cc, oct-py-types.h (pytave::py_implicitly_convert_argument,
pytave::py_implicitly_convert_return_value): New functions.
* __py_struct_from_dict__.cc, oct-py-eval.cc, pycall.cc, pyeval.cc, pyexec.cc:
Use them instead of legacy conversion functions. Add necessary #includes,
remove #includes of legacy header files.
* @pyobject/subsasgn.m, @pyobject/subsref.m: Change %!tests that depend on
NumPy implicit conversion into %!xtests.
* octave_to_python.cc, octave_to_python.h, python_to_octave.cc,
python_to_octave.h: Delete, no longer used.
* Makefile.am (COMMON_SOURCE_FILES, PYTAVE_HEADER_FILES): Remove the files.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Wed, 03 May 2017 16:30:45 -0700 |
parents | 95c6ad0be828 |
children | 9bf8ba050122 |
line wrap: on
line diff
--- a/pyeval.cc Tue May 02 17:40:01 2017 -0700 +++ b/pyeval.cc Wed May 03 16:30:45 2017 -0700 @@ -33,8 +33,9 @@ #include "exceptions.h" #include "oct-py-eval.h" #include "oct-py-init.h" +#include "oct-py-object.h" +#include "oct-py-types.h" #include "oct-py-util.h" -#include "python_to_octave.h" DEFUN_DLD (pyeval, args, nargout, "-*- texinfo -*-\n\ @@ -85,15 +86,10 @@ try { - PyObject *obj = pytave::py_eval_string (code, 0, local_namespace); - boost::python::object res { boost::python::handle<> (obj) }; + pytave::python_object res = pytave::py_eval_string (code, 0, local_namespace); if (nargout > 0 || ! res.is_none ()) - { - octave_value val; - pytave::pyobj_to_octvalue (val, res); - retval(0) = val; - } + retval(0) = pytave::py_implicitly_convert_return_value (res); } catch (pytave::object_convert_exception const &) {