Bug 1074591 (part 2) - Remove Pointer{Element,Property}() from JSONWriter. r=froydnj.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 02 Oct 2014 18:01:32 -0700
changeset 231720 1eb845ba1fc6328cd7c56b73d9948d6e227de271
parent 231719 7151ebc290753ea29fa7ba53988d22e0d11ae61d
child 231721 31b722e8e85d107b3c741d43301c1954fe2b8df1
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1074591
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 1074591 (part 2) - Remove Pointer{Element,Property}() from JSONWriter. r=froydnj.
mfbt/JSONWriter.h
mfbt/tests/TestJSONWriter.cpp
--- a/mfbt/JSONWriter.h
+++ b/mfbt/JSONWriter.h
@@ -46,23 +46,22 @@
 // following code:
 //
 //   JSONWriter w(MakeUnique<MyWriteFunc>());
 //   w.Start();
 //   {
 //     w.NullProperty("null");
 //     w.BoolProperty("bool", true);
 //     w.IntProperty("int", 1);
-//     w.StringProperty("string", "hello");
 //     w.StartArrayProperty("array");
 //     {
-//       w.DoubleElement(3.4);
+//       w.StringElement("string");
 //       w.StartObjectElement();
 //       {
-//         w.PointerProperty("ptr", (void*)0x12345678);
+//         w.DoubleProperty("double", 3.4);
 //         w.StartArrayProperty("single-line array", w.SingleLineStyle);
 //         {
 //           w.IntElement(1);
 //           w.StartObjectElement();  // SingleLineStyle is inherited from
 //           w.EndObjectElement();    //   above for this collection
 //         }
 //         w.EndArray();
 //       }
@@ -73,21 +72,20 @@
 //   w.End();
 //
 // will produce pretty-printed output for the following JSON object:
 //
 //  {
 //   "null": null,
 //   "bool": true,
 //   "int": 1,
-//   "string": "hello",
 //   "array": [
-//    3.4,
+//    "string",
 //    {
-//     "ptr": "0x12345678",
+//     "double": 3.4,
 //     "single-line array": [1, {}]
 //    }
 //   ]
 //  }
 //
 // The nesting in the example code is obviously optional, but can aid
 // readability.
 
@@ -417,29 +415,16 @@ public:
   {
     EscapedString escapedStr(aStr);
     QuotedScalar(aName, escapedStr.get());
   }
 
   // Prints: "<aStr>"
   void StringElement(const char* aStr) { StringProperty(nullptr, aStr); }
 
-  // Prints: "<aName>": "<aPtr>"
-  // The pointer is printed as a hexadecimal integer with a leading '0x'.
-  void PointerProperty(const char* aName, const void* aPtr)
-  {
-    char buf[32];
-    sprintf(buf, "0x%" PRIxPTR, uintptr_t(aPtr));
-    QuotedScalar(aName, buf);
-  }
-
-  // Prints: "<aPtr>"
-  // The pointer is printed as a hexadecimal integer with a leading '0x'.
-  void PointerElement(const void* aPtr) { PointerProperty(nullptr, aPtr); }
-
   // Prints: "<aName>": [
   void StartArrayProperty(const char* aName,
                           CollectionStyle aStyle = MultiLineStyle)
   {
     StartCollection(aName, "[", aStyle);
   }
 
   // Prints: [
--- a/mfbt/tests/TestJSONWriter.cpp
+++ b/mfbt/tests/TestJSONWriter.cpp
@@ -65,19 +65,16 @@ void TestBasicProperties()
  \"double1\": 1.2345,\n\
  \"double2\": -3,\n\
  \"double3\": 1e-7,\n\
  \"double4\": 1.1111111111111111e+21,\n\
  \"string1\": \"\",\n\
  \"string2\": \"1234\",\n\
  \"string3\": \"hello\",\n\
  \"string4\": \"\\\" \\\\ \\u0007 \\b \\t \\n \\u000b \\f \\r\",\n\
- \"ptr1\": \"0x0\",\n\
- \"ptr2\": \"0xdeadbeef\",\n\
- \"ptr3\": \"0xfacade\",\n\
  \"len 0 array, multi-line\": [\n\
  ],\n\
  \"len 0 array, single-line\": [],\n\
  \"len 1 array\": [\n\
   1\n\
  ],\n\
  \"len 5 array, multi-line\": [\n\
   1,\n\
@@ -122,20 +119,16 @@ void TestBasicProperties()
     w.DoubleProperty("double3", 1e-7);
     w.DoubleProperty("double4", 1.1111111111111111e+21);
 
     w.StringProperty("string1", "");
     w.StringProperty("string2", "1234");
     w.StringProperty("string3", "hello");
     w.StringProperty("string4", "\" \\ \a \b \t \n \v \f \r");
 
-    w.PointerProperty("ptr1", (void*)0x0);
-    w.PointerProperty("ptr2", (void*)0xdeadbeef);
-    w.PointerProperty("ptr3", (void*)0xFaCaDe);
-
     w.StartArrayProperty("len 0 array, multi-line", w.MultiLineStyle);
     w.EndArray();
 
     w.StartArrayProperty("len 0 array, single-line", w.SingleLineStyle);
     w.EndArray();
 
     w.StartArrayProperty("len 1 array");
     {
@@ -230,19 +223,16 @@ void TestBasicElements()
   1.2345,\n\
   -3,\n\
   1e-7,\n\
   1.1111111111111111e+21,\n\
   \"\",\n\
   \"1234\",\n\
   \"hello\",\n\
   \"\\\" \\\\ \\u0007 \\b \\t \\n \\u000b \\f \\r\",\n\
-  \"0x0\",\n\
-  \"0xdeadbeef\",\n\
-  \"0xfacade\",\n\
   [\n\
   ],\n\
   [],\n\
   [\n\
    1\n\
   ],\n\
   [\n\
    1,\n\
@@ -289,20 +279,16 @@ void TestBasicElements()
     w.DoubleElement(1e-7);
     w.DoubleElement(1.1111111111111111e+21);
 
     w.StringElement("");
     w.StringElement("1234");
     w.StringElement("hello");
     w.StringElement("\" \\ \a \b \t \n \v \f \r");
 
-    w.PointerElement((void*)0x0);
-    w.PointerElement((void*)0xdeadbeef);
-    w.PointerElement((void*)0xFaCaDe);
-
     w.StartArrayElement();
     w.EndArray();
 
     w.StartArrayElement(w.SingleLineStyle);
     w.EndArray();
 
     w.StartArrayElement();
     {
@@ -431,17 +417,17 @@ void TestStringEscaping()
   // problems for some compilers (see bug 1069726).
   const char* expected = "\
 {\n\
  \"ascii\": \"\x7F~}|{zyxwvutsrqponmlkjihgfedcba`_^]\\\\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#\\\"! \\u001f\\u001e\\u001d\\u001c\\u001b\\u001a\\u0019\\u0018\\u0017\\u0016\\u0015\\u0014\\u0013\\u0012\\u0011\\u0010\\u000f\\u000e\\r\\f\\u000b\\n\\t\\b\\u0007\\u0006\\u0005\\u0004\\u0003\\u0002\\u0001\",\n\
  \"\xD9\x85\xD8\xB1\xD8\xAD\xD8\xA8\xD8\xA7 \xD9\x87\xD9\x86\xD8\xA7\xD9\x83\": true,\n\
  \"\xD5\xA2\xD5\xA1\xD6\x80\xD5\xA5\xD6\x82 \xD5\xB9\xD5\xAF\xD5\xA1\": -123,\n\
  \"\xE4\xBD\xA0\xE5\xA5\xBD\": 1.234,\n\
  \"\xCE\xB3\xCE\xB5\xCE\xB9\xCE\xB1 \xCE\xB5\xCE\xBA\xCE\xB5\xCE\xAF\": \"\xD8\xB3\xD9\x84\xD8\xA7\xD9\x85\",\n\
- \"hall\xC3\xB3 \xC3\xBE" "arna\": \"0x1234\",\n\
+ \"hall\xC3\xB3 \xC3\xBE" "arna\": 4660,\n\
  \"\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF\": {\n\
   \"\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82\": [\n\
   ]\n\
  }\n\
 }\n\
 ";
 
   JSONWriter w(MakeUnique<StringWriteFunc>());
@@ -457,17 +443,17 @@ void TestStringEscaping()
     }
     w.StringProperty("ascii", buf);
 
     // Test lots of unicode stuff. Note that this file is encoded as UTF-8.
     w.BoolProperty("\xD9\x85\xD8\xB1\xD8\xAD\xD8\xA8\xD8\xA7 \xD9\x87\xD9\x86\xD8\xA7\xD9\x83", true);
     w.IntProperty("\xD5\xA2\xD5\xA1\xD6\x80\xD5\xA5\xD6\x82 \xD5\xB9\xD5\xAF\xD5\xA1", -123);
     w.DoubleProperty("\xE4\xBD\xA0\xE5\xA5\xBD", 1.234);
     w.StringProperty("\xCE\xB3\xCE\xB5\xCE\xB9\xCE\xB1 \xCE\xB5\xCE\xBA\xCE\xB5\xCE\xAF", "\xD8\xB3\xD9\x84\xD8\xA7\xD9\x85");
-    w.PointerProperty("hall\xC3\xB3 \xC3\xBE" "arna", (void*)0x1234);
+    w.IntProperty("hall\xC3\xB3 \xC3\xBE" "arna", 0x1234);
     w.StartObjectProperty("\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF");
     {
       w.StartArrayProperty("\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82");
       w.EndArray();
     }
     w.EndObject();
   }
   w.End();