コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: LuaState.cs プロジェクト: vic910/ChessSoul
        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);
        }
コード例 #3
0
ファイル: LuaState.cs プロジェクト: 253627764/slua
        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);
        }
コード例 #4
0
ファイル: LuaState.cs プロジェクト: LuffyPan/slua
        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);
        }