** Call a hook for the given event. Make sure there is a hook to be ** called. (Both 'L->hook' and 'L->hookmask', which triggers this ** function, can be changed asynchronously by signals.) */
| 251 | ** function, can be changed asynchronously by signals.) |
| 252 | */ |
| 253 | void luaD_hook (lua_State *L, int event, int line) { |
| 254 | lua_Hook hook = L->hook; |
| 255 | if (hook && L->allowhook) { /* make sure there is a hook */ |
| 256 | CallInfo *ci = L->ci; |
| 257 | ptrdiff_t top = savestack(L, L->top); |
| 258 | ptrdiff_t ci_top = savestack(L, ci->top); |
| 259 | lua_Debug ar; |
| 260 | ar.event = event; |
| 261 | ar.currentline = line; |
| 262 | ar.i_ci = ci; |
| 263 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ |
| 264 | ci->top = L->top + LUA_MINSTACK; |
| 265 | lua_assert(ci->top <= L->stack_last); |
| 266 | L->allowhook = 0; /* cannot call hooks inside a hook */ |
| 267 | ci->callstatus |= CIST_HOOKED; |
| 268 | lua_unlock(L); |
| 269 | (*hook)(L, &ar); |
| 270 | lua_lock(L); |
| 271 | lua_assert(!L->allowhook); |
| 272 | L->allowhook = 1; |
| 273 | ci->top = restorestack(L, ci_top); |
| 274 | L->top = restorestack(L, top); |
| 275 | ci->callstatus &= ~CIST_HOOKED; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | |
| 280 | static void callhook (lua_State *L, CallInfo *ci) { |
no outgoing calls
no test coverage detected