Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:37

0001 // Copyright David Abrahams 2002.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 #ifndef PYOBJECT_TRAITS_DWA2002720_HPP
0006 # define PYOBJECT_TRAITS_DWA2002720_HPP
0007 
0008 # include <boost/python/detail/prefix.hpp>
0009 # include <boost/python/converter/pyobject_type.hpp>
0010 
0011 namespace boost { namespace python { namespace converter { 
0012 
0013 template <class> struct pyobject_traits;
0014 
0015 template <>
0016 struct pyobject_traits<PyObject>
0017 {
0018     // All objects are convertible to PyObject
0019     static bool check(PyObject*) { return true; }
0020     static PyObject* checked_downcast(PyObject* x) { return x; }
0021 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
0022     static PyTypeObject const* get_pytype() { return 0; }
0023 #endif
0024 };
0025 
0026 //
0027 // Specializations
0028 //
0029 
0030 # define BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(T)                  \
0031     template <> struct pyobject_traits<Py##T##Object>           \
0032         : pyobject_type<Py##T##Object, &Py##T##_Type> {}
0033 
0034 // This is not an exhaustive list; should be expanded.
0035 BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Type);
0036 BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(List);
0037 #if PY_VERSION_HEX < 0x03000000
0038 BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Int);
0039 #endif
0040 BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Long);
0041 BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Dict);
0042 BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Tuple);
0043 
0044 }}} // namespace boost::python::converter
0045 
0046 #endif // PYOBJECT_TRAITS_DWA2002720_HPP