type
ffi.FFITypeOrString
Referenced types
enum FFIType
- bool = 11
Boolean value
Must be
trueorfalse.0and1type 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
bufferparameter; the engine reads pointer and length off the same object at call time, so the two always agree (an atomic snapshot -- unlike passingview.byteLengthyourself). Engine-native only; not supported insidecc(). - char = 0
- cstring = 14
When used as a
returns, the value becomes astring(a NULL pointer becomesnull).When used in
args, it is equivalent to FFIType.pointer and additionally accepts a JavaScript string. - function = 17
- 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 & x64In JavaScript:
var num = 0; - i64_fast = 15
Attempts to coerce a
BigIntinto anumberwhen it fits. This improves performance, but the JavaScript value may be either anumberor aBigInt, 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 macOSIn JavaScript:
var num = 0; - 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 & x64In JavaScript:
var num = 0; - 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 macOSIn JavaScript:
var num = 0; - napi_env = 18
- napi_value = 19
- ptr = 12
Pointer value
See the
ptr()function for getting a pointer from aTypedArrayIn 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 & x64In JavaScript:
var num = 0; - u64_fast = 16
Attempts to coerce a
BigIntinto anumberwhen it fits. This improves performance, but the JavaScript value may be either anumberor aBigInt, 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 charIn 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 & x64In JavaScript:
var num = 0; - uint32_t = 6
32-bit unsigned integer
The same as
unsigned intin C (on x64 & arm64)C:
unsigned intJavaScript:
ptr(new Uint32Array(1)) - 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 charIn JavaScript:
var num = 0; - void = 13
void value
void arguments are not supported
void return type is the default return type
In C:
void