UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
auxlib.h
Go to the documentation of this file.
1 
2 #ifndef UGDK_SCRIPT_LUA_AUXLIB_H_
3 #define UGDK_SCRIPT_LUA_AUXLIB_H_
4 
5 
6 #include <functional>
7 
10 
11 namespace ugdk {
12 namespace script {
13 namespace lua {
14 
15 class State;
16 
17 class AuxLib {
18 
19  public:
20 
21  explicit AuxLib(lua_State* L) : L_(L) {}
22 
23  static lua_State* newstate() {
24  return luaL_newstate();
25  }
26 
27  void openlibs() { luaL_openlibs(L_); }
28 
29  const Constant loadfile(const char* filename) {
30  return Constant(
31  std::bind(luaL_loadfile, L_, filename)
32  );
33  }
34 
35  const Constant loadstring(const char* str) {
36  return Constant(
37  std::bind(luaL_loadstring, L_, str)
38  );
39  }
40 
41  int checkintteger(int index) { return static_cast<int>(luaL_checkinteger(L_, index)); }
42  const char* checkstring(int index) { return luaL_checkstring(L_, index); }
43 
44  DataID ref(int index) { return luaL_ref(L_, index); }
45 
46  void unref(int index, int n) { luaL_unref(L_, index, n); }
47 
48  private:
49 
50  lua_State* L_;
51 
52 };
53 
54 } /* namespace lua */
55 } /* namespace script */
56 } /* namespace ugdk */
57 
58 
59 #endif /* UGDK_SCRIPT_LUA_AUXLIB_H_ */
static lua_State * newstate()
Definition: auxlib.h:23
int checkintteger(int index)
Definition: auxlib.h:41
Definition: animation.h:11
void openlibs()
Definition: auxlib.h:27
const Constant loadstring(const char *str)
Definition: auxlib.h:35
Represents a constant value from the Lua library.
Definition: header.h:25
void unref(int index, int n)
Definition: auxlib.h:46
Definition: auxlib.h:17
DataID ref(int index)
Definition: auxlib.h:44
struct lua_State lua_State
Definition: defs.h:8
const char * checkstring(int index)
Definition: auxlib.h:42
const Constant loadfile(const char *filename)
Definition: auxlib.h:29
int DataID
Definition: defs.h:20
AuxLib(lua_State *L)
Definition: auxlib.h:21