Add test for extending exported classes in Lua.
[luabind.git] / test / test_shared_ptr.cpp
blobc34422baaf42a09d33b3347927a5f78a93c81feb
1 // Copyright Daniel Wallin 2009. 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/shared_ptr_converter.hpp>
9 struct X
11 X(int value)
12 : value(value)
15 int value;
18 int get_value(boost::shared_ptr<X> const& p)
20 return p->value;
23 boost::shared_ptr<X> filter(boost::shared_ptr<X> const& p)
25 return p;
28 void test_main(lua_State* L)
30 using namespace luabind;
32 module(L) [
33 class_<X>("X")
34 .def(constructor<int>()),
35 def("get_value", &get_value),
36 def("filter", &filter)
39 DOSTRING(L,
40 "x = X(1)\n"
41 "assert(get_value(x) == 1)\n"
44 DOSTRING(L,
45 "assert(x == filter(x))\n"