| 176 | |
| 177 | |
| 178 | static int pairsmeta (lua_State *L, const char *method, int iszero, |
| 179 | lua_CFunction iter) { |
| 180 | if (!luaL_getmetafield(L, 1, method)) { /* no metamethod? */ |
| 181 | luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */ |
| 182 | lua_pushcfunction(L, iter); /* will return generator, */ |
| 183 | lua_pushvalue(L, 1); /* state, */ |
| 184 | if (iszero) lua_pushinteger(L, 0); /* and initial value */ |
| 185 | else lua_pushnil(L); |
| 186 | } |
| 187 | else { |
| 188 | lua_pushvalue(L, 1); /* argument 'self' to metamethod */ |
| 189 | lua_call(L, 1, 3); /* get 3 values from metamethod */ |
| 190 | } |
| 191 | return 3; |
| 192 | } |
| 193 | |
| 194 | |
| 195 | static int luaB_next (lua_State *L) { |
no test coverage detected