Class MemoryField
- Namespace
- CStructSharp.Memory
- Assembly
- CStructSharp.dll
One member of a struct or union: a name, a type ID, a byte offset from the container's start, and an optional bit slice.
public sealed record MemoryField : IEquatable<MemoryField>
- Inheritance
-
MemoryField
- Implements
- Inherited Members
Remarks
A field is the link between a containing composite and the type stored inside it. The offset is relative to the start of the containing record, never an absolute address; the session adds it to the record's region when a path selects the member. The referenced type supplies the storage size.
A bit slice describes a C bitfield: the field occupies only BitWidth bits of its storage integer, starting at BitOffset counted from the least significant bit. Bits are numbered after the storage integer has been assembled from its bytes, so switching byte order changes which byte holds the slice but not the meaning of bit index zero. A signed slice is sign-extended on read and range-checked on write, using two's complement.
A promoted field makes the members of an anonymous nested struct or union visible in the parent, mirroring C's anonymous members. If two promoted members share a name the schema rejects the ambiguity instead of picking one. Extent and overlap checks belong to MemorySchema, which sees the whole graph.
Constructors
MemoryField(string, string, int, int?, int?, bool, bool)
Creates a member description; type references, extents, and overlap are validated later by the schema.
public MemoryField(string name, string typeId, int offset, int? bitOffset = null, int? bitWidth = null, bool signed = false, bool promoted = false)
Parameters
namestringMember name used in session paths and struct value dictionaries.
typeIdstringID of the member's type in the schema.
offsetintByte offset from the start of the containing struct or union, not a source address.
bitOffsetint?Index of the slice's least significant bit within the storage integer, or null for a whole value.
bitWidthint?Number of bits in the slice, or null for a whole value; must accompany
bitOffset.signedboolWhether the bit slice is a two's-complement signed number.
promotedboolWhether the members of this composite are visible in the containing record.
Properties
BitOffset
Gets the index of the slice's least significant bit within the storage integer, or null for a whole value.
public int? BitOffset { get; }
Property Value
- int?
BitWidth
Gets the number of bits in the slice, or null for a whole value.
public int? BitWidth { get; }
Property Value
- int?
Name
Gets the member name used for path lookup and value dictionaries.
public string Name { get; }
Property Value
Offset
Gets the byte offset from the start of the containing record.
public int Offset { get; }
Property Value
Promoted
Gets whether the members of this composite are visible in its containing record.
public bool Promoted { get; }
Property Value
Signed
Gets whether the bit slice is read and written as a two's-complement signed number.
public bool Signed { get; }
Property Value
TypeId
Gets the ID of the member's type.
public string TypeId { get; }
Property Value
Methods
Equals(MemoryField?)
public bool Equals(MemoryField? other)
Parameters
otherMemoryField
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
ToString()
public override string ToString()
Returns
Operators
operator ==(MemoryField?, MemoryField?)
public static bool operator ==(MemoryField? left, MemoryField? right)
Parameters
leftMemoryFieldrightMemoryField
Returns
operator !=(MemoryField?, MemoryField?)
public static bool operator !=(MemoryField? left, MemoryField? right)
Parameters
leftMemoryFieldrightMemoryField