2 #ifndef UGDK_SCRIPT_LUA_STATE_H_
3 #define UGDK_SCRIPT_LUA_STATE_H_
11 #include FROM_TR1(functional)
30 operator bool()
const {
return !!(L_); }
34 void close() { lua_close(L_); L_ = NULL; }
38 int gettop()
const {
return lua_gettop(L_); }
39 void settop(
int index) { lua_settop(L_, index); }
41 void pushvalue (
int index) { lua_pushvalue(L_, index); }
44 void pushinteger (lua_Integer integer) { lua_pushinteger(L_, integer); }
45 void pushnumber (lua_Number number) { lua_pushnumber(L_, number); }
47 void pushstring (
const char* str) { lua_pushstring(L_, str); }
49 lua_pushcclosure(L_, func, n);
56 void pop (
int n) { lua_pop(L_, n); }
58 void insert (
int index) { lua_insert(L_, index); }
59 void remove (
int index) { lua_remove(L_, index); }
63 void getglobal (
const char* name) { lua_getglobal(L_, name); }
64 void getfield (
int index,
const char* k) { lua_getfield(L_, index, k); }
65 void setfield (
int index,
const char* k) { lua_setfield(L_, index, k); }
67 void gettable (
int index) { lua_gettable(L_, index); }
68 void settable (
int index) { lua_settable(L_, index); }
69 void rawgeti (
int index,
int n) { lua_rawgeti(L_, index, n); }
70 void rawseti (
int index,
int n) { lua_rawseti(L_, index, n); }
72 int setfenv(
int index) {
return lua_setfenv(L_, index); }
73 void getfenv(
int index) { lua_getfenv(L_, index); }
75 int getmetatable(
int index) {
return lua_getmetatable(L_, index); }
76 int setmetatable(
int index) {
return lua_setmetatable(L_, index); }
80 return lua_is<T>::primitive(L_, index);
82 bool isnil (
int index)
const {
return !!(lua_isnil(L_, index)); }
83 bool isstring (
int index)
const {
return !!(lua_isstring(L_, index)); }
84 bool isfunction (
int index)
const {
return !!(lua_isfunction(L_, index)); }
85 bool istable (
int index)
const {
return !!(lua_istable(L_, index)); }
89 T
toprimitive(
int n)
const {
return lua_to<T>::primitive(L_, n); }
90 bool toboolean(
int n)
const {
return !!(lua_toboolean(L_, n)); }
91 lua_Integer
tointeger(
int n)
const {
return lua_tointeger(L_, n); }
92 const char*
tostring(
int n)
const {
return lua_tostring(L_, n); }
93 void*
touserdata(
int n)
const {
return lua_touserdata(L_, n); }
95 int type (
int n)
const {
return lua_type(L_, n); }
97 void call (
int nargs,
int nres) { lua_call(L_, nargs, nres); }
100 std::tr1::bind(lua_pcall, L_, nargs, nres, errfunc)
105 return lua_gc(L_, what.
value(), data);