Mercurial > pytave
diff __py_struct_from_dict__.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 | b9b8790d1082 |
children | 9bf8ba050122 |
line wrap: on
line diff
--- a/__py_struct_from_dict__.cc Tue May 02 17:40:01 2017 -0700 +++ b/__py_struct_from_dict__.cc Wed May 03 16:30:45 2017 -0700 @@ -32,7 +32,9 @@ #include "oct-py-object.h" #include "oct-py-types.h" #include "oct-py-util.h" -#include "octave_to_python.h" + +// FIXME: only here for exception types still used in this file +#include <boost/python/errors.hpp> DEFUN_DLD (__py_class_name__, args, , "-*- texinfo -*-\n\ @@ -299,24 +301,12 @@ pytave::py_init (); - // FIXME: PyObject *obj = convert argument to Python (args(0)); - PyObject *obj = nullptr; - try - { - boost::python::object arg; - pytave::octvalue_to_pyobj (arg, args(0)); - obj = arg.ptr (); - Py_INCREF (obj); - } - catch (pytave::value_convert_exception const &) - { - } + pytave::python_object obj = pytave::py_implicitly_convert_argument (args(0)); if (! obj) error ("__py_objstore_put__: VALUE must be convertible to a Python value"); - uint64_t key = pytave::py_objstore_put (obj); - Py_DECREF (obj); + uint64_t key = pytave::py_objstore_put (obj.release ()); return ovl (octave_uint64 (key)); }