Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Copyright David Abrahams 2002,  Nikolay Mladenov 2007.
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 WRAP_PYTYPE_NM20070606_HPP
0006 # define WRAP_PYTYPE_NM20070606_HPP
0007 
0008 # include <boost/python/detail/prefix.hpp>
0009 # include <boost/python/converter/registered.hpp>
0010 #  include <boost/python/detail/unwind_type.hpp>
0011 #  include <boost/python/detail/type_traits.hpp>
0012 
0013 
0014 namespace boost { namespace python {
0015 
0016 namespace converter
0017 {
0018 template <PyTypeObject const* python_type>
0019 struct wrap_pytype
0020 {
0021     static PyTypeObject const* get_pytype()
0022     {
0023         return python_type;
0024     }
0025 };
0026 
0027 typedef PyTypeObject const* (*pytype_function)();
0028 
0029 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
0030 
0031 
0032 
0033 namespace detail
0034 {
0035 struct unwind_type_id_helper{
0036     typedef python::type_info result_type;
0037     template <class U>
0038     static result_type execute(U* ){
0039         return python::type_id<U>();
0040     }
0041 };
0042 
0043 template <class T>
0044 inline python::type_info unwind_type_id_(boost::type<T>* = 0, mpl::false_ * =0)
0045 {
0046     return boost::python::detail::unwind_type<unwind_type_id_helper, T> ();
0047 }
0048 
0049 inline python::type_info unwind_type_id_(boost::type<void>* = 0, mpl::true_* =0)
0050 {
0051     return type_id<void>();
0052 }
0053 
0054 template <class T>
0055 inline python::type_info unwind_type_id(boost::type<T>* p= 0)
0056 {
0057     return unwind_type_id_(p, (mpl::bool_<boost::python::detail::is_void<T>::value >*)0 );
0058 }
0059 }
0060 
0061 
0062 template <class T>
0063 struct expected_pytype_for_arg
0064 {
0065     static PyTypeObject const *get_pytype()
0066     {
0067         const converter::registration *r=converter::registry::query(
0068             detail::unwind_type_id_((boost::type<T>*)0, (mpl::bool_<boost::python::detail::is_void<T>::value >*)0 )
0069             );
0070         return r ? r->expected_from_python_type(): 0;
0071     }
0072 };
0073 
0074 
0075 template <class T>
0076 struct registered_pytype
0077 {
0078     static PyTypeObject const *get_pytype()
0079     {
0080         const converter::registration *r=converter::registry::query(
0081             detail::unwind_type_id_((boost::type<T>*) 0, (mpl::bool_<boost::python::detail::is_void<T>::value >*)0 )
0082             );
0083         return r ? r->m_class_object: 0;
0084     }
0085 };
0086 
0087 
0088 template <class T>
0089 struct registered_pytype_direct
0090 {
0091     static PyTypeObject const* get_pytype()
0092     {
0093         return registered<T>::converters.m_class_object;
0094     }
0095 };
0096 
0097 template <class T>
0098 struct expected_from_python_type : expected_pytype_for_arg<T>{};
0099 
0100 template <class T>
0101 struct expected_from_python_type_direct
0102 {
0103     static PyTypeObject const* get_pytype()
0104     {
0105         return registered<T>::converters.expected_from_python_type();
0106     }
0107 };
0108 
0109 template <class T>
0110 struct to_python_target_type
0111 {
0112     static PyTypeObject const *get_pytype()
0113     {
0114         const converter::registration *r=converter::registry::query(
0115             detail::unwind_type_id_((boost::type<T>*)0, (mpl::bool_<boost::python::detail::is_void<T>::value >*)0 )
0116             );
0117         return r ? r->to_python_target_type(): 0;
0118     }
0119 };
0120 
0121 template <class T>
0122 struct to_python_target_type_direct
0123 {
0124     static PyTypeObject const *get_pytype()
0125     {
0126         return registered<T>::converters.to_python_target_type();
0127     }
0128 };
0129 #endif
0130 
0131 }}} // namespace boost::python
0132 
0133 #endif // WRAP_PYTYPE_NM20070606_HPP