File indexing completed on 2025-01-18 09:50:37
0001
0002
0003
0004
0005 #ifndef DEF_HELPER_DWA200287_HPP
0006 # define DEF_HELPER_DWA200287_HPP
0007
0008 # include <boost/python/args.hpp>
0009 # include <boost/python/detail/indirect_traits.hpp>
0010 # include <boost/python/detail/type_traits.hpp>
0011 # include <boost/mpl/not.hpp>
0012 # include <boost/mpl/and.hpp>
0013 # include <boost/mpl/or.hpp>
0014 # include <boost/mpl/lambda.hpp>
0015 # include <boost/mpl/apply.hpp>
0016 # include <boost/tuple/tuple.hpp>
0017 # include <boost/python/detail/not_specified.hpp>
0018 # include <boost/python/detail/def_helper_fwd.hpp>
0019
0020 namespace boost { namespace python {
0021
0022 struct default_call_policies;
0023
0024 namespace detail
0025 {
0026
0027
0028
0029
0030 template <class Tuple, class Predicate>
0031 struct tuple_extract;
0032
0033
0034
0035 template <bool matched>
0036 struct tuple_extract_impl
0037 {
0038 template <class Tuple, class Predicate>
0039 struct apply
0040 {
0041 typedef typename Tuple::head_type result_type;
0042
0043 static typename Tuple::head_type extract(Tuple const& x)
0044 {
0045 return x.get_head();
0046 }
0047 };
0048 };
0049
0050
0051
0052 template <>
0053 struct tuple_extract_impl<false>
0054 {
0055 template <class Tuple, class Predicate>
0056 struct apply
0057 {
0058
0059 typedef tuple_extract<typename Tuple::tail_type, Predicate> next;
0060 typedef typename next::result_type result_type;
0061
0062 static result_type extract(Tuple const& x)
0063 {
0064 return next::extract(x.get_tail());
0065 }
0066 };
0067 };
0068
0069
0070
0071 template <class Tuple, class Predicate>
0072 struct tuple_extract_base_select
0073 {
0074 typedef typename Tuple::head_type head_type;
0075 typedef typename mpl::apply1<Predicate,
0076 typename add_lvalue_reference<head_type>::type>::type match_t;
0077 BOOST_STATIC_CONSTANT(bool, match = match_t::value);
0078 typedef typename tuple_extract_impl<match>::template apply<Tuple,Predicate> type;
0079 };
0080
0081 template <class Tuple, class Predicate>
0082 struct tuple_extract
0083 : tuple_extract_base_select<
0084 Tuple
0085 , typename mpl::lambda<Predicate>::type
0086 >::type
0087 {
0088 };
0089
0090
0091
0092
0093
0094
0095
0096 template <class Tuple>
0097 struct doc_extract
0098 : tuple_extract<
0099 Tuple
0100 , mpl::not_<
0101 mpl::or_<
0102 indirect_traits::is_reference_to_class<mpl::_1>
0103 , indirect_traits::is_reference_to_member_function_pointer<mpl::_1 >
0104 >
0105 >
0106 >
0107 {
0108 };
0109
0110 template <class Tuple>
0111 struct keyword_extract
0112 : tuple_extract<Tuple, is_reference_to_keywords<mpl::_1 > >
0113 {
0114 };
0115
0116 template <class Tuple>
0117 struct policy_extract
0118 : tuple_extract<
0119 Tuple
0120 , mpl::and_<
0121 mpl::not_<is_same<not_specified const&,mpl::_1> >
0122 , indirect_traits::is_reference_to_class<mpl::_1 >
0123 , mpl::not_<is_reference_to_keywords<mpl::_1 > >
0124 >
0125 >
0126 {
0127 };
0128
0129 template <class Tuple>
0130 struct default_implementation_extract
0131 : tuple_extract<
0132 Tuple
0133 , indirect_traits::is_reference_to_member_function_pointer<mpl::_1 >
0134 >
0135 {
0136 };
0137
0138
0139
0140
0141
0142
0143
0144
0145 template <class T1, class T2, class T3, class T4>
0146 struct def_helper
0147 {
0148
0149
0150
0151 typedef boost::tuples::tuple<
0152 T1 const&
0153 , T2 const&
0154 , T3 const&
0155 , T4 const&
0156 , default_call_policies
0157 , detail::keywords<0>
0158 , char const*
0159 , void(not_specified::*)()
0160
0161 > all_t;
0162
0163
0164
0165 def_helper(T1 const& a1) : m_all(a1,m_nil,m_nil,m_nil) {}
0166 def_helper(T1 const& a1, T2 const& a2) : m_all(a1,a2,m_nil,m_nil) {}
0167 def_helper(T1 const& a1, T2 const& a2, T3 const& a3) : m_all(a1,a2,a3,m_nil) {}
0168 def_helper(T1 const& a1, T2 const& a2, T3 const& a3, T4 const& a4) : m_all(a1,a2,a3,a4) {}
0169
0170 private:
0171 typedef typename default_implementation_extract<all_t>::result_type default_implementation_t;
0172
0173 public:
0174
0175
0176
0177 BOOST_STATIC_CONSTANT(
0178 bool, has_default_implementation = (
0179 !is_same<default_implementation_t, void(not_specified::*)()>::value));
0180
0181 public:
0182
0183 char const* doc() const
0184 {
0185 return doc_extract<all_t>::extract(m_all);
0186 }
0187
0188 typename keyword_extract<all_t>::result_type keywords() const
0189 {
0190 return keyword_extract<all_t>::extract(m_all);
0191 }
0192
0193 typename policy_extract<all_t>::result_type policies() const
0194 {
0195 return policy_extract<all_t>::extract(m_all);
0196 }
0197
0198 default_implementation_t default_implementation() const
0199 {
0200 return default_implementation_extract<all_t>::extract(m_all);
0201 }
0202
0203 private:
0204 all_t m_all;
0205 not_specified m_nil;
0206 };
0207 }
0208
0209 }}
0210
0211 #endif