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_TRAITS_DWA2002720_HPP
|
---|
6 | # define PYOBJECT_TRAITS_DWA2002720_HPP
|
---|
7 |
|
---|
8 | # include <boost/python/detail/prefix.hpp>
|
---|
9 | # include <boost/python/converter/pyobject_type.hpp>
|
---|
10 |
|
---|
11 | namespace boost { namespace python { namespace converter {
|
---|
12 |
|
---|
13 | template <class> struct pyobject_traits;
|
---|
14 |
|
---|
15 | template <>
|
---|
16 | struct pyobject_traits<PyObject>
|
---|
17 | {
|
---|
18 | // All objects are convertible to PyObject
|
---|
19 | static bool check(PyObject*) { return true; }
|
---|
20 | static PyObject* checked_downcast(PyObject* x) { return x; }
|
---|
21 | };
|
---|
22 |
|
---|
23 | //
|
---|
24 | // Specializations
|
---|
25 | //
|
---|
26 |
|
---|
27 | # define BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(T) \
|
---|
28 | template <> struct pyobject_traits<Py##T##Object> \
|
---|
29 | : pyobject_type<Py##T##Object, &Py##T##_Type> {}
|
---|
30 |
|
---|
31 | // This is not an exhaustive list; should be expanded.
|
---|
32 | BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Type);
|
---|
33 | BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(List);
|
---|
34 | BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Int);
|
---|
35 | BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Long);
|
---|
36 | BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Dict);
|
---|
37 | BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Tuple);
|
---|
38 |
|
---|
39 | }}} // namespace boost::python::converter
|
---|
40 |
|
---|
41 | #endif // PYOBJECT_TRAITS_DWA2002720_HPP
|
---|