JSContextRef.h

Includes:
<JavaScriptCore/JSObjectRef.h>
<JavaScriptCore/JSValueRef.h>
<JavaScriptCore/WebKitAvailability.h>
<stdbool.h>

Overview

Use the links in the table of contents to the left to access the documentation.



Functions

JSContextGetGlobalObject

Gets the global object of a JavaScript execution context.

JSContextGetGroup

Gets the context group to which a JavaScript execution context belongs.

JSContextGroupCreate

Creates a JavaScript context group.

JSContextGroupRelease

Releases a JavaScript context group.

JSContextGroupRetain

Retains a JavaScript context group.

JSGlobalContextCreate

Creates a global JavaScript execution context.

JSGlobalContextCreateInGroup

Creates a global JavaScript execution context in the context group provided.

JSGlobalContextRelease

Releases a global JavaScript execution context.

JSGlobalContextRetain

Retains a global JavaScript execution context.


JSContextGetGlobalObject


Gets the global object of a JavaScript execution context.

JS_EXPORT JSObjectRef JSContextGetGlobalObject(
    JSContextRef ctx);  
Parameters
ctx

The JSContext whose global object you want to get.

Return Value

ctx's global object.


JSContextGetGroup


Gets the context group to which a JavaScript execution context belongs.

JS_EXPORT JSContextGroupRef JSContextGetGroup(
    JSContextRef ctx) AVAILABLE_IN_WEBKIT_VERSION_4_0;  
Parameters
ctx

The JSContext whose group you want to get.

Return Value

ctx's group.


JSContextGroupCreate


Creates a JavaScript context group.

JS_EXPORT JSContextGroupRef JSContextGroupCreate() AVAILABLE_IN_WEBKIT_VERSION_4_0;  
Return Value

The created JSContextGroup.

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


Releases a JavaScript context group.

JS_EXPORT void JSContextGroupRelease(
    JSContextGroupRef group) AVAILABLE_IN_WEBKIT_VERSION_4_0;  
Parameters
group

The JSContextGroup to release.


JSContextGroupRetain


Retains a JavaScript context group.

JS_EXPORT JSContextGroupRef JSContextGroupRetain(
    JSContextGroupRef group) AVAILABLE_IN_WEBKIT_VERSION_4_0;  
Parameters
group

The JSContextGroup to retain.

Return Value

A JSContextGroup that is the same as group.


JSGlobalContextCreate


Creates a global JavaScript execution context.

JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(
    JSClassRef globalObjectClass) AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER;  
Parameters
globalObjectClass

The class to use when creating the global object. Pass NULL to use the default object class.

Return Value

A JSGlobalContext with a global object of class globalObjectClass.

Discussion

JSGlobalContextCreate allocates a global object and populates it with all the built-in JavaScript objects, such as Object, Function, String, and Array.

In WebKit version 4.0 and later, the context is created in a unique context group. Therefore, scripts may execute in it concurrently with scripts executing in other contexts. However, you may not use values created in the context in other contexts.


JSGlobalContextCreateInGroup


Creates a global JavaScript execution context in the context group provided.

JS_EXPORT JSGlobalContextRef JSGlobalContextCreateInGroup(
    JSContextGroupRef group,
    JSClassRef globalObjectClass) AVAILABLE_IN_WEBKIT_VERSION_4_0;  
Parameters
globalObjectClass

The class to use when creating the global object. Pass NULL to use the default object class.

group

The context group to use. The created global context retains the group. Pass NULL to create a unique group for the context.

Return Value

A JSGlobalContext with a global object of class globalObjectClass and a context group equal to group.

Discussion

JSGlobalContextCreateInGroup allocates a global object and populates it with all the built-in JavaScript objects, such as Object, Function, String, and Array.


JSGlobalContextRelease


Releases a global JavaScript execution context.

JS_EXPORT void JSGlobalContextRelease(
    JSGlobalContextRef ctx);  
Parameters
ctx

The JSGlobalContext to release.


JSGlobalContextRetain


Retains a global JavaScript execution context.

JS_EXPORT JSGlobalContextRef JSGlobalContextRetain(
    JSGlobalContextRef ctx);  
Parameters
ctx

The JSGlobalContext to retain.

Return Value

A JSGlobalContext that is the same as ctx.

Did this document help you? Yes It's good, but... Not helpful...

 

Last Updated: 2009-08-12