зеркало из https://github.com/mozilla/pjs.git
Bug 763856 - Introduce JSAutoEnterCompartment::leave(). r=luke
This commit is contained in:
Родитель
bdb5696e93
Коммит
ac0847a571
|
@ -1444,13 +1444,22 @@ JSAutoEnterCompartment::enterAndIgnoreErrors(JSContext *cx, JSObject *target)
|
|||
(void) enter(cx, target);
|
||||
}
|
||||
|
||||
JSAutoEnterCompartment::~JSAutoEnterCompartment()
|
||||
void
|
||||
JSAutoEnterCompartment::leave()
|
||||
{
|
||||
JS_ASSERT(entered());
|
||||
if (state == STATE_OTHER_COMPARTMENT) {
|
||||
AutoCompartment* ac = getAutoCompartment();
|
||||
CHECK_REQUEST(ac->context);
|
||||
ac->~AutoCompartment();
|
||||
}
|
||||
state = STATE_UNENTERED;
|
||||
}
|
||||
|
||||
JSAutoEnterCompartment::~JSAutoEnterCompartment()
|
||||
{
|
||||
if (entered())
|
||||
leave();
|
||||
}
|
||||
|
||||
namespace JS {
|
||||
|
|
|
@ -2892,6 +2892,13 @@ class JS_PUBLIC_API(JSAutoEnterCompartment)
|
|||
|
||||
bool entered() const { return state != STATE_UNENTERED; }
|
||||
|
||||
/*
|
||||
* In general, consumers should try to avoid calling leave() explicitly,
|
||||
* and defer to the destructor by scoping the JSAutoEnterCompartment
|
||||
* appropriately. Sometimes, though, it's unavoidable.
|
||||
*/
|
||||
void leave();
|
||||
|
||||
~JSAutoEnterCompartment();
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче