OSDN Git Service

build moflib1.0 on cmake-base system
[moflib/moflib.git] / extlib / luabind-0.8 / luabind / detail / construct_rep.hpp
1 // Copyright (c) 2003 Daniel Wallin and Arvid Norberg
2
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:
9
10 // The above copyright notice and this permission notice shall be included
11 // in all copies or substantial portions of the Software.
12
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.
22
23
24 #ifndef LUABIND_CONSTRUCT_REP_HPP_INCLUDED
25 #define LUABIND_CONSTRUCT_REP_HPP_INCLUDED
26
27 #include <luabind/config.hpp>
28
29 #include <vector>
30 #include <string>
31
32 #include <boost/preprocessor/enum_params.hpp>
33 #include <boost/function/function1.hpp>
34 #include <boost/function/function2.hpp>
35
36 //#include <luabind/detail/signature_match.hpp>
37 #include <luabind/detail/overload_rep_base.hpp>
38 #include <luabind/weak_ref.hpp>
39
40 namespace luabind { namespace detail
41 {
42
43
44         struct construct_rep
45         {
46                 struct overload_t: public overload_rep_base
47                 {
48                         overload_t(): wrapped_construct_fun(0) 
49                         {
50                         }
51
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&);
55
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; }
58
59                         inline void* construct(lua_State* L, weak_ref const& backref) 
60                         { 
61                                 return construct_fun(L, backref); 
62                         }
63
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; }
66
67                         inline void set_arity(int arity) { m_arity = arity; }
68
69                 private:
70
71                         construct_ptr construct_fun;
72                         wrapped_construct_ptr wrapped_construct_fun;
73
74                 };
75
76                 void swap(construct_rep& x)
77                 {
78                         std::swap(x.overloads, overloads);
79                 }
80
81                 std::vector<overload_t> overloads;
82         };
83
84 }}
85
86 #endif // LUABIND_CONSTRUCT_REP_HPP_INCLUDED