Bug 904985 - Use Char16.h in favor of NS_LL, Part 3: kill NS_LL. r=dbaron
authorJoshua Cranmer <Pidgeot18@gmail.com>
Tue, 17 Sep 2013 22:43:21 -0500
changeset 147681 b0479039a28615cf897b618882b411f9f65e66a8
parent 147680 0a62484ff46bb8ed6d3bb173ab04bc46c62b659b
child 147682 ae31c55333b31259657f068d09e5596767f699bf
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdbaron
bugs904985
milestone27.0a1
Bug 904985 - Use Char16.h in favor of NS_LL, Part 3: kill NS_LL. r=dbaron
dom/base/nsJSEnvironment.cpp
xpcom/ds/nsStaticAtom.h
xpcom/glue/nsStringAPI.h
xpcom/string/public/nsLiteralString.h
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -2116,18 +2116,18 @@ nsJSContext::CycleCollectNow(nsICycleCol
     }
 
     nsCString gcMsg;
     if (ccResults.mForcedGC) {
       gcMsg.AssignLiteral(", forced a GC");
     }
 
     NS_NAMED_MULTILINE_LITERAL_STRING(kFmt,
-      NS_LL("CC(T+%.1f) duration: %lums, suspected: %lu, visited: %lu RCed and %lu%s GCed, collected: %lu RCed and %lu GCed (%lu|%lu waiting for GC)%s\n")
-      NS_LL("ForgetSkippable %lu times before CC, min: %lu ms, max: %lu ms, avg: %lu ms, total: %lu ms, sync: %lu ms, removed: %lu"));
+      MOZ_UTF16("CC(T+%.1f) duration: %lums, suspected: %lu, visited: %lu RCed and %lu%s GCed, collected: %lu RCed and %lu GCed (%lu|%lu waiting for GC)%s\n")
+      MOZ_UTF16("ForgetSkippable %lu times before CC, min: %lu ms, max: %lu ms, avg: %lu ms, total: %lu ms, sync: %lu ms, removed: %lu"));
     nsString msg;
     msg.Adopt(nsTextFormatter::smprintf(kFmt.get(), double(delta) / PR_USEC_PER_SEC,
                                         ccNowDuration, suspected,
                                         ccResults.mVisitedRefCounted, ccResults.mVisitedGCed, mergeMsg.get(),
                                         ccResults.mFreedRefCounted, ccResults.mFreedGCed,
                                         sCCollectedWaitingForGC, sLikelyShortLivingObjectsNeedingGC,
                                         gcMsg.get(),
                                         sForgetSkippableBeforeCC,
@@ -2141,38 +2141,38 @@ nsJSContext::CycleCollectNow(nsICycleCol
       do_GetService(NS_CONSOLESERVICE_CONTRACTID);
     if (cs) {
       cs->LogStringMessage(msg.get());
     }
   }
 
   if (sPostGCEventsToObserver) {
     NS_NAMED_MULTILINE_LITERAL_STRING(kJSONFmt,
-       NS_LL("{ \"timestamp\": %llu, ")
-         NS_LL("\"duration\": %llu, ")
-         NS_LL("\"finish_gc_duration\": %llu, ")
-         NS_LL("\"sync_skippable_duration\": %llu, ")
-         NS_LL("\"suspected\": %lu, ")
-         NS_LL("\"visited\": { ")
-             NS_LL("\"RCed\": %lu, ")
-             NS_LL("\"GCed\": %lu }, ")
-         NS_LL("\"collected\": { ")
-             NS_LL("\"RCed\": %lu, ")
-             NS_LL("\"GCed\": %lu }, ")
-         NS_LL("\"waiting_for_gc\": %lu, ")
-         NS_LL("\"short_living_objects_waiting_for_gc\": %lu, ")
-         NS_LL("\"forced_gc\": %d, ")
-         NS_LL("\"forget_skippable\": { ")
-             NS_LL("\"times_before_cc\": %lu, ")
-             NS_LL("\"min\": %lu, ")
-             NS_LL("\"max\": %lu, ")
-             NS_LL("\"avg\": %lu, ")
-             NS_LL("\"total\": %lu, ")
-             NS_LL("\"removed\": %lu } ")
-       NS_LL("}"));
+       MOZ_UTF16("{ \"timestamp\": %llu, ")
+         MOZ_UTF16("\"duration\": %llu, ")
+         MOZ_UTF16("\"finish_gc_duration\": %llu, ")
+         MOZ_UTF16("\"sync_skippable_duration\": %llu, ")
+         MOZ_UTF16("\"suspected\": %lu, ")
+         MOZ_UTF16("\"visited\": { ")
+             MOZ_UTF16("\"RCed\": %lu, ")
+             MOZ_UTF16("\"GCed\": %lu }, ")
+         MOZ_UTF16("\"collected\": { ")
+             MOZ_UTF16("\"RCed\": %lu, ")
+             MOZ_UTF16("\"GCed\": %lu }, ")
+         MOZ_UTF16("\"waiting_for_gc\": %lu, ")
+         MOZ_UTF16("\"short_living_objects_waiting_for_gc\": %lu, ")
+         MOZ_UTF16("\"forced_gc\": %d, ")
+         MOZ_UTF16("\"forget_skippable\": { ")
+             MOZ_UTF16("\"times_before_cc\": %lu, ")
+             MOZ_UTF16("\"min\": %lu, ")
+             MOZ_UTF16("\"max\": %lu, ")
+             MOZ_UTF16("\"avg\": %lu, ")
+             MOZ_UTF16("\"total\": %lu, ")
+             MOZ_UTF16("\"removed\": %lu } ")
+       MOZ_UTF16("}"));
     nsString json;
     json.Adopt(nsTextFormatter::smprintf(kJSONFmt.get(), endCCTime,
                                          ccNowDuration, gcDuration, skippableDuration,
                                          suspected,
                                          ccResults.mVisitedRefCounted, ccResults.mVisitedGCed,
                                          ccResults.mFreedRefCounted, ccResults.mFreedGCed,
                                          sCCollectedWaitingForGC,
                                          sLikelyShortLivingObjectsNeedingGC,
--- a/xpcom/ds/nsStaticAtom.h
+++ b/xpcom/ds/nsStaticAtom.h
@@ -8,17 +8,17 @@
 
 #include "nsIAtom.h"
 #include "nsStringBuffer.h"
 #include "prlog.h"
 
 typedef char16_t nsStaticAtomStringType;
 
 #define NS_STATIC_ATOM(buffer_name, atom_ptr)  { (nsStringBuffer*) &buffer_name, atom_ptr }
-#define NS_STATIC_ATOM_BUFFER(buffer_name, str_data) static nsFakeStringBuffer< sizeof(str_data) > buffer_name = { 1, sizeof(str_data) * sizeof(nsStaticAtomStringType), NS_L(str_data) };
+#define NS_STATIC_ATOM_BUFFER(buffer_name, str_data) static nsFakeStringBuffer< sizeof(str_data) > buffer_name = { 1, sizeof(str_data) * sizeof(nsStaticAtomStringType), MOZ_UTF16(str_data) };
 
 /**
  * Holds data used to initialize large number of atoms during startup. Use
  * the above macros to initialize these structs. They should never be accessed
  * directly other than from AtomTable.cpp
  */
 struct nsStaticAtom {
     nsStringBuffer* mStringBuffer;
--- a/xpcom/glue/nsStringAPI.h
+++ b/xpcom/glue/nsStringAPI.h
@@ -1073,39 +1073,27 @@ private:
 
 
 /**
  * literal strings
  */
 static_assert(sizeof(char16_t) == 2, "size of char16_t must be 2");
 static_assert(char16_t(-1) > char16_t(0), "char16_t must be unsigned");
 
-#define NS_LL(s) MOZ_UTF16(s)
 #define NS_MULTILINE_LITERAL_STRING(s)          nsDependentString(reinterpret_cast<const nsAString::char_type*>(s), uint32_t((sizeof(s)/2)-1))
 #define NS_MULTILINE_LITERAL_STRING_INIT(n,s)   n(reinterpret_cast<const nsAString::char_type*>(s), uint32_t((sizeof(s)/2)-1))
 #define NS_NAMED_MULTILINE_LITERAL_STRING(n,s)  const nsDependentString n(reinterpret_cast<const nsAString::char_type*>(s), uint32_t((sizeof(s)/2)-1))
 typedef nsDependentString nsLiteralString;
 
 /* Check that PRUnichar is unsigned */
 static_assert(PRUnichar(-1) > PRUnichar(0), "PRUnichar is by definition an unsigned type");
 
-/*
- * Macro arguments used in concatenation or stringification won't be expanded.
- * Therefore, in order for |NS_L(FOO)| to work as expected (which is to expand
- * |FOO| before doing whatever |NS_L| needs to do to it) a helper macro needs
- * to be inserted in between to allow the macro argument to expand.
- * See "3.10.6 Separate Expansion of Macro Arguments" of the CPP manual for a
- * more accurate and precise explanation.
- */
-
-#define NS_L(s)                                   NS_LL(s)
-
-#define NS_LITERAL_STRING(s)                      static_cast<const nsString&>(NS_MULTILINE_LITERAL_STRING(NS_LL(s)))
-#define NS_LITERAL_STRING_INIT(n,s)               NS_MULTILINE_LITERAL_STRING_INIT(n, NS_LL(s))
-#define NS_NAMED_LITERAL_STRING(n,s)              NS_NAMED_MULTILINE_LITERAL_STRING(n, NS_LL(s))
+#define NS_LITERAL_STRING(s)                      static_cast<const nsString&>(NS_MULTILINE_LITERAL_STRING(MOZ_UTF16(s)))
+#define NS_LITERAL_STRING_INIT(n,s)               NS_MULTILINE_LITERAL_STRING_INIT(n, MOZ_UTF16(s))
+#define NS_NAMED_LITERAL_STRING(n,s)              NS_NAMED_MULTILINE_LITERAL_STRING(n, MOZ_UTF16(s))
 
 #define NS_LITERAL_CSTRING(s)                     static_cast<const nsDependentCString&>(nsDependentCString(s, uint32_t(sizeof(s)-1)))
 #define NS_LITERAL_CSTRING_INIT(n,s)              n(s, uint32_t(sizeof(s)-1))
 #define NS_NAMED_LITERAL_CSTRING(n,s)             const nsDependentCString n(s, uint32_t(sizeof(s)-1))
 
 typedef nsDependentCString nsLiteralCString;
 
 
--- a/xpcom/string/public/nsLiteralString.h
+++ b/xpcom/string/public/nsLiteralString.h
@@ -32,36 +32,24 @@ template<int n>
 inline uint32_t LiteralWStringLength(const char16_t (&c)[n])
 {
   return n - 1;
 }
 
 } // namespace internal
 } // namespace mozilla
 
-#define NS_LL(s) MOZ_UTF16(s)
 #define NS_MULTILINE_LITERAL_STRING(s)          nsDependentString(reinterpret_cast<const nsAString::char_type*>(s), mozilla::internal::LiteralWStringLength(s))
 #define NS_MULTILINE_LITERAL_STRING_INIT(n,s)   n(reinterpret_cast<const nsAString::char_type*>(s), mozilla::internal::LiteralWStringLength(s))
 #define NS_NAMED_MULTILINE_LITERAL_STRING(n,s)  const nsDependentString n(reinterpret_cast<const nsAString::char_type*>(s), mozilla::internal::LiteralWStringLength(s))
 typedef nsDependentString nsLiteralString;
 
-/*
- * Macro arguments used in concatenation or stringification won't be expanded.
- * Therefore, in order for |NS_L(FOO)| to work as expected (which is to expand
- * |FOO| before doing whatever |NS_L| needs to do to it) a helper macro needs
- * to be inserted in between to allow the macro argument to expand.
- * See "3.10.6 Separate Expansion of Macro Arguments" of the CPP manual for a
- * more accurate and precise explanation.
- */
-
-#define NS_L(s)                                   NS_LL(s)
-
-#define NS_LITERAL_STRING(s)                      static_cast<const nsAFlatString&>(NS_MULTILINE_LITERAL_STRING(NS_LL(s)))
-#define NS_LITERAL_STRING_INIT(n,s)               NS_MULTILINE_LITERAL_STRING_INIT(n, NS_LL(s))
-#define NS_NAMED_LITERAL_STRING(n,s)              NS_NAMED_MULTILINE_LITERAL_STRING(n, NS_LL(s))
+#define NS_LITERAL_STRING(s)                      static_cast<const nsAFlatString&>(NS_MULTILINE_LITERAL_STRING(MOZ_UTF16(s)))
+#define NS_LITERAL_STRING_INIT(n,s)               NS_MULTILINE_LITERAL_STRING_INIT(n, MOZ_UTF16(s))
+#define NS_NAMED_LITERAL_STRING(n,s)              NS_NAMED_MULTILINE_LITERAL_STRING(n, MOZ_UTF16(s))
 
 #define NS_LITERAL_CSTRING(s)                     static_cast<const nsDependentCString&>(nsDependentCString(s, mozilla::internal::LiteralStringLength(s)))
 #define NS_LITERAL_CSTRING_INIT(n,s)              n(s, mozilla::internal::LiteralStringLength(s))
 #define NS_NAMED_LITERAL_CSTRING(n,s)             const nsDependentCString n(s, mozilla::internal::LiteralStringLength(s))
 
 typedef nsDependentCString nsLiteralCString;
 
 #endif /* !defined(nsLiteralString_h___) */