MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaD_hook

Function luaD_hook

depends/lua/src/ldo.c:253–277  ·  view source on GitHub ↗

** 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.) */

Source from the content-addressed store, hash-verified

251** function, can be changed asynchronously by signals.)
252*/
253void 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
280static void callhook (lua_State *L, CallInfo *ci) {

Callers 4

luaG_traceexecFunction · 0.85
callhookFunction · 0.85
luaD_poscallFunction · 0.85
luaD_precallFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected