本文整理汇总了C++中JSCompartment::zone方法的典型用法代码示例。如果您正苦于以下问题:C++ JSCompartment::zone方法的具体用法?C++ JSCompartment::zone怎么用?C++ JSCompartment::zone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSCompartment
的用法示例。
在下文中一共展示了JSCompartment::zone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
GlobalObject*
GlobalObject::new_(JSContext* cx, const Class* clasp, JSPrincipals* principals,
JS::OnNewGlobalHookOption hookOption,
const JS::CompartmentOptions& options)
{
MOZ_ASSERT(!cx->isExceptionPending());
MOZ_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
JSRuntime* rt = cx->runtime();
auto zoneSpecifier = options.creationOptions().zoneSpecifier();
Zone* zone;
if (zoneSpecifier == JS::SystemZone)
zone = rt->gc.systemZone;
else if (zoneSpecifier == JS::FreshZone)
zone = nullptr;
else
zone = static_cast<Zone*>(options.creationOptions().zonePointer());
JSCompartment* compartment = NewCompartment(cx, zone, principals, options);
if (!compartment)
return nullptr;
// Lazily create the system zone.
if (!rt->gc.systemZone && zoneSpecifier == JS::SystemZone) {
rt->gc.systemZone = compartment->zone();
rt->gc.systemZone->isSystem = true;
}
Rooted<GlobalObject*> global(cx);
{
AutoCompartment ac(cx, compartment);
global = GlobalObject::createInternal(cx, clasp);
if (!global)
return nullptr;
}
if (hookOption == JS::FireOnNewGlobalHook)
JS_FireOnNewGlobalObject(cx, global);
return global;
}