| 207 | |
| 208 | |
| 209 | static int pairsmeta (lua_State *L, const char *method, int iszero, |
| 210 | lua_CFunction iter) { |
| 211 | luaL_checkany(L, 1); |
| 212 | if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */ |
| 213 | lua_pushcfunction(L, iter); /* will return generator, */ |
| 214 | lua_pushvalue(L, 1); /* state, */ |
| 215 | if (iszero) lua_pushinteger(L, 0); /* and initial value */ |
| 216 | else lua_pushnil(L); |
| 217 | } |
| 218 | else { |
| 219 | lua_pushvalue(L, 1); /* argument 'self' to metamethod */ |
| 220 | lua_call(L, 1, 3); /* get 3 values from metamethod */ |
| 221 | } |
| 222 | return 3; |
| 223 | } |
| 224 | |
| 225 | |
| 226 | static int luaB_next (lua_State *L) { |
no test coverage detected