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)
6 #include <luabind/luabind.hpp>
7 #include <boost/shared_ptr.hpp>
8 #include <luabind/shared_ptr_converter.hpp>
9 #include <luabind/class_info.hpp>
19 boost::shared_ptr
<Foo
> getFoo() const { return m_foo
; }
20 void setFoo( boost::shared_ptr
<Foo
> foo
) { m_foo
= foo
; }
22 boost::shared_ptr
<Foo
> m_foo
;
25 void test_main(lua_State
* L
)
27 using namespace luabind
;
33 class_
<Foo
, boost::shared_ptr
<Foo
> >( "Foo" )
34 .def( constructor
<>() )
35 .def_readwrite("baz", &Foo::m_baz
),
36 class_
<Bar
, boost::shared_ptr
<Bar
> >( "Bar" )
37 .def( constructor
<>() )
38 .property("fooz", &Bar::getFoo
, &Bar::setFoo
)
39 .def_readwrite("foo", &Bar::m_foo
)
41 dostring( L
, "foo = Foo();");
42 dostring( L
, "foo.baz = 42;");
43 dostring( L
, "x = Bar();");
44 dostring( L
, "x.fooz = foo;");
45 dostring( L
, "print(type(x), class_info(x).name);");
46 dostring( L
, "print(type(x.fooz), class_info(x.fooz).name);");
47 dostring( L
, "print(type(x.foo), class_info(x.foo).name);"); // crashes here);