Contents

JSValueToInt64(_:_:_:)

Declaration

func JSValueToInt64(_ ctx: JSContextRef, _ value: JSValueRef, _ exception: UnsafeMutablePointer<JSValueRef?>?) -> Int64

Parameters

  • ctx:

    The execution context to use.

  • value:

    The JSValue to convert.

  • exception:

    A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.

Return Value

An int64_t with the result of conversion, or 0 if an exception is thrown. Since 0 is valid value, exception must be checked after the call.

Discussion

Converts a JSValue to a singed 64-bit integer and returns the resulting integer.

The JSValue is converted to an integer according to the rules specified by the JavaScript language. If the value is a BigInt, then the JSValue is truncated to an int64_t.