lua_gettop() private method

private lua_gettop ( IntPtr luaState ) : int
luaState System.IntPtr
return int
Esempio n. 1
0
        public static Tuple <T1, T2, T3> GetTuple <T1, T2, T3>(
            this IntPtr L,
            int index,
            Func <IntPtr, int, T1> getor1,
            Func <IntPtr, int, T2> getor2,
            Func <IntPtr, int, T3> getor3)
        {
            int _lastTopIndex = Lua.lua_gettop(L);

            //Get First Item
            Lua.lua_rawgeti(L, index, 1);
            var value1 = getor1(L, -1);

            Lua.lua_settop(L, _lastTopIndex);

            //Get Second Item
            Lua.lua_rawgeti(L, index, 2);
            var value2 = getor2(L, -1);

            Lua.lua_settop(L, _lastTopIndex);

            //Get Thrird Item
            Lua.lua_rawgeti(L, index, 3);
            var value3 = getor3(L, -1);

            Lua.lua_settop(L, _lastTopIndex);

            return(Tuple.Create(value1, value2, value3));
        }
Esempio n. 2
0
        public static Tuple <T1, T2, T3, T4, T5, T6> GetTuple <T1, T2, T3, T4, T5, T6>(
            this IntPtr L,
            int index,
            Func <IntPtr, int, T1> getor1,
            Func <IntPtr, int, T2> getor2,
            Func <IntPtr, int, T3> getor3,
            Func <IntPtr, int, T4> getor4,
            Func <IntPtr, int, T5> getor5,
            Func <IntPtr, int, T6> getor6)
        {
            int _lastTopIndex = Lua.lua_gettop(L);

            //Get First Item
            Lua.lua_rawgeti(L, index, 1);
            var value1 = getor1(L, -1);

            Lua.lua_settop(L, _lastTopIndex);

            //Get Second Item
            Lua.lua_rawgeti(L, index, 2);
            var value2 = getor2(L, -1);

            Lua.lua_settop(L, _lastTopIndex);

            //Get Thrird Item
            Lua.lua_rawgeti(L, index, 3);
            var value3 = getor3(L, -1);

            Lua.lua_settop(L, _lastTopIndex);

            //Get Forth Item
            Lua.lua_rawgeti(L, index, 4);
            var value4 = getor4(L, -1);

            Lua.lua_settop(L, _lastTopIndex);

            //Get Fifth Item
            Lua.lua_rawgeti(L, index, 5);
            var value5 = getor5(L, -1);

            Lua.lua_settop(L, _lastTopIndex);

            //Get Sixth Item
            Lua.lua_rawgeti(L, index, 6);
            var value6 = getor6(L, -1);

            Lua.lua_settop(L, _lastTopIndex);

            return(Tuple.Create(value1, value2, value3, value4, value5, value6));
        }
Esempio n. 3
0
        public static List <T> GetList <T>(this IntPtr L, int index, Func <IntPtr, int, T> getor)
        {
            var result = new List <T>();
            var size   = Lua.lua_objlen(L, index);

            for (int i = 1; i <= size; i++)
            {
                int _lastTopIndex = Lua.lua_gettop(L);
                Lua.lua_rawgeti(L, index, i);
                var value = getor(L, -1);
                Lua.lua_settop(L, _lastTopIndex);
                result.Add(value);
            }
            return(result);
        }
Esempio n. 4
0
 protected void BeginCall()
 {
     _lastTopIndex = Lua.lua_gettop(_luaState);
     Lua.lua_rawgeti(_luaState, (int)LuaInnerIndex.LUA_REGISTRYINDEX, _luaFunctionRefIndex);
 }