diff options
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 36 |
1 files changed, 1 insertions, 35 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.156 2001/10/17 21:17:45 roberto Exp $ | 2 | ** $Id: lapi.c,v 1.157 2001/10/25 19:14:14 roberto Exp $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -458,30 +458,6 @@ LUA_API void lua_setglobals (lua_State *L) { | |||
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | 460 | ||
| 461 | LUA_API int lua_ref (lua_State *L, int lock) { | ||
| 462 | int ref; | ||
| 463 | if (lock == 0) lua_error(L, l_s("unlocked references are obsolete")); | ||
| 464 | if (lua_isnil(L, -1)) { | ||
| 465 | lua_pop(L, 1); | ||
| 466 | return LUA_REFNIL; | ||
| 467 | } | ||
| 468 | lua_rawgeti(L, LUA_REGISTRYINDEX, 0); /* get first free element */ | ||
| 469 | ref = cast(int, lua_tonumber(L, -1)); | ||
| 470 | lua_pop(L, 1); /* remove it from stack */ | ||
| 471 | if (ref != 0) { /* some free element? */ | ||
| 472 | lua_rawgeti(L, LUA_REGISTRYINDEX, ref); /* remove it from list */ | ||
| 473 | lua_rawseti(L, LUA_REGISTRYINDEX, 0); | ||
| 474 | } | ||
| 475 | else { /* no free elements */ | ||
| 476 | ref = lua_getn(L, LUA_REGISTRYINDEX) + 1; /* use next `n' */ | ||
| 477 | lua_pushliteral(L, l_s("n")); | ||
| 478 | lua_pushnumber(L, ref); | ||
| 479 | lua_settable(L, LUA_REGISTRYINDEX); /* n = n+1 */ | ||
| 480 | } | ||
| 481 | lua_rawseti(L, LUA_REGISTRYINDEX, ref); | ||
| 482 | return ref; | ||
| 483 | } | ||
| 484 | |||
| 485 | 461 | ||
| 486 | /* | 462 | /* |
| 487 | ** `do' functions (run Lua code) | 463 | ** `do' functions (run Lua code) |
| @@ -635,16 +611,6 @@ LUA_API void lua_error (lua_State *L, const l_char *s) { | |||
| 635 | } | 611 | } |
| 636 | 612 | ||
| 637 | 613 | ||
| 638 | LUA_API void lua_unref (lua_State *L, int ref) { | ||
| 639 | if (ref >= 0) { | ||
| 640 | lua_rawgeti(L, LUA_REGISTRYINDEX, 0); | ||
| 641 | lua_pushnumber(L, ref); | ||
| 642 | lua_rawseti(L, LUA_REGISTRYINDEX, 0); | ||
| 643 | lua_rawseti(L, LUA_REGISTRYINDEX, ref); | ||
| 644 | } | ||
| 645 | } | ||
| 646 | |||
| 647 | |||
| 648 | LUA_API int lua_next (lua_State *L, int index) { | 614 | LUA_API int lua_next (lua_State *L, int index) { |
| 649 | StkId t; | 615 | StkId t; |
| 650 | int more; | 616 | int more; |
