Bug 873735 part 2. Change nsIXPConnectJSObjectHolder::GetJSObject to return a JSObject*. r=bholley

This commit is contained in:
Boris Zbarsky 2013-05-20 08:44:18 -04:00
parent e46734cb01
commit dbe1f3da32
32 changed files with 128 additions and 166 deletions

View File

@ -2294,8 +2294,8 @@ nsScriptSecurityManager::CheckXPCPermissions(JSContext* cx,
do_QueryInterface(aObj);
if (xpcwrappedjs)
{
rv = xpcwrappedjs->GetJSObject(jsObject.address());
NS_ENSURE_SUCCESS(rv, rv);
jsObject = xpcwrappedjs->GetJSObject();
NS_ENSURE_STATE(jsObject);
}
}

View File

@ -646,8 +646,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
if (!wrappedJS) {
continue;
}
JS::Rooted<JSObject*> object(ctx);
wrappedJS->GetJSObject(object.address());
JS::Rooted<JSObject*> object(ctx, wrappedJS->GetJSObject());
if (!object) {
continue;
}
@ -1009,8 +1008,7 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
// Need to scope JSAutoRequest to happen after Push but before Pop,
// at least for now. See bug 584673.
JSAutoRequest ar(mCx);
JS::Rooted<JSObject*> global(mCx);
mGlobal->GetJSObject(global.address());
JS::Rooted<JSObject*> global(mCx, mGlobal->GetJSObject());
if (global) {
(void) JS_ExecuteScript(mCx, global, holder->mScript, nullptr);
}
@ -1068,8 +1066,7 @@ nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
// Need to scope JSAutoRequest to happen after Push but before Pop,
// at least for now. See bug 584673.
JSAutoRequest ar(mCx);
JS::Rooted<JSObject*> global(mCx);
mGlobal->GetJSObject(global.address());
JS::Rooted<JSObject*> global(mCx, mGlobal->GetJSObject());
if (global) {
JSAutoCompartment ac(mCx, global);
JS::CompileOptions options(mCx);
@ -1138,9 +1135,8 @@ nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope,
NS_ENSURE_SUCCESS(rv, false);
JS::Rooted<JSObject*> global(cx);
rv = mGlobal->GetJSObject(global.address());
NS_ENSURE_SUCCESS(rv, false);
JS::Rooted<JSObject*> global(cx, mGlobal->GetJSObject());
NS_ENSURE_TRUE(global, false);
JS_SetGlobalObject(cx, global);

View File

@ -121,10 +121,7 @@ public:
return nullptr;
}
JSObject* global;
mGlobal->GetJSObject(&global);
return global;
return mGlobal->GetJSObject();
}
protected:
nsresult Init();

View File

@ -84,8 +84,8 @@ nsEventListenerInfo::GetJSVal(JSContext* aCx,
*aJSVal = JSVAL_NULL;
nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = do_QueryInterface(mListener);
if (wrappedJS) {
JS::Rooted<JSObject*> object(aCx, nullptr);
if (NS_FAILED(wrappedJS->GetJSObject(object.address()))) {
JS::Rooted<JSObject*> object(aCx, wrappedJS->GetJSObject());
if (!object) {
return false;
}
aAc.construct(aCx, object);

View File

@ -83,8 +83,8 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
if (!targetObjectIsNew)
return NS_OK;
JS::Rooted<JSObject*> targetScriptObject(context->GetNativeContext());
holder->GetJSObject(targetScriptObject.address());
JS::Rooted<JSObject*> targetScriptObject(context->GetNativeContext(),
holder->GetJSObject());
AutoPushJSContext cx(context->GetNativeContext());
JSAutoRequest ar(cx);

View File

@ -1438,9 +1438,8 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult)
JSContext* cx = nsContentUtils::GetCurrentJSContext();
NS_ENSURE_TRUE(cx, NS_ERROR_NOT_AVAILABLE);
JS::RootedObject jsobj(cx);
rv = holder->GetJSObject(jsobj.address());
NS_ENSURE_SUCCESS(rv, rv);
JS::RootedObject jsobj(cx, holder->GetJSObject());
NS_ENSURE_STATE(jsobj);
JS::RootedString str(cx, JS_ValueToString(cx, OBJECT_TO_JSVAL(jsobj)));
NS_ENSURE_TRUE(str, NS_ERROR_FAILURE);

View File

@ -2649,8 +2649,8 @@ nsDOMClassInfo::CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
nsresult rv;
JS::Rooted<JSObject*> real_obj(cx);
if (wrapper) {
rv = wrapper->GetJSObject(real_obj.address());
NS_ENSURE_SUCCESS(rv, rv);
real_obj = wrapper->GetJSObject();
NS_ENSURE_STATE(real_obj);
}
else {
real_obj = obj;
@ -3360,8 +3360,7 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
} else {
nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = do_QueryInterface(native);
JS::Rooted<JSObject*> thisObject(cx);
wrappedJS->GetJSObject(thisObject.address());
JS::Rooted<JSObject*> thisObject(cx, wrappedJS->GetJSObject());
if (!thisObject) {
return NS_ERROR_UNEXPECTED;
}
@ -4106,8 +4105,7 @@ GetXPCProto(nsIXPConnect *aXPConnect, JSContext *cx, nsGlobalWindow *aWin,
aProto);
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JSObject*> proto_obj(cx);
(*aProto)->GetJSObject(proto_obj.address());
JS::Rooted<JSObject*> proto_obj(cx, (*aProto)->GetJSObject());
if (!JS_WrapObject(cx, proto_obj.address())) {
return NS_ERROR_FAILURE;
}
@ -4149,8 +4147,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
NS_ENSURE_SUCCESS(rv, rv);
}
JS::Rooted<JSObject*> class_obj(cx);
holder->GetJSObject(class_obj.address());
JS::Rooted<JSObject*> class_obj(cx, holder->GetJSObject());
NS_ASSERTION(class_obj, "The return value lied");
const nsIID *primary_iid = &NS_GET_IID(nsISupports);
@ -4427,8 +4424,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
rv = constructor->Install(cx, obj, v);
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JSObject*> class_obj(cx);
holder->GetJSObject(class_obj.address());
JS::Rooted<JSObject*> class_obj(cx, holder->GetJSObject());
NS_ASSERTION(class_obj, "The return value lied");
// ... and define the constants from the DOM interface on that
@ -4456,9 +4452,8 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
getter_AddRefs(proto_holder));
if (NS_SUCCEEDED(rv) && obj != aWin->GetGlobalJSObject()) {
JS::Rooted<JSObject*> dot_prototype(cx);
rv = proto_holder->GetJSObject(dot_prototype.address());
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JSObject*> dot_prototype(cx, proto_holder->GetJSObject());
NS_ENSURE_STATE(dot_prototype);
const nsDOMClassInfoData *ci_data;
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
@ -4498,9 +4493,8 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
getter_AddRefs(proto_holder));
NS_ENSURE_SUCCESS(rv, rv);
JSObject* dot_prototype;
rv = proto_holder->GetJSObject(&dot_prototype);
NS_ENSURE_SUCCESS(rv, rv);
JSObject* dot_prototype = proto_holder->GetJSObject();
NS_ENSURE_STATE(dot_prototype);
const nsDOMClassInfoData *ci_data;
if (alias_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
@ -4532,9 +4526,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
rv = constructor->Install(cx, obj, val);
NS_ENSURE_SUCCESS(rv, rv);
JSObject* class_obj;
holder->GetJSObject(&class_obj);
NS_ASSERTION(class_obj, "Why didn't we get a JSObject?");
NS_ASSERTION(holder->GetJSObject(), "Why didn't we get a JSObject?");
*did_resolve = true;
@ -4879,8 +4871,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
NS_ENSURE_SUCCESS(rv, rv);
// Make sure we wrap the location object in the window's scope.
JS::Rooted<JSObject*> scope(cx);
wrapper->GetJSObject(scope.address());
JS::Rooted<JSObject*> scope(cx, wrapper->GetJSObject());
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
JS::Rooted<JS::Value> v(cx);
@ -5063,8 +5054,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
// defined on our prototype chain. This way we can access this
// expando w/o ever getting back into XPConnect.
if (flags & JSRESOLVE_ASSIGNING) {
JS::Rooted<JSObject*> realObj(cx);
wrapper->GetJSObject(realObj.address());
JS::Rooted<JSObject*> realObj(cx, wrapper->GetJSObject());
if (obj == realObj) {
JS::Rooted<JSObject*> proto(cx);
@ -5909,13 +5899,7 @@ nsNamedArraySH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
!ObjectIsNativeWrapper(cx, obj)) {
{
JS::Rooted<JSObject*> realObj(cx);
if (wrapper) {
wrapper->GetJSObject(realObj.address());
} else {
realObj = obj;
}
JS::Rooted<JSObject*> realObj(cx, wrapper ? wrapper->GetJSObject() : obj);
JSAutoCompartment ac(cx, realObj);
JS::Rooted<JSObject*> proto(cx);
@ -6905,8 +6889,7 @@ nsStorage2SH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
JS::Rooted<JSObject*> realObj(cx);
wrapper->GetJSObject(realObj.address());
JS::Rooted<JSObject*> realObj(cx, wrapper->GetJSObject());
JSAutoCompartment ac(cx, realObj);

View File

@ -2130,7 +2130,7 @@ CreateNativeGlobalForInner(JSContext* aCx,
NS_ENSURE_SUCCESS(rv, rv);
MOZ_ASSERT(jsholder);
jsholder->GetJSObject(aNativeGlobal);
*aNativeGlobal = jsholder->GetJSObject();
jsholder.forget(aHolder);
// Set the location information for the new global, so that tools like

View File

@ -343,8 +343,8 @@ public:
AutoSafeJSContext cx;
JS::Rooted<JSObject*> obj(cx);
if (NS_FAILED(wrappedJS->GetJSObject(obj.address())) || !obj) {
JS::Rooted<JSObject*> obj(cx, wrappedJS->GetJSObject());
if (!obj) {
return nullptr;
}

View File

@ -8997,7 +8997,8 @@ def genConstructorBody(descriptor, initCall=""):
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
if (NS_FAILED(implWrapped->GetJSObject(jsImplObj.address()))) {
jsImplObj = implWrapped->GetJSObject();
if (!jsImplObj) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}

View File

@ -218,9 +218,8 @@ IDBFactory::Create(ContentParent* aContentParent,
nsresult rv = xpc->CreateSandbox(cx, principal, getter_AddRefs(globalHolder));
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JSObject*> global(cx);
rv = globalHolder->GetJSObject(global.address());
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JSObject*> global(cx, globalHolder->GetJSObject());
NS_ENSURE_STATE(global);
// The CreateSandbox call returns a proxy to the actual sandbox object. We
// don't need a proxy here.

View File

@ -52,8 +52,8 @@ ReturnKeyRange(JSContext* aCx,
return false;
}
JS::Rooted<JSObject*> result(aCx);
if (NS_FAILED(holder->GetJSObject(result.address()))) {
JS::Rooted<JSObject*> result(aCx, holder->GetJSObject());
if (!result) {
JS_ReportError(aCx, "Couldn't get JSObject from wrapper.");
return false;
}

View File

@ -1245,8 +1245,7 @@ _getpluginelement(NPP npp)
getter_AddRefs(holder));
NS_ENSURE_TRUE(holder, nullptr);
JS::Rooted<JSObject*> obj(cx);
holder->GetJSObject(obj.address());
JS::Rooted<JSObject*> obj(cx, holder->GetJSObject());
NS_ENSURE_TRUE(obj, nullptr);
return nsJSObjWrapper::GetNewOrUsed(npp, cx, obj);

View File

@ -290,9 +290,8 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
// our current compartment. Because our current context doesn't necessarily
// subsume that of the sandbox, we want to unwrap and enter the sandbox's
// compartment. It's a shame that the APIs here are so clunkly. :-(
JS::Rooted<JSObject*> sandboxObj(cx);
rv = sandbox->GetJSObject(sandboxObj.address());
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JSObject*> sandboxObj(cx, sandbox->GetJSObject());
NS_ENSURE_STATE(sandboxObj);
sandboxObj = js::UncheckedUnwrap(sandboxObj);
JSAutoCompartment ac(cx, sandboxObj);

View File

@ -57,8 +57,8 @@ nsresult CentralizedAdminPrefManagerInit()
NS_ENSURE_SUCCESS(rv, rv);
// Unwrap, store and root the sandbox.
rv = sandbox->GetJSObject(&autoconfigSb);
NS_ENSURE_SUCCESS(rv, rv);
autoconfigSb = sandbox->GetJSObject();
NS_ENSURE_STATE(autoconfigSb);
autoconfigSb = js::UncheckedUnwrap(autoconfigSb);
JSAutoCompartment ac(cx, autoconfigSb);
if (!JS_AddNamedObjectRoot(cx, &autoconfigSb, "AutoConfig Sandbox"))

View File

@ -1026,9 +1026,8 @@ XPCShellEnvironment::Init()
return false;
}
JS::Rooted<JSObject*> globalObj(cx);
rv = holder->GetJSObject(globalObj.address());
if (NS_FAILED(rv)) {
JS::Rooted<JSObject*> globalObj(cx, holder->GetJSObject());
if (!globalObj) {
NS_ERROR("Failed to get global JSObject!");
return false;
}

View File

@ -63,10 +63,10 @@ class nsScriptObjectTracer;
%}
/***************************************************************************/
[uuid(8916a320-d118-11d3-8f3a-0010a4e73d9a)]
[uuid(909e8641-7c54-4dff-9b94-ba631f057b33)]
interface nsIXPConnectJSObjectHolder : nsISupports
{
readonly attribute JSObjectPtr JSObject;
[notxpcom, nostdcall] JSObjectPtr GetJSObject();
};
[uuid(92e98688-0154-4b65-971b-0d4afe8fd7cb)]

View File

@ -546,7 +546,6 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile)
JSCLContextHelper cx(mContext);
JSAutoCompartment ac(cx, entry->obj);
JSObject* cm_jsobj;
nsCOMPtr<nsIXPConnectJSObjectHolder> cm_holder;
rv = xpc->WrapNative(cx, entry->obj, cm,
NS_GET_IID(nsIComponentManager),
@ -560,15 +559,14 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile)
return NULL;
}
rv = cm_holder->GetJSObject(&cm_jsobj);
if (NS_FAILED(rv)) {
JSObject* cm_jsobj = cm_holder->GetJSObject();
if (!cm_jsobj) {
#ifdef DEBUG_shaver
fprintf(stderr, "GetJSObject of ComponentManager failed\n");
#endif
return NULL;
}
JSObject* file_jsobj;
nsCOMPtr<nsIXPConnectJSObjectHolder> file_holder;
rv = xpc->WrapNative(cx, entry->obj, file,
NS_GET_IID(nsIFile),
@ -578,8 +576,8 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile)
return NULL;
}
rv = file_holder->GetJSObject(&file_jsobj);
if (NS_FAILED(rv)) {
JSObject* file_jsobj = file_holder->GetJSObject();
if (!file_jsobj) {
return NULL;
}
@ -662,7 +660,7 @@ mozJSComponentLoader::FindTargetObject(JSContext* aCx,
rv = cc->GetCalleeWrapper(getter_AddRefs(wn));
NS_ENSURE_SUCCESS(rv, rv);
wn->GetJSObject(targetObject.address());
targetObject = wn->GetJSObject();
if (!targetObject) {
NS_ERROR("null calling object");
return NS_ERROR_FAILURE;
@ -745,9 +743,8 @@ mozJSComponentLoader::PrepareObjectForLocation(JSCLContextHelper& aCx,
getter_AddRefs(holder));
NS_ENSURE_SUCCESS(rv, nullptr);
RootedObject global(aCx);
rv = holder->GetJSObject(global.address());
NS_ENSURE_SUCCESS(rv, nullptr);
RootedObject global(aCx, holder->GetJSObject());
NS_ENSURE_TRUE(global, nullptr);
backstagePass->SetGlobalObject(global);
@ -762,9 +759,8 @@ mozJSComponentLoader::PrepareObjectForLocation(JSCLContextHelper& aCx,
}
}
RootedObject obj(aCx);
rv = holder->GetJSObject(obj.address());
NS_ENSURE_SUCCESS(rv, nullptr);
RootedObject obj(aCx, holder->GetJSObject());
NS_ENSURE_TRUE(obj, nullptr);
JSAutoCompartment ac(aCx, obj);
@ -795,9 +791,8 @@ mozJSComponentLoader::PrepareObjectForLocation(JSCLContextHelper& aCx,
getter_AddRefs(locationHolder));
NS_ENSURE_SUCCESS(rv, nullptr);
RootedObject locationObj(aCx);
rv = locationHolder->GetJSObject(locationObj.address());
NS_ENSURE_SUCCESS(rv, nullptr);
RootedObject locationObj(aCx, locationHolder->GetJSObject());
NS_ENSURE_TRUE(locationObj, nullptr);
if (!JS_DefineProperty(aCx, obj, "__LOCATION__",
JS::ObjectValue(*locationObj),
@ -1140,8 +1135,8 @@ mozJSComponentLoader::UnloadModules()
if (mLoaderGlobal) {
MOZ_ASSERT(mReuseLoaderGlobal, "How did this happen?");
RootedObject global(mContext);
if (NS_SUCCEEDED(mLoaderGlobal->GetJSObject(global.address()))) {
RootedObject global(mContext, mLoaderGlobal->GetJSObject());
if (global) {
JSAutoRequest ar(mContext);
JS_SetAllNonReservedSlotsToUndefined(mContext, global);
} else {

View File

@ -204,7 +204,6 @@ GetLocationProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableH
if (location) {
nsCOMPtr<nsIXPConnectJSObjectHolder> locationHolder;
JS::Rooted<JSObject*> locationObj(cx, nullptr);
bool symlink;
// don't normalize symlinks, because that's kind of confusing
@ -216,8 +215,8 @@ GetLocationProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableH
getter_AddRefs(locationHolder));
if (NS_SUCCEEDED(rv) &&
NS_SUCCEEDED(locationHolder->GetJSObject(locationObj.address()))) {
vp.set(OBJECT_TO_JSVAL(locationObj));
locationHolder->GetJSObject()) {
vp.set(OBJECT_TO_JSVAL(locationHolder->GetJSObject()));
}
}
}
@ -1692,7 +1691,6 @@ main(int argc, char **argv, char **envp)
#endif
JSRuntime *rt;
JSContext *cx;
JSObject *glob, *envobj;
int result;
nsresult rv;
@ -1820,6 +1818,9 @@ main(int argc, char **argv, char **envp)
return 1;
}
JS::Rooted<JSObject*> glob(cx);
JS::Rooted<JSObject*> envobj(cx);
argc--;
argv++;
ProcessArgsForCompartment(cx, argv, argc);
@ -1893,9 +1894,8 @@ main(int argc, char **argv, char **envp)
if (NS_FAILED(rv))
return 1;
rv = holder->GetJSObject(&glob);
if (NS_FAILED(rv)) {
NS_ASSERTION(glob == nullptr, "bad GetJSObject?");
glob = holder->GetJSObject();
if (!glob) {
return 1;
}
@ -1931,8 +1931,7 @@ main(int argc, char **argv, char **envp)
JS_DefineProperty(cx, glob, "__LOCATION__", JSVAL_VOID,
GetLocationProperty, NULL, 0);
JS::Rooted<JSObject*> rootedGlob(cx, glob);
result = ProcessArgs(cx, rootedGlob, argv, argc, &dirprovider);
result = ProcessArgs(cx, glob, argv, argc, &dirprovider);
JS_DropPrincipals(rt, gJSPrincipals);
JS_SetAllNonReservedSlotsToUndefined(cx, glob);

View File

@ -333,7 +333,9 @@ nsXPCComponents_Interfaces::NewResolve(nsIXPConnectWrappedNative *wrapper,
NS_GET_IID(nsIJSIID),
getter_AddRefs(holder)))) {
RootedObject idobj(cx);
if (holder && NS_SUCCEEDED(holder->GetJSObject(idobj.address()))) {
if (holder &&
// Assign, not compare
(idobj = holder->GetJSObject())) {
*objp = obj;
*_retval = JS_DefinePropertyById(cx, obj, id,
OBJECT_TO_JSVAL(idobj),
@ -623,7 +625,9 @@ nsXPCComponents_InterfacesByID::NewResolve(nsIXPConnectWrappedNative *wrapper,
NS_GET_IID(nsIJSIID),
getter_AddRefs(holder)))) {
RootedObject idobj(cx);
if (holder && NS_SUCCEEDED(holder->GetJSObject(idobj.address()))) {
if (holder &&
// Assign, not compare
(idobj = holder->GetJSObject())) {
*objp = obj;
*_retval =
JS_DefinePropertyById(cx, obj, id,
@ -903,7 +907,9 @@ nsXPCComponents_Classes::NewResolve(nsIXPConnectWrappedNative *wrapper,
NS_GET_IID(nsIJSCID),
getter_AddRefs(holder)))) {
RootedObject idobj(cx);
if (holder && NS_SUCCEEDED(holder->GetJSObject(idobj.address()))) {
if (holder &&
// Assign, not compare
(idobj = holder->GetJSObject())) {
*objp = obj;
*_retval = JS_DefinePropertyById(cx, obj, id,
OBJECT_TO_JSVAL(idobj),
@ -1165,7 +1171,9 @@ nsXPCComponents_ClassesByID::NewResolve(nsIXPConnectWrappedNative *wrapper,
NS_GET_IID(nsIJSCID),
getter_AddRefs(holder)))) {
RootedObject idobj(cx);
if (holder && NS_SUCCEEDED(holder->GetJSObject(idobj.address()))) {
if (holder &&
// Assign, not compare
(idobj = holder->GetJSObject())) {
*objp = obj;
*_retval = JS_DefinePropertyById(cx, obj, id,
ObjectValue(*idobj),
@ -1979,7 +1987,8 @@ nsXPCComponents_Exception::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
if (NS_FAILED(xpc->WrapNative(cx, obj, e, NS_GET_IID(nsIXPCException),
getter_AddRefs(holder))) || !holder ||
NS_FAILED(holder->GetJSObject(newObj.address())) || !newObj) {
// Assign, not compare
!(newObj = holder->GetJSObject())) {
return ThrowAndFail(NS_ERROR_XPC_CANT_CREATE_WN, cx, _retval);
}
@ -2236,10 +2245,12 @@ nsXPCConstructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,JSContext *
if (NS_FAILED(xpc->WrapNative(cx, obj, mClassID, NS_GET_IID(nsIJSCID),
getter_AddRefs(cidHolder))) || !cidHolder ||
NS_FAILED(cidHolder->GetJSObject(cidObj.address())) || !cidObj ||
// Assign, not compare
!(cidObj = cidHolder->GetJSObject()) ||
NS_FAILED(xpc->WrapNative(cx, obj, mInterfaceID, NS_GET_IID(nsIJSIID),
getter_AddRefs(iidHolder))) || !iidHolder ||
NS_FAILED(iidHolder->GetJSObject(iidObj.address())) || !iidObj) {
// Assign, not compare
!(iidObj = iidHolder->GetJSObject())) {
return ThrowAndFail(NS_ERROR_XPC_CANT_CREATE_WN, cx, _retval);
}
@ -2503,7 +2514,8 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
NS_FAILED(xpc->WrapNative(cx, obj, ifaces,
NS_GET_IID(nsIXPCComponents_Interfaces),
getter_AddRefs(holder))) || !holder ||
NS_FAILED(holder->GetJSObject(ifacesObj.address())) || !ifacesObj) {
// Assign, not compare
!(ifacesObj = holder->GetJSObject())) {
return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
}
@ -2551,7 +2563,8 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
NS_FAILED(xpc->WrapNative(cx, obj, classes,
NS_GET_IID(nsIXPCComponents_Classes),
getter_AddRefs(holder))) || !holder ||
NS_FAILED(holder->GetJSObject(classesObj.address())) || !classesObj) {
// Assign, not compare
!(classesObj = holder->GetJSObject())) {
return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
}
@ -2583,7 +2596,8 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
if (NS_FAILED(xpc->WrapNative(cx, obj, ctor, NS_GET_IID(nsIXPCConstructor),
getter_AddRefs(holder2))) || !holder2 ||
NS_FAILED(holder2->GetJSObject(newObj.address())) || !newObj) {
// Assign, not compare
!(newObj = holder2->GetJSObject())) {
return ThrowAndFail(NS_ERROR_XPC_CANT_CREATE_WN, cx, _retval);
}

View File

@ -725,7 +725,7 @@ GetWrapperObject(MutableHandleObject obj)
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
ccxp->GetCalleeWrapper(getter_AddRefs(wrapper));
wrapper->GetJSObject(obj.address());
obj.set(wrapper->GetJSObject());
}
/* nsISupports createInstance (); */
@ -819,7 +819,9 @@ nsJSCID::GetService(const JS::Value& iidval, JSContext* cx,
RootedObject instJSObj(cx);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = nsXPConnect::GetXPConnect()->WrapNative(cx, obj, srvc, *iid, getter_AddRefs(holder));
if (NS_FAILED(rv) || !holder || NS_FAILED(holder->GetJSObject(instJSObj.address())))
if (NS_FAILED(rv) || !holder ||
// Assign, not compare
!(instJSObj = holder->GetJSObject()))
return NS_ERROR_XPC_CANT_CREATE_WN;
*retval = OBJECT_TO_JSVAL(instJSObj);
@ -901,7 +903,7 @@ xpc_NewIDObject(JSContext *cx, HandleObject jsobj, const nsID& aID)
NS_GET_IID(nsIJSID),
getter_AddRefs(holder));
if (NS_SUCCEEDED(rv) && holder) {
holder->GetJSObject(obj.address());
obj = holder->GetJSObject();
}
}
}

View File

@ -78,8 +78,7 @@ xpcJSWeakReference::Get(JSContext* aCx, JS::Value* aRetval)
aRetval);
}
JS::RootedObject obj(aCx);
wrappedObj->GetJSObject(obj.address());
JS::RootedObject obj(aCx, wrappedObj->GetJSObject());
if (!obj) {
return NS_OK;
}

View File

@ -251,8 +251,8 @@ XPCThrower::ThrowExceptionObject(JSContext* cx, nsIException* e)
NS_GET_IID(nsIException),
getter_AddRefs(holder));
if (NS_SUCCEEDED(rv) && holder) {
JS::RootedObject obj(cx);
if (NS_SUCCEEDED(holder->GetJSObject(obj.address()))) {
JS::RootedObject obj(cx, holder->GetJSObject());
if (obj) {
JS_SetPendingException(cx, OBJECT_TO_JSVAL(obj));
success = true;
}

View File

@ -236,15 +236,10 @@ nsXPCWrappedJS::GetWeakReference(nsIWeakReference** aInstancePtr)
return nsSupportsWeakReference::GetWeakReference(aInstancePtr);
}
NS_IMETHODIMP
nsXPCWrappedJS::GetJSObject(JSObject** aJSObj)
JSObject*
nsXPCWrappedJS::GetJSObject()
{
NS_PRECONDITION(aJSObj, "bad param");
NS_PRECONDITION(IsValid(), "bad wrapper");
if (!(*aJSObj = GetJSObject()))
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
return xpc_UnmarkGrayObject(mJSObj);
}
static bool

View File

@ -563,9 +563,7 @@ XPCWrappedNative::GetNewOrUsed(XPCCallContext& ccx,
nsISupports *Object = helper.Object();
if (nsXPCWrappedJSClass::IsWrappedJS(Object)) {
nsCOMPtr<nsIXPConnectWrappedJS> wrappedjs(do_QueryInterface(Object));
RootedObject obj(ccx);
wrappedjs->GetJSObject(obj.address());
if (xpc::AccessCheck::isChrome(js::GetObjectCompartment(obj)) &&
if (xpc::AccessCheck::isChrome(js::GetObjectCompartment(wrappedjs->GetJSObject())) &&
!xpc::AccessCheck::isChrome(js::GetObjectCompartment(Scope->GetGlobalJSObject()))) {
needsCOW = true;
}
@ -1918,9 +1916,8 @@ XPCWrappedNative::InitTearOff(XPCCallContext& ccx,
nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS(do_QueryInterface(obj));
if (wrappedJS) {
RootedObject jso(ccx);
if (NS_SUCCEEDED(wrappedJS->GetJSObject(jso.address())) &&
jso == mFlatJSObject) {
RootedObject jso(ccx, wrappedJS->GetJSObject());
if (jso == mFlatJSObject) {
// The implementing JSObject is the same as ours! Just say OK
// without actually extending the set.
//
@ -2943,11 +2940,11 @@ CallMethodHelper::Invoke()
/***************************************************************************/
// interface methods
/* readonly attribute JSObjectPtr JSObject; */
NS_IMETHODIMP XPCWrappedNative::GetJSObject(JSObject * *aJSObject)
/* JSObjectPtr GetJSObject(); */
JSObject*
XPCWrappedNative::GetJSObject()
{
*aJSObject = GetFlatJSObject();
return NS_OK;
return GetFlatJSObject();
}
/* readonly attribute nsISupports Native; */
@ -3549,13 +3546,11 @@ void DEBUG_ReportShadowedMembers(XPCNativeSet* set,
NS_IMPL_THREADSAFE_ISUPPORTS1(XPCJSObjectHolder, nsIXPConnectJSObjectHolder)
NS_IMETHODIMP
XPCJSObjectHolder::GetJSObject(JSObject** aJSObj)
JSObject*
XPCJSObjectHolder::GetJSObject()
{
NS_PRECONDITION(aJSObj, "bad param");
NS_PRECONDITION(mJSObj, "bad object state");
*aJSObj = mJSObj;
return NS_OK;
return mJSObj;
}
XPCJSObjectHolder::XPCJSObjectHolder(XPCCallContext& ccx, JSObject* obj)

View File

@ -146,8 +146,8 @@ GetDoubleWrappedJSObject(XPCCallContext& ccx, XPCWrappedNative* wrapper)
nsCOMPtr<nsIXPConnectWrappedJS>
underware = do_QueryInterface(wrapper->GetIdentityObject());
if (underware) {
RootedObject mainObj(ccx);
if (NS_SUCCEEDED(underware->GetJSObject(mainObj.address())) && mainObj) {
RootedObject mainObj(ccx, underware->GetJSObject());
if (mainObj) {
RootedId id(ccx, ccx.GetRuntime()->
GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT));

View File

@ -3146,12 +3146,6 @@ public:
nsISomeInterface* GetXPTCStub() { return mXPTCStub; }
/**
* This getter clears the gray bit before handing out the JSObject which
* means that the object is guaranteed to be kept alive past the next CC.
*/
JSObject* GetJSObject() const {return xpc_UnmarkGrayObject(mJSObj);}
/**
* This getter does not change the color of the JSObject meaning that the
* object returned is not guaranteed to be kept alive past the next CC.

View File

@ -1856,7 +1856,6 @@ nsCrypto::GenerateCRMFRequest(nsIDOMCRMFObject** aReturn)
nrv = ncc->GetJSContext(&cx);
NS_ENSURE_SUCCESS(nrv, nrv);
JS::RootedObject script_obj(cx);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
JSAutoRequest ar(cx);
@ -1921,8 +1920,8 @@ nsCrypto::GenerateCRMFRequest(nsIDOMCRMFObject** aReturn)
NS_GET_IID(nsIDOMCrypto), getter_AddRefs(holder));
NS_ENSURE_SUCCESS(nrv, nrv);
nrv = holder->GetJSObject(script_obj.address());
NS_ENSURE_SUCCESS(nrv, nrv);
JS::RootedObject script_obj(cx, holder->GetJSObject());
NS_ENSURE_STATE(script_obj);
//Put up some UI warning that someone is trying to
//escrow the private key.

View File

@ -57,8 +57,8 @@ AsyncStatementJSHelper::getParams(AsyncStatement *aStatement,
}
JS::Rooted<JSObject*> obj(aCtx);
rv = aStatement->mStatementParamsHolder->GetJSObject(obj.address());
NS_ENSURE_SUCCESS(rv, rv);
obj = aStatement->mStatementParamsHolder->GetJSObject();
NS_ENSURE_STATE(obj);
*_params = OBJECT_TO_JSVAL(obj);
return NS_OK;

View File

@ -110,8 +110,8 @@ StatementJSHelper::getRow(Statement *aStatement,
}
JS::Rooted<JSObject*> obj(aCtx);
rv = aStatement->mStatementRowHolder->GetJSObject(obj.address());
NS_ENSURE_SUCCESS(rv, rv);
obj = aStatement->mStatementRowHolder->GetJSObject();
NS_ENSURE_STATE(obj);
*_row = OBJECT_TO_JSVAL(obj);
return NS_OK;
@ -150,8 +150,8 @@ StatementJSHelper::getParams(Statement *aStatement,
}
JS::Rooted<JSObject*> obj(aCtx);
rv = aStatement->mStatementParamsHolder->GetJSObject(obj.address());
NS_ENSURE_SUCCESS(rv, rv);
obj = aStatement->mStatementParamsHolder->GetJSObject();
NS_ENSURE_STATE(obj);
*_params = OBJECT_TO_JSVAL(obj);
return NS_OK;

View File

@ -90,9 +90,8 @@ PlaceInfo::GetVisits(JSContext* aContext,
getter_AddRefs(wrapper));
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JSObject*> jsobj(aContext);
rv = wrapper->GetJSObject(jsobj.address());
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JSObject*> jsobj(aContext, wrapper->GetJSObject());
NS_ENSURE_STATE(jsobj);
JS::Value wrappedVisit = OBJECT_TO_JSVAL(jsobj);
JSBool rc = JS_SetElement(aContext, visits, idx, &wrappedVisit);

View File

@ -253,11 +253,10 @@ nsHTTPIndex::OnStartRequest(nsIRequest *request, nsISupports* aContext)
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to xpconnect-wrap http-index");
if (NS_FAILED(rv)) return rv;
JS::Rooted<JSObject*> jsobj(cx);
rv = wrapper->GetJSObject(jsobj.address());
NS_ASSERTION(NS_SUCCEEDED(rv),
JS::Rooted<JSObject*> jsobj(cx, wrapper->GetJSObject());
NS_ASSERTION(jsobj,
"unable to get jsobj from xpconnect wrapper");
if (NS_FAILED(rv)) return rv;
if (!jsobj) return NS_ERROR_UNEXPECTED;
JS::Rooted<JS::Value> jslistener(cx, OBJECT_TO_JSVAL(jsobj));