Created a bool pretty printer at WTF for debugging purposes
authorcalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Jul 2017 09:14:58 +0000 (09:14 +0000)
committercalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Jul 2017 09:14:58 +0000 (09:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174893

Reviewed by Darin Adler.

Source/WebCore:

Use WTF::boolPrettyPrinter in debugging messages.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::supportsKeySystem):
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::seek):

Source/WTF:

* wtf/PrintStream.cpp:
(WTF::printInternal): The overload taking bool uses boolForPrinting
* wtf/PrintStream.h:
(WTF::boolForPrinting): Converts a bool in "true" or "false".

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220058 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/PrintStream.cpp
Source/WTF/wtf/PrintStream.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp

index 38cc1e0..56a7b40 100644 (file)
@@ -1,3 +1,15 @@
+2017-07-31  Xabier Rodriguez Calvar  <calvaris@igalia.com>
+
+        Created a bool pretty printer at WTF for debugging purposes
+        https://bugs.webkit.org/show_bug.cgi?id=174893
+
+        Reviewed by Darin Adler.
+
+        * wtf/PrintStream.cpp:
+        (WTF::printInternal): The overload taking bool uses boolForPrinting
+        * wtf/PrintStream.h:
+        (WTF::boolForPrinting): Converts a bool in "true" or "false".
+
 2017-07-30  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [WTF] Introduce Private Symbols
index 97faf30..9e11c99 100644 (file)
@@ -108,10 +108,7 @@ void printInternal(PrintStream& out, const StringImpl* string)
 
 void printInternal(PrintStream& out, bool value)
 {
-    if (value)
-        out.print("true");
-    else
-        out.print("false");
+    out.print(boolForPrinting(value));
 }
 
 void printInternal(PrintStream& out, int value)
index 6a8060b..5b3913c 100644 (file)
@@ -44,6 +44,11 @@ class StringImpl;
 class StringView;
 class UniquedStringImpl;
 
+inline const char* boolForPrinting(bool value)
+{
+    return value ? "true" : "false";
+}
+
 class PrintStream {
     WTF_MAKE_FAST_ALLOCATED; WTF_MAKE_NONCOPYABLE(PrintStream);
 public:
@@ -337,6 +342,7 @@ void printInternal(PrintStream& out, const std::optional<T>& value)
 
 } // namespace WTF
 
+using WTF::boolForPrinting;
 using WTF::CharacterDump;
 using WTF::PointerDump;
 using WTF::PrintStream;
index a68a983..f62f057 100644 (file)
@@ -1,3 +1,17 @@
+2017-07-31  Xabier Rodriguez Calvar  <calvaris@igalia.com>
+
+        Created a bool pretty printer at WTF for debugging purposes
+        https://bugs.webkit.org/show_bug.cgi?id=174893
+
+        Reviewed by Darin Adler.
+
+        Use WTF::boolPrettyPrinter in debugging messages.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::supportsKeySystem):
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerMSE::seek):
+
 2017-07-30  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed. Suppress the -Wextra compiler warning when building with GCC 6.3.0,
index 9063ae3..96b5420 100644 (file)
@@ -1040,7 +1040,7 @@ bool MediaPlayerPrivateGStreamerBase::supportsKeySystem(const String& keySystem,
         result = true;
 #endif
 
-    GST_DEBUG("checking for KeySystem support with %s and type %s: %s", keySystem.utf8().data(), mimeType.utf8().data(), result ? "true" : "false");
+    GST_DEBUG("checking for KeySystem support with %s and type %s: %s", keySystem.utf8().data(), mimeType.utf8().data(), boolForPrinting(result));
     return result;
 }
 
index 2416058..0246700 100644 (file)
@@ -197,7 +197,7 @@ void MediaPlayerPrivateGStreamerMSE::seek(float time)
     }
 
     m_isEndReached = false;
-    GST_DEBUG("m_seeking=%s, m_seekTime=%f", m_seeking ? "true" : "false", m_seekTime);
+    GST_DEBUG("m_seeking=%s, m_seekTime=%f", boolForPrinting(m_seeking), m_seekTime);
 }
 
 void MediaPlayerPrivateGStreamerMSE::configurePlaySink()