123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- #ifndef DEF_HELPER_DWA200287_HPP
- # define DEF_HELPER_DWA200287_HPP
- # include <boost/python/args.hpp>
- # include <boost/python/detail/indirect_traits.hpp>
- # include <boost/python/detail/type_traits.hpp>
- # include <boost/mpl/not.hpp>
- # include <boost/mpl/and.hpp>
- # include <boost/mpl/or.hpp>
- # include <boost/mpl/lambda.hpp>
- # include <boost/mpl/apply.hpp>
- # include <boost/tuple/tuple.hpp>
- # include <boost/python/detail/not_specified.hpp>
- # include <boost/python/detail/def_helper_fwd.hpp>
- namespace boost { namespace python {
- struct default_call_policies;
- namespace detail
- {
-
-
-
-
- template <class Tuple, class Predicate>
- struct tuple_extract;
-
-
- template <bool matched>
- struct tuple_extract_impl
- {
- template <class Tuple, class Predicate>
- struct apply
- {
- typedef typename Tuple::head_type result_type;
-
- static typename Tuple::head_type extract(Tuple const& x)
- {
- return x.get_head();
- }
- };
- };
-
-
- template <>
- struct tuple_extract_impl<false>
- {
- template <class Tuple, class Predicate>
- struct apply
- {
-
- typedef tuple_extract<typename Tuple::tail_type, Predicate> next;
- typedef typename next::result_type result_type;
-
- static result_type extract(Tuple const& x)
- {
- return next::extract(x.get_tail());
- }
- };
- };
-
-
- template <class Tuple, class Predicate>
- struct tuple_extract_base_select
- {
- typedef typename Tuple::head_type head_type;
- typedef typename mpl::apply1<Predicate,
- typename add_lvalue_reference<head_type>::type>::type match_t;
- BOOST_STATIC_CONSTANT(bool, match = match_t::value);
- typedef typename tuple_extract_impl<match>::template apply<Tuple,Predicate> type;
- };
-
- template <class Tuple, class Predicate>
- struct tuple_extract
- : tuple_extract_base_select<
- Tuple
- , typename mpl::lambda<Predicate>::type
- >::type
- {
- };
-
-
-
-
- template <class Tuple>
- struct doc_extract
- : tuple_extract<
- Tuple
- , mpl::not_<
- mpl::or_<
- indirect_traits::is_reference_to_class<mpl::_1>
- , indirect_traits::is_reference_to_member_function_pointer<mpl::_1 >
- >
- >
- >
- {
- };
-
- template <class Tuple>
- struct keyword_extract
- : tuple_extract<Tuple, is_reference_to_keywords<mpl::_1 > >
- {
- };
- template <class Tuple>
- struct policy_extract
- : tuple_extract<
- Tuple
- , mpl::and_<
- mpl::not_<is_same<not_specified const&,mpl::_1> >
- , indirect_traits::is_reference_to_class<mpl::_1 >
- , mpl::not_<is_reference_to_keywords<mpl::_1 > >
- >
- >
- {
- };
- template <class Tuple>
- struct default_implementation_extract
- : tuple_extract<
- Tuple
- , indirect_traits::is_reference_to_member_function_pointer<mpl::_1 >
- >
- {
- };
-
-
-
-
-
-
-
- template <class T1, class T2, class T3, class T4>
- struct def_helper
- {
-
-
-
- typedef boost::tuples::tuple<
- T1 const&
- , T2 const&
- , T3 const&
- , T4 const&
- , default_call_policies
- , detail::keywords<0>
- , char const*
- , void(not_specified::*)()
-
- > all_t;
-
-
- def_helper(T1 const& a1) : m_all(a1,m_nil,m_nil,m_nil) {}
- def_helper(T1 const& a1, T2 const& a2) : m_all(a1,a2,m_nil,m_nil) {}
- def_helper(T1 const& a1, T2 const& a2, T3 const& a3) : m_all(a1,a2,a3,m_nil) {}
- def_helper(T1 const& a1, T2 const& a2, T3 const& a3, T4 const& a4) : m_all(a1,a2,a3,a4) {}
- private:
- typedef typename default_implementation_extract<all_t>::result_type default_implementation_t;
-
- public:
-
-
- BOOST_STATIC_CONSTANT(
- bool, has_default_implementation = (
- !is_same<default_implementation_t, void(not_specified::*)()>::value));
-
- public:
-
- char const* doc() const
- {
- return doc_extract<all_t>::extract(m_all);
- }
-
- typename keyword_extract<all_t>::result_type keywords() const
- {
- return keyword_extract<all_t>::extract(m_all);
- }
-
- typename policy_extract<all_t>::result_type policies() const
- {
- return policy_extract<all_t>::extract(m_all);
- }
- default_implementation_t default_implementation() const
- {
- return default_implementation_extract<all_t>::extract(m_all);
- }
-
- private:
- all_t m_all;
- not_specified m_nil;
- };
- }
- }}
- #endif
|