OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 Member_h | 5 #ifndef Member_h |
6 #define Member_h | 6 #define Member_h |
7 | 7 |
8 #include "wtf/Allocator.h" | 8 #include "wtf/Allocator.h" |
9 #include "wtf/HashFunctions.h" | 9 #include "wtf/HashFunctions.h" |
10 | 10 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 { | 265 { |
266 this->m_raw = nullptr; | 266 this->m_raw = nullptr; |
267 return *this; | 267 return *this; |
268 } | 268 } |
269 }; | 269 }; |
270 | 270 |
271 } // namespace blink | 271 } // namespace blink |
272 | 272 |
273 namespace WTF { | 273 namespace WTF { |
274 | 274 |
| 275 // PtrHash is the default hash for hash tables with Member<>-derived elements. |
275 template <typename T> | 276 template <typename T> |
276 struct MemberHash : PtrHash<T> { | 277 struct MemberHash : PtrHash<T> { |
277 STATIC_ONLY(MemberHash); | 278 STATIC_ONLY(MemberHash); |
278 template <typename U> | 279 template <typename U> |
279 static unsigned hash(const U& key) { return PtrHash<T>::hash(key); } | 280 static unsigned hash(const U& key) { return PtrHash<T>::hash(key); } |
280 template <typename U, typename V> | 281 template <typename U, typename V> |
281 static bool equal(const U& a, const V& b) { return a == b; } | 282 static bool equal(const U& a, const V& b) { return a == b; } |
282 }; | 283 }; |
283 | 284 |
284 template <typename T> | 285 template <typename T> |
285 struct WeakMemberHash : MemberHash<T> { | |
286 STATIC_ONLY(WeakMemberHash); | |
287 }; | |
288 | |
289 template <typename T> | |
290 struct UntracedMemberHash : MemberHash<T> { | |
291 STATIC_ONLY(UntracedMemberHash); | |
292 }; | |
293 | |
294 // PtrHash is the default hash for hash tables with members. | |
295 template <typename T> | |
296 struct DefaultHash<blink::Member<T>> { | 286 struct DefaultHash<blink::Member<T>> { |
297 STATIC_ONLY(DefaultHash); | 287 STATIC_ONLY(DefaultHash); |
298 using Hash = MemberHash<T>; | 288 using Hash = MemberHash<T>; |
299 }; | 289 }; |
300 | 290 |
301 template <typename T> | 291 template <typename T> |
302 struct DefaultHash<blink::WeakMember<T>> { | 292 struct DefaultHash<blink::WeakMember<T>> { |
303 STATIC_ONLY(DefaultHash); | 293 STATIC_ONLY(DefaultHash); |
304 using Hash = WeakMemberHash<T>; | 294 using Hash = MemberHash<T>; |
305 }; | 295 }; |
306 | 296 |
307 template <typename T> | 297 template <typename T> |
308 struct DefaultHash<blink::UntracedMember<T>> { | 298 struct DefaultHash<blink::UntracedMember<T>> { |
309 STATIC_ONLY(DefaultHash); | 299 STATIC_ONLY(DefaultHash); |
310 using Hash = UntracedMemberHash<T>; | 300 using Hash = MemberHash<T>; |
311 }; | 301 }; |
312 | 302 |
313 template<typename T> | 303 template<typename T> |
314 struct IsTraceable<blink::Member<T>> { | 304 struct IsTraceable<blink::Member<T>> { |
315 STATIC_ONLY(IsTraceable); | 305 STATIC_ONLY(IsTraceable); |
316 static const bool value = true; | 306 static const bool value = true; |
317 }; | 307 }; |
318 | 308 |
319 template<typename T> | 309 template<typename T> |
320 struct IsWeak<blink::WeakMember<T>> { | 310 struct IsWeak<blink::WeakMember<T>> { |
321 STATIC_ONLY(IsWeak); | 311 STATIC_ONLY(IsWeak); |
322 static const bool value = true; | 312 static const bool value = true; |
323 }; | 313 }; |
324 | 314 |
325 template<typename T> | 315 template<typename T> |
326 struct IsTraceable<blink::WeakMember<T>> { | 316 struct IsTraceable<blink::WeakMember<T>> { |
327 STATIC_ONLY(IsTraceable); | 317 STATIC_ONLY(IsTraceable); |
328 static const bool value = true; | 318 static const bool value = true; |
329 }; | 319 }; |
330 | 320 |
331 } // namespace WTF | 321 } // namespace WTF |
332 | 322 |
333 #endif // Member_h | 323 #endif // Member_h |
334 | 324 |
OLD | NEW |