Changeset 47592 in webkit


Ignore:
Timestamp:
Aug 20, 2009 1:12:17 PM (15 years ago)
Author:
eric@webkit.org
Message:

2009-08-20 Yongjun Zhang <yongjun.zhang@nokia.com>

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):
Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r47582 r47592  
     12009-08-20  Yongjun Zhang  <yongjun.zhang@nokia.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=28054
     6       
     7        Use a helper function to work around winscw compiler forward declaration bug
     8        regarding templated classes.
     9
     10        Add parenthesis around (PassRefPtr::*UnspecifiedBoolType) to make winscw compiler
     11        work with the default UnSpecifiedBoolType() operator, which removes the winscw
     12        specific bool cast hack.
     13
     14        * wtf/PassRefPtr.h:
     15        (WTF::derefIfNotNull):
     16        (WTF::PassRefPtr::~PassRefPtr):
     17
    1182009-08-19  Yong Li  <yong.li@torchmobile.com>
    219
  • 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.