1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
2 /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is [Open Source Virtual Machine.].
18 * The Initial Developer of the Original Code is
19 * Adobe System Incorporated.
20 * Portions created by the Initial Developer are Copyright (C) 2004-2006
21 * the Initial Developer. All Rights Reserved.
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef __avmplus_DateObject__
41 #define __avmplus_DateObject__
47 * The DateObject class is the C++ implementation of instances
48 * of the Date class in the ECMA-262 Specification.
50 class GC_AS3_EXACT(DateObject
, ScriptObject
)
54 * This variant is only used for creating the prototype
56 DateObject(VTable
* ivtable
, ScriptObject
*objectPrototype
)
57 : ScriptObject(ivtable
, objectPrototype
)
59 SAMPLE_FRAME("Date", core());
60 AvmAssert(traits()->getSizeOfInstance() == sizeof(DateObject
));
61 date
.setTime(MathUtils::kNaN
); // Date.prototype should be the "Invalid Date"
65 * This variant is used for creating all dates other
68 DateObject(DateClass
*type
, const Date
& date
)
69 : ScriptObject(type
->ivtable(), type
->prototypePtr())
71 AvmAssert(traits()->getSizeOfInstance() == sizeof(DateObject
));
76 REALLY_INLINE
static DateObject
* create(MMgc::GC
* gc
, VTable
* ivtable
, ScriptObject
* prototype
)
78 return new (gc
, MMgc::kExact
, ivtable
->getExtraSize()) DateObject(ivtable
, prototype
);
81 REALLY_INLINE
static DateObject
* create(MMgc::GC
* gc
, DateClass
* type
, const Date
& date
)
83 return new (gc
, MMgc::kExact
, type
->ivtable()->getExtraSize()) DateObject(type
, date
);
86 // renamed to avoid hiding ScriptObject::toString
87 Stringp
_toString(int index
);
89 double _setTime(double value
);
90 double _get(int index
);
91 double _set(int index
, Atom
* argv
, int argc
);
93 double AS3_getUTCFullYear() { return _get(Date::kUTCFullYear
); }
94 double AS3_getUTCMonth() { return _get(Date::kUTCMonth
); }
95 double AS3_getUTCDate() { return _get(Date::kUTCDate
); }
96 double AS3_getUTCDay() { return _get(Date::kUTCDay
); }
97 double AS3_getUTCHours() { return _get(Date::kUTCHours
); }
98 double AS3_getUTCMinutes() { return _get(Date::kUTCMinutes
); }
99 double AS3_getUTCSeconds() { return _get(Date::kUTCSeconds
); }
100 double AS3_getUTCMilliseconds() { return _get(Date::kUTCMilliseconds
); }
101 double AS3_getFullYear() { return _get(Date::kFullYear
); }
102 double AS3_getMonth() { return _get(Date::kMonth
); }
103 double AS3_getDate() { return _get(Date::kDate
); }
104 double AS3_getDay() { return _get(Date::kDay
); }
105 double AS3_getHours() { return _get(Date::kHours
); }
106 double AS3_getMinutes() { return _get(Date::kMinutes
); }
107 double AS3_getSeconds() { return _get(Date::kSeconds
); }
108 double AS3_getMilliseconds() { return _get(Date::kMilliseconds
); }
109 double AS3_getTimezoneOffset() { return _get(Date::kTimezoneOffset
); }
110 double AS3_getTime() { return _get(Date::kTime
); }
112 double _setUTCFullYear(Atom
* argv
, int argc
) { return _set(-1, argv
, argc
); }
113 double _setUTCMonth(Atom
* argv
, int argc
) { return _set(-2, argv
, argc
); }
114 double _setUTCDate(Atom
* argv
, int argc
) { return _set(-3, argv
, argc
); }
115 double _setUTCHours(Atom
* argv
, int argc
) { return _set(-4, argv
, argc
); }
116 double _setUTCMinutes(Atom
* argv
, int argc
) { return _set(-5, argv
, argc
); }
117 double _setUTCSeconds(Atom
* argv
, int argc
) { return _set(-6, argv
, argc
); }
118 double _setUTCMilliseconds(Atom
* argv
, int argc
) { return _set(-7, argv
, argc
); }
120 double _setFullYear(Atom
* argv
, int argc
) { return _set(1, argv
, argc
); }
121 double _setMonth(Atom
* argv
, int argc
) { return _set(2, argv
, argc
); }
122 double _setDate(Atom
* argv
, int argc
) { return _set(3, argv
, argc
); }
123 double _setHours(Atom
* argv
, int argc
) { return _set(4, argv
, argc
); }
124 double _setMinutes(Atom
* argv
, int argc
) { return _set(5, argv
, argc
); }
125 double _setSeconds(Atom
* argv
, int argc
) { return _set(6, argv
, argc
); }
126 double _setMilliseconds(Atom
* argv
, int argc
) { return _set(7, argv
, argc
); }
128 #ifdef AVMPLUS_VERBOSE
130 PrintWriter
& print(PrintWriter
& prw
) const;
133 // ------------------------ DATA SECTION BEGIN
135 GC_DATA_BEGIN(DateObject
)
137 Date date
; // Not subject to GC, contains no pointers
139 GC_DATA_END(DateObject
)
142 DECLARE_SLOTS_DateObject
;
143 // ------------------------ DATA SECTION END
147 #endif /* __avmplus_DateObject__ */