1
0
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:
ShadowNinja
2013-12-18 16:35:55 -05:00
parent 38d112033b
commit 49cec3f782
18 changed files with 113 additions and 134 deletions

View File

@@ -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;