struct JSStaticFunction
This structure contains properties and callbacks that define a type of object. All fields other than the version field are optional. Any pointer may be NULL.
The staticValues and staticFunctions arrays are the simplest and most efficient means for vending custom properties. Statically declared properties autmatically service requests like getProperty, setProperty, and getPropertyNames. Property access callbacks are required only to implement unusual properties, like array indexes, whose names are not known at compile-time.
Checks for syntax errors in a string of JavaScript.
ctx (JSContextRef) The execution context to use.
script (JSStringRef) A JSString containing the script to check for syntax errors.
sourceURL (JSStringRef) A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
startingLineNumber (int) An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
exception (JSValueRef*) A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception.
@result (bool) true if the script is syntactically correct, otherwise false.
Creates a JavaScript class suitable for use with JSObjectMake.
definition (JSClassDefinition*) A JSClassDefinition that defines the class.
@result (JSClassRef) A JSClass with the given definition. Ownership follows the Create Rule.
Gets the global context of a JavaScript execution context.
ctx (JSContextRef) The JSContext whose global context you want to get.
@result (JSGlobalContextRef) ctx's global context.
Gets the global object of a JavaScript execution context.
ctx (JSContextRef) The JSContext whose global object you want to get.
@result (JSObjectRef) ctx's global object.
Gets the context group to which a JavaScript execution context belongs.
ctx (JSContextRef) The JSContext whose group you want to get.
@result (JSContextGroupRef) ctx's group.
Creates a JavaScript context group.
A JSContextGroup associates JavaScript contexts with one another.
Contexts in the same group may share and exchange JavaScript objects. Sharing and/or exchanging
JavaScript objects between contexts in different groups will produce undefined behavior.
When objects from the same context group are used in multiple threads, explicit
synchronization is required.
Retains a JavaScript context group.
group (JSContextGroupRef) The JSContextGroup to retain.
@result (JSContextGroupRef) A JSContextGroup that is the same as group.
Evaluates a string of JavaScript.
ctx (JSContextRef) The execution context to use.
script (JSStringRef) A JSString containing the script to evaluate.
thisObject (JSObjectRef) The object to use as "this," or NULL to use the global object as "this."
sourceURL (JSStringRef) A JSString containing a URL for the script's source file. This is used by debuggers and when reporting exceptions. Pass NULL if you do not care to include source file information.
startingLineNumber (int) An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSValueRef) The JSValue that results from evaluating script, or NULL if an exception is thrown.
Performs a JavaScript garbage collection.
JavaScript values that are on the machine stack, in a register,
protected by JSValueProtect, set as the global object of an execution context,
or reachable from any such value will not be collected.
Gets a copy of the name of a context.
A JSGlobalContext's name is exposed for remote debugging to make it
easier to identify the context you would like to attach to.
ctx (JSGlobalContextRef) The JSGlobalContext whose name you want to get.
@result (JSStringRef) The name for ctx.
Creates a global JavaScript execution context.
JSGlobalContextCreate allocates a global object and populates it with all the
built-in JavaScript objects, such as Object, Function, String, and Array.
Creates a global JavaScript execution context in the context group provided.
JSGlobalContextCreateInGroup allocates a global object and populates it with
all the built-in JavaScript objects, such as Object, Function, String, and Array.
group (JSContextGroupRef) The context group to use. The created global context retains the group. Pass NULL to create a unique group for the context.
globalObjectClass (JSClassRef) The class to use when creating the global object. Pass NULL to use the default object class.
@result (JSGlobalContextRef) A JSGlobalContext with a global object of class globalObjectClass and a context group equal to group.
Retains a global JavaScript execution context.
ctx (JSGlobalContextRef) The JSGlobalContext to retain.
@result (JSGlobalContextRef) A JSGlobalContext that is the same as ctx.
Sets the remote debugging name for a context.
ctx (JSGlobalContextRef) The JSGlobalContext that you want to name.
name (JSStringRef) The remote debugging name to set on ctx.
Calls an object as a constructor.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject to call as a constructor.
argumentCount (size_t) An integer count of the number of arguments in arguments.
arguments (JSValueRef[]) A JSValue array of arguments to pass to the constructor. Pass NULL if argumentCount is 0.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor.
Calls an object as a function.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject to call as a function.
thisObject (JSObjectRef) The object to use as "this," or NULL to use the global object as "this."
argumentCount (size_t) An integer count of the number of arguments in arguments.
arguments (JSValueRef[]) A JSValue array of arguments to pass to the function. Pass NULL if argumentCount is 0.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSValueRef) The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function.
Gets the names of an object's enumerable properties.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The object whose property names you want to get.
@result (JSPropertyNameArrayRef) A JSPropertyNameArray containing the names object's enumerable properties. Ownership follows the Create Rule.
Deletes a property from an object.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject whose property you want to delete.
propertyName (JSStringRef) A JSString containing the property's name.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (bool) true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
Deletes a property from an object using a JSValueRef as the property key.
This function is the same as performing "delete objectpropertyKey" from JavaScript.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject whose property you want to delete.
propertyKey (JSValueRef) A JSValueRef containing the property key to use when looking up the property.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (bool) true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
Returns the number of bytes in a JavaScript data object.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JS Arary Buffer object whose length in bytes to return.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (size_t) The number of bytes stored in the data object.
Returns a pointer to the data buffer that serves as the backing store for a JavaScript Typed Array object.
The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls.
ctx (JSContextRef)
object (JSObjectRef) The Array Buffer object whose internal backing store pointer to return.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (void*) A pointer to the raw data buffer that serves as object's backing store or NULL if object is not an Array Buffer object.
Gets an object's private data.
object (JSObjectRef) A JSObject whose private data you want to get.
@result (void*) A void* that is the object's private data, if the object has private data, otherwise NULL.
Gets a property from an object.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject whose property you want to get.
propertyName (JSStringRef) A JSString containing the property's name.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSValueRef) The property's value if object has the property, otherwise the undefined value.
Gets a property from an object by numeric index.
Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but JSObjectGetPropertyAtIndex provides optimized access to numeric properties.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject whose property you want to get.
propertyIndex (unsigned) An integer value that is the property's name.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSValueRef) The property's value if object has the property, otherwise the undefined value.
Gets a property from an object using a JSValueRef as the property key.
This function is the same as performing "objectpropertyKey" from JavaScript.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject whose property you want to get.
propertyKey (JSValueRef) A JSValueRef containing the property key to use when looking up the property.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSValueRef) The property's value if object has the property key, otherwise the undefined value.
Gets an object's prototype.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) A JSObject whose prototype you want to get.
@result (JSValueRef) A JSValue that is the object's prototype.
Returns the JavaScript Array Buffer object that is used as the backing of a JavaScript Typed Array object.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObjectRef whose Typed Array type data pointer to obtain.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) A JSObjectRef with a JSTypedArrayType of kJSTypedArrayTypeArrayBuffer or NULL if object is not a Typed Array.
Returns the byte length of a JavaScript Typed Array object.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The Typed Array object whose byte length to return.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (size_t) The byte length of the Typed Array object or 0 if the object is not a Typed Array object.
Returns the byte offset of a JavaScript Typed Array object.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The Typed Array object whose byte offset to return.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (size_t) The byte offset of the Typed Array object or 0 if the object is not a Typed Array object.
Returns a temporary pointer to the backing store of a JavaScript Typed Array object.
The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The Typed Array object whose backing store pointer to return.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (void*) A pointer to the raw data buffer that serves as object's backing store or NULL if object is not a Typed Array object.
Returns the length of a JavaScript Typed Array object.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The Typed Array object whose length to return.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (size_t) The length of the Typed Array object or 0 if the object is not a Typed Array object.
Tests whether an object has a given property.
ctx (JSContextRef)
object (JSObjectRef) The JSObject to test.
propertyName (JSStringRef) A JSString containing the property's name.
@result (bool) true if the object has a property whose name matches propertyName, otherwise false.
Tests whether an object has a given property using a JSValueRef as the property key.
This function is the same as performing "propertyKey in object" from JavaScript.
ctx (JSContextRef)
object (JSObjectRef) The JSObject to test.
propertyKey (JSValueRef) A JSValueRef containing the property key to use when looking up the property.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (bool) true if the object has a property whose name matches propertyKey, otherwise false.
Tests whether an object can be called as a constructor.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject to test.
@result (bool) true if the object can be called as a constructor, otherwise false.
Tests whether an object can be called as a function.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject to test.
@result (bool) true if the object can be called as a function, otherwise false.
Creates a JavaScript object.
The default object class does not allocate storage for private data, so you must provide a non-NULL jsClass to JSObjectMake if you want your object to be able to store private data.
Creates a JavaScript Array object.
The behavior of this function does not exactly match the behavior of the built-in Array constructor. Specifically, if one argument
is supplied, this function returns an array with one element.
ctx (JSContextRef) The execution context to use.
argumentCount (size_t) An integer count of the number of arguments in arguments.
arguments (JSValueRef[]) A JSValue array of data to populate the Array with. Pass NULL if argumentCount is 0.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) A JSObject that is an Array.
Creates a JavaScript Array Buffer object from an existing pointer.
If an exception is thrown during this function the bytesDeallocator will always be called.
ctx (JSContextRef) The execution context to use.
bytes (void*) A pointer to the byte buffer to be used as the backing store of the Typed Array object.
byteLength (size_t) The number of bytes pointed to by the parameter bytes.
bytesDeallocator (JSTypedArrayBytesDeallocator) The allocator to use to deallocate the external buffer when the Typed Array data object is deallocated.
deallocatorContext (void*) A pointer to pass back to the deallocator.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) A JSObjectRef Array Buffer whose backing store is the same as the one pointed to by bytes or NULL if there was an error.
Convenience method for creating a JavaScript constructor.
The default object constructor takes no arguments and constructs an object of class jsClass with no private data.
ctx (JSContextRef) The execution context to use.
jsClass (JSClassRef) A JSClass that is the class your constructor will assign to the objects its constructs. jsClass will be used to set the constructor's .prototype property, and to evaluate 'instanceof' expressions. Pass NULL to use the default object class.
callAsConstructor (JSObjectCallAsConstructorCallback) A JSObjectCallAsConstructorCallback to invoke when your constructor is used in a 'new' expression. Pass NULL to use the default object constructor.
@result (JSObjectRef) A JSObject that is a constructor. The object's prototype will be the default object prototype.
Creates a JavaScript Date object, as if by invoking the built-in Date constructor.
ctx (JSContextRef) The execution context to use.
argumentCount (size_t) An integer count of the number of arguments in arguments.
arguments (JSValueRef[]) A JSValue array of arguments to pass to the Date Constructor. Pass NULL if argumentCount is 0.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) A JSObject that is a Date.
Creates a JavaScript promise object by invoking the provided executor.
ctx (JSContextRef) The execution context to use.
resolve (JSObjectRef*) A pointer to a JSObjectRef in which to store the resolve function for the new promise. Pass NULL if you do not care to store the resolve callback.
reject (JSObjectRef*) A pointer to a JSObjectRef in which to store the reject function for the new promise. Pass NULL if you do not care to store the reject callback.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) A JSObject that is a promise or NULL if an exception occurred.
Creates a JavaScript Error object, as if by invoking the built-in Error constructor.
ctx (JSContextRef) The execution context to use.
argumentCount (size_t) An integer count of the number of arguments in arguments.
arguments (JSValueRef[]) A JSValue array of arguments to pass to the Error Constructor. Pass NULL if argumentCount is 0.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) A JSObject that is a Error.
Creates a function with a given script as its body.
Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.
ctx (JSContextRef) The execution context to use.
name (JSStringRef) A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function.
parameterCount (unsigned) An integer count of the number of parameter names in parameterNames.
parameterNames (JSStringRef[]) A JSString array containing the names of the function's parameters. Pass NULL if parameterCount is 0.
body (JSStringRef) A JSString containing the script to use as the function's body.
sourceURL (JSStringRef) A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
startingLineNumber (int) An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
exception (JSValueRef*) A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception.
@result (JSObjectRef) A JSObject that is a function, or NULL if either body or parameterNames contains a syntax error. The object's prototype will be the default function prototype.
Convenience method for creating a JavaScript function with a given callback as its implementation.
ctx (JSContextRef) The execution context to use.
name (JSStringRef) A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function.
callAsFunction (JSObjectCallAsFunctionCallback) The JSObjectCallAsFunctionCallback to invoke when the function is called.
@result (JSObjectRef) A JSObject that is a function. The object's prototype will be the default function prototype.
Creates a JavaScript RegExp object, as if by invoking the built-in RegExp constructor.
ctx (JSContextRef) The execution context to use.
argumentCount (size_t) An integer count of the number of arguments in arguments.
arguments (JSValueRef[]) A JSValue array of arguments to pass to the RegExp Constructor. Pass NULL if argumentCount is 0.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) A JSObject that is a RegExp.
Creates a JavaScript Typed Array object with the given number of elements.
ctx (JSContextRef) The execution context to use.
arrayType (JSTypedArrayType) A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
length (size_t) The number of elements to be in the new Typed Array.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) A JSObjectRef that is a Typed Array with all elements set to zero or NULL if there was an error.
Creates a JavaScript Typed Array object from an existing JavaScript Array Buffer object.
ctx (JSContextRef) The execution context to use.
arrayType (JSTypedArrayType) A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
buffer (JSObjectRef) An Array Buffer object that should be used as the backing store for the created JavaScript Typed Array object.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer.
Creates a JavaScript Typed Array object from an existing JavaScript Array Buffer object with the given offset and length.
ctx (JSContextRef) The execution context to use.
arrayType (JSTypedArrayType) A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
buffer (JSObjectRef) An Array Buffer object that should be used as the backing store for the created JavaScript Typed Array object.
byteOffset (size_t) The byte offset for the created Typed Array. byteOffset should aligned with the element size of arrayType.
length (size_t) The number of elements to include in the Typed Array.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer.
Creates a JavaScript Typed Array object from an existing pointer.
If an exception is thrown during this function the bytesDeallocator will always be called.
ctx (JSContextRef) The execution context to use.
arrayType (JSTypedArrayType) A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
bytes (void*) A pointer to the byte buffer to be used as the backing store of the Typed Array object.
byteLength (size_t) The number of bytes pointed to by the parameter bytes.
bytesDeallocator (JSTypedArrayBytesDeallocator) The allocator to use to deallocate the external buffer when the JSTypedArrayData object is deallocated.
deallocatorContext (void*) A pointer to pass back to the deallocator.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) A JSObjectRef Typed Array whose backing store is the same as the one pointed to by bytes or NULL if there was an error.
Sets a pointer to private data on an object.
The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data.
object (JSObjectRef) The JSObject whose private data you want to set.
data (void*) A void* to set as the object's private data.
@result (bool) true if object can store private data, otherwise false.
Sets a property on an object.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject whose property you want to set.
propertyName (JSStringRef) A JSString containing the property's name.
value (JSValueRef) A JSValueRef to use as the property's value.
attributes (JSPropertyAttributes) A logically ORed set of JSPropertyAttributes to give to the property.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Sets a property on an object by numeric index.
Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but JSObjectSetPropertyAtIndex provides optimized access to numeric properties.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject whose property you want to set.
propertyIndex (unsigned) The property's name as a number.
value (JSValueRef) A JSValue to use as the property's value.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Sets a property on an object using a JSValueRef as the property key.
This function is the same as performing "objectpropertyKey = value" from JavaScript.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject whose property you want to set.
propertyKey (JSValueRef) A JSValueRef containing the property key to use when looking up the property.
value (JSValueRef) A JSValueRef to use as the property's value.
attributes (JSPropertyAttributes) A logically ORed set of JSPropertyAttributes to give to the property.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Sets an object's prototype.
ctx (JSContextRef) The execution context to use.
object (JSObjectRef) The JSObject whose prototype you want to set.
value (JSValueRef) A JSValue to set as the object's prototype.
Adds a property name to a JavaScript property name accumulator.
accumulator (JSPropertyNameAccumulatorRef) The accumulator object to which to add the property name.
propertyName (JSStringRef) The property name to add.
Gets a count of the number of items in a JavaScript property name array.
array (JSPropertyNameArrayRef) The array from which to retrieve the count.
@result (size_t) An integer count of the number of names in array.
Gets a property name at a given index in a JavaScript property name array.
array (JSPropertyNameArrayRef) The array from which to retrieve the property name.
index (size_t) The index of the property name to retrieve.
@result (JSStringRef) A JSStringRef containing the property name.
Retains a JavaScript property name array.
array (JSPropertyNameArrayRef) The JSPropertyNameArray to retain.
@result (JSPropertyNameArrayRef) A JSPropertyNameArray that is the same as array.
Creates a JavaScript string from a buffer of Unicode characters.
chars (JSChar*) The buffer of Unicode characters to copy into the new JSString.
numChars (size_t) The number of characters to copy from the buffer pointed to by chars.
@result (JSStringRef) A JSString containing chars. Ownership follows the Create Rule.
Creates a JavaScript string from a null-terminated UTF8 string.
string (char*) The null-terminated UTF8 string to copy into the new JSString.
@result (JSStringRef) A JSString containing string. Ownership follows the Create Rule.
Returns a pointer to the Unicode character buffer that
serves as the backing store for a JavaScript string.
string (JSStringRef) The JSString whose backing store you want to access.
@result (const JSChar*) A pointer to the Unicode character buffer that serves as string's backing store, which will be deallocated when string is deallocated.
Returns the number of Unicode characters in a JavaScript string.
string (JSStringRef) The JSString whose length (in Unicode characters) you want to know.
@result (size_t) The number of Unicode characters stored in string.
Returns the maximum number of bytes a JavaScript string will
take up if converted into a null-terminated UTF8 string.
string (JSStringRef) The JSString whose maximum converted size (in bytes) you want to know.
@result (size_t) The maximum number of bytes that could be required to convert string into a null-terminated UTF8 string. The number of bytes that the conversion actually ends up requiring could be less than this, but never more.
Converts a JavaScript string into a null-terminated UTF8 string,
and copies the result into an external byte buffer.
string (JSStringRef) The source JSString.
buffer (char*) The destination byte buffer into which to copy a null-terminated UTF8 representation of string. On return, buffer contains a UTF8 string representation of string. If bufferSize is too small, buffer will contain only partial results. If buffer is not at least bufferSize bytes in size, behavior is undefined.
bufferSize (size_t) The size of the external buffer in bytes.
@result (size_t) The number of bytes written into buffer (including the null-terminator byte).
Tests whether two JavaScript strings match.
a (JSStringRef) The first JSString to test.
b (JSStringRef) The second JSString to test.
@result (bool) true if the two strings match, otherwise false.
Tests whether a JavaScript string matches a null-terminated UTF8 string.
a (JSStringRef) The JSString to test.
b (char*) The null-terminated UTF8 string to test.
@result (bool) true if the two strings match, otherwise false.
Creates a JavaScript string containing the JSON serialized representation of a JS value.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The value to serialize.
indent (unsigned) The 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.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSStringRef) A JSString with the result of serialization, or NULL if an exception is thrown.
Returns a JavaScript value's type.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue whose type you want to obtain.
@result (JSType) A value of type JSType that identifies value's type.
Returns a JavaScript value's Typed Array type.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue whose Typed Array type to return.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSTypedArrayType) A value of type JSTypedArrayType that identifies value's Typed Array type, or kJSTypedArrayTypeNone if the value is not a Typed Array object.
Tests whether a JavaScript value is an array.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to test.
@result (bool) true if value is an array, otherwise false.
Tests whether a JavaScript value's type is the boolean type.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to test.
@result (bool) true if value's type is the boolean type, otherwise false.
Tests whether a JavaScript value is a date.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to test.
@result (bool) true if value is a date, otherwise false.
Tests whether two JavaScript values are equal, as compared by the JS == operator.
ctx (JSContextRef) The execution context to use.
a (JSValueRef) The first value to test.
b (JSValueRef) The second value to test.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (bool) true if the two values are equal, false if they are not equal or an exception is thrown.
Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to test.
constructor (JSObjectRef) The constructor to test against.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (bool) true if value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false.
Tests whether a JavaScript value's type is the null type.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to test.
@result (bool) true if value's type is the null type, otherwise false.
Tests whether a JavaScript value's type is the number type.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to test.
@result (bool) true if value's type is the number type, otherwise false.
Tests whether a JavaScript value's type is the object type.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to test.
@result (bool) true if value's type is the object type, otherwise false.
Tests whether a JavaScript value is an object with a given class in its class chain.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to test.
jsClass (JSClassRef) The JSClass to test against.
@result (bool) true if value is an object and has jsClass in its class chain, otherwise false.
Tests whether two JavaScript values are strict equal, as compared by the JS === operator.
ctx (JSContextRef) The execution context to use.
a (JSValueRef) The first value to test.
b (JSValueRef) The second value to test.
@result (bool) true if the two values are strict equal, otherwise false.
Tests whether a JavaScript value's type is the string type.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to test.
@result (bool) true if value's type is the string type, otherwise false.
Tests whether a JavaScript value's type is the symbol type.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to test.
@result (bool) true if value's type is the symbol type, otherwise false.
Tests whether a JavaScript value's type is the undefined type.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to test.
@result (bool) true if value's type is the undefined type, otherwise false.
Creates a JavaScript value of the boolean type.
ctx (JSContextRef) The execution context to use.
boolean (bool) The bool to assign to the newly created JSValue.
@result (JSValueRef) A JSValue of the boolean type, representing the value of boolean.
Creates a JavaScript value from a JSON formatted string.
ctx (JSContextRef) The execution context to use.
string (JSStringRef) The JSString containing the JSON string to be parsed.
@result (JSValueRef) A JSValue containing the parsed value, or NULL if the input is invalid.
Creates a JavaScript value of the number type.
ctx (JSContextRef) The execution context to use.
number (double) The double to assign to the newly created JSValue.
@result (JSValueRef) A JSValue of the number type, representing the value of number.
Creates a JavaScript value of the string type.
ctx (JSContextRef) The execution context to use.
string (JSStringRef) The JSString to assign to the newly created JSValue. The newly created JSValue retains string, and releases it upon garbage collection.
@result (JSValueRef) A JSValue of the string type, representing the value of string.
Creates a JavaScript value of the symbol type.
ctx (JSContextRef) The execution context to use.
description (JSStringRef) A description of the newly created symbol value.
@result (JSValueRef) A unique JSValue of the symbol type, whose description matches the one provided.
Protects a JavaScript value from garbage collection.
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.
Converts a JavaScript value to boolean and returns the resulting boolean.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to convert.
@result (bool) The boolean result of conversion.
Converts a JavaScript value to number and returns the resulting number.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to convert.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (double) The numeric result of conversion, or NaN if an exception is thrown.
Converts a JavaScript value to object and returns the resulting object.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to convert.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSObjectRef) The JSObject result of conversion, or NULL if an exception is thrown.
Converts a JavaScript value to string and copies the result into a JavaScript string.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to convert.
exception (JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result (JSStringRef) A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule.
Unprotects a JavaScript value from garbage collection.
A value may be protected multiple times and must be unprotected an
equal number of times before becoming eligible for garbage collection.
ctx (JSContextRef) The execution context to use.
value (JSValueRef) The JSValue to unprotect.
typedef JSObjectCallAsConstructorCallback
The callback invoked when an object is used as a constructor in a 'new' expression.
ctx The execution context to use.
constructor A JSObject that is the constructor being called.
argumentCount An integer count of the number of arguments in arguments.
arguments A JSValue array of the arguments passed to the function.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result A JSObject that is the constructor's return value.
If you named your function CallAsConstructor, you would declare it like this:
typedef JSObjectCallAsFunctionCallback
The callback invoked when an object is called as a function.
ctx The execution context to use.
function A JSObject that is the function being called.
thisObject A JSObject that is the 'this' variable in the function's scope.
argumentCount An integer count of the number of arguments in arguments.
arguments A JSValue array of the arguments passed to the function.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result A JSValue that is the function's return value.
If you named your function CallAsFunction, you would declare it like this:
typedef JSObjectConvertToTypeCallback
The callback invoked when converting an object to a particular JavaScript type.
ctx The execution context to use.
object The JSObject to convert.
type A JSType specifying the JavaScript type to convert to.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result The objects's converted value, or NULL if the object was not converted.
If you named your function ConvertToType, you would declare it like this:
typedef JSObjectDeletePropertyCallback
The callback invoked when deleting a property.
ctx The execution context to use.
object The JSObject in which to delete the property.
propertyName A JSString containing the name of the property to delete.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result true if propertyName was successfully deleted, otherwise false.
If you named your function DeleteProperty, you would declare it like this:
typedef JSObjectFinalizeCallback
The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread.
object The JSObject being finalized.
If you named your function Finalize, you would declare it like this:
typedef JSObjectGetPropertyCallback
The callback invoked when getting a property's value.
ctx The execution context to use.
object The JSObject to search for the property.
propertyName A JSString containing the name of the property to get.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result The property's value if object has the property, otherwise NULL.
If you named your function GetProperty, you would declare it like this:
typedef JSObjectGetPropertyNamesCallback
The callback invoked when collecting the names of an object's properties.
ctx The execution context to use.
object The JSObject whose property names are being collected.
propertyNames A JavaScript property name accumulator in which to accumulate the names of object's properties.
If you named your function GetPropertyNames, you would declare it like this:
typedef JSObjectHasInstanceCallback
hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
ctx The execution context to use.
constructor The JSObject that is the target of the 'instanceof' expression.
possibleInstance The JSValue being tested to determine if it is an instance of constructor.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result true if possibleInstance is an instance of constructor, otherwise false.
If you named your function HasInstance, you would declare it like this:
typedef JSObjectHasPropertyCallback
The callback invoked when determining whether an object has a property.
ctx The execution context to use.
object The JSObject to search for the property.
propertyName A JSString containing the name of the property look up.
@result true if object has the property, otherwise false.
If you named your function HasProperty, you would declare it like this:
typedef JSObjectInitializeCallback
The callback invoked when an object is first created.
ctx The execution context to use.
object The JSObject being created.
If you named your function Initialize, you would declare it like this:
typedef JSObjectSetPropertyCallback
The callback invoked when setting a property's value.
ctx The execution context to use.
object The JSObject on which to set the property's value.
propertyName A JSString containing the name of the property to set.
value A JSValue to use as the property's value.
exception A pointer to a JSValueRef in which to return an exception, if any.
@result true if the property was set, otherwise false.
If you named your function SetProperty, you would declare it like this:
typedef JSTypedArrayBytesDeallocator A function used to deallocate bytes passed to a Typed Array constructor. The function should take two arguments. The first is a pointer to the bytes that were originally passed to the Typed Array constructor. The second is a pointer to additional information desired at the time the bytes are to be freed.
typedef void (JSTypedArrayBytesDeallocator)(void bytes, void* deallocatorContext);