node-ctypes - v2.17.1
    Preparing search index...

    Class LittleEndianUnion<F>

    Union subclass with explicit little-endian layout (same as plain Union on LE hosts).

    Python equivalent: ctypes.LittleEndianUnion

    Type Parameters

    • F extends Record<string, FieldSpec> = Record<string, any>

    Hierarchy (View Summary)

    Indexable

    • [field: string]: any

      Fields: accessors of the class (not own properties, as in Python).

    Index
    • Create a new instance.

      Type Parameters

      • F extends Record<string, FieldSpec> = Record<string, any>

      Parameters

      • ...args: any[]

        Positional values matching field order (a single Buffer is a positional value too, not the memory: use from_buffer / create(buffer)), or a single object with field names as keys

      Returns LittleEndianUnion<F>

    _fields_?: Record<string, FieldSpec> | readonly FieldEntry[]

    Field definitions. Array of [name, type] tuples, or [name, type, bits] for bit fields.

    static _fields_ = [
    ["x", c_int],
    ["y", c_int],
    ["flags", c_uint32, 3], // 3-bit bit field
    ];
    _pack_?: string | number | bigint | boolean

    Maximum field alignment in bytes, as Python's _pack_ (1 = no padding). true is accepted as 1.

    _layout_?: "gcc-sysv" | "ms"

    Bit field layout, as Python's _layout_: "gcc-sysv" (default except on Windows) or "ms" (default on Windows and with _pack_).

    _align_?: number | bigint | boolean

    Minimum alignment in bytes, as Python's _align_ (a boolean or BigInt is a Python int; 0 means 1).

    _anonymous_?: readonly string[]

    List of field names whose members are promoted to the parent struct.

    Python equivalent: _anonymous_

    _abstract_?: unknown

    Declaring _abstract_ (any value, as in CPython) makes the class abstract: construction, from_buffer, from_buffer_copy, from_address and in_dll throw TypeError abstract class. Not inherited.

    __pointer_type__?: PointerTypeDef<any>

    Python 3.14 T.__pointer_type__: the type POINTER(T) returns, set by the first POINTER(T) (undefined before, not inherited by subclasses). Writable and deletable.

    size: number

    Size in bytes (Python: sizeof(cls)).

    alignment: number

    Alignment in bytes (Python: alignment(cls)).

    fields: FieldDef[]

    Field descriptors, in layout order.

    _buffer: Buffer

    The underlying memory buffer. Passed automatically to native functions.

    _structDef: StructDef

    The struct definition metadata.

    • Create instance with optional initial values, or over a copy-free view of a Buffer.

      Type Parameters

      Parameters

      • this: new (...args: any[]) => ThisT
      • Optionalvalues: Buffer<ArrayBufferLike> | AggregateFieldsInput<ThisT>

      Returns ThisT

    • Create an instance that aliases memory inside an existing Buffer. Writes through the instance propagate to the source Buffer.

      Python ctypes parity: Structure.from_buffer(source, offset=0).

      Type Parameters

      Parameters

      • this: new (...args: any[]) => ThisT
      • source: ArrayBufferView<ArrayBufferLike> | { _buffer: Buffer }
      • Optionaloffset: BufferOffset

      Returns ThisT

    • Create an instance whose buffer is an independent copy of the source bytes.

      Python ctypes parity: Structure.from_buffer_copy(source, offset=0).

      Type Parameters

      Parameters

      • this: new (...args: any[]) => ThisT
      • source: ReadonlyMemoryView | ArrayBufferView<ArrayBufferLike> | { _buffer: Buffer }
      • Optionaloffset: BufferOffset

      Returns ThisT

    • Create an instance that views raw memory at address. Caller is responsible for ensuring the memory stays valid and is at least sizeof(this) bytes.

      Python ctypes parity: Structure.from_address(address).

      Type Parameters

      Parameters

      • this: new (...args: any[]) => ThisT
      • address: number | bigint

      Returns ThisT

    • Bind the Structure to an exported global variable in a shared library. Reads/writes through the returned instance go to/from the DLL's memory.

      Python ctypes parity: Structure.in_dll(library, name); a missing symbol is a RangeError (Python ValueError: "symbol 'name' not found" on Windows, the dlerror() text on Linux and macOS).

      Type Parameters

      Parameters

      Returns ThisT

    • Read a field value by name.

      Type Parameters

      • K extends string

      Parameters

      • fieldName: K

      Returns FieldsToInstance<F>[K]

    • Write a field value by name.

      Type Parameters

      • K extends string

      Parameters

      • fieldName: K
      • value: FieldsToInstance<F>[K]

      Returns void

    • Convert all fields to a plain JavaScript object (snapshot).

      Returns FieldsToInstance<F>