diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-20 14:25:30 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-20 14:25:30 -0300 |
commit | b940f09984b47979caf8142046e1fe813e531e3d (patch) | |
tree | cfd6225ce77fce64af8214466a4901ba65947d02 | |
parent | 878979cef7f77f7d77e22f60d2f5c754d6a0327d (diff) | |
download | lua-b940f09984b47979caf8142046e1fe813e531e3d.tar.gz lua-b940f09984b47979caf8142046e1fe813e531e3d.tar.bz2 lua-b940f09984b47979caf8142046e1fe813e531e3d.zip |
no more "compat mode" with 3.2 (deprecated functions)
-rw-r--r-- | lbaselib.c | 68 |
1 files changed, 1 insertions, 67 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.36 2001/06/05 19:41:31 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.37 2001/06/06 18:00:19 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -690,71 +690,6 @@ static int luaB_sort (lua_State *L) { | |||
690 | 690 | ||
691 | 691 | ||
692 | 692 | ||
693 | /* | ||
694 | ** {====================================================== | ||
695 | ** Deprecated functions to manipulate global environment. | ||
696 | ** ======================================================= | ||
697 | */ | ||
698 | |||
699 | |||
700 | #define num_deprecated 4 | ||
701 | |||
702 | static const luaL_reg deprecated_names [num_deprecated] = { | ||
703 | {l_s("foreachvar"), luaB_foreach}, | ||
704 | {l_s("nextvar"), luaB_next}, | ||
705 | {l_s("rawgetglobal"), luaB_rawget}, | ||
706 | {l_s("rawsetglobal"), luaB_rawset} | ||
707 | }; | ||
708 | |||
709 | |||
710 | #ifdef LUA_DEPRECATEDFUNCS | ||
711 | |||
712 | /* | ||
713 | ** call corresponding function inserting `globals' as first argument | ||
714 | */ | ||
715 | static int deprecated_func (lua_State *L) { | ||
716 | lua_insert(L, 1); /* upvalue is the function to be called */ | ||
717 | lua_getglobals(L); | ||
718 | lua_insert(L, 2); /* table of globals is 1o argument */ | ||
719 | lua_rawcall(L, lua_gettop(L)-1, LUA_MULTRET); | ||
720 | return lua_gettop(L); /* return all results */ | ||
721 | } | ||
722 | |||
723 | |||
724 | static void deprecated_funcs (lua_State *L) { | ||
725 | int i; | ||
726 | for (i=0; i<num_deprecated; i++) { | ||
727 | lua_pushcfunction(L, deprecated_names[i].func); | ||
728 | lua_pushcclosure(L, deprecated_func, 1); | ||
729 | lua_setglobal(L, deprecated_names[i].name); | ||
730 | } | ||
731 | } | ||
732 | |||
733 | |||
734 | #else | ||
735 | |||
736 | /* | ||
737 | ** gives an explicit error in any attempt to call a deprecated function | ||
738 | */ | ||
739 | static int deprecated_func (lua_State *L) { | ||
740 | luaL_verror(L, l_s("function `%.20s' is deprecated"), lua_tostring(L, -1)); | ||
741 | return 0; /* to avoid warnings */ | ||
742 | } | ||
743 | |||
744 | |||
745 | static void deprecated_funcs (lua_State *L) { | ||
746 | int i; | ||
747 | for (i=0; i<num_deprecated; i++) { | ||
748 | lua_pushstring(L, deprecated_names[i].name); | ||
749 | lua_pushcclosure(L, deprecated_func, 1); | ||
750 | lua_setglobal(L, deprecated_names[i].name); | ||
751 | } | ||
752 | } | ||
753 | |||
754 | #endif | ||
755 | |||
756 | /* }====================================================== */ | ||
757 | |||
758 | static const luaL_reg base_funcs[] = { | 693 | static const luaL_reg base_funcs[] = { |
759 | {l_s(LUA_ALERT), luaB__ALERT}, | 694 | {l_s(LUA_ALERT), luaB__ALERT}, |
760 | {l_s(LUA_ERRORMESSAGE), luaB__ERRORMESSAGE}, | 695 | {l_s(LUA_ERRORMESSAGE), luaB__ERRORMESSAGE}, |
@@ -804,7 +739,6 @@ LUALIB_API int lua_baselibopen (lua_State *L) { | |||
804 | luaL_openl(L, base_funcs); | 739 | luaL_openl(L, base_funcs); |
805 | lua_pushliteral(L, l_s(LUA_VERSION)); | 740 | lua_pushliteral(L, l_s(LUA_VERSION)); |
806 | lua_setglobal(L, l_s("_VERSION")); | 741 | lua_setglobal(L, l_s("_VERSION")); |
807 | deprecated_funcs(L); | ||
808 | return 0; | 742 | return 0; |
809 | } | 743 | } |
810 | 744 | ||