node-ctypes - v2.10.0
    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 struct instance.

      Type Parameters

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

      Parameters

      • ...args: any[]

        Positional values matching field order, 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

    Minimum alignment in bytes, as Python's _align_.

    _anonymous_?: readonly string[]

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

    Python equivalent: _anonymous_

    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.

    • Convert a buffer or instance to a plain object.

      Type Parameters

      Parameters

      • this: new (...args: any[]) => ThisT
      • bufOrInstance: Buffer<ArrayBufferLike> | Structure<F>

      Returns F

    • 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: number

      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: ArrayBufferView<ArrayBufferLike> | { _buffer: Buffer }
      • Optionaloffset: number

      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).

      Type Parameters

      Parameters

      Returns ThisT