mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Added GetAllocSize
to FlexibleArrayAttribute
This commit is contained in:
parent
9ba19e4cd7
commit
ec4ccb2e9c
1 changed files with 4 additions and 1 deletions
|
@ -108,7 +108,10 @@ namespace System
|
|||
if ((field.FieldType == null) || (!field.FieldType.IsSizedArray) || (field.FieldType.Size != 0))
|
||||
Runtime.FatalError("Type must end in a zero-sized array");
|
||||
var elementType = (field.FieldType as SizedArrayType).UnderlyingType;
|
||||
Compiler.EmitTypeBody(type, scope $"public {elementType}* {mName} mut => (({elementType}*)((uint8*)&this + Math.Align(typeof(Self).Size, typeof({elementType}).Align)));");
|
||||
Compiler.EmitTypeBody(type, scope $"""
|
||||
public {elementType}* {mName} mut => (({elementType}*)((uint8*)&this + Math.Align(typeof(Self).Size, typeof({elementType}).Align)));
|
||||
public static int GetAllocSize(int arrayCount) => Math.Align(typeof(Self).Size, typeof({elementType}).Align) + typeof({elementType}).Size*arrayCount;
|
||||
""");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue