JSContext class
A JavaScript execution context. Holds the global object and other execution state.
Constructors
-
JSContext(Pointer<
NativeType> _pointer) - JSContext.create({JSClass? globalObjectClass})
- 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.
- JSContext.createInGroup({JSContextGroup? group, JSClass? globalObjectClass})
-
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
(JSContextGroup) The context group to use. The created global context retains the group. Pass NULL to create a unique group for the context.globalObjectClass
(JSClass) The class to use when creating the global object. Pass NULL to use the default object class.@result
(JSGlobalContext) A JSGlobalContext with a global object of class globalObjectClass and a context group equal to group.
Properties
- exception ↔ JSValuePointer
-
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.
getter/setter pair
- globalObject → JSObject
-
Gets the global object of a JavaScript execution context.
@result
(JSObject) ctx's global object.no setter - group → JSContextGroup
-
Gets the context group to which a JavaScript execution context belongs.
@result
(JSContextGroup) ctx's group.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
-
pointer
→ Pointer<
NativeType> -
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
copyName(
) → JSString -
Gets the global context of a JavaScript execution context.
@result
(JSGlobalContext) ctx's global context. 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.@result
(JSString) The name for ctx. -
evaluate(
String script, {JSObject? thisObject, String? sourceURL, int startingLineNumber = 1}) → JSValue -
Evaluates a string of JavaScript.
script
(String) A JSString containing the script to evaluate.thisObject
(JSObject) The object to use as "this," or NULL to use the global object as "this."sourceURL
(String) 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.@result
(JSValueRef) The JSValue that results from evaluating script, or NULL if an exception is thrown. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
release(
) → void -
Releases a global JavaScript execution context.
ctx
(JSGlobalContext) The JSGlobalContext to release. -
retain(
) → void -
Retains a global JavaScript execution context.
@result
(JSGlobalContext) A JSGlobalContext that is the same as ctx. -
setInspectable(
bool inspectable) → void -
setName(
JSString name) → void -
Sets the remote debugging name for a context.
name
(JSString) The remote debugging name to set on ctx. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited