diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-11-05 15:26:00 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-11-05 15:26:00 -0200 |
| commit | b7d5f18d71f691df752e220f844ea613a8f6d722 (patch) | |
| tree | 9f9ba3cd43799389c1564be16b7836e09fcf7317 /ldblib.c | |
| parent | 5598b2bc558ba0c755068f21e786d3a6d59eb1ca (diff) | |
| download | lua-github-b7d5f18d71f691df752e220f844ea613a8f6d722.tar.gz | |
api functions to manipulate upvalues do not need to check their
arguments (the caller must check them before calling)
Diffstat (limited to 'ldblib.c')
| -rw-r--r-- | ldblib.c | 24 |
1 files changed, 10 insertions, 14 deletions
@@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.112 2009/09/09 20:32:19 roberto Exp roberto $ +** $Id: ldblib.c,v 1.113 2009/11/05 16:48:31 roberto Exp roberto $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -199,23 +199,10 @@ static int db_setupvalue (lua_State *L) { } -static int db_upvaladdr (lua_State *L) { - void *addr; - int n = luaL_checkint(L, 2); - luaL_checktype(L, 1, LUA_TFUNCTION); - addr = lua_upvaladdr(L, 1, n); - if (addr == NULL) lua_pushnil(L); - else lua_pushlightuserdata(L, addr); - return 1; -} - - static int checkupval (lua_State *L, int argf, int argnup) { lua_Debug ar; int nup = luaL_checkint(L, argnup); luaL_checktype(L, argf, LUA_TFUNCTION); - luaL_argcheck(L, !lua_iscfunction(L, argf), argf, - "cannot join upvalues of a C function"); lua_pushvalue(L, argf); lua_getinfo(L, ">u", &ar); luaL_argcheck(L, 1 <= nup && nup <= ar.nups, argnup, "invalid upvalue index"); @@ -223,9 +210,18 @@ static int checkupval (lua_State *L, int argf, int argnup) { } +static int db_upvaladdr (lua_State *L) { + int n = checkupval(L, 1, 2); + lua_pushlightuserdata(L, lua_upvaladdr(L, 1, n)); + return 1; +} + + static int db_joinupval (lua_State *L) { int n1 = checkupval(L, 1, 2); int n2 = checkupval(L, 3, 4); + luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected"); + luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected"); lua_upvaljoin(L, 1, n1, 3, n2); return 0; } |
