MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / db_sethook

Function db_sethook

third-party/lua-5.2.4/src/ldblib.c:304–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302
303
304static int db_sethook (lua_State *L) {
305 int arg, mask, count;
306 lua_Hook func;
307 lua_State *L1 = getthread(L, &arg);
308 if (lua_isnoneornil(L, arg+1)) {
309 lua_settop(L, arg+1);
310 func = NULL; mask = 0; count = 0; /* turn off hooks */
311 }
312 else {
313 const char *smask = luaL_checkstring(L, arg+2);
314 luaL_checktype(L, arg+1, LUA_TFUNCTION);
315 count = luaL_optint(L, arg+3, 0);
316 func = hookf; mask = makemask(smask, count);
317 }
318 if (gethooktable(L) == 0) { /* creating hook table? */
319 lua_pushstring(L, "k");
320 lua_setfield(L, -2, "__mode"); /** hooktable.__mode = "k" */
321 lua_pushvalue(L, -1);
322 lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */
323 }
324 checkstack(L, L1, 1);
325 lua_pushthread(L1); lua_xmove(L1, L, 1);
326 lua_pushvalue(L, arg+1);
327 lua_rawset(L, -3); /* set new hook */
328 lua_sethook(L1, func, mask, count); /* set hooks */
329 return 0;
330}
331
332
333static int db_gethook (lua_State *L) {

Callers

nothing calls this directly

Calls 14

gethooktableFunction · 0.85
getthreadFunction · 0.70
lua_settopFunction · 0.70
luaL_checktypeFunction · 0.70
makemaskFunction · 0.70
lua_pushstringFunction · 0.70
lua_setfieldFunction · 0.70
lua_pushvalueFunction · 0.70
lua_setmetatableFunction · 0.70
checkstackFunction · 0.70
lua_pushthreadFunction · 0.70
lua_xmoveFunction · 0.70

Tested by

no test coverage detected