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

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

Issue 828453003: Revert of Templatize visitor arguments for TraceTrait mark and trace methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 12 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
« no previous file with comments | « Source/wtf/HashTable.h ('k') | Source/wtf/Vector.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) 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 #define EnsurePtrConvertibleArgDecl(From, To) \ 296 #define EnsurePtrConvertibleArgDecl(From, To) \
297 typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Ty pe = true 297 typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Ty pe = true
298 #define EnsurePtrConvertibleArgDefn(From, To) \ 298 #define EnsurePtrConvertibleArgDefn(From, To) \
299 typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Ty pe 299 typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Ty pe
300 300
301 } // namespace WTF 301 } // namespace WTF
302 302
303 namespace blink { 303 namespace blink {
304 304
305 class JSONValue; 305 class JSONValue;
306 class Visitor;
307 306
308 } // namespace blink 307 } // namespace blink
309 308
310 namespace WTF { 309 namespace WTF {
311 310
312 // FIXME: Disable pointer conversion checking against JSONValue. 311 // FIXME: Disable pointer conversion checking against JSONValue.
313 // The current CodeGeneratorInspector.py generates code which upcasts to JSO NValue from undefined types. 312 // The current CodeGeneratorInspector.py generates code which upcasts to JSO NValue from undefined types.
314 template<typename From> class IsPointerConvertible<From, blink::JSONValue> { 313 template<typename From> class IsPointerConvertible<From, blink::JSONValue> {
315 public: 314 public:
316 enum { 315 enum {
317 Value = true 316 Value = true
318 }; 317 };
319 }; 318 };
320 319
321 template<typename T> 320 template<typename T>
322 class NeedsTracing { 321 class NeedsTracing {
323 typedef char YesType; 322 typedef char YesType;
324 typedef struct NoType { 323 typedef struct NoType {
325 char padding[8]; 324 char padding[8];
326 } NoType; 325 } NoType;
327 #if COMPILER(MSVC) 326 #if COMPILER(MSVC)
328 public: 327 template<typename V> static YesType checkHasTraceMethod(char[&V::trace != 0] );
329 __if_exists(T::trace)
330 {
331 static const bool value = true;
332 }
333 __if_not_exists(T::trace)
334 {
335 static const bool value = false;
336 }
337 #else 328 #else
338 template<size_t> struct HasMethod; 329 template<size_t> struct HasMethod;
339 template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(sta tic_cast<void (V::*)(blink::Visitor*)>(&V::trace))>*); 330 template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(&V: :trace)>*);
331 #endif // COMPILER(MSVC)
340 template<typename V> static NoType checkHasTraceMethod(...); 332 template<typename V> static NoType checkHasTraceMethod(...);
341 public: 333 public:
342 // We add sizeof(T) to both sides here, because we want it to fail for 334 // We add sizeof(T) to both sides here, because we want it to fail for
343 // incomplete types. Otherwise it just assumes that incomplete types do not 335 // incomplete types. Otherwise it just assumes that incomplete types do not
344 // have a trace method, which may not be true. 336 // have a trace method, which may not be true.
345 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTrac eMethod<T>(nullptr)) + sizeof(T); 337 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTrac eMethod<T>(0)) + sizeof(T);
346 #endif // COMPILER(MSVC)
347 }; 338 };
348 339
349 // Convenience template wrapping the NeedsTracingLazily template in 340 // Convenience template wrapping the NeedsTracingLazily template in
350 // Collection Traits. It helps make the code more readable. 341 // Collection Traits. It helps make the code more readable.
351 template<typename Traits> 342 template<typename Traits>
352 class ShouldBeTraced { 343 class ShouldBeTraced {
353 public: 344 public:
354 static const bool value = Traits::template NeedsTracingLazily<>::value; 345 static const bool value = Traits::template NeedsTracingLazily<>::value;
355 }; 346 };
356 347
357 template<typename T, typename U> 348 template<typename T, typename U>
358 struct NeedsTracing<std::pair<T, U> > { 349 struct NeedsTracing<std::pair<T, U> > {
359 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value | | IsWeak<T>::value || IsWeak<U>::value; 350 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value | | IsWeak<T>::value || IsWeak<U>::value;
360 }; 351 };
361 352
362 } // namespace WTF 353 } // namespace WTF
363 354
364 #endif // TypeTraits_h 355 #endif // TypeTraits_h
OLDNEW
« no previous file with comments | « Source/wtf/HashTable.h ('k') | Source/wtf/Vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698