*** empty log message ***
[luabind.git] / test / test_held_type.cpp
blob191017295f33e45e5a0184d581cd355388408ada
1 #include <boost/shared_ptr.hpp>
4 namespace luabind
6 namespace detail
8 template<class T>
9 T* get_pointer(boost::shared_ptr<T>& p) { return p.get(); }
13 #include "test.h"
15 namespace
18 int feedback = 0;
20 struct held_type_test
22 held_type_test() {}
23 ~held_type_test() { feedback = 1; }
26 void tester(held_type_test* t)
28 feedback = 2;
31 } // anonymous namespace
34 bool test_held_type()
36 // This feature is not finished yet
38 using namespace luabind;
40 lua_State* L = lua_open();
41 lua_closer c(L);
42 int top = lua_gettop(L);
44 open(L);
46 function(L, "tester", &tester);
48 class_<held_type_test, boost::shared_ptr<held_type_test> >(L, "held_type_test")
49 .def(constructor<>())
52 object g = get_globals(L);
53 g["test"] = boost::shared_ptr<held_type_test>(new held_type_test());
54 if (dostring(L, "tester(test)")) return false;
55 if (feedback != 2) return false;
56 if (top != lua_gettop(L)) return false;
59 if (feedback != 1) return false;
61 return true;