mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 959013 - Convert the Date object to use ClassSpec. r=luke
This commit is contained in:
parent
460ab407b5
commit
c6fb00a32a
@ -521,23 +521,6 @@ date_convert(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp
|
|||||||
return DefaultValue(cx, obj, (hint == JSTYPE_VOID) ? JSTYPE_STRING : hint, vp);
|
return DefaultValue(cx, obj, (hint == JSTYPE_VOID) ? JSTYPE_STRING : hint, vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Other Support routines and definitions
|
|
||||||
*/
|
|
||||||
|
|
||||||
const Class DateObject::class_ = {
|
|
||||||
js_Date_str,
|
|
||||||
JSCLASS_HAS_RESERVED_SLOTS(RESERVED_SLOTS) |
|
|
||||||
JSCLASS_HAS_CACHED_PROTO(JSProto_Date),
|
|
||||||
JS_PropertyStub, /* addProperty */
|
|
||||||
JS_DeletePropertyStub, /* delProperty */
|
|
||||||
JS_PropertyStub, /* getProperty */
|
|
||||||
JS_StrictPropertyStub, /* setProperty */
|
|
||||||
JS_EnumerateStub,
|
|
||||||
JS_ResolveStub,
|
|
||||||
date_convert
|
|
||||||
};
|
|
||||||
|
|
||||||
/* for use by date_parse */
|
/* for use by date_parse */
|
||||||
|
|
||||||
static const char* const wtb[] = {
|
static const char* const wtb[] = {
|
||||||
@ -3027,52 +3010,48 @@ js_Date(JSContext *cx, unsigned argc, Value *vp)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *
|
static bool
|
||||||
js_InitDateClass(JSContext *cx, HandleObject obj)
|
FinishDateClassInit(JSContext *cx, HandleObject ctor, HandleObject proto)
|
||||||
{
|
{
|
||||||
JS_ASSERT(obj->isNative());
|
proto->as<DateObject>().setUTCTime(GenericNaN());
|
||||||
|
|
||||||
Rooted<GlobalObject*> global(cx, &obj->as<GlobalObject>());
|
|
||||||
|
|
||||||
RootedObject dateProto(cx, global->createBlankPrototype(cx, &DateObject::class_));
|
|
||||||
if (!dateProto)
|
|
||||||
return nullptr;
|
|
||||||
dateProto->as<DateObject>().setUTCTime(GenericNaN());
|
|
||||||
|
|
||||||
RootedFunction ctor(cx);
|
|
||||||
ctor = global->createConstructor(cx, js_Date, cx->names().Date, MAXARGS);
|
|
||||||
if (!ctor)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
if (!LinkConstructorAndPrototype(cx, ctor, dateProto))
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
if (!DefinePropertiesAndBrand(cx, ctor, nullptr, date_static_methods))
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define all Date.prototype.* functions, then brand for trace-jitted code.
|
|
||||||
* Date.prototype.toGMTString has the same initial value as
|
* Date.prototype.toGMTString has the same initial value as
|
||||||
* Date.prototype.toUTCString.
|
* Date.prototype.toUTCString.
|
||||||
*/
|
*/
|
||||||
if (!JS_DefineFunctions(cx, dateProto, date_methods))
|
|
||||||
return nullptr;
|
|
||||||
RootedValue toUTCStringFun(cx);
|
RootedValue toUTCStringFun(cx);
|
||||||
RootedId toUTCStringId(cx, NameToId(cx->names().toUTCString));
|
RootedId toUTCStringId(cx, NameToId(cx->names().toUTCString));
|
||||||
RootedId toGMTStringId(cx, NameToId(cx->names().toGMTString));
|
RootedId toGMTStringId(cx, NameToId(cx->names().toGMTString));
|
||||||
if (!baseops::GetProperty(cx, dateProto, toUTCStringId, &toUTCStringFun) ||
|
return baseops::GetProperty(cx, proto, toUTCStringId, &toUTCStringFun) &&
|
||||||
!baseops::DefineGeneric(cx, dateProto, toGMTStringId, toUTCStringFun,
|
baseops::DefineGeneric(cx, proto, toGMTStringId, toUTCStringFun,
|
||||||
JS_PropertyStub, JS_StrictPropertyStub, 0))
|
JS_PropertyStub, JS_StrictPropertyStub, 0);
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DefineConstructorAndPrototype(cx, global, JSProto_Date, ctor, dateProto))
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
return dateProto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Class DateObject::class_ = {
|
||||||
|
js_Date_str,
|
||||||
|
JSCLASS_HAS_RESERVED_SLOTS(RESERVED_SLOTS) |
|
||||||
|
JSCLASS_HAS_CACHED_PROTO(JSProto_Date),
|
||||||
|
JS_PropertyStub, /* addProperty */
|
||||||
|
JS_DeletePropertyStub, /* delProperty */
|
||||||
|
JS_PropertyStub, /* getProperty */
|
||||||
|
JS_StrictPropertyStub, /* setProperty */
|
||||||
|
JS_EnumerateStub,
|
||||||
|
JS_ResolveStub,
|
||||||
|
date_convert,
|
||||||
|
nullptr, /* finalize */
|
||||||
|
nullptr, /* call */
|
||||||
|
nullptr, /* hasInstance */
|
||||||
|
nullptr, /* construct */
|
||||||
|
nullptr, /* trace */
|
||||||
|
{
|
||||||
|
GenericCreateConstructor<js_Date, NAME_OFFSET(Date), MAXARGS>,
|
||||||
|
GenericCreatePrototype<&DateObject::class_>,
|
||||||
|
date_static_methods,
|
||||||
|
date_methods,
|
||||||
|
FinishDateClassInit
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
JS_FRIEND_API(JSObject *)
|
JS_FRIEND_API(JSObject *)
|
||||||
js_NewDateObjectMsec(JSContext *cx, double msec_time)
|
js_NewDateObjectMsec(JSContext *cx, double msec_time)
|
||||||
{
|
{
|
||||||
|
@ -16,9 +16,6 @@
|
|||||||
#include "js/RootingAPI.h"
|
#include "js/RootingAPI.h"
|
||||||
#include "js/TypeDecls.h"
|
#include "js/TypeDecls.h"
|
||||||
|
|
||||||
extern JSObject *
|
|
||||||
js_InitDateClass(JSContext *cx, JS::HandleObject obj);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These functions provide a C interface to the date/time object
|
* These functions provide a C interface to the date/time object
|
||||||
*/
|
*/
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
real(Array, 3, js_InitArrayClass, OCLASP(Array)) \
|
real(Array, 3, js_InitArrayClass, OCLASP(Array)) \
|
||||||
real(Boolean, 4, js_InitBooleanClass, OCLASP(Boolean)) \
|
real(Boolean, 4, js_InitBooleanClass, OCLASP(Boolean)) \
|
||||||
real(JSON, 5, js_InitJSONClass, CLASP(JSON)) \
|
real(JSON, 5, js_InitJSONClass, CLASP(JSON)) \
|
||||||
real(Date, 6, js_InitDateClass, OCLASP(Date)) \
|
real(Date, 6, js_InitViaClassSpec, OCLASP(Date)) \
|
||||||
real(Math, 7, js_InitMathClass, CLASP(Math)) \
|
real(Math, 7, js_InitMathClass, CLASP(Math)) \
|
||||||
real(Number, 8, js_InitNumberClass, OCLASP(Number)) \
|
real(Number, 8, js_InitNumberClass, OCLASP(Number)) \
|
||||||
real(String, 9, js_InitStringClass, OCLASP(String)) \
|
real(String, 9, js_InitStringClass, OCLASP(String)) \
|
||||||
|
Loading…
Reference in New Issue
Block a user