/src/bindings/bind_app.cpp

https://bitbucket.org/vivkin/gam3b00bs/ · C++ · 52 lines · 41 code · 10 blank · 1 comment · 0 complexity · c57a45a0f8e4b6792738344535c12849 MD5 · raw file

  1. #include "common.h"
  2. #include "bind_all.h"
  3. #include "app/app.h"
  4. namespace luab
  5. {
  6. static int bind_app_init( lua_State * L )
  7. {
  8. lua_pushboolean( L, app::init() );
  9. return 1;
  10. }
  11. static int bind_app_term( lua_State * L )
  12. {
  13. app::term();
  14. return 0;
  15. }
  16. static int bind_app_tick( lua_State * L )
  17. {
  18. lua_pushboolean( L, app::tick() );
  19. return 1;
  20. }
  21. static int bind_app_time( lua_State * L )
  22. {
  23. struct app::timings t = app::time();
  24. lua_newtable( L );
  25. lua_pushnumber( L, t.T ); lua_setfield( L, -2, "T" );
  26. lua_pushnumber( L, t.dt); lua_setfield( L, -2, "dt" );
  27. return 1;
  28. }
  29. static const struct luaL_reg funcs[] =
  30. {
  31. { "init", bind_app_init },
  32. { "term", bind_app_term },
  33. { "tick", bind_app_tick },
  34. { "time", bind_app_time },
  35. {0,0}
  36. };
  37. /////////////////////////////////////////////////////////
  38. void bind_app( lua_State * L )
  39. {
  40. luaL_register( L, "app", funcs );
  41. }
  42. }