`panic' function configurable via API
This commit is contained in:
11
lapi.c
11
lapi.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 1.182 2002/04/02 20:43:18 roberto Exp roberto $
|
** $Id: lapi.c,v 1.183 2002/04/05 18:54:31 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -98,6 +98,15 @@ LUA_API int lua_checkstack (lua_State *L, int size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LUA_API lua_CFunction lua_setpanicf (lua_State *L, lua_CFunction panicf) {
|
||||||
|
lua_CFunction old;
|
||||||
|
lua_lock(L);
|
||||||
|
old = G(L)->panic;
|
||||||
|
G(L)->panic = panicf;
|
||||||
|
lua_unlock(L);
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** basic stack manipulation
|
** basic stack manipulation
|
||||||
|
|||||||
5
ldo.c
5
ldo.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 1.169 2002/04/10 12:10:54 roberto Exp roberto $
|
** $Id: ldo.c,v 1.170 2002/04/15 19:34:42 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -501,8 +501,7 @@ void luaD_breakrun (lua_State *L, int errcode) {
|
|||||||
longjmp(L->errorJmp->b, 1);
|
longjmp(L->errorJmp->b, 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (errcode != LUA_ERRMEM && errcode != LUA_ERRERR)
|
G(L)->panic(L);
|
||||||
message(L, "unable to recover; exiting\n");
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
lstate.c
13
lstate.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstate.c,v 1.87 2002/03/11 12:45:00 roberto Exp roberto $
|
** $Id: lstate.c,v 1.88 2002/03/20 12:52:32 roberto Exp roberto $
|
||||||
** Global State
|
** Global State
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -25,6 +25,16 @@
|
|||||||
static void close_state (lua_State *L);
|
static void close_state (lua_State *L);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** you can change this function through the official API
|
||||||
|
** call `lua_setpanicf'
|
||||||
|
*/
|
||||||
|
static int default_panic (lua_State *L) {
|
||||||
|
fprintf(stderr, "unable to recover; exiting\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void stack_init (lua_State *L, lua_State *OL) {
|
static void stack_init (lua_State *L, lua_State *OL) {
|
||||||
L->stack = luaM_newvector(OL, BASIC_STACK_SIZE, TObject);
|
L->stack = luaM_newvector(OL, BASIC_STACK_SIZE, TObject);
|
||||||
L->stacksize = BASIC_STACK_SIZE;
|
L->stacksize = BASIC_STACK_SIZE;
|
||||||
@@ -52,6 +62,7 @@ static void f_luaopen (lua_State *L, void *ud) {
|
|||||||
G(L)->strt.hash = NULL;
|
G(L)->strt.hash = NULL;
|
||||||
G(L)->Mbuffer = NULL;
|
G(L)->Mbuffer = NULL;
|
||||||
G(L)->Mbuffsize = 0;
|
G(L)->Mbuffsize = 0;
|
||||||
|
G(L)->panic = &default_panic;
|
||||||
G(L)->rootproto = NULL;
|
G(L)->rootproto = NULL;
|
||||||
G(L)->rootcl = NULL;
|
G(L)->rootcl = NULL;
|
||||||
G(L)->roottable = NULL;
|
G(L)->roottable = NULL;
|
||||||
|
|||||||
3
lstate.h
3
lstate.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstate.h,v 1.81 2002/03/26 20:46:10 roberto Exp roberto $
|
** $Id: lstate.h,v 1.82 2002/04/10 12:11:07 roberto Exp roberto $
|
||||||
** Global State
|
** Global State
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -112,6 +112,7 @@ typedef struct global_State {
|
|||||||
size_t Mbuffsize; /* size of Mbuffer */
|
size_t Mbuffsize; /* size of Mbuffer */
|
||||||
lu_mem GCthreshold;
|
lu_mem GCthreshold;
|
||||||
lu_mem nblocks; /* number of `bytes' currently allocated */
|
lu_mem nblocks; /* number of `bytes' currently allocated */
|
||||||
|
lua_CFunction panic; /* to be called in unprotected errors */
|
||||||
TString *tmname[TM_N]; /* array with tag-method names */
|
TString *tmname[TM_N]; /* array with tag-method names */
|
||||||
} global_State;
|
} global_State;
|
||||||
|
|
||||||
|
|||||||
4
lua.h
4
lua.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lua.h,v 1.125 2002/03/27 15:30:41 roberto Exp roberto $
|
** $Id: lua.h,v 1.126 2002/04/05 18:54:31 roberto Exp roberto $
|
||||||
** Lua - An Extensible Extension Language
|
** Lua - An Extensible Extension Language
|
||||||
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
|
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
|
||||||
** e-mail: info@lua.org
|
** e-mail: info@lua.org
|
||||||
@@ -100,6 +100,8 @@ LUA_API void lua_close (lua_State *L);
|
|||||||
LUA_API lua_State *lua_newthread (lua_State *L);
|
LUA_API lua_State *lua_newthread (lua_State *L);
|
||||||
LUA_API void lua_closethread (lua_State *L, lua_State *thread);
|
LUA_API void lua_closethread (lua_State *L, lua_State *thread);
|
||||||
|
|
||||||
|
LUA_API lua_CFunction lua_setpanicf (lua_State *L, lua_CFunction panicf);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** basic stack manipulation
|
** basic stack manipulation
|
||||||
|
|||||||
Reference in New Issue
Block a user