Mercurial > pytave
diff oct-py-util.h @ 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 | c4b78e449c62 |
children |
line wrap: on
line diff
--- a/oct-py-util.h Tue May 02 10:06:14 2017 -0700 +++ b/oct-py-util.h Tue May 02 17:44:02 2017 -0700 @@ -83,6 +83,18 @@ bool py_isinstance (PyObject *obj, PyObject *type); + //! Check whether an object is an instance of a type. + //! + //! @param obj Python object + //! @param typestr name of a Python type + //! @return @c true if @a obj is an instance of the type named by @a typestr, + //! @c false otherwise + inline bool + py_isinstance (PyObject *obj, const std::string& typestr) + { + return py_isinstance (obj, py_find_type (typestr)); + } + std::string py_object_class_name (PyObject *obj);