File indexing completed on 2025-01-18 09:50:37
0001
0002
0003
0004
0005 #ifndef PYOBJECT_TYPE_DWA2002720_HPP
0006 # define PYOBJECT_TYPE_DWA2002720_HPP
0007
0008 # include <boost/python/cast.hpp>
0009
0010 namespace boost { namespace python { namespace converter {
0011
0012 BOOST_PYTHON_DECL inline
0013 PyObject* checked_downcast_impl(PyObject *obj, PyTypeObject *type)
0014 {
0015 return (PyType_IsSubtype(Py_TYPE(obj), type) ? obj : NULL);
0016 }
0017
0018
0019 template <class Object, PyTypeObject* pytype>
0020 struct pyobject_type
0021 {
0022 static bool check(PyObject* x)
0023 {
0024 return ::PyObject_IsInstance(x, (PyObject*)pytype);
0025 }
0026
0027 static Object* checked_downcast(PyObject* x)
0028 {
0029 return python::downcast<Object>(
0030 (checked_downcast_impl)(x, pytype)
0031 );
0032 }
0033 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
0034 static PyTypeObject const* get_pytype() { return pytype; }
0035 #endif
0036 };
0037
0038 }}}
0039
0040 #endif