| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 299 |
| 300 // FIXME: Disable pointer conversion checking against JSONValue. | 300 // FIXME: Disable pointer conversion checking against JSONValue. |
| 301 // The current CodeGeneratorInspector.py generates code which upcasts to JSO
NValue from undefined types. | 301 // The current CodeGeneratorInspector.py generates code which upcasts to JSO
NValue from undefined types. |
| 302 template<typename From> class IsPointerConvertible<From, blink::JSONValue> { | 302 template<typename From> class IsPointerConvertible<From, blink::JSONValue> { |
| 303 public: | 303 public: |
| 304 enum { | 304 enum { |
| 305 Value = true | 305 Value = true |
| 306 }; | 306 }; |
| 307 }; | 307 }; |
| 308 | 308 |
| 309 template<typename T> | |
| 310 class NeedsTracing { | |
| 311 typedef char YesType; | |
| 312 typedef struct NoType { | |
| 313 char padding[8]; | |
| 314 } NoType; | |
| 315 template<size_t> struct HasMethod; | |
| 316 template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(&V:
:trace)>*); | |
| 317 template<typename V> static NoType checkHasTraceMethod(...); | |
| 318 public: | |
| 319 // We add sizeof(T) to both sides here, because we want it to fail for | |
| 320 // incomplete types. Otherwise it just assumes that incomplete types do not | |
| 321 // have a trace method, which may not be true. | |
| 322 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTrac
eMethod<T>(0)) + sizeof(T); | |
| 323 }; | |
| 324 | |
| 325 // Convenience template wrapping the NeedsTracingLazily template in | |
| 326 // Collection Traits. It helps make the code more readable. | |
| 327 template<typename Traits> | |
| 328 class ShouldBeTraced { | |
| 329 public: | |
| 330 static const bool value = Traits::template NeedsTracingLazily<>::value; | |
| 331 }; | |
| 332 | |
| 333 template<typename T, typename U> | |
| 334 struct NeedsTracing<std::pair<T, U> > { | |
| 335 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value |
| IsWeak<T>::value || IsWeak<U>::value; | |
| 336 }; | |
| 337 | |
| 338 } // namespace WTF | 309 } // namespace WTF |
| 339 | 310 |
| 340 #endif // TypeTraits_h | 311 #endif // TypeTraits_h |
| OLD | NEW |