/* ** This function will use either 'ipairsaux' or 'ipairsaux_raw' to ** traverse a table, depending on whether the table has metamethods ** that can affect the traversal. */ static int luaB_ipairs (lua_State *L) { #if defined(LUA_COMPAT_IPAIRS) return pairsmeta(L, "__ipairs", 1, ipairsaux); #else luaL_checkany(L, 1); lua_pushcfunction(L, ipairsaux); /* iteration function */ lua_pushvalue(L, 1); /* state */ lua_pushinteger(L, 0); /* initial value */ return 3; #endif }
/* ** This function will use either 'ipairsaux' or 'ipairsaux_raw' to ** traverse a table, depending on whether the table has metamethods ** that can affect the traversal. */ static int luaB_ipairs (lua_State *L) { lua_CFunction iter = (luaL_getmetafield(L, 1, "__index") != LUA_TNIL) ? ipairsaux : ipairsaux_raw; #if defined(LUA_COMPAT_IPAIRS) return pairsmeta(L, "__ipairs", 1, iter); #else lua_pushcfunction(L, iter); /* iteration function */ lua_pushvalue(L, 1); /* state */ lua_pushinteger(L, 0); /* initial value */ return 3; #endif }
static int luaB_ipairs (lua_State *L) { return pairsmeta(L, "__ipairs", 1, lua_upvalueindex(1)); }
static int luaB_ipairs (lua_State *L) { return pairsmeta(L, "__ipairs", 1, ipairsaux); }
static int luaB_pairs (lua_State *L) { return pairsmeta(L, "__pairs", 0, luaB_next); }
static int luaB_ipairs (lua_State *L) { return pairsmeta(L, "__ipairs", 1, ipairsaux); /* ipairs function from lua 5.2 */ }
static int luaB_pairs (lua_State *L) { /* pairs function from lua 5.2 */ return pairsmeta(L, "__pairs", 0, luaB_next); }