seqlua

diff seqlualib.h @ 52:3362ec36cb09

Do not automatically assume that functions passed to ipairs are iterators
but require ipairs(func, mode) to have an explicit mode set to "call" or "generator"
author jbe
date Tue Aug 26 21:10:03 2014 +0200 (2014-08-26)
parents 3ff7cec8d3ce
children 92ce3958aca7
line diff
     1.1 --- a/seqlualib.h	Mon Aug 25 12:12:46 2014 +0200
     1.2 +++ b/seqlualib.h	Tue Aug 26 21:10:03 2014 +0200
     1.3 @@ -8,19 +8,23 @@
     1.4    lua_Integer i;
     1.5  } seqlua_Iterator;
     1.6  
     1.7 -extern void seqlua_iterinit(lua_State *L, seqlua_Iterator *iter, int idx);
     1.8 +#define SEQLUA_MODE_NONE      0
     1.9 +#define SEQLUA_MODE_CALL      1
    1.10 +#define SEQLUA_MODE_GENERATOR 2
    1.11 +
    1.12 +extern void seqlua_iterinit(lua_State *L, seqlua_Iterator *iter, int mode, int idx);
    1.13  
    1.14  extern int seqlua_iternext(seqlua_Iterator *iter);
    1.15  
    1.16 -#define seqlua_iterloop(L, iter, idx) \
    1.17 +#define seqlua_iterloop(L, iter, mode, idx) \
    1.18    for ( \
    1.19 -    seqlua_iterinit((L), (iter), (idx)); \
    1.20 +    seqlua_iterinit((L), (iter), (mode), (idx)); \
    1.21      seqlua_iternext(iter); \
    1.22    )
    1.23  
    1.24 -#define seqlua_iterloopauto(L, iter, idx) \
    1.25 +#define seqlua_iterloopauto(L, iter, mode, idx) \
    1.26    for ( \
    1.27 -    seqlua_iterinit((L), (iter), (idx)); \
    1.28 +    seqlua_iterinit((L), (iter), (mode), (idx)); \
    1.29      seqlua_iternext(iter); \
    1.30      lua_pop((L), 1) \
    1.31    )

Impressum / About Us