KJS

date_object.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 1999-2000 Harri Porten ([email protected])
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  */
20 
21 #ifndef DATE_OBJECT_H
22 #define DATE_OBJECT_H
23 
24 #include "function.h"
25 #include "JSWrapperObject.h"
26 
27 struct tm;
28 
29 namespace KJS
30 {
31 
32 class FunctionPrototype;
33 class ObjectPrototype;
34 
35 class DateInstance : public JSWrapperObject
36 {
37 public:
38  DateInstance(JSObject *proto);
39 
40  bool getTime(tm &t, int &gmtoffset) const;
41  bool getUTCTime(tm &t) const;
42  bool getTime(double &ms, int &gmtoffset) const;
43  bool getUTCTime(double &ms) const;
44 
45  const ClassInfo *classInfo() const override
46  {
47  return &info;
48  }
49  static const ClassInfo info;
50 
51  JSObject *valueClone(Interpreter *targetCtx) const override;
52 };
53 
54 /**
55  * @internal
56  *
57  * The initial value of Date.prototype (and thus all objects created
58  * with the Date constructor
59  */
60 class DatePrototype : public DateInstance
61 {
62 public:
64  using KJS::JSObject::getOwnPropertySlot;
65  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
66  const ClassInfo *classInfo() const override
67  {
68  return &info;
69  }
70  static const ClassInfo info;
71 };
72 
73 /**
74  * @internal
75  *
76  * Class to implement all methods that are properties of the
77  * Date.prototype object
78  */
79 class DateProtoFunc : public InternalFunctionImp
80 {
81 public:
82  DateProtoFunc(ExecState *, int i, int len, const Identifier &date);
83 
84  JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args) override;
85 
86  enum { ToString, ToDateString, ToTimeString, ToLocaleString,
87  ToLocaleDateString, ToLocaleTimeString, ValueOf, GetTime,
88  GetFullYear, GetMonth, GetDate, GetDay, GetHours, GetMinutes,
89  GetSeconds, GetMilliSeconds, GetTimezoneOffset, SetTime,
90  SetMilliSeconds, SetSeconds, SetMinutes, SetHours, SetDate,
91  SetMonth, SetFullYear, ToUTCString, ToISOString, ToJSON,
92  // non-normative properties (Appendix B)
93  GetYear, SetYear, ToGMTString
94  };
95 private:
96  short id;
97  bool utc;
98 };
99 
100 /**
101  * @internal
102  *
103  * The initial value of the global variable's "Date" property
104  */
105 class DateObjectImp : public InternalFunctionImp
106 {
107  using InternalFunctionImp::construct;
108 public:
110 
111  bool implementsConstruct() const override;
112  JSObject *construct(ExecState *, const List &args) override;
113  JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args) override;
114 
115  Completion execute(const List &);
116  JSObject *construct(const List &);
117 };
118 
119 } // namespace
120 
121 #endif
Class Information.
Definition: object.h:48
JSValue is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects in...
Definition: value.h:58
Completion objects are used to convey the return status and value from functions.
Definition: completion.h:52
Represents the current state of script execution.
Definition: ExecState.h:53
Represents an Identifier for a Javascript object.
Definition: identifier.h:36
Native list type.
Definition: list.h:52
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Wed Sep 28 2022 03:51:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.