| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 template <typename T, template <class V> class OuterTemplate> struct RemoveT
emplate { | 235 template <typename T, template <class V> class OuterTemplate> struct RemoveT
emplate { |
| 236 typedef T Type; | 236 typedef T Type; |
| 237 }; | 237 }; |
| 238 | 238 |
| 239 template <typename T, template <class V> class OuterTemplate> struct RemoveT
emplate<OuterTemplate<T>, OuterTemplate> { | 239 template <typename T, template <class V> class OuterTemplate> struct RemoveT
emplate<OuterTemplate<T>, OuterTemplate> { |
| 240 typedef T Type; | 240 typedef T Type; |
| 241 }; | 241 }; |
| 242 | 242 |
| 243 template <typename T> struct Identity { |
| 244 typedef T type; |
| 245 }; |
| 246 |
| 243 template <typename T> struct RemoveConst { | 247 template <typename T> struct RemoveConst { |
| 244 typedef T Type; | 248 typedef T Type; |
| 245 }; | 249 }; |
| 246 | 250 |
| 247 template <typename T> struct RemoveConst<const T> { | 251 template <typename T> struct RemoveConst<const T> { |
| 248 typedef T Type; | 252 typedef T Type; |
| 249 }; | 253 }; |
| 250 | 254 |
| 251 template <typename T> struct RemoveVolatile { | 255 template <typename T> struct RemoveVolatile { |
| 252 typedef T Type; | 256 typedef T Type; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 #define EnsurePtrConvertibleArgDecl(From, To) \ | 300 #define EnsurePtrConvertibleArgDecl(From, To) \ |
| 297 typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Ty
pe = true | 301 typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Ty
pe = true |
| 298 #define EnsurePtrConvertibleArgDefn(From, To) \ | 302 #define EnsurePtrConvertibleArgDefn(From, To) \ |
| 299 typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Ty
pe | 303 typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Ty
pe |
| 300 | 304 |
| 301 } // namespace WTF | 305 } // namespace WTF |
| 302 | 306 |
| 303 namespace blink { | 307 namespace blink { |
| 304 | 308 |
| 305 class JSONValue; | 309 class JSONValue; |
| 310 class InlinedGlobalMarkingVisitor; |
| 311 class Visitor; |
| 306 | 312 |
| 307 } // namespace blink | 313 } // namespace blink |
| 308 | 314 |
| 309 namespace WTF { | 315 namespace WTF { |
| 310 | 316 |
| 311 // FIXME: Disable pointer conversion checking against JSONValue. | 317 // FIXME: Disable pointer conversion checking against JSONValue. |
| 312 // The current CodeGeneratorInspector.py generates code which upcasts to JSO
NValue from undefined types. | 318 // The current CodeGeneratorInspector.py generates code which upcasts to JSO
NValue from undefined types. |
| 313 template<typename From> class IsPointerConvertible<From, blink::JSONValue> { | 319 template<typename From> class IsPointerConvertible<From, blink::JSONValue> { |
| 314 public: | 320 public: |
| 315 enum { | 321 enum { |
| 316 Value = true | 322 Value = true |
| 317 }; | 323 }; |
| 318 }; | 324 }; |
| 319 | 325 |
| 320 template<typename T> | 326 template<typename T> |
| 327 class HasTraceNewMethod { |
| 328 typedef char YesType; |
| 329 typedef struct NoType { |
| 330 char padding[8]; |
| 331 } NoType; |
| 332 #if COMPILER(MSVC) |
| 333 QUACK! |
| 334 #else |
| 335 template<size_t> struct HasMethod; |
| 336 template<typename V> static YesType checkHasTraceNewMethod(HasMethod<sizeof(
static_cast<void (V::*)(blink::InlinedGlobalMarkingVisitor)>(&V::trace))>*); |
| 337 #endif // COMPILER(MSVC) |
| 338 template<typename V> static NoType checkHasTraceNewMethod(...); |
| 339 public: |
| 340 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTrac
eNewMethod<T>(0)) + sizeof(T); |
| 341 }; |
| 342 |
| 343 template<typename T> |
| 321 class NeedsTracing { | 344 class NeedsTracing { |
| 322 typedef char YesType; | 345 typedef char YesType; |
| 323 typedef struct NoType { | 346 typedef struct NoType { |
| 324 char padding[8]; | 347 char padding[8]; |
| 325 } NoType; | 348 } NoType; |
| 326 #if COMPILER(MSVC) | 349 #if COMPILER(MSVC) |
| 350 QUACK! |
| 327 template<typename V> static YesType checkHasTraceMethod(char[&V::trace != 0]
); | 351 template<typename V> static YesType checkHasTraceMethod(char[&V::trace != 0]
); |
| 328 #else | 352 #else |
| 329 template<size_t> struct HasMethod; | 353 template<size_t> struct HasMethod; |
| 330 template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(&V:
:trace)>*); | 354 template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(sta
tic_cast<void (V::*)(blink::Visitor*)>(&V::trace))>*); |
| 331 #endif // COMPILER(MSVC) | 355 #endif // COMPILER(MSVC) |
| 332 template<typename V> static NoType checkHasTraceMethod(...); | 356 template<typename V> static NoType checkHasTraceMethod(...); |
| 333 public: | 357 public: |
| 334 // We add sizeof(T) to both sides here, because we want it to fail for | 358 // 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 | 359 // incomplete types. Otherwise it just assumes that incomplete types do not |
| 336 // have a trace method, which may not be true. | 360 // 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); | 361 static const bool hasTraceMethod = sizeof(YesType) + sizeof(T) == sizeof(che
ckHasTraceMethod<T>(0)) + sizeof(T); |
| 362 static const bool value = hasTraceMethod || HasTraceNewMethod<T>::value; |
| 338 }; | 363 }; |
| 339 | 364 |
| 340 // Convenience template wrapping the NeedsTracingLazily template in | 365 // Convenience template wrapping the NeedsTracingLazily template in |
| 341 // Collection Traits. It helps make the code more readable. | 366 // Collection Traits. It helps make the code more readable. |
| 342 template<typename Traits> | 367 template<typename Traits> |
| 343 class ShouldBeTraced { | 368 class ShouldBeTraced { |
| 344 public: | 369 public: |
| 345 static const bool value = Traits::template NeedsTracingLazily<>::value; | 370 static const bool value = Traits::template NeedsTracingLazily<>::value; |
| 346 }; | 371 }; |
| 347 | 372 |
| 348 template<typename T, typename U> | 373 template<typename T, typename U> |
| 349 struct NeedsTracing<std::pair<T, U> > { | 374 struct NeedsTracing<std::pair<T, U> > { |
| 350 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value |
| IsWeak<T>::value || IsWeak<U>::value; | 375 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value |
| IsWeak<T>::value || IsWeak<U>::value; |
| 351 }; | 376 }; |
| 352 | 377 |
| 353 } // namespace WTF | 378 } // namespace WTF |
| 354 | 379 |
| 355 #endif // TypeTraits_h | 380 #endif // TypeTraits_h |
| OLD | NEW |