MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / foreach

Function foreach

deps/lua/src/ltablib.c:39–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38
39static int foreach (lua_State *L) {
40 luaL_checktype(L, 1, LUA_TTABLE);
41 luaL_checktype(L, 2, LUA_TFUNCTION);
42 lua_pushnil(L); /* first key */
43 while (lua_next(L, 1)) {
44 lua_pushvalue(L, 2); /* function */
45 lua_pushvalue(L, -3); /* key */
46 lua_pushvalue(L, -3); /* value */
47 lua_call(L, 2, 1);
48 if (!lua_isnil(L, -1))
49 return 1;
50 lua_pop(L, 2); /* remove value and result */
51 }
52 return 0;
53}
54
55
56static 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