Changeset 29217 in webkit


Ignore:
Timestamp:
Jan 6, 2008 10:06:43 PM (16 years ago)
Author:
eric@webkit.org
Message:

Reviewed by Sam.

Abstract all DateObject.set* functions in preparation for fixing:
http://bugs.webkit.org/show_bug.cgi?id=16753

SunSpider had random changes here and there but was overall a wash.

  • kjs/date_object.cpp: (KJS::fillStructuresUsingTimeArgs): (KJS::setNewValueFromTimeArgs): (KJS::setNewValueFromDateArgs): (KJS::DateProtoFuncSetMilliSeconds::callAsFunction): (KJS::DateProtoFuncSetUTCMilliseconds::callAsFunction): (KJS::DateProtoFuncSetSeconds::callAsFunction): (KJS::DateProtoFuncSetUTCSeconds::callAsFunction): (KJS::DateProtoFuncSetMinutes::callAsFunction): (KJS::DateProtoFuncSetUTCMinutes::callAsFunction): (KJS::DateProtoFuncSetHours::callAsFunction): (KJS::DateProtoFuncSetUTCHours::callAsFunction): (KJS::DateProtoFuncSetDate::callAsFunction): (KJS::DateProtoFuncSetUTCDate::callAsFunction): (KJS::DateProtoFuncSetMonth::callAsFunction): (KJS::DateProtoFuncSetUTCMonth::callAsFunction): (KJS::DateProtoFuncSetFullYear::callAsFunction): (KJS::DateProtoFuncSetUTCFullYear::callAsFunction):
Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r29215 r29217  
     12008-01-06  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Sam.
     4
     5        Abstract all DateObject.set* functions in preparation for fixing:
     6        http://bugs.webkit.org/show_bug.cgi?id=16753
     7       
     8        SunSpider had random changes here and there but was overall a wash.
     9
     10        * kjs/date_object.cpp:
     11        (KJS::fillStructuresUsingTimeArgs):
     12        (KJS::setNewValueFromTimeArgs):
     13        (KJS::setNewValueFromDateArgs):
     14        (KJS::DateProtoFuncSetMilliSeconds::callAsFunction):
     15        (KJS::DateProtoFuncSetUTCMilliseconds::callAsFunction):
     16        (KJS::DateProtoFuncSetSeconds::callAsFunction):
     17        (KJS::DateProtoFuncSetUTCSeconds::callAsFunction):
     18        (KJS::DateProtoFuncSetMinutes::callAsFunction):
     19        (KJS::DateProtoFuncSetUTCMinutes::callAsFunction):
     20        (KJS::DateProtoFuncSetHours::callAsFunction):
     21        (KJS::DateProtoFuncSetUTCHours::callAsFunction):
     22        (KJS::DateProtoFuncSetDate::callAsFunction):
     23        (KJS::DateProtoFuncSetUTCDate::callAsFunction):
     24        (KJS::DateProtoFuncSetMonth::callAsFunction):
     25        (KJS::DateProtoFuncSetUTCMonth::callAsFunction):
     26        (KJS::DateProtoFuncSetFullYear::callAsFunction):
     27        (KJS::DateProtoFuncSetUTCFullYear::callAsFunction):
     28
    1292008-01-06  Nikolas Zimmermann  <zimmermann@kde.org>
    230
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r28468 r29217  
    247247//
    248248// Format of member function: f([hour,] [min,] [sec,] [ms])
    249 static void fillStructuresUsingTimeArgs(ExecState *exec, const List &args, int maxArgs, double *ms, GregorianDateTime *t)
     249static void fillStructuresUsingTimeArgs(ExecState* exec, const List& args, int maxArgs, double* ms, GregorianDateTime* t)
    250250{
    251251    double milliseconds = 0;
     
    276276   
    277277    // milliseconds
    278     if (idx < numArgs) {
     278    if (idx < numArgs)
    279279        milliseconds += args[idx]->toNumber(exec);
    280     } else {
     280    else
    281281        milliseconds += *ms;
    282     }
    283282   
    284283    *ms = milliseconds;
     
    14451444}
    14461445
    1447 JSValue* DateProtoFuncSetMilliSeconds::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    1448 {
    1449     if (!thisObj->inherits(&DateInstance::info))
    1450         return throwError(exec, TypeError);
    1451 
    1452     const bool utc = false;
    1453 
    1454     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
     1446static JSValue* setNewValueFromTimeArgs(ExecState* exec, JSObject* thisObj, const List& args, int numArgsToUse, bool inputIsUTC)
     1447{
     1448    if (!thisObj->inherits(&DateInstance::info))
     1449        return throwError(exec, TypeError);
     1450
     1451    DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    14551452    JSValue* v = thisDateObj->internalValue();
    14561453    double milli = v->toNumber(exec);
     
    14591456
    14601457    GregorianDateTime t;
    1461     msToGregorianDateTime(milli, utc, t);
    1462 
    1463     fillStructuresUsingTimeArgs(exec, args, 1, &ms, &t);
    1464 
    1465     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
     1458    msToGregorianDateTime(milli, inputIsUTC, t);
     1459
     1460    fillStructuresUsingTimeArgs(exec, args, numArgsToUse, &ms, &t);
     1461
     1462    JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, inputIsUTC));
    14661463    thisDateObj->setInternalValue(result);
    14671464    return result;
    14681465}
    14691466
    1470 JSValue* DateProtoFuncSetUTCMilliseconds::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    1471 {
    1472     if (!thisObj->inherits(&DateInstance::info))
    1473         return throwError(exec, TypeError);
    1474 
    1475     const bool utc = true;
    1476 
    1477     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
     1467static JSValue* setNewValueFromDateArgs(ExecState* exec, JSObject* thisObj, const List& args, int numArgsToUse, bool inputIsUTC)
     1468{
     1469    if (!thisObj->inherits(&DateInstance::info))
     1470        return throwError(exec, TypeError);
     1471
     1472    DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    14781473    JSValue* v = thisDateObj->internalValue();
    14791474    double milli = v->toNumber(exec);
     
    14821477
    14831478    GregorianDateTime t;
    1484     msToGregorianDateTime(milli, utc, t);
    1485 
    1486     fillStructuresUsingTimeArgs(exec, args, 1, &ms, &t);
    1487 
    1488     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
     1479    msToGregorianDateTime(milli, inputIsUTC, t);
     1480
     1481    fillStructuresUsingDateArgs(exec, args, numArgsToUse, &ms, &t);
     1482
     1483    JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, inputIsUTC));
    14891484    thisDateObj->setInternalValue(result);
    14901485    return result;
    14911486}
    14921487
     1488JSValue* DateProtoFuncSetMilliSeconds::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     1489{
     1490    const bool inputIsUTC = false;
     1491    return setNewValueFromTimeArgs(exec, thisObj, args, 1, inputIsUTC);
     1492}
     1493
     1494JSValue* DateProtoFuncSetUTCMilliseconds::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     1495{
     1496    const bool inputIsUTC = true;
     1497    return setNewValueFromTimeArgs(exec, thisObj, args, 1, inputIsUTC);
     1498}
     1499
    14931500JSValue* DateProtoFuncSetSeconds::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    14941501{
    1495     if (!thisObj->inherits(&DateInstance::info))
    1496         return throwError(exec, TypeError);
    1497 
    1498     const bool utc = false;
    1499 
    1500     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1501     JSValue* v = thisDateObj->internalValue();
    1502     double milli = v->toNumber(exec);
    1503     double secs = floor(milli / msPerSecond);
    1504     double ms = milli - secs * msPerSecond;
    1505 
    1506     GregorianDateTime t;
    1507     msToGregorianDateTime(milli, utc, t);
    1508 
    1509     fillStructuresUsingTimeArgs(exec, args, 2, &ms, &t);
    1510 
    1511     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
    1512     thisDateObj->setInternalValue(result);
    1513     return result;
     1502    const bool inputIsUTC = false;
     1503    return setNewValueFromTimeArgs(exec, thisObj, args, 2, inputIsUTC);
    15141504}
    15151505
    15161506JSValue* DateProtoFuncSetUTCSeconds::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    15171507{
    1518     if (!thisObj->inherits(&DateInstance::info))
    1519         return throwError(exec, TypeError);
    1520 
    1521     const bool utc = true;
    1522 
    1523     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1524     JSValue* v = thisDateObj->internalValue();
    1525     double milli = v->toNumber(exec);
    1526     double secs = floor(milli / msPerSecond);
    1527     double ms = milli - secs * msPerSecond;
    1528 
    1529     GregorianDateTime t;
    1530     msToGregorianDateTime(milli, utc, t);
    1531 
    1532     fillStructuresUsingTimeArgs(exec, args, 2, &ms, &t);
    1533 
    1534     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
    1535     thisDateObj->setInternalValue(result);
    1536     return result;
     1508    const bool inputIsUTC = true;
     1509    return setNewValueFromTimeArgs(exec, thisObj, args, 2, inputIsUTC);
    15371510}
    15381511
    15391512JSValue* DateProtoFuncSetMinutes::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    15401513{
    1541     if (!thisObj->inherits(&DateInstance::info))
    1542         return throwError(exec, TypeError);
    1543 
    1544     const bool utc = false;
    1545 
    1546     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1547     JSValue* v = thisDateObj->internalValue();
    1548     double milli = v->toNumber(exec);
    1549     double secs = floor(milli / msPerSecond);
    1550     double ms = milli - secs * msPerSecond;
    1551 
    1552     GregorianDateTime t;
    1553     msToGregorianDateTime(milli, utc, t);
    1554 
    1555     fillStructuresUsingTimeArgs(exec, args, 3, &ms, &t);
    1556 
    1557     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
    1558     thisDateObj->setInternalValue(result);
    1559     return result;
     1514    const bool inputIsUTC = false;
     1515    return setNewValueFromTimeArgs(exec, thisObj, args, 3, inputIsUTC);
    15601516}
    15611517
    15621518JSValue* DateProtoFuncSetUTCMinutes::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    15631519{
    1564     if (!thisObj->inherits(&DateInstance::info))
    1565         return throwError(exec, TypeError);
    1566 
    1567     const bool utc = true;
    1568 
    1569     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1570     JSValue* v = thisDateObj->internalValue();
    1571     double milli = v->toNumber(exec);
    1572     double secs = floor(milli / msPerSecond);
    1573     double ms = milli - secs * msPerSecond;
    1574 
    1575     GregorianDateTime t;
    1576     msToGregorianDateTime(milli, utc, t);
    1577 
    1578     fillStructuresUsingTimeArgs(exec, args, 3, &ms, &t);
    1579 
    1580     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
    1581     thisDateObj->setInternalValue(result);
    1582     return result;
     1520    const bool inputIsUTC = true;
     1521    return setNewValueFromTimeArgs(exec, thisObj, args, 3, inputIsUTC);
    15831522}
    15841523
    15851524JSValue* DateProtoFuncSetHours::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    15861525{
    1587     if (!thisObj->inherits(&DateInstance::info))
    1588         return throwError(exec, TypeError);
    1589 
    1590     const bool utc = false;
    1591 
    1592     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1593     JSValue* v = thisDateObj->internalValue();
    1594     double milli = v->toNumber(exec);
    1595     double secs = floor(milli / msPerSecond);
    1596     double ms = milli - secs * msPerSecond;
    1597 
    1598     GregorianDateTime t;
    1599     msToGregorianDateTime(milli, utc, t);
    1600 
    1601     fillStructuresUsingTimeArgs(exec, args, 4, &ms, &t);
    1602 
    1603     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
    1604     thisDateObj->setInternalValue(result);
    1605     return result;
     1526    const bool inputIsUTC = false;
     1527    return setNewValueFromTimeArgs(exec, thisObj, args, 4, inputIsUTC);
    16061528}
    16071529
    16081530JSValue* DateProtoFuncSetUTCHours::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    16091531{
    1610     if (!thisObj->inherits(&DateInstance::info))
    1611         return throwError(exec, TypeError);
    1612 
    1613     const bool utc = true;
    1614 
    1615     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1616     JSValue* v = thisDateObj->internalValue();
    1617     double milli = v->toNumber(exec);
    1618     double secs = floor(milli / msPerSecond);
    1619     double ms = milli - secs * msPerSecond;
    1620 
    1621     GregorianDateTime t;
    1622     msToGregorianDateTime(milli, utc, t);
    1623 
    1624     fillStructuresUsingTimeArgs(exec, args, 4, &ms, &t);
    1625 
    1626     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
    1627     thisDateObj->setInternalValue(result);
    1628     return result;
     1532    const bool inputIsUTC = true;
     1533    return setNewValueFromTimeArgs(exec, thisObj, args, 4, inputIsUTC);
    16291534}
    16301535
    16311536JSValue* DateProtoFuncSetDate::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    16321537{
    1633     if (!thisObj->inherits(&DateInstance::info))
    1634         return throwError(exec, TypeError);
    1635 
    1636     const bool utc = false;
    1637 
    1638     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1639     JSValue* v = thisDateObj->internalValue();
    1640     double milli = v->toNumber(exec);
    1641     double secs = floor(milli / msPerSecond);
    1642     double ms = milli - secs * msPerSecond;
    1643 
    1644     GregorianDateTime t;
    1645     msToGregorianDateTime(milli, utc, t);
    1646 
    1647     fillStructuresUsingDateArgs(exec, args, 1, &ms, &t);
    1648 
    1649     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
    1650     thisDateObj->setInternalValue(result);
    1651     return result;
     1538    const bool inputIsUTC = false;
     1539    return setNewValueFromDateArgs(exec, thisObj, args, 1, inputIsUTC);
    16521540}
    16531541
    16541542JSValue* DateProtoFuncSetUTCDate::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    16551543{
    1656     if (!thisObj->inherits(&DateInstance::info))
    1657         return throwError(exec, TypeError);
    1658 
    1659     const bool utc = true;
    1660 
    1661     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1662     JSValue* v = thisDateObj->internalValue();
    1663     double milli = v->toNumber(exec);
    1664     double secs = floor(milli / msPerSecond);
    1665     double ms = milli - secs * msPerSecond;
    1666 
    1667     GregorianDateTime t;
    1668     msToGregorianDateTime(milli, utc, t);
    1669 
    1670     fillStructuresUsingDateArgs(exec, args, 1, &ms, &t);
    1671 
    1672     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
    1673     thisDateObj->setInternalValue(result);
    1674     return result;
     1544    const bool inputIsUTC = true;
     1545    return setNewValueFromDateArgs(exec, thisObj, args, 1, inputIsUTC);
    16751546}
    16761547
    16771548JSValue* DateProtoFuncSetMonth::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    16781549{
    1679     if (!thisObj->inherits(&DateInstance::info))
    1680         return throwError(exec, TypeError);
    1681 
    1682     const bool utc = false;
    1683 
    1684     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1685     JSValue* v = thisDateObj->internalValue();
    1686     double milli = v->toNumber(exec);
    1687     double secs = floor(milli / msPerSecond);
    1688     double ms = milli - secs * msPerSecond;
    1689 
    1690     GregorianDateTime t;
    1691     msToGregorianDateTime(milli, utc, t);
    1692 
    1693     fillStructuresUsingDateArgs(exec, args, 2, &ms, &t);   
    1694 
    1695     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
    1696     thisDateObj->setInternalValue(result);
    1697     return result;
     1550    const bool inputIsUTC = false;
     1551    return setNewValueFromDateArgs(exec, thisObj, args, 2, inputIsUTC);
    16981552}
    16991553
    17001554JSValue* DateProtoFuncSetUTCMonth::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    17011555{
    1702     if (!thisObj->inherits(&DateInstance::info))
    1703         return throwError(exec, TypeError);
    1704 
    1705     const bool utc = true;
    1706 
    1707     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1708     JSValue* v = thisDateObj->internalValue();
    1709     double milli = v->toNumber(exec);
    1710     double secs = floor(milli / msPerSecond);
    1711     double ms = milli - secs * msPerSecond;
    1712 
    1713     GregorianDateTime t;
    1714     msToGregorianDateTime(milli, utc, t);
    1715 
    1716     fillStructuresUsingDateArgs(exec, args, 2, &ms, &t);   
    1717 
    1718     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
    1719     thisDateObj->setInternalValue(result);
    1720     return result;
     1556    const bool inputIsUTC = true;
     1557    return setNewValueFromDateArgs(exec, thisObj, args, 2, inputIsUTC);
    17211558}
    17221559
    17231560JSValue* DateProtoFuncSetFullYear::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    17241561{
    1725     if (!thisObj->inherits(&DateInstance::info))
    1726         return throwError(exec, TypeError);
    1727 
    1728     const bool utc = false;
    1729 
    1730     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1731     JSValue* v = thisDateObj->internalValue();
    1732     double milli = v->toNumber(exec);
    1733     double secs = floor(milli / msPerSecond);
    1734     double ms = milli - secs * msPerSecond;
    1735 
    1736     GregorianDateTime t;
    1737     msToGregorianDateTime(milli, utc, t);
    1738 
    1739     fillStructuresUsingDateArgs(exec, args, 3, &ms, &t);
    1740 
    1741     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
    1742     thisDateObj->setInternalValue(result);
    1743     return result;
     1562    const bool inputIsUTC = false;
     1563    return setNewValueFromDateArgs(exec, thisObj, args, 3, inputIsUTC);
    17441564}
    17451565
    17461566JSValue* DateProtoFuncSetUTCFullYear::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    17471567{
    1748     if (!thisObj->inherits(&DateInstance::info))
    1749         return throwError(exec, TypeError);
    1750 
    1751     const bool utc = true;
    1752 
    1753     DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
    1754     JSValue* v = thisDateObj->internalValue();
    1755     double milli = v->toNumber(exec);
    1756     double secs = floor(milli / msPerSecond);
    1757     double ms = milli - secs * msPerSecond;
    1758 
    1759     GregorianDateTime t;
    1760     msToGregorianDateTime(milli, utc, t);
    1761 
    1762     fillStructuresUsingDateArgs(exec, args, 3, &ms, &t);
    1763 
    1764     JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc));
    1765     thisDateObj->setInternalValue(result);
    1766     return result;
     1568    const bool inputIsUTC = true;
     1569    return setNewValueFromDateArgs(exec, thisObj, args, 3, inputIsUTC);
    17671570}
    17681571
Note: See TracChangeset for help on using the changeset viewer.