| 168 | |
| 169 | |
| 170 | static int luaB_close (lua_State *L) { |
| 171 | lua_State *co = getco(L); |
| 172 | int status = auxstatus(L, co); |
| 173 | switch (status) { |
| 174 | case COS_DEAD: case COS_YIELD: { |
| 175 | status = lua_closethread(co, L); |
| 176 | if (status == LUA_OK) { |
| 177 | lua_pushboolean(L, 1); |
| 178 | return 1; |
| 179 | } |
| 180 | else { |
| 181 | lua_pushboolean(L, 0); |
| 182 | lua_xmove(co, L, 1); /* move error message */ |
| 183 | return 2; |
| 184 | } |
| 185 | } |
| 186 | default: /* normal or running coroutine */ |
| 187 | return luaL_error(L, "cannot close a %s coroutine", statname[status]); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | |
| 192 | static const luaL_Reg co_funcs[] = { |
nothing calls this directly
no test coverage detected