** Resumes a coroutine. Returns the number of results for non-error ** cases or -1 for errors. */
| 30 | ** cases or -1 for errors. |
| 31 | */ |
| 32 | static int auxresume (lua_State *L, lua_State *co, int narg) { |
| 33 | int status, nres; |
| 34 | if (!lua_checkstack(co, narg)) { |
| 35 | lua_pushliteral(L, "too many arguments to resume"); |
| 36 | return -1; /* error flag */ |
| 37 | } |
| 38 | lua_xmove(L, co, narg); |
| 39 | status = lua_resume(co, L, narg, &nres); |
| 40 | if (status == LUA_OK || status == LUA_YIELD) { |
| 41 | if (!lua_checkstack(L, nres + 1)) { |
| 42 | lua_pop(co, nres); /* remove results anyway */ |
| 43 | lua_pushliteral(L, "too many results to resume"); |
| 44 | return -1; /* error flag */ |
| 45 | } |
| 46 | lua_xmove(co, L, nres); /* move yielded values */ |
| 47 | return nres; |
| 48 | } |
| 49 | else { |
| 50 | lua_xmove(co, L, 1); /* move error message */ |
| 51 | return -1; /* error flag */ |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | |
| 56 | static int luaB_coresume (lua_State *L) { |
no test coverage detected