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)
6 #include <luabind/luabind.hpp>
7 #include <luabind/adopt_policy.hpp>
27 struct Base_wrap
: Base
, luabind::wrap_base
37 void take_ownership(Base
* p
)
42 void not_null(Base
* p
)
47 void test_main(lua_State
* L
)
49 using namespace luabind
;
51 disable_super_deprecation();
54 class_
<Base
, Base_wrap
>("Base")
55 .def(constructor
<>()),
57 def("take_ownership", &take_ownership
, adopt(_1
)),
58 def("not_null", ¬_null
)
65 TEST_CHECK(Base::count
== 1);
69 "collectgarbage('collect')\n"
72 TEST_CHECK(Base::count
== 0);
75 "class 'Derived' (Base)\n"
76 " function Derived:__init()\n"
86 TEST_CHECK(Base::count
== 2);
90 "collectgarbage('collect')\n"
91 "collectgarbage('collect')\n"
94 TEST_CHECK(Base::count
== 0);
98 "collectgarbage('collect')\n"
101 TEST_CHECK(Base::count
== 0);
104 "class 'Derived2' (Derived)\n"
105 " function Derived2:__init()\n"
114 TEST_CHECK(Base::count
== 2);
118 "collectgarbage('collect')\n"
119 "collectgarbage('collect')\n"
122 TEST_CHECK(Base::count
== 0);
128 TEST_CHECK(Base::count
== 2);
131 "take_ownership(x)\n"
133 "collectgarbage('collect')\n"
134 "collectgarbage('collect')\n"
137 TEST_CHECK(Base::count
== 2);
142 "collectgarbage('collect')\n"
143 "collectgarbage('collect')\n"
146 TEST_CHECK(Base::count
== 0);
152 TEST_CHECK(Base::count
== 2);
155 "take_ownership(x)\n"
157 "collectgarbage('collect')\n"
158 "collectgarbage('collect')\n"
161 TEST_CHECK(Base::count
== 2);
166 "collectgarbage('collect')\n"
167 "collectgarbage('collect')\n"
170 TEST_CHECK(Base::count
== 0);
174 "take_ownership(x)\n"
182 "collectgarbage('collect')\n"
185 TEST_CHECK(Base::count
== 0);