diff options
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.5 2000/09/14 14:09:31 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.6 2000/09/20 12:54:17 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -183,10 +183,8 @@ static int luaB_settagmethod (lua_State *L) { | |||
183 | const char *event = luaL_check_string(L, 2); | 183 | const char *event = luaL_check_string(L, 2); |
184 | luaL_arg_check(L, lua_isfunction(L, 3) || lua_isnil(L, 3), 3, | 184 | luaL_arg_check(L, lua_isfunction(L, 3) || lua_isnil(L, 3), 3, |
185 | "function or nil expected"); | 185 | "function or nil expected"); |
186 | lua_pushnil(L); /* to get its tag */ | 186 | if (strcmp(event, "gc") == 0) |
187 | if (strcmp(event, "gc") == 0 && tag != lua_tag(L, -1)) | ||
188 | lua_error(L, "deprecated use: cannot set the `gc' tag method from Lua"); | 187 | lua_error(L, "deprecated use: cannot set the `gc' tag method from Lua"); |
189 | lua_pop(L, 1); /* remove the nil */ | ||
190 | lua_settagmethod(L, tag, event); | 188 | lua_settagmethod(L, tag, event); |
191 | return 1; | 189 | return 1; |
192 | } | 190 | } |
@@ -197,9 +195,16 @@ static int luaB_gettagmethod (lua_State *L) { | |||
197 | } | 195 | } |
198 | 196 | ||
199 | 197 | ||
198 | static int luaB_gcinfo (lua_State *L) { | ||
199 | lua_pushnumber(L, lua_getgccount(L)); | ||
200 | lua_pushnumber(L, lua_getgcthreshold(L)); | ||
201 | return 2; | ||
202 | } | ||
203 | |||
204 | |||
200 | static int luaB_collectgarbage (lua_State *L) { | 205 | static int luaB_collectgarbage (lua_State *L) { |
201 | lua_pushnumber(L, lua_collectgarbage(L, luaL_opt_int(L, 1, 0))); | 206 | lua_setgcthreshold(L, luaL_opt_int(L, 1, 0)); |
202 | return 1; | 207 | return 0; |
203 | } | 208 | } |
204 | 209 | ||
205 | 210 | ||
@@ -601,6 +606,7 @@ static const struct luaL_reg base_funcs[] = { | |||
601 | {"error", luaB_error}, | 606 | {"error", luaB_error}, |
602 | {"foreach", luaB_foreach}, | 607 | {"foreach", luaB_foreach}, |
603 | {"foreachi", luaB_foreachi}, | 608 | {"foreachi", luaB_foreachi}, |
609 | {"gcinfo", luaB_gcinfo}, | ||
604 | {"getglobal", luaB_getglobal}, | 610 | {"getglobal", luaB_getglobal}, |
605 | {"gettagmethod", luaB_gettagmethod}, | 611 | {"gettagmethod", luaB_gettagmethod}, |
606 | {"globals", luaB_globals}, | 612 | {"globals", luaB_globals}, |