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-566758de79b40ee1e2e8c4b48851d9bea1554e2c.tar.gz lua-566758de79b40ee1e2e8c4b48851d9bea1554e2c.tar.bz2 lua-566758de79b40ee1e2e8c4b48851d9bea1554e2c.zip | |
'getuservalue' accepts any type of argument
| -rw-r--r-- | ldblib.c | 19 |
1 files changed, 8 insertions, 11 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldblib.c,v 1.124 2010/07/25 15:18:19 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.125 2010/11/10 18:06:10 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,22 +44,19 @@ static int db_setmetatable (lua_State *L) { | |||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | static void checkudata (lua_State *L, int narg) { | ||
| 48 | if (lua_type(L, narg) == LUA_TLIGHTUSERDATA) | ||
| 49 | luaL_argerror(L, narg, "full userdata expected, got light userdata"); | ||
| 50 | luaL_checktype(L, narg, LUA_TUSERDATA); | ||
| 51 | } | ||
| 52 | |||
| 53 | |||
| 54 | static int db_getuservalue (lua_State *L) { | 47 | static int db_getuservalue (lua_State *L) { |
| 55 | checkudata(L, 1); | 48 | if (lua_type(L, 1) != LUA_TUSERDATA) |
| 56 | lua_getuservalue(L, 1); | 49 | lua_pushnil(L); |
| 50 | else | ||
| 51 | lua_getuservalue(L, 1); | ||
| 57 | return 1; | 52 | return 1; |
| 58 | } | 53 | } |
| 59 | 54 | ||
| 60 | 55 | ||
| 61 | static int db_setuservalue (lua_State *L) { | 56 | static int db_setuservalue (lua_State *L) { |
| 62 | checkudata(L, 1); | 57 | if (lua_type(L, 1) == LUA_TLIGHTUSERDATA) |
| 58 | luaL_argerror(L, 1, "full userdata expected, got light userdata"); | ||
| 59 | luaL_checktype(L, 1, LUA_TUSERDATA); | ||
| 63 | if (!lua_isnoneornil(L, 2)) | 60 | if (!lua_isnoneornil(L, 2)) |
| 64 | luaL_checktype(L, 2, LUA_TTABLE); | 61 | luaL_checktype(L, 2, LUA_TTABLE); |
| 65 | lua_settop(L, 2); | 62 | lua_settop(L, 2); |
