mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
Handle LuaErrors in Lua -> C++ calls on LuaJIT
This commit is contained in:
@@ -29,6 +29,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
extern "C" {
|
||||
#include "lualib.h"
|
||||
#if USE_LUAJIT
|
||||
#include "luajit.h"
|
||||
#endif
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -73,6 +76,14 @@ ScriptApiBase::ScriptApiBase()
|
||||
lua_pushlightuserdata(m_luastack, this);
|
||||
lua_setfield(m_luastack, LUA_REGISTRYINDEX, "scriptapi");
|
||||
|
||||
// If we are using LuaJIT 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);
|
||||
#endif
|
||||
|
||||
m_server = 0;
|
||||
m_environment = 0;
|
||||
m_guiengine = 0;
|
||||
|
Reference in New Issue
Block a user