Пример #1
0
        public void PushVVMUIScriptXLuaXLuaDataType(RealStatePtr L, VVMUI.Script.XLua.XLuaDataType val)
        {
            if (VVMUIScriptXLuaXLuaDataType_TypeID == -1)
            {
                bool is_first;
                VVMUIScriptXLuaXLuaDataType_TypeID = getTypeId(L, typeof(VVMUI.Script.XLua.XLuaDataType), out is_first);

                if (VVMUIScriptXLuaXLuaDataType_EnumRef == -1)
                {
                    Utils.LoadCSTable(L, typeof(VVMUI.Script.XLua.XLuaDataType));
                    VVMUIScriptXLuaXLuaDataType_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX);
                }
            }

            if (LuaAPI.xlua_tryget_cachedud(L, (int)val, VVMUIScriptXLuaXLuaDataType_EnumRef) == 1)
            {
                return;
            }

            IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, VVMUIScriptXLuaXLuaDataType_TypeID);

            if (!CopyByValue.Pack(buff, 0, (int)val))
            {
                throw new Exception("pack fail fail for VVMUI.Script.XLua.XLuaDataType ,value=" + val);
            }

            LuaAPI.lua_getref(L, VVMUIScriptXLuaXLuaDataType_EnumRef);
            LuaAPI.lua_pushvalue(L, -2);
            LuaAPI.xlua_rawseti(L, -2, (int)val);
            LuaAPI.lua_pop(L, 1);
        }
Пример #2
0
        public void UpdateVVMUIScriptXLuaXLuaDataType(RealStatePtr L, int index, VVMUI.Script.XLua.XLuaDataType val)
        {
            if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != VVMUIScriptXLuaXLuaDataType_TypeID)
                {
                    throw new Exception("invalid userdata for VVMUI.Script.XLua.XLuaDataType");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                if (!CopyByValue.Pack(buff, 0, (int)val))
                {
                    throw new Exception("pack fail for VVMUI.Script.XLua.XLuaDataType ,value=" + val);
                }
            }

            else
            {
                throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index));
            }
        }
Пример #3
0
        public void Get(RealStatePtr L, int index, out VVMUI.Script.XLua.XLuaDataType val)
        {
            LuaTypes type = LuaAPI.lua_type(L, index);

            if (type == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != VVMUIScriptXLuaXLuaDataType_TypeID)
                {
                    throw new Exception("invalid userdata for VVMUI.Script.XLua.XLuaDataType");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                int    e;
                if (!CopyByValue.UnPack(buff, 0, out e))
                {
                    throw new Exception("unpack fail for VVMUI.Script.XLua.XLuaDataType");
                }
                val = (VVMUI.Script.XLua.XLuaDataType)e;
            }
            else
            {
                val = (VVMUI.Script.XLua.XLuaDataType)objectCasters.GetCaster(typeof(VVMUI.Script.XLua.XLuaDataType))(L, index, null);
            }
        }