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

LibJS: Convert Calendar AOs to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-09-16 21:42:01 +01:00
parent dea43d88e7
commit f8d92232c8
22 changed files with 349 additions and 416 deletions

View file

@ -7,6 +7,7 @@
#pragma once
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/Temporal/PlainDate.h>
#include <LibJS/Runtime/Temporal/PlainMonthDay.h>
@ -29,34 +30,34 @@ private:
String m_identifier; // [[Identifier]]
};
Calendar* create_temporal_calendar(GlobalObject&, String const& identifier, FunctionObject const* new_target = nullptr);
ThrowCompletionOr<Calendar*> create_temporal_calendar(GlobalObject&, String const& identifier, FunctionObject const* new_target = nullptr);
bool is_builtin_calendar(String const& identifier);
Calendar* get_builtin_calendar(GlobalObject&, String const& identifier);
ThrowCompletionOr<Calendar*> get_builtin_calendar(GlobalObject&, String const& identifier);
Calendar* get_iso8601_calendar(GlobalObject&);
Vector<String> calendar_fields(GlobalObject&, Object& calendar, Vector<StringView> const& field_names);
double calendar_year(GlobalObject&, Object& calendar, Object& date_like);
double calendar_month(GlobalObject&, Object& calendar, Object& date_like);
String calendar_month_code(GlobalObject&, Object& calendar, Object& date_like);
double calendar_day(GlobalObject&, Object& calendar, Object& date_like);
Value calendar_day_of_week(GlobalObject&, Object& calendar, Object& date_like);
Value calendar_day_of_year(GlobalObject&, Object& calendar, Object& date_like);
Value calendar_week_of_year(GlobalObject&, Object& calendar, Object& date_like);
Value calendar_days_in_week(GlobalObject&, Object& calendar, Object& date_like);
Value calendar_days_in_month(GlobalObject&, Object& calendar, Object& date_like);
Value calendar_days_in_year(GlobalObject&, Object& calendar, Object& date_like);
Value calendar_months_in_year(GlobalObject&, Object& calendar, Object& date_like);
Value calendar_in_leap_year(GlobalObject&, Object& calendar, Object& date_like);
Value calendar_era(GlobalObject&, Object& calendar, Object& date_like);
Value calendar_era_year(GlobalObject&, Object& calendar, Object& date_like);
Object* to_temporal_calendar(GlobalObject&, Value);
Object* to_temporal_calendar_with_iso_default(GlobalObject&, Value);
Object* get_temporal_calendar_with_iso_default(GlobalObject&, Object&);
PlainDate* date_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const& options);
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 const& fields, Object const* options = nullptr);
ThrowCompletionOr<Vector<String>> calendar_fields(GlobalObject&, Object& calendar, Vector<StringView> const& field_names);
ThrowCompletionOr<double> calendar_year(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<double> calendar_month(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<String> calendar_month_code(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<double> calendar_day(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<Value> calendar_day_of_week(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<Value> calendar_day_of_year(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<Value> calendar_week_of_year(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<Value> calendar_days_in_week(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<Value> calendar_days_in_month(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<Value> calendar_days_in_year(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<Value> calendar_months_in_year(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<Value> calendar_in_leap_year(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<Value> calendar_era(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<Value> calendar_era_year(GlobalObject&, Object& calendar, Object& date_like);
ThrowCompletionOr<Object*> to_temporal_calendar(GlobalObject&, Value);
ThrowCompletionOr<Object*> to_temporal_calendar_with_iso_default(GlobalObject&, Value);
ThrowCompletionOr<Object*> get_temporal_calendar_with_iso_default(GlobalObject&, Object&);
ThrowCompletionOr<PlainDate*> date_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const& options);
ThrowCompletionOr<PlainYearMonth*> year_month_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const* options = nullptr);
ThrowCompletionOr<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);
bool calendar_equals(GlobalObject&, Object& one, Object& two);
Object* consolidate_calendars(GlobalObject&, Object& one, Object& two);
ThrowCompletionOr<bool> calendar_equals(GlobalObject&, Object& one, Object& two);
ThrowCompletionOr<Object*> consolidate_calendars(GlobalObject&, Object& one, Object& two);
bool is_iso_leap_year(i32 year);
u16 iso_days_in_year(i32 year);
u8 iso_days_in_month(i32 year, u8 month);
@ -64,14 +65,14 @@ u8 to_iso_day_of_week(i32 year, u8 month, u8 day);
u16 to_iso_day_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);
double resolve_iso_month(GlobalObject&, Object const& fields);
Optional<ISODate> iso_date_from_fields(GlobalObject&, Object const& fields, Object const& options);
Optional<ISOYearMonth> iso_year_month_from_fields(GlobalObject&, Object const& fields, Object const& options);
Optional<ISOMonthDay> iso_month_day_from_fields(GlobalObject&, Object const& fields, Object const& options);
ThrowCompletionOr<double> resolve_iso_month(GlobalObject&, Object const& fields);
ThrowCompletionOr<ISODate> iso_date_from_fields(GlobalObject&, Object const& fields, Object const& options);
ThrowCompletionOr<ISOYearMonth> iso_year_month_from_fields(GlobalObject&, Object const& fields, Object const& options);
ThrowCompletionOr<ISOMonthDay> iso_month_day_from_fields(GlobalObject&, Object const& fields, Object const& options);
i32 iso_year(Object& temporal_object);
u8 iso_month(Object& temporal_object);
String iso_month_code(Object& temporal_object);
u8 iso_day(Object& temporal_object);
Object* default_merge_fields(GlobalObject&, Object const& fields, Object const& additional_fields);
ThrowCompletionOr<Object*> default_merge_fields(GlobalObject&, Object const& fields, Object const& additional_fields);
}