From 33fed251303917f3a9bdc250df6af97f6246731c Mon Sep 17 00:00:00 2001 From: Leonardo Laguna Ruiz Date: Mon, 20 Jul 2020 08:07:09 +0300 Subject: [PATCH] Blocks access to ffi in LuaJIT before the user script is loaded --- src/LuaJITEngine.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/LuaJITEngine.cpp b/src/LuaJITEngine.cpp index dc0dada..2ce826b 100644 --- a/src/LuaJITEngine.cpp +++ b/src/LuaJITEngine.cpp @@ -112,7 +112,10 @@ struct LuaJITEngine : ScriptEngine { << "float *switchLights[" << NUM_ROWS + 1 << "];" << std::endl << "};]]" << std::endl // Declare the function `_castBlock` used to transform `luaBlock` pointer into a LuaJIT cdata - << "function _castBlock(b) return ffi.cast('struct LuaProcessBlock*', b) end"; + << "_ffi_cast = ffi.cast" << std::endl + << "function _castBlock(b) return _ffi_cast('struct LuaProcessBlock*', b) end" << std::endl + // Unload ffi and require + << "ffi = nil; require = nil;" << std::endl; std::string ffi_script = ffi_stream.str(); // Compile the ffi script