Backed out changeset e9a4931b119c (bug 861219)

This commit is contained in:
Carsten "Tomcat" Book
2015-05-12 12:27:20 +02:00
parent a065248c51
commit 322c031436
16 changed files with 226 additions and 93 deletions

View File

@@ -2869,26 +2869,18 @@ date_toSource(JSContext* cx, unsigned argc, Value* vp)
}
#endif
// ES6 final draft 20.3.4.41.
MOZ_ALWAYS_INLINE bool
date_toString_impl(JSContext* cx, CallArgs args)
{
return date_format(cx, args.thisv().toObject().as<DateObject>().UTCTime().toNumber(),
FORMATSPEC_FULL, args.rval());
}
static bool
date_toString(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
// Step 2.a. (reordered)
double tv = GenericNaN();
if (args.thisv().isObject()) {
// Step 1.
RootedObject obj(cx, &args.thisv().toObject());
// Step 2.
if (ObjectClassIs(obj, ESClass_Date, cx)) {
// Step 3.a.
RootedValue unboxed(cx);
Unbox(cx, obj, &unboxed);
tv = unboxed.toNumber();
}
}
// Step 4.
return date_format(cx, tv, FORMATSPEC_FULL, args.rval());
return CallNonGenericMethod<IsDate, date_toString_impl>(cx, args);
}
MOZ_ALWAYS_INLINE bool
@@ -3127,16 +3119,11 @@ js::DateConstructor(JSContext* cx, unsigned argc, Value* vp)
return DateMultipleArguments(cx, args);
}
// ES6 final draft 20.3.4.
static JSObject*
CreateDatePrototype(JSContext* cx, JSProtoKey key)
{
return cx->global()->createBlankPrototype(cx, &DateObject::protoClass_);
}
static bool
FinishDateClassInit(JSContext* cx, HandleObject ctor, HandleObject proto)
{
proto->as<DateObject>().setUTCTime(ClippedTime::NaN());
/*
* Date.prototype.toGMTString has the same initial value as
* Date.prototype.toUTCString.
@@ -3144,8 +3131,8 @@ FinishDateClassInit(JSContext* cx, HandleObject ctor, HandleObject proto)
RootedValue toUTCStringFun(cx);
RootedId toUTCStringId(cx, NameToId(cx->names().toUTCString));
RootedId toGMTStringId(cx, NameToId(cx->names().toGMTString));
return NativeGetProperty(cx, proto.as<NativeObject>(), toUTCStringId, &toUTCStringFun) &&
NativeDefineProperty(cx, proto.as<NativeObject>(), toGMTStringId, toUTCStringFun,
return NativeGetProperty(cx, proto.as<DateObject>(), toUTCStringId, &toUTCStringFun) &&
NativeDefineProperty(cx, proto.as<DateObject>(), toGMTStringId, toUTCStringFun,
nullptr, nullptr, 0);
}
@@ -3168,7 +3155,7 @@ const Class DateObject::class_ = {
nullptr, /* trace */
{
GenericCreateConstructor<DateConstructor, 7, gc::AllocKind::FUNCTION>,
CreateDatePrototype,
GenericCreatePrototype,
date_static_methods,
nullptr,
date_methods,
@@ -3177,27 +3164,6 @@ const Class DateObject::class_ = {
}
};
const Class DateObject::protoClass_ = {
js_Object_str,
JSCLASS_HAS_CACHED_PROTO(JSProto_Date),
nullptr, /* addProperty */
nullptr, /* delProperty */
nullptr, /* getProperty */
nullptr, /* setProperty */
nullptr, /* enumerate */
nullptr, /* resolve */
nullptr, /* mayResolve */
nullptr, /* convert */
nullptr, /* finalize */
nullptr, /* call */
nullptr, /* hasInstance */
nullptr, /* construct */
nullptr, /* trace */
{
DELEGATED_CLASSSPEC(&DateObject::class_.spec)
}
};
JSObject*
js::NewDateObjectMsec(JSContext* cx, ClippedTime t)
{