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

Side by Side Diff: sky/engine/wtf/TypeTraits.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) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 template<> struct IsInteger<signed char> { static const bool value = true; }; 54 template<> struct IsInteger<signed char> { static const bool value = true; };
55 template<> struct IsInteger<unsigned char> { static const bool value = true; }; 55 template<> struct IsInteger<unsigned char> { static const bool value = true; };
56 template<> struct IsInteger<short> { static const bool value = true; }; 56 template<> struct IsInteger<short> { static const bool value = true; };
57 template<> struct IsInteger<unsigned short> { static const bool value = true; }; 57 template<> struct IsInteger<unsigned short> { static const bool value = true; };
58 template<> struct IsInteger<int> { static const bool value = true; }; 58 template<> struct IsInteger<int> { static const bool value = true; };
59 template<> struct IsInteger<unsigned int> { static const bool value = true; }; 59 template<> struct IsInteger<unsigned int> { static const bool value = true; };
60 template<> struct IsInteger<long> { static const bool value = true; }; 60 template<> struct IsInteger<long> { static const bool value = true; };
61 template<> struct IsInteger<unsigned long> { static const bool value = true; }; 61 template<> struct IsInteger<unsigned long> { static const bool value = true; };
62 template<> struct IsInteger<long long> { static const bool value = true; }; 62 template<> struct IsInteger<long long> { static const bool value = true; };
63 template<> struct IsInteger<unsigned long long> { static const bool value = true; }; 63 template<> struct IsInteger<unsigned long long> { static const bool value = true; };
64 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
64 template<> struct IsInteger<wchar_t> { static const bool value = true; }; 65 template<> struct IsInteger<wchar_t> { static const bool value = true; };
66 #endif
65 67
66 template<typename T> struct IsFloatingPoint { static const bool value = false; }; 68 template<typename T> struct IsFloatingPoint { static const bool value = false; };
67 template<> struct IsFloatingPoint<float> { static const bool value = true; }; 69 template<> struct IsFloatingPoint<float> { static const bool value = true; };
68 template<> struct IsFloatingPoint<double> { static const bool value = true; }; 70 template<> struct IsFloatingPoint<double> { static const bool value = true; };
69 template<> struct IsFloatingPoint<long double> { static const bool value = true; }; 71 template<> struct IsFloatingPoint<long double> { static const bool value = true; };
70 72
71 template<typename T> struct IsArithmetic { static const bool value = IsInteger<T>::value || IsFloatingPoint<T>::value; }; 73 template<typename T> struct IsArithmetic { static const bool value = IsInteger<T>::value || IsFloatingPoint<T>::value; };
72 74
73 template<typename T> struct IsWeak { static const bool value = false; }; 75 template<typename T> struct IsWeak { static const bool value = false; };
74 76
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 Value = true 307 Value = true
306 }; 308 };
307 }; 309 };
308 310
309 template<typename T> 311 template<typename T>
310 class NeedsTracing { 312 class NeedsTracing {
311 typedef char YesType; 313 typedef char YesType;
312 typedef struct NoType { 314 typedef struct NoType {
313 char padding[8]; 315 char padding[8];
314 } NoType; 316 } NoType;
317 #if COMPILER(MSVC)
318 template<typename V> static YesType checkHasTraceMethod(char[&V::trace != 0] );
319 #else
315 template<size_t> struct HasMethod; 320 template<size_t> struct HasMethod;
316 template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(&V: :trace)>*); 321 template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(&V: :trace)>*);
322 #endif // COMPILER(MSVC)
317 template<typename V> static NoType checkHasTraceMethod(...); 323 template<typename V> static NoType checkHasTraceMethod(...);
318 public: 324 public:
319 // We add sizeof(T) to both sides here, because we want it to fail for 325 // We add sizeof(T) to both sides here, because we want it to fail for
320 // incomplete types. Otherwise it just assumes that incomplete types do not 326 // incomplete types. Otherwise it just assumes that incomplete types do not
321 // have a trace method, which may not be true. 327 // have a trace method, which may not be true.
322 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTrac eMethod<T>(0)) + sizeof(T); 328 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTrac eMethod<T>(0)) + sizeof(T);
323 }; 329 };
324 330
325 // Convenience template wrapping the NeedsTracingLazily template in 331 // Convenience template wrapping the NeedsTracingLazily template in
326 // Collection Traits. It helps make the code more readable. 332 // Collection Traits. It helps make the code more readable.
327 template<typename Traits> 333 template<typename Traits>
328 class ShouldBeTraced { 334 class ShouldBeTraced {
329 public: 335 public:
330 static const bool value = Traits::template NeedsTracingLazily<>::value; 336 static const bool value = Traits::template NeedsTracingLazily<>::value;
331 }; 337 };
332 338
333 template<typename T, typename U> 339 template<typename T, typename U>
334 struct NeedsTracing<std::pair<T, U> > { 340 struct NeedsTracing<std::pair<T, U> > {
335 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value | | IsWeak<T>::value || IsWeak<U>::value; 341 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value | | IsWeak<T>::value || IsWeak<U>::value;
336 }; 342 };
337 343
338 } // namespace WTF 344 } // namespace WTF
339 345
340 #endif // TypeTraits_h 346 #endif // TypeTraits_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698