Added IsPointer field for array attribute, fixed pointer arrays sizes

This commit is contained in:
mm00
2025-03-12 19:01:52 +01:00
parent 6533511a4a
commit 934c878878
2 changed files with 13 additions and 2 deletions

View File

@@ -241,7 +241,7 @@ namespace CodeGenerator {
else //Store the data for when the list attribute is made
listCountOffsets.Add(fName, totalSize);
totalSize += field.Type.ParseFSize();
totalSize += field.Type.ParseFSize()!.Value;
} else {
Log($"Field {field.Name} is of unknown or unsupported type");
}
@@ -367,6 +367,7 @@ namespace CodeGenerator {
.AddAutoProperty(typeof(string), "OriginalName")
.AddAutoProperty(typeof(string), "UnderlyingType")
.AddAutoProperty(typeof(int), "ArrayLenght")
.AddAutoProperty(typeof(bool), "IsPointer")
.AddAutoProperty(typeof(int), "MemoryOffset")
.AddPropertiesConstructor()
.AddBaseConstructorParams(["OriginalIndex", "OriginalName"])
@@ -427,10 +428,16 @@ namespace CodeGenerator {
private static CodeAttributeDeclaration GenerateDnaArrayAttribute(int index, DnaField field, Dna1Body body, int offset,
out int size) {
var isPointer = false;
//Grab the lenght of the single item in the array
size = body.Lengths[field.IdxType];
//Generate the array declaration again... to grab the base type
CodeMemberField amf = CreateArrayMemberField(field);
if (field.Name.StartsWith('*')) {
size = 8;
isPointer = true;
}
//Generate the type string
var sb = new StringBuilder();
@@ -445,7 +452,7 @@ namespace CodeGenerator {
var dimensions = field.Name.GetArrayDimensions();
int length = 1;
foreach (int dim in dimensions) {
length += dim;
length *= dim;
size *= dim;
}
@@ -457,6 +464,7 @@ namespace CodeGenerator {
new(new CodePrimitiveExpression(field.Name)),
new(new CodePrimitiveExpression(t)),
new(new CodePrimitiveExpression(length)),
new(new CodePrimitiveExpression(isPointer)),
new(new CodePrimitiveExpression(offset))
});
return cad;