]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | #ifndef BOOST_PYTHON_NO_PY_SIGNATURES | |
22 | static PyTypeObject const* get_pytype() { return 0; } | |
23 | #endif | |
24 | }; | |
25 | ||
26 | // | |
27 | // Specializations | |
28 | // | |
29 | ||
30 | # define BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(T) \ | |
31 | template <> struct pyobject_traits<Py##T##Object> \ | |
32 | : pyobject_type<Py##T##Object, &Py##T##_Type> {} | |
33 | ||
34 | // This is not an exhaustive list; should be expanded. | |
35 | BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Type); | |
36 | BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(List); | |
37 | #if PY_VERSION_HEX < 0x03000000 | |
38 | BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Int); | |
39 | #endif | |
40 | BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Long); | |
41 | BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Dict); | |
42 | BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Tuple); | |
43 | ||
44 | }}} // namespace boost::python::converter | |
45 | ||
46 | #endif // PYOBJECT_TRAITS_DWA2002720_HPP |