| 255 | |
| 256 | |
| 257 | static int db_sethook (lua_State *L) { |
| 258 | int arg, mask, count; |
| 259 | lua_Hook func; |
| 260 | lua_State *L1 = getthread(L, &arg); |
| 261 | if (lua_isnoneornil(L, arg+1)) { |
| 262 | lua_settop(L, arg+1); |
| 263 | func = NULL; mask = 0; count = 0; /* turn off hooks */ |
| 264 | } |
| 265 | else { |
| 266 | const char *smask = luaL_checkstring(L, arg+2); |
| 267 | luaL_checktype(L, arg+1, LUA_TFUNCTION); |
| 268 | count = luaL_optint(L, arg+3, 0); |
| 269 | func = hookf; mask = makemask(smask, count); |
| 270 | } |
| 271 | gethooktable(L); |
| 272 | lua_pushlightuserdata(L, L1); |
| 273 | lua_pushvalue(L, arg+1); |
| 274 | lua_rawset(L, -3); /* set new hook */ |
| 275 | lua_pop(L, 1); /* remove hook table */ |
| 276 | lua_sethook(L1, func, mask, count); /* set hooks */ |
| 277 | return 0; |
| 278 | } |
| 279 | |
| 280 | |
| 281 | static int db_gethook (lua_State *L) { |
nothing calls this directly
no test coverage detected