From 2628a424801de3562777a059e599c5e7255965a1 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 13 Sep 2000 16:52:39 -0300 Subject: re-implementation of deprecated functions (wiht compiler option) --- lbaselib.c | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/lbaselib.c b/lbaselib.c index e8cbaca6..e876f1e6 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.2 2000/09/12 13:49:05 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.3 2000/09/12 18:41:43 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -534,31 +534,62 @@ static int luaB_sort (lua_State *L) { */ +#define num_deprecated 4 + +static const struct luaL_reg deprecated_names [num_deprecated] = { + {"foreachvar", luaB_foreach}, + {"nextvar", luaB_next}, + {"rawgetglobal", luaB_rawget}, + {"rawsetglobal", luaB_rawset} +}; + + +#ifdef LUA_DEPRECATETFUNCS + /* -** gives an explicit error in any attempt to call a deprecated function +** call corresponding function inserting `globals' as first argument */ static int deprecated_func (lua_State *L) { - luaL_verror(L, "function `%.20s' is deprecated", luaL_check_string(L, -1)); - return 0; /* to avoid warnings */ + lua_insert(L, 1); /* upvalue is the function to be called */ + lua_getglobals(L); + lua_insert(L, 2); /* table of globals is 1o argument */ + if (lua_call(L, lua_gettop(L)-1, LUA_MULTRET) != 0) + lua_error(L, NULL); + return lua_gettop(L); /* return all results */ } -#define num_deprecated 4 +static void deprecated_funcs (lua_State *L) { + int i; + for (i=0; i