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 209134 2279791b5c6e8d55675db58f38ccfcba7c568ca9
parent 209133 6e6f184e59285a2dcdf106c830e7ec0db2da6a97
child 209135 435e1a7b1a347e2ca5a564f4c45625e50fef3e05
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbillm
bugs1071177
milestone35.0a1
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
 {