diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/BLua.h | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/include/BLua.h b/include/BLua.h index c12a8b7..1cc74f4 100644 --- a/include/BLua.h +++ b/include/BLua.h @@ -82,21 +82,22 @@ class Lua : public Base { void declarefunc(const String &, lua_CFunction, int = LUA_GLOBALSINDEX); void call(const String &, int = LUA_GLOBALSINDEX, int = 0, int = 0); void call(int = 0, int = 0) throw (GeneralException); - void push() { lua_pushnil(L); } - void push(lua_Number n) { lua_pushnumber(L, n); } - void push(const String & s) { lua_pushlstring(L, s.to_charp(), s.strlen()); } - void push(bool b) { lua_pushboolean(L, b); } + void push() { checkstack(); lua_pushnil(L); } + void push(lua_Number n) { checkstack(); lua_pushnumber(L, n); } + void push(const String & s) { checkstack(); lua_pushlstring(L, s.to_charp(), s.strlen()); } + void push(bool b) { checkstack(); lua_pushboolean(L, b); } void push(const char *, int size = -1); - void push(void * p) { lua_pushlightuserdata(L, p); } - void push(lua_CFunction f, int n = 0) { lua_pushcclosure(L, f, n); } + void push(void * p) { checkstack(); lua_pushlightuserdata(L, p); } + void push(lua_CFunction f, int n = 0) { checkstack(); lua_pushcclosure(L, f, n); } void pop(int n = 1) { lua_pop(L, n); } int next(int t = -2) { lua_next(L, t); } - void copy(int n = -1) { lua_pushvalue(L, n); } + int checkstack(int extra = 1) { return lua_checkstack(L, extra); } + void copy(int n = -1) { checkstack(); lua_pushvalue(L, n); } void remove(int n = 1) { lua_remove(L, n); } - void insert(int n = 1) { lua_insert(L, n); } + void insert(int n = 1) { checkstack(); lua_insert(L, n); } void replace(int n = 1) { lua_replace(L, n); } - void newtable() { lua_newtable(L); } - void * newuser(size_t s) { return lua_newuserdata(L, s); } + void newtable() { checkstack(); lua_newtable(L); } + void * newuser(size_t s) { checkstack(); return lua_newuserdata(L, s); } void settable(int = -3, bool raw = false); void gettable(int = -2, bool raw = false); void setvar() { lua_settable(L, LUA_GLOBALSINDEX); } @@ -138,7 +139,7 @@ class Lua : public Base { static Lua * find(lua_State *) throw (GeneralException); void showstack(int level = M_INFO); void showerror(); - int getmetatable(int i = -1) { return lua_getmetatable(L, i); } + int getmetatable(int i = -1) { checkstack(); return lua_getmetatable(L, i); } int setmetatable(int i = -2) { return lua_setmetatable(L, i); } int sethook(lua_Hook func, int mask, int count) { return lua_sethook(L, func, mask, count); } |