diff --git a/js/ipc/JavaScriptChild.cpp b/js/ipc/JavaScriptChild.cpp index 46d91b598d9..81efc5e325e 100644 --- a/js/ipc/JavaScriptChild.cpp +++ b/js/ipc/JavaScriptChild.cpp @@ -413,7 +413,7 @@ JavaScriptChild::AnswerSet(const ObjectId &objId, const ObjectId &receiverId, co MOZ_ASSERT(obj == receiver); RootedValue val(cx); - if (!toValue(cx, value, &val)) + if (!fromVariant(cx, value, &val)) return fail(cx, rs); if (!JS_SetPropertyById(cx, obj, internedId, val)) @@ -465,7 +465,7 @@ JavaScriptChild::AnswerCall(const ObjectId &objId, const nsTArray &argv MOZ_ASSERT(argv.Length() >= 2); RootedValue objv(cx); - if (!toValue(cx, argv[0], &objv)) + if (!fromVariant(cx, argv[0], &objv)) return fail(cx, rs); JSAutoCompartment comp(cx, &objv.toObject()); @@ -488,7 +488,7 @@ JavaScriptChild::AnswerCall(const ObjectId &objId, const nsTArray &argv return fail(cx, rs); } else { RootedValue v(cx); - if (!toValue(cx, argv[i].get_JSVariant(), &v)) + if (!fromVariant(cx, argv[i].get_JSVariant(), &v)) return fail(cx, rs); if (!vals.append(v)) return fail(cx, rs); diff --git a/js/ipc/JavaScriptParent.cpp b/js/ipc/JavaScriptParent.cpp index 4e6bfe8f5f0..c6dd416658f 100644 --- a/js/ipc/JavaScriptParent.cpp +++ b/js/ipc/JavaScriptParent.cpp @@ -317,7 +317,7 @@ JavaScriptParent::get(JSContext *cx, HandleObject proxy, HandleObject receiver, if (!ok(cx, status)) return false; - return toValue(cx, val, vp); + return fromVariant(cx, val, vp); } bool @@ -350,7 +350,7 @@ JavaScriptParent::set(JSContext *cx, JS::HandleObject proxy, JS::HandleObject re if (!ok(cx, status)) return false; - return toValue(cx, result, vp); + return fromVariant(cx, result, vp); } bool @@ -443,7 +443,7 @@ JavaScriptParent::call(JSContext *cx, HandleObject proxy, const CallArgs &args) // Take the value the child process returned, and set it on the XPC // object. - if (!toValue(cx, outparams[i], &v)) + if (!fromVariant(cx, outparams[i], &v)) return false; obj = &outobjects[i].toObject(); @@ -451,7 +451,7 @@ JavaScriptParent::call(JSContext *cx, HandleObject proxy, const CallArgs &args) return false; } - if (!toValue(cx, result, args.rval())) + if (!fromVariant(cx, result, args.rval())) return false; return true; @@ -620,7 +620,7 @@ JavaScriptParent::ok(JSContext *cx, const ReturnStatus &status) return JS_ThrowStopIteration(cx); RootedValue exn(cx); - if (!toValue(cx, status.get_ReturnException().exn(), &exn)) + if (!fromVariant(cx, status.get_ReturnException().exn(), &exn)) return false; JS_SetPendingException(cx, exn); diff --git a/js/ipc/JavaScriptShared.cpp b/js/ipc/JavaScriptShared.cpp index 2873f2160d0..a7ea3279392 100644 --- a/js/ipc/JavaScriptShared.cpp +++ b/js/ipc/JavaScriptShared.cpp @@ -228,7 +228,7 @@ JavaScriptShared::toVariant(JSContext *cx, JS::HandleValue from, JSVariant *to) } bool -JavaScriptShared::toValue(JSContext *cx, const JSVariant &from, MutableHandleValue to) +JavaScriptShared::fromVariant(JSContext *cx, const JSVariant &from, MutableHandleValue to) { switch (from.type()) { case JSVariant::Tvoid_t: @@ -384,7 +384,7 @@ JavaScriptShared::toDescriptor(JSContext *cx, const PPropertyDescriptor &in, MutableHandle out) { out.setAttributes(in.attrs()); - if (!toValue(cx, in.value(), out.value())) + if (!fromVariant(cx, in.value(), out.value())) return false; Rooted obj(cx); if (!unwrap(cx, in.objId(), &obj)) @@ -448,7 +448,7 @@ JavaScriptShared::Unwrap(JSContext *cx, const InfallibleTArray &aCpow for (size_t i = 0; i < aCpows.Length(); i++) { const nsString &name = aCpows[i].name(); - if (!toValue(cx, aCpows[i].value(), &v)) + if (!fromVariant(cx, aCpows[i].value(), &v)) return false; if (!JS_DefineUCProperty(cx, diff --git a/js/ipc/JavaScriptShared.h b/js/ipc/JavaScriptShared.h index 783f1aa21e4..02abc7625df 100644 --- a/js/ipc/JavaScriptShared.h +++ b/js/ipc/JavaScriptShared.h @@ -93,21 +93,16 @@ class JavaScriptShared protected: bool toVariant(JSContext *cx, JS::HandleValue from, JSVariant *to); - bool toValue(JSContext *cx, const JSVariant &from, JS::MutableHandleValue to); - bool fromDescriptor(JSContext *cx, JS::Handle desc, PPropertyDescriptor *out); + bool fromVariant(JSContext *cx, const JSVariant &from, JS::MutableHandleValue to); + + bool fromDescriptor(JSContext *cx, JS::Handle desc, + PPropertyDescriptor *out); bool toDescriptor(JSContext *cx, const PPropertyDescriptor &in, JS::MutableHandle out); + bool convertIdToGeckoString(JSContext *cx, JS::HandleId id, nsString *to); bool convertGeckoStringToId(JSContext *cx, const nsString &from, JS::MutableHandleId id); - bool toValue(JSContext *cx, const JSVariant &from, jsval *to) { - JS::RootedValue v(cx); - if (!toValue(cx, from, &v)) - return false; - *to = v; - return true; - } - virtual bool makeId(JSContext *cx, JSObject *obj, ObjectId *idp) = 0; virtual JSObject *unwrap(JSContext *cx, ObjectId id) = 0;