Bug 1071177 - Add support for symbols as a value type. r=billm
authorTom Schuster <evilpies@gmail.com>
Tue, 07 Oct 2014 11:29:03 +0200
changeset 233669 2279791b5c6e8d55675db58f38ccfcba7c568ca9
parent 233668 6e6f184e59285a2dcdf106c830e7ec0db2da6a97
child 233670 435e1a7b1a347e2ca5a564f4c45625e50fef3e05
push id611
push userraliiev@mozilla.com
push dateMon, 05 Jan 2015 23:23:16 +0000
treeherdermozilla-release@345cd3b9c445 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1071177
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1071177 - Add support for symbols as a value type. r=billm
js/ipc/JavaScriptLogging.h
js/ipc/JavaScriptShared.cpp
js/ipc/JavaScriptTypes.ipdlh
--- a/js/ipc/JavaScriptLogging.h
+++ b/js/ipc/JavaScriptLogging.h
@@ -166,16 +166,20 @@ class Logging
           case JSVariant::TObjectVariant: {
               const ObjectVariant &ovar = value.get_ObjectVariant();
               if (ovar.type() == ObjectVariant::TLocalObject)
                   formatObject(incoming, true, ObjectId::deserialize(ovar.get_LocalObject().serializedId()), out);
               else
                   formatObject(incoming, false, ObjectId::deserialize(ovar.get_RemoteObject().serializedId()), out);
               break;
           }
+          case JSVariant::TSymbolVariant: {
+              out = "<Symbol>";
+              break;
+          }
           case JSVariant::Tdouble: {
               out = nsPrintfCString("%.0f", value.get_double());
               break;
           }
           case JSVariant::Tbool: {
               out = value.get_bool() ? "true" : "false";
               break;
           }
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -262,16 +262,27 @@ JavaScriptShared::toVariant(JSContext *c
 
         ObjectVariant objVar;
         if (!toObjectVariant(cx, obj, &objVar))
             return false;
         *to = objVar;
         return true;
       }
 
+      case JSTYPE_SYMBOL:
+      {
+        RootedSymbol sym(cx, from.toSymbol());
+
+        SymbolVariant symVar;
+        if (!toSymbolVariant(cx, sym, &symVar))
+            return false;
+        *to = symVar;
+        return true;
+      }
+
       case JSTYPE_STRING:
       {
         nsAutoJSString autoStr;
         if (!autoStr.init(cx, from))
             return false;
         *to = autoStr;
         return true;
       }
@@ -309,16 +320,25 @@ JavaScriptShared::fromVariant(JSContext 
         {
           JSObject *obj = fromObjectVariant(cx, from.get_ObjectVariant());
           if (!obj)
               return false;
           to.set(ObjectValue(*obj));
           return true;
         }
 
+        case JSVariant::TSymbolVariant:
+        {
+          Symbol *sym = fromSymbolVariant(cx, from.get_SymbolVariant());
+          if (!sym)
+              return false;
+          to.setSymbol(sym);
+          return true;
+        }
+
         case JSVariant::Tdouble:
           to.set(JS_NumberValue(from.get_double()));
           return true;
 
         case JSVariant::Tbool:
           to.set(BOOLEAN_TO_JSVAL(from.get_bool()));
           return true;
 
--- a/js/ipc/JavaScriptTypes.ipdlh
+++ b/js/ipc/JavaScriptTypes.ipdlh
@@ -62,16 +62,17 @@ union SymbolVariant
 struct UndefinedVariant {};
 struct NullVariant {};
 
 union JSVariant
 {
     UndefinedVariant;
     NullVariant;
     ObjectVariant;
+    SymbolVariant;
     nsString;   /* StringValue(x) */
     double;     /* NumberValue(x) */
     bool;       /* BooleanValue(x) */
     JSIID;      /* XPC nsIID */
 };
 
 union JSIDVariant
 {