PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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