MCPcopy Create free account
hub / github.com/DFHack/dfhack / pairsmeta

Function pairsmeta

depends/lua/src/lbaselib.c:209–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208
209static int pairsmeta (lua_State *L, const char *method, int iszero,
210 lua_CFunction iter) {
211 luaL_checkany(L, 1);
212 if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */
213 lua_pushcfunction(L, iter); /* will return generator, */
214 lua_pushvalue(L, 1); /* state, */
215 if (iszero) lua_pushinteger(L, 0); /* and initial value */
216 else lua_pushnil(L);
217 }
218 else {
219 lua_pushvalue(L, 1); /* argument 'self' to metamethod */
220 lua_call(L, 1, 3); /* get 3 values from metamethod */
221 }
222 return 3;
223}
224
225
226static int luaB_next (lua_State *L) {

Callers 2

luaB_pairsFunction · 0.85
luaB_ipairsFunction · 0.85

Calls 5

luaL_checkanyFunction · 0.85
luaL_getmetafieldFunction · 0.85
lua_pushvalueFunction · 0.85
lua_pushintegerFunction · 0.85
lua_pushnilFunction · 0.85

Tested by

no test coverage detected