Add define that strips extern "C" {} around Lua includes.
[luabind.git] / test / test_class_info.cpp
blob3f7ba8b176541f7c873d4aa54e8b279678d534f6
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/class_info.hpp>
9 struct X
11 void f()
14 int x;
15 int y;
18 void test_main(lua_State* L)
20 using namespace luabind;
22 bind_class_info(L);
24 module(L) [
25 class_<X>("X")
26 .def(constructor<>())
27 .def("f", &X::f)
28 .def_readonly("x", &X::x)
29 .def_readonly("y", &X::y)
32 DOSTRING(L,
33 "x = X()\n"
34 "info = class_info(x)\n"
35 "assert(info.name == 'X')\n"
36 "assert(info.methods['f'] == x.f)\n"
37 "assert(info.methods['__init'] == x.__init)\n"
38 "assert(info.attributes[1] == 'y')\n"
39 "assert(info.attributes[2] == 'x')\n"
40 "info = class_info(2)\n"
41 "assert(info.name == 'number')\n"
42 "assert(#info.methods == 0)\n"
43 "assert(#info.attributes == 0)\n"
44 "names = class_names()\n"
45 "assert(type(names) == 'table')\n"
46 "assert(#names == 2)\n"
47 "assert(names[1] == 'X' or names[2] == 'X')\n"
48 "assert(names[1] == 'class_info_data' or names[2] == 'class_info_data')\n"