Added extra parameter

This commit is contained in:
Samuele Lorefice
2025-02-18 16:27:50 +01:00
parent 88a4515c8d
commit 7403dd7776
2 changed files with 30 additions and 1 deletions

View File

@@ -1,4 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AArgumentException_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F0beb96d31db641cf82014cb1a758a330b2dc00_003Fea_003F056794d0_003FArgumentException_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACSharpCodeGenerator_002Ecs_002Fl_003AC_0021_003FUsers_003Fairon_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F4aa9136c27fa69d6c91e9d8679c1a1d4b7aabee06e20d4405ee3d91ee05048f0_003FCSharpCodeGenerator_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeType_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F0beb96d31db641cf82014cb1a758a330b2dc00_003F5b_003F039af867_003FRuntimeType_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F0beb96d31db641cf82014cb1a758a330b2dc00_003F3e_003F433607bb_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F0beb96d31db641cf82014cb1a758a330b2dc00_003F3e_003F433607bb_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AType_002Ecs_002Fl_003AC_0021_003FUsers_003Fairon_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fe7dbd6fe331ff9a3c4b24dd470ec1f19a71b7c5acf258b81ae7f761cd2b319b_003FType_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

View File

@@ -4,6 +4,7 @@ using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using Kaitai;
using Microsoft.CSharp;
@@ -218,12 +219,28 @@ namespace CodeGenerator {
};
ctd.Members.Add(cmp);
cmp = new CodeMemberProperty() {
Name = "UnderlyingType",
Type = new CodeTypeReference(typeof(Type)),
Attributes = MemberAttributes.Public,
HasGet = true,
GetStatements = {
new CodeMethodReturnStatement(new CodeSnippetExpression("_originalType.ParseFType()"))
},
HasSet = true,
SetStatements = {
new CodeAssignStatement(new CFieldRefExp(new CThisRefExp(), "_originalType"), new CArgRefExp("value"))
}
};
ctd.Members.Add(cmp);
var cc = new CodeConstructor() { Attributes = MemberAttributes.Public };
cc.Parameters.AddRange(new CParamDeclExp[] {
new(typeof(int), "originalIndex"),
new(typeof(string), "originalType"),
new(typeof(string), "originalName"),
new(typeof(Type), "underlyingType"),
new(typeof(int), "size")
});
@@ -231,6 +248,7 @@ namespace CodeGenerator {
new(new CFieldRefExp(new CThisRefExp(), "OriginalIndex"), new CArgRefExp("originalIndex")),
new(new CFieldRefExp(new CThisRefExp(), "OriginalType"), new CArgRefExp("originalType")),
new(new CFieldRefExp(new CThisRefExp(), "OriginalName"), new CArgRefExp("originalName")),
new(new CFieldRefExp(new CThisRefExp(), "OriginalType"), new CArgRefExp("underlyingType")),
new(new CFieldRefExp(new CThisRefExp(), "Size"), new CArgRefExp("size"))
});
@@ -306,11 +324,20 @@ namespace CodeGenerator {
private static CodeAttributeDeclaration GenerateDNAFieldAttribute(int index, BlendFile.DnaField field,
BlendFile.Dna1Body body) {
Type t;
if (field.Name.Contains('[')) {
CodeMemberField amf = CreateArrayMemberField(field);
t = Type.GetType($"Array<{amf.Type.ArrayElementType.BaseType}>");
} else {
t = Type.GetType(field.Type.ParseFType());
}
CodeAttributeDeclaration cad = new("DNAFieldAttribute");
cad.Arguments.AddRange(new CodeAttributeArgumentCollection() {
new(new CodePrimitiveExpression(index)),
new(new CodePrimitiveExpression(field.Type)),
new(new CodePrimitiveExpression(field.Name)),
new(new CodePrimitiveExpression(t)),
new(new CodePrimitiveExpression((int)body.Lengths[field.IdxType]))
});
return cad;