Changeset 37812 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Oct 23, 2008, 8:55:41 AM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSCell.h
r37799 r37812 30 30 namespace JSC { 31 31 32 class JSCell : Noncopyable {32 class JSCell : public JSValue { 33 33 friend class CTI; 34 34 friend class GetterSetter; … … 113 113 { 114 114 ASSERT(!JSImmediate::isImmediate(value)); 115 return reinterpret_cast<JSCell*>(value.payload());115 return static_cast<JSCell*>(value); 116 116 } 117 117 … … 168 168 return globalData->heap.allocate(size); 169 169 #endif 170 }171 172 // --- JSValuePtr inlines ----------------------------173 174 inline JSValuePtr::JSValuePtr(const JSCell* cell)175 : m_payload(reinterpret_cast<JSValue*>(const_cast<JSCell*>(cell)))176 {177 170 } 178 171 -
trunk/JavaScriptCore/kjs/JSImmediate.h
r37712 r37812 40 40 class UString; 41 41 42 class JSValuePtr { 43 public: 44 JSValuePtr() { } // uninitialized (not zero) 45 JSValuePtr(const JSValue* payload) : m_payload(const_cast<JSValue*>(payload)) { } 46 JSValuePtr(const JSCell*); 47 48 JSValue* payload() const { return m_payload; } 49 JSValue** payloadPtr() { return &m_payload; } 50 51 bool operator!() const { return !payload(); } 52 53 // This conversion operator allows implicit conversion to bool but not to other integer types. 54 typedef JSValue* JSValuePtr::*UnspecifiedBoolType; 55 operator UnspecifiedBoolType() const { return payload() ? &JSValuePtr::m_payload : 0; } 56 57 JSValue* operator->() const { return payload(); } 58 59 private: 60 JSValue* m_payload; 61 }; 42 typedef JSValue* JSValuePtr; 62 43 63 44 inline JSValuePtr noValue() { return static_cast<JSValue*>(0); } 64 inline void* asPointer(JSValuePtr value) { return value .payload(); }45 inline void* asPointer(JSValuePtr value) { return value; } 65 46 66 47 /* … … 322 303 static ALWAYS_INLINE uintptr_t rawValue(JSValuePtr v) 323 304 { 324 return reinterpret_cast<uintptr_t>(v .payload());305 return reinterpret_cast<uintptr_t>(v); 325 306 } 326 307 -
trunk/JavaScriptCore/kjs/JSValue.h
r37714 r37812 47 47 48 48 class JSValue : Noncopyable { 49 pr ivate:50 JSValue() ;51 ~JSValue();49 protected: 50 JSValue() { } 51 virtual ~JSValue() { } 52 52 53 53 public: … … 137 137 }; 138 138 139 bool operator==(JSValuePtr, JSValuePtr);140 bool operator!=(JSValuePtr, JSValuePtr);141 142 139 // These are identical logic to the JSValue functions above, and faster than jsNumber(number)->toInt32(). 143 140 int32_t toInt32(double); … … 242 239 } 243 240 244 inline bool operator==(JSValuePtr a, JSValuePtr b)245 {246 return a.payload() == b.payload();247 }248 249 inline bool operator!=(JSValuePtr a, JSValuePtr b)250 {251 return a.payload() != b.payload();252 }253 254 241 } // namespace JSC 255 242 -
trunk/JavaScriptCore/kjs/PropertySlot.h
r37712 r37812 45 45 } 46 46 47 explicit PropertySlot( JSValuePtrbase)48 : m_slotBase( base)47 explicit PropertySlot(const JSValue* base) 48 : m_slotBase(const_cast<JSValue*>(base)) 49 49 , m_offset(WTF::notFound) 50 50 { -
trunk/JavaScriptCore/kjs/protect.h
r37712 r37812 90 90 91 91 T* get() const { return m_ptr; } 92 operator JSValuePtr() const { return m_ptr; }93 92 operator T*() const { return m_ptr; } 94 93 T* operator->() const { return m_ptr; } … … 101 100 private: 102 101 T* m_ptr; 103 };104 105 template <> class ProtectedPtr<JSValuePtr> {106 public:107 ProtectedPtr() : m_ptr(0) { }108 ProtectedPtr(JSValuePtr);109 ProtectedPtr(const ProtectedPtr&);110 ~ProtectedPtr();111 112 template <class U> ProtectedPtr(const ProtectedPtr<U>&);113 114 JSValue* get() const { return m_ptr; }115 operator JSValuePtr() const { return m_ptr; }116 operator JSValue*() const { return m_ptr; }117 JSValue* operator->() const { return m_ptr; }118 119 bool operator!() const { return !m_ptr; }120 121 ProtectedPtr& operator=(JSValuePtr);122 ProtectedPtr& operator=(const ProtectedPtr&);123 124 private:125 JSValue* m_ptr;126 102 }; 127 103 … … 166 142 } 167 143 168 inline ProtectedPtr<JSValuePtr>::ProtectedPtr(JSValuePtr ptr)169 : m_ptr(ptr.payload())170 {171 gcProtectNullTolerant(m_ptr);172 }173 174 inline ProtectedPtr<JSValuePtr>::ProtectedPtr(const ProtectedPtr& o)175 : m_ptr(o.m_ptr)176 {177 gcProtectNullTolerant(m_ptr);178 }179 180 inline ProtectedPtr<JSValuePtr>::~ProtectedPtr()181 {182 gcUnprotectNullTolerant(m_ptr);183 }184 185 inline ProtectedPtr<JSValuePtr>& ProtectedPtr<JSValuePtr>::operator=(const ProtectedPtr& o)186 {187 JSValuePtr optr = o.m_ptr;188 gcProtectNullTolerant(optr);189 gcUnprotectNullTolerant(m_ptr);190 m_ptr = optr.payload();191 return *this;192 }193 194 inline ProtectedPtr<JSValuePtr>& ProtectedPtr<JSValuePtr>::operator=(JSValuePtr ptr)195 {196 gcProtectNullTolerant(ptr);197 gcUnprotectNullTolerant(m_ptr);198 m_ptr = ptr.payload();199 return *this;200 }201 202 144 template <class T> inline bool operator==(const ProtectedPtr<T>& a, const ProtectedPtr<T>& b) { return a.get() == b.get(); } 203 145 template <class T> inline bool operator==(const ProtectedPtr<T>& a, const T* b) { return a.get() == b; }
Note:
See TracChangeset
for help on using the changeset viewer.