]> git.sesse.net Git - casparcg/blob - dependencies/boost/boost/parameter/aux_/python/invoker_iterate.hpp
Manually merged pull request #222
[casparcg] / dependencies / boost / boost / parameter / aux_ / python / invoker_iterate.hpp
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 #include <boost/preprocessor/cat.hpp>
6 #include <boost/preprocessor/dec.hpp>
7 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
8 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
9
10 #define N BOOST_PP_ITERATION()
11
12 #define BOOST_PARAMETER_PY_ARG_TYPES(z, n, _) \
13     typedef typename mpl::next< \
14         BOOST_PP_CAT(iter,BOOST_PP_DEC(n)) \
15     >::type BOOST_PP_CAT(iter,n); \
16     \
17     typedef typename mpl::deref<BOOST_PP_CAT(iter,n)>::type BOOST_PP_CAT(spec,n); \
18     typedef typename mpl::if_< \
19         mpl::and_< \
20             mpl::not_<typename BOOST_PP_CAT(spec,n)::required> \
21           , typename BOOST_PP_CAT(spec,n)::optimized_default \
22         > \
23       , parameter::aux::maybe<typename BOOST_PP_CAT(spec,n)::type> \
24       , typename BOOST_PP_CAT(spec,n)::type \
25     >::type BOOST_PP_CAT(arg,n); \
26     typedef typename BOOST_PP_CAT(spec,n)::keyword BOOST_PP_CAT(kw,n);
27
28 #if BOOST_PP_ITERATION_FLAGS() == 1
29 template <class M, class R, class Args>
30 struct invoker<N, M, R, Args>
31 #elif BOOST_PP_ITERATION_FLAGS() == 2
32 template <class T, class R, class Args>
33 struct call_invoker<N, T, R, Args>
34 #elif BOOST_PP_ITERATION_FLAGS() == 3
35 template <class T, class Args>
36 struct init_invoker<N, T, Args>
37 #elif BOOST_PP_ITERATION_FLAGS() == 4
38 template <class M, class R, class T, class Args>
39 struct member_invoker<N, M, R, T, Args>
40 #endif
41 {
42     typedef typename mpl::begin<Args>::type iter0;
43     typedef typename mpl::deref<iter0>::type spec0;
44     typedef typename mpl::if_<
45         mpl::and_<
46             mpl::not_<typename spec0::required>
47           , typename spec0::optimized_default
48         >
49       , parameter::aux::maybe<typename spec0::type>
50       , typename spec0::type
51     >::type arg0;
52     typedef typename spec0::keyword kw0;
53
54     BOOST_PP_REPEAT_FROM_TO(1, N, BOOST_PARAMETER_PY_ARG_TYPES, ~)
55
56     static
57 #if BOOST_PP_ITERATION_FLAGS() == 3
58     T*
59 #else
60     R
61 #endif 
62     execute(
63 #if BOOST_PP_ITERATION_FLAGS() == 2 || BOOST_PP_ITERATION_FLAGS() == 4
64         T& self
65       ,
66 #endif
67         BOOST_PP_ENUM_BINARY_PARAMS(N, arg, a)
68     )
69     {
70         return
71 #if BOOST_PP_ITERATION_FLAGS() == 1 || BOOST_PP_ITERATION_FLAGS() == 4
72          M()(
73               boost::type<R>()
74 # if BOOST_PP_ITERATION_FLAGS() == 4
75             , self
76 # endif
77             , BOOST_PP_ENUM_BINARY_PARAMS(N, parameter::keyword<kw, >::get() = a)
78          );
79 #elif BOOST_PP_ITERATION_FLAGS() == 2
80          self(
81             BOOST_PP_ENUM_BINARY_PARAMS(N, parameter::keyword<kw, >::get() = a)
82          );
83 #elif BOOST_PP_ITERATION_FLAGS() == 3
84          new T(
85              BOOST_PP_ENUM_BINARY_PARAMS(N, parameter::keyword<kw, >::get() = a)
86          );
87 #endif
88     }
89 };
90
91 #undef BOOST_PARAMETER_PY_ARG_TYPES
92 #undef N
93