docs
Loading...
Searching...
No Matches
JSValueRef.h

Functions

 ios (10.0))
JSType JSValueGetType (JSContextRef ctx, JSValueRef value)
 Returns a JavaScript value's type.
bool JSValueIsUndefined (JSContextRef ctx, JSValueRef value)
 Tests whether a JavaScript value's type is the undefined type.
bool JSValueIsNull (JSContextRef ctx, JSValueRef value)
 Tests whether a JavaScript value's type is the null type.
bool JSValueIsBoolean (JSContextRef ctx, JSValueRef value)
 Tests whether a JavaScript value's type is the boolean type.
bool JSValueIsNumber (JSContextRef ctx, JSValueRef value)
 Tests whether a JavaScript value's type is the number type.
bool JSValueIsString (JSContextRef ctx, JSValueRef value)
 Tests whether a JavaScript value's type is the string type.
bool JSValueIsSymbol (JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macos(10.15)
 Tests whether a JavaScript value's type is the symbol type.
bool ios (13.0))
bool JSValueIsObject (JSContextRef ctx, JSValueRef value)
 Tests whether a JavaScript value's type is the object type.
bool JSValueIsObjectOfClass (JSContextRef ctx, JSValueRef value, JSClassRef jsClass)
 Tests whether a JavaScript value is an object with a given class in its class chain.
bool JSValueIsArray (JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macos(10.11)
 Tests whether a JavaScript value is an array.
bool ios (9.0))
bool JSValueIsDate (JSContextRef ctx, JSValueRef value) JSC_API_AVAILABLE(macos(10.11)
 Tests whether a JavaScript value is a date.
JSTypedArrayType JSValueGetTypedArrayType (JSContextRef ctx, JSValueRef value, JSValueRef *exception) JSC_API_AVAILABLE(macos(10.12)
 Returns a JavaScript value's Typed Array type.
bool JSValueIsEqual (JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef *exception)
 Tests whether two JavaScript values are equal, as compared by the JS == operator.
bool JSValueIsStrictEqual (JSContextRef ctx, JSValueRef a, JSValueRef b)
 Tests whether two JavaScript values are strict equal, as compared by the JS === operator.
bool JSValueIsInstanceOfConstructor (JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef *exception)
 Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator.
JSValueRef JSValueMakeUndefined (JSContextRef ctx)
 Creates a JavaScript value of the undefined type.
JSValueRef JSValueMakeNull (JSContextRef ctx)
 Creates a JavaScript value of the null type.
JSValueRef JSValueMakeBoolean (JSContextRef ctx, bool boolean)
 Creates a JavaScript value of the boolean type.
JSValueRef JSValueMakeNumber (JSContextRef ctx, double number)
 Creates a JavaScript value of the number type.
JSValueRef JSValueMakeString (JSContextRef ctx, JSStringRef string)
 Creates a JavaScript value of the string type.
JSValueRef JSValueMakeSymbol (JSContextRef ctx, JSStringRef description) JSC_API_AVAILABLE(macos(10.15)
 Creates a JavaScript value of the symbol type.
JSValueRef JSValueMakeFromJSONString (JSContextRef ctx, JSStringRef string) JSC_API_AVAILABLE(macos(10.7)
 Creates a JavaScript value from a JSON formatted string.
JSValueRef ios (7.0))
JSStringRef JSValueCreateJSONString (JSContextRef ctx, JSValueRef value, unsigned indent, JSValueRef *exception) JSC_API_AVAILABLE(macos(10.7)
 Creates a JavaScript string containing the JSON serialized representation of a JS value.
bool JSValueToBoolean (JSContextRef ctx, JSValueRef value)
 Converts a JavaScript value to boolean and returns the resulting boolean.
double JSValueToNumber (JSContextRef ctx, JSValueRef value, JSValueRef *exception)
 Converts a JavaScript value to number and returns the resulting number.
JSStringRef JSValueToStringCopy (JSContextRef ctx, JSValueRef value, JSValueRef *exception)
 Converts a JavaScript value to string and copies the result into a JavaScript string.
JSObjectRef JSValueToObject (JSContextRef ctx, JSValueRef value, JSValueRef *exception)
 Converts a JavaScript value to object and returns the resulting object.
void JSValueProtect (JSContextRef ctx, JSValueRef value)
 Protects a JavaScript value from garbage collection.
void JSValueUnprotect (JSContextRef ctx, JSValueRef value)
 Unprotects a JavaScript value from garbage collection.

Enumerations

enum  JSType {
  kJSTypeUndefined , kJSTypeNull , kJSTypeBoolean , kJSTypeNumber ,
  kJSTypeString , kJSTypeObject , JSC_API_AVAILABLE =(macos(10.15), ios(13.0))
}
 A constant identifying the type of a JSValue. More...
enum  JSTypedArrayType {
  kJSTypedArrayTypeInt8Array , kJSTypedArrayTypeInt16Array , kJSTypedArrayTypeInt32Array , kJSTypedArrayTypeUint8Array ,
  kJSTypedArrayTypeUint8ClampedArray , kJSTypedArrayTypeUint16Array , kJSTypedArrayTypeUint32Array , kJSTypedArrayTypeFloat32Array ,
  kJSTypedArrayTypeFloat64Array , kJSTypedArrayTypeArrayBuffer , kJSTypedArrayTypeNone , kJSTypedArrayTypeBigInt64Array ,
  kJSTypedArrayTypeBigUint64Array
}
 A constant identifying the Typed Array type of a JSObjectRef. More...

Function Documentation

◆ ios() [1/4]

ios ( 10. 0)

◆ ios() [2/4]

bool ios ( 13. 0)

◆ ios() [3/4]

JSValueRef ios ( 7. 0)

◆ ios() [4/4]

bool ios ( 9. 0)

◆ JSValueCreateJSONString()

JSStringRef JSValueCreateJSONString ( JSContextRef ctx,
JSValueRef value,
unsigned indent,
JSValueRef * exception )

Creates a JavaScript string containing the JSON serialized representation of a JS value.

Parameters
ctxThe execution context to use.
valueThe value to serialize.
indentThe number of spaces to indent when nesting. If 0, the resulting JSON will not contains newlines. The size of the indent is clamped to 10 spaces.
exceptionA pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Returns
A JSString with the result of serialization, or NULL if an exception is thrown.

◆ JSValueGetType()

JSType JSValueGetType ( JSContextRef ctx,
JSValueRef value )

Returns a JavaScript value's type.

Parameters
ctxThe execution context to use.
valueThe JSValue whose type you want to obtain.
Returns
A value of type JSType that identifies value's type.

◆ JSValueGetTypedArrayType()

JSTypedArrayType JSValueGetTypedArrayType ( JSContextRef ctx,
JSValueRef value,
JSValueRef * exception )

Returns a JavaScript value's Typed Array type.

Parameters
ctxThe execution context to use.
valueThe JSValue whose Typed Array type to return.
exceptionA pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Returns
A value of type JSTypedArrayType that identifies value's Typed Array type, or kJSTypedArrayTypeNone if the value is not a Typed Array object.

◆ JSValueIsArray()

bool JSValueIsArray ( JSContextRef ctx,
JSValueRef value )

Tests whether a JavaScript value is an array.

Parameters
ctxThe execution context to use.
valueThe JSValue to test.
Returns
true if value is an array, otherwise false.

◆ JSValueIsBoolean()

bool JSValueIsBoolean ( JSContextRef ctx,
JSValueRef value )

Tests whether a JavaScript value's type is the boolean type.

Parameters
ctxThe execution context to use.
valueThe JSValue to test.
Returns
true if value's type is the boolean type, otherwise false.

◆ JSValueIsDate()

bool JSValueIsDate ( JSContextRef ctx,
JSValueRef value )

Tests whether a JavaScript value is a date.

Parameters
ctxThe execution context to use.
valueThe JSValue to test.
Returns
true if value is a date, otherwise false.

◆ JSValueIsEqual()

bool JSValueIsEqual ( JSContextRef ctx,
JSValueRef a,
JSValueRef b,
JSValueRef * exception )

Tests whether two JavaScript values are equal, as compared by the JS == operator.

Parameters
ctxThe execution context to use.
aThe first value to test.
bThe second value to test.
exceptionA pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Returns
true if the two values are equal, false if they are not equal or an exception is thrown.

◆ JSValueIsInstanceOfConstructor()

bool JSValueIsInstanceOfConstructor ( JSContextRef ctx,
JSValueRef value,
JSObjectRef constructor,
JSValueRef * exception )

Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator.

Parameters
ctxThe execution context to use.
valueThe JSValue to test.
constructorThe constructor to test against.
exceptionA pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Returns
true if value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false.

◆ JSValueIsNull()

bool JSValueIsNull ( JSContextRef ctx,
JSValueRef value )

Tests whether a JavaScript value's type is the null type.

Parameters
ctxThe execution context to use.
valueThe JSValue to test.
Returns
true if value's type is the null type, otherwise false.

◆ JSValueIsNumber()

bool JSValueIsNumber ( JSContextRef ctx,
JSValueRef value )

Tests whether a JavaScript value's type is the number type.

Parameters
ctxThe execution context to use.
valueThe JSValue to test.
Returns
true if value's type is the number type, otherwise false.

◆ JSValueIsObject()

bool JSValueIsObject ( JSContextRef ctx,
JSValueRef value )

Tests whether a JavaScript value's type is the object type.

Parameters
ctxThe execution context to use.
valueThe JSValue to test.
Returns
true if value's type is the object type, otherwise false.

◆ JSValueIsObjectOfClass()

bool JSValueIsObjectOfClass ( JSContextRef ctx,
JSValueRef value,
JSClassRef jsClass )

Tests whether a JavaScript value is an object with a given class in its class chain.

Parameters
ctxThe execution context to use.
valueThe JSValue to test.
jsClassThe JSClass to test against.
Returns
true if value is an object and has jsClass in its class chain, otherwise false.

◆ JSValueIsStrictEqual()

bool JSValueIsStrictEqual ( JSContextRef ctx,
JSValueRef a,
JSValueRef b )

Tests whether two JavaScript values are strict equal, as compared by the JS === operator.

Parameters
ctxThe execution context to use.
aThe first value to test.
bThe second value to test.
Returns
true if the two values are strict equal, otherwise false.

◆ JSValueIsString()

bool JSValueIsString ( JSContextRef ctx,
JSValueRef value )

Tests whether a JavaScript value's type is the string type.

Parameters
ctxThe execution context to use.
valueThe JSValue to test.
Returns
true if value's type is the string type, otherwise false.

◆ JSValueIsSymbol()

bool JSValueIsSymbol ( JSContextRef ctx,
JSValueRef value )

Tests whether a JavaScript value's type is the symbol type.

Parameters
ctxThe execution context to use.
valueThe JSValue to test.
Returns
true if value's type is the symbol type, otherwise false.

◆ JSValueIsUndefined()

bool JSValueIsUndefined ( JSContextRef ctx,
JSValueRef value )

Tests whether a JavaScript value's type is the undefined type.

Parameters
ctxThe execution context to use.
valueThe JSValue to test.
Returns
true if value's type is the undefined type, otherwise false.

◆ JSValueMakeBoolean()

JSValueRef JSValueMakeBoolean ( JSContextRef ctx,
bool boolean )

Creates a JavaScript value of the boolean type.

Parameters
ctxThe execution context to use.
booleanThe bool to assign to the newly created JSValue.
Returns
A JSValue of the boolean type, representing the value of boolean.

◆ JSValueMakeFromJSONString()

JSValueRef JSValueMakeFromJSONString ( JSContextRef ctx,
JSStringRef string )

Creates a JavaScript value from a JSON formatted string.

Parameters
ctxThe execution context to use.
stringThe JSString containing the JSON string to be parsed.
Returns
A JSValue containing the parsed value, or NULL if the input is invalid.

◆ JSValueMakeNull()

JSValueRef JSValueMakeNull ( JSContextRef ctx)

Creates a JavaScript value of the null type.

Parameters
ctxThe execution context to use.
Returns
The unique null value.

◆ JSValueMakeNumber()

JSValueRef JSValueMakeNumber ( JSContextRef ctx,
double number )

Creates a JavaScript value of the number type.

Parameters
ctxThe execution context to use.
numberThe double to assign to the newly created JSValue.
Returns
A JSValue of the number type, representing the value of number.

◆ JSValueMakeString()

JSValueRef JSValueMakeString ( JSContextRef ctx,
JSStringRef string )

Creates a JavaScript value of the string type.

Parameters
ctxThe execution context to use.
stringThe JSString to assign to the newly created JSValue. The newly created JSValue retains string, and releases it upon garbage collection.
Returns
A JSValue of the string type, representing the value of string.

◆ JSValueMakeSymbol()

JSValueRef JSValueMakeSymbol ( JSContextRef ctx,
JSStringRef description )

Creates a JavaScript value of the symbol type.

Parameters
ctxThe execution context to use.
descriptionA description of the newly created symbol value.
Returns
A unique JSValue of the symbol type, whose description matches the one provided.

◆ JSValueMakeUndefined()

JSValueRef JSValueMakeUndefined ( JSContextRef ctx)

Creates a JavaScript value of the undefined type.

Parameters
ctxThe execution context to use.
Returns
The unique undefined value.

◆ JSValueProtect()

void JSValueProtect ( JSContextRef ctx,
JSValueRef value )

Protects a JavaScript value from garbage collection.

Parameters
ctxThe execution context to use.
valueThe JSValue to protect.
Note

Use this method when you want to store a JSValue in a global or on the heap, where the garbage collector will not be able to discover your reference to it.

A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection.

◆ JSValueToBoolean()

bool JSValueToBoolean ( JSContextRef ctx,
JSValueRef value )

Converts a JavaScript value to boolean and returns the resulting boolean.

Parameters
ctxThe execution context to use.
valueThe JSValue to convert.
Returns
The boolean result of conversion.

◆ JSValueToNumber()

double JSValueToNumber ( JSContextRef ctx,
JSValueRef value,
JSValueRef * exception )

Converts a JavaScript value to number and returns the resulting number.

Parameters
ctxThe execution context to use.
valueThe JSValue to convert.
exceptionA pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Returns
The numeric result of conversion, or NaN if an exception is thrown.

◆ JSValueToObject()

JSObjectRef JSValueToObject ( JSContextRef ctx,
JSValueRef value,
JSValueRef * exception )

Converts a JavaScript value to object and returns the resulting object.

Parameters
ctxThe execution context to use.
valueThe JSValue to convert.
exceptionA pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Returns
The JSObject result of conversion, or NULL if an exception is thrown.

◆ JSValueToStringCopy()

JSStringRef JSValueToStringCopy ( JSContextRef ctx,
JSValueRef value,
JSValueRef * exception )

Converts a JavaScript value to string and copies the result into a JavaScript string.

Parameters
ctxThe execution context to use.
valueThe JSValue to convert.
exceptionA pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Returns
A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule.

◆ JSValueUnprotect()

void JSValueUnprotect ( JSContextRef ctx,
JSValueRef value )

Unprotects a JavaScript value from garbage collection.

Parameters
ctxThe execution context to use.
valueThe JSValue to unprotect.
Note
A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection.

Enumeration Type Documentation

◆ JSType

enum JSType

A constant identifying the type of a JSValue.

  • kJSTypeUndefined The unique undefined value.
  • kJSTypeNull The unique null value.
  • kJSTypeBoolean A primitive boolean value, one of true or false.
  • kJSTypeNumber A primitive number value.
  • kJSTypeString A primitive string value.
  • kJSTypeObject An object value (meaning that this JSValueRef is a JSObjectRef).
  • kJSTypeSymbol A primitive symbol value.
Enumerator
kJSTypeUndefined 
kJSTypeNull 
kJSTypeBoolean 
kJSTypeNumber 
kJSTypeString 
kJSTypeObject 
JSC_API_AVAILABLE 

◆ JSTypedArrayType

A constant identifying the Typed Array type of a JSObjectRef.

  • kJSTypedArrayTypeInt8Array Int8Array
  • kJSTypedArrayTypeInt16Array Int16Array
  • kJSTypedArrayTypeInt32Array Int32Array
  • kJSTypedArrayTypeUint8Array Uint8Array
  • kJSTypedArrayTypeUint8ClampedArray Uint8ClampedArray
  • kJSTypedArrayTypeUint16Array Uint16Array
  • kJSTypedArrayTypeUint32Array Uint32Array
  • kJSTypedArrayTypeFloat32Array Float32Array
  • kJSTypedArrayTypeFloat64Array Float64Array
  • kJSTypedArrayTypeBigInt64Array BigInt64Array
  • kJSTypedArrayTypeBigUint64Array BigUint64Array
  • kJSTypedArrayTypeArrayBuffer ArrayBuffer
  • kJSTypedArrayTypeNone Not a Typed Array
Enumerator
kJSTypedArrayTypeInt8Array 
kJSTypedArrayTypeInt16Array 
kJSTypedArrayTypeInt32Array 
kJSTypedArrayTypeUint8Array 
kJSTypedArrayTypeUint8ClampedArray 
kJSTypedArrayTypeUint16Array 
kJSTypedArrayTypeUint32Array 
kJSTypedArrayTypeFloat32Array 
kJSTypedArrayTypeFloat64Array 
kJSTypedArrayTypeArrayBuffer 
kJSTypedArrayTypeNone 
kJSTypedArrayTypeBigInt64Array 
kJSTypedArrayTypeBigUint64Array 

Go to the source code of this file.