| 20 | |
| 21 | |
| 22 | static int foreachi (lua_State *L) { |
| 23 | int i; |
| 24 | int n = aux_getn(L, 1); |
| 25 | luaL_checktype(L, 2, LUA_TFUNCTION); |
| 26 | for (i=1; i <= n; i++) { |
| 27 | lua_pushvalue(L, 2); /* function */ |
| 28 | lua_pushinteger(L, i); /* 1st argument */ |
| 29 | lua_rawgeti(L, 1, i); /* 2nd argument */ |
| 30 | lua_call(L, 2, 1); |
| 31 | if (!lua_isnil(L, -1)) |
| 32 | return 1; |
| 33 | lua_pop(L, 1); /* remove nil result */ |
| 34 | } |
| 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | |
| 39 | static int foreach (lua_State *L) { |
nothing calls this directly
no test coverage detected