Bug 996785 - Rename CPOW toValue (r=mrbkap)
authorBill McCloskey <wmccloskey@mozilla.com>
Fri, 16 May 2014 16:40:35 -0700
changeset 183652 9631faa6ed6754f5ab7b07ce40725e31482ec55f
parent 183651 bb17661ca3bcde81273bd4b176693f69072733a7
child 183653 4b7c1b82d2aa722406acf8e83c75b3e2a8759503
push id6844
push userphilringnalda@gmail.com
push dateSun, 18 May 2014 01:12:08 +0000
treeherderfx-team@41a54c8add09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs996785
milestone32.0a1
Bug 996785 - Rename CPOW toValue (r=mrbkap)
js/ipc/JavaScriptChild.cpp
js/ipc/JavaScriptParent.cpp
js/ipc/JavaScriptShared.cpp
js/ipc/JavaScriptShared.h
--- a/js/ipc/JavaScriptChild.cpp
+++ b/js/ipc/JavaScriptChild.cpp
@@ -408,17 +408,17 @@ JavaScriptChild::AnswerSet(const ObjectI
 
     RootedId internedId(cx);
     if (!convertGeckoStringToId(cx, id, &internedId))
         return fail(cx, rs);
 
     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))
         return fail(cx, rs);
 
     if (!toVariant(cx, val, result))
         return fail(cx, rs);
 
@@ -460,17 +460,17 @@ JavaScriptChild::AnswerCall(const Object
 
     RootedObject obj(cx, findObjectById(objId));
     if (!obj)
         return false;
 
     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());
 
     *result = JSVariant(void_t());
 
     AutoValueVector vals(cx);
     AutoValueVector outobjects(cx);
@@ -483,17 +483,17 @@ JavaScriptChild::AnswerCall(const Object
             if (!obj)
                 return fail(cx, rs);
             if (!outobjects.append(ObjectValue(*obj)))
                 return fail(cx, rs);
             if (!vals.append(ObjectValue(*obj)))
                 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);
         }
     }
 
     RootedValue rval(cx);
     {
--- a/js/ipc/JavaScriptParent.cpp
+++ b/js/ipc/JavaScriptParent.cpp
@@ -312,17 +312,17 @@ JavaScriptParent::get(JSContext *cx, Han
     JSVariant val;
     ReturnStatus status;
     if (!CallGet(objId, receiverId, idstr, &status, &val))
         return ipcfail(cx);
 
     if (!ok(cx, status))
         return false;
 
-    return toValue(cx, val, vp);
+    return fromVariant(cx, val, vp);
 }
 
 bool
 CPOWProxyHandler::set(JSContext *cx, JS::HandleObject proxy, JS::HandleObject receiver,
                       JS::HandleId id, bool strict, JS::MutableHandleValue vp)
 {
     FORWARD(set, (cx, proxy, receiver, id, strict, vp));
 }
@@ -345,17 +345,17 @@ JavaScriptParent::set(JSContext *cx, JS:
     ReturnStatus status;
     JSVariant result;
     if (!CallSet(objId, receiverId, idstr, strict, val, &status, &result))
         return ipcfail(cx);
 
     if (!ok(cx, status))
         return false;
 
-    return toValue(cx, result, vp);
+    return fromVariant(cx, result, vp);
 }
 
 bool
 CPOWProxyHandler::keys(JSContext *cx, HandleObject proxy, AutoIdVector &props)
 {
     FORWARD(keys, (cx, proxy, props));
 }
 
@@ -438,25 +438,25 @@ JavaScriptParent::call(JSContext *cx, Ha
     RootedObject obj(cx);
     for (size_t i = 0; i < outparams.Length(); i++) {
         // Don't bother doing anything for outparams that weren't set.
         if (outparams[i].type() == JSParam::Tvoid_t)
             continue;
 
         // 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();
         if (!JS_SetProperty(cx, obj, "value", v))
             return false;
     }
 
-    if (!toValue(cx, result, args.rval()))
+    if (!fromVariant(cx, result, args.rval()))
         return false;
 
     return true;
 }
 
 
 bool
 CPOWProxyHandler::objectClassIs(HandleObject proxy, js::ESClassValue classValue, JSContext *cx)
@@ -615,17 +615,17 @@ JavaScriptParent::ok(JSContext *cx, cons
 {
     if (status.type() == ReturnStatus::TReturnSuccess)
         return true;
 
     if (status.type() == ReturnStatus::TReturnStopIteration)
         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);
     return false;
 }
 
 void
 JavaScriptParent::decref()
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -223,17 +223,17 @@ JavaScriptShared::toVariant(JSContext *c
 
       default:
         MOZ_ASSERT(false);
         return false;
     }
 }
 
 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:
           to.set(UndefinedValue());
           return true;
 
         case JSVariant::Tuint64_t:
         {
@@ -379,17 +379,17 @@ UnknownStrictPropertyStub(JSContext *cx,
     return false;
 }
 
 bool
 JavaScriptShared::toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
                                MutableHandle<JSPropertyDescriptor> out)
 {
     out.setAttributes(in.attrs());
-    if (!toValue(cx, in.value(), out.value()))
+    if (!fromVariant(cx, in.value(), out.value()))
         return false;
     Rooted<JSObject*> obj(cx);
     if (!unwrap(cx, in.objId(), &obj))
         return false;
     out.object().set(obj);
 
     if (!in.getter()) {
         out.setGetter(nullptr);
@@ -443,17 +443,17 @@ JavaScriptShared::Unwrap(JSContext *cx, 
     if (!obj)
         return false;
 
     RootedValue v(cx);
     RootedString str(cx);
     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,
                                  obj,
                                  name.BeginReading(),
                                  name.Length(),
                                  v,
                                  JSPROP_ENUMERATE))
--- a/js/ipc/JavaScriptShared.h
+++ b/js/ipc/JavaScriptShared.h
@@ -88,31 +88,26 @@ class JavaScriptShared
     static const uint32_t OBJECT_EXTRA_BITS  = 1;
     static const uint32_t OBJECT_IS_CALLABLE = (1 << 0);
 
     bool Unwrap(JSContext *cx, const InfallibleTArray<CpowEntry> &aCpows, JS::MutableHandleObject objp);
     bool Wrap(JSContext *cx, JS::HandleObject aObj, InfallibleTArray<CpowEntry> *outCpows);
 
   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<JSPropertyDescriptor> desc, PPropertyDescriptor *out);
+    bool fromVariant(JSContext *cx, const JSVariant &from, JS::MutableHandleValue to);
+
+    bool fromDescriptor(JSContext *cx, JS::Handle<JSPropertyDescriptor> desc,
+                        PPropertyDescriptor *out);
     bool toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
                       JS::MutableHandle<JSPropertyDescriptor> 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;
 
     bool unwrap(JSContext *cx, ObjectId id, JS::MutableHandle<JSObject*> objp) {
         if (!id) {
             objp.set(nullptr);
             return true;
         }