modified handling of array types in dna field attributes generation

This commit is contained in:
mm00
2025-02-18 17:59:52 +01:00
parent 7403dd7776
commit 15fb695bcd

View File

@@ -221,7 +221,7 @@ namespace CodeGenerator {
cmp = new CodeMemberProperty() { cmp = new CodeMemberProperty() {
Name = "UnderlyingType", Name = "UnderlyingType",
Type = new CodeTypeReference(typeof(Type)), Type = new CodeTypeReference(typeof(string)),
Attributes = MemberAttributes.Public, Attributes = MemberAttributes.Public,
HasGet = true, HasGet = true,
GetStatements = { GetStatements = {
@@ -240,7 +240,7 @@ namespace CodeGenerator {
new(typeof(int), "originalIndex"), new(typeof(int), "originalIndex"),
new(typeof(string), "originalType"), new(typeof(string), "originalType"),
new(typeof(string), "originalName"), new(typeof(string), "originalName"),
new(typeof(Type), "underlyingType"), new(typeof(string), "underlyingType"),
new(typeof(int), "size") new(typeof(int), "size")
}); });
@@ -324,12 +324,20 @@ namespace CodeGenerator {
private static CodeAttributeDeclaration GenerateDNAFieldAttribute(int index, BlendFile.DnaField field, private static CodeAttributeDeclaration GenerateDNAFieldAttribute(int index, BlendFile.DnaField field,
BlendFile.Dna1Body body) { BlendFile.Dna1Body body) {
Type t; string t;
if (field.Name.Contains('[')) { if (field.Name.Contains('[')) {
CodeMemberField amf = CreateArrayMemberField(field); CodeMemberField amf = CreateArrayMemberField(field);
t = Type.GetType($"Array<{amf.Type.ArrayElementType.BaseType}>"); var sb = new StringBuilder();
} else { sb.Append(amf.Type.BaseType);
t = Type.GetType(field.Type.ParseFType()); sb.Append("[");
for(int i=1; i<amf.Type.ArrayRank; i++) {
sb.Append(",");
}
sb.Append("]");
t = sb.ToString();
} else
{
t = field.Type;
} }
CodeAttributeDeclaration cad = new("DNAFieldAttribute"); CodeAttributeDeclaration cad = new("DNAFieldAttribute");