Ignore:
Timestamp:
Feb 12, 2010, 6:29:02 AM (15 years ago)
Author:
[email protected]
Message:

Additional refptr/passrefptr workarounds for WINSCW compiler

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

Patch by Janne Koskinen <[email protected]> on 2010-02-12

Reviewed by Tor Arne Vestbø.

  • wtf/PassRefPtr.h:

(WTF::refIfNotNull):
(WTF::PassRefPtr::PassRefPtr):
(WTF::PassRefPtr::~PassRefPtr):
(WTF::PassRefPtr::clear):
(WTF::::operator):

  • wtf/RefPtr.h:

(WTF::RefPtr::RefPtr):
(WTF::::operator):

File:
1 edited

Legend:

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

    r48836 r54724  
    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.
     31
     32
     33    // Remove inline for WINSCW compiler to prevent the compiler agressively resolving
     34    // T::ref() and T::deref(), which will fail compiling when PassRefPtr<T> is used as
     35    // a class member or function arguments before T is defined.
     36    template<typename T>
     37#if !COMPILER(WINSCW)
     38    inline
     39#endif
     40    void refIfNotNull(T* ptr)
     41    {
     42        if (UNLIKELY(ptr != 0))
     43            ptr->ref();
     44    }
     45
    3546    template<typename T>
    3647#if !COMPILER(WINSCW)
     
    4657    public:
    4758        PassRefPtr() : m_ptr(0) {}
    48         PassRefPtr(T* ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); }
     59        PassRefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); }
    4960        // It somewhat breaks the type system to allow transfer of ownership out of
    5061        // a const PassRefPtr. However, it makes it much easier to work with PassRefPtr
     
    5465        template <typename U> PassRefPtr(const PassRefPtr<U>& o) : m_ptr(o.releaseRef()) { }
    5566
    56         ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull<T>(m_ptr); }
     67        ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); }
    5768
    5869        template <class U>
    59         PassRefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { if (T* ptr = m_ptr) ptr->ref(); }
     70        PassRefPtr(const RefPtr<U>& o) : m_ptr(o.get()) { T* ptr = m_ptr; refIfNotNull(ptr); }
    6071       
    6172        T* get() const { return m_ptr; }
    6273
    63         void clear() { if (T* ptr = m_ptr) ptr->deref(); m_ptr = 0; }
     74        void clear() { T* ptr = m_ptr; derefIfNotNull(ptr); m_ptr = 0; }
    6475        T* releaseRef() const { T* tmp = m_ptr; m_ptr = 0; return tmp; }
    6576
     
    144155    {
    145156        T* optr = o.get();
    146         if (optr)
    147             optr->ref();
     157        refIfNotNull(optr);
    148158        T* ptr = m_ptr;
    149159        m_ptr = optr;
    150         if (ptr)
    151             ptr->deref();
     160        derefIfNotNull(ptr);
    152161        return *this;
    153162    }
     
    155164    template <typename T> inline PassRefPtr<T>& PassRefPtr<T>::operator=(T* optr)
    156165    {
    157         if (optr)
    158             optr->ref();
     166        refIfNotNull(optr);
    159167        T* ptr = m_ptr;
    160168        m_ptr = optr;
    161         if (ptr)
    162             ptr->deref();
     169        derefIfNotNull(ptr);
    163170        return *this;
    164171    }
     
    168175        T* ptr = m_ptr;
    169176        m_ptr = ref.releaseRef();
    170         if (ptr)
    171             ptr->deref();
     177        derefIfNotNull(ptr);
    172178        return *this;
    173179    }
     
    177183        T* ptr = m_ptr;
    178184        m_ptr = ref.releaseRef();
    179         if (ptr)
    180             ptr->deref();
     185        derefIfNotNull(ptr);
    181186        return *this;
    182187    }
Note: See TracChangeset for help on using the changeset viewer.