OSDN Git Service

build moflib1.0 on cmake-base system
[moflib/moflib.git] / extlib / luabind-0.8 / luabind / tag_function.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_TAG_FUNCTION_081129_HPP
8 #  define LUABIND_TAG_FUNCTION_081129_HPP
9
10 #  if LUABIND_MAX_ARITY <= 8
11 #   include <boost/mpl/vector/vector10.hpp>
12 #  else
13 #   include <boost/mpl/vector/vector50.hpp>
14 #  endif
15 #  include <boost/preprocessor/cat.hpp>
16 #  include <boost/preprocessor/iterate.hpp>
17 #  include <boost/preprocessor/repetition/enum_params.hpp>
18 #  include <boost/preprocessor/repetition/enum_trailing_params.hpp>
19
20 namespace luabind {
21
22 namespace detail
23 {
24
25   template <class Signature, class F>
26   struct tagged_function
27   {
28       tagged_function(F f)
29         : f(f)
30       {}
31
32       F f;
33   };
34
35   template <class Signature, class F>
36   Signature deduce_signature(tagged_function<Signature, F> const&, ...)
37   {
38       return Signature();
39   }
40
41   template <class Signature, class F, class Policies>
42   int invoke(
43       lua_State* L, tagged_function<Signature, F> const& tagged
44     , Signature, Policies const& policies)
45   {
46       return invoke(L, tagged.f, Signature(), policies);
47   }
48
49   template <class Function>
50   struct signature_from_function;
51
52 #  define BOOST_PP_ITERATION_PARAMS_1 \
53   (3, (0, LUABIND_MAX_ARITY, <luabind/tag_function.hpp>))
54 #  include BOOST_PP_ITERATE()
55
56 } // namespace detail
57
58 template <class Signature, class F>
59 detail::tagged_function<
60     typename detail::signature_from_function<Signature>::type
61   , F
62 >
63 tag_function(F f)
64 {
65     return f;
66 }
67
68 } // namespace luabind
69
70 # endif // LUABIND_TAG_FUNCTION_081129_HPP
71
72 #else // BOOST_PP_IS_ITERATING
73
74 # define N BOOST_PP_ITERATION()
75 # define NPLUS1 BOOST_PP_INC(N)
76
77 template <class R BOOST_PP_ENUM_TRAILING_PARAMS(N, class A)>
78 struct signature_from_function<R(BOOST_PP_ENUM_PARAMS(N, A))>
79 {
80     typedef BOOST_PP_CAT(mpl::vector, NPLUS1)<
81         R BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
82     > type;
83 };
84
85 #endif // BOOST_PP_IS_ITERATING
86
87