MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pairsmeta

Function pairsmeta

freebsd/contrib/openzfs/module/lua/lbaselib.c:178–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176
177
178static int pairsmeta (lua_State *L, const char *method, int iszero,
179 lua_CFunction iter) {
180 if (!luaL_getmetafield(L, 1, method)) { /* no metamethod? */
181 luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */
182 lua_pushcfunction(L, iter); /* will return generator, */
183 lua_pushvalue(L, 1); /* state, */
184 if (iszero) lua_pushinteger(L, 0); /* and initial value */
185 else lua_pushnil(L);
186 }
187 else {
188 lua_pushvalue(L, 1); /* argument 'self' to metamethod */
189 lua_call(L, 1, 3); /* get 3 values from metamethod */
190 }
191 return 3;
192}
193
194
195static int luaB_next (lua_State *L) {

Callers 2

luaB_pairsFunction · 0.85
luaB_ipairsFunction · 0.85

Calls 6

lua_callFunction · 0.85
luaL_getmetafieldFunction · 0.70
luaL_checktypeFunction · 0.70
lua_pushvalueFunction · 0.70
lua_pushintegerFunction · 0.70
lua_pushnilFunction · 0.70

Tested by

no test coverage detected