|
@@ -283,13 +283,13 @@ LJLIB_CF(debug_setuservalue)
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
|
-static const char KEY_HOOK = 'h';
|
|
|
|
|
|
+#define KEY_HOOK ((void *)0x3004)
|
|
|
|
|
|
static void hookf(lua_State *L, lua_Debug *ar)
|
|
static void hookf(lua_State *L, lua_Debug *ar)
|
|
{
|
|
{
|
|
static const char *const hooknames[] =
|
|
static const char *const hooknames[] =
|
|
{"call", "return", "line", "count", "tail return"};
|
|
{"call", "return", "line", "count", "tail return"};
|
|
- lua_pushlightuserdata(L, (void *)&KEY_HOOK);
|
|
|
|
|
|
+ lua_pushlightuserdata(L, KEY_HOOK);
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
|
if (lua_isfunction(L, -1)) {
|
|
if (lua_isfunction(L, -1)) {
|
|
lua_pushstring(L, hooknames[(int)ar->event]);
|
|
lua_pushstring(L, hooknames[(int)ar->event]);
|
|
@@ -334,7 +334,7 @@ LJLIB_CF(debug_sethook)
|
|
count = luaL_optint(L, arg+3, 0);
|
|
count = luaL_optint(L, arg+3, 0);
|
|
func = hookf; mask = makemask(smask, count);
|
|
func = hookf; mask = makemask(smask, count);
|
|
}
|
|
}
|
|
- lua_pushlightuserdata(L, (void *)&KEY_HOOK);
|
|
|
|
|
|
+ lua_pushlightuserdata(L, KEY_HOOK);
|
|
lua_pushvalue(L, arg+1);
|
|
lua_pushvalue(L, arg+1);
|
|
lua_rawset(L, LUA_REGISTRYINDEX);
|
|
lua_rawset(L, LUA_REGISTRYINDEX);
|
|
lua_sethook(L, func, mask, count);
|
|
lua_sethook(L, func, mask, count);
|
|
@@ -349,7 +349,7 @@ LJLIB_CF(debug_gethook)
|
|
if (hook != NULL && hook != hookf) { /* external hook? */
|
|
if (hook != NULL && hook != hookf) { /* external hook? */
|
|
lua_pushliteral(L, "external hook");
|
|
lua_pushliteral(L, "external hook");
|
|
} else {
|
|
} else {
|
|
- lua_pushlightuserdata(L, (void *)&KEY_HOOK);
|
|
|
|
|
|
+ lua_pushlightuserdata(L, KEY_HOOK);
|
|
lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */
|
|
lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */
|
|
}
|
|
}
|
|
lua_pushstring(L, unmakemask(mask, buff));
|
|
lua_pushstring(L, unmakemask(mask, buff));
|