diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-03-26 17:58:11 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-03-26 17:58:11 -0300 |
commit | 064e406f67c0153999a5246deb1d616b06ee9bb0 (patch) | |
tree | f4483ab6ad6d55484829a0d8a27b8afa1768a36e /ldblib.c | |
parent | 5c87f61e6b1567400d2bd8f452939bb948f16dda (diff) | |
download | lua-064e406f67c0153999a5246deb1d616b06ee9bb0.tar.gz lua-064e406f67c0153999a5246deb1d616b06ee9bb0.tar.bz2 lua-064e406f67c0153999a5246deb1d616b06ee9bb0.zip |
no more fenvs!
Diffstat (limited to 'ldblib.c')
-rw-r--r-- | ldblib.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.119 2010/01/06 14:42:35 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.120 2010/02/18 19:18:41 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -44,19 +44,19 @@ static int db_setmetatable (lua_State *L) { | |||
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | static int db_getfenv (lua_State *L) { | 47 | static int db_getenv (lua_State *L) { |
48 | luaL_checkany(L, 1); | 48 | luaL_checktype(L, 1, LUA_TUSERDATA); |
49 | lua_getfenv(L, 1); | 49 | lua_getenv(L, 1); |
50 | return 1; | 50 | return 1; |
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | static int db_setfenv (lua_State *L) { | 54 | static int db_setenv (lua_State *L) { |
55 | luaL_checktype(L, 2, LUA_TTABLE); | 55 | luaL_checktype(L, 1, LUA_TUSERDATA); |
56 | if (!lua_isnoneornil(L, 2)) | ||
57 | luaL_checktype(L, 2, LUA_TTABLE); | ||
56 | lua_settop(L, 2); | 58 | lua_settop(L, 2); |
57 | if (lua_setfenv(L, 1) == 0) | 59 | lua_setenv(L, 1); |
58 | luaL_error(L, LUA_QL("setfenv") | ||
59 | " cannot change environment of given object"); | ||
60 | return 1; | 60 | return 1; |
61 | } | 61 | } |
62 | 62 | ||
@@ -367,7 +367,7 @@ static int db_traceback (lua_State *L) { | |||
367 | 367 | ||
368 | static const luaL_Reg dblib[] = { | 368 | static const luaL_Reg dblib[] = { |
369 | {"debug", db_debug}, | 369 | {"debug", db_debug}, |
370 | {"getfenv", db_getfenv}, | 370 | {"getenv", db_getenv}, |
371 | {"gethook", db_gethook}, | 371 | {"gethook", db_gethook}, |
372 | {"getinfo", db_getinfo}, | 372 | {"getinfo", db_getinfo}, |
373 | {"getlocal", db_getlocal}, | 373 | {"getlocal", db_getlocal}, |
@@ -376,7 +376,7 @@ static const luaL_Reg dblib[] = { | |||
376 | {"getupvalue", db_getupvalue}, | 376 | {"getupvalue", db_getupvalue}, |
377 | {"upvaluejoin", db_upvaluejoin}, | 377 | {"upvaluejoin", db_upvaluejoin}, |
378 | {"upvalueid", db_upvalueid}, | 378 | {"upvalueid", db_upvalueid}, |
379 | {"setfenv", db_setfenv}, | 379 | {"setenv", db_setenv}, |
380 | {"sethook", db_sethook}, | 380 | {"sethook", db_sethook}, |
381 | {"setlocal", db_setlocal}, | 381 | {"setlocal", db_setlocal}, |
382 | {"setmetatable", db_setmetatable}, | 382 | {"setmetatable", db_setmetatable}, |