diff options
author | ShadowNinja <shadowninja@minetest.net> | 2013-12-18 16:35:55 -0500 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2013-12-18 16:35:55 -0500 |
commit | 49cec3f78240ed6310a9b5dd05ce09a79ed5a12e (patch) | |
tree | 38e8199e49906357939e74b6ed0b00f6f54de976 /src/script/cpp_api/s_base.cpp | |
parent | 38d112033b3ba0ea0360fced334a279576aafc5d (diff) | |
download | dragonfireclient-49cec3f78240ed6310a9b5dd05ce09a79ed5a12e.tar.xz |
Handle LuaErrors in Lua -> C++ calls on LuaJIT
Diffstat (limited to 'src/script/cpp_api/s_base.cpp')
-rw-r--r-- | src/script/cpp_api/s_base.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp index b957dc64f..898271743 100644 --- a/src/script/cpp_api/s_base.cpp +++ b/src/script/cpp_api/s_base.cpp @@ -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; |