getFunction() private method

private getFunction ( IntPtr luaState, int index ) : LuaFunction
luaState System.IntPtr
index int
return LuaFunction
示例#1
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
            {
                if (LuaDLL.luaL_loadbuffer(luaState, chunk, name) != 0)
                {
                    ThrowExceptionFromError(oldTop);
                }
            }
            finally { executing = false; }

            LuaFunction 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);
        }
示例#4
0
        public LuaFunction LoadString(string chunk, string name)
        {
            int oldTop = LuaAPI.lua_gettop(L);

            byte[] bt = Encoding.UTF8.GetBytes(chunk);

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

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

            translator.popValues(L, oldTop);
            return(result);
        }
 public object extractGenerated(IntPtr luaState, int stackPos)
 {
     return(CodeGeneration.Instance.GetDelegate(delegateType, translator.getFunction(luaState, stackPos)));
 }
示例#6
0
 private object getAsFunction(IntPtr luaState, int stackPos)
 {
     return(translator.getFunction(luaState, stackPos));
 }
 public object extractGenerated(lua.State L, int index)
 {
     Debug.Assert(translator.interpreter.IsSameLua(L));
     return(CodeGeneration.Instance.GetDelegate(delegateType, translator.getFunction(L, index)));
 }
示例#8
0
 private object getAsFunction(KopiLua.LuaState luaState, int stackPos)
 {
     return(translator.getFunction(luaState, stackPos));
 }
示例#9
0
 object asFunction(lua.State L, int index)
 {
     return(lua.type(L, index) == LUA.T.FUNCTION ? translator.getFunction(L, index) : null);
 }
示例#10
0
 private object getAsFunction(LuaCore.lua_State luaState, int stackPos)
 {
     return(translator.getFunction(luaState, stackPos));
 }