Table of Contents

Class CStructCompilationOptions

Namespace
CStructSharp
Assembly
CStructSharp.dll

Controls the resource limits applied before a C-like layout definition is parsed and compiled.

public sealed record CStructCompilationOptions : IEquatable<CStructCompilationOptions>
Inheritance
CStructCompilationOptions
Implements
Inherited Members

Remarks

Values are read and validated when CStruct is constructed. Later changes to the options object do not alter an already compiled layout. A record: options with { CLongWidth = 32 } copies every other member, and two instances with the same members are equal (Codecs and Defined compare by reference).

Constructors

CStructCompilationOptions()

Creates the default bounded compilation policy.

public CStructCompilationOptions()

Properties

BitfieldAllocation

Gets which end of a storage unit the first bitfield takes: LowBitFirst (the default) or HighBitFirst for formats specified by big-endian ABIs or RFC diagrams. Storage-unit grouping and byte order are unaffected.

public BitfieldAllocation BitfieldAllocation { get; init; }

Property Value

BitfieldAllocation

BitfieldPacking

Gets how adjacent bitfields of different declared types share storage: SysV (the default; GCC and Clang on every System V platform, and the Itanium C++ ABI) allocates bits contiguously and lets a field join the previous one as long as it does not cross a boundary of its own type's size, so uint8 a:4; uint16 b:4; is two bytes; Msvc starts a new unit of the declared size whenever the size changes, so the same fields take four. Both are part of the compiled-layout cache key; BitfieldAllocation chooses bit numbering inside a unit independently.

public BitfieldPacking BitfieldPacking { get; init; }

Property Value

BitfieldPacking

CLongWidth

Gets the width in bits of the C long family (long, unsigned long, ulong, long int, ...). Portable's default is 64, the LP64 reading of a kernel header; 32 is the ILP32/LLP64 reading and the width dissect.cstruct assumes. Windows LONG/ULONG are always 32 bits and are not affected. Accepted values are 32 and 64.

public int CLongWidth { get; init; }

Property Value

int

Codecs

Gets the caller-supplied primitive types available to the layout by name. The list is compared by reference for caching, so keep one instance per codec set. null means none.

public IReadOnlyList<ICustomCodec>? Codecs { get; init; }

Property Value

IReadOnlyList<ICustomCodec>

DefaultEnumStorage

Gets the storage type of an enum or flag declared without a backing type (enum E { A };). null, the default, applies the rule C compilers use: 32 bits (int-sized), uint32 unless a member is written as a negative number, which selects int32. That also matches dissect.cstruct's uint32 default for every header it ships. Any accepted integer spelling fixes the storage instead and is resolved when the layout compiles.

public string? DefaultEnumStorage { get; init; }

Property Value

string

Defined

Gets the names that #ifdef/#ifndef treat as defined before the layout's own #define lines are seen, the way a compiler's -D flags do. null means none.

public IReadOnlySet<string>? Defined { get; init; }

Property Value

IReadOnlySet<string>

MaxDefinitionLength

Gets the greatest accepted layout-source length in characters.

public int MaxDefinitionLength { get; init; }

Property Value

int

MaxExpressionNestingDepth

Gets the greatest syntax-tree or identifier-dependency depth accepted for one expression.

public int MaxExpressionNestingDepth { get; init; }

Property Value

int

MaxExpressionTokens

Gets the greatest number of expression nodes one evaluation session may compile or execute.

public int MaxExpressionTokens { get; init; }

Property Value

int

MaxLayoutNestingDepth

Gets the greatest brace-nesting depth accepted in a layout definition.

public int MaxLayoutNestingDepth { get; init; }

Property Value

int

Prelude

Gets layout text compiled ahead of the layout itself - shared typedefs, defines, and declarations that several layouts have in common. The prelude's declarations are ordinary declarations of the layout (they appear in Layout and ToDefinition()) and count toward MaxDefinitionLength. null means none.

public string? Prelude { get; init; }

Property Value

string

Methods

Equals(CStructCompilationOptions?)

public bool Equals(CStructCompilationOptions? other)

Parameters

other CStructCompilationOptions

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

Operators

operator ==(CStructCompilationOptions?, CStructCompilationOptions?)

public static bool operator ==(CStructCompilationOptions? left, CStructCompilationOptions? right)

Parameters

left CStructCompilationOptions
right CStructCompilationOptions

Returns

bool

operator !=(CStructCompilationOptions?, CStructCompilationOptions?)

public static bool operator !=(CStructCompilationOptions? left, CStructCompilationOptions? right)

Parameters

left CStructCompilationOptions
right CStructCompilationOptions

Returns

bool