Changeset 43122 in webkit for trunk/JavaScriptCore/runtime/JSValue.h
- Timestamp:
- May 1, 2009, 3:43:39 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSValue.h
r43121 r43122 46 46 enum PreferredPrimitiveType { NoPreference, PreferNumber, PreferString }; 47 47 48 typedef void* EncodedJSValue Ptr;49 50 class JSValue Ptr{48 typedef void* EncodedJSValue; 49 50 class JSValue { 51 51 friend class JSImmediate; 52 52 53 static JSValue PtrmakeImmediate(intptr_t value)53 static JSValue makeImmediate(intptr_t value) 54 54 { 55 return JSValue Ptr(reinterpret_cast<JSCell*>(value));55 return JSValue(reinterpret_cast<JSCell*>(value)); 56 56 } 57 57 … … 68 68 enum JSFalseTag { JSFalse }; 69 69 70 static EncodedJSValue Ptr encode(JSValuePtrvalue);71 static JSValue Ptr decode(EncodedJSValuePtrptr);72 73 JSValue Ptr();74 JSValue Ptr(ImpossibleValueTag);75 JSValue Ptr(JSNullTag);76 JSValue Ptr(JSUndefinedTag);77 JSValue Ptr(JSTrueTag);78 JSValue Ptr(JSFalseTag);79 JSValue Ptr(JSCell* ptr);80 JSValue Ptr(const JSCell* ptr);70 static EncodedJSValue encode(JSValue value); 71 static JSValue decode(EncodedJSValue ptr); 72 73 JSValue(); 74 JSValue(ImpossibleValueTag); 75 JSValue(JSNullTag); 76 JSValue(JSUndefinedTag); 77 JSValue(JSTrueTag); 78 JSValue(JSFalseTag); 79 JSValue(JSCell* ptr); 80 JSValue(const JSCell* ptr); 81 81 82 82 operator bool() const; 83 bool operator==(const JSValue Ptrother) const;84 bool operator!=(const JSValue Ptrother) const;83 bool operator==(const JSValue other) const; 84 bool operator!=(const JSValue other) const; 85 85 86 86 // Querying the type. … … 113 113 114 114 // Basic conversions. 115 JSValue PtrtoPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;116 bool getPrimitiveNumber(ExecState*, double& number, JSValue Ptr&);115 JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const; 116 bool getPrimitiveNumber(ExecState*, double& number, JSValue&); 117 117 118 118 bool toBoolean(ExecState*) const; … … 121 121 // been set in the ExecState already. 122 122 double toNumber(ExecState*) const; 123 JSValue PtrtoJSNumber(ExecState*) const; // Fast path for when you expect that the value is an immediate number.123 JSValue toJSNumber(ExecState*) const; // Fast path for when you expect that the value is an immediate number. 124 124 UString toString(ExecState*) const; 125 125 JSObject* toObject(ExecState*) const; … … 144 144 bool isUInt32Fast() const; 145 145 uint32_t getUInt32Fast() const; 146 static JSValue PtrmakeInt32Fast(int32_t);147 static bool areBothInt32Fast(JSValue Ptr, JSValuePtr);146 static JSValue makeInt32Fast(int32_t); 147 static bool areBothInt32Fast(JSValue, JSValue); 148 148 149 149 // Floating point conversions (this is a convenience method for webcore; … … 156 156 157 157 // Object operations, with the toObject operation included. 158 JSValue Ptrget(ExecState*, const Identifier& propertyName) const;159 JSValue Ptrget(ExecState*, const Identifier& propertyName, PropertySlot&) const;160 JSValue Ptrget(ExecState*, unsigned propertyName) const;161 JSValue Ptrget(ExecState*, unsigned propertyName, PropertySlot&) const;162 void put(ExecState*, const Identifier& propertyName, JSValue Ptr, PutPropertySlot&);163 void put(ExecState*, unsigned propertyName, JSValue Ptr);158 JSValue get(ExecState*, const Identifier& propertyName) const; 159 JSValue get(ExecState*, const Identifier& propertyName, PropertySlot&) const; 160 JSValue get(ExecState*, unsigned propertyName) const; 161 JSValue get(ExecState*, unsigned propertyName, PropertySlot&) const; 162 void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&); 163 void put(ExecState*, unsigned propertyName, JSValue); 164 164 165 165 bool needsThisConversion() const; … … 168 168 JSString* toThisJSString(ExecState*); 169 169 170 static bool equal(ExecState* exec, JSValue Ptr v1, JSValuePtrv2);171 static bool equalSlowCase(ExecState* exec, JSValue Ptr v1, JSValuePtrv2);172 static bool equalSlowCaseInline(ExecState* exec, JSValue Ptr v1, JSValuePtrv2);173 static bool strictEqual(JSValue Ptr v1, JSValuePtrv2);174 static bool strictEqualSlowCase(JSValue Ptr v1, JSValuePtrv2);175 static bool strictEqualSlowCaseInline(JSValue Ptr v1, JSValuePtrv2);176 177 JSValue PtrgetJSNumber(); // noValue() if this is not a JSNumber or number object170 static bool equal(ExecState* exec, JSValue v1, JSValue v2); 171 static bool equalSlowCase(ExecState* exec, JSValue v1, JSValue v2); 172 static bool equalSlowCaseInline(ExecState* exec, JSValue v1, JSValue v2); 173 static bool strictEqual(JSValue v1, JSValue v2); 174 static bool strictEqualSlowCase(JSValue v1, JSValue v2); 175 static bool strictEqualSlowCaseInline(JSValue v1, JSValue v2); 176 177 JSValue getJSNumber(); // noValue() if this is not a JSNumber or number object 178 178 179 179 bool isCell() const; … … 181 181 182 182 private: 183 inline const JSValue PtrasValue() const { return *this; }183 inline const JSValue asValue() const { return *this; } 184 184 185 185 bool isDoubleNumber() const; … … 190 190 191 191 // Stand-alone helper functions. 192 inline JSValue PtrnoValue()193 { 194 return JSValue Ptr();195 } 196 197 inline JSValue PtrjsImpossibleValue()198 { 199 return JSValue Ptr(JSValuePtr::ImpossibleValue);200 } 201 202 inline JSValue PtrjsNull()203 { 204 return JSValue Ptr(JSValuePtr::JSNull);205 } 206 207 inline JSValue PtrjsUndefined()208 { 209 return JSValue Ptr(JSValuePtr::JSUndefined);210 } 211 212 inline JSValue PtrjsBoolean(bool b)213 { 214 return b ? JSValue Ptr(JSValuePtr::JSTrue) : JSValuePtr(JSValuePtr::JSFalse);215 } 216 217 inline bool operator==(const JSValue Ptr a, const JSCell* b) { return a == JSValuePtr(b); }218 inline bool operator==(const JSCell* a, const JSValue Ptr b) { return JSValuePtr(a) == b; }219 220 inline bool operator!=(const JSValue Ptr a, const JSCell* b) { return a != JSValuePtr(b); }221 inline bool operator!=(const JSCell* a, const JSValue Ptr b) { return JSValuePtr(a) != b; }222 223 // JSValue Ptrmember functions.224 inline EncodedJSValue Ptr JSValuePtr::encode(JSValuePtrvalue)225 { 226 return reinterpret_cast<EncodedJSValue Ptr>(value.m_ptr);227 } 228 229 inline JSValue Ptr JSValuePtr::decode(EncodedJSValuePtrptr)230 { 231 return JSValue Ptr(reinterpret_cast<JSCell*>(ptr));232 } 233 234 inline JSValue Ptr::JSValuePtr()192 inline JSValue noValue() 193 { 194 return JSValue(); 195 } 196 197 inline JSValue jsImpossibleValue() 198 { 199 return JSValue(JSValue::ImpossibleValue); 200 } 201 202 inline JSValue jsNull() 203 { 204 return JSValue(JSValue::JSNull); 205 } 206 207 inline JSValue jsUndefined() 208 { 209 return JSValue(JSValue::JSUndefined); 210 } 211 212 inline JSValue jsBoolean(bool b) 213 { 214 return b ? JSValue(JSValue::JSTrue) : JSValue(JSValue::JSFalse); 215 } 216 217 inline bool operator==(const JSValue a, const JSCell* b) { return a == JSValue(b); } 218 inline bool operator==(const JSCell* a, const JSValue b) { return JSValue(a) == b; } 219 220 inline bool operator!=(const JSValue a, const JSCell* b) { return a != JSValue(b); } 221 inline bool operator!=(const JSCell* a, const JSValue b) { return JSValue(a) != b; } 222 223 // JSValue member functions. 224 inline EncodedJSValue JSValue::encode(JSValue value) 225 { 226 return reinterpret_cast<EncodedJSValue>(value.m_ptr); 227 } 228 229 inline JSValue JSValue::decode(EncodedJSValue ptr) 230 { 231 return JSValue(reinterpret_cast<JSCell*>(ptr)); 232 } 233 234 inline JSValue::JSValue() 235 235 : m_ptr(0) 236 236 { 237 237 } 238 238 239 inline JSValue Ptr::JSValuePtr(JSCell* ptr)239 inline JSValue::JSValue(JSCell* ptr) 240 240 : m_ptr(ptr) 241 241 { 242 242 } 243 243 244 inline JSValue Ptr::JSValuePtr(const JSCell* ptr)244 inline JSValue::JSValue(const JSCell* ptr) 245 245 : m_ptr(const_cast<JSCell*>(ptr)) 246 246 { 247 247 } 248 248 249 inline JSValue Ptr::operator bool() const249 inline JSValue::operator bool() const 250 250 { 251 251 return m_ptr; 252 252 } 253 253 254 inline bool JSValue Ptr::operator==(const JSValuePtrother) const254 inline bool JSValue::operator==(const JSValue other) const 255 255 { 256 256 return m_ptr == other.m_ptr; 257 257 } 258 258 259 inline bool JSValue Ptr::operator!=(const JSValuePtrother) const259 inline bool JSValue::operator!=(const JSValue other) const 260 260 { 261 261 return m_ptr != other.m_ptr; 262 262 } 263 263 264 inline bool JSValue Ptr::isUndefined() const264 inline bool JSValue::isUndefined() const 265 265 { 266 266 return asValue() == jsUndefined(); 267 267 } 268 268 269 inline bool JSValue Ptr::isNull() const269 inline bool JSValue::isNull() const 270 270 { 271 271 return asValue() == jsNull();
Note:
See TracChangeset
for help on using the changeset viewer.