Ignore:
Timestamp:
Oct 9, 2005, 3:56:30 PM (20 years ago)
Author:
darin
Message:

JavaScriptCore:

Reviewed by Maciej; some changes done after review.

Retested all tests to be sure nothing broke; added layout test for bug 5280.

  • kjs/config.h: Removed TIME_WITH_SYS_TIME define. Also set HAVE_SYS_TIMEB_H for the APPLE case (the latter is accurate but irrelevant).
  • kjs/date_object.h: Reformatted. Removed unnecessary include of "function_object.h". Moved declarations of helper classes and functions into the cpp file.
  • kjs/date_object.cpp: Removed code at top to define macros to use CoreFoundation instead of POSIX date functions. (KJS::styleFromArgString): Tweaked to return early instead of using a variable. (KJS::formatLocaleDate): Tweaked to check for undefined rather than checking argument count. (KJS::formatDate): Made parameter const. (KJS::formatDateUTCVariant): Ditto. (KJS::formatTime): Ditto. (KJS::DateProtoFuncImp::callAsFunction): Use gmtime_r and localtime_r instead of gmtime and localtime. (KJS::DateObjectImp::callAsFunction): Use localtime_r instead of localtime. (KJS::ymdhmsToSeconds): Renamed from ymdhms_to_seconds. Changed computation to avoid possible overflow if year is an extremely large or small number. (KJS::makeTime): Removed code to move large month numbers from tm_mon to tm_year; this was to accomodate CFGregorianDate, which is no longer used (and didn't handle negative values). (KJS::parseDate): Renamed from KRFCDate_parseDate; changed to return a value in milliseconds rather than in seconds. Reformatted the code. Changed to use UTF8String() instead of ascii(), since ascii() is not thread safe. Changed some variables back from int to long to avoid trouble if the result of strtol does not fit in an int (64-bit issue only).

LayoutTests:

  • fast/js/date-negative-setmonth-expected.txt: Added.
  • fast/js/date-negative-setmonth.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/date_object.h

    r10456 r10801  
    1 // -*- c-basic-offset: 2 -*-
    21/*
    32 *  This file is part of the KDE libraries
     
    2019 */
    2120
    22 #ifndef _DATE_OBJECT_H_
    23 #define _DATE_OBJECT_H_
     21#ifndef DATE_OBJECT_H
     22#define DATE_OBJECT_H
    2423
    2524#include "internal.h"
    26 #include "function_object.h"
    2725
    2826namespace KJS {
    2927
    30   class DateInstanceImp : public ObjectImp {
    31   public:
    32     DateInstanceImp(ObjectImp *proto);
     28    class FunctionPrototypeImp;
     29    class ObjectPrototypeImp;
    3330
    34     virtual const ClassInfo *classInfo() const { return &info; }
    35     static const ClassInfo info;
    36   };
     31    class DateInstanceImp : public ObjectImp {
     32    public:
     33        DateInstanceImp(ObjectImp *proto);
    3734
    38   /**
    39    * @internal
    40    *
    41    * The initial value of Date.prototype (and thus all objects created
    42    * with the Date constructor
    43    */
    44   class DatePrototypeImp : public DateInstanceImp {
    45   public:
    46     DatePrototypeImp(ExecState *exec, ObjectPrototypeImp *objectProto);
    47     bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
    48     virtual const ClassInfo *classInfo() const { return &info; }
    49     static const ClassInfo info;
    50   };
     35        virtual const ClassInfo *classInfo() const { return &info; }
     36        static const ClassInfo info;
     37    };
    5138
    52   /**
    53    * @internal
    54    *
    55    * Class to implement all methods that are properties of the
    56    * Date.prototype object
    57    */
    58   class DateProtoFuncImp : public InternalFunctionImp {
    59   public:
    60     DateProtoFuncImp(ExecState *exec, int i, int len);
     39    /**
     40     * @internal
     41     *
     42     * The initial value of Date.prototype (and thus all objects created
     43     * with the Date constructor
     44     */
     45    class DatePrototypeImp : public DateInstanceImp {
     46    public:
     47        DatePrototypeImp(ExecState *, ObjectPrototypeImp *);
     48        virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
     49        virtual const ClassInfo *classInfo() const { return &info; }
     50        static const ClassInfo info;
     51    };
    6152
    62     virtual bool implementsCall() const;
    63     virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
     53    /**
     54     * @internal
     55     *
     56     * The initial value of the the global variable's "Date" property
     57     */
     58    class DateObjectImp : public InternalFunctionImp {
     59    public:
     60        DateObjectImp(ExecState *, FunctionPrototypeImp *, DatePrototypeImp *);
    6461
     62        virtual bool implementsConstruct() const;
     63        virtual ObjectImp *construct(ExecState *, const List &args);
     64        virtual bool implementsCall() const;
     65        virtual ValueImp *callAsFunction(ExecState *, ObjectImp *thisObj, const List &args);
    6566
    66     Completion execute(const List &);
    67     enum { ToString, ToDateString, ToTimeString, ToLocaleString,
    68            ToLocaleDateString, ToLocaleTimeString, ValueOf, GetTime,
    69            GetFullYear, GetMonth, GetDate, GetDay, GetHours, GetMinutes,
    70            GetSeconds, GetMilliSeconds, GetTimezoneOffset, SetTime,
    71            SetMilliSeconds, SetSeconds, SetMinutes, SetHours, SetDate,
    72            SetMonth, SetFullYear, ToUTCString,
    73            // non-normative properties (Appendix B)
    74            GetYear, SetYear, ToGMTString };
    75   private:
    76     int id;
    77     bool utc;
    78   };
    79 
    80   /**
    81    * @internal
    82    *
    83    * The initial value of the the global variable's "Date" property
    84    */
    85   class DateObjectImp : public InternalFunctionImp {
    86   public:
    87     DateObjectImp(ExecState *exec,
    88                   FunctionPrototypeImp *funcProto,
    89                   DatePrototypeImp *dateProto);
    90 
    91     virtual bool implementsConstruct() const;
    92     virtual ObjectImp *construct(ExecState *exec, const List &args);
    93     virtual bool implementsCall() const;
    94     virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    95 
    96     Completion execute(const List &);
    97     ObjectImp *construct(const List &);
    98   };
    99 
    100   /**
    101    * @internal
    102    *
    103    * Class to implement all methods that are properties of the
    104    * Date object
    105    */
    106   class DateObjectFuncImp : public InternalFunctionImp {
    107   public:
    108     DateObjectFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto,
    109                       int i, int len);
    110 
    111     virtual bool implementsCall() const;
    112     virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args);
    113 
    114     enum { Parse, UTC };
    115   private:
    116     int id;
    117   };
    118 
    119   // helper functions
    120   double parseDate(const UString &u);
    121   double KRFCDate_parseDate(const UString &_date);
    122   double timeClip(double t);
    123   double makeTime(struct tm *t, double milli, bool utc);
     67        Completion execute(const List &);
     68        ObjectImp *construct(const List &);
     69    };
    12470
    12571} // namespace
Note: See TracChangeset for help on using the changeset viewer.