popValues() private method

private popValues ( IntPtr luaState, int oldTop ) : object[]
luaState IntPtr
oldTop int
return object[]
示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name = "chunk"></param>
        /// <param name = "name"></param>
        /// <returns></returns>
        public LuaFunction LoadString(string chunk, string name)
        {
            int oldTop = LuaLib.lua_gettop(luaState);

            executing = true;

            try
            {
                if (LuaLib.luaL_loadbuffer(luaState, chunk, name) != 0)
                {
                    ThrowExceptionFromError(oldTop);
                }
            }
            finally
            {
                executing = false;
            }

            var result = translator.getFunction(luaState, -1);

            translator.popValues(luaState, oldTop);
            return(result);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="chunk"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public LuaFunction LoadString(byte[] chunk, string name, LuaTable env)
        {
            int oldTop = LuaDLL.lua_gettop(L);

            if (LuaDLL.luaL_loadbuffer(L, chunk, chunk.Length, name) != 0)
            {
                ThrowExceptionFromError(oldTop);
            }

            if (env != null)
            {
                env.push(L);
                LuaDLL.lua_setfenv(L, -2);
            }

            LuaFunction result = translator.getFunction(L, -1);

            translator.popValues(L, oldTop);

            return(result);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="chunk"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public LuaFunction LoadString(string chunk, string name)
        {
            int oldTop = LuaDLL.lua_gettop(luaState);

            executing = true;
            try
            {
                // Somehow, on OS X and Linux, we need to use the UTF-8 byte count rather than the string length
                var length = enableLengthWorkaround ? System.Text.Encoding.UTF8.GetByteCount(chunk) : chunk.Length;

                if (LuaDLL.luaL_loadbuffer(luaState, chunk, length, name) != 0)
                {
                    ThrowExceptionFromError(oldTop);
                }
            }
            finally { executing = false; }

            LuaFunction result = translator.getFunction(luaState, -1);

            translator.popValues(luaState, oldTop);

            return(result);
        }