public bool doBuffer(byte[] bytes, string fn, out object ret) { ret = null; int errfunc = LuaObject.pushTry(L); if (LuaDLL.luaL_loadbuffer(L, bytes, bytes.Length, fn) == 0) { if (LuaDLL.lua_pcall(L, 0, LuaDLL.LUA_MULTRET, errfunc) != 0) { LuaDLL.lua_pop(L, 2); return(false); } LuaDLL.lua_remove(L, errfunc); // pop error function ret = topObjects(errfunc - 1); return(true); } string err = LuaDLL.lua_tostring(L, -1); LuaDLL.lua_pop(L, 2); throw new Exception(err); }
public bool doBuffer(byte[] bytes, string fn, out object ret) { #if GROOT_SLUA_EXTENSION // ensure no utf-8 bom, LuaJIT can read BOM, but Lua cannot! Boolean detected = CheckAndCleanUTF8BOM(bytes); ret = null; m_temp_allow_bg_thread = true; int errfunc = LuaObject.pushTry(L); if (LuaDLL.luaL_loadbuffer(L, bytes, detected ? bytes.Length - 3 : bytes.Length, fn) == 0) #else bytes = CleanUTF8Bom(bytes); ret = null; int errfunc = LuaObject.pushTry(L); if (LuaDLL.luaL_loadbuffer(L, bytes, bytes.Length, fn) == 0) #endif { if (LuaDLL.lua_pcall(L, 0, LuaDLL.LUA_MULTRET, errfunc) != 0) { LuaDLL.lua_pop(L, 2); #if GROOT_SLUA_EXTENSION m_temp_allow_bg_thread = false; #endif return(false); } LuaDLL.lua_remove(L, errfunc); // pop error function ret = topObjects(errfunc - 1); #if GROOT_SLUA_EXTENSION m_temp_allow_bg_thread = false; #endif return(true); } string err = LuaDLL.lua_tostring(L, -1); LuaDLL.lua_pop(L, 2); #if GROOT_SLUA_EXTENSION m_temp_allow_bg_thread = false; #endif throw new Exception(err); }
internal static int loader(IntPtr L) { string fileName = LuaDLL.lua_tostring(L, 1); byte[] bytes = loadFile(fileName); if (bytes != null) { if (LuaDLL.luaL_loadbuffer(L, bytes, bytes.Length, "@" + fileName) == 0) { LuaObject.pushValue(L, true); LuaDLL.lua_insert(L, -2); return(2); } else { string errstr = LuaDLL.lua_tostring(L, -1); return(LuaObject.error(L, errstr)); } } LuaObject.pushValue(L, true); LuaDLL.lua_pushnil(L); return(2); }
public bool doBuffer(byte[] bytes, string fn, out object ret) { ret = null; LuaDLL.lua_pushstdcallcfunction(L, errorReport); int errfunc = LuaDLL.lua_gettop(L); if (LuaDLL.luaL_loadbuffer(L, bytes, bytes.Length, fn) == 0) { if (LuaDLL.lua_pcall(L, 0, LuaDLL.LUA_MULTRET, -2) != 0) { LuaDLL.lua_pop(L, 1); return(false); } LuaDLL.lua_remove(L, errfunc); // pop error function ret = topObjects(errfunc - 1); return(true); } string err = LuaDLL.lua_tostring(L, -1); Debug.LogError(err); LuaDLL.lua_pop(L, 1); return(false); }