Line | |
---|
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
|
---|
7 |
|
---|
8 | # include <boost/python/cast.hpp>
|
---|
9 |
|
---|
10 | namespace boost { namespace python { namespace converter {
|
---|
11 |
|
---|
12 | BOOST_PYTHON_DECL PyObject* checked_downcast_impl(PyObject*, PyTypeObject*);
|
---|
13 |
|
---|
14 | // Used as a base class for specializations which need to provide
|
---|
15 | // Python type checking capability.
|
---|
16 | template <class Object, PyTypeObject* pytype>
|
---|
17 | struct pyobject_type
|
---|
18 | {
|
---|
19 | static bool check(PyObject* x)
|
---|
20 | {
|
---|
21 | return ::PyObject_IsInstance(x, (PyObject*)pytype);
|
---|
22 | }
|
---|
23 |
|
---|
24 | static Object* checked_downcast(PyObject* x)
|
---|
25 | {
|
---|
26 | return python::downcast<Object>(
|
---|
27 | (checked_downcast_impl)(x, pytype)
|
---|
28 | );
|
---|
29 | }
|
---|
30 | };
|
---|
31 |
|
---|
32 | }}} // namespace boost::python::converter
|
---|
33 |
|
---|
34 | #endif // PYOBJECT_TYPE_DWA2002720_HPP
|
---|
Note: See
TracBrowser
for help on using the repository browser.