1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:07:45 +00:00

LibJS: Make Temporal foo_from_fields() AO field/options Object a const*

This is a bit of a lie as the Value(Object const*) ctor will const_cast
them in invoke(), but at least it ensures that nothing else in the
function relies on getting non-const Objects.
Perhaps we can have an actual Object const* Value in the future as well.
This commit is contained in:
Linus Groh 2021-09-09 21:24:07 +01:00
parent 4be2aeca00
commit 1f99538185
2 changed files with 12 additions and 12 deletions

View file

@ -439,7 +439,7 @@ Object* get_temporal_calendar_with_iso_default(GlobalObject& global_object, Obje
} }
// 12.1.24 DateFromFields ( calendar, fields, options ), https://tc39.es/proposal-temporal/#sec-temporal-datefromfields // 12.1.24 DateFromFields ( calendar, fields, options ), https://tc39.es/proposal-temporal/#sec-temporal-datefromfields
PlainDate* date_from_fields(GlobalObject& global_object, Object& calendar, Object& fields, Object& options) PlainDate* date_from_fields(GlobalObject& global_object, Object& calendar, Object const& fields, Object const& options)
{ {
auto& vm = global_object.vm(); auto& vm = global_object.vm();
@ -465,7 +465,7 @@ PlainDate* date_from_fields(GlobalObject& global_object, Object& calendar, Objec
} }
// 12.1.25 YearMonthFromFields ( calendar, fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-yearmonthfromfields // 12.1.25 YearMonthFromFields ( calendar, fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-yearmonthfromfields
PlainYearMonth* year_month_from_fields(GlobalObject& global_object, Object& calendar, Object& fields, Object* options) PlainYearMonth* year_month_from_fields(GlobalObject& global_object, Object& calendar, Object const& fields, Object const* options)
{ {
auto& vm = global_object.vm(); auto& vm = global_object.vm();
@ -495,7 +495,7 @@ PlainYearMonth* year_month_from_fields(GlobalObject& global_object, Object& cale
} }
// 12.1.26 MonthDayFromFields ( calendar, fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-monthdayfromfields // 12.1.26 MonthDayFromFields ( calendar, fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-monthdayfromfields
PlainMonthDay* month_day_from_fields(GlobalObject& global_object, Object& calendar, Object& fields, Object* options) PlainMonthDay* month_day_from_fields(GlobalObject& global_object, Object& calendar, Object const& fields, Object const* options)
{ {
auto& vm = global_object.vm(); auto& vm = global_object.vm();
@ -793,7 +793,7 @@ double resolve_iso_month(GlobalObject& global_object, Object& fields)
} }
// 12.1.38 ISODateFromFields ( fields, options ), https://tc39.es/proposal-temporal/#sec-temporal-isodatefromfields // 12.1.38 ISODateFromFields ( fields, options ), https://tc39.es/proposal-temporal/#sec-temporal-isodatefromfields
Optional<ISODate> iso_date_from_fields(GlobalObject& global_object, Object& fields, Object& options) Optional<ISODate> iso_date_from_fields(GlobalObject& global_object, Object const& fields, Object const& options)
{ {
auto& vm = global_object.vm(); auto& vm = global_object.vm();
@ -841,7 +841,7 @@ Optional<ISODate> iso_date_from_fields(GlobalObject& global_object, Object& fiel
} }
// 12.1.39 ISOYearMonthFromFields ( fields, options ), https://tc39.es/proposal-temporal/#sec-temporal-isoyearmonthfromfields // 12.1.39 ISOYearMonthFromFields ( fields, options ), https://tc39.es/proposal-temporal/#sec-temporal-isoyearmonthfromfields
Optional<ISOYearMonth> iso_year_month_from_fields(GlobalObject& global_object, Object& fields, Object& options) Optional<ISOYearMonth> iso_year_month_from_fields(GlobalObject& global_object, Object const& fields, Object const& options)
{ {
auto& vm = global_object.vm(); auto& vm = global_object.vm();
@ -883,7 +883,7 @@ Optional<ISOYearMonth> iso_year_month_from_fields(GlobalObject& global_object, O
} }
// 12.1.40 ISOMonthDayFromFields ( fields, options ), https://tc39.es/proposal-temporal/#sec-temporal-isomonthdayfromfields // 12.1.40 ISOMonthDayFromFields ( fields, options ), https://tc39.es/proposal-temporal/#sec-temporal-isomonthdayfromfields
Optional<ISOMonthDay> iso_month_day_from_fields(GlobalObject& global_object, Object& fields, Object& options) Optional<ISOMonthDay> iso_month_day_from_fields(GlobalObject& global_object, Object const& fields, Object const& options)
{ {
auto& vm = global_object.vm(); auto& vm = global_object.vm();

View file

@ -51,9 +51,9 @@ Value calendar_era_year(GlobalObject&, Object& calendar, Object& date_like);
Object* to_temporal_calendar(GlobalObject&, Value); Object* to_temporal_calendar(GlobalObject&, Value);
Object* to_temporal_calendar_with_iso_default(GlobalObject&, Value); Object* to_temporal_calendar_with_iso_default(GlobalObject&, Value);
Object* get_temporal_calendar_with_iso_default(GlobalObject&, Object&); Object* get_temporal_calendar_with_iso_default(GlobalObject&, Object&);
PlainDate* date_from_fields(GlobalObject&, Object& calendar, Object& fields, Object& options); PlainDate* date_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const& options);
PlainYearMonth* year_month_from_fields(GlobalObject&, Object& calendar, Object& fields, Object* options = nullptr); PlainYearMonth* year_month_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const* options = nullptr);
PlainMonthDay* month_day_from_fields(GlobalObject& global_object, Object& calendar, Object& fields, Object* options = nullptr); PlainMonthDay* month_day_from_fields(GlobalObject& global_object, Object& calendar, Object const& fields, Object const* options = nullptr);
String format_calendar_annotation(StringView id, StringView show_calendar); String format_calendar_annotation(StringView id, StringView show_calendar);
bool calendar_equals(GlobalObject&, Object& one, Object& two); bool calendar_equals(GlobalObject&, Object& one, Object& two);
Object* consolidate_calendars(GlobalObject&, Object& one, Object& two); Object* consolidate_calendars(GlobalObject&, Object& one, Object& two);
@ -65,9 +65,9 @@ u16 to_iso_day_of_year(i32 year, u8 month, u8 day);
u8 to_iso_week_of_year(i32 year, u8 month, u8 day); u8 to_iso_week_of_year(i32 year, u8 month, u8 day);
String build_iso_month_code(u8 month); String build_iso_month_code(u8 month);
double resolve_iso_month(GlobalObject&, Object& fields); double resolve_iso_month(GlobalObject&, Object& fields);
Optional<ISODate> iso_date_from_fields(GlobalObject&, Object& fields, Object& options); Optional<ISODate> iso_date_from_fields(GlobalObject&, Object const& fields, Object const& options);
Optional<ISOYearMonth> iso_year_month_from_fields(GlobalObject&, Object& fields, Object& options); Optional<ISOYearMonth> iso_year_month_from_fields(GlobalObject&, Object const& fields, Object const& options);
Optional<ISOMonthDay> iso_month_day_from_fields(GlobalObject&, Object& fields, Object& options); Optional<ISOMonthDay> iso_month_day_from_fields(GlobalObject&, Object const& fields, Object const& options);
i32 iso_year(Object& temporal_object); i32 iso_year(Object& temporal_object);
u8 iso_month(Object& temporal_object); u8 iso_month(Object& temporal_object);
String iso_month_code(Object& temporal_object); String iso_month_code(Object& temporal_object);