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>
38 ptr(ptr
<U
> const& other
)
53 T
* get_pointer(ptr
<T
> const& x
)
59 ptr
<T
const>* get_const_holder(ptr
<T
>*)
78 TEST_CHECK(ptr_count
== (p
.p
? 2 : 3));
81 void g2(ptr
<X
> const& p
)
83 TEST_CHECK(ptr_count
== (p
.p
? 1 : 2));
88 TEST_CHECK(ptr_count
== 1);
91 void g4(ptr
<X
> const*)
93 TEST_CHECK(ptr_count
== 1);
101 void test_main(lua_State
* L
)
103 using namespace luabind
;
106 class_
<X
, ptr
<X
> >("X"),
121 DOSTRING(L
, "x = get()\n");
122 TEST_CHECK(ptr_count
== 1);
124 DOSTRING(L
, "f1(x)\n");
125 TEST_CHECK(ptr_count
== 1);
127 DOSTRING(L
, "f2(x)\n");
128 TEST_CHECK(ptr_count
== 1);
130 DOSTRING(L
, "f3(x)\n");
131 TEST_CHECK(ptr_count
== 1);
133 DOSTRING(L
, "f4(x)\n");
134 TEST_CHECK(ptr_count
== 1);
136 DOSTRING(L
, "g1(x)\n");
137 TEST_CHECK(ptr_count
== 1);
139 DOSTRING(L
, "g2(x)\n");
140 TEST_CHECK(ptr_count
== 1);
142 DOSTRING(L
, "g3(x)\n");
143 TEST_CHECK(ptr_count
== 1);
145 DOSTRING(L
, "g4(x)\n");
146 TEST_CHECK(ptr_count
== 1);
152 lua_gc(L
, LUA_GCCOLLECT
, 0);
153 TEST_CHECK(ptr_count
== 0);