From 4daae2165d617e57ad1460471f8d902d38abac6e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 11 Dec 1997 15:21:11 -0200 Subject: new API function and built-in "lua_copytagmethods" --- lbuiltin.c | 10 +++++++++- ltm.c | 16 ++++++++++++++-- lua.h | 4 +++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lbuiltin.c b/lbuiltin.c index e48e1d5d..cae7a59c 100644 --- a/lbuiltin.c +++ b/lbuiltin.c @@ -1,5 +1,5 @@ /* -** $Id: lbuiltin.c,v 1.14 1997/12/01 20:30:44 roberto Exp roberto $ +** $Id: lbuiltin.c,v 1.15 1997/12/09 13:35:19 roberto Exp roberto $ ** Built-in functions ** See Copyright Notice in lua.h */ @@ -299,6 +299,13 @@ static void newtag (void) } +static void copytagmethods (void) +{ + lua_pushnumber(lua_copytagmethods(luaL_check_number(1), + luaL_check_number(2))); +} + + static void rawgettable (void) { lua_Object t = luaL_nonnullarg(1); @@ -431,6 +438,7 @@ static struct luaL_reg int_funcs[] = { {"call", luaI_call}, {"collectgarbage", luaI_collectgarbage}, {"dofile", internaldofile}, + {"copytagmethods", copytagmethods}, {"dostring", internaldostring}, {"error", luaI_error}, {"foreach", foreach}, diff --git a/ltm.c b/ltm.c index ac2160ac..ff01f27a 100644 --- a/ltm.c +++ b/ltm.c @@ -1,5 +1,5 @@ /* -** $Id: ltm.c,v 1.9 1997/11/19 18:16:33 roberto Exp roberto $ +** $Id: ltm.c,v 1.10 1997/12/11 14:48:46 roberto Exp roberto $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -46,7 +46,7 @@ static char validevents[NUM_TAGS][IM_N] = { /* ORDER LUA_T, ORDER IM */ }; -static int validevent (lua_Type t, int e) +static int validevent (int t, int e) { /* ORDER LUA_T */ return (t < LUA_T_NIL) ? 1 : validevents[-t][e]; } @@ -95,6 +95,18 @@ void luaT_realtag (int tag) } +int lua_copytagmethods (int tagto, int tagfrom) +{ + int e; + checktag(tagto); + checktag(tagfrom); + for (e=0; e