mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Modify PUC Lua to wrap C++ exceptions (#12445)
This commit is contained in:
parent
f916398a54
commit
03428d9825
7 changed files with 105 additions and 4 deletions
|
@ -109,12 +109,14 @@ ScriptApiBase::ScriptApiBase(ScriptingType type):
|
|||
lua_rawseti(m_luastack, LUA_REGISTRYINDEX, CUSTOM_RIDX_BACKTRACE);
|
||||
lua_pop(m_luastack, 1); // pop debug
|
||||
|
||||
// If we are using LuaJIT add a C++ wrapper function to catch
|
||||
// exceptions thrown in Lua -> C++ calls
|
||||
// Add a C++ wrapper function to catch exceptions thrown in Lua -> C++ calls
|
||||
#if USE_LUAJIT
|
||||
lua_pushlightuserdata(m_luastack, (void*) script_exception_wrapper);
|
||||
luaJIT_setmode(m_luastack, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_ON);
|
||||
lua_pop(m_luastack, 1);
|
||||
#else
|
||||
// (This is a custom API from the bundled Lua.)
|
||||
lua_atccall(m_luastack, script_exception_wrapper);
|
||||
#endif
|
||||
|
||||
// Add basic globals
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue