diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-10-24 12:54:05 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-10-24 12:54:05 -0200 |
commit | af00a0772ca1a37f6d8cce5b6c03cc86db0389c3 (patch) | |
tree | 571699f16a48330ffd686ab97839dcdbb1d1449d /ldblib.c | |
parent | 6819c2a98adebaea1a8d1b065364f3b3748072aa (diff) | |
download | lua-af00a0772ca1a37f6d8cce5b6c03cc86db0389c3.tar.gz lua-af00a0772ca1a37f6d8cce5b6c03cc86db0389c3.tar.bz2 lua-af00a0772ca1a37f6d8cce5b6c03cc86db0389c3.zip |
new functions lua_rawsetp/lua_rawgetp
Diffstat (limited to 'ldblib.c')
-rw-r--r-- | ldblib.c | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.129 2011/01/26 16:30:02 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.130 2011/04/08 19:17:36 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 | */ |
@@ -260,8 +260,7 @@ static void hookf (lua_State *L, lua_Debug *ar) { | |||
260 | static const char *const hooknames[] = | 260 | static const char *const hooknames[] = |
261 | {"call", "return", "line", "count", "tail call"}; | 261 | {"call", "return", "line", "count", "tail call"}; |
262 | gethooktable(L); | 262 | gethooktable(L); |
263 | lua_pushlightuserdata(L, L); | 263 | lua_rawgetp(L, -1, L); |
264 | lua_rawget(L, -2); | ||
265 | if (lua_isfunction(L, -1)) { | 264 | if (lua_isfunction(L, -1)) { |
266 | lua_pushstring(L, hooknames[(int)ar->event]); | 265 | lua_pushstring(L, hooknames[(int)ar->event]); |
267 | if (ar->currentline >= 0) | 266 | if (ar->currentline >= 0) |
@@ -308,9 +307,8 @@ static int db_sethook (lua_State *L) { | |||
308 | func = hookf; mask = makemask(smask, count); | 307 | func = hookf; mask = makemask(smask, count); |
309 | } | 308 | } |
310 | gethooktable(L); | 309 | gethooktable(L); |
311 | lua_pushlightuserdata(L, L1); | ||
312 | lua_pushvalue(L, arg+1); | 310 | lua_pushvalue(L, arg+1); |
313 | lua_rawset(L, -3); /* set new hook */ | 311 | lua_rawsetp(L, -2, L1); /* set new hook */ |
314 | lua_pop(L, 1); /* remove hook table */ | 312 | lua_pop(L, 1); /* remove hook table */ |
315 | lua_sethook(L1, func, mask, count); /* set hooks */ | 313 | lua_sethook(L1, func, mask, count); /* set hooks */ |
316 | return 0; | 314 | return 0; |
@@ -327,8 +325,7 @@ static int db_gethook (lua_State *L) { | |||
327 | lua_pushliteral(L, "external hook"); | 325 | lua_pushliteral(L, "external hook"); |
328 | else { | 326 | else { |
329 | gethooktable(L); | 327 | gethooktable(L); |
330 | lua_pushlightuserdata(L, L1); | 328 | lua_rawgetp(L, -1, L1); /* get hook */ |
331 | lua_rawget(L, -2); /* get hook */ | ||
332 | lua_remove(L, -2); /* remove hook table */ | 329 | lua_remove(L, -2); /* remove hook table */ |
333 | } | 330 | } |
334 | lua_pushstring(L, unmakemask(mask, buff)); | 331 | lua_pushstring(L, unmakemask(mask, buff)); |