test_shadow.cpp 719 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright Daniel Wallin 2008. 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)
  4. #include "test.hpp"
  5. #include <luabind/luabind.hpp>
  6. using namespace luabind;
  7. struct X
  8. {
  9. void f()
  10. {}
  11. };
  12. struct Y : X
  13. {
  14. void f()
  15. {}
  16. };
  17. void test_main(lua_State* L)
  18. {
  19. module(L) [
  20. class_<X>("X")
  21. .def(constructor<>())
  22. .def("f", &X::f),
  23. class_<Y, X>("Y")
  24. .def(constructor<>())
  25. .def("f", &Y::f)
  26. ];
  27. DOSTRING(L,
  28. "x = X()\n"
  29. "x:f()\n"
  30. );
  31. DOSTRING(L,
  32. "x = Y()\n"
  33. "x:f()\n"
  34. );
  35. }