| 140 | |
| 141 | |
| 142 | static int luaB_collectgarbage (lua_State *L) { |
| 143 | static const char *const opts[] = {"stop", "restart", "collect", |
| 144 | "count", "step", "setpause", "setstepmul", |
| 145 | "setmajorinc", "isrunning", "generational", "incremental", NULL}; |
| 146 | static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, |
| 147 | LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, |
| 148 | LUA_GCSETMAJORINC, LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC}; |
| 149 | int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; |
| 150 | int ex = luaL_optint(L, 2, 0); |
| 151 | int res = lua_gc(L, o, ex); |
| 152 | switch (o) { |
| 153 | case LUA_GCCOUNT: { |
| 154 | int b = lua_gc(L, LUA_GCCOUNTB, 0); |
| 155 | lua_pushnumber(L, res + ((lua_Number)b/1024)); |
| 156 | lua_pushinteger(L, b); |
| 157 | return 2; |
| 158 | } |
| 159 | case LUA_GCSTEP: case LUA_GCISRUNNING: { |
| 160 | lua_pushboolean(L, res); |
| 161 | return 1; |
| 162 | } |
| 163 | default: { |
| 164 | lua_pushinteger(L, res); |
| 165 | return 1; |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | |
| 171 | static int luaB_type (lua_State *L) { |
nothing calls this directly
no test coverage detected