public override async Task GenerateCopyIn(
            FileGeneration fg,
            ObjectGeneration objGen,
            TypeGeneration typeGen,
            Accessor frameAccessor,
            Accessor itemAccessor,
            Accessor errorMaskAccessor,
            Accessor translationMaskAccessor)
        {
            var data = typeGen.CustomData[Constants.DataKey] as MutagenFieldData;
            var eType = typeGen as EnumType;
            if (data.HasTrigger)
            {
                fg.AppendLine($"{frameAccessor}.Position += {frameAccessor}.{nameof(MutagenBinaryReadStream.MetaData)}.{nameof(ParsingBundle.Constants)}.{nameof(GameConstants.SubConstants)}.{nameof(RecordHeaderConstants.HeaderLength)};");
            }

            TranslationGeneration.WrapParseCall(
                new TranslationWrapParseArgs()
                {
                    FG = fg,
                    TypeGen = typeGen,
                    TranslatorLine = GetTranslatorInstance(typeGen, getter: true),
                    MaskAccessor = errorMaskAccessor,
                    ItemAccessor = itemAccessor,
                    TranslationMaskAccessor = null,
                    IndexAccessor = typeGen.IndexEnumInt,
                    ExtraArgs = $"reader: {frameAccessor}".AsEnumerable()
                        .And($"length: {(data.HasTrigger ? "contentLength" : eType.ByteLength.ToString())}"),
                    SkipErrorMask = !this.DoErrorMasks
                });
        }
        public override async Task GenerateCopyIn(
            FileGeneration fg,
            ObjectGeneration objGen,
            TypeGeneration typeGen,
            Accessor frameAccessor,
            Accessor itemAccessor,
            Accessor errorMaskAccessor,
            Accessor translationMaskAccessor)
        {
            var data = typeGen.CustomData[Constants.DataKey] as MutagenFieldData;

            if (data.HasTrigger)
            {
                fg.AppendLine($"{frameAccessor}.Position += Constants.SUBRECORD_LENGTH;");
            }

            TranslationGeneration.WrapParseCall(
                new TranslationWrapParseArgs()
            {
                FG                      = fg,
                TypeGen                 = typeGen,
                TranslatorLine          = $"{this.NamespacePrefix}FilePathBinaryTranslation.Instance",
                MaskAccessor            = errorMaskAccessor,
                ItemAccessor            = itemAccessor,
                TranslationMaskAccessor = translationMaskAccessor,
                IndexAccessor           = typeGen.HasIndex ? typeGen.IndexEnumInt : null,
                ExtraArgs               = $"frame: {frameAccessor}{(data.HasTrigger ? ".SpawnWithLength(contentLength)" : "")}".AsEnumerable(),
                SkipErrorMask           = true
            });
        }
Пример #3
0
        public override async Task GenerateCopyIn(
            FileGeneration fg,
            ObjectGeneration objGen,
            TypeGeneration typeGen,
            Accessor frameAccessor,
            Accessor itemAccessor,
            Accessor errorMaskAccessor,
            Accessor translationAccessor)
        {
            FormLinkType linkType = typeGen as FormLinkType;

            if (typeGen.TryGetFieldData(out var data) &&
                data.RecordType.HasValue)
            {
                fg.AppendLine($"{frameAccessor}.Position += {frameAccessor}.{nameof(MutagenBinaryReadStream.MetaData)}.{nameof(ParsingBundle.Constants)}.{nameof(GameConstants.SubConstants)}.{nameof(RecordHeaderConstants.HeaderLength)};");
            }

            TranslationGeneration.WrapParseCall(
                new TranslationWrapParseArgs()
            {
                FG                      = fg,
                TypeGen                 = typeGen,
                TranslatorLine          = $"{this.Namespace}{this.Typename(typeGen)}BinaryTranslation.Instance",
                MaskAccessor            = errorMaskAccessor,
                ItemAccessor            = $"{itemAccessor}",
                TranslationMaskAccessor = null,
                IndexAccessor           = typeGen.HasIndex ? typeGen.IndexEnumInt : null,
                TypeOverride            = linkType.FormIDType == FormLinkType.FormIDTypeEnum.Normal ? "FormKey" : "RecordType",
                DefaultOverride         = linkType.FormIDType == FormLinkType.FormIDTypeEnum.Normal ? "FormKey.Null" : "RecordType.Null",
                ExtraArgs               = $"frame: {frameAccessor}{(data.HasTrigger ? ".SpawnWithLength(contentLength)" : "")}"
                                          .Single()
                                          .ToArray(),
                SkipErrorMask = !this.DoErrorMasks,
            });
        }
Пример #4
0
        public override async Task GenerateCopyIn(
            FileGeneration fg,
            ObjectGeneration objGen,
            TypeGeneration typeGen,
            Accessor frameAccessor,
            Accessor itemAccessor,
            Accessor errorMaskAccessor,
            Accessor translationMaskAccessor)
        {
            var str  = typeGen as StringType;
            var data = typeGen.GetFieldData();

            if (data.HasTrigger)
            {
                fg.AppendLine($"{frameAccessor}.Position += {frameAccessor}.{nameof(MutagenBinaryReadStream.MetaData)}.{nameof(ParsingBundle.Constants)}.{nameof(GameConstants.SubConstants)}.{nameof(RecordHeaderConstants.HeaderLength)};");
            }

            List <string> extraArgs = new List <string>();

            extraArgs.Add($"reader: {frameAccessor}{(data.HasTrigger ? ".SpawnWithLength(contentLength)" : null)}");
            if (str.Translated.HasValue)
            {
                extraArgs.Add($"source: {nameof(StringsSource)}.{str.Translated.Value}");
            }
            extraArgs.Add($"stringBinaryType: {nameof(StringBinaryType)}.{str.BinaryType}");
            switch (str.BinaryType)
            {
            case StringBinaryType.NullTerminate:
                if (!data.HasTrigger)
                {
                    extraArgs.Add("parseWhole: false");
                }
                break;

            default:
                break;
            }

            TranslationGeneration.WrapParseCall(
                new TranslationWrapParseArgs()
            {
                FG                      = fg,
                TypeGen                 = typeGen,
                TranslatorLine          = $"{this.NamespacePrefix}StringBinaryTranslation.Instance",
                MaskAccessor            = errorMaskAccessor,
                ItemAccessor            = itemAccessor,
                TranslationMaskAccessor = null,
                IndexAccessor           = typeGen.HasIndex ? typeGen.IndexEnumInt : null,
                ExtraArgs               = extraArgs.ToArray(),
                SkipErrorMask           = !this.DoErrorMasks
            });
        }
        public override async Task GenerateCopyIn(
            FileGeneration fg,
            ObjectGeneration objGen,
            TypeGeneration typeGen,
            Accessor frameAccessor,
            Accessor itemAccessor,
            Accessor errorMaskAccessor,
            Accessor translationMaskAccessor)
        {
            var data = typeGen.CustomData[Constants.DataKey] as MutagenFieldData;

            if (data.HasTrigger)
            {
                fg.AppendLine($"{frameAccessor}.Position += {frameAccessor}.{nameof(MutagenBinaryReadStream.MetaData)}.{nameof(ParsingBundle.Constants)}.{nameof(GameConstants.SubConstants)}.{nameof(RecordHeaderConstants.HeaderLength)};");
            }

            string framePass;

            if (data.HasTrigger)
            {
                framePass = $"{frameAccessor}.SpawnWithLength(contentLength)";
            }
            else if (data.Length.HasValue)
            {
                framePass = $"{frameAccessor}.SpawnWithLength({data.Length.Value})";
            }
            else
            {
                framePass = frameAccessor.ToString();
            }

            TranslationGeneration.WrapParseCall(
                new TranslationWrapParseArgs()
            {
                FG             = fg,
                TypeGen        = typeGen,
                TranslatorLine = $"{this.Namespace}ByteArrayBinaryTranslation.Instance",
                MaskAccessor   = errorMaskAccessor,
                ItemAccessor   = itemAccessor,
                IndexAccessor  = typeGen.IndexEnumInt,
                ExtraArgs      = $"frame: {framePass}".AsEnumerable(),
                SkipErrorMask  = !this.DoErrorMasks
            });
        }
        public override async Task GenerateCopyIn(
            FileGeneration fg,
            ObjectGeneration objGen,
            TypeGeneration typeGen,
            Accessor frameAccessor,
            Accessor itemAccessor,
            Accessor errorMaskAccessor,
            Accessor translationMaskAccessor)
        {
            var data = typeGen.CustomData[Constants.DataKey] as MutagenFieldData;

            if (data.HasTrigger)
            {
                fg.AppendLine($"{frameAccessor}.Position += {frameAccessor}.{nameof(MutagenBinaryReadStream.MetaData)}.{nameof(ParsingBundle.Constants)}.{nameof(GameConstants.SubConstants)}.{nameof(RecordHeaderConstants.HeaderLength)};");
            }

            bool          hasCustom = false;
            List <string> extraArgs = new List <string>();

            extraArgs.Add($"frame: {frameAccessor}{(data.HasTrigger ? ".SpawnWithLength(contentLength)" : "")}");
            foreach (var writeParam in this.AdditionalCopyInParams)
            {
                var get = writeParam(
                    objGen: objGen,
                    typeGen: typeGen);
                if (get.Failed)
                {
                    continue;
                }
                extraArgs.Add(get.Value);
                hasCustom = true;
            }

            if (CustomRead != null)
            {
                if (CustomRead(fg, objGen, typeGen, frameAccessor, itemAccessor))
                {
                    return;
                }
            }
            if (PreferDirectTranslation && !hasCustom)
            {
                fg.AppendLine($"{itemAccessor.DirectAccess} = {frameAccessor.DirectAccess}.Read{typeName}();");
            }
            else
            {
                TranslationGeneration.WrapParseCall(
                    new TranslationWrapParseArgs()
                {
                    FG                      = fg,
                    TypeGen                 = typeGen,
                    TranslatorLine          = $"{this.Namespace}{this.Typename(typeGen)}BinaryTranslation.Instance",
                    MaskAccessor            = errorMaskAccessor,
                    ItemAccessor            = itemAccessor,
                    TranslationMaskAccessor = null,
                    AsyncMode               = AsyncMode.Off,
                    IndexAccessor           = typeGen.HasIndex ? typeGen.IndexEnumInt : null,
                    ExtraArgs               = extraArgs.ToArray(),
                    SkipErrorMask           = !this.DoErrorMasks
                });
            }
        }