From 1dbe708aa84f3a1e51daf8d7e2f714e2b02f554b Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 18 Jun 2002 12:19:27 -0300 Subject: new protocol for error handling --- lua.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lua.h') diff --git a/lua.h b/lua.h index 5c1de5f6..fd2856e8 100644 --- a/lua.h +++ b/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.139 2002/06/13 13:39:55 roberto Exp roberto $ +** $Id: lua.h,v 1.140 2002/06/13 13:44:50 roberto Exp roberto $ ** Lua - An Extensible Extension Language ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil ** http://www.lua.org mailto:info@lua.org @@ -29,6 +29,9 @@ #define LUA_MULTRET (-1) +/* index for a traceback function in the registry */ +#define LUA_TRACEBACK "_TRACEBACK" + /* ** pseudo-indices */ @@ -43,6 +46,7 @@ #define LUA_ERRSYNTAX 3 #define LUA_ERRMEM 4 #define LUA_ERRERR 5 +#define LUA_ERRTHROW 6 typedef struct lua_State lua_State; @@ -180,7 +184,7 @@ LUA_API void lua_setmetatable (lua_State *L, int objindex); ** `load' and `call' functions (load and run Lua code) */ LUA_API void lua_upcall (lua_State *L, int nargs, int nresults); -LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errf); +LUA_API int lua_pcall (lua_State *L, int nargs, int nresults); LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data, const char *chunkname); @@ -203,7 +207,7 @@ LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold); ** miscellaneous functions */ -LUA_API int lua_errorobj (lua_State *L); +LUA_API int lua_error (lua_State *L); LUA_API int lua_next (lua_State *L, int index); LUA_API int lua_getn (lua_State *L, int index); @@ -220,8 +224,6 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size); ** =============================================================== */ -#define lua_error(L,s) (lua_pushstring(L, s), lua_errorobj(L)) - #define lua_newpointerbox(L,u) \ (*(void **)(lua_newuserdata(L, sizeof(void *))) = (u)) @@ -275,7 +277,7 @@ LUA_API int lua_pushupvalues (lua_State *L); #define LUA_REFNIL (-1) #define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ - (lua_error(L, "unlocked references are obsolete"), 0)) + (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) #define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) -- cgit v1.2.3-55-g6feb