Ejemplo n.º 1
0
        public object[] DoString(byte[] chunk, string chunkName = "chunk", LuaTable env = null)
        {
#if THREAD_SAFT || HOTFIX_ENABLE
            lock (luaEnvLock)
            {
#endif
            var _L      = L;
            int oldTop  = LuaAPI.lua_gettop(_L);
            int errFunc = LuaAPI.load_error_func(_L, errorFuncRef);
            if (LuaAPI.xluaL_loadbuffer(_L, chunk, chunk.Length, chunkName) == 0)
            {
                if (env != null)
                {
                    env.push(_L);
                    LuaAPI.lua_setfenv(_L, -2);
                }

                if (LuaAPI.lua_pcall(_L, 0, -1, errFunc) == 0)
                {
                    LuaAPI.lua_remove(_L, errFunc);
                    return(translator.popValues(_L, oldTop));
                }
                else
                {
                    ThrowExceptionFromError(oldTop);
                }
            }
            else
            {
                ThrowExceptionFromError(oldTop);
            }

            return(null);

#if THREAD_SAFT || HOTFIX_ENABLE
        }
#endif
        }