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)
5 #ifndef LUABIND_MAKE_FUNCTION_081014_HPP
6 # define LUABIND_MAKE_FUNCTION_081014_HPP
8 # include <luabind/config.hpp>
9 # include <luabind/object.hpp>
10 # include <luabind/detail/call.hpp>
11 # include <luabind/detail/compute_score.hpp>
12 # include <luabind/detail/deduce_signature.hpp>
13 # include <luabind/detail/format_signature.hpp>
20 LUABIND_API
void handle_exception_aux(lua_State
* L
);
22 template <class F
, class Signature
, class Policies
>
23 struct function_object_impl
: function_object
25 function_object_impl(F f
, Policies
const& policies
)
26 : function_object(&entry_point
)
31 int call(lua_State
* L
, invoke_context
& ctx
) const
33 return invoke(L
, *this, ctx
, f
, Signature(), policies
);
36 void format_signature(lua_State
* L
, char const* function
) const
38 detail::format_signature(L
, function
, Signature());
41 static int entry_point(lua_State
* L
)
43 function_object_impl
const* impl
=
44 *(function_object_impl
const**)lua_touserdata(L
, lua_upvalueindex(1));
53 L
, *impl
, ctx
, impl
->f
, Signature(), impl
->policies
);
57 handle_exception_aux(L
);
63 ctx
.format_error(L
, impl
);
74 LUABIND_API object
make_function_aux(
76 , function_object
* impl
79 LUABIND_API
void add_overload(object
const&, char const*, object
const&);
83 template <class F
, class Signature
, class Policies
>
84 object
make_function(lua_State
* L
, F f
, Signature
, Policies
)
86 return detail::make_function_aux(
88 , detail::compute_arity(Signature(), Policies())
89 , new detail::function_object_impl
<F
, Signature
, Policies
>(
96 object
make_function(lua_State
* L
, F f
)
98 return make_function(L
, detail::deduce_signature(f
), detail::null_type());
101 } // namespace luabind
103 #endif // LUABIND_MAKE_FUNCTION_081014_HPP