Title: [284167] trunk/Source
Revision
284167
Author
ysuz...@apple.com
Date
2021-10-14 09:39:37 -0700 (Thu, 14 Oct 2021)

Log Message

Remove std::iterator usage
https://bugs.webkit.org/show_bug.cgi?id=231728

Reviewed by Keith Miller.

Source/WebCore:

* dom/ElementIterator.h:
* dom/SimpleRange.h:
* platform/Timer.cpp:
(WebCore::TimerBase::heapDecreaseKey):
(WebCore::TimerBase::heapPopMin):
(WebCore::TimerBase::heapDeleteNullMin):

Source/WTF:

std::iterator<> is deprecated and defining 5 type aliases is encouraged[1].
With new clang, using std::iterator<> causes compile error because of deprecation warnings.
This patch removes std::iterator usage.

[1]: https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/

* wtf/HashIterators.h:
(WTF:: const const): Deleted.
* wtf/HashTable.h:
* wtf/WeakHashMap.h:
* wtf/WeakHashSet.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (284166 => 284167)


--- trunk/Source/WTF/ChangeLog	2021-10-14 16:38:59 UTC (rev 284166)
+++ trunk/Source/WTF/ChangeLog	2021-10-14 16:39:37 UTC (rev 284167)
@@ -1,3 +1,22 @@
+2021-10-14  Yusuke Suzuki  <ysuz...@apple.com>
+
+        Remove std::iterator usage
+        https://bugs.webkit.org/show_bug.cgi?id=231728
+
+        Reviewed by Keith Miller.
+
+        std::iterator<> is deprecated and defining 5 type aliases is encouraged[1].
+        With new clang, using std::iterator<> causes compile error because of deprecation warnings.
+        This patch removes std::iterator usage.
+
+        [1]: https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/
+
+        * wtf/HashIterators.h:
+        (WTF:: const const): Deleted.
+        * wtf/HashTable.h:
+        * wtf/WeakHashMap.h:
+        * wtf/WeakHashSet.h:
+
 2021-10-14  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK][WPE] Move getCurrentExecutablePath() and getCurrentExecutableName() to FileSystem

Modified: trunk/Source/WTF/wtf/HashIterators.h (284166 => 284167)


--- trunk/Source/WTF/wtf/HashIterators.h	2021-10-14 16:38:59 UTC (rev 284166)
+++ trunk/Source/WTF/wtf/HashIterators.h	2021-10-14 16:39:37 UTC (rev 284167)
@@ -40,7 +40,14 @@
     template<typename HashTableType, typename ValueType> struct HashTableConstIteratorAdapter;
     template<typename HashTableType, typename ValueType> struct HashTableIteratorAdapter;
 
-    template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType>> : public std::iterator<std::forward_iterator_tag, KeyValuePair<KeyType, MappedType>, std::ptrdiff_t, const KeyValuePair<KeyType, MappedType>*, const KeyValuePair<KeyType, MappedType>&> {
+    template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType>> {
+    public:
+        using iterator_category = std::forward_iterator_tag;
+        using value_type = KeyValuePair<KeyType, MappedType>;
+        using difference_type = ptrdiff_t;
+        using pointer = const value_type*;
+        using reference = const value_type&;
+
     private:
         typedef KeyValuePair<KeyType, MappedType> ValueType;
     public:
@@ -63,7 +70,14 @@
         typename HashTableType::const_iterator m_impl;
     };
 
-    template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType>> : public std::iterator<std::forward_iterator_tag, KeyValuePair<KeyType, MappedType>, std::ptrdiff_t, KeyValuePair<KeyType, MappedType>*, KeyValuePair<KeyType, MappedType>&> {
+    template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType>> {
+    public:
+        using iterator_category = std::forward_iterator_tag;
+        using value_type = KeyValuePair<KeyType, MappedType>;
+        using difference_type = ptrdiff_t;
+        using pointer = value_type*;
+        using reference = value_type&;
+
     private:
         typedef KeyValuePair<KeyType, MappedType> ValueType;
     public:
@@ -91,7 +105,14 @@
         typename HashTableType::iterator m_impl;
     };
 
-    template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstKeysIterator : public std::iterator<std::forward_iterator_tag, KeyType, std::ptrdiff_t, const KeyType*, const KeyType&> {
+    template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstKeysIterator {
+    public:
+        using iterator_category = std::forward_iterator_tag;
+        using value_type = KeyType;
+        using difference_type = ptrdiff_t;
+        using pointer = const value_type*;
+        using reference = const value_type&;
+
     private:
         typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType>> ConstIterator;
 
@@ -108,7 +129,14 @@
         ConstIterator m_impl;
     };
 
-    template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstValuesIterator : public std::iterator<std::forward_iterator_tag, MappedType, std::ptrdiff_t, const MappedType*, const MappedType&> {
+    template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstValuesIterator {
+    public:
+        using iterator_category = std::forward_iterator_tag;
+        using value_type = MappedType;
+        using difference_type = ptrdiff_t;
+        using pointer = const value_type*;
+        using reference = const value_type&;
+
     private:
         typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType>> ConstIterator;
 
@@ -125,7 +153,14 @@
         ConstIterator m_impl;
     };
 
-    template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableKeysIterator : public std::iterator<std::forward_iterator_tag, KeyType, std::ptrdiff_t, KeyType*, KeyType&> {
+    template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableKeysIterator {
+    public:
+        using iterator_category = std::forward_iterator_tag;
+        using value_type = KeyType;
+        using difference_type = ptrdiff_t;
+        using pointer = value_type*;
+        using reference = value_type&;
+
     private:
         typedef HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType>> Iterator;
         typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType>> ConstIterator;
@@ -148,7 +183,14 @@
         Iterator m_impl;
     };
 
-    template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableValuesIterator : public std::iterator<std::forward_iterator_tag, MappedType, std::ptrdiff_t, MappedType*, MappedType&> {
+    template<typename HashTableType, typename KeyType, typename MappedType> struct HashTableValuesIterator {
+    public:
+        using iterator_category = std::forward_iterator_tag;
+        using value_type = MappedType;
+        using difference_type = ptrdiff_t;
+        using pointer = value_type*;
+        using reference = value_type&;
+
     private:
         typedef HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType>> Iterator;
         typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType>> ConstIterator;

Modified: trunk/Source/WTF/wtf/HashTable.h (284166 => 284167)


--- trunk/Source/WTF/wtf/HashTable.h	2021-10-14 16:38:59 UTC (rev 284166)
+++ trunk/Source/WTF/wtf/HashTable.h	2021-10-14 16:39:37 UTC (rev 284167)
@@ -109,8 +109,15 @@
     typedef enum { HashItemKnownGood } HashItemKnownGoodTag;
 
     template<typename HashTable, typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
-    class HashTableConstIterator : public std::iterator<std::forward_iterator_tag, Value, std::ptrdiff_t, const Value*, const Value&> {
+    class HashTableConstIterator {
         WTF_MAKE_FAST_ALLOCATED;
+    public:
+        using iterator_category = std::forward_iterator_tag;
+        using value_type = Value;
+        using difference_type = ptrdiff_t;
+        using pointer = const value_type*;
+        using reference = const value_type&;
+
     private:
         using HashTableType = HashTable;
         typedef HashTableIterator<HashTableType, Key, Value, Extractor, HashFunctions, Traits, KeyTraits> iterator;
@@ -246,8 +253,15 @@
     };
 
     template<typename HashTable, typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
-    class HashTableIterator : public std::iterator<std::forward_iterator_tag, Value, std::ptrdiff_t, Value*, Value&> {
+    class HashTableIterator {
         WTF_MAKE_FAST_ALLOCATED;
+    public:
+        using iterator_category = std::forward_iterator_tag;
+        using value_type = Value;
+        using difference_type = ptrdiff_t;
+        using pointer = value_type*;
+        using reference = value_type&;
+
     private:
         using HashTableType = HashTable;
         typedef HashTableIterator<HashTableType, Key, Value, Extractor, HashFunctions, Traits, KeyTraits> iterator;
@@ -1566,7 +1580,13 @@
 
     // iterator adapters
 
-    template<typename HashTableType, typename ValueType> struct HashTableConstIteratorAdapter : public std::iterator<std::forward_iterator_tag, ValueType, std::ptrdiff_t, const ValueType*, const ValueType&> {
+    template<typename HashTableType, typename ValueType> struct HashTableConstIteratorAdapter {
+        using iterator_category = std::forward_iterator_tag;
+        using value_type = ValueType;
+        using difference_type = ptrdiff_t;
+        using pointer = const value_type*;
+        using reference = const value_type&;
+
         HashTableConstIteratorAdapter() {}
         HashTableConstIteratorAdapter(const typename HashTableType::const_iterator& impl) : m_impl(impl) {}
 
@@ -1580,7 +1600,13 @@
         typename HashTableType::const_iterator m_impl;
     };
 
-    template<typename HashTableType, typename ValueType> struct HashTableIteratorAdapter : public std::iterator<std::forward_iterator_tag, ValueType, std::ptrdiff_t, ValueType*, ValueType&> {
+    template<typename HashTableType, typename ValueType> struct HashTableIteratorAdapter {
+        using iterator_category = std::forward_iterator_tag;
+        using value_type = ValueType;
+        using difference_type = ptrdiff_t;
+        using pointer = value_type*;
+        using reference = value_type&;
+
         HashTableIteratorAdapter() {}
         HashTableIteratorAdapter(const typename HashTableType::iterator& impl) : m_impl(impl) {}
 

Modified: trunk/Source/WTF/wtf/WeakHashMap.h (284166 => 284167)


--- trunk/Source/WTF/wtf/WeakHashMap.h	2021-10-14 16:38:59 UTC (rev 284166)
+++ trunk/Source/WTF/wtf/WeakHashMap.h	2021-10-14 16:39:37 UTC (rev 284167)
@@ -72,7 +72,14 @@
     };
 
     template <typename MapType, typename IteratorType, typename IteratorPeekPtrType, typename IteratorPeekType>
-    class WeakHashMapIteratorBase : public std::iterator<std::forward_iterator_tag, IteratorPeekType, std::ptrdiff_t, IteratorPeekPtrType, IteratorPeekType> {
+    class WeakHashMapIteratorBase {
+    public:
+        using iterator_category = std::forward_iterator_tag;
+        using value_type = IteratorPeekType;
+        using difference_type = ptrdiff_t;
+        using pointer = IteratorPeekPtrType;
+        using reference = IteratorPeekType;
+
     protected:
         WeakHashMapIteratorBase(MapType& weakHashMap, IteratorType position)
             : m_weakHashMap { weakHashMap }

Modified: trunk/Source/WTF/wtf/WeakHashSet.h (284166 => 284167)


--- trunk/Source/WTF/wtf/WeakHashSet.h	2021-10-14 16:38:59 UTC (rev 284166)
+++ trunk/Source/WTF/wtf/WeakHashSet.h	2021-10-14 16:39:37 UTC (rev 284167)
@@ -38,7 +38,14 @@
     typedef HashSet<Ref<WeakPtrImpl<Counter>>> WeakPtrImplSet;
     typedef typename WeakPtrImplSet::AddResult AddResult;
 
-    class WeakHashSetConstIterator : public std::iterator<std::forward_iterator_tag, T, std::ptrdiff_t, const T*, const T&> {
+    class WeakHashSetConstIterator {
+    public:
+        using iterator_category = std::forward_iterator_tag;
+        using value_type = T;
+        using difference_type = ptrdiff_t;
+        using pointer = const value_type*;
+        using reference = const value_type&;
+
     private:
         WeakHashSetConstIterator(const WeakPtrImplSet& set, typename WeakPtrImplSet::const_iterator position)
             : m_position(position), m_endPosition(set.end())

Modified: trunk/Source/WebCore/ChangeLog (284166 => 284167)


--- trunk/Source/WebCore/ChangeLog	2021-10-14 16:38:59 UTC (rev 284166)
+++ trunk/Source/WebCore/ChangeLog	2021-10-14 16:39:37 UTC (rev 284167)
@@ -1,3 +1,17 @@
+2021-10-14  Yusuke Suzuki  <ysuz...@apple.com>
+
+        Remove std::iterator usage
+        https://bugs.webkit.org/show_bug.cgi?id=231728
+
+        Reviewed by Keith Miller.
+
+        * dom/ElementIterator.h:
+        * dom/SimpleRange.h:
+        * platform/Timer.cpp:
+        (WebCore::TimerBase::heapDecreaseKey):
+        (WebCore::TimerBase::heapPopMin):
+        (WebCore::TimerBase::heapDeleteNullMin):
+
 2021-10-14  Simon Fraser  <simon.fra...@apple.com>
 
         Move KeyboardScroll into platform code

Modified: trunk/Source/WebCore/dom/ElementIterator.h (284166 => 284167)


--- trunk/Source/WebCore/dom/ElementIterator.h	2021-10-14 16:38:59 UTC (rev 284166)
+++ trunk/Source/WebCore/dom/ElementIterator.h	2021-10-14 16:39:37 UTC (rev 284167)
@@ -35,8 +35,14 @@
 namespace WebCore {
 
 template <typename ElementType>
-class ElementIterator : public std::iterator<std::forward_iterator_tag, ElementType> {
+class ElementIterator {
 public:
+    using iterator_category = std::forward_iterator_tag;
+    using value_type = ElementType;
+    using difference_type = ptrdiff_t;
+    using pointer = value_type*;
+    using reference = value_type&;
+
     ElementIterator() = default;
 
     ElementType& operator*() const;

Modified: trunk/Source/WebCore/dom/SimpleRange.h (284166 => 284167)


--- trunk/Source/WebCore/dom/SimpleRange.h	2021-10-14 16:38:59 UTC (rev 284166)
+++ trunk/Source/WebCore/dom/SimpleRange.h	2021-10-14 16:39:37 UTC (rev 284167)
@@ -105,8 +105,14 @@
 
 // FIXME: End of functions that are deprecated since they silently default to ComposedTree.
 
-class IntersectingNodeIterator : public std::iterator<std::forward_iterator_tag, Node> {
+class IntersectingNodeIterator {
 public:
+    using iterator_category = std::forward_iterator_tag;
+    using value_type = Node;
+    using difference_type = ptrdiff_t;
+    using pointer = value_type*;
+    using reference = value_type&;
+
     IntersectingNodeIterator(const SimpleRange&);
 
     enum QuirkFlag { DeprecatedZeroOffsetStartQuirk };

Modified: trunk/Source/WebCore/platform/Timer.cpp (284166 => 284167)


--- trunk/Source/WebCore/platform/Timer.cpp	2021-10-14 16:38:59 UTC (rev 284166)
+++ trunk/Source/WebCore/platform/Timer.cpp	2021-10-14 16:39:37 UTC (rev 284167)
@@ -151,8 +151,14 @@
 
 // Class to represent iterators in the heap when calling the standard library heap algorithms.
 // Uses a custom pointer and reference type that update indices for pointers in the heap.
-class TimerHeapIterator : public std::iterator<std::random_access_iterator_tag, RefPtr<ThreadTimerHeapItem>, ptrdiff_t, TimerHeapPointer, TimerHeapReference> {
+class TimerHeapIterator {
 public:
+    using iterator_category = std::random_access_iterator_tag;
+    using value_type = RefPtr<ThreadTimerHeapItem>;
+    using difference_type = ptrdiff_t;
+    using pointer = TimerHeapPointer;
+    using reference = TimerHeapReference;
+
     explicit TimerHeapIterator(RefPtr<ThreadTimerHeapItem>* pointer) : m_pointer(pointer) { checkConsistency(); }
 
     TimerHeapIterator& operator++() { checkConsistency(); ++m_pointer; checkConsistency(); return *this; }
@@ -327,7 +333,7 @@
     ASSERT(m_heapItem);
     checkHeapIndex();
     auto* heapData = m_heapItem->timerHeap().data();
-    push_heap(TimerHeapIterator(heapData), TimerHeapIterator(heapData + m_heapItem->heapIndex() + 1), TimerHeapLessThanFunction());
+    std::push_heap(TimerHeapIterator(heapData), TimerHeapIterator(heapData + m_heapItem->heapIndex() + 1), TimerHeapLessThanFunction());
     checkHeapIndex();
 }
 
@@ -381,7 +387,7 @@
     checkHeapIndex();
     auto& heap = m_heapItem->timerHeap();
     auto* heapData = heap.data();
-    pop_heap(TimerHeapIterator(heapData), TimerHeapIterator(heapData + heap.size()), TimerHeapLessThanFunction());
+    std::pop_heap(TimerHeapIterator(heapData), TimerHeapIterator(heapData + heap.size()), TimerHeapLessThanFunction());
     checkHeapIndex();
     ASSERT(m_heapItem == m_heapItem->timerHeap().last());
 }
@@ -391,7 +397,7 @@
     RELEASE_ASSERT(!heap.first()->hasTimer());
     heap.first()->time = -MonotonicTime::infinity();
     auto* heapData = heap.data();
-    pop_heap(TimerHeapIterator(heapData), TimerHeapIterator(heapData + heap.size()), TimerHeapLessThanFunction());
+    std::pop_heap(TimerHeapIterator(heapData), TimerHeapIterator(heapData + heap.size()), TimerHeapLessThanFunction());
     heap.removeLast();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to