** Call hook function registered at hook table for the current ** thread (if there is one) */
| 312 | ** thread (if there is one) |
| 313 | */ |
| 314 | static void hookf (lua_State *L, lua_Debug *ar) { |
| 315 | static const char *const hooknames[] = |
| 316 | {"call", "return", "line", "count", "tail call"}; |
| 317 | lua_getfield(L, LUA_REGISTRYINDEX, HOOKKEY); |
| 318 | lua_pushthread(L); |
| 319 | if (lua_rawget(L, -2) == LUA_TFUNCTION) { /* is there a hook function? */ |
| 320 | lua_pushstring(L, hooknames[(int)ar->event]); /* push event name */ |
| 321 | if (ar->currentline >= 0) |
| 322 | lua_pushinteger(L, ar->currentline); /* push current line */ |
| 323 | else lua_pushnil(L); |
| 324 | lua_assert(lua_getinfo(L, "lS", ar)); |
| 325 | lua_call(L, 2, 0); /* call hook function */ |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | |
| 330 | /* |
nothing calls this directly
no test coverage detected