OSDN Git Service

build moflib1.0 on cmake-base system
[moflib/moflib.git] / moflib-1.0 / extlib / luabind-0.8 / luabind / detail / deduce_signature.hpp
1 // Copyright Daniel Wallin 2008. 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 #if !BOOST_PP_IS_ITERATING
6
7 # ifndef LUABIND_DEDUCE_SIGNATURE_080911_HPP
8 #  define LUABIND_DEDUCE_SIGNATURE_080911_HPP
9
10 #  include <luabind/detail/most_derived.hpp>
11
12 #  if LUABIND_MAX_ARITY <= 8
13 #   include <boost/mpl/vector/vector10.hpp>
14 #  else
15 #   include <boost/mpl/vector/vector50.hpp>
16 #  endif
17 #  include <boost/preprocessor/cat.hpp>
18 #  include <boost/preprocessor/iteration/iterate.hpp>
19 #  include <boost/preprocessor/repetition/enum_params.hpp>
20
21 namespace luabind { namespace detail {
22
23 namespace mpl = boost::mpl;
24
25 template <class R>
26 mpl::vector1<R> deduce_signature(R(*)(), ...)
27 {
28     return mpl::vector1<R>();
29 }
30
31 template <class R, class T>
32 mpl::vector2<R,T&> deduce_signature(R(T::*)())
33 {
34     return mpl::vector2<R,T&>();
35 }
36
37 template <class R, class T, class Wrapped>
38 mpl::vector2<R,typename most_derived<T,Wrapped>::type&>
39 deduce_signature(R(T::*)(), Wrapped*)
40 {
41     return mpl::vector2<R,typename most_derived<T,Wrapped>::type&>();
42 }
43
44 template <class R, class T>
45 mpl::vector2<R,T const&> deduce_signature(R(T::*)() const)
46 {
47     return mpl::vector2<R,T const&>();
48 }
49
50 template <class R, class T, class Wrapped>
51 mpl::vector2<R,typename most_derived<T,Wrapped>::type const&>
52 deduce_signature(R(T::*)() const, Wrapped*)
53 {
54     return mpl::vector2<R,typename most_derived<T,Wrapped>::type const&>();
55 }
56
57 #  define BOOST_PP_ITERATION_PARAMS_1 \
58     (3, (1, LUABIND_MAX_ARITY, <luabind/detail/deduce_signature.hpp>))
59 #  include BOOST_PP_ITERATE()
60
61 }} // namespace luabind::detail
62
63 # endif // LUABIND_DEDUCE_SIGNATURE_080911_HPP
64
65 #else // BOOST_PP_IS_ITERATING
66
67 # define N BOOST_PP_ITERATION()
68 # define NPLUS1 BOOST_PP_INC(N)
69
70 template <class R, BOOST_PP_ENUM_PARAMS(N,class A)>
71 BOOST_PP_CAT(mpl::vector,NPLUS1)<R, BOOST_PP_ENUM_PARAMS(N,A)>
72 deduce_signature(R(*)(BOOST_PP_ENUM_PARAMS(N,A)), ...)
73 {
74     return BOOST_PP_CAT(mpl::vector,NPLUS1)<R,BOOST_PP_ENUM_PARAMS(N,A)>();
75 }
76
77 # define NPLUS2 BOOST_PP_INC(NPLUS1)
78
79 template <class R, class T, BOOST_PP_ENUM_PARAMS(N,class A)>
80 BOOST_PP_CAT(mpl::vector,NPLUS2)<R, T&, BOOST_PP_ENUM_PARAMS(N,A)>
81 deduce_signature(R(T::*)(BOOST_PP_ENUM_PARAMS(N,A)))
82 {
83     return BOOST_PP_CAT(mpl::vector,NPLUS2)<R,T&,BOOST_PP_ENUM_PARAMS(N,A)>();
84 }
85
86 template <class R, class T, BOOST_PP_ENUM_PARAMS(N,class A), class Wrapped>
87 BOOST_PP_CAT(mpl::vector,NPLUS2)<
88     R, typename most_derived<T,Wrapped>::type&, BOOST_PP_ENUM_PARAMS(N,A)
89 >
90 deduce_signature(R(T::*)(BOOST_PP_ENUM_PARAMS(N,A)), Wrapped*)
91 {
92     return BOOST_PP_CAT(mpl::vector,NPLUS2)<
93         R,typename most_derived<T,Wrapped>::type&,BOOST_PP_ENUM_PARAMS(N,A)>();
94 }
95
96 template <class R, class T, BOOST_PP_ENUM_PARAMS(N,class A)>
97 BOOST_PP_CAT(mpl::vector,NPLUS2)<R, T const&, BOOST_PP_ENUM_PARAMS(N,A)>
98 deduce_signature(R(T::*)(BOOST_PP_ENUM_PARAMS(N,A)) const)
99 {
100     return BOOST_PP_CAT(mpl::vector,NPLUS2)<R,T const&,BOOST_PP_ENUM_PARAMS(N,A)>();
101 }
102
103 template <class R, class T, BOOST_PP_ENUM_PARAMS(N,class A), class Wrapped>
104 BOOST_PP_CAT(mpl::vector,NPLUS2)<
105     R, typename most_derived<T,Wrapped>::type const&, BOOST_PP_ENUM_PARAMS(N,A)
106 >
107 deduce_signature(R(T::*)(BOOST_PP_ENUM_PARAMS(N,A)) const, Wrapped*)
108 {
109     return BOOST_PP_CAT(mpl::vector,NPLUS2)<
110         R,typename most_derived<T,Wrapped>::type const&,BOOST_PP_ENUM_PARAMS(N,A)>();
111 }
112
113 # undef NPLUS2
114 # undef NPLUS1
115 # undef N
116
117 #endif  // BOOST_PP_IS_ITERATING
118