Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 0659a47

Browse files
committed
Add Luabind 0.7.1 includes and binaries - binaries built with Boost 1.55 on v141 toolset (does not compile with Boost 1.69)
1 parent 5f65048 commit 0659a47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+12796
-0
lines changed
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
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_ADOPT_POLICY_HPP_INCLUDED
25+
#define LUABIND_ADOPT_POLICY_HPP_INCLUDED
26+
27+
#include <luabind/config.hpp>
28+
#include <luabind/detail/policy.hpp>
29+
#include <luabind/detail/implicit_cast.hpp>
30+
#include <boost/mpl/bool.hpp>
31+
#include <luabind/back_reference_fwd.hpp>
32+
33+
namespace luabind { namespace detail
34+
{
35+
template<class Direction = lua_to_cpp>
36+
struct adopt_pointer
37+
{
38+
typedef boost::mpl::bool_<false> is_value_converter;
39+
typedef adopt_pointer type;
40+
41+
template<class T>
42+
T* apply(lua_State* L, by_pointer<T>, int index)
43+
{
44+
// preconditions:
45+
// lua_isuserdata(L, index);
46+
// getmetatable().__lua_class is true
47+
// object_rep->flags() & object_rep::constant == 0
48+
49+
int offset = 0;
50+
object_rep* obj = static_cast<object_rep*>(lua_touserdata(L, index));
51+
assert((obj != 0) && "internal error, please report");
52+
const class_rep* crep = obj->crep();
53+
54+
int steps = implicit_cast(crep, LUABIND_TYPEID(T), offset);
55+
(void)steps;
56+
57+
assert((steps >= 0) && "adopt_pointer used with type that cannot be converted");
58+
obj->remove_ownership();
59+
T* ptr = reinterpret_cast<T*>(obj->ptr(offset));
60+
61+
return ptr;
62+
}
63+
64+
template<class T>
65+
static int match(lua_State* L, by_pointer<T>, int index)
66+
{
67+
object_rep* obj = is_class_object(L, index);
68+
if (obj == 0) return -1;
69+
// cannot cast a constant object to nonconst
70+
if (obj->flags() & object_rep::constant) return -1;
71+
if (!(obj->flags() & object_rep::owner)) return -1;
72+
int d;
73+
return implicit_cast(obj->crep(), LUABIND_TYPEID(T), d);
74+
}
75+
76+
template<class T>
77+
void converter_postcall(lua_State*, T, int) {}
78+
};
79+
80+
template<>
81+
struct adopt_pointer<cpp_to_lua>
82+
{
83+
typedef boost::mpl::bool_<false> is_value_converter;
84+
typedef adopt_pointer type;
85+
86+
template<class T>
87+
void apply(lua_State* L, T* ptr)
88+
{
89+
if (ptr == 0)
90+
{
91+
lua_pushnil(L);
92+
return;
93+
}
94+
95+
// if there is a back_reference, then the
96+
// ownership will be removed from the
97+
// back reference and put on the lua stack.
98+
if (luabind::move_back_reference(L, ptr))
99+
{
100+
object_rep* obj = static_cast<object_rep*>(lua_touserdata(L, -1));
101+
obj->set_flags(obj->flags() | object_rep::owner);
102+
return;
103+
}
104+
105+
class_registry* registry = class_registry::get_registry(L);
106+
class_rep* crep = registry->find_class(LUABIND_TYPEID(T));
107+
108+
/* // create the struct to hold the object
109+
void* obj = lua_newuserdata(L, sizeof(object_rep));
110+
// we send 0 as destructor since we know it will never be called
111+
new(obj) object_rep(ptr, crep, object_rep::owner, delete_s<T>::apply);*/
112+
113+
void* obj;
114+
void* held;
115+
116+
boost::tie(obj,held) = crep->allocate(L);
117+
118+
new(obj) object_rep(ptr, crep, object_rep::owner, delete_s<T>::apply);
119+
120+
// set the meta table
121+
detail::getref(L, crep->metatable_ref());
122+
lua_setmetatable(L, -2);
123+
}
124+
};
125+
126+
template<int N>
127+
// struct adopt_policy : converter_policy_tag
128+
struct adopt_policy : conversion_policy<N>
129+
{
130+
// BOOST_STATIC_CONSTANT(int, index = N);
131+
132+
static void precall(lua_State*, const index_map&) {}
133+
static void postcall(lua_State*, const index_map&) {}
134+
135+
struct only_accepts_nonconst_pointers {};
136+
137+
template<class T, class Direction>
138+
struct apply
139+
{
140+
typedef luabind::detail::is_nonconst_pointer<T> is_nonconst_p;
141+
typedef typename boost::mpl::if_<is_nonconst_p, adopt_pointer<Direction>, only_accepts_nonconst_pointers>::type type;
142+
};
143+
};
144+
145+
}}
146+
147+
namespace luabind
148+
{
149+
template<int N>
150+
detail::policy_cons<detail::adopt_policy<N>, detail::null_type>
151+
adopt(LUABIND_PLACEHOLDER_ARG(N))
152+
{
153+
return detail::policy_cons<detail::adopt_policy<N>, detail::null_type>();
154+
}
155+
}
156+
157+
#endif // LUABIND_ADOPT_POLICY_HPP_INCLUDE
158+
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Copyright (c) 2004 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+
#ifndef LUABIND_BACK_REFERENCE_040510_HPP
24+
#define LUABIND_BACK_REFERENCE_040510_HPP
25+
26+
#include <luabind/lua_include.hpp>
27+
#include <luabind/wrapper_base.hpp>
28+
#include <luabind/detail/has_get_pointer.hpp>
29+
#include <luabind/get_pointer.hpp>
30+
#include <boost/type_traits/is_polymorphic.hpp>
31+
#include <boost/type_traits/is_const.hpp>
32+
#include <boost/mpl/if.hpp>
33+
34+
namespace luabind {
35+
36+
namespace detail
37+
{
38+
namespace mpl = boost::mpl;
39+
40+
template<class T>
41+
wrap_base const* get_back_reference_aux0(T const* p, mpl::true_)
42+
{
43+
return dynamic_cast<wrap_base const*>(p);
44+
}
45+
46+
template<class T>
47+
wrap_base const* get_back_reference_aux0(T const* p, mpl::false_)
48+
{
49+
return 0;
50+
}
51+
52+
template<class T>
53+
wrap_base const* get_back_reference_aux1(T const* p)
54+
{
55+
return get_back_reference_aux0(p, boost::is_polymorphic<T>());
56+
}
57+
58+
template<class T>
59+
wrap_base const* get_back_reference_aux2(T const& x, mpl::true_)
60+
{
61+
return get_back_reference_aux1(get_pointer(x));
62+
}
63+
64+
template<class T>
65+
wrap_base const* get_back_reference_aux2(T const& x, mpl::false_)
66+
{
67+
return get_back_reference_aux1(&x);
68+
}
69+
70+
template<class T>
71+
wrap_base const* get_back_reference(T const& x)
72+
{
73+
return detail::get_back_reference_aux2(
74+
x
75+
, has_get_pointer<T>()
76+
);
77+
}
78+
79+
} // namespace detail
80+
81+
template<class T>
82+
bool get_back_reference(lua_State* L, T const& x)
83+
{
84+
#ifndef LUABIND_NO_RTTI
85+
if (wrap_base const* w = detail::get_back_reference(x))
86+
{
87+
detail::wrap_access::ref(*w).get(L);
88+
return true;
89+
}
90+
#endif
91+
return false;
92+
}
93+
94+
template<class T>
95+
bool move_back_reference(lua_State* L, T const& x)
96+
{
97+
#ifndef LUABIND_NO_RTTI
98+
if (wrap_base* w = const_cast<wrap_base*>(detail::get_back_reference(x)))
99+
{
100+
assert(detail::wrap_access::ref(*w).m_strong_ref.is_valid());
101+
detail::wrap_access::ref(*w).get(L);
102+
detail::wrap_access::ref(*w).m_strong_ref.reset();
103+
return true;
104+
}
105+
#endif
106+
return false;
107+
}
108+
109+
} // namespace luabind
110+
111+
#endif // LUABIND_BACK_REFERENCE_040510_HPP
112+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2004 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+
#ifndef LUABIND_BACK_REFERENCE_FWD_040510_HPP
24+
#define LUABIND_BACK_REFERENCE_FWD_040510_HPP
25+
26+
namespace luabind {
27+
28+
template<class T>
29+
bool get_back_reference(lua_State* L, T const& x);
30+
31+
template<class T>
32+
bool move_back_reference(lua_State* L, T const& x);
33+
34+
} // namespace luabind
35+
36+
#endif // LUABIND_BACK_REFERENCE_FWD_040510_HPP
37+

0 commit comments

Comments
 (0)