Bug 1019191 part 22. Eliminate the effectively unused vp argument of xpc_qsUnwrapArgImpl. r=peterv

This commit is contained in:
Boris Zbarsky 2014-10-22 11:40:51 -04:00
parent 5d219a5529
commit d73c01f2df
5 changed files with 13 additions and 26 deletions

View File

@ -827,12 +827,10 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp)
// Switch this to UnwrapDOMObjectToISupports once our global objects are
// using new bindings.
JS::Rooted<JS::Value> unusedVal(cx);
nsISupports* native = nullptr;
nsCOMPtr<nsISupports> nativeRef;
UnwrapArg<nsISupports>(cx, obj, &native,
static_cast<nsISupports**>(getter_AddRefs(nativeRef)),
&unusedVal);
static_cast<nsISupports**>(getter_AddRefs(nativeRef)));
if (!native) {
return Throw(cx, NS_ERROR_FAILURE);
}
@ -848,7 +846,7 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp)
nsIJSID* iid;
SelfRef iidRef;
obj = &args[0].toObject();
if (NS_FAILED(UnwrapArg<nsIJSID>(cx, obj, &iid, &iidRef.ptr, &unusedVal))) {
if (NS_FAILED(UnwrapArg<nsIJSID>(cx, obj, &iid, &iidRef.ptr))) {
return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
}
MOZ_ASSERT(iid);

View File

@ -41,7 +41,7 @@ class nsPIDOMWindow;
extern nsresult
xpc_qsUnwrapArgImpl(JSContext* cx, JS::Handle<JSObject*> src, const nsIID& iid, void** ppArg,
nsISupports** ppArgRef, JS::MutableHandle<JS::Value> vp);
nsISupports** ppArgRef);
namespace mozilla {
namespace dom {
@ -60,12 +60,11 @@ struct SelfRef
template <class Interface, class StrongRefType>
inline nsresult
UnwrapArg(JSContext* cx, JS::Handle<JSObject*> src, Interface** ppArg,
StrongRefType** ppArgRef, JS::MutableHandle<JS::Value> vp)
StrongRefType** ppArgRef)
{
nsISupports* argRef = *ppArgRef;
nsresult rv = xpc_qsUnwrapArgImpl(cx, src, NS_GET_TEMPLATE_IID(Interface),
reinterpret_cast<void**>(ppArg), &argRef,
vp);
reinterpret_cast<void**>(ppArg), &argRef);
*ppArgRef = static_cast<StrongRefType*>(argRef);
return rv;
}

View File

@ -3677,8 +3677,7 @@ class CastableObjectUnwrapper():
// want to be in that compartment for the UnwrapArg call.
JS::Rooted<JSObject*> source(cx, ${source});
JSAutoCompartment ac(cx, ${source});
JS::Rooted<JS::Value> unused(cx);
rv = UnwrapArg<${type}>(cx, source, &objPtr, &objRef.ptr, &unused);
rv = UnwrapArg<${type}>(cx, source, &objPtr, &objRef.ptr);
}
""")
else:
@ -3686,8 +3685,7 @@ class CastableObjectUnwrapper():
self.substitution["source"] = source
xpconnectUnwrap = (
"JS::Rooted<JSObject*> source(cx, ${source});\n"
"JS::Rooted<JS::Value> unused(cx);\n"
"nsresult rv = UnwrapArg<${type}>(cx, source, &objPtr, &objRef.ptr, &unused);\n")
"nsresult rv = UnwrapArg<${type}>(cx, source, &objPtr, &objRef.ptr);\n")
if descriptor.hasXPConnectImpls:
self.substitution["codeOnFailure"] = string.Template(
@ -4767,24 +4765,18 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
else:
holderType = "nsRefPtr<" + typeName + ">"
templateBody += (
"JS::Rooted<JSObject*> source(cx, &${val}.toObject());\n"
"JS::Rooted<JS::Value> tmpVal(cx);\n" +
"JS::Rooted<JSObject*> source(cx, &${val}.toObject());\n" +
typePtr + " tmp;\n"
"if (NS_FAILED(UnwrapArg<" + typeName + ">(cx, source, &tmp, static_cast<" + typeName + "**>(getter_AddRefs(${holderName})), &tmpVal))) {\n")
"if (NS_FAILED(UnwrapArg<" + typeName + ">(cx, source, &tmp, static_cast<" + typeName + "**>(getter_AddRefs(${holderName}))))) {\n")
templateBody += CGIndenter(onFailureBadType(failureCode,
descriptor.interface.identifier.name)).define()
templateBody += ("}\n"
"MOZ_ASSERT(tmp);\n")
if not isDefinitelyObject and not forceOwningType:
# Our tmpVal will go out of scope, so we can't rely on it
# for rooting
templateBody += dedent("""
if (tmpVal != ${val} && !${holderName}) {
// We have to have a strong ref, because we got this off
// some random object that might get GCed
${holderName} = tmp;
}
// UnwrapArg never sets **ppArg without also setting *ppArgRef
MOZ_ASSERT(${holderName});
""")
# And store our tmp, before it goes out of scope.

View File

@ -24,8 +24,7 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
HandleObject src,
const nsIID &iid,
void **ppArg,
nsISupports **ppArgRef,
MutableHandleValue vp)
nsISupports **ppArgRef)
{
nsISupports *iface = xpc::UnwrapReflectorToISupports(src);
if (iface) {
@ -59,7 +58,6 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
rv = wrappedJS->QueryInterface(iid, ppArg);
if (NS_SUCCEEDED(rv)) {
*ppArgRef = static_cast<nsISupports*>(*ppArg);
vp.setObjectOrNull(wrappedJS->GetJSObject());
}
return rv;
}

View File

@ -13,6 +13,6 @@
nsresult
xpc_qsUnwrapArgImpl(JSContext *cx, JS::HandleObject src, const nsIID &iid, void **ppArg,
nsISupports **ppArgRef, JS::MutableHandleValue vp);
nsISupports **ppArgRef);
#endif /* xpcquickstubs_h___ */