File indexing completed on 2025-09-15 08:51:08
0001
0002
0003
0004
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 # include <boost/python/back_reference.hpp>
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 template <class T>
0050 inline python::type_info unwind_type_id_(boost::type<back_reference<T> >* = 0, mpl::false_ * =0)
0051 {
0052 return boost::python::detail::unwind_type<unwind_type_id_helper, T> ();
0053 }
0054
0055 inline python::type_info unwind_type_id_(boost::type<void>* = 0, mpl::true_* =0)
0056 {
0057 return type_id<void>();
0058 }
0059
0060 template <class T>
0061 inline python::type_info unwind_type_id(boost::type<T>* p= 0)
0062 {
0063 return unwind_type_id_(p, (mpl::bool_<boost::python::detail::is_void<T>::value >*)0 );
0064 }
0065 }
0066
0067
0068 template <class T>
0069 struct expected_pytype_for_arg
0070 {
0071 static PyTypeObject const *get_pytype()
0072 {
0073 const converter::registration *r=converter::registry::query(
0074 detail::unwind_type_id_((boost::type<T>*)0, (mpl::bool_<boost::python::detail::is_void<T>::value >*)0 )
0075 );
0076 return r ? r->expected_from_python_type(): 0;
0077 }
0078 };
0079
0080
0081 template <class T>
0082 struct registered_pytype
0083 {
0084 static PyTypeObject const *get_pytype()
0085 {
0086 const converter::registration *r=converter::registry::query(
0087 detail::unwind_type_id_((boost::type<T>*) 0, (mpl::bool_<boost::python::detail::is_void<T>::value >*)0 )
0088 );
0089 return r ? r->m_class_object: 0;
0090 }
0091 };
0092
0093
0094 template <class T>
0095 struct registered_pytype_direct
0096 {
0097 static PyTypeObject const* get_pytype()
0098 {
0099 return registered<T>::converters.m_class_object;
0100 }
0101 };
0102
0103 template <class T>
0104 struct expected_from_python_type : expected_pytype_for_arg<T>{};
0105
0106 template <class T>
0107 struct expected_from_python_type_direct
0108 {
0109 static PyTypeObject const* get_pytype()
0110 {
0111 return registered<T>::converters.expected_from_python_type();
0112 }
0113 };
0114
0115 template <class T>
0116 struct to_python_target_type
0117 {
0118 static PyTypeObject const *get_pytype()
0119 {
0120 const converter::registration *r=converter::registry::query(
0121 detail::unwind_type_id_((boost::type<T>*)0, (mpl::bool_<boost::python::detail::is_void<T>::value >*)0 )
0122 );
0123 return r ? r->to_python_target_type(): 0;
0124 }
0125 };
0126
0127 template <class T>
0128 struct to_python_target_type_direct
0129 {
0130 static PyTypeObject const *get_pytype()
0131 {
0132 return registered<T>::converters.to_python_target_type();
0133 }
0134 };
0135 #endif
0136
0137 }}}
0138
0139 #endif