| 261 | |
| 262 | |
| 263 | static int luaB_pairs (lua_State *L) { |
| 264 | luaL_checkany(L, 1); |
| 265 | if (luaL_getmetafield(L, 1, "__pairs") == LUA_TNIL) { /* no metamethod? */ |
| 266 | lua_pushcfunction(L, luaB_next); /* will return generator, */ |
| 267 | lua_pushvalue(L, 1); /* state, */ |
| 268 | lua_pushnil(L); /* and initial value */ |
| 269 | } |
| 270 | else { |
| 271 | lua_pushvalue(L, 1); /* argument 'self' to metamethod */ |
| 272 | lua_call(L, 1, 3); /* get 3 values from metamethod */ |
| 273 | } |
| 274 | return 3; |
| 275 | } |
| 276 | |
| 277 | |
| 278 | /* |
nothing calls this directly
no test coverage detected