lua: fix __next, must return 2 values

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-08-10 17:23:08 +02:00
parent a921f60510
commit c4999bd59d
1 changed files with 10 additions and 2 deletions

12
lua.h
View File

@ -315,12 +315,20 @@ luaA_generic_pairs(lua_State *L)
{ \
int idx = lua_tonumber(L, 2); \
if(idx >= 0 && idx < value->len) \
return ctor(L, value->tab[idx]); \
{ \
lua_pushnumber(L, idx + 1); \
ctor(L, value->tab[idx]); \
return 2; \
} \
} \
else if(lua_isnil(L, 2)) \
{ \
if(value->len) \
return ctor(L, value->tab[0]); \
{ \
lua_pushnumber(L, 1); \
ctor(L, value->tab[0]); \
return 2; \
} \
} \
} \
return 0; \