Mercurial > pytave
comparison python_to_octave.cc @ 409:b9b8790d1082
Add overload of py_isinstance taking a string decribing a type
* oct-py-util.h (pytave::py_isinstance): New function overload.
* __py_struct_from_dict__.cc (F__py_isinstance__): Use it.
* python_to_octave.cc (pytave::pyobj_to_octvalue): Use it.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Tue, 02 May 2017 17:44:02 -0700 |
parents | 16e79a1e96b8 |
children | 95c6ad0be828 |
comparison
equal
deleted
inserted
replaced
408:f833e29b2c12 | 409:b9b8790d1082 |
---|---|
309 } | 309 } |
310 | 310 |
311 void pyobj_to_octvalue (octave_value& oct_value, | 311 void pyobj_to_octvalue (octave_value& oct_value, |
312 const boost::python::object& py_object) | 312 const boost::python::object& py_object) |
313 { | 313 { |
314 boost::python::extract<boost::python::numeric::array> arrayx (py_object); | |
315 | 314 |
316 if (PyBool_Check (py_object.ptr ())) | 315 if (PyBool_Check (py_object.ptr ())) |
317 oct_value = extract_py_bool (py_object.ptr ()); | 316 oct_value = extract_py_bool (py_object.ptr ()); |
318 #if PY_VERSION_HEX < 0x03000000 | 317 #if PY_VERSION_HEX < 0x03000000 |
319 else if (PyInt_Check (py_object.ptr ())) | 318 else if (PyInt_Check (py_object.ptr ())) |
321 #endif | 320 #endif |
322 else if (PyFloat_Check (py_object.ptr ())) | 321 else if (PyFloat_Check (py_object.ptr ())) |
323 oct_value = extract_py_float (py_object.ptr ()); | 322 oct_value = extract_py_float (py_object.ptr ()); |
324 else if (PyComplex_Check (py_object.ptr ())) | 323 else if (PyComplex_Check (py_object.ptr ())) |
325 oct_value = extract_py_complex (py_object.ptr ()); | 324 oct_value = extract_py_complex (py_object.ptr ()); |
326 else if (arrayx.check ()) | 325 else if (py_isinstance (py_object.ptr (), "numpy.ndarray")) |
327 pyarr_to_octvalue (oct_value, (PyArrayObject*)py_object.ptr ()); | 326 pyarr_to_octvalue (oct_value, (PyArrayObject*)py_object.ptr ()); |
328 else | 327 else |
329 oct_value = pyobject_wrap_object (py_object.ptr ()); | 328 oct_value = pyobject_wrap_object (py_object.ptr ()); |
330 } | 329 } |
331 } | 330 } |