diff options
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 25 |
1 files changed, 6 insertions, 19 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.104 2002/11/06 19:08:00 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.105 2002/11/07 15:39:23 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 | */ |
@@ -88,21 +88,6 @@ static int luaB_error (lua_State *L) { | |||
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | static int luaB_getmode (lua_State *L) { | ||
92 | luaL_check_type(L, 1, LUA_TTABLE); | ||
93 | lua_pushstring(L, lua_getmode(L, 1)); | ||
94 | return 1; | ||
95 | } | ||
96 | |||
97 | |||
98 | static int luaB_setmode (lua_State *L) { | ||
99 | luaL_check_type(L, 1, LUA_TTABLE); | ||
100 | lua_setmode(L, 1, luaL_check_string(L, 2)); | ||
101 | lua_settop(L, 1); | ||
102 | return 1; | ||
103 | } | ||
104 | |||
105 | |||
106 | static int luaB_getmetatable (lua_State *L) { | 91 | static int luaB_getmetatable (lua_State *L) { |
107 | luaL_check_any(L, 1); | 92 | luaL_check_any(L, 1); |
108 | if (!lua_getmetatable(L, 1)) { | 93 | if (!lua_getmetatable(L, 1)) { |
@@ -524,8 +509,6 @@ static const luaL_reg base_funcs[] = { | |||
524 | {"setmetatable", luaB_setmetatable}, | 509 | {"setmetatable", luaB_setmetatable}, |
525 | {"getglobals", luaB_getglobals}, | 510 | {"getglobals", luaB_getglobals}, |
526 | {"setglobals", luaB_setglobals}, | 511 | {"setglobals", luaB_setglobals}, |
527 | {"getmode", luaB_getmode}, | ||
528 | {"setmode", luaB_setmode}, | ||
529 | {"next", luaB_next}, | 512 | {"next", luaB_next}, |
530 | {"ipairs", luaB_ipairs}, | 513 | {"ipairs", luaB_ipairs}, |
531 | {"pairs", luaB_pairs}, | 514 | {"pairs", luaB_pairs}, |
@@ -646,7 +629,11 @@ static void base_open (lua_State *L) { | |||
646 | /* `newproxy' needs a weaktable as upvalue */ | 629 | /* `newproxy' needs a weaktable as upvalue */ |
647 | lua_pushliteral(L, "newproxy"); | 630 | lua_pushliteral(L, "newproxy"); |
648 | lua_newtable(L); /* new table `w' */ | 631 | lua_newtable(L); /* new table `w' */ |
649 | lua_setmode(L, -1, "k"); | 632 | lua_pushvalue(L, -1); /* `w' will be its own metatable */ |
633 | lua_setmetatable(L, -2); | ||
634 | lua_pushliteral(L, "__mode"); | ||
635 | lua_pushliteral(L, "k"); | ||
636 | lua_rawset(L, -3); /* metatable(w).__mode = "k" */ | ||
650 | lua_pushcclosure(L, luaB_newproxy, 1); | 637 | lua_pushcclosure(L, luaB_newproxy, 1); |
651 | lua_rawset(L, -3); /* set global `newproxy' */ | 638 | lua_rawset(L, -3); /* set global `newproxy' */ |
652 | lua_rawset(L, -1); /* set global _G */ | 639 | lua_rawset(L, -1); /* set global _G */ |