if (XPCNativeWrapper::IsNativeWrapperClass(clazz)) { XPCWrappedNative* native = XPCNativeWrapper::GetWrappedNative(cx, obj); if (native) { return native->GetScope(); }   }
GetScopeOfObject(JSContext* cx, JSObject* obj){    nsISupports* supports;    JSClass* clazz = JS_GET_CLASS(cx, obj);    if(!clazz ||       !(clazz->flags & JSCLASS_HAS_PRIVATE) ||       !(clazz->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS) ||       !(supports = (nsISupports*) JS_GetPrivate(cx, obj)))        return nsnull;    nsCOMPtr<nsIXPConnectWrappedNative> iface = do_QueryInterface(supports);    if(iface)    {        // We can fairly safely assume that this is really one of our        // nsXPConnectWrappedNative objects. No other component in our        // universe should be creating objects that implement the        // nsIXPConnectWrappedNative interface!        return ((XPCWrappedNative*)supports)->GetScope();    }    return nsnull;}