| 282 | } |
| 283 | |
| 284 | static int luaB_pairs (lua_State *L) { |
| 285 | luaL_checkany(L, 1); |
| 286 | if (luaL_getmetafield(L, 1, "__pairs") == LUA_TNIL) { /* no metamethod? */ |
| 287 | lua_pushcfunction(L, luaB_next); /* will return generator, */ |
| 288 | lua_pushvalue(L, 1); /* state, */ |
| 289 | lua_pushnil(L); /* and initial value */ |
| 290 | } |
| 291 | else { |
| 292 | lua_pushvalue(L, 1); /* argument 'self' to metamethod */ |
| 293 | lua_callk(L, 1, 3, 0, pairscont); /* get 3 values from metamethod */ |
| 294 | } |
| 295 | return 3; |
| 296 | } |
| 297 | |
| 298 | |
| 299 | /* |
nothing calls this directly
no test coverage detected