diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-11-16 16:01:28 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-11-16 16:01:28 -0200 |
commit | 566758de79b40ee1e2e8c4b48851d9bea1554e2c (patch) | |
tree | dcefd7cb736094351a0194a2ae4ec285e02ff8f7 | |
parent | 50334faad6349046c207d3d2b130b3c67339011c (diff) | |
download | lua-github-566758de79b40ee1e2e8c4b48851d9bea1554e2c.tar.gz |
'getuservalue' accepts any type of argument
-rw-r--r-- | ldblib.c | 19 |
1 files changed, 8 insertions, 11 deletions
@@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.124 2010/07/25 15:18:19 roberto Exp roberto $ +** $Id: ldblib.c,v 1.125 2010/11/10 18:06:10 roberto Exp roberto $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -44,22 +44,19 @@ static int db_setmetatable (lua_State *L) { } -static void checkudata (lua_State *L, int narg) { - if (lua_type(L, narg) == LUA_TLIGHTUSERDATA) - luaL_argerror(L, narg, "full userdata expected, got light userdata"); - luaL_checktype(L, narg, LUA_TUSERDATA); -} - - static int db_getuservalue (lua_State *L) { - checkudata(L, 1); - lua_getuservalue(L, 1); + if (lua_type(L, 1) != LUA_TUSERDATA) + lua_pushnil(L); + else + lua_getuservalue(L, 1); return 1; } static int db_setuservalue (lua_State *L) { - checkudata(L, 1); + if (lua_type(L, 1) == LUA_TLIGHTUSERDATA) + luaL_argerror(L, 1, "full userdata expected, got light userdata"); + luaL_checktype(L, 1, LUA_TUSERDATA); if (!lua_isnoneornil(L, 2)) luaL_checktype(L, 2, LUA_TTABLE); lua_settop(L, 2); |