Changeset 115534 in webkit for trunk/Source/JavaScriptCore/heap/PassWeak.h
- Timestamp:
- Apr 27, 2012, 8:43:29 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/heap/PassWeak.h
r113508 r115534 51 51 }; 52 52 53 template<typename Base> class WeakImplAccessor<Base, Unknown> {54 public:55 typedef JSValue GetType;56 57 const JSValue* operator->() const;58 const JSValue& operator*() const;59 GetType get() const;60 };61 62 53 template<typename T> class PassWeak : public WeakImplAccessor<PassWeak<T>, T> { 63 54 public: … … 67 58 PassWeak(); 68 59 PassWeak(std::nullptr_t); 69 PassWeak(JSGlobalData&, GetType = GetType(), WeakHandleOwner* = 0, void* context = 0);60 PassWeak(JSGlobalData&, GetType, WeakHandleOwner* = 0, void* context = 0); 70 61 71 62 // It somewhat breaks the type system to allow transfer of ownership out of … … 106 97 template<typename Base, typename T> inline typename WeakImplAccessor<Base, T>::GetType WeakImplAccessor<Base, T>::get() const 107 98 { 108 if (!static_cast<const Base*>(this)->m_impl || static_cast<const Base*>(this)->m_impl->state() != WeakImpl::Live || !static_cast<const Base*>(this)->m_impl->jsValue())99 if (!static_cast<const Base*>(this)->m_impl || static_cast<const Base*>(this)->m_impl->state() != WeakImpl::Live) 109 100 return GetType(); 110 101 return jsCast<T*>(static_cast<const Base*>(this)->m_impl->jsValue().asCell()); … … 118 109 #endif 119 110 120 template<typename Base> inline const JSValue* WeakImplAccessor<Base, Unknown>::operator->() const121 {122 ASSERT(static_cast<const Base*>(this)->m_impl && static_cast<const Base*>(this)->m_impl->state() == WeakImpl::Live);123 return &static_cast<const Base*>(this)->m_impl->jsValue();124 }125 126 template<typename Base> inline const JSValue& WeakImplAccessor<Base, Unknown>::operator*() const127 {128 ASSERT(static_cast<const Base*>(this)->m_impl && static_cast<const Base*>(this)->m_impl->state() == WeakImpl::Live);129 return static_cast<const Base*>(this)->m_impl->jsValue();130 }131 132 template<typename Base> inline typename WeakImplAccessor<Base, Unknown>::GetType WeakImplAccessor<Base, Unknown>::get() const133 {134 if (!static_cast<const Base*>(this)->m_impl || static_cast<const Base*>(this)->m_impl->state() != WeakImpl::Live)135 return GetType();136 return static_cast<const Base*>(this)->m_impl->jsValue();137 }138 139 111 template<typename T> inline PassWeak<T>::PassWeak() 140 112 : m_impl(0) … … 148 120 149 121 template<typename T> inline PassWeak<T>::PassWeak(JSGlobalData& globalData, typename PassWeak<T>::GetType getType, WeakHandleOwner* weakOwner, void* context) 150 : m_impl(g lobalData.heap.weakSet()->allocate(getType, weakOwner, context))122 : m_impl(getType ? globalData.heap.weakSet()->allocate(getType, weakOwner, context) : 0) 151 123 { 152 124 }
Note:
See TracChangeset
for help on using the changeset viewer.