Bug 341287. Expand __LINE__ before pasting. r=jlebar
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Mon, 30 Jan 2012 15:28:49 -0500
changeset 85962 006eebde12590c48f92dfc6e76bb0d075e1e0617
parent 85961 77b586e22cb6e44b0181b720d5b936ab56a17678
child 85963 0af1cb4ae8f3cff7e3f0972743ae641f708cf75c
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjlebar
bugs341287
milestone13.0a1
Bug 341287. Expand __LINE__ before pasting. r=jlebar Currently, the code is just append '__LINE__' to the variable instead of the actual line number. This fixes that by expanding the __LINE__ identifier before pasting it.
image/public/ImageLogging.h
--- a/image/public/ImageLogging.h
+++ b/image/public/ImageLogging.h
@@ -179,26 +179,30 @@ public:
   {
     PR_LOG(aLog, PR_LOG_DEBUG, ("%d [this=%p] %s -- %s\n",
                                 GIVE_ME_MS_NOW(), from,
                                 fn.get(),
                                 msg.get()));
   }
 };
 
+#define LOG_SCOPE_APPEND_LINE_NUMBER_PASTE(id, line) id ## line
+#define LOG_SCOPE_APPEND_LINE_NUMBER_EXPAND(id, line) LOG_SCOPE_APPEND_LINE_NUMBER_PASTE(id, line)
+#define LOG_SCOPE_APPEND_LINE_NUMBER(id) LOG_SCOPE_APPEND_LINE_NUMBER_EXPAND(id, __LINE__)
+
 #define LOG_SCOPE(l, s) \
-  LogScope LOG_SCOPE_TMP_VAR ##__LINE__ (l,                            \
-                                         static_cast<void *>(this),    \
-                                         NS_LITERAL_CSTRING(s))
+  LogScope LOG_SCOPE_APPEND_LINE_NUMBER(LOG_SCOPE_TMP_VAR) (l,                            \
+                                                            static_cast<void *>(this),    \
+                                                            NS_LITERAL_CSTRING(s))
 
 #define LOG_SCOPE_WITH_PARAM(l, s, pn, pv) \
-  LogScope LOG_SCOPE_TMP_VAR ##__LINE__ (l,                            \
-                                         static_cast<void *>(this),    \
-                                         NS_LITERAL_CSTRING(s),        \
-                                         NS_LITERAL_CSTRING(pn), pv)
+  LogScope LOG_SCOPE_APPEND_LINE_NUMBER(LOG_SCOPE_TMP_VAR) (l,                            \
+                                                            static_cast<void *>(this),    \
+                                                            NS_LITERAL_CSTRING(s),        \
+                                                            NS_LITERAL_CSTRING(pn), pv)
 
 #define LOG_FUNC(l, s)                  \
   LogFunc(l,                            \
           static_cast<void *>(this),    \
           NS_LITERAL_CSTRING(s))
 
 #define LOG_FUNC_WITH_PARAM(l, s, pn, pv) \
   LogFunc(l,                              \