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 test_main(lua_State
* L
)
44 using namespace luabind
;
46 disable_super_deprecation();
49 class_
<Base
, Base_wrap
>("Base")
50 .def(constructor
<>()),
52 def("take_ownership", &take_ownership
, adopt(_1
))
59 TEST_CHECK(Base::count
== 1);
63 "collectgarbage('collect')\n"
66 TEST_CHECK(Base::count
== 0);
69 "class 'Derived' (Base)\n"
70 " function Derived:__init()\n"
80 TEST_CHECK(Base::count
== 2);
84 "collectgarbage('collect')\n"
85 "collectgarbage('collect')\n"
88 TEST_CHECK(Base::count
== 0);
92 "collectgarbage('collect')\n"
95 TEST_CHECK(Base::count
== 0);
98 "class 'Derived2' (Derived)\n"
99 " function Derived2:__init()\n"
108 TEST_CHECK(Base::count
== 2);
112 "collectgarbage('collect')\n"
113 "collectgarbage('collect')\n"
116 TEST_CHECK(Base::count
== 0);
122 TEST_CHECK(Base::count
== 2);
125 "take_ownership(x)\n"
127 "collectgarbage('collect')\n"
128 "collectgarbage('collect')\n"
131 TEST_CHECK(Base::count
== 2);
136 "collectgarbage('collect')\n"
137 "collectgarbage('collect')\n"
140 TEST_CHECK(Base::count
== 0);
146 TEST_CHECK(Base::count
== 2);
149 "take_ownership(x)\n"
151 "collectgarbage('collect')\n"
152 "collectgarbage('collect')\n"
155 TEST_CHECK(Base::count
== 2);
160 "collectgarbage('collect')\n"
161 "collectgarbage('collect')\n"
164 TEST_CHECK(Base::count
== 0);