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/parameter/keyword.hpp> |
---|
12 | # include <boost/preprocessor/iteration/iterate.hpp> |
---|
13 | |
---|
14 | namespace boost { namespace parameter { namespace python { namespace aux { |
---|
15 | |
---|
16 | template <long Arity, class M, class R, class Args> |
---|
17 | struct invoker; |
---|
18 | |
---|
19 | template <class M, class R> |
---|
20 | struct make_invoker |
---|
21 | { |
---|
22 | template <class Args> |
---|
23 | struct apply |
---|
24 | { |
---|
25 | typedef invoker< |
---|
26 | mpl::size<Args>::value, M, R, Args |
---|
27 | > type; |
---|
28 | }; |
---|
29 | }; |
---|
30 | |
---|
31 | template <long Arity, class M, class R, class T, class Args> |
---|
32 | struct member_invoker; |
---|
33 | |
---|
34 | template <class M, class R, class T> |
---|
35 | struct make_member_invoker |
---|
36 | { |
---|
37 | template <class Args> |
---|
38 | struct apply |
---|
39 | { |
---|
40 | typedef member_invoker< |
---|
41 | mpl::size<Args>::value, M, R, T, Args |
---|
42 | > type; |
---|
43 | }; |
---|
44 | }; |
---|
45 | |
---|
46 | template <long Arity, class T, class R, class Args> |
---|
47 | struct call_invoker; |
---|
48 | |
---|
49 | template <class T, class R> |
---|
50 | struct make_call_invoker |
---|
51 | { |
---|
52 | template <class Args> |
---|
53 | struct apply |
---|
54 | { |
---|
55 | typedef call_invoker< |
---|
56 | mpl::size<Args>::value, T, R, Args |
---|
57 | > type; |
---|
58 | }; |
---|
59 | }; |
---|
60 | |
---|
61 | template <long Arity, class T, class Args> |
---|
62 | struct init_invoker; |
---|
63 | |
---|
64 | template <class T> |
---|
65 | struct make_init_invoker |
---|
66 | { |
---|
67 | template <class Args> |
---|
68 | struct apply |
---|
69 | { |
---|
70 | typedef init_invoker< |
---|
71 | mpl::size<Args>::value, T, Args |
---|
72 | > type; |
---|
73 | }; |
---|
74 | }; |
---|
75 | |
---|
76 | template <class M, class R, class Args> |
---|
77 | struct invoker<0, M, R, Args> |
---|
78 | { |
---|
79 | static R execute() |
---|
80 | { |
---|
81 | return M()(boost::type<R>()); |
---|
82 | } |
---|
83 | }; |
---|
84 | |
---|
85 | template <class M, class R, class T, class Args> |
---|
86 | struct member_invoker<0, M, R, T, Args> |
---|
87 | { |
---|
88 | static R execute(T& self) |
---|
89 | { |
---|
90 | return M()(boost::type<R>(), self); |
---|
91 | } |
---|
92 | }; |
---|
93 | |
---|
94 | template <class T, class R, class Args> |
---|
95 | struct call_invoker<0, T, R, Args> |
---|
96 | { |
---|
97 | static R execute(T& self) |
---|
98 | { |
---|
99 | return self(); |
---|
100 | } |
---|
101 | }; |
---|
102 | |
---|
103 | template <class T, class Args> |
---|
104 | struct init_invoker<0, T, Args> |
---|
105 | { |
---|
106 | static T* execute(T& self) |
---|
107 | { |
---|
108 | return new T; |
---|
109 | } |
---|
110 | }; |
---|
111 | |
---|
112 | # define BOOST_PP_ITERATION_PARAMS_1 (4, \ |
---|
113 | (1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 1)) |
---|
114 | # include BOOST_PP_ITERATE() |
---|
115 | |
---|
116 | # define BOOST_PP_ITERATION_PARAMS_1 (4, \ |
---|
117 | (1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 2)) |
---|
118 | # include BOOST_PP_ITERATE() |
---|
119 | |
---|
120 | # define BOOST_PP_ITERATION_PARAMS_1 (4, \ |
---|
121 | (1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 3)) |
---|
122 | # include BOOST_PP_ITERATE() |
---|
123 | |
---|
124 | # define BOOST_PP_ITERATION_PARAMS_1 (4, \ |
---|
125 | (1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 4)) |
---|
126 | # include BOOST_PP_ITERATE() |
---|
127 | |
---|
128 | }}}} // namespace boost::parameter::python::aux |
---|
129 | |
---|
130 | #endif // BOOST_PARAMETER_INVOKER_051210_HPP |
---|
131 | |
---|