Mercurial > pytave
diff oct-py-types.h @ 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 | c4b78e449c62 |
children |
line wrap: on
line diff
--- a/oct-py-types.h Tue May 02 17:40:01 2017 -0700 +++ b/oct-py-types.h Wed May 03 16:30:45 2017 -0700 @@ -217,6 +217,52 @@ PyObject * make_py_str (const std::string& str); + //! Perform an implicit conversion of the given Octave @c value to a Python + //! argument. + //! + //! The following implicit type conversions are implemented by this function: + //! + //! @arg @c bool from Octave logical scalar, + //! @arg @c complex from Octave double or single precision complex scalar, + //! @arg @c float from Octave double or single precision scalar, + //! @arg @c int from any Octave integer-valued scalar, + //! @arg @c long from Octave @c uint32, @c int64, or @c uint64, and only if + //! running against Python 2, + //! @arg @c str from Octave string (@c char row vector), + //! @arg @c array.array from Octave numeric column or row vector, + //! @arg @c dict from Octave scalar map (consisting entirely of implicitly + //! convertible elements), + //! @arg @c tuple from Octave cell array (consisting entirely of implicitly + //! convertible elements). + //! + //! If @c value refers to a previously created Python object, then a reference + //! to the existing object is returned. + //! + //! Otherwise, a conversion error is raised. + //! + //! @param value Octave value + //! @return Python object + PyObject * + py_implicitly_convert_argument (const octave_value& value); + + //! Perform an implicit conversion of the given Python object to an Octave + //! return value. + //! + //! The following implicit type conversions are implemented by this function: + //! + //! @arg @c logical scalar from Python @c bool, + //! @arg @c complex @c double from Python @c complex, + //! @arg @c double from Python @c float, + //! @arg @c int64 from Python @c int, only if running against Python 2. + //! + //! Otherwise, @c obj is left unconverted, a reference is maintained to it, + //! and an Octave value containing that reference is returned. + //! + //! @param obj Python object + //! @return Octave value + octave_value + py_implicitly_convert_return_value (PyObject *obj); + } #endif