| 191 | |
| 192 | |
| 193 | static int luaB_collectgarbage (lua_State *L) { |
| 194 | static const char *const opts[] = {"stop", "restart", "collect", |
| 195 | "count", "step", "setpause", "setstepmul", NULL}; |
| 196 | static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, |
| 197 | LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; |
| 198 | int o = luaL_checkoption(L, 1, "collect", opts); |
| 199 | int ex = luaL_optint(L, 2, 0); |
| 200 | int res = lua_gc(L, optsnum[o], ex); |
| 201 | switch (optsnum[o]) { |
| 202 | case LUA_GCCOUNT: { |
| 203 | int b = lua_gc(L, LUA_GCCOUNTB, 0); |
| 204 | lua_pushnumber(L, res + ((lua_Number)b/1024)); |
| 205 | return 1; |
| 206 | } |
| 207 | case LUA_GCSTEP: { |
| 208 | lua_pushboolean(L, res); |
| 209 | return 1; |
| 210 | } |
| 211 | default: { |
| 212 | lua_pushnumber(L, res); |
| 213 | return 1; |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | |
| 219 | static int luaB_type (lua_State *L) { |
nothing calls this directly
no test coverage detected