| Index: Source/wtf/TypeTraits.h
|
| diff --git a/Source/wtf/TypeTraits.h b/Source/wtf/TypeTraits.h
|
| index 92f8cebb2b7b02d00e717be8d7902c8af2e656da..1a9f4265a79a19acf23daaa71f3208e3cc0a3459 100644
|
| --- a/Source/wtf/TypeTraits.h
|
| +++ b/Source/wtf/TypeTraits.h
|
| @@ -240,6 +240,10 @@ namespace WTF {
|
| typedef T Type;
|
| };
|
|
|
| + template <typename T> struct Identity {
|
| + typedef T type;
|
| + };
|
| +
|
| template <typename T> struct RemoveConst {
|
| typedef T Type;
|
| };
|
| @@ -303,6 +307,8 @@ namespace WTF {
|
| namespace blink {
|
|
|
| class JSONValue;
|
| +class InlinedGlobalMarkingVisitor;
|
| +class Visitor;
|
|
|
| } // namespace blink
|
|
|
| @@ -318,23 +324,42 @@ namespace WTF {
|
| };
|
|
|
| template<typename T>
|
| +class HasTraceNewMethod {
|
| + typedef char YesType;
|
| + typedef struct NoType {
|
| + char padding[8];
|
| + } NoType;
|
| +#if COMPILER(MSVC)
|
| + QUACK!
|
| +#else
|
| + template<size_t> struct HasMethod;
|
| + template<typename V> static YesType checkHasTraceNewMethod(HasMethod<sizeof(static_cast<void (V::*)(blink::InlinedGlobalMarkingVisitor)>(&V::trace))>*);
|
| +#endif // COMPILER(MSVC)
|
| + template<typename V> static NoType checkHasTraceNewMethod(...);
|
| +public:
|
| + static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTraceNewMethod<T>(0)) + sizeof(T);
|
| +};
|
| +
|
| +template<typename T>
|
| class NeedsTracing {
|
| typedef char YesType;
|
| typedef struct NoType {
|
| char padding[8];
|
| } NoType;
|
| #if COMPILER(MSVC)
|
| + QUACK!
|
| template<typename V> static YesType checkHasTraceMethod(char[&V::trace != 0]);
|
| #else
|
| template<size_t> struct HasMethod;
|
| - template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(&V::trace)>*);
|
| + template<typename V> static YesType checkHasTraceMethod(HasMethod<sizeof(static_cast<void (V::*)(blink::Visitor*)>(&V::trace))>*);
|
| #endif // COMPILER(MSVC)
|
| template<typename V> static NoType checkHasTraceMethod(...);
|
| public:
|
| // We add sizeof(T) to both sides here, because we want it to fail for
|
| // incomplete types. Otherwise it just assumes that incomplete types do not
|
| // have a trace method, which may not be true.
|
| - static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTraceMethod<T>(0)) + sizeof(T);
|
| + static const bool hasTraceMethod = sizeof(YesType) + sizeof(T) == sizeof(checkHasTraceMethod<T>(0)) + sizeof(T);
|
| + static const bool value = hasTraceMethod || HasTraceNewMethod<T>::value;
|
| };
|
|
|
| // Convenience template wrapping the NeedsTracingLazily template in
|
|
|