Changeset 60655 in webkit
- Timestamp:
- Jun 3, 2010 10:57:42 PM (14 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r60650 r60655 1 2010-06-03 Jedrzej Nowacki <jedrzej.nowacki@nokia.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 New states in QScriptValuePrivate. 6 7 The CSpecial state was divided into CNull and CUndefined. It simplify 8 the QScriptValue code by avoiding a few "cast" and "if". 9 Moreover the MSVS compiler didn't like casting between a double and an 10 enum which is avoided now. 11 12 [Qt] The QScriptValuePrivate::CSpecial is too generic. 13 https://bugs.webkit.org/show_bug.cgi?id=40067 14 15 * qt/api/qscriptvalue_p.h: 16 (QScriptValuePrivate::): 17 (QScriptValuePrivate::QScriptValuePrivate): 18 (QScriptValuePrivate::isNull): 19 (QScriptValuePrivate::isUndefined): 20 (QScriptValuePrivate::toString): 21 (QScriptValuePrivate::toNumber): 22 (QScriptValuePrivate::toBool): 23 (QScriptValuePrivate::toObject): 24 (QScriptValuePrivate::assignEngine): 25 (QScriptValuePrivate::isNumberBased): 26 1 27 2010-06-03 Gavin Barraclough <barraclough@apple.com> 2 28 -
trunk/JavaScriptCore/qt/api/qscriptvalue_p.h
r60585 r60655 51 51 CBool -> QSVP is created from bool and no JSC engine has been associated yet. Current value is kept 52 52 in m_number 53 C Special -> QSVP is Undefined or Null, but a JSC engine hasn't been associated yet, current value54 is kept in m_number (cast of QScriptValue::SpecialValue)53 CNull -> QSVP is null, but a JSC engine hasn't been associated yet. 54 CUndefined -> QSVP is undefined, but a JSC engine hasn't been associated yet. 55 55 JSValue -> QSVP is associated with engine, but there is no information about real type, the state 56 56 have really short live cycle. Normally it is created as a function call result. … … 126 126 CNumber, 127 127 CBool, 128 CSpecial, 128 CNull, 129 CUndefined, 129 130 JSValue = 0x2000, // JS values are equal or higher then this value. 130 131 JSPrimitive, … … 207 208 208 209 QScriptValuePrivate::QScriptValuePrivate(QScriptValue::SpecialValue value) 209 : m_state(CSpecial) 210 , m_number(value) 210 : m_state(value == QScriptValue::NullValue ? CNull : CUndefined) 211 211 , m_value(0) 212 212 { … … 326 326 { 327 327 switch (m_state) { 328 case C Special:329 return m_number == static_cast<int>(QScriptValue::NullValue);328 case CNull: 329 return true; 330 330 case JSValue: 331 331 if (refinedJSValue() != JSPrimitive) … … 358 358 { 359 359 switch (m_state) { 360 case C Special:361 return m_number == static_cast<int>(QScriptValue::UndefinedValue);360 case CUndefined: 361 return true; 362 362 case JSValue: 363 363 if (refinedJSValue() != JSPrimitive) … … 423 423 case CNumber: 424 424 return QScriptConverter::toString(m_number); 425 case CSpecial: 426 return m_number == QScriptValue::NullValue ? QString::fromLatin1("null") : QString::fromLatin1("undefined"); 425 case CNull: 426 return QString::fromLatin1("null"); 427 case CUndefined: 428 return QString::fromLatin1("undefined"); 427 429 case JSValue: 428 430 case JSPrimitive: … … 447 449 case CBool: 448 450 return m_number ? 1 : 0; 451 case CNull: 449 452 case Invalid: 450 453 return 0; 451 case C Special:452 return m_number == QScriptValue::NullValue ? 0 :qQNaN();454 case CUndefined: 455 return qQNaN(); 453 456 case CString: 454 457 bool ok; … … 481 484 return m_number; 482 485 case Invalid: 483 case CSpecial: 486 case CNull: 487 case CUndefined: 484 488 return false; 485 489 case CString: … … 537 541 switch (m_state) { 538 542 case Invalid: 539 case CSpecial: 543 case CNull: 544 case CUndefined: 540 545 return new QScriptValuePrivate; 541 546 case CString: … … 675 680 value = engine->makeJSValue(m_number); 676 681 break; 677 case CSpecial: 678 value = engine->makeJSValue(static_cast<QScriptValue::SpecialValue>(m_number)); 682 case CNull: 683 value = engine->makeJSValue(QScriptValue::NullValue); 684 break; 685 case CUndefined: 686 value = engine->makeJSValue(QScriptValue::UndefinedValue); 679 687 break; 680 688 default: … … 804 812 Returns true if current value of QSV is placed in m_number. 805 813 */ 806 bool QScriptValuePrivate::isNumberBased() const { return !isJSBased() && !isStringBased() && m_state != Invalid; }814 bool QScriptValuePrivate::isNumberBased() const { return m_state == CNumber || m_state == CBool; } 807 815 808 816 /*!
Note: See TracChangeset
for help on using the changeset viewer.