Ignore:
Timestamp:
Dec 25, 2005, 1:22:35 AM (19 years ago)
Author:
mjs
Message:

Reviewed by Eric and Dave Hyatt.

This is a somewhat cheesy change. Having to use PassRefPtr_Ref creates ambiguities
in assignment and copy construction. And this makes life way easier and removes
the need for pass(). It is not really correct, but we pretty much never need a real
const PassRefPtr, and this takes care of things for PassRefPtr temporaries.

  • kjs/identifier.cpp: (KJS::Identifier::add): No more need for pass()
  • kjs/property_map.cpp: (KJS::PropertyMap::addSparseArrayPropertiesToReferenceList): No more need for pass()
  • kjs/ustring.cpp: (KJS::UString::Rep::create): Use adoptRef (KJS::UString::UString): No more need for pass (KJS::UString::append): No more need for pass (KJS::UString::substr): No more need for pass
  • kxmlcore/PassRefPtr.h: made m_ptr mutable (ugh) (KXMLCore::PassRefPtr::PassRefPtr): Take a const PassRefPtr reference (KXMLCore::PassRefPtr::release): Made this a const method (ugh) (KXMLCore::PassRefPtr::operator=): clean up appropriately (KXMLCore::adoptRef): Added this to use instead of PassRefPtr<T>::adopt, I think it makes the behavior more clear and it is less verbose. (KXMLCore::static_pointer_cast): use adoptRef (KXMLCore::const_pointer_cast): use adoptRef
  • kxmlcore/RefPtr.h: (KXMLCore::RefPtr::RefPtr): take const PassRefPtr& (KXMLCore::PassRefPtr::operator=): take const PassRefPtr&
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kxmlcore/RefPtr.h

    r11747 r11763  
    2929
    3030    template <typename T> class PassRefPtr;
    31     template <typename T> class PassRefPtr_Ref;
    3231
    3332    template <typename T> class RefPtr
     
    3736        RefPtr(T *ptr) : m_ptr(ptr) { if (ptr) ptr->ref(); }
    3837        RefPtr(const RefPtr& o) : m_ptr(o.m_ptr) { if (T *ptr = m_ptr) ptr->ref(); }
    39         template <typename U> RefPtr(PassRefPtr<U>&);
    40         template <typename U> RefPtr(PassRefPtr_Ref<U>);
     38        // see comment in PassRefPtr.h for why this takes const reference
     39        template <typename U> RefPtr(const PassRefPtr<U>&);
    4140
    4241        ~RefPtr() { if (T *ptr = m_ptr) ptr->deref(); }
     
    5756        RefPtr& operator=(const RefPtr&);
    5857        RefPtr& operator=(T *);
    59         RefPtr& operator=(PassRefPtr<T>&);
    60         RefPtr& operator=(PassRefPtr_Ref<T>);
     58        RefPtr& operator=(const PassRefPtr<T>&);
    6159        template <typename U> RefPtr& operator=(const RefPtr<U>&);
    62         template <typename U> RefPtr& operator=(PassRefPtr<U>&);
    63         template <typename U> RefPtr& operator=(PassRefPtr_Ref<U>);
     60        template <typename U> RefPtr& operator=(const PassRefPtr<U>&);
    6461
    6562        void swap(RefPtr&);
     
    6966    };
    7067   
    71     template <typename T> template <typename U> inline RefPtr<T>::RefPtr(PassRefPtr_Ref<U> ref)
    72         : m_ptr(ref.m_ptr)
    73     {
    74     }
    75    
    76     template <typename T> template <typename U> inline RefPtr<T>::RefPtr(PassRefPtr<U>& o)
     68    template <typename T> template <typename U> inline RefPtr<T>::RefPtr(const PassRefPtr<U>& o)
    7769        : m_ptr(o.release())
    7870    {
     
    111103    }
    112104
    113     template <typename T> template <typename U> inline RefPtr<T>& RefPtr<T>::operator=(PassRefPtr_Ref<U> ref)
    114     {
    115         if (m_ptr)
    116             m_ptr->deref();
    117         m_ptr = ref.m_ptr;
    118         return *this;
    119     }
    120    
    121     template <typename T> inline RefPtr<T>& RefPtr<T>::operator=(PassRefPtr<T>& o)
     105    template <typename T> inline RefPtr<T>& RefPtr<T>::operator=(const PassRefPtr<T>& o)
    122106    {
    123107        if (m_ptr)
     
    127111    }
    128112
    129     template <typename T> inline RefPtr<T>& RefPtr<T>::operator=(PassRefPtr_Ref<T> ref)
    130     {
    131         if (m_ptr)
    132             m_ptr->deref();
    133         m_ptr = ref.m_ptr;
    134         return *this;
    135     }
    136    
    137     template <typename T> template <typename U> inline RefPtr<T>& RefPtr<T>::operator=(PassRefPtr<U>& o)
     113    template <typename T> template <typename U> inline RefPtr<T>& RefPtr<T>::operator=(const PassRefPtr<U>& o)
    138114    {
    139115        if (m_ptr)
Note: See TracChangeset for help on using the changeset viewer.