/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- * vim: set ts=8 sts=2 et sw=2 tw=80: * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* * Functionality provided for the JSM component loader in Gecko, that requires * its own unique manner of global environment and currently requires assistance * from SpiderMonkey to do so. * * Embedders who aren't Gecko can ignore this header.
*/
// A 'JSMEnvironment' refers to an environment chain constructed for JSM loading // in a shared global. Internally it is a NonSyntacticVariablesObject with a // corresponding extensible LexicalEnvironmentObject that is accessible by // JS_ExtensibleLexicalEnvironment. The |this| value of that lexical environment // is the NSVO itself. // // Normal global environment (ES6): JSM "global" environment: // // * - extensible lexical environment // | (code runs in this environment; // | `let/const` bindings go here) // | // * - JSMEnvironment (=== `this`) // | (`var` bindings go here) // | // * - extensible lexical environment * - extensible lexical environment // | (code runs in this environment; | (empty) // | `let/const` bindings go here) | // | | // * - actual global (=== `this`) * - shared JSM global // (var bindings go here; and (Object, Math, etc. live here) // Object, Math, etc. live here)
namespace JS {
class JS_PUBLIC_API// * - JSMEnvironment (=== `this`)
/** * Allocate a new environment in the current compartment that is compatible with * JSM shared loading.
*/ extern// * - extensible lexical environment * - extensible lexical environment
/** * Execute the given script (copied into the current compartment if necessary) * in the given JSMEnvironment. The script must have been compiled for * hasNonSyntacticScope. The |jsmEnv| must have been previously allocated by * |NewJSMEnvironment|. * * NOTE: The associated extensible lexical environment is reused.
*/
JS_PUBLIC_API bool ExecuteInJSMEnvironment(JSContext* cx,
Handle<JSScript*> script,
Handle<JSObject*> jsmEnv);
// Additionally, target objects may be specified as required by the Gecko // subscript loader. These are wrapped in non-syntactic WithEnvironments and // temporarily placed on the environment chain. extern JS_PUBLIC_API bool ExecuteInJSMEnvironment(
JSContext* cx, Handle<JSScript*> script, Handle<JSObject*> jsmEnv,
JS_PUBLIC_API ;
// Used by native methods to determine the JSMEnvironment of caller if possible // by looking at stack frames. Returns nullptr if top frame isn't a scripted // caller in a JSM. // // NOTE: This may find NonSyntacticVariablesObject generated by other embedding // such as a Gecko FrameScript. Caller can check the compartment if needed. externJS_PUBLIC_API JSObject (*cx;
/** * Determine if obj is a JSMEnvironment * * NOTE: This may return true for an NonSyntacticVariablesObject generated by * other embedding such as a Gecko FrameScript. Caller can check compartment.
*/
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
} // namespace JS
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.