Changeset 47592 in webkit for trunk/JavaScriptCore/wtf


Ignore:
Timestamp:
Aug 20, 2009, 1:12:17 PM (16 years ago)
Author:
[email protected]
Message:

2009-08-20 Yongjun Zhang <[email protected]>

Reviewed by Eric Seidel.

https://bugs.webkit.org/show_bug.cgi?id=28054

Use a helper function to work around winscw compiler forward declaration bug
regarding templated classes.

Add parenthesis around (PassRefPtr::*UnspecifiedBoolType) to make winscw compiler
work with the default UnSpecifiedBoolType() operator, which removes the winscw
specific bool cast hack.

  • wtf/PassRefPtr.h: (WTF::derefIfNotNull): (WTF::PassRefPtr::~PassRefPtr):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/PassRefPtr.h

    r43259 r47592  
    2929    template<typename T> class PassRefPtr;
    3030    template <typename T> PassRefPtr<T> adoptRef(T*);
     31   
     32    // Remove inline for winscw compiler to prevent the compiler agressively resolving
     33    // T::deref(), which will fail compiling when PassRefPtr<T> is used as class member
     34    // or function arguments before T is defined.
     35    template<typename T>
     36#if !COMPILER(WINSCW)
     37    inline
     38#endif
     39    void derefIfNotNull(T* ptr)
     40    {
     41        if (UNLIKELY(ptr != 0))
     42            ptr->deref();
     43    }
    3144
    3245    template<typename T> class PassRefPtr {
     
    4154        template <typename U> PassRefPtr(const PassRefPtr<U>& o) : m_ptr(o.releaseRef()) { }
    4255
    43         ALWAYS_INLINE ~PassRefPtr() { if (UNLIKELY(m_ptr != 0)) m_ptr->deref(); }
    44        
     56        ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull<T>(m_ptr); }
     57
    4558        template <class U>
    4659        PassRefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { if (T* ptr = m_ptr) ptr->ref(); }
     
    5770
    5871        // This conversion operator allows implicit conversion to bool but not to other integer types.
    59 #if COMPILER(WINSCW)
    60         operator bool() const { return m_ptr; }
    61 #else
    62         typedef T* PassRefPtr::*UnspecifiedBoolType;
     72        // Parenthesis is needed for winscw compiler to resolve class qualifier in this case.
     73        typedef T* (PassRefPtr::*UnspecifiedBoolType);
    6374        operator UnspecifiedBoolType() const { return m_ptr ? &PassRefPtr::m_ptr : 0; }
    64 #endif
     75
    6576        PassRefPtr& operator=(T*);
    6677        PassRefPtr& operator=(const PassRefPtr&);
Note: See TracChangeset for help on using the changeset viewer.