2 #ifndef UGDK_SCRIPT_LUA_STATE_H_
3 #define UGDK_SCRIPT_LUA_STATE_H_
26 operator bool()
const {
return !!(L_); }
30 void close() { lua_close(L_); L_ =
nullptr; }
34 int gettop()
const {
return lua_gettop(L_); }
35 void settop(
int index) { lua_settop(L_, index); }
37 void pushvalue (
int index) { lua_pushvalue(L_, index); }
40 void pushinteger (lua_Integer integer) { lua_pushinteger(L_, integer); }
41 void pushnumber (lua_Number number) { lua_pushnumber(L_, number); }
43 void pushstring (
const char* str) { lua_pushstring(L_, str); }
45 lua_pushcclosure(L_, func, n);
52 void pop (
int n) { lua_pop(L_, n); }
54 void insert (
int index) { lua_insert(L_, index); }
55 void remove (
int index) { lua_remove(L_, index); }
59 void getglobal (
const char* name) { lua_getglobal(L_, name); }
60 void getfield (
int index,
const char* k) { lua_getfield(L_, index, k); }
61 void setfield (
int index,
const char* k) { lua_setfield(L_, index, k); }
63 void gettable (
int index) { lua_gettable(L_, index); }
64 void settable (
int index) { lua_settable(L_, index); }
65 void rawgeti (
int index,
int n) { lua_rawgeti(L_, index, n); }
66 void rawseti (
int index,
int n) { lua_rawseti(L_, index, n); }
68 int setfenv(
int index) {
return lua_setfenv(L_, index); }
69 void getfenv(
int index) { lua_getfenv(L_, index); }
71 int getmetatable(
int index) {
return lua_getmetatable(L_, index); }
72 int setmetatable(
int index) {
return lua_setmetatable(L_, index); }
76 return lua_is<T>::primitive(L_, index);
78 bool isnil (
int index)
const {
return !!(lua_isnil(L_, index)); }
79 bool isstring (
int index)
const {
return !!(lua_isstring(L_, index)); }
80 bool isfunction (
int index)
const {
return !!(lua_isfunction(L_, index)); }
81 bool istable (
int index)
const {
return !!(lua_istable(L_, index)); }
85 T
toprimitive(
int n)
const {
return lua_to<T>::primitive(L_, n); }
86 bool toboolean(
int n)
const {
return !!(lua_toboolean(L_, n)); }
87 lua_Integer
tointeger(
int n)
const {
return lua_tointeger(L_, n); }
88 const char*
tostring(
int n)
const {
return lua_tostring(L_, n); }
89 void*
touserdata(
int n)
const {
return lua_touserdata(L_, n); }
91 int type (
int n)
const {
return lua_type(L_, n); }
93 void call (
int nargs,
int nres) { lua_call(L_, nargs, nres); }
96 std::bind(lua_pcall, L_, nargs, nres, errfunc)
101 return lua_gc(L_, what.
value(), data);
State(lua_State *L)
Definition: state.h:22
void pushboolean(bool b)
Definition: state.h:39
void * touserdata(int n) const
Definition: state.h:89
void getglobal(const char *name)
Definition: state.h:59
void pushcfunction(lua_CFunction func, int n=0)
Definition: state.h:44
void getfield(int index, const char *k)
Definition: state.h:60
void newtable()
Definition: state.h:57
int type(int n) const
Definition: state.h:91
int getmetatable(int index)
Definition: state.h:71
void pushnil()
Definition: state.h:38
bool isfunction(int index) const
Definition: state.h:80
void close()
Definition: state.h:30
bool isprimitive(int index) const
Definition: state.h:75
void gettable(int index)
Definition: state.h:63
void settop(int index)
Definition: state.h:35
void getfenv(int index)
Definition: state.h:69
void pushudata(UData ptr)
Definition: state.h:42
const Constant pcall(int nargs, int nres, int errfunc)
Definition: state.h:94
void pushstring(const char *str)
Definition: state.h:43
Definition: animation.h:11
void pushinteger(lua_Integer integer)
Definition: state.h:40
int gc(Constant what, int data)
Definition: state.h:100
T toprimitive(int n) const
Definition: state.h:85
bool isnil(int index) const
Definition: state.h:78
void pushprimitive(T value)
Definition: state.h:50
void rawseti(int index, int n)
Definition: state.h:66
lua_Integer tointeger(int n) const
Definition: state.h:87
void settable(int index)
Definition: state.h:64
Represents a constant value from the Lua library.
Definition: header.h:25
void pushnumber(lua_Number number)
Definition: state.h:41
bool istable(int index) const
Definition: state.h:81
UData AsUData(T *p)
Definition: defs.h:26
void insert(int index)
Definition: state.h:54
void call(int nargs, int nres)
Definition: state.h:93
void pushvalue(int index)
Definition: state.h:37
bool toboolean(int n) const
Definition: state.h:86
void pushudata(T *value)
Definition: state.h:48
int setfenv(int index)
Definition: state.h:68
int gettop() const
Definition: state.h:34
void setfield(int index, const char *k)
Definition: state.h:61
struct lua_State lua_State
Definition: defs.h:8
int(* lua_CFunction)(lua_State *)
Definition: defs.h:9
AuxLib & aux()
Definition: state.h:32
void rawgeti(int index, int n)
Definition: state.h:65
int value()
Definition: header.h:38
void pop(int n)
Definition: state.h:52
void * UData
Definition: defs.h:23
const char * tostring(int n) const
Definition: state.h:88
bool isstring(int index) const
Definition: state.h:79
int setmetatable(int index)
Definition: state.h:72