diff options
Diffstat (limited to 'lib/lua/src')
| -rw-r--r-- | lib/lua/src/ldebug.c | 22 | ||||
| -rw-r--r-- | lib/lua/src/lstate.c | 8 | 
2 files changed, 28 insertions, 2 deletions
diff --git a/lib/lua/src/ldebug.c b/lib/lua/src/ldebug.c index b154c1b..4f69bad 100644 --- a/lib/lua/src/ldebug.c +++ b/lib/lua/src/ldebug.c @@ -1,5 +1,5 @@  /* -** $Id: ldebug.c,v 1.5 2004-12-27 22:18:53 pixel Exp $ +** $Id: ldebug.c,v 1.6 2006-02-09 16:59:55 pixel Exp $  ** Debug Interface  ** See Copyright Notice in lua.h  */ @@ -101,6 +101,26 @@ LUA_API lua_CallWrap lua_setcallwrap (lua_State *L, lua_CallWrap func) {  } +LUA_API lua_ThreadHook lua_setcreatehook (lua_State *L, lua_ThreadHook func) { +  lua_ThreadHook old_func; +  lua_lock(L); +  old_func = L->createhook; +  L->createhook = func; +  lua_unlock(L); +  return old_func; +} + + +LUA_API lua_ThreadHook lua_setdestroyhook (lua_State *L, lua_ThreadHook func) { +  lua_ThreadHook old_func; +  lua_lock(L); +  old_func = L->destroyhook; +  L->destroyhook = func; +  lua_unlock(L); +  return old_func; +} + +  LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {    int status;    CallInfo *ci; diff --git a/lib/lua/src/lstate.c b/lib/lua/src/lstate.c index 113a69b..a2618a5 100644 --- a/lib/lua/src/lstate.c +++ b/lib/lua/src/lstate.c @@ -1,5 +1,5 @@  /* -** $Id: lstate.c,v 1.5 2004-12-27 22:18:53 pixel Exp $ +** $Id: lstate.c,v 1.6 2006-02-09 16:59:55 pixel Exp $  ** Global State  ** See Copyright Notice in lua.h  */ @@ -138,6 +138,8 @@ static void preinit_state (lua_State *L) {    L->base_ci = L->ci = NULL;    L->errfunc = 0;    L->callwrap = 0; +  L->createhook = 0; +  L->destroyhook = 0;    setnilvalue(gt(L));  } @@ -167,11 +169,15 @@ lua_State *luaE_newthread (lua_State *L) {    L1->l_G = L->l_G;    stack_init(L1, L);  /* init stack */    setobj2n(gt(L1), gt(L));  /* share table of globals */ +  if (L->createhook) +      L->createhook(L, L1);    return L1;  }  void luaE_freethread (lua_State *L, lua_State *L1) { +  if (L->destroyhook) +      L->destroyhook(L, L1);    luaF_close(L1, L1->stack);  /* close all upvalues for this thread */    lua_assert(L1->openupval == NULL);    freestack(L, L1);  | 
