| OLD | NEW |
| 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 Loading... |
| 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; |
| 306 | 307 |
| 307 } // namespace blink | 308 } // namespace blink |
| 308 | 309 |
| 309 namespace WTF { | 310 namespace WTF { |
| 310 | 311 |
| 311 // FIXME: Disable pointer conversion checking against JSONValue. | 312 // FIXME: Disable pointer conversion checking against JSONValue. |
| 312 // The current CodeGeneratorInspector.py generates code which upcasts to JSO
NValue from undefined types. | 313 // The current CodeGeneratorInspector.py generates code which upcasts to JSO
NValue from undefined types. |
| 313 template<typename From> class IsPointerConvertible<From, blink::JSONValue> { | 314 template<typename From> class IsPointerConvertible<From, blink::JSONValue> { |
| 314 public: | 315 public: |
| 315 enum { | 316 enum { |
| 316 Value = true | 317 Value = true |
| 317 }; | 318 }; |
| 318 }; | 319 }; |
| 319 | 320 |
| 320 template<typename T> | 321 template<typename T> |
| 321 class NeedsTracing { | 322 class NeedsTracing { |
| 322 typedef char YesType; | 323 typedef char YesType; |
| 323 typedef struct NoType { | 324 typedef struct NoType { |
| 324 char padding[8]; | 325 char padding[8]; |
| 325 } NoType; | 326 } NoType; |
| 326 #if COMPILER(MSVC) | 327 #if COMPILER(MSVC) |
| 327 template<typename V> static YesType checkHasTraceMethod(char[&V::trace != 0]
); | 328 public: |
| 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 } |
| 328 #else | 337 #else |
| 329 template<size_t> struct HasMethod; | 338 template<size_t> struct HasMethod; |
| 330 template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(&V:
:trace)>*); | 339 template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(sta
tic_cast<void (V::*)(blink::Visitor*)>(&V::trace))>*); |
| 331 #endif // COMPILER(MSVC) | |
| 332 template<typename V> static NoType checkHasTraceMethod(...); | 340 template<typename V> static NoType checkHasTraceMethod(...); |
| 333 public: | 341 public: |
| 334 // We add sizeof(T) to both sides here, because we want it to fail for | 342 // We add sizeof(T) to both sides here, because we want it to fail for |
| 335 // incomplete types. Otherwise it just assumes that incomplete types do not | 343 // incomplete types. Otherwise it just assumes that incomplete types do not |
| 336 // have a trace method, which may not be true. | 344 // have a trace method, which may not be true. |
| 337 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTrac
eMethod<T>(0)) + sizeof(T); | 345 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTrac
eMethod<T>(nullptr)) + sizeof(T); |
| 346 #endif // COMPILER(MSVC) |
| 338 }; | 347 }; |
| 339 | 348 |
| 340 // Convenience template wrapping the NeedsTracingLazily template in | 349 // Convenience template wrapping the NeedsTracingLazily template in |
| 341 // Collection Traits. It helps make the code more readable. | 350 // Collection Traits. It helps make the code more readable. |
| 342 template<typename Traits> | 351 template<typename Traits> |
| 343 class ShouldBeTraced { | 352 class ShouldBeTraced { |
| 344 public: | 353 public: |
| 345 static const bool value = Traits::template NeedsTracingLazily<>::value; | 354 static const bool value = Traits::template NeedsTracingLazily<>::value; |
| 346 }; | 355 }; |
| 347 | 356 |
| 348 template<typename T, typename U> | 357 template<typename T, typename U> |
| 349 struct NeedsTracing<std::pair<T, U> > { | 358 struct NeedsTracing<std::pair<T, U> > { |
| 350 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value |
| IsWeak<T>::value || IsWeak<U>::value; | 359 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value |
| IsWeak<T>::value || IsWeak<U>::value; |
| 351 }; | 360 }; |
| 352 | 361 |
| 353 } // namespace WTF | 362 } // namespace WTF |
| 354 | 363 |
| 355 #endif // TypeTraits_h | 364 #endif // TypeTraits_h |
| OLD | NEW |