示例#1
0
文件: Lua.cs 项目: yarligayan/libTech
        static void CopyTable()
        {
            int Idx = LL.lua_gettop(L);

            LL.lua_newtable(L);

            LL.lua_pushnil(L);
            while (LL.lua_next(L, Idx) != 0)
            {
                LL.lua_pushvalue(L, -2);
                LL.lua_insert(L, -2);
                LL.lua_settable(L, -4);
            }
        }
示例#2
0
文件: Lua.cs 项目: yarligayan/libTech
        public static LuaReference ConvertToTable <T>(T Obj) where T : struct
        {
            Type ObjType = Obj.GetType();

            FieldInfo[] Fields = ObjType.GetFields();

            LL.lua_newtable(L);

            for (int i = 0; i < Fields.Length; i++)
            {
                Advanced.Push(L, Fields[i].GetValue(Obj));
                LL.lua_setfield(L, -2, Fields[i].Name);
            }

            return(new LuaReference(L));
        }
示例#3
0
文件: Lua.cs 项目: yarligayan/libTech
        public static LuaReference CreateNewEnvironment(LuaReference OldEnvironment = null)
        {
            if (OldEnvironment != null)
            {
                OldEnvironment.GetRef();
                CopyTable();
            }
            else
            {
                LL.lua_newtable(L);
            }

            LuaReference Ref = new LuaReference(L);

            if (OldEnvironment != null)
            {
                LL.lua_pop(L, 1);
            }

            return(Ref);
        }