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)); }
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)); }
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); }
public static void Pop(this IntPtr L, int n) { Lua.lua_settop(L, 0 - n - 1); }
protected void EndCall() { Lua.lua_settop(_luaState, _lastTopIndex); }