Union
The Union
aspect marks a record
/struct
on Cocoa and Island to work like a C-style union – meaning that instead of being laid out sequentially, all fields are located at offset 0 and overlap each other, allowing the same byte(s) in memory to be accessed as different types. The size of the struct is the size of the largest field, and it may not contain types that are unsafe for direct access (such as class references).
type
[Union]
MyInteger = public record
AsInteger: Int32;
AsBytes: array [0..3] of Byte;
end;
[Union]
public struct MyInteger
{
Int32 AsInteger;
byte[3] AsBytes;
}
@Union
public struct MyInteger {
var AsInteger: Int32;
var AsBytes: Byte[3];
}
@Union
public struct MyInteger {
Int32 AsInteger;
Byte[3] AsBytes;
}