** 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.) */
| 260 | ** function, can be changed asynchronously by signals.) |
| 261 | */ |
| 262 | void luaD_hook (lua_State *L, int event, int line) { |
| 263 | lua_Hook hook = L->hook; |
| 264 | if (hook && L->allowhook) { /* make sure there is a hook */ |
| 265 | CallInfo *ci = L->ci; |
| 266 | ptrdiff_t top = savestack(L, L->top); |
| 267 | ptrdiff_t ci_top = savestack(L, ci->top); |
| 268 | lua_Debug ar; |
| 269 | ar.event = event; |
| 270 | ar.currentline = line; |
| 271 | ar.i_ci = ci; |
| 272 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ |
| 273 | ci->top = L->top + LUA_MINSTACK; |
| 274 | lua_assert(ci->top <= L->stack_last); |
| 275 | L->allowhook = 0; /* cannot call hooks inside a hook */ |
| 276 | ci->callstatus |= CIST_HOOKED; |
| 277 | lua_unlock(L); |
| 278 | (*hook)(L, &ar); |
| 279 | lua_lock(L); |
| 280 | lua_assert(!L->allowhook); |
| 281 | L->allowhook = 1; |
| 282 | ci->top = restorestack(L, ci_top); |
| 283 | L->top = restorestack(L, top); |
| 284 | ci->callstatus &= ~CIST_HOOKED; |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | |
| 289 | static void callhook (lua_State *L, CallInfo *ci) { |
no outgoing calls
no test coverage detected