diff options
| -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); |
