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