source: NonGTP/Boost/boost/python/converter/pyobject_traits.hpp @ 857

Revision 857, 1.3 KB checked in by igarcia, 18 years ago (diff)
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_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
11namespace boost { namespace python { namespace converter {
12
13template <class> struct pyobject_traits;
14
15template <>
16struct 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.
32BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Type);
33BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(List);
34BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Int);
35BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Long);
36BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Dict);
37BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Tuple);
38
39}}} // namespace boost::python::converter
40
41#endif // PYOBJECT_TRAITS_DWA2002720_HPP
Note: See TracBrowser for help on using the repository browser.