MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / foreach

Function foreach

Source/Misc/lua/src/lua.c:14585–14599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14583
14584
14585static int foreach (lua_State *L) {
14586luaL_checktype(L, 1, LUA_TTABLE);
14587luaL_checktype(L, 2, LUA_TFUNCTION);
14588lua_pushnil(L); /* first key */
14589while (lua_next(L, 1)) {
14590lua_pushvalue(L, 2); /* function */
14591lua_pushvalue(L, -3); /* key */
14592lua_pushvalue(L, -3); /* value */
14593lua_call(L, 2, 1);
14594if (!lua_isnil(L, -1))
14595return 1;
14596lua_pop(L, 2); /* remove value and result */
14597}
14598return 0;
14599}
14600
14601
14602static int maxn (lua_State *L) {

Callers

nothing calls this directly

Calls 5

luaL_checktypeFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
lua_pushvalueFunction · 0.85
lua_callFunction · 0.85

Tested by

no test coverage detected