Changeset 21736 in webkit
- Timestamp:
- May 24, 2007 4:28:28 PM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r21557 r21736 1 2007-05-24 Luciano Montanaro <mikelima@cirulla.net> 2 3 Reviewed by Darin 4 5 Patch for http://bugs.webkit.org/show_bug.cgi?id=13855 6 Port patch 666176 to JavaScriptCore 7 8 - Renamed JSValue::downcast() to JSValue::asCell() which makes the 9 function meaning cleaner. It's modeled after Harri Porten change in 10 KDE trunk. 11 12 * kjs/collector.cpp: 13 (KJS::Collector::protect): 14 (KJS::Collector::unprotect): 15 (KJS::Collector::collectOnMainThreadOnly): 16 * kjs/object.h: 17 (KJS::JSValue::isObject): 18 * kjs/string_object.cpp: 19 (KJS::StringProtoFunc::callAsFunction): 20 * kjs/value.h: 21 (KJS::JSValue::asCell): 22 (KJS::JSValue::isNumber): 23 (KJS::JSValue::isString): 24 (KJS::JSValue::isObject): 25 (KJS::JSValue::getNumber): 26 (KJS::JSValue::getString): 27 (KJS::JSValue::getObject): 28 (KJS::JSValue::getUInt32): 29 (KJS::JSValue::mark): 30 (KJS::JSValue::marked): 31 (KJS::JSValue::type): 32 (KJS::JSValue::toPrimitive): 33 (KJS::JSValue::toBoolean): 34 (KJS::JSValue::toNumber): 35 (KJS::JSValue::toString): 36 (KJS::JSValue::toObject): 37 1 38 2007-05-18 Holger Hans Peter Freyther <zecke@selfish.org> 2 39 -
trunk/JavaScriptCore/kjs/collector.cpp
r21048 r21736 631 631 return; 632 632 633 protectedValues().add(k-> downcast());633 protectedValues().add(k->asCell()); 634 634 } 635 635 … … 643 643 return; 644 644 645 protectedValues().remove(k-> downcast());645 protectedValues().remove(k->asCell()); 646 646 } 647 647 … … 655 655 return; 656 656 657 JSCell* cell = value-> downcast();657 JSCell* cell = value->asCell(); 658 658 cellBlock(cell)->collectOnMainThreadOnly.set(cellOffset(cell)); 659 659 ++mainThreadOnlyObjectCount; -
trunk/JavaScriptCore/kjs/object.h
r20310 r21736 543 543 inline bool JSValue::isObject(const ClassInfo *c) const 544 544 { 545 return !JSImmediate::isImmediate(this) && downcast()->isObject(c);545 return !JSImmediate::isImmediate(this) && asCell()->isObject(c); 546 546 } 547 547 -
trunk/JavaScriptCore/kjs/string_object.cpp
r20775 r21736 552 552 // Null instead of an empty array, because this matches 553 553 // other browsers and because Null is a false value. 554 result = jsNull(); 554 result = jsNull(); 555 555 } else { 556 556 result = exec->lexicalInterpreter()->builtinArray()->construct(exec, list); -
trunk/JavaScriptCore/kjs/value.h
r21047 r21736 57 57 class JSValue { 58 58 friend class JSCell; // so it can derive from this class 59 friend class Collector; // so it can call downcast()59 friend class Collector; // so it can call asCell() 60 60 61 61 private: … … 109 109 private: 110 110 // Implementation details. 111 JSCell * downcast();112 const JSCell * downcast() const;111 JSCell *asCell(); 112 const JSCell *asCell() const; 113 113 114 114 // Give a compile time error if we try to copy one of these. … … 234 234 } 235 235 236 inline JSCell *JSValue:: downcast()236 inline JSCell *JSValue::asCell() 237 237 { 238 238 ASSERT(!JSImmediate::isImmediate(this)); … … 240 240 } 241 241 242 inline const JSCell *JSValue:: downcast() const242 inline const JSCell *JSValue::asCell() const 243 243 { 244 244 ASSERT(!JSImmediate::isImmediate(this)); … … 268 268 inline bool JSValue::isNumber() const 269 269 { 270 return JSImmediate::isNumber(this) || !JSImmediate::isImmediate(this) && downcast()->isNumber();270 return JSImmediate::isNumber(this) || !JSImmediate::isImmediate(this) && asCell()->isNumber(); 271 271 } 272 272 273 273 inline bool JSValue::isString() const 274 274 { 275 return !JSImmediate::isImmediate(this) && downcast()->isString();275 return !JSImmediate::isImmediate(this) && asCell()->isString(); 276 276 } 277 277 278 278 inline bool JSValue::isObject() const 279 279 { 280 return !JSImmediate::isImmediate(this) && downcast()->isObject();280 return !JSImmediate::isImmediate(this) && asCell()->isObject(); 281 281 } 282 282 … … 302 302 return true; 303 303 } 304 return downcast()->getNumber(v);304 return asCell()->getNumber(v); 305 305 } 306 306 307 307 inline double JSValue::getNumber() const 308 308 { 309 return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : downcast()->getNumber();309 return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->getNumber(); 310 310 } 311 311 312 312 inline bool JSValue::getString(UString& s) const 313 313 { 314 return !JSImmediate::isImmediate(this) && downcast()->getString(s);314 return !JSImmediate::isImmediate(this) && asCell()->getString(s); 315 315 } 316 316 317 317 inline UString JSValue::getString() const 318 318 { 319 return JSImmediate::isImmediate(this) ? UString() : downcast()->getString();319 return JSImmediate::isImmediate(this) ? UString() : asCell()->getString(); 320 320 } 321 321 322 322 inline JSObject *JSValue::getObject() 323 323 { 324 return JSImmediate::isImmediate(this) ? 0 : downcast()->getObject();324 return JSImmediate::isImmediate(this) ? 0 : asCell()->getObject(); 325 325 } 326 326 327 327 inline const JSObject *JSValue::getObject() const 328 328 { 329 return JSImmediate::isImmediate(this) ? 0 : downcast()->getObject();329 return JSImmediate::isImmediate(this) ? 0 : asCell()->getObject(); 330 330 } 331 331 … … 339 339 return JSImmediate::isNumber(this); 340 340 } 341 return downcast()->getUInt32(v);341 return asCell()->getUInt32(v); 342 342 } 343 343 … … 345 345 { 346 346 ASSERT(!JSImmediate::isImmediate(this)); // callers should check !marked() before calling mark() 347 downcast()->mark();347 asCell()->mark(); 348 348 } 349 349 350 350 inline bool JSValue::marked() const 351 351 { 352 return JSImmediate::isImmediate(this) || downcast()->marked();352 return JSImmediate::isImmediate(this) || asCell()->marked(); 353 353 } 354 354 355 355 inline JSType JSValue::type() const 356 356 { 357 return JSImmediate::isImmediate(this) ? JSImmediate::type(this) : downcast()->type();357 return JSImmediate::isImmediate(this) ? JSImmediate::type(this) : asCell()->type(); 358 358 } 359 359 360 360 inline JSValue *JSValue::toPrimitive(ExecState *exec, JSType preferredType) const 361 361 { 362 return JSImmediate::isImmediate(this) ? const_cast<JSValue *>(this) : downcast()->toPrimitive(exec, preferredType);362 return JSImmediate::isImmediate(this) ? const_cast<JSValue *>(this) : asCell()->toPrimitive(exec, preferredType); 363 363 } 364 364 365 365 inline bool JSValue::toBoolean(ExecState *exec) const 366 366 { 367 return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : downcast()->toBoolean(exec);367 return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()->toBoolean(exec); 368 368 } 369 369 370 370 inline double JSValue::toNumber(ExecState *exec) const 371 371 { 372 return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : downcast()->toNumber(exec);372 return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->toNumber(exec); 373 373 } 374 374 375 375 inline UString JSValue::toString(ExecState *exec) const 376 376 { 377 return JSImmediate::isImmediate(this) ? JSImmediate::toString(this) : downcast()->toString(exec);377 return JSImmediate::isImmediate(this) ? JSImmediate::toString(this) : asCell()->toString(exec); 378 378 } 379 379 380 380 inline JSObject* JSValue::toObject(ExecState* exec) const 381 381 { 382 return JSImmediate::isImmediate(this) ? JSImmediate::toObject(this, exec) : downcast()->toObject(exec);382 return JSImmediate::isImmediate(this) ? JSImmediate::toObject(this, exec) : asCell()->toObject(exec); 383 383 } 384 384
Note: See TracChangeset
for help on using the changeset viewer.