Mercurial > pytave
comparison oct-py-eval.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 | aef165ff92b0 |
children | 9bf8ba050122 |
comparison
equal
deleted
inserted
replaced
410:95c6ad0be828 | 411:3613ffbd52b2 |
---|---|
30 #include <octave/ovl.h> | 30 #include <octave/ovl.h> |
31 | 31 |
32 #include "oct-py-eval.h" | 32 #include "oct-py-eval.h" |
33 #include "oct-py-object.h" | 33 #include "oct-py-object.h" |
34 #include "oct-py-util.h" | 34 #include "oct-py-util.h" |
35 #include "octave_to_python.h" | 35 #include "oct-py-types.h" |
36 | 36 |
37 namespace pytave | 37 namespace pytave |
38 { | 38 { |
39 | 39 |
40 PyObject * | 40 PyObject * |
61 if (! args_list) | 61 if (! args_list) |
62 octave_throw_bad_alloc (); | 62 octave_throw_bad_alloc (); |
63 | 63 |
64 for (int i = 0; i < args.length (); ++i) | 64 for (int i = 0; i < args.length (); ++i) |
65 { | 65 { |
66 boost::python::object arg; | 66 python_object obj = py_implicitly_convert_argument (args(i)); |
67 pytave::octvalue_to_pyobj (arg, args(i)); | |
68 PyObject *obj = arg.ptr (); | |
69 | 67 |
70 if (pytave::is_py_kwargs_argument (obj)) | 68 if (pytave::is_py_kwargs_argument (obj)) |
71 kwargs = pytave::update_py_dict (kwargs, obj); | 69 kwargs = pytave::update_py_dict (kwargs, obj); |
72 else | 70 else |
73 { | 71 PyList_Append (args_list, obj.release ()); |
74 Py_INCREF (obj); | |
75 PyList_Append (args_list, obj); | |
76 } | |
77 } | 72 } |
78 | 73 |
79 python_object args_tuple = PyList_AsTuple (args_list); | 74 python_object args_tuple = PyList_AsTuple (args_list); |
80 | 75 |
81 python_object retval = py_call_function (callable, args_tuple, kwargs); | 76 python_object retval = py_call_function (callable, args_tuple, kwargs); |