aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-10-31 17:40:14 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-10-31 17:40:14 -0200
commit46347d768e571ba9b36581c36d11d2de1dee2cfb (patch)
tree70818496b180f09e98693b9b2cf726bcf559076c /lapi.c
parent36eb6658599f7ec158b819f259eca338ee9a0d1a (diff)
downloadlua-46347d768e571ba9b36581c36d11d2de1dee2cfb.tar.gz
lua-46347d768e571ba9b36581c36d11d2de1dee2cfb.tar.bz2
lua-46347d768e571ba9b36581c36d11d2de1dee2cfb.zip
`ref' support goes to auxlib
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c36
1 files changed, 1 insertions, 35 deletions
diff --git a/lapi.c b/lapi.c
index e941139a..c0212e79 100644
--- a/lapi.c
+++ b/lapi.c
@@ -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
461LUA_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
638LUA_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
648LUA_API int lua_next (lua_State *L, int index) { 614LUA_API int lua_next (lua_State *L, int index) {
649 StkId t; 615 StkId t;
650 int more; 616 int more;