Module jscjs_sys::api[][src]

Structs

JSClassDefinition

@struct JSClassDefinition @abstract 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. @field version The version number of this structure. The current version is 0. @field attributes A logically ORed set of JSClassAttributes to give to the class. @field className A null-terminated UTF8 string containing the class’s name. @field parentClass A JSClass to set as the class’s parent class. Pass NULL use the default object class. @field staticValues A JSStaticValue array containing the class’s statically declared value properties. Pass NULL to specify no statically declared value properties. The array must be terminated by a JSStaticValue whose name field is NULL. @field staticFunctions A JSStaticFunction array containing the class’s statically declared function properties. Pass NULL to specify no statically declared function properties. The array must be terminated by a JSStaticFunction whose name field is NULL. @field initialize The callback invoked when an object is first created. Use this callback to initialize the object. @field finalize The callback invoked when an object is finalized (prepared for garbage collection). Use this callback to release resources allocated for the object, and perform other cleanup. @field hasProperty The callback invoked when determining whether an object has a property. If this field is NULL, getProperty is called instead. The hasProperty callback enables optimization in cases where only a property’s existence needs to be known, not its value, and computing its value is expensive. @field getProperty The callback invoked when getting a property’s value. @field setProperty The callback invoked when setting a property’s value. @field deleteProperty The callback invoked when deleting a property. @field getPropertyNames The callback invoked when collecting the names of an object’s properties. @field callAsFunction The callback invoked when an object is called as a function. @field hasInstance The callback invoked when an object is used as the target of an ‘instanceof’ expression. @field callAsConstructor The callback invoked when an object is used as a constructor in a ‘new’ expression. @field convertToType The callback invoked when converting an object to a particular JavaScript type. @discussion 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.

JSStaticFunction

@struct JSStaticFunction @abstract This structure describes a statically declared function property. @field name A null-terminated UTF8 string containing the property’s name. @field callAsFunction A JSObjectCallAsFunctionCallback to invoke when the property is called as a function. @field attributes A logically ORed set of JSPropertyAttributes to give to the property.

JSStaticValue

@struct JSStaticValue @abstract This structure describes a statically declared value property. @field name A null-terminated UTF8 string containing the property’s name. @field getProperty A JSObjectGetPropertyCallback to invoke when getting the property’s value. @field setProperty A JSObjectSetPropertyCallback to invoke when setting the property’s value. May be NULL if the ReadOnly attribute is set. @field attributes A logically ORed set of JSPropertyAttributes to give to the property.

OpaqueJSClass
OpaqueJSContext
OpaqueJSContextGroup
OpaqueJSPropertyNameAccumulator
OpaqueJSPropertyNameArray
OpaqueJSString
OpaqueJSValue

Enums

JSType

@enum JSType @abstract A constant identifying the type of a JSValue. @constant kJSTypeUndefined The unique undefined value. @constant kJSTypeNull The unique null value. @constant kJSTypeBoolean A primitive boolean value, one of true or false. @constant kJSTypeNumber A primitive number value. @constant kJSTypeString A primitive string value. @constant kJSTypeObject An object value (meaning that this JSValueRef is a JSObjectRef). @constant kJSTypeSymbol A primitive symbol value.

JSTypedArrayType

@enum JSTypedArrayType @abstract A constant identifying the Typed Array type of a JSObjectRef. @constant kJSTypedArrayTypeInt8Array Int8Array @constant kJSTypedArrayTypeInt16Array Int16Array @constant kJSTypedArrayTypeInt32Array Int32Array @constant kJSTypedArrayTypeUint8Array Uint8Array @constant kJSTypedArrayTypeUint8ClampedArray Uint8ClampedArray @constant kJSTypedArrayTypeUint16Array Uint16Array @constant kJSTypedArrayTypeUint32Array Uint32Array @constant kJSTypedArrayTypeFloat32Array Float32Array @constant kJSTypedArrayTypeFloat64Array Float64Array @constant kJSTypedArrayTypeBigInt64Array BigInt64Array @constant kJSTypedArrayTypeBigUint64Array BigUint64Array @constant kJSTypedArrayTypeArrayBuffer ArrayBuffer @constant kJSTypedArrayTypeNone Not a Typed Array

Functions

JSCheckScriptSyntax

@function JSCheckScriptSyntax @abstract Checks for syntax errors in a string of JavaScript. @param ctx The execution context to use. @param script A JSString containing the script to check for syntax errors. @param sourceURL 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. @param startingLineNumber 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. @param exception 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 true if the script is syntactically correct, otherwise false.

JSClassCreate

@function @abstract Creates a JavaScript class suitable for use with JSObjectMake. @param definition A JSClassDefinition that defines the class. @result A JSClass with the given definition. Ownership follows the Create Rule.

JSClassRelease

@function @abstract Releases a JavaScript class. @param jsClass The JSClass to release.

JSClassRetain

@function @abstract Retains a JavaScript class. @param jsClass The JSClass to retain. @result A JSClass that is the same as jsClass.

JSContextGetGlobalContext

@function @abstract Gets the global context of a JavaScript execution context. @param ctx The JSContext whose global context you want to get. @result ctx’s global context.

JSContextGetGlobalObject

@function @abstract Gets the global object of a JavaScript execution context. @param ctx The JSContext whose global object you want to get. @result ctx’s global object.

JSContextGetGroup

@function @abstract Gets the context group to which a JavaScript execution context belongs. @param ctx The JSContext whose group you want to get. @result ctx’s group.

JSContextGroupCreate

@function @abstract Creates a JavaScript context group. @discussion 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.

JSContextGroupRelease

@function @abstract Releases a JavaScript context group. @param group The JSContextGroup to release.

JSContextGroupRetain

@function @abstract Retains a JavaScript context group. @param group The JSContextGroup to retain. @result A JSContextGroup that is the same as group.

JSEvaluateScript

@function JSEvaluateScript @abstract Evaluates a string of JavaScript. @param ctx The execution context to use. @param script A JSString containing the script to evaluate. @param thisObject The object to use as “this,” or NULL to use the global object as “this.” @param sourceURL 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. @param startingLineNumber 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. @param exception 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 The JSValue that results from evaluating script, or NULL if an exception is thrown.

JSGarbageCollect

@function JSGarbageCollect @abstract Performs a JavaScript garbage collection. @param ctx The execution context to use. @discussion 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.

JSGlobalContextCopyName

@function @abstract Gets a copy of the name of a context. @param ctx The JSGlobalContext whose name you want to get. @result The name for ctx. @discussion A JSGlobalContext’s name is exposed for remote debugging to make it easier to identify the context you would like to attach to.

JSGlobalContextCreate

@function @abstract Creates a global JavaScript execution context. @discussion JSGlobalContextCreate allocates a global object and populates it with all the built-in JavaScript objects, such as Object, Function, String, and Array.

JSGlobalContextCreateInGroup

@function @abstract Creates a global JavaScript execution context in the context group provided. @discussion JSGlobalContextCreateInGroup allocates a global object and populates it with all the built-in JavaScript objects, such as Object, Function, String, and Array. @param globalObjectClass The class to use when creating the global object. Pass NULL to use the default object class. @param group The context group to use. The created global context retains the group. Pass NULL to create a unique group for the context. @result A JSGlobalContext with a global object of class globalObjectClass and a context group equal to group.

JSGlobalContextRelease

@function @abstract Releases a global JavaScript execution context. @param ctx The JSGlobalContext to release.

JSGlobalContextRetain

@function @abstract Retains a global JavaScript execution context. @param ctx The JSGlobalContext to retain. @result A JSGlobalContext that is the same as ctx.

JSGlobalContextSetName

@function @abstract Sets the remote debugging name for a context. @param ctx The JSGlobalContext that you want to name. @param name The remote debugging name to set on ctx.

JSObjectCallAsConstructor

@function @abstract Calls an object as a constructor. @param ctx The execution context to use. @param object The JSObject to call as a constructor. @param argumentCount An integer count of the number of arguments in arguments. @param arguments A JSValue array of arguments to pass to the constructor. Pass NULL if argumentCount is 0. @param exception 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 The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor.

JSObjectCallAsFunction

@function @abstract Calls an object as a function. @param ctx The execution context to use. @param object The JSObject to call as a function. @param thisObject The object to use as “this,” or NULL to use the global object as “this.” @param argumentCount An integer count of the number of arguments in arguments. @param arguments A JSValue array of arguments to pass to the function. Pass NULL if argumentCount is 0. @param exception 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 The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function.

JSObjectCopyPropertyNames

@function @abstract Gets the names of an object’s enumerable properties. @param ctx The execution context to use. @param object The object whose property names you want to get. @result A JSPropertyNameArray containing the names object’s enumerable properties. Ownership follows the Create Rule.

JSObjectDeleteProperty

@function @abstract Deletes a property from an object. @param ctx The execution context to use. @param object The JSObject whose property you want to delete. @param propertyName A JSString containing the property’s name. @param exception 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 true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).

JSObjectDeletePropertyForKey

@function @abstract Deletes a property from an object using a JSValueRef as the property key. @param ctx The execution context to use. @param object The JSObject whose property you want to delete. @param propertyKey A JSValueRef containing the property key to use when looking up the property. @param exception 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 true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set). @discussion This function is the same as performing “delete object[propertyKey]” from JavaScript.

JSObjectGetArrayBufferByteLength

@function @abstract Returns the number of bytes in a JavaScript data object. @param ctx The execution context to use. @param object The JS Arary Buffer object whose length in bytes to return. @param exception 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 The number of bytes stored in the data object.

JSObjectGetArrayBufferBytesPtr

@function @abstract Returns a pointer to the data buffer that serves as the backing store for a JavaScript Typed Array object. @param object The Array Buffer object whose internal backing store pointer to return. @param exception 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 A pointer to the raw data buffer that serves as object’s backing store or NULL if object is not an Array Buffer object. @discussion The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls.

JSObjectGetPrivate

@function @abstract Gets an object’s private data. @param object A JSObject whose private data you want to get. @result A void* that is the object’s private data, if the object has private data, otherwise NULL.

JSObjectGetProperty

@function @abstract Gets a property from an object. @param ctx The execution context to use. @param object The JSObject whose property you want to get. @param propertyName A JSString containing the property’s name. @param exception 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 The property’s value if object has the property, otherwise the undefined value.

JSObjectGetPropertyAtIndex

@function @abstract Gets a property from an object by numeric index. @param ctx The execution context to use. @param object The JSObject whose property you want to get. @param propertyIndex An integer value that is the property’s name. @param exception 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 The property’s value if object has the property, otherwise the undefined value. @discussion Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but JSObjectGetPropertyAtIndex provides optimized access to numeric properties.

JSObjectGetPropertyForKey

@function @abstract Gets a property from an object using a JSValueRef as the property key. @param ctx The execution context to use. @param object The JSObject whose property you want to get. @param propertyKey A JSValueRef containing the property key to use when looking up the property. @param exception 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 The property’s value if object has the property key, otherwise the undefined value. @discussion This function is the same as performing “object[propertyKey]” from JavaScript.

JSObjectGetPrototype

@function @abstract Gets an object’s prototype. @param ctx The execution context to use. @param object A JSObject whose prototype you want to get. @result A JSValue that is the object’s prototype.

JSObjectGetTypedArrayBuffer

@function @abstract Returns the JavaScript Array Buffer object that is used as the backing of a JavaScript Typed Array object. @param ctx The execution context to use. @param object The JSObjectRef whose Typed Array type data pointer to obtain. @param exception 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 A JSObjectRef with a JSTypedArrayType of kJSTypedArrayTypeArrayBuffer or NULL if object is not a Typed Array.

JSObjectGetTypedArrayByteLength

@function @abstract Returns the byte length of a JavaScript Typed Array object. @param ctx The execution context to use. @param object The Typed Array object whose byte length to return. @param exception 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 The byte length of the Typed Array object or 0 if the object is not a Typed Array object.

JSObjectGetTypedArrayByteOffset

@function @abstract Returns the byte offset of a JavaScript Typed Array object. @param ctx The execution context to use. @param object The Typed Array object whose byte offset to return. @param exception 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 The byte offset of the Typed Array object or 0 if the object is not a Typed Array object.

JSObjectGetTypedArrayBytesPtr

@function @abstract Returns a temporary pointer to the backing store of a JavaScript Typed Array object. @param ctx The execution context to use. @param object The Typed Array object whose backing store pointer to return. @param exception 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 A pointer to the raw data buffer that serves as object’s backing store or NULL if object is not a Typed Array object. @discussion The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls.

JSObjectGetTypedArrayLength

@function @abstract Returns the length of a JavaScript Typed Array object. @param ctx The execution context to use. @param object The Typed Array object whose length to return. @param exception 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 The length of the Typed Array object or 0 if the object is not a Typed Array object.

JSObjectHasProperty

@function @abstract Tests whether an object has a given property. @param object The JSObject to test. @param propertyName A JSString containing the property’s name. @result true if the object has a property whose name matches propertyName, otherwise false.

JSObjectHasPropertyForKey

@function @abstract Tests whether an object has a given property using a JSValueRef as the property key. @param object The JSObject to test. @param propertyKey A JSValueRef containing the property key to use when looking up the property. @param exception 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 true if the object has a property whose name matches propertyKey, otherwise false. @discussion This function is the same as performing “propertyKey in object” from JavaScript.

JSObjectIsConstructor

@function @abstract Tests whether an object can be called as a constructor. @param ctx The execution context to use. @param object The JSObject to test. @result true if the object can be called as a constructor, otherwise false.

JSObjectIsFunction

@function @abstract Tests whether an object can be called as a function. @param ctx The execution context to use. @param object The JSObject to test. @result true if the object can be called as a function, otherwise false.

JSObjectMake

@function @abstract Creates a JavaScript object. @param ctx The execution context to use. @param jsClass The JSClass to assign to the object. Pass NULL to use the default object class. @param data A void* to set as the object’s private data. Pass NULL to specify no private data. @result A JSObject with the given class and private data. @discussion 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.

JSObjectMakeArray

@function @abstract Creates a JavaScript Array object. @param ctx The execution context to use. @param argumentCount An integer count of the number of arguments in arguments. @param arguments A JSValue array of data to populate the Array with. Pass NULL if argumentCount is 0. @param exception 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 A JSObject that is an Array. @discussion 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.

JSObjectMakeArrayBufferWithBytesNoCopy

@function @abstract Creates a JavaScript Array Buffer object from an existing pointer. @param ctx The execution context to use. @param bytes A pointer to the byte buffer to be used as the backing store of the Typed Array object. @param byteLength The number of bytes pointed to by the parameter bytes. @param bytesDeallocator The allocator to use to deallocate the external buffer when the Typed Array data object is deallocated. @param deallocatorContext A pointer to pass back to the deallocator. @param exception 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 A JSObjectRef Array Buffer whose backing store is the same as the one pointed to by bytes or NULL if there was an error. @discussion If an exception is thrown during this function the bytesDeallocator will always be called.

JSObjectMakeConstructor

@function @abstract Convenience method for creating a JavaScript constructor. @param ctx The execution context to use. @param jsClass 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. @param callAsConstructor A JSObjectCallAsConstructorCallback to invoke when your constructor is used in a ‘new’ expression. Pass NULL to use the default object constructor. @result A JSObject that is a constructor. The object’s prototype will be the default object prototype. @discussion The default object constructor takes no arguments and constructs an object of class jsClass with no private data. If the constructor is inherited via JS subclassing and the value returned from callAsConstructor was created with jsClass, then the returned object will have it’s prototype overridden to the derived class’s prototype.

JSObjectMakeDate

@function @abstract Creates a JavaScript Date object, as if by invoking the built-in Date constructor. @param ctx The execution context to use. @param argumentCount An integer count of the number of arguments in arguments. @param arguments A JSValue array of arguments to pass to the Date Constructor. Pass NULL if argumentCount is 0. @param exception 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 A JSObject that is a Date.

JSObjectMakeDeferredPromise

@function @abstract Creates a JavaScript promise object by invoking the provided executor. @param ctx The execution context to use. @param resolve 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. @param reject 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. @param exception 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 A JSObject that is a promise or NULL if an exception occurred.

JSObjectMakeError

@function @abstract Creates a JavaScript Error object, as if by invoking the built-in Error constructor. @param ctx The execution context to use. @param argumentCount An integer count of the number of arguments in arguments. @param arguments A JSValue array of arguments to pass to the Error Constructor. Pass NULL if argumentCount is 0. @param exception 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 A JSObject that is an Error.

JSObjectMakeFunction

@function @abstract Creates a function with a given script as its body. @param ctx The execution context to use. @param name A JSString containing the function’s name. This will be used when converting the function to string. Pass NULL to create an anonymous function. @param parameterCount An integer count of the number of parameter names in parameterNames. @param parameterNames A JSString array containing the names of the function’s parameters. Pass NULL if parameterCount is 0. @param body A JSString containing the script to use as the function’s body. @param sourceURL 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. @param startingLineNumber 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. @param exception 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 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. @discussion Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.

JSObjectMakeFunctionWithCallback

@function @abstract Convenience method for creating a JavaScript function with a given callback as its implementation. @param ctx The execution context to use. @param name A JSString containing the function’s name. This will be used when converting the function to string. Pass NULL to create an anonymous function. @param callAsFunction The JSObjectCallAsFunctionCallback to invoke when the function is called. @result A JSObject that is a function. The object’s prototype will be the default function prototype.

JSObjectMakeRegExp

@function @abstract Creates a JavaScript RegExp object, as if by invoking the built-in RegExp constructor. @param ctx The execution context to use. @param argumentCount An integer count of the number of arguments in arguments. @param arguments A JSValue array of arguments to pass to the RegExp Constructor. Pass NULL if argumentCount is 0. @param exception 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 A JSObject that is a RegExp.

JSObjectMakeTypedArray

@function @abstract Creates a JavaScript Typed Array object with the given number of elements. @param ctx The execution context to use. @param arrayType A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned. @param length The number of elements to be in the new Typed Array. @param exception 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 A JSObjectRef that is a Typed Array with all elements set to zero or NULL if there was an error.

JSObjectMakeTypedArrayWithArrayBuffer

@function @abstract Creates a JavaScript Typed Array object from an existing JavaScript Array Buffer object. @param ctx The execution context to use. @param arrayType A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned. @param buffer An Array Buffer object that should be used as the backing store for the created JavaScript Typed Array object. @param exception 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 A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer.

JSObjectMakeTypedArrayWithArrayBufferAndOffset

@function @abstract Creates a JavaScript Typed Array object from an existing JavaScript Array Buffer object with the given offset and length. @param ctx The execution context to use. @param arrayType A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned. @param buffer An Array Buffer object that should be used as the backing store for the created JavaScript Typed Array object. @param byteOffset The byte offset for the created Typed Array. byteOffset should aligned with the element size of arrayType. @param length The number of elements to include in the Typed Array. @param exception 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 A JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer.

JSObjectMakeTypedArrayWithBytesNoCopy

@function @abstract Creates a JavaScript Typed Array object from an existing pointer. @param ctx The execution context to use. @param arrayType A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned. @param bytes A pointer to the byte buffer to be used as the backing store of the Typed Array object. @param byteLength The number of bytes pointed to by the parameter bytes. @param bytesDeallocator The allocator to use to deallocate the external buffer when the JSTypedArrayData object is deallocated. @param deallocatorContext A pointer to pass back to the deallocator. @param exception 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 A JSObjectRef Typed Array whose backing store is the same as the one pointed to by bytes or NULL if there was an error. @discussion If an exception is thrown during this function the bytesDeallocator will always be called.

JSObjectSetPrivate

@function @abstract Sets a pointer to private data on an object. @param object The JSObject whose private data you want to set. @param data A void* to set as the object’s private data. @result true if object can store private data, otherwise false. @discussion The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data.

JSObjectSetProperty

@function @abstract Sets a property on an object. @param ctx The execution context to use. @param object The JSObject whose property you want to set. @param propertyName A JSString containing the property’s name. @param value A JSValueRef to use as the property’s value. @param attributes A logically ORed set of JSPropertyAttributes to give to the property. @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.

JSObjectSetPropertyAtIndex

@function @abstract Sets a property on an object by numeric index. @param ctx The execution context to use. @param object The JSObject whose property you want to set. @param propertyIndex The property’s name as a number. @param value A JSValue to use as the property’s value. @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. @discussion Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but JSObjectSetPropertyAtIndex provides optimized access to numeric properties.

JSObjectSetPropertyForKey

@function @abstract Sets a property on an object using a JSValueRef as the property key. @param ctx The execution context to use. @param object The JSObject whose property you want to set. @param propertyKey A JSValueRef containing the property key to use when looking up the property. @param value A JSValueRef to use as the property’s value. @param attributes A logically ORed set of JSPropertyAttributes to give to the property. @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. @discussion This function is the same as performing “object[propertyKey] = value” from JavaScript.

JSObjectSetPrototype

@function @abstract Sets an object’s prototype. @param ctx The execution context to use. @param object The JSObject whose prototype you want to set. @param value A JSValue to set as the object’s prototype.

JSStringCreateWithCharacters

@function @abstract Creates a JavaScript string from a buffer of Unicode characters. @param chars The buffer of Unicode characters to copy into the new JSString. @param numChars The number of characters to copy from the buffer pointed to by chars. @result A JSString containing chars. Ownership follows the Create Rule.

JSStringCreateWithUTF8CString

@function @abstract Creates a JavaScript string from a null-terminated UTF8 string. @param string The null-terminated UTF8 string to copy into the new JSString. @result A JSString containing string. Ownership follows the Create Rule.

JSStringGetCharactersPtr

@function @abstract Returns a pointer to the Unicode character buffer that serves as the backing store for a JavaScript string. @param string The JSString whose backing store you want to access. @result A pointer to the Unicode character buffer that serves as string’s backing store, which will be deallocated when string is deallocated.

JSStringGetLength

@function @abstract Returns the number of Unicode characters in a JavaScript string. @param string The JSString whose length (in Unicode characters) you want to know. @result The number of Unicode characters stored in string.

JSStringGetMaximumUTF8CStringSize

@function @abstract Returns the maximum number of bytes a JavaScript string will take up if converted into a null-terminated UTF8 string. @param string The JSString whose maximum converted size (in bytes) you want to know. @result 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.

JSStringGetUTF8CString

@function @abstract Converts a JavaScript string into a null-terminated UTF8 string, and copies the result into an external byte buffer. @param string The source JSString. @param buffer 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. @param bufferSize The size of the external buffer in bytes. @result The number of bytes written into buffer (including the null-terminator byte).

JSStringIsEqual

@function @abstract Tests whether two JavaScript strings match. @param a The first JSString to test. @param b The second JSString to test. @result true if the two strings match, otherwise false.

JSStringIsEqualToUTF8CString

@function @abstract Tests whether a JavaScript string matches a null-terminated UTF8 string. @param a The JSString to test. @param b The null-terminated UTF8 string to test. @result true if the two strings match, otherwise false.

JSStringRelease

@function @abstract Releases a JavaScript string. @param string The JSString to release.

JSStringRetain

@function @abstract Retains a JavaScript string. @param string The JSString to retain. @result A JSString that is the same as string.

JSValueCreateJSONString

@function @abstract Creates a JavaScript string containing the JSON serialized representation of a JS value. @param ctx The execution context to use. @param value The value to serialize. @param indent 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. @param exception 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 A JSString with the result of serialization, or NULL if an exception is thrown.

JSValueGetType

@function @abstract Returns a JavaScript value’s type. @param ctx The execution context to use. @param value The JSValue whose type you want to obtain. @result A value of type JSType that identifies value’s type.

JSValueGetTypedArrayType

@function @abstract Returns a JavaScript value’s Typed Array type. @param ctx The execution context to use. @param value The JSValue whose Typed Array type to return. @param exception 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 A value of type JSTypedArrayType that identifies value’s Typed Array type, or kJSTypedArrayTypeNone if the value is not a Typed Array object.

JSValueIsArray

@function @abstract Tests whether a JavaScript value is an array. @param ctx The execution context to use. @param value The JSValue to test. @result true if value is an array, otherwise false.

JSValueIsBoolean

@function @abstract Tests whether a JavaScript value’s type is the boolean type. @param ctx The execution context to use. @param value The JSValue to test. @result true if value’s type is the boolean type, otherwise false.

JSValueIsDate

@function @abstract Tests whether a JavaScript value is a date. @param ctx The execution context to use. @param value The JSValue to test. @result true if value is a date, otherwise false.

JSValueIsEqual

@function @abstract Tests whether two JavaScript values are equal, as compared by the JS == operator. @param ctx The execution context to use. @param a The first value to test. @param b The second value to test. @param exception 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 true if the two values are equal, false if they are not equal or an exception is thrown.

JSValueIsInstanceOfConstructor

@function @abstract Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator. @param ctx The execution context to use. @param value The JSValue to test. @param constructor The constructor to test against. @param exception 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 true if value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false.

JSValueIsNull

@function @abstract Tests whether a JavaScript value’s type is the null type. @param ctx The execution context to use. @param value The JSValue to test. @result true if value’s type is the null type, otherwise false.

JSValueIsNumber

@function @abstract Tests whether a JavaScript value’s type is the number type. @param ctx The execution context to use. @param value The JSValue to test. @result true if value’s type is the number type, otherwise false.

JSValueIsObject

@function @abstract Tests whether a JavaScript value’s type is the object type. @param ctx The execution context to use. @param value The JSValue to test. @result true if value’s type is the object type, otherwise false.

JSValueIsObjectOfClass

@function @abstract Tests whether a JavaScript value is an object with a given class in its class chain. @param ctx The execution context to use. @param value The JSValue to test. @param jsClass The JSClass to test against. @result true if value is an object and has jsClass in its class chain, otherwise false.

JSValueIsStrictEqual

@function @abstract Tests whether two JavaScript values are strict equal, as compared by the JS === operator. @param ctx The execution context to use. @param a The first value to test. @param b The second value to test. @result true if the two values are strict equal, otherwise false.

JSValueIsString

@function @abstract Tests whether a JavaScript value’s type is the string type. @param ctx The execution context to use. @param value The JSValue to test. @result true if value’s type is the string type, otherwise false.

JSValueIsSymbol

@function @abstract Tests whether a JavaScript value’s type is the symbol type. @param ctx The execution context to use. @param value The JSValue to test. @result true if value’s type is the symbol type, otherwise false.

JSValueIsUndefined

@function @abstract Tests whether a JavaScript value’s type is the undefined type. @param ctx The execution context to use. @param value The JSValue to test. @result true if value’s type is the undefined type, otherwise false.

JSValueMakeBoolean

@function @abstract Creates a JavaScript value of the boolean type. @param ctx The execution context to use. @param boolean The bool to assign to the newly created JSValue. @result A JSValue of the boolean type, representing the value of boolean.

JSValueMakeFromJSONString

@function @abstract Creates a JavaScript value from a JSON formatted string. @param ctx The execution context to use. @param string The JSString containing the JSON string to be parsed. @result A JSValue containing the parsed value, or NULL if the input is invalid.

JSValueMakeNull

@function @abstract Creates a JavaScript value of the null type. @param ctx The execution context to use. @result The unique null value.

JSValueMakeNumber

@function @abstract Creates a JavaScript value of the number type. @param ctx The execution context to use. @param number The double to assign to the newly created JSValue. @result A JSValue of the number type, representing the value of number.

JSValueMakeString

@function @abstract Creates a JavaScript value of the string type. @param ctx The execution context to use. @param string The JSString to assign to the newly created JSValue. The newly created JSValue retains string, and releases it upon garbage collection. @result A JSValue of the string type, representing the value of string.

JSValueMakeSymbol

@function @abstract Creates a JavaScript value of the symbol type. @param ctx The execution context to use. @param description A description of the newly created symbol value. @result A unique JSValue of the symbol type, whose description matches the one provided.

JSValueMakeUndefined

@function @abstract Creates a JavaScript value of the undefined type. @param ctx The execution context to use. @result The unique undefined value.

JSValueProtect

@function @abstract Protects a JavaScript value from garbage collection. @param ctx The execution context to use. @param value The JSValue to protect. @discussion 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.

JSValueToBoolean

@function @abstract Converts a JavaScript value to boolean and returns the resulting boolean. @param ctx The execution context to use. @param value The JSValue to convert. @result The boolean result of conversion.

JSValueToNumber

@function @abstract Converts a JavaScript value to number and returns the resulting number. @param ctx The execution context to use. @param value The JSValue to convert. @param exception 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 The numeric result of conversion, or NaN if an exception is thrown.

JSValueToObject

@function @abstract Converts a JavaScript value to object and returns the resulting object. @param ctx The execution context to use. @param value The JSValue to convert. @param exception 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 The JSObject result of conversion, or NULL if an exception is thrown.

JSValueToStringCopy

@function @abstract Converts a JavaScript value to string and copies the result into a JavaScript string. @param ctx The execution context to use. @param value The JSValue to convert. @param exception 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 A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule.

JSValueUnprotect

@function @abstract Unprotects a JavaScript value from garbage collection. @param ctx The execution context to use. @param value The JSValue to unprotect. @discussion A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection.

Type Definitions

JSChar

@typedef JSChar @abstract A UTF-16 code unit. One, or a sequence of two, can encode any Unicode character. As with all scalar types, endianness depends on the underlying architecture.

JSClassAttributes

@typedef JSClassAttributes @abstract A set of JSClassAttributes. Combine multiple attributes by logically ORing them together.

JSClassRef

@typedef JSClassRef A JavaScript class. Used with JSObjectMake to construct objects with custom behavior.

JSContextGroupRef

@typedef JSContextGroupRef A group that associates JavaScript contexts with one another. Contexts in the same group may share and exchange JavaScript objects.

JSContextRef

@typedef JSContextRef A JavaScript execution context. Holds the global object and other execution state.

JSGlobalContextRef

@typedef JSGlobalContextRef A global JavaScript execution context. A JSGlobalContext is a JSContext.

JSObjectCallAsConstructorCallback

@typedef JSObjectCallAsConstructorCallback @abstract The callback invoked when an object is used as a constructor in a ‘new’ expression. @param ctx The execution context to use. @param constructor A JSObject that is the constructor being called. @param argumentCount An integer count of the number of arguments in arguments. @param arguments A JSValue array of the arguments passed to the function. @param exception A pointer to a JSValueRef in which to return an exception, if any. @result A JSObject that is the constructor’s return value. @discussion If you named your function CallAsConstructor, you would declare it like this:

JSObjectCallAsFunctionCallback

@typedef JSObjectCallAsFunctionCallback @abstract The callback invoked when an object is called as a function. @param ctx The execution context to use. @param function A JSObject that is the function being called. @param thisObject A JSObject that is the ‘this’ variable in the function’s scope. @param argumentCount An integer count of the number of arguments in arguments. @param arguments A JSValue array of the arguments passed to the function. @param exception A pointer to a JSValueRef in which to return an exception, if any. @result A JSValue that is the function’s return value. @discussion If you named your function CallAsFunction, you would declare it like this:

JSObjectConvertToTypeCallback

@typedef JSObjectConvertToTypeCallback @abstract The callback invoked when converting an object to a particular JavaScript type. @param ctx The execution context to use. @param object The JSObject to convert. @param type A JSType specifying the JavaScript type to convert to. @param 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. @discussion If you named your function ConvertToType, you would declare it like this:

JSObjectDeletePropertyCallback

@typedef JSObjectDeletePropertyCallback @abstract The callback invoked when deleting a property. @param ctx The execution context to use. @param object The JSObject in which to delete the property. @param propertyName A JSString containing the name of the property to delete. @param exception A pointer to a JSValueRef in which to return an exception, if any. @result true if propertyName was successfully deleted, otherwise false. @discussion If you named your function DeleteProperty, you would declare it like this:

JSObjectFinalizeCallback

@typedef JSObjectFinalizeCallback @abstract The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread. @param object The JSObject being finalized. @discussion If you named your function Finalize, you would declare it like this:

JSObjectGetPropertyCallback

@typedef JSObjectGetPropertyCallback @abstract The callback invoked when getting a property’s value. @param ctx The execution context to use. @param object The JSObject to search for the property. @param propertyName A JSString containing the name of the property to get. @param 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. @discussion If you named your function GetProperty, you would declare it like this:

JSObjectGetPropertyNamesCallback

@typedef JSObjectGetPropertyNamesCallback @abstract The callback invoked when collecting the names of an object’s properties. @param ctx The execution context to use. @param object The JSObject whose property names are being collected. @param propertyNames A JavaScript property name accumulator in which to accumulate the names of object’s properties. @discussion If you named your function GetPropertyNames, you would declare it like this:

JSObjectHasInstanceCallback

@typedef JSObjectHasInstanceCallback @abstract hasInstance The callback invoked when an object is used as the target of an ‘instanceof’ expression. @param ctx The execution context to use. @param constructor The JSObject that is the target of the ‘instanceof’ expression. @param possibleInstance The JSValue being tested to determine if it is an instance of constructor. @param 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. @discussion If you named your function HasInstance, you would declare it like this:

JSObjectHasPropertyCallback

@typedef JSObjectHasPropertyCallback @abstract The callback invoked when determining whether an object has a property. @param ctx The execution context to use. @param object The JSObject to search for the property. @param propertyName A JSString containing the name of the property look up. @result true if object has the property, otherwise false. @discussion If you named your function HasProperty, you would declare it like this:

JSObjectInitializeCallback

@typedef JSObjectInitializeCallback @abstract The callback invoked when an object is first created. @param ctx The execution context to use. @param object The JSObject being created. @discussion If you named your function Initialize, you would declare it like this:

JSObjectRef

@typedef JSObjectRef A JavaScript object. A JSObject is a JSValue.

JSObjectSetPropertyCallback

@typedef JSObjectSetPropertyCallback @abstract The callback invoked when setting a property’s value. @param ctx The execution context to use. @param object The JSObject on which to set the property’s value. @param propertyName A JSString containing the name of the property to set. @param value A JSValue to use as the property’s value. @param exception A pointer to a JSValueRef in which to return an exception, if any. @result true if the property was set, otherwise false. @discussion If you named your function SetProperty, you would declare it like this:

JSPropertyAttributes

@typedef JSPropertyAttributes @abstract A set of JSPropertyAttributes. Combine multiple attributes by logically ORing them together.

JSPropertyNameAccumulatorRef

@typedef JSPropertyNameAccumulatorRef An ordered set used to collect the names of a JavaScript object’s properties.

JSPropertyNameArrayRef

@typedef JSPropertyNameArrayRef An array of JavaScript property names.

JSStringRef

@typedef JSStringRef A UTF16 character buffer. The fundamental string representation in JavaScript.

JSTypedArrayBytesDeallocator

@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.

JSValueRef

@typedef JSValueRef A JavaScript value. The base type for all JavaScript values, and polymorphic functions on them.