Bug 1856338 - Part 27: Make Calendar operations strongly typed. r=sfink

Differential Revision: https://phabricator.services.mozilla.com/D189798
This commit is contained in:
André Bargull 2023-11-06 12:28:23 +00:00
parent 5ef750c786
commit a9b3ce69f4
7 changed files with 945 additions and 439 deletions

File diff suppressed because it is too large Load Diff

View File

@ -119,6 +119,7 @@ struct PlainDate;
struct PlainDateTime;
class DurationObject;
class PlainDateObject;
class PlainDateTimeObject;
class PlainMonthDayObject;
class PlainYearMonthObject;
enum class CalendarOption;
@ -314,91 +315,252 @@ bool CalendarDateUntil(JSContext* cx, JS::Handle<CalendarValue> calendar,
* CalendarYear ( calendar, dateLike )
*/
bool CalendarYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarYear ( calendar, dateLike )
*/
bool CalendarYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarYear ( calendar, dateLike )
*/
bool CalendarYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainYearMonthObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarMonth ( calendar, dateLike )
*/
bool CalendarMonth(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarMonth ( calendar, dateLike )
*/
bool CalendarMonth(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarMonth ( calendar, dateLike )
*/
bool CalendarMonth(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainYearMonthObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarMonthCode ( calendar, dateLike )
*/
bool CalendarMonthCode(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarMonthCode ( calendar, dateLike )
*/
bool CalendarMonthCode(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarMonthCode ( calendar, dateLike )
*/
bool CalendarMonthCode(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainMonthDayObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarMonthCode ( calendar, dateLike )
*/
bool CalendarMonthCode(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainYearMonthObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDay ( calendar, dateLike )
*/
bool CalendarDay(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDay ( calendar, dateLike )
*/
bool CalendarDay(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDay ( calendar, dateLike )
*/
bool CalendarDay(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainMonthDayObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDay ( calendar, dateLike )
*/
bool CalendarDayWrapped(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<Wrapped<PlainDateObject*>> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDayOfWeek ( calendar, dateLike )
*/
bool CalendarDayOfWeek(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDayOfWeek ( calendar, dateLike )
*/
bool CalendarDayOfWeek(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDayOfYear ( calendar, dateLike )
*/
bool CalendarDayOfYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDayOfYear ( calendar, dateLike )
*/
bool CalendarDayOfYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarWeekOfYear ( calendar, dateLike )
*/
bool CalendarWeekOfYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarWeekOfYear ( calendar, dateLike )
*/
bool CalendarWeekOfYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarYearOfWeek ( calendar, dateLike )
*/
bool CalendarYearOfWeek(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarYearOfWeek ( calendar, dateLike )
*/
bool CalendarYearOfWeek(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDaysInWeek ( calendar, dateLike )
*/
bool CalendarDaysInWeek(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDaysInWeek ( calendar, dateLike )
*/
bool CalendarDaysInWeek(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDaysInMonth ( calendar, dateLike )
*/
bool CalendarDaysInMonth(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDaysInMonth ( calendar, dateLike )
*/
bool CalendarDaysInMonth(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDaysInMonth ( calendar, dateLike )
*/
bool CalendarDaysInMonth(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainYearMonthObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDaysInYear ( calendar, dateLike )
*/
bool CalendarDaysInYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDaysInYear ( calendar, dateLike )
*/
bool CalendarDaysInYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarDaysInYear ( calendar, dateLike )
*/
bool CalendarDaysInYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainYearMonthObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarMonthsInYear ( calendar, dateLike )
*/
bool CalendarMonthsInYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarMonthsInYear ( calendar, dateLike )
*/
bool CalendarMonthsInYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarMonthsInYear ( calendar, dateLike )
*/
bool CalendarMonthsInYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainYearMonthObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarInLeapYear ( calendar, dateLike )
*/
bool CalendarInLeapYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<JS::Value> dateLike,
JS::Handle<PlainDateObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarInLeapYear ( calendar, dateLike )
*/
bool CalendarInLeapYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainDateTimeObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**
* CalendarInLeapYear ( calendar, dateLike )
*/
bool CalendarInLeapYear(JSContext* cx, JS::Handle<CalendarValue> calendar,
JS::Handle<PlainYearMonthObject*> dateLike,
JS::MutableHandle<JS::Value> result);
/**

View File

@ -1425,11 +1425,12 @@ static bool PlainDate_calendarId(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_year(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarYear(cx, calendar, args.thisv(), args.rval());
return CalendarYear(cx, calendar, temporalDate, args.rval());
}
/**
@ -1446,11 +1447,12 @@ static bool PlainDate_year(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_month(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarMonth(cx, calendar, args.thisv(), args.rval());
return CalendarMonth(cx, calendar, temporalDate, args.rval());
}
/**
@ -1467,11 +1469,12 @@ static bool PlainDate_month(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_monthCode(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarMonthCode(cx, calendar, args.thisv(), args.rval());
return CalendarMonthCode(cx, calendar, temporalDate, args.rval());
}
/**
@ -1488,11 +1491,12 @@ static bool PlainDate_monthCode(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_day(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarDay(cx, calendar, args.thisv(), args.rval());
return CalendarDay(cx, calendar, temporalDate, args.rval());
}
/**
@ -1509,11 +1513,12 @@ static bool PlainDate_day(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_dayOfWeek(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarDayOfWeek(cx, calendar, args.thisv(), args.rval());
return CalendarDayOfWeek(cx, calendar, temporalDate, args.rval());
}
/**
@ -1530,11 +1535,12 @@ static bool PlainDate_dayOfWeek(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_dayOfYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarDayOfYear(cx, calendar, args.thisv(), args.rval());
return CalendarDayOfYear(cx, calendar, temporalDate, args.rval());
}
/**
@ -1551,11 +1557,12 @@ static bool PlainDate_dayOfYear(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_weekOfYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarWeekOfYear(cx, calendar, args.thisv(), args.rval());
return CalendarWeekOfYear(cx, calendar, temporalDate, args.rval());
}
/**
@ -1572,11 +1579,12 @@ static bool PlainDate_weekOfYear(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_yearOfWeek(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarYearOfWeek(cx, calendar, args.thisv(), args.rval());
return CalendarYearOfWeek(cx, calendar, temporalDate, args.rval());
}
/**
@ -1593,11 +1601,12 @@ static bool PlainDate_yearOfWeek(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_daysInWeek(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarDaysInWeek(cx, calendar, args.thisv(), args.rval());
return CalendarDaysInWeek(cx, calendar, temporalDate, args.rval());
}
/**
@ -1614,11 +1623,12 @@ static bool PlainDate_daysInWeek(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_daysInMonth(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarDaysInMonth(cx, calendar, args.thisv(), args.rval());
return CalendarDaysInMonth(cx, calendar, temporalDate, args.rval());
}
/**
@ -1635,11 +1645,12 @@ static bool PlainDate_daysInMonth(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_daysInYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarDaysInYear(cx, calendar, args.thisv(), args.rval());
return CalendarDaysInYear(cx, calendar, temporalDate, args.rval());
}
/**
@ -1656,11 +1667,12 @@ static bool PlainDate_daysInYear(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_monthsInYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarMonthsInYear(cx, calendar, args.thisv(), args.rval());
return CalendarMonthsInYear(cx, calendar, temporalDate, args.rval());
}
/**
@ -1677,11 +1689,12 @@ static bool PlainDate_monthsInYear(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDate_inLeapYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* temporalDate = &args.thisv().toObject().as<PlainDateObject>();
Rooted<PlainDateObject*> temporalDate(
cx, &args.thisv().toObject().as<PlainDateObject>());
Rooted<CalendarValue> calendar(cx, temporalDate->calendar());
// Step 4.
return CalendarInLeapYear(cx, calendar, args.thisv(), args.rval());
return CalendarInLeapYear(cx, calendar, temporalDate, args.rval());
}
/**

View File

@ -1308,11 +1308,12 @@ static bool PlainDateTime_calendarId(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDateTime_year(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarYear(cx, calendar, args.thisv(), args.rval());
return CalendarYear(cx, calendar, dateTime, args.rval());
}
/**
@ -1329,11 +1330,12 @@ static bool PlainDateTime_year(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDateTime_month(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarMonth(cx, calendar, args.thisv(), args.rval());
return CalendarMonth(cx, calendar, dateTime, args.rval());
}
/**
@ -1350,11 +1352,12 @@ static bool PlainDateTime_month(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDateTime_monthCode(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarMonthCode(cx, calendar, args.thisv(), args.rval());
return CalendarMonthCode(cx, calendar, dateTime, args.rval());
}
/**
@ -1372,11 +1375,12 @@ static bool PlainDateTime_monthCode(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDateTime_day(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarDay(cx, calendar, args.thisv(), args.rval());
return CalendarDay(cx, calendar, dateTime, args.rval());
}
/**
@ -1510,11 +1514,12 @@ static bool PlainDateTime_nanosecond(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDateTime_dayOfWeek(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarDayOfWeek(cx, calendar, args.thisv(), args.rval());
return CalendarDayOfWeek(cx, calendar, dateTime, args.rval());
}
/**
@ -1532,11 +1537,12 @@ static bool PlainDateTime_dayOfWeek(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDateTime_dayOfYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarDayOfYear(cx, calendar, args.thisv(), args.rval());
return CalendarDayOfYear(cx, calendar, dateTime, args.rval());
}
/**
@ -1554,11 +1560,12 @@ static bool PlainDateTime_dayOfYear(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDateTime_weekOfYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarWeekOfYear(cx, calendar, args.thisv(), args.rval());
return CalendarWeekOfYear(cx, calendar, dateTime, args.rval());
}
/**
@ -1576,11 +1583,12 @@ static bool PlainDateTime_weekOfYear(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDateTime_yearOfWeek(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarYearOfWeek(cx, calendar, args.thisv(), args.rval());
return CalendarYearOfWeek(cx, calendar, dateTime, args.rval());
}
/**
@ -1598,11 +1606,12 @@ static bool PlainDateTime_yearOfWeek(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDateTime_daysInWeek(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarDaysInWeek(cx, calendar, args.thisv(), args.rval());
return CalendarDaysInWeek(cx, calendar, dateTime, args.rval());
}
/**
@ -1620,11 +1629,12 @@ static bool PlainDateTime_daysInWeek(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDateTime_daysInMonth(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarDaysInMonth(cx, calendar, args.thisv(), args.rval());
return CalendarDaysInMonth(cx, calendar, dateTime, args.rval());
}
/**
@ -1642,11 +1652,12 @@ static bool PlainDateTime_daysInMonth(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDateTime_daysInYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarDaysInYear(cx, calendar, args.thisv(), args.rval());
return CalendarDaysInYear(cx, calendar, dateTime, args.rval());
}
/**
@ -1664,11 +1675,12 @@ static bool PlainDateTime_daysInYear(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainDateTime_monthsInYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarMonthsInYear(cx, calendar, args.thisv(), args.rval());
return CalendarMonthsInYear(cx, calendar, dateTime, args.rval());
}
/**
@ -1687,11 +1699,12 @@ static bool PlainDateTime_monthsInYear(JSContext* cx, unsigned argc,
*/
static bool PlainDateTime_inLeapYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* dateTime = &args.thisv().toObject().as<PlainDateTimeObject>();
Rooted<PlainDateTimeObject*> dateTime(
cx, &args.thisv().toObject().as<PlainDateTimeObject>());
Rooted<CalendarValue> calendar(cx, dateTime->calendar());
// Step 4.
return CalendarInLeapYear(cx, calendar, args.thisv(), args.rval());
return CalendarInLeapYear(cx, calendar, dateTime, args.rval());
}
/**

View File

@ -483,11 +483,12 @@ static bool PlainMonthDay_calendarId(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainMonthDay_monthCode(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* monthDay = &args.thisv().toObject().as<PlainMonthDayObject>();
Rooted<PlainMonthDayObject*> monthDay(
cx, &args.thisv().toObject().as<PlainMonthDayObject>());
Rooted<CalendarValue> calendar(cx, monthDay->calendar());
// Step 4.
return CalendarMonthCode(cx, calendar, args.thisv(), args.rval());
return CalendarMonthCode(cx, calendar, monthDay, args.rval());
}
/**
@ -505,11 +506,12 @@ static bool PlainMonthDay_monthCode(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainMonthDay_day(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* monthDay = &args.thisv().toObject().as<PlainMonthDayObject>();
Rooted<PlainMonthDayObject*> monthDay(
cx, &args.thisv().toObject().as<PlainMonthDayObject>());
Rooted<CalendarValue> calendar(cx, monthDay->calendar());
// Step 4.
return CalendarDay(cx, calendar, args.thisv(), args.rval());
return CalendarDay(cx, calendar, monthDay, args.rval());
}
/**

View File

@ -610,9 +610,8 @@ static bool AddDurationToOrSubtractDurationFromPlainYearMonth(
}
// Step 12.e.
Rooted<Value> endOfMonthValue(cx, ObjectValue(*endOfMonth));
Rooted<Value> day(cx);
if (!CalendarDay(cx, calendar, endOfMonthValue, &day)) {
if (!CalendarDayWrapped(cx, calendar, endOfMonth, &day)) {
return false;
}
@ -845,11 +844,12 @@ static bool PlainYearMonth_calendarId(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainYearMonth_year(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* yearMonth = &args.thisv().toObject().as<PlainYearMonthObject>();
Rooted<PlainYearMonthObject*> yearMonth(
cx, &args.thisv().toObject().as<PlainYearMonthObject>());
Rooted<CalendarValue> calendar(cx, yearMonth->calendar());
// Step 4.
return CalendarYear(cx, calendar, args.thisv(), args.rval());
return CalendarYear(cx, calendar, yearMonth, args.rval());
}
/**
@ -866,11 +866,12 @@ static bool PlainYearMonth_year(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainYearMonth_month(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* yearMonth = &args.thisv().toObject().as<PlainYearMonthObject>();
Rooted<PlainYearMonthObject*> yearMonth(
cx, &args.thisv().toObject().as<PlainYearMonthObject>());
Rooted<CalendarValue> calendar(cx, yearMonth->calendar());
// Step 4.
return CalendarMonth(cx, calendar, args.thisv(), args.rval());
return CalendarMonth(cx, calendar, yearMonth, args.rval());
}
/**
@ -887,11 +888,12 @@ static bool PlainYearMonth_month(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainYearMonth_monthCode(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* yearMonth = &args.thisv().toObject().as<PlainYearMonthObject>();
Rooted<PlainYearMonthObject*> yearMonth(
cx, &args.thisv().toObject().as<PlainYearMonthObject>());
Rooted<CalendarValue> calendar(cx, yearMonth->calendar());
// Step 4.
return CalendarMonthCode(cx, calendar, args.thisv(), args.rval());
return CalendarMonthCode(cx, calendar, yearMonth, args.rval());
}
/**
@ -909,11 +911,12 @@ static bool PlainYearMonth_monthCode(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainYearMonth_daysInYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* yearMonth = &args.thisv().toObject().as<PlainYearMonthObject>();
Rooted<PlainYearMonthObject*> yearMonth(
cx, &args.thisv().toObject().as<PlainYearMonthObject>());
Rooted<CalendarValue> calendar(cx, yearMonth->calendar());
// Step 4.
return CalendarDaysInYear(cx, calendar, args.thisv(), args.rval());
return CalendarDaysInYear(cx, calendar, yearMonth, args.rval());
}
/**
@ -931,11 +934,12 @@ static bool PlainYearMonth_daysInYear(JSContext* cx, unsigned argc, Value* vp) {
*/
static bool PlainYearMonth_daysInMonth(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* yearMonth = &args.thisv().toObject().as<PlainYearMonthObject>();
Rooted<PlainYearMonthObject*> yearMonth(
cx, &args.thisv().toObject().as<PlainYearMonthObject>());
Rooted<CalendarValue> calendar(cx, yearMonth->calendar());
// Step 4.
return CalendarDaysInMonth(cx, calendar, args.thisv(), args.rval());
return CalendarDaysInMonth(cx, calendar, yearMonth, args.rval());
}
/**
@ -954,11 +958,12 @@ static bool PlainYearMonth_daysInMonth(JSContext* cx, unsigned argc,
*/
static bool PlainYearMonth_monthsInYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* yearMonth = &args.thisv().toObject().as<PlainYearMonthObject>();
Rooted<PlainYearMonthObject*> yearMonth(
cx, &args.thisv().toObject().as<PlainYearMonthObject>());
Rooted<CalendarValue> calendar(cx, yearMonth->calendar());
// Step 4.
return CalendarMonthsInYear(cx, calendar, args.thisv(), args.rval());
return CalendarMonthsInYear(cx, calendar, yearMonth, args.rval());
}
/**
@ -977,11 +982,12 @@ static bool PlainYearMonth_monthsInYear(JSContext* cx, unsigned argc,
*/
static bool PlainYearMonth_inLeapYear(JSContext* cx, const CallArgs& args) {
// Step 3.
auto* yearMonth = &args.thisv().toObject().as<PlainYearMonthObject>();
Rooted<PlainYearMonthObject*> yearMonth(
cx, &args.thisv().toObject().as<PlainYearMonthObject>());
Rooted<CalendarValue> calendar(cx, yearMonth->calendar());
// Step 4.
return CalendarInLeapYear(cx, calendar, args.thisv(), args.rval());
return CalendarInLeapYear(cx, calendar, yearMonth, args.rval());
}
/**

View File

@ -1621,14 +1621,14 @@ static bool ZonedDateTime_year(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarYear(cx, calendar, temporalDateTime, args.rval());
return CalendarYear(cx, calendar, dateTime, args.rval());
}
/**
@ -1650,14 +1650,14 @@ static bool ZonedDateTime_month(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarMonth(cx, calendar, temporalDateTime, args.rval());
return CalendarMonth(cx, calendar, dateTime, args.rval());
}
/**
@ -1679,14 +1679,14 @@ static bool ZonedDateTime_monthCode(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarMonthCode(cx, calendar, temporalDateTime, args.rval());
return CalendarMonthCode(cx, calendar, dateTime, args.rval());
}
/**
@ -1709,14 +1709,14 @@ static bool ZonedDateTime_day(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarDay(cx, calendar, temporalDateTime, args.rval());
return CalendarDay(cx, calendar, dateTime, args.rval());
}
/**
@ -2021,14 +2021,14 @@ static bool ZonedDateTime_dayOfWeek(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarDayOfWeek(cx, calendar, temporalDateTime, args.rval());
return CalendarDayOfWeek(cx, calendar, dateTime, args.rval());
}
/**
@ -2051,14 +2051,14 @@ static bool ZonedDateTime_dayOfYear(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarDayOfYear(cx, calendar, temporalDateTime, args.rval());
return CalendarDayOfYear(cx, calendar, dateTime, args.rval());
}
/**
@ -2081,14 +2081,14 @@ static bool ZonedDateTime_weekOfYear(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarWeekOfYear(cx, calendar, temporalDateTime, args.rval());
return CalendarWeekOfYear(cx, calendar, dateTime, args.rval());
}
/**
@ -2111,14 +2111,14 @@ static bool ZonedDateTime_yearOfWeek(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarYearOfWeek(cx, calendar, temporalDateTime, args.rval());
return CalendarYearOfWeek(cx, calendar, dateTime, args.rval());
}
/**
@ -2221,14 +2221,14 @@ static bool ZonedDateTime_daysInWeek(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarDaysInWeek(cx, calendar, temporalDateTime, args.rval());
return CalendarDaysInWeek(cx, calendar, dateTime, args.rval());
}
/**
@ -2251,14 +2251,14 @@ static bool ZonedDateTime_daysInMonth(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarDaysInMonth(cx, calendar, temporalDateTime, args.rval());
return CalendarDaysInMonth(cx, calendar, dateTime, args.rval());
}
/**
@ -2281,14 +2281,14 @@ static bool ZonedDateTime_daysInYear(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarDaysInYear(cx, calendar, temporalDateTime, args.rval());
return CalendarDaysInYear(cx, calendar, dateTime, args.rval());
}
/**
@ -2311,14 +2311,14 @@ static bool ZonedDateTime_monthsInYear(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarMonthsInYear(cx, calendar, temporalDateTime, args.rval());
return CalendarMonthsInYear(cx, calendar, dateTime, args.rval());
}
/**
@ -2342,14 +2342,14 @@ static bool ZonedDateTime_inLeapYear(JSContext* cx, const CallArgs& args) {
Rooted<CalendarValue> calendar(cx, zonedDateTime->calendar());
// Steps 3-6.
auto* dateTime = GetPlainDateTimeFor(cx, timeZone, instant, calendar);
Rooted<PlainDateTimeObject*> dateTime(
cx, GetPlainDateTimeFor(cx, timeZone, instant, calendar));
if (!dateTime) {
return false;
}
Rooted<Value> temporalDateTime(cx, ObjectValue(*dateTime));
// Step 7.
return CalendarInLeapYear(cx, calendar, temporalDateTime, args.rval());
return CalendarInLeapYear(cx, calendar, dateTime, args.rval());
}
/**