diff options
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.147 2002/12/04 17:29:05 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.148 2002/12/04 17:38:31 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -384,6 +384,24 @@ static int metatable (lua_State *L) { | |||
384 | return 1; | 384 | return 1; |
385 | } | 385 | } |
386 | 386 | ||
387 | |||
388 | static int upvalue (lua_State *L) { | ||
389 | int n = luaL_checkint(L, 2); | ||
390 | luaL_checktype(L, 1, LUA_TFUNCTION); | ||
391 | if (lua_isnone(L, 3)) { | ||
392 | const char *name = lua_getupvalue(L, 1, n); | ||
393 | if (name == NULL) return 0; | ||
394 | lua_pushstring(L, name); | ||
395 | return 2; | ||
396 | } | ||
397 | else { | ||
398 | const char *name = lua_setupvalue(L, 1, n); | ||
399 | lua_pushstring(L, name); | ||
400 | return 1; | ||
401 | } | ||
402 | } | ||
403 | |||
404 | |||
387 | static int newuserdata (lua_State *L) { | 405 | static int newuserdata (lua_State *L) { |
388 | size_t size = luaL_checkint(L, 1); | 406 | size_t size = luaL_checkint(L, 1); |
389 | char *p = cast(char *, lua_newuserdata(L, size)); | 407 | char *p = cast(char *, lua_newuserdata(L, size)); |
@@ -754,6 +772,7 @@ static const struct luaL_reg tests_funcs[] = { | |||
754 | {"d2s", d2s}, | 772 | {"d2s", d2s}, |
755 | {"s2d", s2d}, | 773 | {"s2d", s2d}, |
756 | {"metatable", metatable}, | 774 | {"metatable", metatable}, |
775 | {"upvalue", upvalue}, | ||
757 | {"newuserdata", newuserdata}, | 776 | {"newuserdata", newuserdata}, |
758 | {"pushuserdata", pushuserdata}, | 777 | {"pushuserdata", pushuserdata}, |
759 | {"udataval", udataval}, | 778 | {"udataval", udataval}, |