Chris@16
|
1 // Copyright Daniel Wallin 2005. Use, modification and distribution is
|
Chris@16
|
2 // subject to the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
4
|
Chris@16
|
5 #include <boost/preprocessor/cat.hpp>
|
Chris@16
|
6 #include <boost/preprocessor/dec.hpp>
|
Chris@16
|
7 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
Chris@16
|
8 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
Chris@16
|
9
|
Chris@16
|
10 #define N BOOST_PP_ITERATION()
|
Chris@16
|
11
|
Chris@16
|
12 #define BOOST_PARAMETER_PY_ARG_TYPES(z, n, _) \
|
Chris@16
|
13 typedef typename mpl::next< \
|
Chris@16
|
14 BOOST_PP_CAT(iter,BOOST_PP_DEC(n)) \
|
Chris@16
|
15 >::type BOOST_PP_CAT(iter,n); \
|
Chris@16
|
16 \
|
Chris@16
|
17 typedef typename mpl::deref<BOOST_PP_CAT(iter,n)>::type BOOST_PP_CAT(spec,n); \
|
Chris@16
|
18 typedef typename mpl::if_< \
|
Chris@16
|
19 mpl::and_< \
|
Chris@16
|
20 mpl::not_<typename BOOST_PP_CAT(spec,n)::required> \
|
Chris@16
|
21 , typename BOOST_PP_CAT(spec,n)::optimized_default \
|
Chris@16
|
22 > \
|
Chris@16
|
23 , parameter::aux::maybe<typename BOOST_PP_CAT(spec,n)::type> \
|
Chris@16
|
24 , typename BOOST_PP_CAT(spec,n)::type \
|
Chris@16
|
25 >::type BOOST_PP_CAT(arg,n); \
|
Chris@16
|
26 typedef typename BOOST_PP_CAT(spec,n)::keyword BOOST_PP_CAT(kw,n);
|
Chris@16
|
27
|
Chris@16
|
28 #if BOOST_PP_ITERATION_FLAGS() == 1
|
Chris@16
|
29 template <class M, class R, class Args>
|
Chris@16
|
30 struct invoker<N, M, R, Args>
|
Chris@16
|
31 #elif BOOST_PP_ITERATION_FLAGS() == 2
|
Chris@16
|
32 template <class T, class R, class Args>
|
Chris@16
|
33 struct call_invoker<N, T, R, Args>
|
Chris@16
|
34 #elif BOOST_PP_ITERATION_FLAGS() == 3
|
Chris@16
|
35 template <class T, class Args>
|
Chris@16
|
36 struct init_invoker<N, T, Args>
|
Chris@16
|
37 #elif BOOST_PP_ITERATION_FLAGS() == 4
|
Chris@16
|
38 template <class M, class R, class T, class Args>
|
Chris@16
|
39 struct member_invoker<N, M, R, T, Args>
|
Chris@16
|
40 #endif
|
Chris@16
|
41 {
|
Chris@16
|
42 typedef typename mpl::begin<Args>::type iter0;
|
Chris@16
|
43 typedef typename mpl::deref<iter0>::type spec0;
|
Chris@16
|
44 typedef typename mpl::if_<
|
Chris@16
|
45 mpl::and_<
|
Chris@16
|
46 mpl::not_<typename spec0::required>
|
Chris@16
|
47 , typename spec0::optimized_default
|
Chris@16
|
48 >
|
Chris@16
|
49 , parameter::aux::maybe<typename spec0::type>
|
Chris@16
|
50 , typename spec0::type
|
Chris@16
|
51 >::type arg0;
|
Chris@16
|
52 typedef typename spec0::keyword kw0;
|
Chris@16
|
53
|
Chris@16
|
54 BOOST_PP_REPEAT_FROM_TO(1, N, BOOST_PARAMETER_PY_ARG_TYPES, ~)
|
Chris@16
|
55
|
Chris@16
|
56 static
|
Chris@16
|
57 #if BOOST_PP_ITERATION_FLAGS() == 3
|
Chris@16
|
58 T*
|
Chris@16
|
59 #else
|
Chris@16
|
60 R
|
Chris@16
|
61 #endif
|
Chris@16
|
62 execute(
|
Chris@16
|
63 #if BOOST_PP_ITERATION_FLAGS() == 2 || BOOST_PP_ITERATION_FLAGS() == 4
|
Chris@16
|
64 T& self
|
Chris@16
|
65 ,
|
Chris@16
|
66 #endif
|
Chris@16
|
67 BOOST_PP_ENUM_BINARY_PARAMS(N, arg, a)
|
Chris@16
|
68 )
|
Chris@16
|
69 {
|
Chris@16
|
70 return
|
Chris@16
|
71 #if BOOST_PP_ITERATION_FLAGS() == 1 || BOOST_PP_ITERATION_FLAGS() == 4
|
Chris@16
|
72 M()(
|
Chris@16
|
73 boost::type<R>()
|
Chris@16
|
74 # if BOOST_PP_ITERATION_FLAGS() == 4
|
Chris@16
|
75 , self
|
Chris@16
|
76 # endif
|
Chris@16
|
77 , BOOST_PP_ENUM_BINARY_PARAMS(N, parameter::keyword<kw, >::get() = a)
|
Chris@16
|
78 );
|
Chris@16
|
79 #elif BOOST_PP_ITERATION_FLAGS() == 2
|
Chris@16
|
80 self(
|
Chris@16
|
81 BOOST_PP_ENUM_BINARY_PARAMS(N, parameter::keyword<kw, >::get() = a)
|
Chris@16
|
82 );
|
Chris@16
|
83 #elif BOOST_PP_ITERATION_FLAGS() == 3
|
Chris@16
|
84 new T(
|
Chris@16
|
85 BOOST_PP_ENUM_BINARY_PARAMS(N, parameter::keyword<kw, >::get() = a)
|
Chris@16
|
86 );
|
Chris@16
|
87 #endif
|
Chris@16
|
88 }
|
Chris@16
|
89 };
|
Chris@16
|
90
|
Chris@16
|
91 #undef BOOST_PARAMETER_PY_ARG_TYPES
|
Chris@16
|
92 #undef N
|
Chris@16
|
93
|