type

ffi.FFITypeOrString

Referenced types

enum FFIType

  • bool = 11

    Boolean value

    Must be true or false. 0 and 1 type coercion is not supported.

    In C, this corresponds to:

    bool
    _Bool
  • buffer = 20
  • buffer_length = 21

    A TypedArray or DataView whose byte length is passed to the callee as an unsigned 64-bit integer. Pass the same view you passed for a buffer parameter; the engine reads pointer and length off the same object at call time, so the two always agree (an atomic snapshot -- unlike passing view.byteLength yourself). Engine-native only; not supported inside cc().

  • char = 0
  • cstring = 14

    When used as a returns, the value becomes a string (a NULL pointer becomes null).

    When used in args, it is equivalent to FFIType.pointer and additionally accepts a JavaScript string.

  • double = 9

    IEEE-754 double precision float

  • f32 = 10

    Alias of FFIType.float

  • f64 = 9

    Alias of FFIType.double

  • float = 10

    IEEE-754 single precision float

  • i16 = 3

    16-bit signed integer

    Must be a value between -32768 and 32767

    When passing to an FFI function (C ABI), type coercion is not performed.

    In C:

    int16_t
    short // on arm64 & x64

    In JavaScript:

    var num = 0;
  • i32 = 5

    32-bit signed integer

    Alias of FFIType.int32_t

  • i64 = 7

    64-bit signed integer

    Alias of FFIType.int64_t

  • i64_fast = 15

    Attempts to coerce a BigInt into a number when it fits. This improves performance, but the JavaScript value may be either a number or a BigInt, depending on the value.

    In C, this always becomes int64_t

  • i8 = 1

    8-bit signed integer

    Must be a value between -128 and 127

    When passing to an FFI function (C ABI), type coercion is not performed.

    In C:

    signed char
    char // on x64 & aarch64 macOS

    In JavaScript:

    var num = 0;
  • int = 5

    32-bit signed integer

    The same as int in C

    int
  • int16_t = 3

    16-bit signed integer

    Must be a value between -32768 and 32767

    When passing to an FFI function (C ABI), type coercion is not performed.

    In C:

    int16_t
    short // on arm64 & x64

    In JavaScript:

    var num = 0;
  • int32_t = 5

    32-bit signed integer

  • int64_t = 7

    64-bit signed integer

  • int8_t = 1

    8-bit signed integer

    Must be a value between -128 and 127

    When passing to an FFI function (C ABI), type coercion is not performed.

    In C:

    signed char
    char // on x64 & aarch64 macOS

    In JavaScript:

    var num = 0;
  • pointer = 12

    Pointer value

    Alias of FFIType.ptr

  • ptr = 12

    Pointer value

    See the ptr() function for getting a pointer from a TypedArray

    In C:

    void*

    In JavaScript:

    ptr(new Uint8Array(1))
  • u16 = 4

    16-bit unsigned integer

    Must be a value between 0 and 65535, inclusive.

    When passing to an FFI function (C ABI), type coercion is not performed.

    In C:

    uint16_t
    unsigned short // on arm64 & x64

    In JavaScript:

    var num = 0;
  • u32 = 6

    32-bit unsigned integer

    Alias of FFIType.uint32_t

  • u64 = 8

    64-bit unsigned integer

  • u64_fast = 16

    Attempts to coerce a BigInt into a number when it fits. This improves performance, but the JavaScript value may be either a number or a BigInt, depending on the value.

    In C, this always becomes uint64_t

  • u8 = 2

    8-bit unsigned integer

    Must be a value between 0 and 255

    When passing to an FFI function (C ABI), type coercion is not performed.

    In C:

    unsigned char

    In JavaScript:

    var num = 0;
  • uint16_t = 4

    16-bit unsigned integer

    Must be a value between 0 and 65535, inclusive.

    When passing to an FFI function (C ABI), type coercion is not performed.

    In C:

    uint16_t
    unsigned short // on arm64 & x64

    In JavaScript:

    var num = 0;
  • uint32_t = 6

    32-bit unsigned integer

    The same as unsigned int in C (on x64 & arm64)

    C:

    unsigned int

    JavaScript:

    ptr(new Uint32Array(1))
  • uint64_t = 8

    64-bit unsigned integer

  • uint8_t = 2

    8-bit unsigned integer

    Must be a value between 0 and 255

    When passing to an FFI function (C ABI), type coercion is not performed.

    In C:

    unsigned char

    In JavaScript:

    var num = 0;
  • void = 13

    void value

    void arguments are not supported

    void return type is the default return type

    In C:

    void