summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-12-21 14:37:27 +0000
committerTim Flynn <trflynn89@pm.me>2023-01-26 09:57:14 -0500
commitad9b2043dd82badb6a8730a20710c4042fa4dfd5 (patch)
tree4528c89b5d10395be1c5e581646356a9371db890
parent77e15ff4daecc28d0cc120b685c41db87681855d (diff)
downloadserenity-ad9b2043dd82badb6a8730a20710c4042fa4dfd5.zip
CodeGenerators: Replace uses of JsonObject::get_deprecated()/get_ptr()
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp60
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp176
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp257
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp78
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp10
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp10
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp18
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp40
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp6
9 files changed, 326 insertions, 329 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp b/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp
index 601435ecba..e44191c93d 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp
@@ -82,16 +82,16 @@ struct EncodedType {
bool is_const_pointer;
};
-Vector<DeprecatedString> get_name_list(JsonValue const& name_definition)
+Vector<DeprecatedString> get_name_list(Optional<JsonValue const&> name_definition)
{
- if (name_definition.is_null())
+ if (!name_definition.has_value() || name_definition->is_null())
return {};
Vector<DeprecatedString, 1> names;
- if (name_definition.is_string()) {
- names.append(name_definition.as_string());
- } else if (name_definition.is_array()) {
- name_definition.as_array().for_each([&names](auto& value) {
+ if (name_definition->is_string()) {
+ names.append(name_definition->as_string());
+ } else if (name_definition->is_array()) {
+ name_definition->as_array().for_each([&names](auto& value) {
VERIFY(value.is_string());
names.append(value.as_string());
});
@@ -167,38 +167,38 @@ Variants read_variants_settings(JsonObject const& variants_obj)
{
Variants variants;
- if (variants_obj.has("argument_counts"sv)) {
+ if (variants_obj.has_array("argument_counts"sv)) {
variants.argument_counts.clear_with_capacity();
- variants_obj.get_deprecated("argument_counts"sv).as_array().for_each([&](auto const& argument_count_value) {
+ variants_obj.get_array("argument_counts"sv)->for_each([&](auto const& argument_count_value) {
variants.argument_counts.append(argument_count_value.to_u32());
});
}
- if (variants_obj.has("argument_defaults"sv)) {
+ if (variants_obj.has_array("argument_defaults"sv)) {
variants.argument_defaults.clear_with_capacity();
- variants_obj.get_deprecated("argument_defaults"sv).as_array().for_each([&](auto const& argument_default_value) {
+ variants_obj.get_array("argument_defaults"sv)->for_each([&](auto const& argument_default_value) {
variants.argument_defaults.append(argument_default_value.as_string());
});
}
- if (variants_obj.has("convert_range"sv)) {
- variants.convert_range = variants_obj.get_deprecated("convert_range"sv).to_bool();
+ if (variants_obj.has_bool("convert_range"sv)) {
+ variants.convert_range = variants_obj.get_bool("convert_range"sv).value();
}
- if (variants_obj.has("api_suffixes"sv)) {
+ if (variants_obj.has_array("api_suffixes"sv)) {
variants.api_suffixes.clear_with_capacity();
- variants_obj.get_deprecated("api_suffixes"sv).as_array().for_each([&](auto const& suffix_value) {
+ variants_obj.get_array("api_suffixes"sv)->for_each([&](auto const& suffix_value) {
variants.api_suffixes.append(suffix_value.as_string());
});
}
- if (variants_obj.has("pointer_argument"sv)) {
- variants.pointer_argument = variants_obj.get_deprecated("pointer_argument"sv).as_string();
+ if (variants_obj.has_string("pointer_argument"sv)) {
+ variants.pointer_argument = variants_obj.get_deprecated_string("pointer_argument"sv).value();
}
- if (variants_obj.has("types"sv)) {
+ if (variants_obj.has_object("types"sv)) {
variants.types.clear_with_capacity();
- variants_obj.get_deprecated("types"sv).as_object().for_each_member([&](auto const& key, auto const& type_value) {
+ variants_obj.get_object("types"sv)->for_each_member([&](auto const& key, auto const& type_value) {
auto const& type = type_value.as_object();
variants.types.append(VariantType {
.encoded_type = key,
- .implementation = type.has("implementation"sv) ? type.get_deprecated("implementation"sv).as_string() : Optional<DeprecatedString> {},
- .unimplemented = type.get_deprecated("unimplemented"sv).to_bool(false),
+ .implementation = type.get_deprecated_string("implementation"sv),
+ .unimplemented = type.get_bool("unimplemented"sv).value_or(false),
});
});
}
@@ -279,17 +279,15 @@ Vector<FunctionDefinition> create_function_definitions(DeprecatedString function
// Parse base argument definitions first; these may later be modified by variants
Vector<ArgumentDefinition> argument_definitions;
- JsonArray const& arguments = function_definition.has("arguments"sv)
- ? function_definition.get_deprecated("arguments"sv).as_array()
- : JsonArray {};
+ JsonArray const& arguments = function_definition.get_array("arguments"sv).value_or(JsonArray {});
arguments.for_each([&argument_definitions](auto const& argument_value) {
VERIFY(argument_value.is_object());
auto const& argument = argument_value.as_object();
- auto type = argument.has("type"sv) ? argument.get_deprecated("type"sv).as_string() : Optional<DeprecatedString> {};
- auto argument_names = get_name_list(argument.get_deprecated("name"sv));
- auto expression = argument.get_deprecated("expression"sv).as_string_or("@argument_name@");
- auto cast_to = argument.has("cast_to"sv) ? argument.get_deprecated("cast_to"sv).as_string() : Optional<DeprecatedString> {};
+ auto type = argument.get_deprecated_string("type"sv);
+ auto argument_names = get_name_list(argument.get("name"sv));
+ auto expression = argument.get_deprecated_string("expression"sv).value_or("@argument_name@");
+ auto cast_to = argument.get_deprecated_string("cast_to"sv);
// Add an empty dummy name when all we have is an expression
if (argument_names.is_empty() && !expression.is_empty())
@@ -306,9 +304,9 @@ Vector<FunctionDefinition> create_function_definitions(DeprecatedString function
// Create functions for each name and/or variant
Vector<FunctionDefinition> functions;
- auto return_type = function_definition.get_deprecated("return_type"sv).as_string_or("void"sv);
- auto function_implementation = function_definition.get_deprecated("implementation"sv).as_string_or(function_name.to_snakecase());
- auto function_unimplemented = function_definition.get_deprecated("unimplemented"sv).to_bool(false);
+ auto return_type = function_definition.get_deprecated_string("return_type"sv).value_or("void");
+ auto function_implementation = function_definition.get_deprecated_string("implementation"sv).value_or(function_name.to_snakecase());
+ auto function_unimplemented = function_definition.get_bool("unimplemented"sv).value_or(false);
if (!function_definition.has("variants"sv)) {
functions.append({
@@ -323,7 +321,7 @@ Vector<FunctionDefinition> create_function_definitions(DeprecatedString function
}
// Read variants settings for this function
- auto variants_obj = function_definition.get_deprecated("variants"sv).as_object();
+ auto variants_obj = function_definition.get_object("variants"sv).value();
auto variants = read_variants_settings(variants_obj);
for (auto argument_count : variants.argument_counts) {
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp
index 7f8732bf7d..67ab671002 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp
@@ -572,8 +572,8 @@ static ErrorOr<void> parse_hour_cycles(DeprecatedString core_path, CLDR& cldr)
time_data_path = time_data_path.append("timeData.json"sv);
auto time_data = TRY(read_json_file(time_data_path.string()));
- auto const& supplemental_object = time_data.as_object().get_deprecated("supplemental"sv);
- auto const& time_data_object = supplemental_object.as_object().get_deprecated("timeData"sv);
+ auto const& supplemental_object = time_data.as_object().get_object("supplemental"sv).value();
+ auto const& time_data_object = supplemental_object.get_object("timeData"sv).value();
auto parse_hour_cycle = [](StringView hour_cycle) -> Optional<Locale::HourCycle> {
if (hour_cycle == "h"sv)
@@ -587,8 +587,8 @@ static ErrorOr<void> parse_hour_cycles(DeprecatedString core_path, CLDR& cldr)
return {};
};
- time_data_object.as_object().for_each_member([&](auto const& key, JsonValue const& value) {
- auto allowed_hour_cycles_string = value.as_object().get_deprecated("_allowed"sv).as_string();
+ time_data_object.for_each_member([&](auto const& key, JsonValue const& value) {
+ auto allowed_hour_cycles_string = value.as_object().get_deprecated_string("_allowed"sv).value();
auto allowed_hour_cycles = allowed_hour_cycles_string.split_view(' ');
Vector<Locale::HourCycle> hour_cycles;
@@ -616,8 +616,8 @@ static ErrorOr<void> parse_week_data(DeprecatedString core_path, CLDR& cldr)
week_data_path = week_data_path.append("weekData.json"sv);
auto week_data = TRY(read_json_file(week_data_path.string()));
- auto const& supplemental_object = week_data.as_object().get_deprecated("supplemental"sv);
- auto const& week_data_object = supplemental_object.as_object().get_deprecated("weekData"sv);
+ auto const& supplemental_object = week_data.as_object().get_object("supplemental"sv).value();
+ auto const& week_data_object = supplemental_object.get_object("weekData"sv).value();
auto parse_weekday = [](StringView day) -> Locale::Weekday {
if (day == "sun"sv)
@@ -647,12 +647,12 @@ static ErrorOr<void> parse_week_data(DeprecatedString core_path, CLDR& cldr)
weekday_regions.append(region);
};
- auto const& minimum_days_object = week_data_object.as_object().get_deprecated("minDays"sv);
- auto const& first_day_object = week_data_object.as_object().get_deprecated("firstDay"sv);
- auto const& weekend_start_object = week_data_object.as_object().get_deprecated("weekendStart"sv);
- auto const& weekend_end_object = week_data_object.as_object().get_deprecated("weekendEnd"sv);
+ auto const& minimum_days_object = week_data_object.get_object("minDays"sv).value();
+ auto const& first_day_object = week_data_object.get_object("firstDay"sv).value();
+ auto const& weekend_start_object = week_data_object.get_object("weekendStart"sv).value();
+ auto const& weekend_end_object = week_data_object.get_object("weekendEnd"sv).value();
- minimum_days_object.as_object().for_each_member([&](auto const& region, auto const& value) {
+ minimum_days_object.for_each_member([&](auto const& region, auto const& value) {
auto minimum_days = value.as_string().template to_uint<u8>();
cldr.minimum_days.set(region, *minimum_days);
@@ -660,13 +660,13 @@ static ErrorOr<void> parse_week_data(DeprecatedString core_path, CLDR& cldr)
cldr.minimum_days_regions.append(region);
});
- first_day_object.as_object().for_each_member([&](auto const& region, auto const& value) {
+ first_day_object.for_each_member([&](auto const& region, auto const& value) {
parse_regional_weekdays(region, value.as_string(), cldr.first_day, cldr.first_day_regions);
});
- weekend_start_object.as_object().for_each_member([&](auto const& region, auto const& value) {
+ weekend_start_object.for_each_member([&](auto const& region, auto const& value) {
parse_regional_weekdays(region, value.as_string(), cldr.weekend_start, cldr.weekend_start_regions);
});
- weekend_end_object.as_object().for_each_member([&](auto const& region, auto const& value) {
+ weekend_end_object.for_each_member([&](auto const& region, auto const& value) {
parse_regional_weekdays(region, value.as_string(), cldr.weekend_end, cldr.weekend_end_regions);
});
@@ -681,17 +681,17 @@ static ErrorOr<void> parse_meta_zones(DeprecatedString core_path, CLDR& cldr)
meta_zone_path = meta_zone_path.append("metaZones.json"sv);
auto meta_zone = TRY(read_json_file(meta_zone_path.string()));
- auto const& supplemental_object = meta_zone.as_object().get_deprecated("supplemental"sv);
- auto const& meta_zone_object = supplemental_object.as_object().get_deprecated("metaZones"sv);
- auto const& meta_zone_array = meta_zone_object.as_object().get_deprecated("metazones"sv);
+ auto const& supplemental_object = meta_zone.as_object().get_object("supplemental"sv).value();
+ auto const& meta_zone_object = supplemental_object.get_object("metaZones"sv).value();
+ auto const& meta_zone_array = meta_zone_object.get_array("metazones"sv).value();
- meta_zone_array.as_array().for_each([&](JsonValue const& value) {
- auto const& mapping = value.as_object().get_deprecated("mapZone"sv);
- auto const& meta_zone = mapping.as_object().get_deprecated("_other"sv);
- auto const& golden_zone = mapping.as_object().get_deprecated("_type"sv);
+ meta_zone_array.for_each([&](JsonValue const& value) {
+ auto const& mapping = value.as_object().get_object("mapZone"sv).value();
+ auto const& meta_zone = mapping.get_deprecated_string("_other"sv).value();
+ auto const& golden_zone = mapping.get_deprecated_string("_type"sv).value();
- if (auto time_zone = TimeZone::time_zone_from_string(golden_zone.as_string()); time_zone.has_value()) {
- auto& golden_zones = cldr.meta_zones.ensure(meta_zone.as_string());
+ if (auto time_zone = TimeZone::time_zone_from_string(golden_zone); time_zone.has_value()) {
+ auto& golden_zones = cldr.meta_zones.ensure(meta_zone);
golden_zones.append(*time_zone);
}
});
@@ -1263,9 +1263,9 @@ static void parse_calendar_symbols(Calendar& calendar, JsonObject const& calenda
};
auto parse_era_symbols = [&](auto const& symbols_object) {
- auto const& narrow_symbols = symbols_object.get_deprecated("eraNarrow"sv).as_object();
- auto const& short_symbols = symbols_object.get_deprecated("eraAbbr"sv).as_object();
- auto const& long_symbols = symbols_object.get_deprecated("eraNames"sv).as_object();
+ auto const& narrow_symbols = symbols_object.get_object("eraNarrow"sv).value();
+ auto const& short_symbols = symbols_object.get_object("eraAbbr"sv).value();
+ auto const& long_symbols = symbols_object.get_object("eraNames"sv).value();
auto symbol_lists = create_symbol_lists(2);
auto append_symbol = [&](auto& symbols, auto const& key, auto symbol) {
@@ -1287,9 +1287,9 @@ static void parse_calendar_symbols(Calendar& calendar, JsonObject const& calenda
};
auto parse_month_symbols = [&](auto const& symbols_object) {
- auto const& narrow_symbols = symbols_object.get_deprecated("narrow"sv).as_object();
- auto const& short_symbols = symbols_object.get_deprecated("abbreviated"sv).as_object();
- auto const& long_symbols = symbols_object.get_deprecated("wide"sv).as_object();
+ auto const& narrow_symbols = symbols_object.get_object("narrow"sv).value();
+ auto const& short_symbols = symbols_object.get_object("abbreviated"sv).value();
+ auto const& long_symbols = symbols_object.get_object("wide"sv).value();
auto symbol_lists = create_symbol_lists(12);
auto append_symbol = [&](auto& symbols, auto const& key, auto symbol) {
@@ -1311,9 +1311,9 @@ static void parse_calendar_symbols(Calendar& calendar, JsonObject const& calenda
};
auto parse_weekday_symbols = [&](auto const& symbols_object) {
- auto const& narrow_symbols = symbols_object.get_deprecated("narrow"sv).as_object();
- auto const& short_symbols = symbols_object.get_deprecated("abbreviated"sv).as_object();
- auto const& long_symbols = symbols_object.get_deprecated("wide"sv).as_object();
+ auto const& narrow_symbols = symbols_object.get_object("narrow"sv).value();
+ auto const& short_symbols = symbols_object.get_object("abbreviated"sv).value();
+ auto const& long_symbols = symbols_object.get_object("wide"sv).value();
auto symbol_lists = create_symbol_lists(7);
auto append_symbol = [&](auto& symbols, auto const& key, auto symbol) {
@@ -1347,9 +1347,9 @@ static void parse_calendar_symbols(Calendar& calendar, JsonObject const& calenda
};
auto parse_day_period_symbols = [&](auto const& symbols_object) {
- auto const& narrow_symbols = symbols_object.get_deprecated("narrow"sv).as_object();
- auto const& short_symbols = symbols_object.get_deprecated("abbreviated"sv).as_object();
- auto const& long_symbols = symbols_object.get_deprecated("wide"sv).as_object();
+ auto const& narrow_symbols = symbols_object.get_object("narrow"sv).value();
+ auto const& short_symbols = symbols_object.get_object("abbreviated"sv).value();
+ auto const& long_symbols = symbols_object.get_object("wide"sv).value();
auto symbol_lists = create_symbol_lists(11);
auto append_symbol = [&](auto& symbols, auto const& key, auto symbol) {
@@ -1370,10 +1370,10 @@ static void parse_calendar_symbols(Calendar& calendar, JsonObject const& calenda
store_symbol_lists(Locale::CalendarSymbol::DayPeriod, move(symbol_lists));
};
- parse_era_symbols(calendar_object.get_deprecated("eras"sv).as_object());
- parse_month_symbols(calendar_object.get_deprecated("months"sv).as_object().get_deprecated("format"sv).as_object());
- parse_weekday_symbols(calendar_object.get_deprecated("days"sv).as_object().get_deprecated("format"sv).as_object());
- parse_day_period_symbols(calendar_object.get_deprecated("dayPeriods"sv).as_object().get_deprecated("format"sv).as_object());
+ parse_era_symbols(calendar_object.get_object("eras"sv).value());
+ parse_month_symbols(calendar_object.get_object("months"sv)->get_object("format"sv).value());
+ parse_weekday_symbols(calendar_object.get_object("days"sv)->get_object("format"sv).value());
+ parse_day_period_symbols(calendar_object.get_object("dayPeriods"sv)->get_object("format"sv).value());
calendar.symbols = cldr.unique_calendar_symbols_lists.ensure(move(symbols_list));
}
@@ -1385,17 +1385,17 @@ static ErrorOr<void> parse_calendars(DeprecatedString locale_calendars_path, CLD
return {};
auto calendars = TRY(read_json_file(calendars_path.string()));
- auto const& main_object = calendars.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(calendars_path.parent().basename());
- auto const& dates_object = locale_object.as_object().get_deprecated("dates"sv);
- auto const& calendars_object = dates_object.as_object().get_deprecated("calendars"sv);
+ auto const& main_object = calendars.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(calendars_path.parent().basename()).value();
+ auto const& dates_object = locale_object.get_object("dates"sv).value();
+ auto const& calendars_object = dates_object.get_object("calendars"sv).value();
auto parse_patterns = [&](auto const& patterns_object, auto const& skeletons_object, Vector<CalendarPattern>* patterns) {
auto parse_pattern = [&](auto name) {
- auto format = patterns_object.get_deprecated(name);
- auto skeleton = skeletons_object.get_deprecated(name);
+ auto format = patterns_object.get_deprecated_string(name);
+ auto skeleton = skeletons_object.get_deprecated_string(name);
- auto format_index = parse_date_time_pattern(format.as_string(), skeleton.as_string_or(DeprecatedString::empty()), cldr).value();
+ auto format_index = parse_date_time_pattern(format.value(), skeleton.value_or(DeprecatedString::empty()), cldr).value();
if (patterns)
patterns->append(cldr.unique_patterns.get(format_index));
@@ -1412,7 +1412,7 @@ static ErrorOr<void> parse_calendars(DeprecatedString locale_calendars_path, CLD
return cldr.unique_formats.ensure(move(formats));
};
- calendars_object.as_object().for_each_member([&](auto const& calendar_name, JsonValue const& value) {
+ calendars_object.for_each_member([&](auto const& calendar_name, JsonValue const& value) {
// The generic calendar is not a supported Unicode calendar key, so skip it:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar#unicode_calendar_keys
if (calendar_name == "generic"sv)
@@ -1427,20 +1427,20 @@ static ErrorOr<void> parse_calendars(DeprecatedString locale_calendars_path, CLD
Vector<CalendarPattern> date_formats;
Vector<CalendarPattern> time_formats;
- auto const& date_formats_object = value.as_object().get_deprecated("dateFormats"sv);
- auto const& date_skeletons_object = value.as_object().get_deprecated("dateSkeletons"sv);
- calendar.date_formats = parse_patterns(date_formats_object.as_object(), date_skeletons_object.as_object(), &date_formats);
+ auto const& date_formats_object = value.as_object().get_object("dateFormats"sv).value();
+ auto const& date_skeletons_object = value.as_object().get_object("dateSkeletons"sv).value();
+ calendar.date_formats = parse_patterns(date_formats_object, date_skeletons_object, &date_formats);
- auto const& time_formats_object = value.as_object().get_deprecated("timeFormats"sv);
- auto const& time_skeletons_object = value.as_object().get_deprecated("timeSkeletons"sv);
- calendar.time_formats = parse_patterns(time_formats_object.as_object(), time_skeletons_object.as_object(), &time_formats);
+ auto const& time_formats_object = value.as_object().get_object("timeFormats"sv).value();
+ auto const& time_skeletons_object = value.as_object().get_object("timeSkeletons"sv).value();
+ calendar.time_formats = parse_patterns(time_formats_object, time_skeletons_object, &time_formats);
- auto const& standard_date_time_formats_object = value.as_object().get_deprecated("dateTimeFormats-atTime"sv).as_object().get_deprecated("standard"sv);
- calendar.date_time_formats = parse_patterns(standard_date_time_formats_object.as_object(), JsonObject {}, nullptr);
+ auto const& standard_date_time_formats_object = value.as_object().get_object("dateTimeFormats-atTime"sv)->get_object("standard"sv).value();
+ calendar.date_time_formats = parse_patterns(standard_date_time_formats_object, JsonObject {}, nullptr);
- auto const& date_time_formats_object = value.as_object().get_deprecated("dateTimeFormats"sv);
- auto const& available_formats_object = date_time_formats_object.as_object().get_deprecated("availableFormats"sv);
- available_formats_object.as_object().for_each_member([&](auto const& skeleton, JsonValue const& pattern) {
+ auto const& date_time_formats_object = value.as_object().get_object("dateTimeFormats"sv).value();
+ auto const& available_formats_object = date_time_formats_object.get_object("availableFormats"sv).value();
+ available_formats_object.for_each_member([&](auto const& skeleton, JsonValue const& pattern) {
auto pattern_index = parse_date_time_pattern(pattern.as_string(), skeleton, cldr);
if (!pattern_index.has_value())
return;
@@ -1455,8 +1455,8 @@ static ErrorOr<void> parse_calendars(DeprecatedString locale_calendars_path, CLD
available_formats.append(*pattern_index);
});
- auto const& interval_formats_object = date_time_formats_object.as_object().get_deprecated("intervalFormats"sv);
- parse_interval_patterns(calendar, interval_formats_object.as_object(), cldr);
+ auto const& interval_formats_object = date_time_formats_object.get_object("intervalFormats"sv).value();
+ parse_interval_patterns(calendar, interval_formats_object, cldr);
generate_default_patterns(available_formats, cldr);
generate_missing_patterns(calendar, available_formats, move(date_formats), move(time_formats), cldr);
@@ -1475,26 +1475,26 @@ static ErrorOr<void> parse_time_zone_names(DeprecatedString locale_time_zone_nam
time_zone_names_path = time_zone_names_path.append("timeZoneNames.json"sv);
auto time_zone_names = TRY(read_json_file(time_zone_names_path.string()));
- auto const& main_object = time_zone_names.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(time_zone_names_path.parent().basename());
- auto const& dates_object = locale_object.as_object().get_deprecated("dates"sv);
- auto const& time_zone_names_object = dates_object.as_object().get_deprecated("timeZoneNames"sv);
- auto const& meta_zone_object = time_zone_names_object.as_object().get_deprecated("metazone"sv);
- auto const& hour_format_string = time_zone_names_object.as_object().get_deprecated("hourFormat"sv);
- auto const& gmt_format_string = time_zone_names_object.as_object().get_deprecated("gmtFormat"sv);
- auto const& gmt_zero_format_string = time_zone_names_object.as_object().get_deprecated("gmtZeroFormat"sv);
-
- if (meta_zone_object.is_null())
+ auto const& main_object = time_zone_names.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(time_zone_names_path.parent().basename()).value();
+ auto const& dates_object = locale_object.get_object("dates"sv).value();
+ auto const& time_zone_names_object = dates_object.get_object("timeZoneNames"sv).value();
+ auto const& meta_zone_object = time_zone_names_object.get_object("metazone"sv);
+ auto const& hour_format_string = time_zone_names_object.get_deprecated_string("hourFormat"sv).value();
+ auto const& gmt_format_string = time_zone_names_object.get_deprecated_string("gmtFormat"sv).value();
+ auto const& gmt_zero_format_string = time_zone_names_object.get_deprecated_string("gmtZeroFormat"sv).value();
+
+ if (!meta_zone_object.has_value())
return {};
auto parse_name = [&](StringView type, JsonObject const& meta_zone_object, StringView key) -> Optional<size_t> {
- auto const& names = meta_zone_object.get_deprecated(type);
- if (!names.is_object())
+ auto const& names = meta_zone_object.get_object(type);
+ if (!names.has_value())
return {};
- auto const& name = names.as_object().get_deprecated(key);
- if (name.is_string())
- return cldr.unique_strings.ensure(name.as_string());
+ auto const& name = names->get_deprecated_string(key);
+ if (name.has_value())
+ return cldr.unique_strings.ensure(name.value());
return {};
};
@@ -1525,9 +1525,9 @@ static ErrorOr<void> parse_time_zone_names(DeprecatedString locale_time_zone_nam
TimeZoneNamesList time_zones;
TimeZoneFormat time_zone_formats {};
- parse_hour_format(hour_format_string.as_string(), time_zone_formats);
- time_zone_formats.gmt_format = cldr.unique_strings.ensure(gmt_format_string.as_string());
- time_zone_formats.gmt_zero_format = cldr.unique_strings.ensure(gmt_zero_format_string.as_string());
+ parse_hour_format(hour_format_string, time_zone_formats);
+ time_zone_formats.gmt_format = cldr.unique_strings.ensure(gmt_format_string);
+ time_zone_formats.gmt_zero_format = cldr.unique_strings.ensure(gmt_zero_format_string);
auto parse_time_zone = [&](StringView meta_zone, JsonObject const& meta_zone_object) {
auto golden_zones = cldr.meta_zones.find(meta_zone);
@@ -1562,15 +1562,15 @@ static ErrorOr<void> parse_time_zone_names(DeprecatedString locale_time_zone_nam
}
};
- meta_zone_object.as_object().for_each_member([&](auto const& meta_zone, JsonValue const& value) {
+ meta_zone_object->for_each_member([&](auto const& meta_zone, JsonValue const& value) {
parse_time_zone(meta_zone, value.as_object());
});
// The long and short names for UTC are not under the "timeZoneNames/metazone" object, but are under "timeZoneNames/zone/Etc".
- auto const& zone_object = time_zone_names_object.as_object().get_deprecated("zone"sv);
- auto const& etc_object = zone_object.as_object().get_deprecated("Etc"sv);
- auto const& utc_object = etc_object.as_object().get_deprecated("UTC"sv);
- parse_time_zone("UTC"sv, utc_object.as_object());
+ auto const& zone_object = time_zone_names_object.get_object("zone"sv).value();
+ auto const& etc_object = zone_object.get_object("Etc"sv).value();
+ auto const& utc_object = etc_object.get_object("UTC"sv).value();
+ parse_time_zone("UTC"sv, utc_object);
locale.time_zones = cldr.unique_time_zone_lists.ensure(move(time_zones));
locale.time_zone_formats = cldr.unique_time_zone_formats.ensure(move(time_zone_formats));
@@ -1586,8 +1586,8 @@ static ErrorOr<void> parse_day_periods(DeprecatedString core_path, CLDR& cldr)
day_periods_path = day_periods_path.append("dayPeriods.json"sv);
auto locale_day_periods = TRY(read_json_file(day_periods_path.string()));
- auto const& supplemental_object = locale_day_periods.as_object().get_deprecated("supplemental"sv);
- auto const& day_periods_object = supplemental_object.as_object().get_deprecated("dayPeriodRuleSet"sv);
+ auto const& supplemental_object = locale_day_periods.as_object().get_object("supplemental"sv).value();
+ auto const& day_periods_object = supplemental_object.get_object("dayPeriodRuleSet"sv).value();
auto parse_hour = [](auto const& time) {
auto hour_end_index = time.find(':').value();
@@ -1608,13 +1608,13 @@ static ErrorOr<void> parse_day_periods(DeprecatedString core_path, CLDR& cldr)
if (!day_period.has_value())
return {};
- auto begin = parse_hour(ranges.get_deprecated("_from"sv).as_string());
- auto end = parse_hour(ranges.get_deprecated("_before"sv).as_string());
+ auto begin = parse_hour(ranges.get_deprecated_string("_from"sv).value());
+ auto end = parse_hour(ranges.get_deprecated_string("_before"sv).value());
return DayPeriod { *day_period, begin, end };
};
- day_periods_object.as_object().for_each_member([&](auto const& language, JsonValue const& value) {
+ day_periods_object.for_each_member([&](auto const& language, JsonValue const& value) {
auto locale = cldr.locales.find(language);
if (locale == cldr.locales.end())
return;
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp
index e762aabf31..6ef5fee618 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp
@@ -254,13 +254,13 @@ static ErrorOr<void> parse_core_aliases(DeprecatedString core_supplemental_path,
core_aliases_path = core_aliases_path.append("aliases.json"sv);
auto core_aliases = TRY(read_json_file(core_aliases_path.string()));
- auto const& supplemental_object = core_aliases.as_object().get_deprecated("supplemental"sv);
- auto const& metadata_object = supplemental_object.as_object().get_deprecated("metadata"sv);
- auto const& alias_object = metadata_object.as_object().get_deprecated("alias"sv);
+ auto const& supplemental_object = core_aliases.as_object().get_object("supplemental"sv).value();
+ auto const& metadata_object = supplemental_object.get_object("metadata"sv).value();
+ auto const& alias_object = metadata_object.get_object("alias"sv).value();
auto append_aliases = [&](auto& alias_object, auto& alias_map) {
- alias_object.as_object().for_each_member([&](auto const& key, JsonValue const& value) {
- auto alias = value.as_object().get_deprecated("_replacement"sv).as_string();
+ alias_object.for_each_member([&](auto const& key, JsonValue const& value) {
+ auto alias = value.as_object().get_deprecated_string("_replacement"sv).value();
if (key.contains('-')) {
auto mapping = TRY_OR_DISCARD(parse_language_mapping(cldr, key, alias));
@@ -273,11 +273,11 @@ static ErrorOr<void> parse_core_aliases(DeprecatedString core_supplemental_path,
});
};
- append_aliases(alias_object.as_object().get_deprecated("languageAlias"sv), cldr.language_aliases);
- append_aliases(alias_object.as_object().get_deprecated("territoryAlias"sv), cldr.territory_aliases);
- append_aliases(alias_object.as_object().get_deprecated("scriptAlias"sv), cldr.script_aliases);
- append_aliases(alias_object.as_object().get_deprecated("variantAlias"sv), cldr.variant_aliases);
- append_aliases(alias_object.as_object().get_deprecated("subdivisionAlias"sv), cldr.subdivision_aliases);
+ append_aliases(alias_object.get_object("languageAlias"sv).value(), cldr.language_aliases);
+ append_aliases(alias_object.get_object("territoryAlias"sv).value(), cldr.territory_aliases);
+ append_aliases(alias_object.get_object("scriptAlias"sv).value(), cldr.script_aliases);
+ append_aliases(alias_object.get_object("variantAlias"sv).value(), cldr.variant_aliases);
+ append_aliases(alias_object.get_object("subdivisionAlias"sv).value(), cldr.subdivision_aliases);
return {};
}
@@ -288,10 +288,10 @@ static ErrorOr<void> parse_likely_subtags(DeprecatedString core_supplemental_pat
likely_subtags_path = likely_subtags_path.append("likelySubtags.json"sv);
auto likely_subtags = TRY(read_json_file(likely_subtags_path.string()));
- auto const& supplemental_object = likely_subtags.as_object().get_deprecated("supplemental"sv);
- auto const& likely_subtags_object = supplemental_object.as_object().get_deprecated("likelySubtags"sv);
+ auto const& supplemental_object = likely_subtags.as_object().get_object("supplemental"sv).value();
+ auto const& likely_subtags_object = supplemental_object.get_object("likelySubtags"sv).value();
- likely_subtags_object.as_object().for_each_member([&](auto const& key, JsonValue const& value) {
+ likely_subtags_object.for_each_member([&](auto const& key, JsonValue const& value) {
auto mapping = TRY_OR_DISCARD(parse_language_mapping(cldr, key, value.as_string()));
cldr.max_variant_size = max(mapping.key.variants.size(), cldr.max_variant_size);
cldr.max_variant_size = max(mapping.alias.variants.size(), cldr.max_variant_size);
@@ -307,30 +307,30 @@ static ErrorOr<void> parse_identity(DeprecatedString locale_path, CLDR& cldr, Lo
languages_path = languages_path.append("languages.json"sv);
auto languages = TRY(read_json_file(languages_path.string()));
- auto const& main_object = languages.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(languages_path.parent().basename());
- auto const& identity_object = locale_object.as_object().get_deprecated("identity"sv);
- auto const& language_string = identity_object.as_object().get_deprecated("language"sv);
- auto const& territory_string = identity_object.as_object().get_deprecated("territory"sv);
- auto const& script_string = identity_object.as_object().get_deprecated("script"sv);
- auto const& variant_string = identity_object.as_object().get_deprecated("variant"sv);
-
- locale.language = language_string.as_string();
-
- if (territory_string.is_string()) {
- locale.territory = territory_string.as_string();
+ auto const& main_object = languages.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(languages_path.parent().basename()).value();
+ auto const& identity_object = locale_object.get_object("identity"sv).value();
+ auto const& language_string = identity_object.get_deprecated_string("language"sv).value();
+ auto const& territory_string = identity_object.get_deprecated_string("territory"sv);
+ auto const& script_string = identity_object.get_deprecated_string("script"sv);
+ auto const& variant_string = identity_object.get_deprecated_string("variant"sv);
+
+ locale.language = language_string;
+
+ if (territory_string.has_value()) {
+ locale.territory = territory_string.value();
if (!cldr.territories.contains_slow(*locale.territory))
cldr.territories.append(*locale.territory);
}
- if (script_string.is_string()) {
- auto script = script_string.as_string();
+ if (script_string.has_value()) {
+ auto script = script_string.value();
if (!cldr.scripts.contains_slow(script))
cldr.scripts.append(script);
}
- if (variant_string.is_string()) {
- locale.variant = variant_string.as_string();
+ if (variant_string.has_value()) {
+ locale.variant = variant_string.value();
if (!cldr.variants.contains_slow(*locale.variant))
cldr.variants.append(*locale.variant);
}
@@ -344,16 +344,16 @@ static ErrorOr<void> parse_locale_display_patterns(DeprecatedString locale_path,
locale_display_names_path = locale_display_names_path.append("localeDisplayNames.json"sv);
auto locale_display_names = TRY(read_json_file(locale_display_names_path.string()));
- auto const& main_object = locale_display_names.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(locale_display_names_path.parent().basename());
- auto const& locale_display_names_object = locale_object.as_object().get_deprecated("localeDisplayNames"sv);
- auto const& locale_display_patterns_object = locale_display_names_object.as_object().get_deprecated("localeDisplayPattern"sv);
- auto const& locale_pattern = locale_display_patterns_object.as_object().get_deprecated("localePattern"sv);
- auto const& locale_separator = locale_display_patterns_object.as_object().get_deprecated("localeSeparator"sv);
+ auto const& main_object = locale_display_names.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(locale_display_names_path.parent().basename()).value();
+ auto const& locale_display_names_object = locale_object.get_object("localeDisplayNames"sv).value();
+ auto const& locale_display_patterns_object = locale_display_names_object.get_object("localeDisplayPattern"sv).value();
+ auto const& locale_pattern = locale_display_patterns_object.get_deprecated_string("localePattern"sv).value();
+ auto const& locale_separator = locale_display_patterns_object.get_deprecated_string("localeSeparator"sv).value();
DisplayPattern patterns {};
- patterns.locale_pattern = cldr.unique_strings.ensure(locale_pattern.as_string());
- patterns.locale_separator = cldr.unique_strings.ensure(locale_separator.as_string());
+ patterns.locale_pattern = cldr.unique_strings.ensure(locale_pattern);
+ patterns.locale_separator = cldr.unique_strings.ensure(locale_separator);
locale.display_patterns = cldr.unique_display_patterns.ensure(move(patterns));
return {};
@@ -365,12 +365,12 @@ static ErrorOr<void> preprocess_languages(DeprecatedString locale_path, CLDR& cl
languages_path = languages_path.append("languages.json"sv);
auto locale_languages = TRY(read_json_file(languages_path.string()));
- auto const& main_object = locale_languages.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(languages_path.parent().basename());
- auto const& locale_display_names_object = locale_object.as_object().get_deprecated("localeDisplayNames"sv);
- auto const& languages_object = locale_display_names_object.as_object().get_deprecated("languages"sv);
+ auto const& main_object = locale_languages.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(languages_path.parent().basename()).value();
+ auto const& locale_display_names_object = locale_object.get_object("localeDisplayNames"sv).value();
+ auto const& languages_object = locale_display_names_object.get_object("languages"sv).value();
- languages_object.as_object().for_each_member([&](auto const& key, auto const&) {
+ languages_object.for_each_member([&](auto const& key, auto const&) {
if (!key.contains("-alt-"sv) && !cldr.languages.contains_slow(key))
cldr.languages.append(key);
});
@@ -383,17 +383,17 @@ static ErrorOr<void> parse_unicode_extension_keywords(DeprecatedString bcp47_pat
constexpr auto desired_keywords = Array { "ca"sv, "co"sv, "hc"sv, "kf"sv, "kn"sv, "nu"sv };
auto keywords = TRY(read_json_file(bcp47_path));
- auto const& keyword_object = keywords.as_object().get_deprecated("keyword"sv);
- auto const& unicode_object = keyword_object.as_object().get_deprecated("u"sv);
- if (unicode_object.is_null())
+ auto const& keyword_object = keywords.as_object().get_object("keyword"sv).value();
+ auto unicode_object = keyword_object.get_object("u"sv);
+ if (!unicode_object.has_value())
return {};
- unicode_object.as_object().for_each_member([&](auto const& key, auto const& value) {
+ unicode_object->for_each_member([&](auto const& key, auto const& value) {
if (!desired_keywords.span().contains_slow(key))
return;
- auto const& name = value.as_object().get_deprecated("_alias"sv);
- cldr.keyword_names.set(key, name.as_string());
+ auto const& name = value.as_object().get_deprecated_string("_alias"sv).value();
+ cldr.keyword_names.set(key, name);
auto& keywords = cldr.keywords.ensure(key);
@@ -414,13 +414,13 @@ static ErrorOr<void> parse_unicode_extension_keywords(DeprecatedString bcp47_pat
if (key == "nu"sv && keyword.is_one_of("finance"sv, "native"sv, "traditio"sv))
return;
- if (auto const& preferred = properties.as_object().get_deprecated("_preferred"sv); preferred.is_string()) {
- cldr.keyword_aliases.ensure(key).append({ preferred.as_string(), keyword });
+ if (auto const& preferred = properties.as_object().get_deprecated_string("_preferred"sv); preferred.has_value()) {
+ cldr.keyword_aliases.ensure(key).append({ preferred.value(), keyword });
return;
}
- if (auto const& alias = properties.as_object().get_deprecated("_alias"sv); alias.is_string())
- cldr.keyword_aliases.ensure(key).append({ keyword, alias.as_string() });
+ if (auto const& alias = properties.as_object().get_deprecated_string("_alias"sv); alias.has_value())
+ cldr.keyword_aliases.ensure(key).append({ keyword, alias.value() });
keywords.append(keyword);
});
@@ -448,15 +448,15 @@ static ErrorOr<void> parse_locale_languages(DeprecatedString locale_path, CLDR&
languages_path = languages_path.append("languages.json"sv);
auto locale_languages = TRY(read_json_file(languages_path.string()));
- auto const& main_object = locale_languages.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(languages_path.parent().basename());
- auto const& locale_display_names_object = locale_object.as_object().get_deprecated("localeDisplayNames"sv);
- auto const& languages_object = locale_display_names_object.as_object().get_deprecated("languages"sv);
+ auto const& main_object = locale_languages.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(languages_path.parent().basename()).value();
+ auto const& locale_display_names_object = locale_object.get_object("localeDisplayNames"sv).value();
+ auto const& languages_object = locale_display_names_object.get_object("languages"sv).value();
LanguageList languages;
languages.resize(cldr.languages.size());
- languages_object.as_object().for_each_member([&](auto const& key, JsonValue const& value) {
+ languages_object.for_each_member([&](auto const& key, JsonValue const& value) {
if (key.contains("-alt-"sv))
return;
@@ -474,15 +474,15 @@ static ErrorOr<void> parse_locale_territories(DeprecatedString locale_path, CLDR
territories_path = territories_path.append("territories.json"sv);
auto locale_territories = TRY(read_json_file(territories_path.string()));
- auto const& main_object = locale_territories.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(territories_path.parent().basename());
- auto const& locale_display_names_object = locale_object.as_object().get_deprecated("localeDisplayNames"sv);
- auto const& territories_object = locale_display_names_object.as_object().get_deprecated("territories"sv);
+ auto const& main_object = locale_territories.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(territories_path.parent().basename()).value();
+ auto const& locale_display_names_object = locale_object.get_object("localeDisplayNames"sv).value();
+ auto const& territories_object = locale_display_names_object.get_object("territories"sv).value();
TerritoryList territories;
territories.resize(cldr.territories.size());
- territories_object.as_object().for_each_member([&](auto const& key, JsonValue const& value) {
+ territories_object.for_each_member([&](auto const& key, JsonValue const& value) {
if (auto index = cldr.territories.find_first_index(key); index.has_value())
territories[*index] = cldr.unique_strings.ensure(value.as_string());
});
@@ -497,15 +497,15 @@ static ErrorOr<void> parse_locale_scripts(DeprecatedString locale_path, CLDR& cl
scripts_path = scripts_path.append("scripts.json"sv);
auto locale_scripts = TRY(read_json_file(scripts_path.string()));
- auto const& main_object = locale_scripts.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(scripts_path.parent().basename());
- auto const& locale_display_names_object = locale_object.as_object().get_deprecated("localeDisplayNames"sv);
- auto const& scripts_object = locale_display_names_object.as_object().get_deprecated("scripts"sv);
+ auto const& main_object = locale_scripts.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(scripts_path.parent().basename()).value();
+ auto const& locale_display_names_object = locale_object.get_object("localeDisplayNames"sv).value();
+ auto const& scripts_object = locale_display_names_object.get_object("scripts"sv).value();
ScriptList scripts;
scripts.resize(cldr.scripts.size());
- scripts_object.as_object().for_each_member([&](auto const& key, JsonValue const& value) {
+ scripts_object.for_each_member([&](auto const& key, JsonValue const& value) {
if (auto index = cldr.scripts.find_first_index(key); index.has_value())
scripts[*index] = cldr.unique_strings.ensure(value.as_string());
});
@@ -520,9 +520,9 @@ static ErrorOr<void> parse_locale_list_patterns(DeprecatedString misc_path, CLDR
list_patterns_path = list_patterns_path.append("listPatterns.json"sv);
auto locale_list_patterns = TRY(read_json_file(list_patterns_path.string()));
- auto const& main_object = locale_list_patterns.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(list_patterns_path.parent().basename());
- auto const& list_patterns_object = locale_object.as_object().get_deprecated("listPatterns"sv);
+ auto const& main_object = locale_list_patterns.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(list_patterns_path.parent().basename()).value();
+ auto const& list_patterns_object = locale_object.get_object("listPatterns"sv).value();
auto list_pattern_type = [](StringView key) {
if (key.contains("type-standard"sv))
@@ -543,16 +543,16 @@ static ErrorOr<void> parse_locale_list_patterns(DeprecatedString misc_path, CLDR
};
ListPatternList list_patterns;
- list_patterns.ensure_capacity(list_patterns_object.as_object().size());
+ list_patterns.ensure_capacity(list_patterns_object.size());
- list_patterns_object.as_object().for_each_member([&](auto const& key, JsonValue const& value) {
+ list_patterns_object.for_each_member([&](auto const& key, JsonValue const& value) {
auto type = list_pattern_type(key);
auto style = list_pattern_style(key);
- auto start = cldr.unique_strings.ensure(value.as_object().get_deprecated("start"sv).as_string());
- auto middle = cldr.unique_strings.ensure(value.as_object().get_deprecated("middle"sv).as_string());
- auto end = cldr.unique_strings.ensure(value.as_object().get_deprecated("end"sv).as_string());
- auto pair = cldr.unique_strings.ensure(value.as_object().get_deprecated("2"sv).as_string());
+ auto start = cldr.unique_strings.ensure(value.as_object().get_deprecated_string("start"sv).value());
+ auto middle = cldr.unique_strings.ensure(value.as_object().get_deprecated_string("middle"sv).value());
+ auto end = cldr.unique_strings.ensure(value.as_object().get_deprecated_string("end"sv).value());
+ auto pair = cldr.unique_strings.ensure(value.as_object().get_deprecated_string("2"sv).value());
if (!cldr.list_pattern_types.contains_slow(type))
cldr.list_pattern_types.append(type);
@@ -571,10 +571,10 @@ static ErrorOr<void> parse_locale_layout(DeprecatedString misc_path, CLDR& cldr,
layout_path = layout_path.append("layout.json"sv);
auto locale_layout = TRY(read_json_file(layout_path.string()));
- auto const& main_object = locale_layout.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(layout_path.parent().basename());
- auto const& layout_object = locale_object.as_object().get_deprecated("layout"sv);
- auto const& orientation_object = layout_object.as_object().get_deprecated("orientation"sv);
+ auto const& main_object = locale_layout.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(layout_path.parent().basename()).value();
+ auto const& layout_object = locale_object.get_object("layout"sv).value();
+ auto const& orientation_object = layout_object.get_object("orientation"sv).value();
auto text_layout_character_order = [](StringView key) {
if (key == "left-to-right"sv)
@@ -584,8 +584,7 @@ static ErrorOr<void> parse_locale_layout(DeprecatedString misc_path, CLDR& cldr,
VERIFY_NOT_REACHED();
};
- auto const& character_order_string = orientation_object.as_object().get_deprecated("characterOrder"sv);
- auto const& character_order = character_order_string.as_string();
+ auto character_order = orientation_object.get_deprecated_string("characterOrder"sv).value();
TextLayout layout {};
layout.character_order = text_layout_character_order(character_order);
@@ -603,12 +602,12 @@ static ErrorOr<void> parse_locale_currencies(DeprecatedString numbers_path, CLDR
currencies_path = currencies_path.append("currencies.json"sv);
auto locale_currencies = TRY(read_json_file(currencies_path.string()));
- auto const& main_object = locale_currencies.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(currencies_path.parent().basename());
- auto const& locale_numbers_object = locale_object.as_object().get_deprecated("numbers"sv);
- auto const& currencies_object = locale_numbers_object.as_object().get_deprecated("currencies"sv);
+ auto const& main_object = locale_currencies.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(currencies_path.parent().basename()).value();
+ auto const& locale_numbers_object = locale_object.get_object("numbers"sv).value();
+ auto const& currencies_object = locale_numbers_object.get_object("currencies"sv).value();
- currencies_object.as_object().for_each_member([&](auto const& key, JsonValue const&) {
+ currencies_object.for_each_member([&](auto const& key, JsonValue const&) {
if (!cldr.currencies.contains_slow(key))
cldr.currencies.append(key);
});
@@ -625,17 +624,17 @@ static ErrorOr<void> parse_locale_currencies(DeprecatedString numbers_path, CLDR
CurrencyList numeric_currencies {};
numeric_currencies.resize(cldr.currencies.size());
- currencies_object.as_object().for_each_member([&](auto const& key, JsonValue const& value) {
- auto const& long_name = value.as_object().get_deprecated("displayName"sv);
- auto const& short_name = value.as_object().get_deprecated("symbol"sv);
- auto const& narrow_name = value.as_object().get_deprecated("symbol-alt-narrow"sv);
- auto const& numeric_name = value.as_object().get_deprecated("displayName-count-other"sv);
+ currencies_object.for_each_member([&](auto const& key, JsonValue const& value) {
+ auto const& long_name = value.as_object().get_deprecated_string("displayName"sv);
+ auto const& short_name = value.as_object().get_deprecated_string("symbol"sv);
+ auto const& narrow_name = value.as_object().get_deprecated_string("symbol-alt-narrow"sv);
+ auto const& numeric_name = value.as_object().get_deprecated_string("displayName-count-other"sv);
auto index = cldr.currencies.find_first_index(key).value();
- long_currencies[index] = cldr.unique_strings.ensure(long_name.as_string());
- short_currencies[index] = cldr.unique_strings.ensure(short_name.as_string());
- narrow_currencies[index] = narrow_name.is_null() ? 0 : cldr.unique_strings.ensure(narrow_name.as_string());
- numeric_currencies[index] = cldr.unique_strings.ensure(numeric_name.is_null() ? long_name.as_string() : numeric_name.as_string());
+ long_currencies[index] = cldr.unique_strings.ensure(long_name.value());
+ short_currencies[index] = cldr.unique_strings.ensure(short_name.value());
+ narrow_currencies[index] = narrow_name.has_value() ? cldr.unique_strings.ensure(narrow_name.value()) : 0;
+ numeric_currencies[index] = cldr.unique_strings.ensure(numeric_name.has_value() ? numeric_name.value() : long_name.value());
});
locale.long_currencies = cldr.unique_currency_lists.ensure(move(long_currencies));
@@ -651,18 +650,18 @@ static ErrorOr<void> parse_locale_calendars(DeprecatedString locale_path, CLDR&
locale_display_names_path = locale_display_names_path.append("localeDisplayNames.json"sv);
auto locale_display_names = TRY(read_json_file(locale_display_names_path.string()));
- auto const& main_object = locale_display_names.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(locale_display_names_path.parent().basename());
- auto const& locale_display_names_object = locale_object.as_object().get_deprecated("localeDisplayNames"sv);
- auto const& types_object = locale_display_names_object.as_object().get_deprecated("types"sv);
- auto const& calendar_object = types_object.as_object().get_deprecated("calendar"sv);
+ auto const& main_object = locale_display_names.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(locale_display_names_path.parent().basename()).value();
+ auto const& locale_display_names_object = locale_object.get_object("localeDisplayNames"sv).value();
+ auto const& types_object = locale_display_names_object.get_object("types"sv).value();
+ auto const& calendar_object = types_object.get_object("calendar"sv).value();
auto const& supported_calendars = cldr.keywords.find("ca"sv)->value;
CalendarList calendars;
calendars.resize(supported_calendars.size());
- calendar_object.as_object().for_each_member([&](auto const& key, auto const& calendar) {
+ calendar_object.for_each_member([&](auto const& key, auto const& calendar) {
auto index = supported_calendars.find_first_index(key);
if (!index.has_value()) {
auto alias = find_keyword_alias("ca"sv, key, cldr);
@@ -682,10 +681,10 @@ static ErrorOr<void> parse_locale_date_fields(DeprecatedString dates_path, CLDR&
date_fields_path = date_fields_path.append("dateFields.json"sv);
auto locale_date_fields = TRY(read_json_file(date_fields_path.string()));
- auto const& main_object = locale_date_fields.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(date_fields_path.parent().basename());
- auto const& dates_object = locale_object.as_object().get_deprecated("dates"sv);
- auto const& fields_object = dates_object.as_object().get_deprecated("fields"sv);
+ auto const& main_object = locale_date_fields.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(date_fields_path.parent().basename()).value();
+ auto const& dates_object = locale_object.get_object("dates"sv).value();
+ auto const& fields_object = dates_object.get_object("fields"sv).value();
auto is_sanctioned_field = [](StringView field) {
// This is a copy of the units sanctioned for use within ECMA-402, with names adjusted for the names used by the CLDR.
@@ -693,7 +692,7 @@ static ErrorOr<void> parse_locale_date_fields(DeprecatedString dates_path, CLDR&
return field.is_one_of("era"sv, "year"sv, "quarter"sv, "month"sv, "week"sv, "weekday"sv, "day"sv, "dayperiod"sv, "hour"sv, "minute"sv, "second"sv, "zone"sv);
};
- fields_object.as_object().for_each_member([&](auto const& key, JsonValue const&) {
+ fields_object.for_each_member([&](auto const& key, JsonValue const&) {
if (!is_sanctioned_field(key))
return;
@@ -712,18 +711,18 @@ static ErrorOr<void> parse_locale_date_fields(DeprecatedString dates_path, CLDR&
DateFieldList narrow_date_fields {};
narrow_date_fields.resize(cldr.date_fields.size());
- fields_object.as_object().for_each_member([&](auto const& key, JsonValue const& value) {
+ fields_object.for_each_member([&](auto const& key, JsonValue const& value) {
if (!is_sanctioned_field(key))
return;
- auto const& long_name = value.as_object().get_deprecated("displayName"sv);
- auto const& short_name = fields_object.as_object().get_deprecated(DeprecatedString::formatted("{}-short", key)).as_object().get_deprecated("displayName"sv);
- auto const& narrow_name = fields_object.as_object().get_deprecated(DeprecatedString::formatted("{}-narrow", key)).as_object().get_deprecated("displayName"sv);
+ auto const& long_name = value.as_object().get_deprecated_string("displayName"sv).value();
+ auto const& short_name = fields_object.get_object(DeprecatedString::formatted("{}-short", key))->get_deprecated_string("displayName"sv).value();
+ auto const& narrow_name = fields_object.get_object(DeprecatedString::formatted("{}-narrow", key))->get_deprecated_string("displayName"sv).value();
auto index = cldr.date_fields.find_first_index(key).value();
- long_date_fields[index] = cldr.unique_strings.ensure(long_name.as_string());
- short_date_fields[index] = cldr.unique_strings.ensure(short_name.as_string());
- narrow_date_fields[index] = cldr.unique_strings.ensure(narrow_name.as_string());
+ long_date_fields[index] = cldr.unique_strings.ensure(long_name);
+ short_date_fields[index] = cldr.unique_strings.ensure(short_name);
+ narrow_date_fields[index] = cldr.unique_strings.ensure(narrow_name);
});
locale.long_date_fields = cldr.unique_date_field_lists.ensure(move(long_date_fields));
@@ -738,11 +737,11 @@ static ErrorOr<void> parse_number_system_keywords(DeprecatedString locale_number
numbers_path = numbers_path.append("numbers.json"sv);
auto numbers = TRY(read_json_file(numbers_path.string()));
- auto const& main_object = numbers.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(numbers_path.parent().basename());
- auto const& locale_numbers_object = locale_object.as_object().get_deprecated("numbers"sv);
- auto const& default_numbering_system_object = locale_numbers_object.as_object().get_deprecated("defaultNumberingSystem"sv);
- auto const& other_numbering_systems_object = locale_numbers_object.as_object().get_deprecated("otherNumberingSystems"sv);
+ auto const& main_object = numbers.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(numbers_path.parent().basename()).value();
+ auto const& locale_numbers_object = locale_object.get_object("numbers"sv).value();
+ auto const& default_numbering_system_object = locale_numbers_object.get_deprecated_string("defaultNumberingSystem"sv).value();
+ auto const& other_numbering_systems_object = locale_numbers_object.get_object("otherNumberingSystems"sv).value();
KeywordList keywords {};
@@ -755,13 +754,13 @@ static ErrorOr<void> parse_number_system_keywords(DeprecatedString locale_number
keywords.append(move(index));
};
- append_numbering_system(default_numbering_system_object.as_string());
+ append_numbering_system(default_numbering_system_object);
- other_numbering_systems_object.as_object().for_each_member([&](auto const&, JsonValue const& value) {
+ other_numbering_systems_object.for_each_member([&](auto const&, JsonValue const& value) {
append_numbering_system(value.as_string());
});
- locale_numbers_object.as_object().for_each_member([&](auto const& key, JsonValue const& value) {
+ locale_numbers_object.for_each_member([&](auto const& key, JsonValue const& value) {
if (!key.starts_with("defaultNumberingSystem-alt-"sv))
return;
append_numbering_system(value.as_string());
@@ -784,12 +783,12 @@ static ErrorOr<void> parse_calendar_keywords(DeprecatedString locale_dates_path,
continue;
auto calendars = TRY(read_json_file(calendars_path.string()));
- auto const& main_object = calendars.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(calendars_path.parent().basename());
- auto const& dates_object = locale_object.as_object().get_deprecated("dates"sv);
- auto const& calendars_object = dates_object.as_object().get_deprecated("calendars"sv);
+ auto const& main_object = calendars.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(calendars_path.parent().basename()).value();
+ auto const& dates_object = locale_object.get_object("dates"sv).value();
+ auto const& calendars_object = dates_object.get_object("calendars"sv).value();
- calendars_object.as_object().for_each_member([&](auto calendar_name, JsonValue const&) {
+ calendars_object.for_each_member([&](auto calendar_name, JsonValue const&) {
// The generic calendar is not a supported Unicode calendar key, so skip it:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar#unicode_calendar_keys
if (calendar_name == "generic"sv)
@@ -842,9 +841,9 @@ static ErrorOr<void> parse_default_content_locales(DeprecatedString core_path, C
default_content_path = default_content_path.append("defaultContent.json"sv);
auto default_content = TRY(read_json_file(default_content_path.string()));
- auto const& default_content_array = default_content.as_object().get_deprecated("defaultContent"sv);
+ auto const& default_content_array = default_content.as_object().get_array("defaultContent"sv).value();
- default_content_array.as_array().for_each([&](JsonValue const& value) {
+ default_content_array.for_each([&](JsonValue const& value) {
auto locale = value.as_string();
StringView default_locale = locale;
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp
index cb132dc439..5fe97008b8 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp
@@ -245,15 +245,15 @@ static ErrorOr<void> parse_number_system_digits(DeprecatedString core_supplement
number_systems_path = number_systems_path.append("numberingSystems.json"sv);
auto number_systems = TRY(read_json_file(number_systems_path.string()));
- auto const& supplemental_object = number_systems.as_object().get_deprecated("supplemental"sv);
- auto const& number_systems_object = supplemental_object.as_object().get_deprecated("numberingSystems"sv);
+ auto const& supplemental_object = number_systems.as_object().get_object("supplemental"sv).value();
+ auto const& number_systems_object = supplemental_object.get_object("numberingSystems"sv).value();
- number_systems_object.as_object().for_each_member([&](auto const& number_system, auto const& digits_object) {
- auto type = digits_object.as_object().get_deprecated("_type"sv).as_string();
+ number_systems_object.for_each_member([&](auto const& number_system, auto const& digits_object) {
+ auto type = digits_object.as_object().get_deprecated_string("_type"sv).value();
if (type != "numeric"sv)
return;
- auto digits = digits_object.as_object().get_deprecated("_digits"sv).as_string();
+ auto digits = digits_object.as_object().get_deprecated_string("_digits"sv).value();
Utf8View utf8_digits { digits };
VERIFY(utf8_digits.length() == 10);
@@ -415,10 +415,10 @@ static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path,
numbers_path = numbers_path.append("numbers.json"sv);
auto numbers = TRY(read_json_file(numbers_path.string()));
- auto const& main_object = numbers.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(numbers_path.parent().basename());
- auto const& locale_numbers_object = locale_object.as_object().get_deprecated("numbers"sv);
- auto const& minimum_grouping_digits = locale_numbers_object.as_object().get_deprecated("minimumGroupingDigits"sv);
+ auto const& main_object = numbers.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(numbers_path.parent().basename()).value();
+ auto const& locale_numbers_object = locale_object.get_object("numbers"sv).value();
+ auto const& minimum_grouping_digits = locale_numbers_object.get_deprecated_string("minimumGroupingDigits"sv).value();
Vector<Optional<NumberSystem>> number_systems;
number_systems.resize(cldr.number_systems.size());
@@ -494,7 +494,7 @@ static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path,
return {};
};
- locale_numbers_object.as_object().for_each_member([&](auto const& key, JsonValue const& value) {
+ locale_numbers_object.for_each_member([&](auto const& key, JsonValue const& value) {
constexpr auto symbols_prefix = "symbols-numberSystem-"sv;
constexpr auto decimal_formats_prefix = "decimalFormats-numberSystem-"sv;
constexpr auto currency_formats_prefix = "currencyFormats-numberSystem-"sv;
@@ -523,8 +523,8 @@ static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path,
// The range separator does not appear in the symbols list, we have to extract it from
// the range pattern.
auto misc_patterns_key = DeprecatedString::formatted("{}{}", misc_patterns_prefix, system);
- auto misc_patterns = locale_numbers_object.as_object().get_deprecated(misc_patterns_key);
- auto range_separator = misc_patterns.as_object().get_deprecated("range"sv).as_string();
+ auto misc_patterns = locale_numbers_object.get_object(misc_patterns_key).value();
+ auto range_separator = misc_patterns.get_deprecated_string("range"sv).value();
auto begin_index = range_separator.find("{0}"sv).value() + "{0}"sv.length();
auto end_index = range_separator.find("{1}"sv).value();
@@ -541,42 +541,42 @@ static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path,
auto system = key.substring(decimal_formats_prefix.length());
auto& number_system = ensure_number_system(system);
- auto format_object = value.as_object().get_deprecated("standard"sv);
- parse_number_pattern(format_object.as_string().split(';'), cldr, NumberFormatType::Standard, number_system.decimal_format, &number_system);
+ auto format_object = value.as_object().get_deprecated_string("standard"sv).value();
+ parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.decimal_format, &number_system);
- auto const& long_format = value.as_object().get_deprecated("long"sv).as_object().get_deprecated("decimalFormat"sv);
- number_system.decimal_long_formats = parse_number_format(long_format.as_object());
+ auto const& long_format = value.as_object().get_object("long"sv)->get_object("decimalFormat"sv).value();
+ number_system.decimal_long_formats = parse_number_format(long_format);
- auto const& short_format = value.as_object().get_deprecated("short"sv).as_object().get_deprecated("decimalFormat"sv);
- number_system.decimal_short_formats = parse_number_format(short_format.as_object());
+ auto const& short_format = value.as_object().get_object("short"sv)->get_object("decimalFormat"sv).value();
+ number_system.decimal_short_formats = parse_number_format(short_format);
} else if (key.starts_with(currency_formats_prefix)) {
auto system = key.substring(currency_formats_prefix.length());
auto& number_system = ensure_number_system(system);
- auto format_object = value.as_object().get_deprecated("standard"sv);
- parse_number_pattern(format_object.as_string().split(';'), cldr, NumberFormatType::Standard, number_system.currency_format);
+ auto format_object = value.as_object().get_deprecated_string("standard"sv).value();
+ parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.currency_format);
- format_object = value.as_object().get_deprecated("accounting"sv);
- parse_number_pattern(format_object.as_string().split(';'), cldr, NumberFormatType::Standard, number_system.accounting_format);
+ format_object = value.as_object().get_deprecated_string("accounting"sv).value();
+ parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.accounting_format);
number_system.currency_unit_formats = parse_number_format(value.as_object());
- if (value.as_object().has("short"sv)) {
- auto const& short_format = value.as_object().get_deprecated("short"sv).as_object().get_deprecated("standard"sv);
- number_system.currency_short_formats = parse_number_format(short_format.as_object());
+ if (value.as_object().has_object("short"sv)) {
+ auto const& short_format = value.as_object().get_object("short"sv)->get_object("standard"sv).value();
+ number_system.currency_short_formats = parse_number_format(short_format);
}
} else if (key.starts_with(percent_formats_prefix)) {
auto system = key.substring(percent_formats_prefix.length());
auto& number_system = ensure_number_system(system);
- auto format_object = value.as_object().get_deprecated("standard"sv);
- parse_number_pattern(format_object.as_string().split(';'), cldr, NumberFormatType::Standard, number_system.percent_format);
+ auto format_object = value.as_object().get_deprecated_string("standard"sv).value();
+ parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.percent_format);
} else if (key.starts_with(scientific_formats_prefix)) {
auto system = key.substring(scientific_formats_prefix.length());
auto& number_system = ensure_number_system(system);
- auto format_object = value.as_object().get_deprecated("standard"sv);
- parse_number_pattern(format_object.as_string().split(';'), cldr, NumberFormatType::Standard, number_system.scientific_format);
+ auto format_object = value.as_object().get_deprecated_string("standard"sv).value();
+ parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.scientific_format);
}
});
@@ -590,7 +590,7 @@ static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path,
locale.number_systems.append(system_index);
}
- locale.minimum_grouping_digits = minimum_grouping_digits.as_string().template to_uint<u8>().value();
+ locale.minimum_grouping_digits = minimum_grouping_digits.template to_uint<u8>().value();
return {};
}
@@ -600,12 +600,12 @@ static ErrorOr<void> parse_units(DeprecatedString locale_units_path, CLDR& cldr,
units_path = units_path.append("units.json"sv);
auto locale_units = TRY(read_json_file(units_path.string()));
- auto const& main_object = locale_units.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(units_path.parent().basename());
- auto const& locale_units_object = locale_object.as_object().get_deprecated("units"sv);
- auto const& long_object = locale_units_object.as_object().get_deprecated("long"sv);
- auto const& short_object = locale_units_object.as_object().get_deprecated("short"sv);
- auto const& narrow_object = locale_units_object.as_object().get_deprecated("narrow"sv);
+ auto const& main_object = locale_units.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(units_path.parent().basename()).value();
+ auto const& locale_units_object = locale_object.get_object("units"sv).value();
+ auto const& long_object = locale_units_object.get_object("long"sv).value();
+ auto const& short_object = locale_units_object.get_object("short"sv).value();
+ auto const& narrow_object = locale_units_object.get_object("narrow"sv).value();
HashMap<DeprecatedString, Unit> units;
@@ -685,9 +685,9 @@ static ErrorOr<void> parse_units(DeprecatedString locale_units_path, CLDR& cldr,
});
};
- parse_units_object(long_object.as_object(), Locale::Style::Long);
- parse_units_object(short_object.as_object(), Locale::Style::Short);
- parse_units_object(narrow_object.as_object(), Locale::Style::Narrow);
+ parse_units_object(long_object, Locale::Style::Long);
+ parse_units_object(short_object, Locale::Style::Short);
+ parse_units_object(narrow_object, Locale::Style::Narrow);
for (auto& unit : units) {
auto unit_index = cldr.unique_units.ensure(move(unit.value));
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp
index 03f6eaf9f9..cfb5b62a69 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp
@@ -330,9 +330,9 @@ static ErrorOr<void> parse_plural_rules(DeprecatedString core_supplemental_path,
plurals_path = plurals_path.append(file_name);
auto plurals = TRY(read_json_file(plurals_path.string()));
- auto const& supplemental_object = plurals.as_object().get_deprecated("supplemental"sv);
+ auto const& supplemental_object = plurals.as_object().get_object("supplemental"sv).value();
- supplemental_object.as_object().for_each_member([&](auto const& key, auto const& plurals_object) {
+ supplemental_object.for_each_member([&](auto const& key, auto const& plurals_object) {
if (!key.starts_with(form_prefix))
return;
@@ -365,10 +365,10 @@ static ErrorOr<void> parse_plural_ranges(DeprecatedString core_supplemental_path
plural_ranges_path = plural_ranges_path.append("pluralRanges.json"sv);
auto plural_ranges = TRY(read_json_file(plural_ranges_path.string()));
- auto const& supplemental_object = plural_ranges.as_object().get_deprecated("supplemental"sv);
- auto const& plurals_object = supplemental_object.as_object().get_deprecated("plurals"sv);
+ auto const& supplemental_object = plural_ranges.as_object().get_object("supplemental"sv).value();
+ auto const& plurals_object = supplemental_object.get_object("plurals"sv).value();
- plurals_object.as_object().for_each_member([&](auto const& loc, auto const& ranges_object) {
+ plurals_object.for_each_member([&](auto const& loc, auto const& ranges_object) {
auto locale = cldr.locales.get(loc);
if (!locale.has_value())
return;
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp
index 21b708d091..1fad0b1365 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp
@@ -83,10 +83,10 @@ static ErrorOr<void> parse_date_fields(DeprecatedString locale_dates_path, CLDR&
date_fields_path = date_fields_path.append("dateFields.json"sv);
auto date_fields = TRY(read_json_file(date_fields_path.string()));
- auto const& main_object = date_fields.as_object().get_deprecated("main"sv);
- auto const& locale_object = main_object.as_object().get_deprecated(date_fields_path.parent().basename());
- auto const& dates_object = locale_object.as_object().get_deprecated("dates"sv);
- auto const& fields_object = dates_object.as_object().get_deprecated("fields"sv);
+ auto const& main_object = date_fields.as_object().get_object("main"sv).value();
+ auto const& locale_object = main_object.get_object(date_fields_path.parent().basename()).value();
+ auto const& dates_object = locale_object.get_object("dates"sv).value();
+ auto const& fields_object = dates_object.get_object("fields"sv).value();
auto is_sanctioned_unit = [](auto unit) {
// This is a copy of the time units sanctioned for use within ECMA-402.
@@ -105,7 +105,7 @@ static ErrorOr<void> parse_date_fields(DeprecatedString locale_dates_path, CLDR&
locale.time_units.append(cldr.unique_formats.ensure(move(format)));
};
- fields_object.as_object().for_each_member([&](auto const& unit_and_style, auto const& patterns) {
+ fields_object.for_each_member([&](auto const& unit_and_style, auto const& patterns) {
auto segments = unit_and_style.split_view('-');
auto unit = segments[0];
auto style = (segments.size() > 1) ? segments[1] : "long"sv;
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp
index 1282dd3577..11b7f08423 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp
@@ -138,9 +138,9 @@ bool media_feature_type_is_range(MediaFeatureID media_feature_id)
auto member_generator = generator.fork();
member_generator.set("name:titlecase", title_casify(name));
VERIFY(feature.has("type"sv));
- auto feature_type = feature.get_deprecated("type"sv);
- VERIFY(feature_type.is_string());
- member_generator.set("is_range", feature_type.as_string() == "range" ? "true" : "false");
+ auto feature_type = feature.get_deprecated_string("type"sv);
+ VERIFY(feature_type.has_value());
+ member_generator.set("is_range", feature_type.value() == "range" ? "true" : "false");
member_generator.append(R"~~~(
case MediaFeatureID::@name:titlecase@:
return @is_range@;)~~~");
@@ -173,9 +173,9 @@ bool media_feature_accepts_type(MediaFeatureID media_feature_id, MediaFeatureVal
}
have_output_value_type_switch = true;
};
- auto& values = feature.get_deprecated("values"sv);
- VERIFY(values.is_array());
- auto& values_array = values.as_array();
+ auto values = feature.get_array("values"sv);
+ VERIFY(values.has_value());
+ auto& values_array = values.value();
for (auto& type : values_array.values()) {
VERIFY(type.is_string());
auto type_name = type.as_string();
@@ -251,9 +251,9 @@ bool media_feature_accepts_identifier(MediaFeatureID media_feature_id, ValueID i
}
have_output_identifier_switch = true;
};
- auto& values = feature.get_deprecated("values"sv);
- VERIFY(values.is_array());
- auto& values_array = values.as_array();
+ auto values = feature.get_array("values"sv);
+ VERIFY(values.has_value());
+ auto& values_array = values.value();
for (auto& identifier : values_array.values()) {
VERIFY(identifier.is_string());
auto identifier_name = identifier.as_string();
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
index e7aae11651..ad90d396a6 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
@@ -230,9 +230,9 @@ bool is_inherited_property(PropertyID property_id)
bool inherited = false;
if (value.as_object().has("inherited"sv)) {
- auto& inherited_value = value.as_object().get_deprecated("inherited"sv);
- VERIFY(inherited_value.is_bool());
- inherited = inherited_value.as_bool();
+ auto inherited_value = value.as_object().get_bool("inherited"sv);
+ VERIFY(inherited_value.has_value());
+ inherited = inherited_value.value();
}
if (inherited) {
@@ -261,7 +261,7 @@ bool property_affects_layout(PropertyID property_id)
bool affects_layout = true;
if (value.as_object().has("affects-layout"sv))
- affects_layout = value.as_object().get_deprecated("affects-layout"sv).to_bool();
+ affects_layout = value.as_object().get_bool("affects-layout"sv).value_or(false);
if (affects_layout) {
auto member_generator = generator.fork();
@@ -289,7 +289,7 @@ bool property_affects_stacking_context(PropertyID property_id)
bool affects_stacking_context = false;
if (value.as_object().has("affects-stacking-context"sv))
- affects_stacking_context = value.as_object().get_deprecated("affects-stacking-context"sv).to_bool();
+ affects_stacking_context = value.as_object().get_bool("affects-stacking-context"sv).value_or(false);
if (affects_stacking_context) {
auto member_generator = generator.fork();
@@ -326,9 +326,9 @@ NonnullRefPtr<StyleValue> property_initial_value(PropertyID property_id)
dbgln("No initial value specified for property '{}'", name);
VERIFY_NOT_REACHED();
}
- auto& initial_value = object.get_deprecated("initial"sv);
- VERIFY(initial_value.is_string());
- auto initial_value_string = initial_value.as_string();
+ auto initial_value = object.get_deprecated_string("initial"sv);
+ VERIFY(initial_value.has_value());
+ auto& initial_value_string = initial_value.value();
auto member_generator = generator.fork();
member_generator.set("name:titlecase", title_casify(name));
@@ -370,9 +370,9 @@ bool property_has_quirk(PropertyID property_id, Quirk quirk)
properties.for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
if (value.as_object().has("quirks"sv)) {
- auto& quirks_value = value.as_object().get_deprecated("quirks"sv);
- VERIFY(quirks_value.is_array());
- auto& quirks = quirks_value.as_array();
+ auto quirks_value = value.as_object().get_array("quirks"sv);
+ VERIFY(quirks_value.has_value());
+ auto& quirks = quirks_value.value();
if (!quirks.is_empty()) {
auto property_generator = generator.fork();
@@ -461,9 +461,9 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
};
if (has_valid_types) {
- auto valid_types_value = object.get_deprecated("valid-types"sv);
- VERIFY(valid_types_value.is_array());
- auto valid_types = valid_types_value.as_array();
+ auto valid_types_value = object.get_array("valid-types"sv);
+ VERIFY(valid_types_value.has_value());
+ auto& valid_types = valid_types_value.value();
if (!valid_types.is_empty()) {
for (auto& type : valid_types.values()) {
VERIFY(type.is_string());
@@ -536,9 +536,9 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
}
if (has_valid_identifiers) {
- auto valid_identifiers_value = object.get_deprecated("valid-identifiers"sv);
- VERIFY(valid_identifiers_value.is_array());
- auto valid_identifiers = valid_identifiers_value.as_array();
+ auto valid_identifiers_value = object.get_array("valid-identifiers"sv);
+ VERIFY(valid_identifiers_value.has_value());
+ auto& valid_identifiers = valid_identifiers_value.value();
if (!valid_identifiers.is_empty()) {
property_generator.append(R"~~~(
switch (style_value.to_identifier()) {
@@ -581,11 +581,11 @@ size_t property_maximum_value_count(PropertyID property_id)
properties.for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
if (value.as_object().has("max-values"sv)) {
- auto max_values = value.as_object().get_deprecated("max-values"sv);
- VERIFY(max_values.is_number() && !max_values.is_double());
+ auto max_values = value.as_object().get("max-values"sv);
+ VERIFY(max_values.has_value() && max_values->is_number() && !max_values->is_double());
auto property_generator = generator.fork();
property_generator.set("name:titlecase", title_casify(name));
- property_generator.set("max_values", max_values.to_deprecated_string());
+ property_generator.set("max_values", max_values->to_deprecated_string());
property_generator.append(R"~~~(
case PropertyID::@name:titlecase@:
return @max_values@;
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp
index 81cce1f162..4dedf3e81f 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp
@@ -166,10 +166,10 @@ TransformFunctionMetadata transform_function_metadata(TransformFunction transfor
return TransformFunctionMetadata {
.parameters = {)~~~");
- const JsonArray& parameters = value.as_object().get_deprecated("parameters"sv).as_array();
+ JsonArray const& parameters = value.as_object().get_array("parameters"sv).value();
bool first = true;
parameters.for_each([&](JsonValue const& value) {
- GenericLexer lexer { value.as_object().get_deprecated("type"sv).as_string() };
+ GenericLexer lexer { value.as_object().get_deprecated_string("type"sv).value() };
VERIFY(lexer.consume_specific('<'));
auto parameter_type_name = lexer.consume_until('>');
VERIFY(lexer.consume_specific('>'));
@@ -189,7 +189,7 @@ TransformFunctionMetadata transform_function_metadata(TransformFunction transfor
member_generator.append(first ? " "sv : ", "sv);
first = false;
- member_generator.append(DeprecatedString::formatted("{{ TransformFunctionParameterType::{}, {}}}", parameter_type, value.as_object().get_deprecated("required"sv).to_deprecated_string()));
+ member_generator.append(DeprecatedString::formatted("{{ TransformFunctionParameterType::{}, {}}}", parameter_type, value.as_object().get("required"sv)->to_deprecated_string()));
});
member_generator.append(R"~~~( }