diff oct-py-types.h @ 340:06b8aeea456f

Add functions to conversion API to extract bool, double, and complex values * oct-py-types.cc, oct-py-types.h (pytave::extract_py_bool, pytave::extract_py_complex, pytave::extract_py_float): New functions to extract numeric values from Python numeric types. * python_to_octave.cc (pytave::pyobj_to_octvalue): Use them.
author Mike Miller <mtmiller@octave.org>
date Mon, 15 Aug 2016 21:52:50 -0700
parents 832ee1f14862
children 6bd8f5e3542a
line wrap: on
line diff
--- a/oct-py-types.h	Mon Aug 15 21:53:25 2016 -0700
+++ b/oct-py-types.h	Mon Aug 15 21:52:50 2016 -0700
@@ -34,6 +34,13 @@
 namespace pytave
 {
 
+//! Extract the integer value of the given Python bool object.
+//!
+//! @param obj Python bool object
+//! @return @c true or @c false value of @a obj
+bool
+extract_py_bool (PyObject *obj);
+
 //! Create a Python bool object with the value of the given @c bool value.
 //!
 //! @param value @c true or @c false value
@@ -41,6 +48,13 @@
 PyObject *
 make_py_bool (bool value);
 
+//! Extract the complex value of the given Python complex object.
+//!
+//! @param obj Python complex object
+//! @return complex value of @a obj
+std::complex<double>
+extract_py_complex (PyObject *obj);
+
 //! Create a Python complex object with the value of the given @c complex value.
 //!
 //! @param value complex value
@@ -48,6 +62,13 @@
 PyObject *
 make_py_complex (std::complex<double> value);
 
+//! Extract the floating point value of the given Python float object.
+//!
+//! @param obj Python float object
+//! @return floating point value of @a obj
+double
+extract_py_float (PyObject *obj);
+
 //! Create a Python float object with the value of the given @c double value.
 //!
 //! @param value floating point value