aboutsummaryrefslogtreecommitdiff
path: root/ldblib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldblib.c')
-rw-r--r--ldblib.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/ldblib.c b/ldblib.c
index c1e26e0d..32da9697 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.151 2015/11/23 11:29:43 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.152 2018/02/17 19:29:29 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*/
@@ -64,19 +64,24 @@ static int db_setmetatable (lua_State *L) {
64 64
65 65
66static int db_getuservalue (lua_State *L) { 66static int db_getuservalue (lua_State *L) {
67 int n = luaL_optinteger(L, 2, 1);
67 if (lua_type(L, 1) != LUA_TUSERDATA) 68 if (lua_type(L, 1) != LUA_TUSERDATA)
68 lua_pushnil(L); 69 lua_pushnil(L);
69 else 70 else if (lua_getiuservalue(L, 1, n) != LUA_TNONE) {
70 lua_getuservalue(L, 1); 71 lua_pushboolean(L, 1);
72 return 2;
73 }
71 return 1; 74 return 1;
72} 75}
73 76
74 77
75static int db_setuservalue (lua_State *L) { 78static int db_setuservalue (lua_State *L) {
79 int n = luaL_optinteger(L, 3, 1);
76 luaL_checktype(L, 1, LUA_TUSERDATA); 80 luaL_checktype(L, 1, LUA_TUSERDATA);
77 luaL_checkany(L, 2); 81 luaL_checkany(L, 2);
78 lua_settop(L, 2); 82 lua_settop(L, 2);
79 lua_setuservalue(L, 1); 83 if (!lua_setiuservalue(L, 1, n))
84 lua_pushnil(L);
80 return 1; 85 return 1;
81} 86}
82 87