OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef Iterable_h | 5 #ifndef Iterable_h |
6 #define Iterable_h | 6 #define Iterable_h |
7 | 7 |
8 #include "bindings/core/v8/V8IteratorResultValue.h" | 8 #include "bindings/core/v8/V8IteratorResultValue.h" |
9 #include "core/dom/Iterator.h" | 9 #include "core/dom/Iterator.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 // Typically, use one of ValueIterable<> and PairIterable<> (below) instead! | 13 // Typically, use one of ValueIterable<> and PairIterable<> (below) instead! |
14 template <typename KeyType, typename ValueType> | 14 template <typename KeyType, typename ValueType> |
15 class Iterable { | 15 class Iterable { |
16 public: | 16 public: |
17 virtual ~Iterable() { } | |
18 | |
19 Iterator* keys(ScriptState* scriptState, ExceptionState& exceptionState) | 17 Iterator* keys(ScriptState* scriptState, ExceptionState& exceptionState) |
20 { | 18 { |
21 IterationSource* source = this->startIteration(scriptState, exceptionSta
te); | 19 IterationSource* source = this->startIteration(scriptState, exceptionSta
te); |
22 if (!source) | 20 if (!source) |
23 return nullptr; | 21 return nullptr; |
24 return new IterableIterator<KeySelector>(source); | 22 return new IterableIterator<KeySelector>(source); |
25 } | 23 } |
26 | 24 |
27 Iterator* values(ScriptState* scriptState, ExceptionState& exceptionState) | 25 Iterator* values(ScriptState* scriptState, ExceptionState& exceptionState) |
28 { | 26 { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 public: | 156 public: |
159 Iterator* iterator(ScriptState* scriptState, ExceptionState& exceptionState) | 157 Iterator* iterator(ScriptState* scriptState, ExceptionState& exceptionState) |
160 { | 158 { |
161 return this->entries(scriptState, exceptionState); | 159 return this->entries(scriptState, exceptionState); |
162 } | 160 } |
163 }; | 161 }; |
164 | 162 |
165 } // namespace blink | 163 } // namespace blink |
166 | 164 |
167 #endif // Iterable_h | 165 #endif // Iterable_h |
OLD | NEW |