예제 #1
0
// static
XPCWrappedNativeScope*
XPCWrappedNativeScope::GetNewOrUsed(XPCCallContext& ccx, JSObject* aGlobal)
{

    XPCWrappedNativeScope* scope = FindInJSObjectScope(ccx, aGlobal, JS_TRUE);
    if(!scope)
        scope = new XPCWrappedNativeScope(ccx, aGlobal);
    else
    {
        // We need to call SetGlobal in order to refresh our cached
        // mPrototypeJSObject and mPrototypeJSFunction and to clear
        // mPrototypeNoHelper (so we get a new one if requested in the
        // new scope) in the case where the global object is being
        // reused (JS_ClearScope has been called).  NOTE: We are only
        // called by nsXPConnect::InitClasses.
        scope->SetGlobal(ccx, aGlobal);
    }
    return scope;
}
예제 #2
0
// static
XPCWrappedNativeScope*
XPCWrappedNativeScope::GetNewOrUsed(XPCCallContext& ccx, JSObject* aGlobal)
{

    XPCWrappedNativeScope* scope = FindInJSObjectScope(ccx, aGlobal, true);
    if (!scope)
        scope = new XPCWrappedNativeScope(ccx, aGlobal);
    else {
        // We need to call SetGlobal in order to refresh our cached
        // mPrototypeJSObject and to clear mPrototypeNoHelper (so we get a new
        // new one if requested in the new scope) in the case where the global
        // object is being reused (JS_ClearScope has been called).  NOTE: We are
        // only called by nsXPConnect::InitClasses.
        scope->SetGlobal(ccx, aGlobal);
    }
    if (js::GetObjectClass(aGlobal)->flags & JSCLASS_XPCONNECT_GLOBAL)
        JS_SetReservedSlot(aGlobal,
                           JSCLASS_GLOBAL_SLOT_COUNT,
                           PRIVATE_TO_JSVAL(scope));
    return scope;
}