1 // Copyright Daniel Wallin 2005. Use, modification and distribution is 2 // subject to the Boost Software License, Version 1.0. (See accompanying 3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 5 #ifndef BOOST_PARAMETER_INVOKER_051210_HPP 6 # define BOOST_PARAMETER_INVOKER_051210_HPP 7 8 # include <boost/mpl/begin.hpp> 9 # include <boost/mpl/next.hpp> 10 # include <boost/mpl/deref.hpp> 11 # include <boost/mpl/size.hpp> 12 # include <boost/parameter/keyword.hpp> 13 # include <boost/preprocessor/iteration/iterate.hpp> 14 15 namespace boost { namespace parameter { namespace python { namespace aux { 16 17 template <long Arity, class M, class R, class Args> 18 struct invoker; 19 20 template <class M, class R> 21 struct make_invoker 22 { 23 template <class Args> 24 struct apply 25 { 26 typedef invoker< 27 mpl::size<Args>::value, M, R, Args 28 > type; 29 }; 30 }; 31 32 template <long Arity, class M, class R, class T, class Args> 33 struct member_invoker; 34 35 template <class M, class R, class T> 36 struct make_member_invoker 37 { 38 template <class Args> 39 struct apply 40 { 41 typedef member_invoker< 42 mpl::size<Args>::value, M, R, T, Args 43 > type; 44 }; 45 }; 46 47 template <long Arity, class T, class R, class Args> 48 struct call_invoker; 49 50 template <class T, class R> 51 struct make_call_invoker 52 { 53 template <class Args> 54 struct apply 55 { 56 typedef call_invoker< 57 mpl::size<Args>::value, T, R, Args 58 > type; 59 }; 60 }; 61 62 template <long Arity, class T, class Args> 63 struct init_invoker; 64 65 template <class T> 66 struct make_init_invoker 67 { 68 template <class Args> 69 struct apply 70 { 71 typedef init_invoker< 72 mpl::size<Args>::value, T, Args 73 > type; 74 }; 75 }; 76 77 template <class M, class R, class Args> 78 struct invoker<0, M, R, Args> 79 { executeboost::parameter::python::aux::invoker80 static R execute() 81 { 82 return M()(boost::type<R>()); 83 } 84 }; 85 86 template <class M, class R, class T, class Args> 87 struct member_invoker<0, M, R, T, Args> 88 { executeboost::parameter::python::aux::member_invoker89 static R execute(T& self) 90 { 91 return M()(boost::type<R>(), self); 92 } 93 }; 94 95 template <class T, class R, class Args> 96 struct call_invoker<0, T, R, Args> 97 { executeboost::parameter::python::aux::call_invoker98 static R execute(T& self) 99 { 100 return self(); 101 } 102 }; 103 104 template <class T, class Args> 105 struct init_invoker<0, T, Args> 106 { executeboost::parameter::python::aux::init_invoker107 static T* execute(T& self) 108 { 109 return new T; 110 } 111 }; 112 113 # define BOOST_PP_ITERATION_PARAMS_1 (4, \ 114 (1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 1)) 115 # include BOOST_PP_ITERATE() 116 117 # define BOOST_PP_ITERATION_PARAMS_1 (4, \ 118 (1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 2)) 119 # include BOOST_PP_ITERATE() 120 121 # define BOOST_PP_ITERATION_PARAMS_1 (4, \ 122 (1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 3)) 123 # include BOOST_PP_ITERATE() 124 125 # define BOOST_PP_ITERATION_PARAMS_1 (4, \ 126 (1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 4)) 127 # include BOOST_PP_ITERATE() 128 129 }}}} // namespace boost::parameter::python::aux 130 131 #endif // BOOST_PARAMETER_INVOKER_051210_HPP 132 133