Initial C++0x support.
[luabind.git] / luabind / function.hpp
blobe156fbfcb9929157af190d223745f29cbb6fb75f
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_FUNCTION2_081014_HPP
6 # define LUABIND_FUNCTION2_081014_HPP
8 # include <luabind/make_function.hpp>
9 # include <luabind/scope.hpp>
10 # include <luabind/detail/call_function.hpp>
12 namespace luabind {
14 namespace detail
17 template <class F, class Policies>
18 struct function_registration : registration
20 function_registration(char const* name, F f, Policies const& policies)
21 : name(name)
22 , f(f)
23 , policies(policies)
26 void register_(lua_State* L) const
28 object fn = make_function(L, f, deduce_signature(f), policies);
30 add_overload(
31 object(from_stack(L, -1))
32 , name
33 , fn
37 char const* name;
38 F f;
39 Policies policies;
42 LUABIND_API bool is_luabind_function(lua_State* L, int index);
44 } // namespace detail
46 template <class F, class Policies>
47 scope def(char const* name, F f, Policies const& policies)
49 return scope(std::auto_ptr<detail::registration>(
50 new detail::function_registration<F, Policies>(name, f, policies)));
53 template <class F>
54 scope def(char const* name, F f)
56 return def(name, f, detail::null_type());
59 } // namespace luabind
61 #endif // LUABIND_FUNCTION2_081014_HPP