MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaD_hook

Function luaD_hook

extlibs/lua/src/ldo.c:275–306  ·  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 trigger this ** function, can be changed asynchronously by signals.) */

Source from the content-addressed store, hash-verified

273** function, can be changed asynchronously by signals.)
274*/
275void luaD_hook (lua_State *L, int event, int line,
276 int ftransfer, int ntransfer) {
277 lua_Hook hook = L->hook;
278 if (hook && L->allowhook) { /* make sure there is a hook */
279 int mask = CIST_HOOKED;
280 CallInfo *ci = L->ci;
281 ptrdiff_t top = savestack(L, L->top);
282 ptrdiff_t ci_top = savestack(L, ci->top);
283 lua_Debug ar;
284 ar.event = event;
285 ar.currentline = line;
286 ar.i_ci = ci;
287 if (ntransfer != 0) {
288 mask |= CIST_TRAN; /* 'ci' has transfer information */
289 ci->u2.transferinfo.ftransfer = ftransfer;
290 ci->u2.transferinfo.ntransfer = ntransfer;
291 }
292 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
293 if (L->top + LUA_MINSTACK > ci->top)
294 ci->top = L->top + LUA_MINSTACK;
295 L->allowhook = 0; /* cannot call hooks inside a hook */
296 ci->callstatus |= mask;
297 lua_unlock(L);
298 (*hook)(L, &ar);
299 lua_lock(L);
300 lua_assert(!L->allowhook);
301 L->allowhook = 1;
302 ci->top = restorestack(L, ci_top);
303 L->top = restorestack(L, top);
304 ci->callstatus &= ~mask;
305 }
306}
307
308
309/*

Callers 4

luaG_traceexecFunction · 0.85
luaD_hookcallFunction · 0.85
rethookFunction · 0.85
luaD_callFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected