From cb370239d589b837e9a079e6f7e5808e3f20003f Mon Sep 17 00:00:00 2001 From: jyelon Date: Tue, 4 Apr 2023 15:50:06 -0400 Subject: [PATCH] First step in making Lua use exceptions properly --- luprex/ext/eris-master/src/ldo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/luprex/ext/eris-master/src/ldo.c b/luprex/ext/eris-master/src/ldo.c index 1117d8f4..f85a1856 100644 --- a/luprex/ext/eris-master/src/ldo.c +++ b/luprex/ext/eris-master/src/ldo.c @@ -50,9 +50,12 @@ #if defined(__cplusplus) && !defined(LUA_USE_LONGJMP) /* C++ exceptions */ -#define LUAI_THROW(L,c) throw(c) +class LuaException {}; +#define LUAI_THROW(L,c) throw(LuaException()) +// Do not call the lua interpreter inside a try-catch block. If you do, +// the intepreter state could be corrupted. #define LUAI_TRY(L,c,a) \ - try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; } +try { a } catch(LuaException e) { if ((c)->status == 0) (c)->status = -1; } #define luai_jmpbuf int /* dummy variable */ #elif defined(LUA_USE_ULONGJMP)