JS_GetCompartmentPrivate

This article covers features introduced in SpiderMonkey 1.8.5

Please provide a description for this function.

Syntax

void
JS_SetCompartmentPrivate(JSCompartment *compartment, void *data);

void *
JS_GetCompartmentPrivate(JSCompartment *compartment);
Name Type Description
compartment JSCompartment * Any compartment
data void * (in JS_SetCompartmentPrivate) Pointer to application-defined data to be associated with the compartment.

Description

Each JSCompartment has a field of type void * which the application may use for any purpose. It is especially useful for storing data needed by callbacks. JS_GetCompartmentPrivate gets this field and JS_SetCompartmentPrivate sets it. The field is initially NULL.

Memory management for this private data is the application's responsibility. The JavaScript engine itself never uses it.

See Also