1 // Copyright David Abrahams 2002.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 #ifndef PYOBJECT_TYPE_DWA2002720_HPP
6 # define PYOBJECT_TYPE_DWA2002720_HPP
8 # include <boost/python/cast.hpp>
10 namespace boost { namespace python { namespace converter {
12 BOOST_PYTHON_DECL PyObject* checked_downcast_impl(PyObject*, PyTypeObject*);
14 // Used as a base class for specializations which need to provide
15 // Python type checking capability.
16 template <class Object, PyTypeObject* pytype>
19 static bool check(PyObject* x)
21 return ::PyObject_IsInstance(x, (PyObject*)pytype);
24 static Object* checked_downcast(PyObject* x)
26 return python::downcast<Object>(
27 (checked_downcast_impl)(x, pytype)
30 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
31 static PyTypeObject const* get_pytype() { return pytype; }
35 }}} // namespace boost::python::converter
37 #endif // PYOBJECT_TYPE_DWA2002720_HPP