GlobalObject * GlobalObject::create(JSContext *cx, Class *clasp) { JS_ASSERT(clasp->flags & JSCLASS_IS_GLOBAL); JSObject *obj = NewObjectWithGivenProto(cx, clasp, NULL, NULL, SingletonObject); if (!obj) return NULL; Rooted<GlobalObject *> global(cx, &obj->asGlobal()); cx->compartment->initGlobal(*global); if (!global->setVarObj(cx)) return NULL; if (!global->setDelegate(cx)) return NULL; /* Construct a regexp statics object for this global object. */ JSObject *res = RegExpStatics::create(cx, global); if (!res) return NULL; global->initSlot(REGEXP_STATICS, ObjectValue(*res)); return global; }
GlobalObject * GlobalObject::create(JSContext *cx, Class *clasp) { JS_ASSERT(clasp->flags & JSCLASS_IS_GLOBAL); JSObject *obj = NewNonFunction<WithProto::Given>(cx, clasp, NULL, NULL); if (!obj) return NULL; GlobalObject *globalObj = obj->asGlobal(); globalObj->syncSpecialEquality(); /* Construct a regexp statics object for this global object. */ JSObject *res = regexp_statics_construct(cx, globalObj); if (!res) return NULL; globalObj->setSlot(REGEXP_STATICS, ObjectValue(*res)); globalObj->setFlags(0); return globalObj; }
GlobalObject * GlobalObject::create(JSContext *cx, Class *clasp) { JS_ASSERT(clasp->flags & JSCLASS_IS_GLOBAL); JSObject *obj = NewObjectWithGivenProto(cx, clasp, NULL, NULL); if (!obj || !obj->setSingletonType(cx)) return NULL; GlobalObject *globalObj = obj->asGlobal(); if (!globalObj->setVarObj(cx)) return NULL; /* Construct a regexp statics object for this global object. */ JSObject *res = RegExpStatics::create(cx, globalObj); if (!res) return NULL; globalObj->initSlot(REGEXP_STATICS, ObjectValue(*res)); globalObj->initFlags(0); return globalObj; }