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

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

Issue 722723003: Re-land 714393002 after fixing android build. (Closed) Base URL: git@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
« no previous file with comments | « sky/engine/wtf/RetainPtr.h ('k') | sky/engine/wtf/TypeTraits.cpp » ('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) 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)
65 template<> struct IsInteger<wchar_t> { static const bool value = true; }; 64 template<> struct IsInteger<wchar_t> { static const bool value = true; };
66 #endif
67 65
68 template<typename T> struct IsFloatingPoint { static const bool value = false; }; 66 template<typename T> struct IsFloatingPoint { static const bool value = false; };
69 template<> struct IsFloatingPoint<float> { static const bool value = true; }; 67 template<> struct IsFloatingPoint<float> { static const bool value = true; };
70 template<> struct IsFloatingPoint<double> { static const bool value = true; }; 68 template<> struct IsFloatingPoint<double> { static const bool value = true; };
71 template<> struct IsFloatingPoint<long double> { static const bool value = true; }; 69 template<> struct IsFloatingPoint<long double> { static const bool value = true; };
72 70
73 template<typename T> struct IsArithmetic { static const bool value = IsInteger<T>::value || IsFloatingPoint<T>::value; }; 71 template<typename T> struct IsArithmetic { static const bool value = IsInteger<T>::value || IsFloatingPoint<T>::value; };
74 72
75 template<typename T> struct IsWeak { static const bool value = false; }; 73 template<typename T> struct IsWeak { static const bool value = false; };
76 74
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 Value = true 305 Value = true
308 }; 306 };
309 }; 307 };
310 308
311 template<typename T> 309 template<typename T>
312 class NeedsTracing { 310 class NeedsTracing {
313 typedef char YesType; 311 typedef char YesType;
314 typedef struct NoType { 312 typedef struct NoType {
315 char padding[8]; 313 char padding[8];
316 } NoType; 314 } NoType;
317 #if COMPILER(MSVC)
318 template<typename V> static YesType checkHasTraceMethod(char[&V::trace != 0] );
319 #else
320 template<size_t> struct HasMethod; 315 template<size_t> struct HasMethod;
321 template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(&V: :trace)>*); 316 template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(&V: :trace)>*);
322 #endif // COMPILER(MSVC)
323 template<typename V> static NoType checkHasTraceMethod(...); 317 template<typename V> static NoType checkHasTraceMethod(...);
324 public: 318 public:
325 // We add sizeof(T) to both sides here, because we want it to fail for 319 // We add sizeof(T) to both sides here, because we want it to fail for
326 // incomplete types. Otherwise it just assumes that incomplete types do not 320 // incomplete types. Otherwise it just assumes that incomplete types do not
327 // have a trace method, which may not be true. 321 // have a trace method, which may not be true.
328 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTrac eMethod<T>(0)) + sizeof(T); 322 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTrac eMethod<T>(0)) + sizeof(T);
329 }; 323 };
330 324
331 // Convenience template wrapping the NeedsTracingLazily template in 325 // Convenience template wrapping the NeedsTracingLazily template in
332 // Collection Traits. It helps make the code more readable. 326 // Collection Traits. It helps make the code more readable.
333 template<typename Traits> 327 template<typename Traits>
334 class ShouldBeTraced { 328 class ShouldBeTraced {
335 public: 329 public:
336 static const bool value = Traits::template NeedsTracingLazily<>::value; 330 static const bool value = Traits::template NeedsTracingLazily<>::value;
337 }; 331 };
338 332
339 template<typename T, typename U> 333 template<typename T, typename U>
340 struct NeedsTracing<std::pair<T, U> > { 334 struct NeedsTracing<std::pair<T, U> > {
341 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value | | IsWeak<T>::value || IsWeak<U>::value; 335 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value | | IsWeak<T>::value || IsWeak<U>::value;
342 }; 336 };
343 337
344 } // namespace WTF 338 } // namespace WTF
345 339
346 #endif // TypeTraits_h 340 #endif // TypeTraits_h
OLDNEW
« no previous file with comments | « sky/engine/wtf/RetainPtr.h ('k') | sky/engine/wtf/TypeTraits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698