Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: Source/wtf/HashTraits.h

Issue 319593004: Oilpan:Allow custom handling of classes that contain weak pointers that are embedded in collections. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove 'typename' that Win compiler does not like Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/wtf/HashTable.h ('k') | Source/wtf/LinkedHashSet.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv ed.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) 56 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
57 static const unsigned minimumTableSize = 1; 57 static const unsigned minimumTableSize = 1;
58 #else 58 #else
59 static const unsigned minimumTableSize = 8; 59 static const unsigned minimumTableSize = 8;
60 #endif 60 #endif
61 61
62 template<typename U = void> 62 template<typename U = void>
63 struct NeedsTracingLazily { 63 struct NeedsTracingLazily {
64 static const bool value = NeedsTracing<T>::value; 64 static const bool value = NeedsTracing<T>::value;
65 }; 65 };
66 static const bool isWeak = IsWeak<T>::value; 66 static const WeakHandlingFlag weakHandlingFlag = IsWeak<T>::value ? Weak HandlingInCollections : NoWeakHandlingInCollections;
67 template<typename Visitor>
68 static bool shouldRemoveFromCollection(Visitor*, T&) { return false; }
67 }; 69 };
68 70
69 // Default integer traits disallow both 0 and -1 as keys (max value instead of -1 for unsigned). 71 // Default integer traits disallow both 0 and -1 as keys (max value instead of -1 for unsigned).
70 template<typename T> struct GenericHashTraitsBase<true, T> : GenericHashTrai tsBase<false, T> { 72 template<typename T> struct GenericHashTraitsBase<true, T> : GenericHashTrai tsBase<false, T> {
71 static const bool emptyValueIsZero = true; 73 static const bool emptyValueIsZero = true;
72 static const bool needsDestruction = false; 74 static const bool needsDestruction = false;
73 static void constructDeletedValue(T& slot) { slot = static_cast<T>(-1); } 75 static void constructDeletedValue(T& slot) { slot = static_cast<T>(-1); }
74 static bool isDeletedValue(T value) { return value == static_cast<T>(-1) ; } 76 static bool isDeletedValue(T value) { return value == static_cast<T>(-1) ; }
75 }; 77 };
76 78
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 typedef KeyValuePair<typename KeyTraits::EmptyValueType, typename ValueT raits::EmptyValueType> EmptyValueType; 265 typedef KeyValuePair<typename KeyTraits::EmptyValueType, typename ValueT raits::EmptyValueType> EmptyValueType;
264 266
265 static const bool emptyValueIsZero = KeyTraits::emptyValueIsZero && Valu eTraits::emptyValueIsZero; 267 static const bool emptyValueIsZero = KeyTraits::emptyValueIsZero && Valu eTraits::emptyValueIsZero;
266 static EmptyValueType emptyValue() { return KeyValuePair<typename KeyTra its::EmptyValueType, typename ValueTraits::EmptyValueType>(KeyTraits::emptyValue (), ValueTraits::emptyValue()); } 268 static EmptyValueType emptyValue() { return KeyValuePair<typename KeyTra its::EmptyValueType, typename ValueTraits::EmptyValueType>(KeyTraits::emptyValue (), ValueTraits::emptyValue()); }
267 269
268 static const bool needsDestruction = KeyTraits::needsDestruction || Valu eTraits::needsDestruction; 270 static const bool needsDestruction = KeyTraits::needsDestruction || Valu eTraits::needsDestruction;
269 template<typename U = void> 271 template<typename U = void>
270 struct NeedsTracingLazily { 272 struct NeedsTracingLazily {
271 static const bool value = ShouldBeTraced<KeyTraits>::value || Should BeTraced<ValueTraits>::value; 273 static const bool value = ShouldBeTraced<KeyTraits>::value || Should BeTraced<ValueTraits>::value;
272 }; 274 };
273 static const bool isWeak = KeyTraits::isWeak || ValueTraits::isWeak; 275 static const WeakHandlingFlag weakHandlingFlag = (KeyTraits::weakHandlin gFlag == WeakHandlingInCollections || ValueTraits::weakHandlingFlag == WeakHandl ingInCollections) ? WeakHandlingInCollections : NoWeakHandlingInCollections;
274 276
275 static const unsigned minimumTableSize = KeyTraits::minimumTableSize; 277 static const unsigned minimumTableSize = KeyTraits::minimumTableSize;
276 278
277 static void constructDeletedValue(TraitType& slot) { KeyTraits::construc tDeletedValue(slot.key); } 279 static void constructDeletedValue(TraitType& slot) { KeyTraits::construc tDeletedValue(slot.key); }
278 static bool isDeletedValue(const TraitType& value) { return KeyTraits::i sDeletedValue(value.key); } 280 static bool isDeletedValue(const TraitType& value) { return KeyTraits::i sDeletedValue(value.key); }
281 template<typename Visitor>
282 static bool shouldRemoveFromCollection(Visitor* visitor, TraitType& pair )
283 {
284 return KeyTraits::shouldRemoveFromCollection(visitor, pair.key)
285 || ValueTraits::shouldRemoveFromCollection(visitor, pair.value);
286 }
279 }; 287 };
280 288
281 template<typename Key, typename Value> 289 template<typename Key, typename Value>
282 struct HashTraits<KeyValuePair<Key, Value> > : public KeyValuePairHashTraits <HashTraits<Key>, HashTraits<Value> > { }; 290 struct HashTraits<KeyValuePair<Key, Value> > : public KeyValuePairHashTraits <HashTraits<Key>, HashTraits<Value> > { };
283 291
284 template<typename T> 292 template<typename T>
285 struct NullableHashTraits : public HashTraits<T> { 293 struct NullableHashTraits : public HashTraits<T> {
286 static const bool emptyValueIsZero = false; 294 static const bool emptyValueIsZero = false;
287 static T emptyValue() { return reinterpret_cast<T>(1); } 295 static T emptyValue() { return reinterpret_cast<T>(1); }
288 }; 296 };
289 297
290 } // namespace WTF 298 } // namespace WTF
291 299
292 using WTF::HashTraits; 300 using WTF::HashTraits;
293 using WTF::PairHashTraits; 301 using WTF::PairHashTraits;
294 using WTF::NullableHashTraits; 302 using WTF::NullableHashTraits;
295 using WTF::SimpleClassHashTraits; 303 using WTF::SimpleClassHashTraits;
296 304
297 #endif // WTF_HashTraits_h 305 #endif // WTF_HashTraits_h
OLDNEW
« no previous file with comments | « Source/wtf/HashTable.h ('k') | Source/wtf/LinkedHashSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698