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

Side by Side Diff: sky/engine/wtf/HashFunctions.h

Issue 719063002: Revert "Remove support for MSVC" (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 return bitwise_cast<Bits>(a) == bitwise_cast<Bits>(b); 117 return bitwise_cast<Bits>(a) == bitwise_cast<Bits>(b);
118 } 118 }
119 static const bool safeToCompareToEmptyOrDeleted = true; 119 static const bool safeToCompareToEmptyOrDeleted = true;
120 }; 120 };
121 121
122 // pointer identity hash function 122 // pointer identity hash function
123 123
124 template<typename T> struct PtrHash { 124 template<typename T> struct PtrHash {
125 static unsigned hash(T key) 125 static unsigned hash(T key)
126 { 126 {
127 #if COMPILER(MSVC)
128 #pragma warning(push)
129 #pragma warning(disable: 4244) // work around what seems to be a bug in MSVC's c onversion warnings
130 #endif
127 return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key)); 131 return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key));
132 #if COMPILER(MSVC)
133 #pragma warning(pop)
134 #endif
128 } 135 }
129 static bool equal(T a, T b) { return a == b; } 136 static bool equal(T a, T b) { return a == b; }
130 static bool equal(std::nullptr_t, T b) { return b == 0; } 137 static bool equal(std::nullptr_t, T b) { return b == 0; }
131 static bool equal(T a, std::nullptr_t) { return a == 0; } 138 static bool equal(T a, std::nullptr_t) { return a == 0; }
132 static const bool safeToCompareToEmptyOrDeleted = true; 139 static const bool safeToCompareToEmptyOrDeleted = true;
133 }; 140 };
134 template<typename P> struct PtrHash<RefPtr<P> > : PtrHash<P*> { 141 template<typename P> struct PtrHash<RefPtr<P> > : PtrHash<P*> {
135 using PtrHash<P*>::hash; 142 using PtrHash<P*>::hash;
136 static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); } 143 static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); }
137 static unsigned hash(const PassRefPtr<P>& key) { return hash(key.get()); } 144 static unsigned hash(const PassRefPtr<P>& key) { return hash(key.get()); }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // make IntHash the default hash function for many integer types 198 // make IntHash the default hash function for many integer types
192 199
193 template<> struct DefaultHash<short> { typedef IntHash<unsigned> Hash; }; 200 template<> struct DefaultHash<short> { typedef IntHash<unsigned> Hash; };
194 template<> struct DefaultHash<unsigned short> { typedef IntHash<unsigned> Ha sh; }; 201 template<> struct DefaultHash<unsigned short> { typedef IntHash<unsigned> Ha sh; };
195 template<> struct DefaultHash<int> { typedef IntHash<unsigned> Hash; }; 202 template<> struct DefaultHash<int> { typedef IntHash<unsigned> Hash; };
196 template<> struct DefaultHash<unsigned> { typedef IntHash<unsigned> Hash; }; 203 template<> struct DefaultHash<unsigned> { typedef IntHash<unsigned> Hash; };
197 template<> struct DefaultHash<long> { typedef IntHash<unsigned long> Hash; } ; 204 template<> struct DefaultHash<long> { typedef IntHash<unsigned long> Hash; } ;
198 template<> struct DefaultHash<unsigned long> { typedef IntHash<unsigned long > Hash; }; 205 template<> struct DefaultHash<unsigned long> { typedef IntHash<unsigned long > Hash; };
199 template<> struct DefaultHash<long long> { typedef IntHash<unsigned long lon g> Hash; }; 206 template<> struct DefaultHash<long long> { typedef IntHash<unsigned long lon g> Hash; };
200 template<> struct DefaultHash<unsigned long long> { typedef IntHash<unsigned long long> Hash; }; 207 template<> struct DefaultHash<unsigned long long> { typedef IntHash<unsigned long long> Hash; };
208
209 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
201 template<> struct DefaultHash<wchar_t> { typedef IntHash<wchar_t> Hash; }; 210 template<> struct DefaultHash<wchar_t> { typedef IntHash<wchar_t> Hash; };
211 #endif
212
202 template<> struct DefaultHash<float> { typedef FloatHash<float> Hash; }; 213 template<> struct DefaultHash<float> { typedef FloatHash<float> Hash; };
203 template<> struct DefaultHash<double> { typedef FloatHash<double> Hash; }; 214 template<> struct DefaultHash<double> { typedef FloatHash<double> Hash; };
204 215
205 // make PtrHash the default hash function for pointer types that don't speci alize 216 // make PtrHash the default hash function for pointer types that don't speci alize
206 217
207 template<typename P> struct DefaultHash<P*> { typedef PtrHash<P*> Hash; }; 218 template<typename P> struct DefaultHash<P*> { typedef PtrHash<P*> Hash; };
208 template<typename P> struct DefaultHash<RefPtr<P> > { typedef PtrHash<RefPtr <P> > Hash; }; 219 template<typename P> struct DefaultHash<RefPtr<P> > { typedef PtrHash<RefPtr <P> > Hash; };
209 template<typename P> struct DefaultHash<RawPtr<P> > { typedef PtrHash<RawPtr <P> > Hash; }; 220 template<typename P> struct DefaultHash<RawPtr<P> > { typedef PtrHash<RawPtr <P> > Hash; };
210 template<typename P> struct DefaultHash<OwnPtr<P> > { typedef PtrHash<OwnPtr <P> > Hash; }; 221 template<typename P> struct DefaultHash<OwnPtr<P> > { typedef PtrHash<OwnPtr <P> > Hash; };
211 222
(...skipping 20 matching lines...) Expand all
232 243
233 template<typename T, typename U> struct DefaultHash<std::pair<T, U> > { type def PairHash<T, U> Hash; }; 244 template<typename T, typename U> struct DefaultHash<std::pair<T, U> > { type def PairHash<T, U> Hash; };
234 245
235 } // namespace WTF 246 } // namespace WTF
236 247
237 using WTF::DefaultHash; 248 using WTF::DefaultHash;
238 using WTF::IntHash; 249 using WTF::IntHash;
239 using WTF::PtrHash; 250 using WTF::PtrHash;
240 251
241 #endif // WTF_HashFunctions_h 252 #endif // WTF_HashFunctions_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698