Ultralight C++ API 1.3.0
Loading...
Searching...
No Matches
JSContextRef.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef JSContextRef_h
27#define JSContextRef_h
28
32
33#ifndef __cplusplus
34#include <stdbool.h>
35#endif
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/*!
42@function
43@abstract Creates a JavaScript context group.
44@discussion A JSContextGroup associates JavaScript contexts with one another.
45 Contexts in the same group may share and exchange JavaScript objects. Sharing and/or exchanging
46 JavaScript objects between contexts in different groups will produce undefined behavior.
47 When objects from the same context group are used in multiple threads, explicit
48 synchronization is required.
49
50 A JSContextGroup may need to run deferred tasks on a run loop, such as garbage collection
51 or resolving WebAssembly compilations. By default, calling JSContextGroupCreate will use
52 the run loop of the thread it was called on. Currently, there is no API to change a
53 JSContextGroup's run loop once it has been created.
54@result The created JSContextGroup.
55*/
57
58/*!
59@function
60@abstract Retains a JavaScript context group.
61@param group The JSContextGroup to retain.
62@result A JSContextGroup that is the same as group.
63*/
65
66/*!
67@function
68@abstract Releases a JavaScript context group.
69@param group The JSContextGroup to release.
70*/
72
73/*!
74@function
75@abstract Creates a global JavaScript execution context.
76@discussion JSGlobalContextCreate allocates a global object and populates it with all the
77 built-in JavaScript objects, such as Object, Function, String, and Array.
78
79 In WebKit version 4.0 and later, the context is created in a unique context group.
80 Therefore, scripts may execute in it concurrently with scripts executing in other contexts.
81 However, you may not use values created in the context in other contexts.
82@param globalObjectClass The class to use when creating the global object. Pass
83 NULL to use the default object class.
84@result A JSGlobalContext with a global object of class globalObjectClass.
85*/
87
88/*!
89@function
90@abstract Creates a global JavaScript execution context in the context group provided.
91@discussion JSGlobalContextCreateInGroup allocates a global object and populates it with
92 all the built-in JavaScript objects, such as Object, Function, String, and Array.
93@param globalObjectClass The class to use when creating the global object. Pass
94 NULL to use the default object class.
95@param group The context group to use. The created global context retains the group.
96 Pass NULL to create a unique group for the context.
97@result A JSGlobalContext with a global object of class globalObjectClass and a context
98 group equal to group.
99*/
101
102/*!
103@function
104@abstract Retains a global JavaScript execution context.
105@param ctx The JSGlobalContext to retain.
106@result A JSGlobalContext that is the same as ctx.
107*/
109
110/*!
111@function
112@abstract Releases a global JavaScript execution context.
113@param ctx The JSGlobalContext to release.
114*/
116
117/*!
118@function
119@abstract Gets the global object of a JavaScript execution context.
120@param ctx The JSContext whose global object you want to get.
121@result ctx's global object.
122*/
124
125/*!
126@function
127@abstract Gets the context group to which a JavaScript execution context belongs.
128@param ctx The JSContext whose group you want to get.
129@result ctx's group.
130*/
132
133/*!
134@function
135@abstract Gets the global context of a JavaScript execution context.
136@param ctx The JSContext whose global context you want to get.
137@result ctx's global context.
138*/
140
141/*!
142@function
143@abstract Gets a copy of the name of a context.
144@param ctx The JSGlobalContext whose name you want to get.
145@result The name for ctx.
146@discussion A JSGlobalContext's name is exposed for remote debugging to make it
147easier to identify the context you would like to attach to.
148*/
150
151/*!
152@function
153@abstract Sets the remote debugging name for a context.
154@param ctx The JSGlobalContext that you want to name.
155@param name The remote debugging name to set on ctx.
156*/
158
159#ifdef __cplusplus
160}
161#endif
162
163#endif /* JSContextRef_h */
struct OpaqueJSClass * JSClassRef
Definition JSBase.h:52
struct OpaqueJSString * JSStringRef
Definition JSBase.h:49
struct OpaqueJSContext * JSGlobalContextRef
Definition JSBase.h:46
const struct OpaqueJSContextGroup * JSContextGroupRef
Definition JSBase.h:40
struct OpaqueJSValue * JSObjectRef
Definition JSBase.h:69
#define JS_EXPORT
Definition JSBase.h:93
const struct OpaqueJSContext * JSContextRef
Definition JSBase.h:43
void JSGlobalContextRelease(JSGlobalContextRef ctx)
Releases a global JavaScript execution context.
JSContextGroupRef JSContextGetGroup(JSContextRef ctx) JSC_API_AVAILABLE(macos(10.6)
Gets the context group to which a JavaScript execution context belongs.
JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) JSC_API_AVAILABLE(macos(10.7)
Gets the global context of a JavaScript execution context.
JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) JSC_API_AVAILABLE(macos(10.5)
Creates a global JavaScript execution context.
JSObjectRef JSContextGetGlobalObject(JSContextRef ctx)
Gets the global object of a JavaScript execution context.
JSContextGroupRef JSContextGroupCreate(void) JSC_API_AVAILABLE(macos(10.6)
Creates a JavaScript context group.
JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) JSC_API_AVAILABLE(macos(10.6)
Creates a global JavaScript execution context in the context group provided.
JSContextGroupRef ios(7.0))
JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) JSC_API_AVAILABLE(macos(10.6)
Retains a JavaScript context group.
JSStringRef JSGlobalContextCopyName(JSGlobalContextRef ctx) JSC_API_AVAILABLE(macos(10.10)
Gets a copy of the name of a context.
void JSGlobalContextSetName(JSGlobalContextRef ctx, JSStringRef name) JSC_API_AVAILABLE(macos(10.10)
Sets the remote debugging name for a context.
void JSContextGroupRelease(JSContextGroupRef group) JSC_API_AVAILABLE(macos(10.6)
Releases a JavaScript context group.
JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
Retains a global JavaScript execution context.
#define JSC_API_AVAILABLE(...)
Definition WebKitAvailability.h:77