Example #1
0
/*
** 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
}
Example #2
0
/*
** 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
}
Example #3
0
static int luaB_ipairs (lua_State *L) {
  return pairsmeta(L, "__ipairs", 1, lua_upvalueindex(1));
}
Example #4
0
static int luaB_ipairs (lua_State *L) {
  return pairsmeta(L, "__ipairs", 1, ipairsaux);
}
Example #5
0
static int luaB_pairs (lua_State *L) {
  return pairsmeta(L, "__pairs", 0, luaB_next);
}
Example #6
0
static int luaB_ipairs (lua_State *L) {
  return pairsmeta(L, "__ipairs", 1, ipairsaux);
  /* ipairs function from lua 5.2 */
}
Example #7
0
static int luaB_pairs (lua_State *L) {
  /* pairs function from lua 5.2 */
  return pairsmeta(L, "__pairs", 0, luaB_next);
}