mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 884124 (part 5) - Add a DateObject class. r=jwalden.
--HG-- extra : rebase_source : bc39dcc8e2f8f2fcc71389a3ea199e264c445bc8
This commit is contained in:
parent
bd7ff1e568
commit
dfac293220
@ -64,6 +64,7 @@
|
|||||||
#include "ion/AsmJS.h"
|
#include "ion/AsmJS.h"
|
||||||
#include "ion/PcScriptCache.h"
|
#include "ion/PcScriptCache.h"
|
||||||
#include "js/CharacterEncoding.h"
|
#include "js/CharacterEncoding.h"
|
||||||
|
#include "vm/DateObject.h"
|
||||||
#include "vm/Debugger.h"
|
#include "vm/Debugger.h"
|
||||||
#include "vm/ErrorObject.h"
|
#include "vm/ErrorObject.h"
|
||||||
#include "vm/Interpreter.h"
|
#include "vm/Interpreter.h"
|
||||||
@ -1806,7 +1807,7 @@ static const JSStdName standard_class_atoms[] = {
|
|||||||
{js_InitObjectClass, EAGER_ATOM_AND_CLASP(Object)},
|
{js_InitObjectClass, EAGER_ATOM_AND_CLASP(Object)},
|
||||||
{js_InitArrayClass, EAGER_ATOM_AND_CLASP(Array)},
|
{js_InitArrayClass, EAGER_ATOM_AND_CLASP(Array)},
|
||||||
{js_InitBooleanClass, EAGER_ATOM_AND_OCLASP(Boolean)},
|
{js_InitBooleanClass, EAGER_ATOM_AND_OCLASP(Boolean)},
|
||||||
{js_InitDateClass, EAGER_ATOM_AND_CLASP(Date)},
|
{js_InitDateClass, EAGER_ATOM_AND_OCLASP(Date)},
|
||||||
{js_InitMathClass, EAGER_ATOM_AND_CLASP(Math)},
|
{js_InitMathClass, EAGER_ATOM_AND_CLASP(Math)},
|
||||||
{js_InitNumberClass, EAGER_ATOM_AND_OCLASP(Number)},
|
{js_InitNumberClass, EAGER_ATOM_AND_OCLASP(Number)},
|
||||||
{js_InitStringClass, EAGER_ATOM_AND_OCLASP(String)},
|
{js_InitStringClass, EAGER_ATOM_AND_OCLASP(String)},
|
||||||
|
@ -685,7 +685,7 @@ JSStructuredCloneWriter::startWrite(const Value &v)
|
|||||||
RegExpObject &reobj = obj->as<RegExpObject>();
|
RegExpObject &reobj = obj->as<RegExpObject>();
|
||||||
return out.writePair(SCTAG_REGEXP_OBJECT, reobj.getFlags()) &&
|
return out.writePair(SCTAG_REGEXP_OBJECT, reobj.getFlags()) &&
|
||||||
writeString(SCTAG_STRING, reobj.getSource());
|
writeString(SCTAG_STRING, reobj.getSource());
|
||||||
} else if (obj->isDate()) {
|
} else if (obj->is<DateObject>()) {
|
||||||
double d = js_DateGetMsecSinceEpoch(obj);
|
double d = js_DateGetMsecSinceEpoch(obj);
|
||||||
return out.writePair(SCTAG_DATE_OBJECT, 0) && out.writeDouble(d);
|
return out.writePair(SCTAG_DATE_OBJECT, 0) && out.writeDouble(d);
|
||||||
} else if (obj->isTypedArray()) {
|
} else if (obj->isTypedArray()) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -206,7 +206,6 @@ DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, JSBool *succeeded);
|
|||||||
} /* namespace js::baseops */
|
} /* namespace js::baseops */
|
||||||
|
|
||||||
extern Class ArrayClass;
|
extern Class ArrayClass;
|
||||||
extern Class DateClass;
|
|
||||||
extern Class IntlClass;
|
extern Class IntlClass;
|
||||||
extern Class JSONClass;
|
extern Class JSONClass;
|
||||||
extern Class MathClass;
|
extern Class MathClass;
|
||||||
@ -638,35 +637,6 @@ class JSObject : public js::ObjectImpl
|
|||||||
static inline void setArrayLength(JSContext *cx, js::HandleObject obj, uint32_t length);
|
static inline void setArrayLength(JSContext *cx, js::HandleObject obj, uint32_t length);
|
||||||
inline void setArrayLengthInt32(uint32_t length);
|
inline void setArrayLengthInt32(uint32_t length);
|
||||||
|
|
||||||
public:
|
|
||||||
/*
|
|
||||||
* Date-specific getters and setters.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static const uint32_t JSSLOT_DATE_UTC_TIME = 0;
|
|
||||||
static const uint32_t JSSLOT_DATE_TZA = 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Cached slots holding local properties of the date.
|
|
||||||
* These are undefined until the first actual lookup occurs
|
|
||||||
* and are reset to undefined whenever the date's time is modified.
|
|
||||||
*/
|
|
||||||
static const uint32_t JSSLOT_DATE_COMPONENTS_START = 2;
|
|
||||||
|
|
||||||
static const uint32_t JSSLOT_DATE_LOCAL_TIME = JSSLOT_DATE_COMPONENTS_START + 0;
|
|
||||||
static const uint32_t JSSLOT_DATE_LOCAL_YEAR = JSSLOT_DATE_COMPONENTS_START + 1;
|
|
||||||
static const uint32_t JSSLOT_DATE_LOCAL_MONTH = JSSLOT_DATE_COMPONENTS_START + 2;
|
|
||||||
static const uint32_t JSSLOT_DATE_LOCAL_DATE = JSSLOT_DATE_COMPONENTS_START + 3;
|
|
||||||
static const uint32_t JSSLOT_DATE_LOCAL_DAY = JSSLOT_DATE_COMPONENTS_START + 4;
|
|
||||||
static const uint32_t JSSLOT_DATE_LOCAL_HOURS = JSSLOT_DATE_COMPONENTS_START + 5;
|
|
||||||
static const uint32_t JSSLOT_DATE_LOCAL_MINUTES = JSSLOT_DATE_COMPONENTS_START + 6;
|
|
||||||
static const uint32_t JSSLOT_DATE_LOCAL_SECONDS = JSSLOT_DATE_COMPONENTS_START + 7;
|
|
||||||
|
|
||||||
static const uint32_t DATE_CLASS_RESERVED_SLOTS = JSSLOT_DATE_LOCAL_SECONDS + 1;
|
|
||||||
|
|
||||||
inline const js::Value &getDateUTCTime() const;
|
|
||||||
inline void setDateUTCTime(const js::Value &pthis);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*
|
/*
|
||||||
* Iterator-specific getters and setters.
|
* Iterator-specific getters and setters.
|
||||||
@ -1076,7 +1046,6 @@ class JSObject : public js::ObjectImpl
|
|||||||
|
|
||||||
/* Direct subtypes of JSObject: */
|
/* Direct subtypes of JSObject: */
|
||||||
inline bool isArray() const { return hasClass(&js::ArrayClass); }
|
inline bool isArray() const { return hasClass(&js::ArrayClass); }
|
||||||
inline bool isDate() const { return hasClass(&js::DateClass); }
|
|
||||||
inline bool isObject() const { return hasClass(&js::ObjectClass); }
|
inline bool isObject() const { return hasClass(&js::ObjectClass); }
|
||||||
using js::ObjectImpl::isProxy;
|
using js::ObjectImpl::isProxy;
|
||||||
inline bool isRegExpStatics() const { return hasClass(&js::RegExpStaticsClass); }
|
inline bool isRegExpStatics() const { return hasClass(&js::RegExpStaticsClass); }
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include "jswrapper.h"
|
#include "jswrapper.h"
|
||||||
|
|
||||||
|
#include "vm/DateObject.h"
|
||||||
#include "vm/NumberObject.h"
|
#include "vm/NumberObject.h"
|
||||||
#include "vm/Probes.h"
|
#include "vm/Probes.h"
|
||||||
#include "vm/StringObject.h"
|
#include "vm/StringObject.h"
|
||||||
@ -526,20 +527,6 @@ JSObject::ensureDenseElements(JSContext *cx, uint32_t index, uint32_t extra)
|
|||||||
return ED_OK;
|
return ED_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const js::Value &
|
|
||||||
JSObject::getDateUTCTime() const
|
|
||||||
{
|
|
||||||
JS_ASSERT(isDate());
|
|
||||||
return getFixedSlot(JSSLOT_DATE_UTC_TIME);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
|
||||||
JSObject::setDateUTCTime(const js::Value &time)
|
|
||||||
{
|
|
||||||
JS_ASSERT(isDate());
|
|
||||||
setFixedSlot(JSSLOT_DATE_UTC_TIME, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* static */ inline bool
|
/* static */ inline bool
|
||||||
JSObject::setSingletonType(JSContext *cx, js::HandleObject obj)
|
JSObject::setSingletonType(JSContext *cx, js::HandleObject obj)
|
||||||
{
|
{
|
||||||
@ -1317,7 +1304,7 @@ ObjectClassIs(HandleObject obj, ESClassValue classValue, JSContext *cx)
|
|||||||
case ESClass_Boolean: return obj->is<BooleanObject>();
|
case ESClass_Boolean: return obj->is<BooleanObject>();
|
||||||
case ESClass_RegExp: return obj->is<RegExpObject>();
|
case ESClass_RegExp: return obj->is<RegExpObject>();
|
||||||
case ESClass_ArrayBuffer: return obj->is<ArrayBufferObject>();
|
case ESClass_ArrayBuffer: return obj->is<ArrayBufferObject>();
|
||||||
case ESClass_Date: return obj->isDate();
|
case ESClass_Date: return obj->is<DateObject>();
|
||||||
}
|
}
|
||||||
JS_NOT_REACHED("bad classValue");
|
JS_NOT_REACHED("bad classValue");
|
||||||
return false;
|
return false;
|
||||||
|
79
js/src/vm/DateObject.h
Normal file
79
js/src/vm/DateObject.h
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||||
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef vm_DateObject_h_
|
||||||
|
#define vm_DateObject_h_
|
||||||
|
|
||||||
|
#include "jsobj.h"
|
||||||
|
|
||||||
|
#include "js/Value.h"
|
||||||
|
|
||||||
|
namespace js {
|
||||||
|
|
||||||
|
class DateTimeInfo;
|
||||||
|
|
||||||
|
class DateObject : public JSObject
|
||||||
|
{
|
||||||
|
static const uint32_t UTC_TIME_SLOT = 0;
|
||||||
|
static const uint32_t TZA_SLOT = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cached slots holding local properties of the date.
|
||||||
|
* These are undefined until the first actual lookup occurs
|
||||||
|
* and are reset to undefined whenever the date's time is modified.
|
||||||
|
*/
|
||||||
|
static const uint32_t COMPONENTS_START_SLOT = 2;
|
||||||
|
|
||||||
|
static const uint32_t LOCAL_TIME_SLOT = COMPONENTS_START_SLOT + 0;
|
||||||
|
static const uint32_t LOCAL_YEAR_SLOT = COMPONENTS_START_SLOT + 1;
|
||||||
|
static const uint32_t LOCAL_MONTH_SLOT = COMPONENTS_START_SLOT + 2;
|
||||||
|
static const uint32_t LOCAL_DATE_SLOT = COMPONENTS_START_SLOT + 3;
|
||||||
|
static const uint32_t LOCAL_DAY_SLOT = COMPONENTS_START_SLOT + 4;
|
||||||
|
static const uint32_t LOCAL_HOURS_SLOT = COMPONENTS_START_SLOT + 5;
|
||||||
|
static const uint32_t LOCAL_MINUTES_SLOT = COMPONENTS_START_SLOT + 6;
|
||||||
|
static const uint32_t LOCAL_SECONDS_SLOT = COMPONENTS_START_SLOT + 7;
|
||||||
|
|
||||||
|
static const uint32_t RESERVED_SLOTS = LOCAL_SECONDS_SLOT + 1;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static Class class_;
|
||||||
|
|
||||||
|
inline const js::Value &UTCTime() const {
|
||||||
|
return getFixedSlot(UTC_TIME_SLOT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set UTC time to a given time and invalidate cached local time.
|
||||||
|
void setUTCTime(double t, Value *vp = NULL);
|
||||||
|
|
||||||
|
inline double cachedLocalTime(DateTimeInfo *dtInfo);
|
||||||
|
|
||||||
|
// Cache the local time, year, month, and so forth of the object.
|
||||||
|
// If UTC time is not finite (e.g., NaN), the local time
|
||||||
|
// slots will be set to the UTC time without conversion.
|
||||||
|
void fillLocalTimeSlots(DateTimeInfo *dtInfo);
|
||||||
|
|
||||||
|
static JS_ALWAYS_INLINE bool getTime_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getYear_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getFullYear_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getUTCFullYear_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getMonth_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getUTCMonth_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getDate_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getUTCDate_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getDay_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getUTCDay_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getHours_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getUTCHours_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getMinutes_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getUTCMinutes_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getUTCSeconds_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getUTCMilliseconds_impl(JSContext *cx, CallArgs args);
|
||||||
|
static JS_ALWAYS_INLINE bool getTimezoneOffset_impl(JSContext *cx, CallArgs args);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace js
|
||||||
|
|
||||||
|
#endif // vm_DateObject_h_
|
@ -796,8 +796,8 @@ CloneObject(JSContext *cx, HandleObject srcObj, CloneMemory &clonedObjects)
|
|||||||
RegExpObject &reobj = srcObj->as<RegExpObject>();
|
RegExpObject &reobj = srcObj->as<RegExpObject>();
|
||||||
RootedAtom source(cx, reobj.getSource());
|
RootedAtom source(cx, reobj.getSource());
|
||||||
clone = RegExpObject::createNoStatics(cx, source, reobj.getFlags(), NULL);
|
clone = RegExpObject::createNoStatics(cx, source, reobj.getFlags(), NULL);
|
||||||
} else if (srcObj->isDate()) {
|
} else if (srcObj->is<DateObject>()) {
|
||||||
clone = JS_NewDateObjectMsec(cx, srcObj->getDateUTCTime().toNumber());
|
clone = JS_NewDateObjectMsec(cx, srcObj->as<DateObject>().UTCTime().toNumber());
|
||||||
} else if (srcObj->is<BooleanObject>()) {
|
} else if (srcObj->is<BooleanObject>()) {
|
||||||
clone = BooleanObject::create(cx, srcObj->as<BooleanObject>().unbox());
|
clone = BooleanObject::create(cx, srcObj->as<BooleanObject>().unbox());
|
||||||
} else if (srcObj->is<NumberObject>()) {
|
} else if (srcObj->is<NumberObject>()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user