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