Teach adopt() to hold the adopted pointer in custom pointer type.
[luabind.git] / test / test_adopt_wrapper.cpp
blob436934fc06dc1a86414dbd078bb9c29a9ae5b4f8
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)
5 #include "test.hpp"
6 #include <luabind/luabind.hpp>
7 #include <luabind/adopt_policy.hpp>
9 struct X
11 virtual ~X()
15 struct X_wrap : X, luabind::wrap_base
16 {};
18 X* make()
20 return new X;
23 void take(X* p)
25 delete p;
28 void test_main(lua_State* L)
30 using namespace luabind;
32 module(L) [
33 class_<X, X_wrap>("X"),
34 def("make", &make, adopt(result)),
35 def("take", &take, adopt(_1))
38 DOSTRING(L,
39 "take(make())\n"