Added count field type argument to the list attribute
This commit is contained in:
@@ -188,17 +188,17 @@ namespace CodeGenerator {
|
||||
//Add the lists to the class
|
||||
for (var index = 0; index < type.Fields.Count; index++) {
|
||||
var field = type.Fields[index];
|
||||
//Skip fields that are not part of a list
|
||||
if (listFields.Select(f => f.Item1).Contains(field)) {
|
||||
if (listFields.Select(f => f.Item1).Contains(field)) { //Field is pointer of list
|
||||
//Retrieve the list pointer and the list length fields
|
||||
var (listPointer, listLength) = listFields.FirstOrDefault(x => x.Item1 == field);
|
||||
Log($"Generating list field {listPointer.Name}");
|
||||
|
||||
//retrieve the offset of the list length field if exists
|
||||
listCountOffsets.TryGetValue(listLength.Name, out int listLenghtOffset);
|
||||
|
||||
//Retrieve the index of the list length field
|
||||
int sizeIndex = type.Fields.IndexOf(listLength);
|
||||
|
||||
Log($"Generating list field {listPointer.Name}");
|
||||
var cmf = CreateListMemberField(listPointer, listLength);
|
||||
|
||||
var attribute = GenerateDnaListAttribute(index, listPointer, sizeIndex, listLength, totalSize,
|
||||
@@ -207,7 +207,7 @@ namespace CodeGenerator {
|
||||
totalSize += size;
|
||||
cmf.CustomAttributes.Add(attribute);
|
||||
ctd.Members.Add(cmf);
|
||||
} else if (listFields.Select(f => f.Item2).Contains(field)) {
|
||||
} else if (listFields.Select(f => f.Item2).Contains(field)) { // field is list length
|
||||
//Retrieve the list length field
|
||||
string fName = field.Name.ParseFName();
|
||||
//Try seeing if the list attribute is already present
|
||||
@@ -217,7 +217,9 @@ namespace CodeGenerator {
|
||||
x.CustomAttributes[0].Arguments[5] = new(new CodePrimitiveExpression(totalSize));
|
||||
else //Store the data for when the list attribute is made
|
||||
listCountOffsets.Add(fName, totalSize);
|
||||
} else {
|
||||
|
||||
totalSize += field.Type.ParseFSize();
|
||||
} else { //Skip fields that are not part of a list
|
||||
Log($"Field {field.Name} is not part of a list, skipping");
|
||||
}
|
||||
}
|
||||
@@ -352,6 +354,7 @@ namespace CodeGenerator {
|
||||
.AddAutoProperty(typeof(string), "OriginalName")
|
||||
.AddAutoProperty(typeof(int), "OriginalIndex")
|
||||
.AddAutoProperty(typeof(string), "UnderlyingType")
|
||||
.AddAutoProperty(typeof(string), "CountFieldType")
|
||||
.AddAutoProperty(typeof(string), "CountFieldName")
|
||||
.AddAutoProperty(typeof(int), "CountFieldIndex")
|
||||
.AddAutoProperty(typeof(int), "PtrMemoryOffset")
|
||||
@@ -421,6 +424,7 @@ namespace CodeGenerator {
|
||||
new(new CodePrimitiveExpression(listField.Name)),
|
||||
new(new CodePrimitiveExpression(listIndex)),
|
||||
new(new CodePrimitiveExpression(listField.Type)),//TODO: double check this
|
||||
new(new CodePrimitiveExpression(lenghtField.Type)),
|
||||
new(new CodePrimitiveExpression(lenghtField.Name)),
|
||||
new(new CodePrimitiveExpression(lenghtIndex)),
|
||||
new(new CodePrimitiveExpression(ptrOffset)),
|
||||
|
||||
Reference in New Issue
Block a user