*** empty log message ***
[luabind.git] / luabind / detail / construct_rep.hpp
blobe42a79d48c9918707003ef72bc829a44774b0958
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>
39 namespace luabind { namespace detail
43 struct construct_rep
45 struct overload_t: public overload_rep_base
47 overload_t(): wrapped_construct_fun(0)
51 typedef void*(*construct_ptr)(lua_State*);
52 typedef void*(*wrapped_construct_ptr)(lua_State*, lua_reference const&);
53 typedef void(*get_signature_ptr)(lua_State*, std::string&);
55 inline void set_constructor(construct_ptr f) { construct_fun = f; }
56 inline void set_wrapped_constructor(wrapped_construct_ptr f) { wrapped_construct_fun = f; }
58 inline void* construct(lua_State* L) { return construct_fun(L); }
59 inline void* construct_wrapped(lua_State* L, lua_reference const& ref) { return wrapped_construct_fun(L, ref); }
60 inline bool has_wrapped_construct() { return wrapped_construct_fun != 0; }
62 inline void set_arity(int arity) { m_arity = arity; }
64 private:
66 construct_ptr construct_fun;
67 wrapped_construct_ptr wrapped_construct_fun;
71 void swap(construct_rep& x)
73 std::swap(x.overloads, overloads);
76 std::vector<overload_t> overloads;
81 #endif // LUABIND_CONSTRUCT_REP_HPP_INCLUDED