JS_GetGlobalForCompartmentOrNull

This article covers features introduced in SpiderMonkey 17

Return the global object for the specified compartment.

Syntax

JSObject *
JS_GetGlobalForCompartmentOrNull(JSContext *cx, JSCompartment *c);
Name Type Description
cx JSContext * The context for which to return the global object. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
c JSCompartment * The compartment for which to return the global object.

Description

JS_GetGlobalForCompartmentOrNull() returns the global object for the context and the compartment. This may return NULL if c never had a global (e.g., the atoms compartment), or if c's global has been collected.

See also