Changeset 43121 in webkit for trunk/JavaScriptCore/runtime/JSValue.h
- Timestamp:
- May 1, 2009, 2:20:11 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSValue.h
r43103 r43121 62 62 63 63 public: 64 JSValuePtr() 65 : m_ptr(0) 66 { 67 } 68 69 JSValuePtr(JSCell* ptr) 70 : m_ptr(ptr) 71 { 72 } 73 74 JSValuePtr(const JSCell* ptr) 75 : m_ptr(const_cast<JSCell*>(ptr)) 76 { 77 } 78 79 operator bool() const 80 { 81 return m_ptr; 82 } 83 84 bool operator==(const JSValuePtr other) const 85 { 86 return m_ptr == other.m_ptr; 87 } 88 89 bool operator!=(const JSValuePtr other) const 90 { 91 return m_ptr != other.m_ptr; 92 } 93 94 static EncodedJSValuePtr encode(JSValuePtr value) 95 { 96 return reinterpret_cast<EncodedJSValuePtr>(value.m_ptr); 97 } 98 99 static JSValuePtr decode(EncodedJSValuePtr ptr) 100 { 101 return JSValuePtr(reinterpret_cast<JSCell*>(ptr)); 102 } 64 enum ImpossibleValueTag { ImpossibleValue }; 65 enum JSNullTag { JSNull }; 66 enum JSUndefinedTag { JSUndefined }; 67 enum JSTrueTag { JSTrue }; 68 enum JSFalseTag { JSFalse }; 69 70 static EncodedJSValuePtr encode(JSValuePtr value); 71 static JSValuePtr decode(EncodedJSValuePtr ptr); 72 73 JSValuePtr(); 74 JSValuePtr(ImpossibleValueTag); 75 JSValuePtr(JSNullTag); 76 JSValuePtr(JSUndefinedTag); 77 JSValuePtr(JSTrueTag); 78 JSValuePtr(JSFalseTag); 79 JSValuePtr(JSCell* ptr); 80 JSValuePtr(const JSCell* ptr); 81 82 operator bool() const; 83 bool operator==(const JSValuePtr other) const; 84 bool operator!=(const JSValuePtr other) const; 103 85 104 86 // Querying the type. … … 207 189 }; 208 190 191 // Stand-alone helper functions. 209 192 inline JSValuePtr noValue() 210 193 { 211 194 return JSValuePtr(); 195 } 196 197 inline JSValuePtr jsImpossibleValue() 198 { 199 return JSValuePtr(JSValuePtr::ImpossibleValue); 200 } 201 202 inline JSValuePtr jsNull() 203 { 204 return JSValuePtr(JSValuePtr::JSNull); 205 } 206 207 inline JSValuePtr jsUndefined() 208 { 209 return JSValuePtr(JSValuePtr::JSUndefined); 210 } 211 212 inline JSValuePtr jsBoolean(bool b) 213 { 214 return b ? JSValuePtr(JSValuePtr::JSTrue) : JSValuePtr(JSValuePtr::JSFalse); 212 215 } 213 216 … … 218 221 inline bool operator!=(const JSCell* a, const JSValuePtr b) { return JSValuePtr(a) != b; } 219 222 223 // JSValuePtr member functions. 224 inline EncodedJSValuePtr JSValuePtr::encode(JSValuePtr value) 225 { 226 return reinterpret_cast<EncodedJSValuePtr>(value.m_ptr); 227 } 228 229 inline JSValuePtr JSValuePtr::decode(EncodedJSValuePtr ptr) 230 { 231 return JSValuePtr(reinterpret_cast<JSCell*>(ptr)); 232 } 233 234 inline JSValuePtr::JSValuePtr() 235 : m_ptr(0) 236 { 237 } 238 239 inline JSValuePtr::JSValuePtr(JSCell* ptr) 240 : m_ptr(ptr) 241 { 242 } 243 244 inline JSValuePtr::JSValuePtr(const JSCell* ptr) 245 : m_ptr(const_cast<JSCell*>(ptr)) 246 { 247 } 248 249 inline JSValuePtr::operator bool() const 250 { 251 return m_ptr; 252 } 253 254 inline bool JSValuePtr::operator==(const JSValuePtr other) const 255 { 256 return m_ptr == other.m_ptr; 257 } 258 259 inline bool JSValuePtr::operator!=(const JSValuePtr other) const 260 { 261 return m_ptr != other.m_ptr; 262 } 263 264 inline bool JSValuePtr::isUndefined() const 265 { 266 return asValue() == jsUndefined(); 267 } 268 269 inline bool JSValuePtr::isNull() const 270 { 271 return asValue() == jsNull(); 272 } 273 220 274 } // namespace JSC 221 275
Note:
See TracChangeset
for help on using the changeset viewer.