Chris@16
|
1 // Copyright David Abrahams 2002.
|
Chris@16
|
2 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
3 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
4 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5 #ifndef PYOBJECT_TRAITS_DWA2002720_HPP
|
Chris@16
|
6 # define PYOBJECT_TRAITS_DWA2002720_HPP
|
Chris@16
|
7
|
Chris@16
|
8 # include <boost/python/detail/prefix.hpp>
|
Chris@16
|
9 # include <boost/python/converter/pyobject_type.hpp>
|
Chris@16
|
10
|
Chris@16
|
11 namespace boost { namespace python { namespace converter {
|
Chris@16
|
12
|
Chris@16
|
13 template <class> struct pyobject_traits;
|
Chris@16
|
14
|
Chris@16
|
15 template <>
|
Chris@16
|
16 struct pyobject_traits<PyObject>
|
Chris@16
|
17 {
|
Chris@16
|
18 // All objects are convertible to PyObject
|
Chris@16
|
19 static bool check(PyObject*) { return true; }
|
Chris@16
|
20 static PyObject* checked_downcast(PyObject* x) { return x; }
|
Chris@16
|
21 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
Chris@16
|
22 static PyTypeObject const* get_pytype() { return 0; }
|
Chris@16
|
23 #endif
|
Chris@16
|
24 };
|
Chris@16
|
25
|
Chris@16
|
26 //
|
Chris@16
|
27 // Specializations
|
Chris@16
|
28 //
|
Chris@16
|
29
|
Chris@16
|
30 # define BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(T) \
|
Chris@16
|
31 template <> struct pyobject_traits<Py##T##Object> \
|
Chris@16
|
32 : pyobject_type<Py##T##Object, &Py##T##_Type> {}
|
Chris@16
|
33
|
Chris@16
|
34 // This is not an exhaustive list; should be expanded.
|
Chris@16
|
35 BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Type);
|
Chris@16
|
36 BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(List);
|
Chris@16
|
37 #if PY_VERSION_HEX < 0x03000000
|
Chris@16
|
38 BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Int);
|
Chris@16
|
39 #endif
|
Chris@16
|
40 BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Long);
|
Chris@16
|
41 BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Dict);
|
Chris@16
|
42 BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Tuple);
|
Chris@16
|
43
|
Chris@16
|
44 }}} // namespace boost::python::converter
|
Chris@16
|
45
|
Chris@16
|
46 #endif // PYOBJECT_TRAITS_DWA2002720_HPP
|