diff options
-rw-r--r-- | include/BLua.h | 2 | ||||
-rw-r--r-- | lib/BLua.cc | 39 |
2 files changed, 31 insertions, 10 deletions
diff --git a/include/BLua.h b/include/BLua.h index 1ae977f..c12a8b7 100644 --- a/include/BLua.h +++ b/include/BLua.h @@ -78,7 +78,7 @@ class Lua : public Base { void open_dir(); void open_bit(); void open_jit(); - int wrap_open(openlualib_t open) { return open(L); } + int wrap_open(openlualib_t open) { int n = gettop(); int r = open(L); for(remove(n); n <= gettop(); remove(n));} 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); diff --git a/lib/BLua.cc b/lib/BLua.cc index 0a763aa..ba5497a 100644 --- a/lib/BLua.cc +++ b/lib/BLua.cc @@ -545,6 +545,7 @@ Lua::Lua(const Lua & l) throw (GeneralException) { } void Lua::open_base() { + int n = gettop(); luaopen_base(L); push("mkdir"); push(LuaStatics::mkdir); @@ -552,7 +553,19 @@ void Lua::open_base() { push("time"); push(LuaStatics::time); settable(); - lua_pop(L, 1); + push("getenv"); + push(LuaStatics::getenv); + settable(); + push("setenv"); + push(LuaStatics::setenv); + settable(); + push("unsetenv"); + push(LuaStatics::unsetenv); + settable(); + push("sleep"); + push(LuaStatics::sleep); + settable(); + for (remove(n); n <= gettop(); remove(n)); push("mkdir"); push(LuaStatics::mkdir); settable(LUA_GLOBALSINDEX); @@ -574,31 +587,36 @@ void Lua::open_base() { } void Lua::open_table() { + int n = gettop(); luaopen_table(L); - lua_pop(L, 1); + for (remove(n); n <= gettop(); remove(n)); } void Lua::open_io(bool safe) { + int n = gettop(); luaopen_io(L); - lua_pop(L, 1); + for (remove(n); n <= gettop(); remove(n)); } void Lua::open_string() { + int n = gettop(); luaopen_string(L); push("iconv"); push(LuaStatics::iconv); settable(); - lua_pop(L, 1); + for (remove(n); n <= gettop(); remove(n)); } void Lua::open_math() { + int n = gettop(); luaopen_math(L); - lua_pop(L, 1); + for (remove(n); n <= gettop(); remove(n)); } void Lua::open_debug() { + int n = gettop(); luaopen_debug(L); - lua_pop(L, 1); + for (remove(n); n <= gettop(); remove(n)); } extern "C" { @@ -606,18 +624,21 @@ LUALIB_API int (luaopen_dir) (lua_State *L); } void Lua::open_dir() { + int n = gettop(); luaopen_dir(L); - lua_pop(L, 1); + for (remove(n); n <= gettop(); remove(n)); } void Lua::open_jit() { + int n = gettop(); luaopen_jit(L); - lua_pop(L, 1); + for (remove(n); n <= gettop(); remove(n)); } void Lua::open_bit() { + int n = gettop(); luaopen_bit(L); - lua_pop(L, 1); + for (remove(n); n <= gettop(); remove(n)); } void Lua::declarefunc(const String & name, lua_CFunction f, int i) { |