javascriptcore/jsvalueref

Search:
Group by:

Bindings for JSValueRef.h.

JSTypedArrayType and JSRelationCondition also live here in C (JSTypedArray.h only holds functions). Availability floors from the SDK headers are noted per item.

Types

JSRelationCondition {.size: 4.} = enum
  kJSRelationConditionUndefined = 0, kJSRelationConditionEqual = 1,
  kJSRelationConditionGreaterThan = 2, kJSRelationConditionLessThan = 3 ## Result of JSValueCompare. macOS 15.0+.
JSType {.size: 4.} = enum
  kJSTypeUndefined = 0, kJSTypeNull = 1, kJSTypeBoolean = 2, kJSTypeNumber = 3,
  kJSTypeString = 4, kJSTypeObject = 5, kJSTypeSymbol = 6, ## macOS 10.15+
  kJSTypeBigInt = 7          ## macOS 15.0+
JSTypedArrayType {.size: 4.} = enum
  kJSTypedArrayTypeInt8Array = 0, kJSTypedArrayTypeInt16Array = 1,
  kJSTypedArrayTypeInt32Array = 2, kJSTypedArrayTypeUint8Array = 3,
  kJSTypedArrayTypeUint8ClampedArray = 4, kJSTypedArrayTypeUint16Array = 5,
  kJSTypedArrayTypeUint32Array = 6, kJSTypedArrayTypeFloat32Array = 7,
  kJSTypedArrayTypeFloat64Array = 8, kJSTypedArrayTypeArrayBuffer = 9,
  kJSTypedArrayTypeNone = 10, kJSTypedArrayTypeBigInt64Array = 11, kJSTypedArrayTypeBigUint64Array = 12 ## macOS 10.12+.

Procs

proc JSBigIntCreateWithDouble(ctx: JSContextRef; value: cdouble;
                              exception: ptr JSValueRef): JSValueRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Throws unless the double is integral. macOS 15.0+.
proc JSBigIntCreateWithInt64(ctx: JSContextRef; integer: int64;
                             exception: ptr JSValueRef): JSValueRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 15.0+.
proc JSBigIntCreateWithString(ctx: JSContextRef; str: JSStringRef;
                              exception: ptr JSValueRef): JSValueRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Like calling the BigInt constructor on a string. macOS 15.0+.
proc JSBigIntCreateWithUInt64(ctx: JSContextRef; integer: uint64;
                              exception: ptr JSValueRef): JSValueRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 15.0+.
proc JSValueCompare(ctx: JSContextRef; left, right: JSValueRef;
                    exception: ptr JSValueRef): JSRelationCondition {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Compares two values. Undefined on exception or NaN. macOS 15.0+.
proc JSValueCompareDouble(ctx: JSContextRef; left: JSValueRef; right: cdouble;
                          exception: ptr JSValueRef): JSRelationCondition {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 15.0+.
proc JSValueCompareInt64(ctx: JSContextRef; left: JSValueRef; right: int64;
                         exception: ptr JSValueRef): JSRelationCondition {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 15.0+.
proc JSValueCompareUInt64(ctx: JSContextRef; left: JSValueRef; right: uint64;
                          exception: ptr JSValueRef): JSRelationCondition {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 15.0+.
proc JSValueCreateJSONString(ctx: JSContextRef; value: JSValueRef;
                             indent: cuint; exception: ptr JSValueRef): JSStringRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Serializes to JSON. Create Rule. indent clamps to 10. macOS 10.7+.
proc JSValueGetType(ctx: JSContextRef; value: JSValueRef): JSType {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Returns a value's type.
proc JSValueGetTypedArrayType(ctx: JSContextRef; value: JSValueRef;
                              exception: ptr JSValueRef): JSTypedArrayType {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Returns the typed-array type, or kJSTypedArrayTypeNone. macOS 10.12+.
proc JSValueIsArray(ctx: JSContextRef; value: JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 10.11+.
proc JSValueIsBigInt(ctx: JSContextRef; value: JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 15.0+.
proc JSValueIsBoolean(ctx: JSContextRef; value: JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
proc JSValueIsDate(ctx: JSContextRef; value: JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 10.11+.
proc JSValueIsEqual(ctx: JSContextRef; a, b: JSValueRef;
                    exception: ptr JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
== comparison.
proc JSValueIsInstanceOfConstructor(ctx: JSContextRef; value: JSValueRef;
                                    constructor: JSObjectRef;
                                    exception: ptr JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
instanceof comparison.
proc JSValueIsNull(ctx: JSContextRef; value: JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
proc JSValueIsNumber(ctx: JSContextRef; value: JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
proc JSValueIsObject(ctx: JSContextRef; value: JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
proc JSValueIsObjectOfClass(ctx: JSContextRef; value: JSValueRef;
                            jsClass: JSClassRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Tests class membership along the class chain.
proc JSValueIsStrictEqual(ctx: JSContextRef; a, b: JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
=== comparison.
proc JSValueIsString(ctx: JSContextRef; value: JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
proc JSValueIsSymbol(ctx: JSContextRef; value: JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 10.15+.
proc JSValueIsUndefined(ctx: JSContextRef; value: JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
proc JSValueMakeBoolean(ctx: JSContextRef; boolean: bool): JSValueRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
proc JSValueMakeFromJSONString(ctx: JSContextRef; str: JSStringRef): JSValueRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Parses JSON. Returns nil on invalid input. macOS 10.7+.
proc JSValueMakeNull(ctx: JSContextRef): JSValueRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
proc JSValueMakeNumber(ctx: JSContextRef; number: cdouble): JSValueRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
proc JSValueMakeString(ctx: JSContextRef; str: JSStringRef): JSValueRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Retains str; released on collection.
proc JSValueMakeSymbol(ctx: JSContextRef; description: JSStringRef): JSValueRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 10.15+.
proc JSValueMakeUndefined(ctx: JSContextRef): JSValueRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
proc JSValueProtect(ctx: JSContextRef; value: JSValueRef) {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Pins a value against GC. Pair every call with Unprotect.
proc JSValueToBoolean(ctx: JSContextRef; value: JSValueRef): bool {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
proc JSValueToInt32(ctx: JSContextRef; value: JSValueRef;
                    exception: ptr JSValueRef): int32 {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
0 is a valid result: check exception[]. macOS 15.0+.
proc JSValueToInt64(ctx: JSContextRef; value: JSValueRef;
                    exception: ptr JSValueRef): int64 {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 15.0+.
proc JSValueToNumber(ctx: JSContextRef; value: JSValueRef;
                     exception: ptr JSValueRef): cdouble {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Like Number(value). NaN on exception.
proc JSValueToObject(ctx: JSContextRef; value: JSValueRef;
                     exception: ptr JSValueRef): JSObjectRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Nil on exception.
proc JSValueToStringCopy(ctx: JSContextRef; value: JSValueRef;
                         exception: ptr JSValueRef): JSStringRef {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Create Rule. Nil on exception.
proc JSValueToUInt32(ctx: JSContextRef; value: JSValueRef;
                     exception: ptr JSValueRef): uint32 {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 15.0+.
proc JSValueToUInt64(ctx: JSContextRef; value: JSValueRef;
                     exception: ptr JSValueRef): uint64 {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
macOS 15.0+.
proc JSValueUnprotect(ctx: JSContextRef; value: JSValueRef) {.
    header: "<JavaScriptCore/JavaScript.h>", importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Releases one Protect hold.