diff options
| -rw-r--r-- | ldblib.c | 13 |
1 files changed, 10 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldblib.c,v 1.123 2010/07/02 11:38:13 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.124 2010/07/25 15:18:19 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,15 +44,22 @@ 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 | |||
| 47 | static int db_getuservalue (lua_State *L) { | 54 | static int db_getuservalue (lua_State *L) { |
| 48 | luaL_checktype(L, 1, LUA_TUSERDATA); | 55 | checkudata(L, 1); |
| 49 | lua_getuservalue(L, 1); | 56 | lua_getuservalue(L, 1); |
| 50 | return 1; | 57 | return 1; |
| 51 | } | 58 | } |
| 52 | 59 | ||
| 53 | 60 | ||
| 54 | static int db_setuservalue (lua_State *L) { | 61 | static int db_setuservalue (lua_State *L) { |
| 55 | luaL_checktype(L, 1, LUA_TUSERDATA); | 62 | checkudata(L, 1); |
| 56 | if (!lua_isnoneornil(L, 2)) | 63 | if (!lua_isnoneornil(L, 2)) |
| 57 | luaL_checktype(L, 2, LUA_TTABLE); | 64 | luaL_checktype(L, 2, LUA_TTABLE); |
| 58 | lua_settop(L, 2); | 65 | lua_settop(L, 2); |
