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

Side by Side Diff: third_party/WebKit/Source/wtf/TypeTraits.h

Issue 2065443002: Rename and improve "traceable" templates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment rewording Created 4 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
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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 namespace blink { 242 namespace blink {
243 243
244 class Visitor; 244 class Visitor;
245 245
246 } // namespace blink 246 } // namespace blink
247 247
248 namespace WTF { 248 namespace WTF {
249 249
250 template <typename T> 250 template <typename T>
251 class NeedsTracing { 251 class IsTraceable {
252 typedef char YesType; 252 typedef char YesType;
253 typedef struct NoType { 253 typedef struct NoType {
254 char padding[8]; 254 char padding[8];
255 } NoType; 255 } NoType;
256 256
257 // Note that this also checks if a superclass of V has a trace method. 257 // Note that this also checks if a superclass of V has a trace method.
258 template <typename V> static YesType checkHasTraceMethod(V* v, blink::Visito r* p = nullptr, typename std::enable_if<std::is_same<decltype(v->trace(p)), void >::value>::type* g = nullptr); 258 template <typename V> static YesType checkHasTraceMethod(V* v, blink::Visito r* p = nullptr, typename std::enable_if<std::is_same<decltype(v->trace(p)), void >::value>::type* g = nullptr);
259 template <typename V> static NoType checkHasTraceMethod(...); 259 template <typename V> static NoType checkHasTraceMethod(...);
260 public: 260 public:
261 // We add sizeof(T) to both sides here, because we want it to fail for 261 // We add sizeof(T) to both sides here, because we want it to fail for
262 // incomplete types. Otherwise it just assumes that incomplete types do not 262 // incomplete types. Otherwise it just assumes that incomplete types do not
263 // have a trace method, which may not be true. 263 // have a trace method, which may not be true.
264 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTrac eMethod<T>(nullptr)) + sizeof(T); 264 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTrac eMethod<T>(nullptr)) + sizeof(T);
265 }; 265 };
266 266
267 // Convenience template wrapping the NeedsTracingLazily template in 267 // Convenience template wrapping the IsTraceableInCollection template in
268 // Collection Traits. It helps make the code more readable. 268 // Collection Traits. It helps make the code more readable.
269 template <typename Traits> 269 template <typename Traits>
270 class NeedsTracingTrait { 270 class IsTraceableInCollectionTrait {
271 public: 271 public:
272 static const bool value = Traits::template NeedsTracingLazily<>::value; 272 static const bool value = Traits::template IsTraceableInCollection<>::value;
273 }; 273 };
274 274
275 template <typename T, typename U> 275 template <typename T, typename U>
276 struct NeedsTracing<std::pair<T, U>> { 276 struct IsTraceable<std::pair<T, U>> {
277 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value | | IsWeak<T>::value || IsWeak<U>::value; 277 static const bool value = IsTraceable<T>::value || IsTraceable<U>::value;
278 }; 278 };
279 279
280 // This is used to check that DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects are not 280 // This is used to check that DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects are not
281 // stored in off-heap Vectors, HashTables etc. 281 // stored in off-heap Vectors, HashTables etc.
282 template <typename T> 282 template <typename T>
283 struct AllowsOnlyPlacementNew { 283 struct AllowsOnlyPlacementNew {
284 private: 284 private:
285 using YesType = char; 285 using YesType = char;
286 struct NoType { 286 struct NoType {
287 char padding[8]; 287 char padding[8];
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 class IsPointerToGarbageCollectedType<T*, false> { 352 class IsPointerToGarbageCollectedType<T*, false> {
353 public: 353 public:
354 static const bool value = IsGarbageCollectedType<T>::value; 354 static const bool value = IsGarbageCollectedType<T>::value;
355 }; 355 };
356 356
357 } // namespace WTF 357 } // namespace WTF
358 358
359 using WTF::IsGarbageCollectedType; 359 using WTF::IsGarbageCollectedType;
360 360
361 #endif // TypeTraits_h 361 #endif // TypeTraits_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698