made the makefiles of the example to use the config-file.
[luabind.git] / test / test_held_type.cpp
blob4f3be210c68fbcb5b4f9f0b76fb83d789579422e
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 LUABIND_ANONYMOUS_FIX 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;
41 lua_State* L = lua_open();
42 lua_closer c(L);
43 int top = lua_gettop(L);
45 open(L);
47 function(L, "tester", &tester);
49 class_<held_type_test, boost::shared_ptr<held_type_test> >("held_type_test")
50 .def(constructor<>())
51 .commit(L)
54 object g = get_globals(L);
55 g["test"] = boost::shared_ptr<held_type_test>(new held_type_test());
56 if (dostring(L, "tester(test)")) return false;
57 if (feedback != 2) return false;
58 if (top != lua_gettop(L)) return false;
61 if (feedback != 1) return false;
63 return true;