mirror of https://github.com/lua/lua
lua_settagmethod does not return old tag method
This commit is contained in:
parent
03770ecfc9
commit
67c1afff59
|
@ -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);
|
||||
|
|
3
liolib.c
3
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 */
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
8
ltests.c
8
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;
|
||||
}
|
||||
|
||||
|
|
7
ltm.c
7
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--;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue