mirror of https://github.com/rusefi/lua.git
better error message when light userdata is used instead of a
full userdata
This commit is contained in:
parent
c97aa9485c
commit
1b54197491
13
ldblib.c
13
ldblib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ldblib.c,v 1.123 2010/07/02 11:38:13 roberto Exp roberto $
|
** $Id: ldblib.c,v 1.124 2010/07/25 15:18:19 roberto Exp roberto $
|
||||||
** Interface from Lua to its debug API
|
** Interface from Lua to its debug API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -44,15 +44,22 @@ 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) {
|
static int db_getuservalue (lua_State *L) {
|
||||||
luaL_checktype(L, 1, LUA_TUSERDATA);
|
checkudata(L, 1);
|
||||||
lua_getuservalue(L, 1);
|
lua_getuservalue(L, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int db_setuservalue (lua_State *L) {
|
static int db_setuservalue (lua_State *L) {
|
||||||
luaL_checktype(L, 1, LUA_TUSERDATA);
|
checkudata(L, 1);
|
||||||
if (!lua_isnoneornil(L, 2))
|
if (!lua_isnoneornil(L, 2))
|
||||||
luaL_checktype(L, 2, LUA_TTABLE);
|
luaL_checktype(L, 2, LUA_TTABLE);
|
||||||
lua_settop(L, 2);
|
lua_settop(L, 2);
|
||||||
|
|
Loading…
Reference in New Issue