Search completed in 0.82 seconds.
JS_NewGlobalObject
syntax jsobject * js_newglobalobject(jscontext *cx, const jsclass *clasp, jsprincipals *principals, js::onnewglobalhookoption hookoption, const
js::compartmentoptions &options =
js::compartmentoptions()); name type description cx jscontext * the context in which to create the new global object.
... hookoption js::onnewglobalhookoption see debugger api hook added in spidermonkey 31 options const
js::compartmentoptions & the option for new compartment (passed to jscompartment constructor).
How to embed the JavaScript engine
jsautorequest ar(cx); // in practice, you would want to exit this any // time you're spinning the event loop
js::compartmentoptions options; js::rootedobject global(cx, js_newglobalobject(cx, &global_class, nullptr, js::fireonnewglobalhook, options)); if (!global) return 1; js::rootedvalue rval(cx); { // scope for jsautocompartment jsautocompartment ac(cx, global); js_initstandardclasses(cx, global); const char *script = "'hello'+'world, it is '+new date()"; ...