aboutsummaryrefslogtreecommitdiff
path: root/ldblib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldblib.c')
-rw-r--r--ldblib.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/ldblib.c b/ldblib.c
index d5604f51..d3f0bca3 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.35 2001/03/07 18:09:25 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.36 2001/03/26 14:31:49 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*/
@@ -111,15 +111,13 @@ static int setlocal (lua_State *L) {
111 111
112 112
113 113
114/* dummy variables (to define unique addresses) */ 114#define KEY_CALLHOOK l_s("luadblibCallhook")
115static const l_char key1[] = l_s("ab"); 115#define KEY_LINEHOOK l_s("luadblibLinehook")
116#define KEY_CALLHOOK ((void *)key1)
117#define KEY_LINEHOOK ((void *)(key1+1))
118 116
119 117
120static void hookf (lua_State *L, void *key) { 118static void hookf (lua_State *L, const l_char *key) {
121 lua_getregistry(L); 119 lua_getregistry(L);
122 lua_pushuserdata(L, key); 120 lua_pushstring(L, key);
123 lua_gettable(L, -2); 121 lua_gettable(L, -2);
124 if (lua_isfunction(L, -1)) { 122 if (lua_isfunction(L, -1)) {
125 lua_pushvalue(L, -3); /* original argument (below table and function) */ 123 lua_pushvalue(L, -3); /* original argument (below table and function) */
@@ -143,7 +141,7 @@ static void linef (lua_State *L, lua_Debug *ar) {
143} 141}
144 142
145 143
146static void sethook (lua_State *L, void *key, lua_Hook hook, 144static void sethook (lua_State *L, const l_char *key, lua_Hook hook,
147 lua_Hook (*sethookf)(lua_State * L, lua_Hook h)) { 145 lua_Hook (*sethookf)(lua_State * L, lua_Hook h)) {
148 lua_settop(L, 1); 146 lua_settop(L, 1);
149 if (lua_isnil(L, 1)) 147 if (lua_isnil(L, 1))
@@ -153,7 +151,7 @@ static void sethook (lua_State *L, void *key, lua_Hook hook,
153 else 151 else
154 luaL_argerror(L, 1, l_s("function expected")); 152 luaL_argerror(L, 1, l_s("function expected"));
155 lua_getregistry(L); 153 lua_getregistry(L);
156 lua_pushuserdata(L, key); 154 lua_pushstring(L, key);
157 lua_pushvalue(L, -1); /* dup key */ 155 lua_pushvalue(L, -1); /* dup key */
158 lua_gettable(L, -3); /* get old value */ 156 lua_gettable(L, -3); /* get old value */
159 lua_pushvalue(L, -2); /* key (again) */ 157 lua_pushvalue(L, -2); /* key (again) */