commit 67c1afff5917b118f3be818dd0df7448d19de877
parent 03770ecfc91718f7a208995adb1f9fd5d8e0c85e
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Tue, 31 Oct 2000 11:10:02 -0200
lua_settagmethod does not return old tag method
Diffstat:
5 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/lbaselib.c b/lbaselib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbaselib.c,v 1.14 2000/10/24 19:19:15 roberto Exp roberto $
+** $Id: lbaselib.c,v 1.15 2000/10/27 16:15:53 roberto Exp roberto $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -184,10 +184,13 @@ static int luaB_settagmethod (lua_State *L) {
"function or nil expected");
if (strcmp(event, "gc") == 0)
lua_error(L, "deprecated use: cannot set the `gc' tag method from Lua");
+ lua_gettagmethod(L, tag, event);
+ lua_pushvalue(L, 3);
lua_settagmethod(L, tag, event);
return 1;
}
+
static int luaB_gettagmethod (lua_State *L) {
int tag = luaL_check_int(L, 1);
const char *event = luaL_check_string(L, 2);
diff --git a/liolib.c b/liolib.c
@@ -1,5 +1,5 @@
/*
-** $Id: liolib.c,v 1.89 2000/10/26 12:53:55 roberto Exp roberto $
+** $Id: liolib.c,v 1.90 2000/10/27 16:15:53 roberto Exp roberto $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -708,7 +708,6 @@ static void openwithcontrol (lua_State *L) {
/* close files when collected */
lua_pushcclosure(L, file_collect, 1); /* pops `ctrl' from stack */
lua_settagmethod(L, ctrl->iotag, "gc");
- lua_pop(L, 1); /* remove tag method returned by previous call */
}
diff --git a/lmathlib.c b/lmathlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmathlib.c,v 1.30 2000/10/26 12:47:05 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.31 2000/10/27 16:15:53 roberto Exp roberto $
** Standard mathematical library
** See Copyright Notice in lua.h
*/
@@ -232,7 +232,6 @@ LUALIB_API void lua_mathlibopen (lua_State *L) {
luaL_openl(L, mathlib);
lua_pushcfunction(L, math_pow);
lua_settagmethod(L, LUA_TNUMBER, "pow");
- lua_pop(L, 1); /* remove result from previous call */
lua_pushnumber(L, PI);
lua_setglobal(L, "PI");
}
diff --git a/ltests.c b/ltests.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltests.c,v 1.52 2000/10/26 12:47:05 roberto Exp roberto $
+** $Id: ltests.c,v 1.53 2000/10/30 16:29:59 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h
*/
@@ -322,8 +322,12 @@ static int doremote (lua_State *L) {
}
static int settagmethod (lua_State *L) {
+ int tag = luaL_check_int(L, 1);
+ const char *event = luaL_check_string(L, 2);
luaL_checkany(L, 3);
- lua_settagmethod(L, luaL_check_int(L, 1), luaL_check_string(L, 2));
+ lua_gettagmethod(L, tag, event);
+ lua_pushvalue(L, 3);
+ lua_settagmethod(L, tag, event);
return 1;
}
diff --git a/ltm.c b/ltm.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.c,v 1.54 2000/10/05 13:00:17 roberto Exp roberto $
+** $Id: ltm.c,v 1.55 2000/10/20 16:39:03 roberto Exp roberto $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -141,7 +141,6 @@ LUA_API void lua_gettagmethod (lua_State *L, int t, const char *event) {
LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) {
- Closure *oldtm;
int e = luaI_checkevent(L, event, t);
checktag(L, t);
if (!luaT_validevent(t, e))
@@ -149,7 +148,6 @@ LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) {
luaT_eventname[e], luaO_typenames[t],
(t == LUA_TTABLE || t == LUA_TUSERDATA) ?
" with default tag" : "");
- oldtm = luaT_gettm(L, t, e);
switch (ttype(L->top - 1)) {
case LUA_TNIL:
luaT_gettm(L, t, e) = NULL;
@@ -160,7 +158,6 @@ LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) {
default:
lua_error(L, "tag method must be a function (or nil)");
}
- clvalue(L->top - 1) = oldtm;
- ttype(L->top - 1) = (oldtm ? LUA_TFUNCTION : LUA_TNIL);
+ L->top--;
}