Title: [188040] trunk/Source/_javascript_Core
Revision
188040
Author
commit-qu...@webkit.org
Date
2015-08-06 09:24:38 -0700 (Thu, 06 Aug 2015)

Log Message

Remove UnspecifiedBoolType from JSC
https://bugs.webkit.org/show_bug.cgi?id=147597

Patch by Keith Miller <keith_mil...@apple.com> on 2015-08-06
Reviewed by Mark Lam.

We were using the safe bool pattern in the code base for implicit casting to booleans.
With C++11 this is no longer necessary and we can instead create an operator bool.

* API/JSRetainPtr.h:
(JSRetainPtr::operator bool):
(JSRetainPtr::operator UnspecifiedBoolType): Deleted.
* dfg/DFGEdge.h:
(JSC::DFG::Edge::operator bool):
(JSC::DFG::Edge::operator UnspecifiedBoolType*): Deleted.
* dfg/DFGIntegerRangeOptimizationPhase.cpp:
* heap/Weak.h:
* heap/WeakInlines.h:
(JSC::bool):
(JSC::UnspecifiedBoolType): Deleted.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSRetainPtr.h (188039 => 188040)


--- trunk/Source/_javascript_Core/API/JSRetainPtr.h	2015-08-06 12:31:45 UTC (rev 188039)
+++ trunk/Source/_javascript_Core/API/JSRetainPtr.h	2015-08-06 16:24:38 UTC (rev 188040)
@@ -57,11 +57,8 @@
     T operator->() const { return m_ptr; }
     
     bool operator!() const { return !m_ptr; }
+    explicit operator bool() const { return m_ptr; }
 
-    // This conversion operator allows implicit conversion to bool but not to other integer types.
-    typedef T JSRetainPtr::*UnspecifiedBoolType;
-    operator UnspecifiedBoolType() const { return m_ptr ? &JSRetainPtr::m_ptr : 0; }
-    
     JSRetainPtr& operator=(const JSRetainPtr&);
     template<typename U> JSRetainPtr& operator=(const JSRetainPtr<U>&);
     JSRetainPtr& operator=(T);

Modified: trunk/Source/_javascript_Core/ChangeLog (188039 => 188040)


--- trunk/Source/_javascript_Core/ChangeLog	2015-08-06 12:31:45 UTC (rev 188039)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-08-06 16:24:38 UTC (rev 188040)
@@ -1,3 +1,25 @@
+2015-08-06  Keith Miller  <keith_mil...@apple.com>
+
+        Remove UnspecifiedBoolType from JSC
+        https://bugs.webkit.org/show_bug.cgi?id=147597
+
+        Reviewed by Mark Lam.
+
+        We were using the safe bool pattern in the code base for implicit casting to booleans.
+        With C++11 this is no longer necessary and we can instead create an operator bool.
+
+        * API/JSRetainPtr.h:
+        (JSRetainPtr::operator bool):
+        (JSRetainPtr::operator UnspecifiedBoolType): Deleted.
+        * dfg/DFGEdge.h:
+        (JSC::DFG::Edge::operator bool):
+        (JSC::DFG::Edge::operator UnspecifiedBoolType*): Deleted.
+        * dfg/DFGIntegerRangeOptimizationPhase.cpp:
+        * heap/Weak.h:
+        * heap/WeakInlines.h:
+        (JSC::bool):
+        (JSC::UnspecifiedBoolType): Deleted.
+
 2015-08-05  Ryosuke Niwa  <rn...@webkit.org>
 
         [ES6] Class parser does not allow methods named set and get.

Modified: trunk/Source/_javascript_Core/dfg/DFGEdge.h (188039 => 188040)


--- trunk/Source/_javascript_Core/dfg/DFGEdge.h	2015-08-06 12:31:45 UTC (rev 188039)
+++ trunk/Source/_javascript_Core/dfg/DFGEdge.h	2015-08-06 16:24:38 UTC (rev 188040)
@@ -158,11 +158,9 @@
 #endif
         return result;
     }
-    
-    typedef void* Edge::*UnspecifiedBoolType;
-    operator UnspecifiedBoolType*() const { return reinterpret_cast<UnspecifiedBoolType*>(isSet()); }
-    
+
     bool operator!() const { return !isSet(); }
+    explicit operator bool() const { return isSet(); }
     
     bool operator==(Edge other) const
     {

Modified: trunk/Source/_javascript_Core/dfg/DFGIntegerRangeOptimizationPhase.cpp (188039 => 188040)


--- trunk/Source/_javascript_Core/dfg/DFGIntegerRangeOptimizationPhase.cpp	2015-08-06 12:31:45 UTC (rev 188039)
+++ trunk/Source/_javascript_Core/dfg/DFGIntegerRangeOptimizationPhase.cpp	2015-08-06 16:24:38 UTC (rev 188040)
@@ -111,8 +111,6 @@
             return Relationship();
         return Relationship(left, right, kind, offset);
     }
-    
-    typedef void* (Relationship::*UnspecifiedBoolType);
 
     explicit operator bool() const { return m_left; }
     

Modified: trunk/Source/_javascript_Core/heap/Weak.h (188039 => 188040)


--- trunk/Source/_javascript_Core/heap/Weak.h	2015-08-06 12:31:45 UTC (rev 188039)
+++ trunk/Source/_javascript_Core/heap/Weak.h	2015-08-06 16:24:38 UTC (rev 188040)
@@ -75,9 +75,7 @@
 
     bool was(T*) const;
 
-    // This conversion operator allows implicit conversion to bool but not to other integer types.
-    typedef void* (Weak::*UnspecifiedBoolType);
-    operator UnspecifiedBoolType*() const;
+    explicit operator bool() const;
 
     WeakImpl* leakImpl() WARN_UNUSED_RETURN;
     void clear()

Modified: trunk/Source/_javascript_Core/heap/WeakInlines.h (188039 => 188040)


--- trunk/Source/_javascript_Core/heap/WeakInlines.h	2015-08-06 12:31:45 UTC (rev 188039)
+++ trunk/Source/_javascript_Core/heap/WeakInlines.h	2015-08-06 16:24:38 UTC (rev 188040)
@@ -99,9 +99,9 @@
     return !m_impl || !m_impl->jsValue() || m_impl->state() != WeakImpl::Live;
 }
 
-template<typename T> inline Weak<T>::operator UnspecifiedBoolType*() const
+template<typename T> inline Weak<T>::operator bool() const
 {
-    return reinterpret_cast<UnspecifiedBoolType*>(!!*this);
+    return !!*this;
 }
 
 template<typename T> inline WeakImpl* Weak<T>::leakImpl()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to