Initial commit, includes Lua with broken Luabind as a backup for branching purposes
[terrastrategy.git] / include / luabind / detail / construct_rep.hpp
bloba7729bb86d6ca413ff437d96e9aa5907e6076658
1 // Copyright (c) 2003 Daniel Wallin and Arvid Norberg
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the "Software"),
5 // to deal in the Software without restriction, including without limitation
6 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 // and/or sell copies of the Software, and to permit persons to whom the
8 // Software is furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included
11 // in all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
14 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
15 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
18 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21 // OR OTHER DEALINGS IN THE SOFTWARE.
24 #ifndef LUABIND_CONSTRUCT_REP_HPP_INCLUDED
25 #define LUABIND_CONSTRUCT_REP_HPP_INCLUDED
27 #include <luabind/config.hpp>
29 #include <vector>
30 #include <string>
32 #include <boost/preprocessor/enum_params.hpp>
33 #include <boost/function/function1.hpp>
34 #include <boost/function/function2.hpp>
36 //#include <luabind/detail/signature_match.hpp>
37 #include <luabind/detail/overload_rep_base.hpp>
38 #include <luabind/weak_ref.hpp>
40 namespace luabind { namespace detail
44 struct construct_rep
46 struct overload_t: public overload_rep_base
48 overload_t(): wrapped_construct_fun(0)
52 typedef void*(*construct_ptr)(lua_State*, weak_ref const&);
53 typedef void*(*wrapped_construct_ptr)(lua_State*, weak_ref const&);
54 typedef void(*get_signature_ptr)(lua_State*, std::string&);
56 inline void set_constructor(construct_ptr f) { construct_fun = f; }
57 inline void set_wrapped_constructor(wrapped_construct_ptr f) { wrapped_construct_fun = f; }
59 inline void* construct(lua_State* L, weak_ref const& backref)
61 return construct_fun(L, backref);
64 inline void* construct_wrapped(lua_State* L, weak_ref const& ref) { return wrapped_construct_fun(L, ref); }
65 inline bool has_wrapped_construct() { return wrapped_construct_fun != 0; }
67 inline void set_arity(int arity) { m_arity = arity; }
69 private:
71 construct_ptr construct_fun;
72 wrapped_construct_ptr wrapped_construct_fun;
76 void swap(construct_rep& x)
78 std::swap(x.overloads, overloads);
81 std::vector<overload_t> overloads;
86 #endif // LUABIND_CONSTRUCT_REP_HPP_INCLUDED