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

Everywhere: Add sv suffix to strings relying on StringView(char const*)

Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
This commit is contained in:
sin-ack 2022-07-11 17:32:29 +00:00 committed by Andreas Kling
parent e5f09ea170
commit 3f3f45580a
762 changed files with 8315 additions and 8316 deletions

View file

@ -10,8 +10,8 @@
int main(int, char**)
{
auto value = JsonValue::from_string("{\"property\": \"value\"}").release_value_but_fixme_should_propagate_errors();
auto value = JsonValue::from_string("{\"property\": \"value\"}"sv).release_value_but_fixme_should_propagate_errors();
printf("parsed: _%s_\n", value.to_string().characters());
printf("object.property = '%s'\n", value.as_object().get("property").to_string().characters());
printf("object.property = '%s'\n", value.as_object().get("property"sv).to_string().characters());
return 0;
}

View file

@ -49,7 +49,7 @@ struct Message {
{
StringBuilder builder;
builder.append(pascal_case(name));
builder.append("Response");
builder.append("Response"sv);
return builder.to_string();
}
};
@ -69,12 +69,12 @@ static bool is_primitive_type(String const& type)
static String message_name(String const& endpoint, String const& message, bool is_response)
{
StringBuilder builder;
builder.append("Messages::");
builder.append("Messages::"sv);
builder.append(endpoint);
builder.append("::");
builder.append("::"sv);
builder.append(pascal_case(message));
if (is_response)
builder.append("Response");
builder.append("Response"sv);
return builder.to_string();
}
@ -261,7 +261,7 @@ String constructor_for_message(String const& name, Vector<Parameter> const& para
builder.append(name);
if (parameters.is_empty()) {
builder.append("() {}");
builder.append("() {}"sv);
return builder.to_string();
}
builder.append('(');
@ -269,16 +269,16 @@ String constructor_for_message(String const& name, Vector<Parameter> const& para
auto const& parameter = parameters[i];
builder.appendff("{} {}", parameter.type, parameter.name);
if (i != parameters.size() - 1)
builder.append(", ");
builder.append(", "sv);
}
builder.append(") : ");
builder.append(") : "sv);
for (size_t i = 0; i < parameters.size(); ++i) {
auto const& parameter = parameters[i];
builder.appendff("m_{}(move({}))", parameter.name, parameter.name);
if (i != parameters.size() - 1)
builder.append(", ");
builder.append(", "sv);
}
builder.append(" {}");
builder.append(" {}"sv);
return builder.to_string();
}
@ -343,7 +343,7 @@ public:)~~~");
auto const& parameter = parameters[i];
builder.appendff("move({})", parameter.name);
if (i != parameters.size() - 1)
builder.append(", ");
builder.append(", "sv);
}
message_generator.set("message.constructor_call_parameters", builder.build());
@ -657,11 +657,11 @@ public:
StringBuilder argument_generator;
for (size_t i = 0; i < parameters.size(); ++i) {
auto const& parameter = parameters[i];
argument_generator.append("request.");
argument_generator.append("request."sv);
argument_generator.append(parameter.name);
argument_generator.append("()");
argument_generator.append("()"sv);
if (i != parameters.size() - 1)
argument_generator.append(", ");
argument_generator.append(", "sv);
}
message_generator.set("message.pascal_name", pascal_case(name));
@ -722,7 +722,7 @@ public:
builder.append(type);
if (const_ref)
builder.append(" const&");
builder.append(" const&"sv);
return builder.to_string();
};

View file

@ -79,7 +79,7 @@ struct AK::Formatter<DateTime> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, DateTime const& date_time)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {}, {}, {}, {}, {}, {} }}",
"{{ {}, {}, {}, {}, {}, {}, {}, {}, {} }}"sv,
date_time.year,
date_time.month.value_or(1),
date_time.day.value_or(1),
@ -97,7 +97,7 @@ struct AK::Formatter<TimeZoneOffset> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, TimeZoneOffset const& time_zone_offset)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {}, {}, {}, {} }}",
"{{ {}, {}, {}, {}, {}, {}, {} }}"sv,
time_zone_offset.offset,
time_zone_offset.until.value_or({}),
time_zone_offset.until.has_value(),
@ -113,7 +113,7 @@ struct AK::Formatter<DaylightSavingsOffset> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, DaylightSavingsOffset const& dst_offset)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {}, {} }}",
"{{ {}, {}, {}, {}, {} }}"sv,
dst_offset.offset,
dst_offset.year_from,
dst_offset.year_to,
@ -127,7 +127,7 @@ struct AK::Formatter<TimeZone::Coordinate> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, TimeZone::Coordinate const& coordinate)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {} }}",
"{{ {}, {}, {} }}"sv,
coordinate.degrees,
coordinate.minutes,
coordinate.seconds);
@ -139,7 +139,7 @@ struct AK::Formatter<TimeZone::Location> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, TimeZone::Location const& location)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {} }}",
"{{ {}, {} }}"sv,
location.latitude,
location.longitude);
}
@ -557,19 +557,19 @@ static constexpr Array<@type@, @size@> @name@ { {
generator.append("} };\n");
};
generate_mapping(generator, time_zone_data.time_zone_names, "TimeZoneOffset"sv, "s_time_zone_offsets"sv, "s_time_zone_offsets_{}", format_identifier,
generate_mapping(generator, time_zone_data.time_zone_names, "TimeZoneOffset"sv, "s_time_zone_offsets"sv, "s_time_zone_offsets_{}"sv, format_identifier,
[&](auto const& name, auto const& value) {
auto const& time_zone_offsets = time_zone_data.time_zones.find(value)->value;
append_offsets(name, "TimeZoneOffset"sv, time_zone_offsets);
});
generate_mapping(generator, time_zone_data.dst_offset_names, "DaylightSavingsOffset"sv, "s_dst_offsets"sv, "s_dst_offsets_{}", format_identifier,
generate_mapping(generator, time_zone_data.dst_offset_names, "DaylightSavingsOffset"sv, "s_dst_offsets"sv, "s_dst_offsets_{}"sv, format_identifier,
[&](auto const& name, auto const& value) {
auto const& dst_offsets = time_zone_data.dst_offsets.find(value)->value;
append_offsets(name, "DaylightSavingsOffset"sv, dst_offsets);
});
generate_mapping(generator, time_zone_data.time_zone_region_names, s_string_index_type, "s_regional_time_zones"sv, "s_regional_time_zones_{}", format_identifier,
generate_mapping(generator, time_zone_data.time_zone_region_names, s_string_index_type, "s_regional_time_zones"sv, "s_regional_time_zones_{}"sv, format_identifier,
[&](auto const& name, auto const& value) {
auto const& time_zones = time_zone_data.time_zone_regions.find(value)->value;
@ -581,7 +581,7 @@ static constexpr Array<@string_index_type@, @size@> @name@ { {)~~~");
bool first = true;
for (auto const& time_zone : time_zones) {
generator.append(first ? " " : ", ");
generator.append(first ? " "sv : ", "sv);
generator.append(String::number(time_zone));
first = false;
}

View file

@ -146,8 +146,8 @@ struct UnicodeData {
static String sanitize_entry(String const& entry)
{
auto sanitized = entry.replace("-", "_", ReplaceMode::All);
sanitized = sanitized.replace(" ", "_", ReplaceMode::All);
auto sanitized = entry.replace("-"sv, "_"sv, ReplaceMode::All);
sanitized = sanitized.replace(" "sv, "_"sv, ReplaceMode::All);
StringBuilder builder;
bool next_is_upper = true;
@ -229,7 +229,7 @@ static ErrorOr<void> parse_special_casing(Core::Stream::BufferedFile& file, Unic
if (!casing.locale.is_empty())
casing.locale = String::formatted("{:c}{}", to_ascii_uppercase(casing.locale[0]), casing.locale.substring_view(1));
casing.condition = casing.condition.replace("_", "", ReplaceMode::All);
casing.condition = casing.condition.replace("_"sv, ""sv, ReplaceMode::All);
if (!casing.condition.is_empty() && !unicode_data.conditions.contains_slow(casing.condition))
unicode_data.conditions.append(casing.condition);
@ -570,7 +570,7 @@ static ErrorOr<void> parse_unicode_data(Core::Stream::BufferedFile& file, Unicod
if (!assigned_code_point_range_start.has_value())
assigned_code_point_range_start = data.code_point;
if (data.name.starts_with("<"sv) && data.name.ends_with(", First>")) {
if (data.name.starts_with("<"sv) && data.name.ends_with(", First>"sv)) {
VERIFY(!code_point_range_start.has_value() && assigned_code_point_range_start.has_value());
code_point_range_start = data.code_point;
@ -578,7 +578,7 @@ static ErrorOr<void> parse_unicode_data(Core::Stream::BufferedFile& file, Unicod
assigned_code_points.append({ *assigned_code_point_range_start, previous_code_point });
assigned_code_point_range_start.clear();
} else if (data.name.starts_with("<"sv) && data.name.ends_with(", Last>")) {
} else if (data.name.starts_with("<"sv) && data.name.ends_with(", Last>"sv)) {
VERIFY(code_point_range_start.has_value());
CodePointRange code_point_range { *code_point_range_start, data.code_point };
@ -739,7 +739,7 @@ namespace Unicode {
bool first = true;
generator.append(", {");
for (auto const& item : list) {
generator.append(first ? " " : ", ");
generator.append(first ? " "sv : ", "sv);
generator.append(String::formatted(format, item));
first = false;
}

View file

@ -147,7 +147,7 @@ struct AK::Formatter<CalendarPattern> : Formatter<FormatString> {
};
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }}",
"{{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }}"sv,
pattern.skeleton_index,
pattern.pattern_index,
pattern.pattern12_index,
@ -212,7 +212,7 @@ struct AK::Formatter<CalendarRangePattern> : Formatter<FormatString> {
};
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }}",
"{{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }}"sv,
pattern.skeleton_index,
field_to_i8(pattern.field),
pattern.start_range,
@ -265,7 +265,7 @@ struct AK::Formatter<CalendarFormat> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, CalendarFormat const& pattern)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {} }}",
"{{ {}, {}, {}, {} }}"sv,
pattern.full_format,
pattern.long_format,
pattern.medium_format,
@ -305,7 +305,7 @@ struct AK::Formatter<CalendarSymbols> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, CalendarSymbols const& symbols)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {} }}",
"{{ {}, {}, {} }}"sv,
symbols.narrow_symbols,
symbols.short_symbols,
symbols.long_symbols);
@ -364,7 +364,7 @@ struct AK::Formatter<Calendar> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, Calendar const& calendar)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {}, {}, {}, {}, {} }}",
"{{ {}, {}, {}, {}, {}, {}, {}, {} }}"sv,
calendar.date_formats,
calendar.time_formats,
calendar.date_time_formats,
@ -418,7 +418,7 @@ struct AK::Formatter<TimeZoneNames> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, TimeZoneNames const& time_zone)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {}, {}, {} }}",
"{{ {}, {}, {}, {}, {}, {} }}"sv,
time_zone.short_standard_name,
time_zone.long_standard_name,
time_zone.short_daylight_name,
@ -469,7 +469,7 @@ template<>
struct AK::Formatter<TimeZoneFormat> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, TimeZoneFormat const& time_zone_format)
{
return Formatter<FormatString>::format(builder, "{{ {}, {}, {}, {}, {}, {} }}",
return Formatter<FormatString>::format(builder, "{{ {}, {}, {}, {}, {}, {} }}"sv,
time_zone_format.symbol_ahead_sign,
time_zone_format.symbol_ahead_separator,
time_zone_format.symbol_behind_sign,
@ -510,7 +510,7 @@ struct AK::Formatter<DayPeriod> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, DayPeriod const& day_period)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {} }}",
"{{ {}, {}, {} }}"sv,
static_cast<u8>(day_period.day_period),
day_period.begin,
day_period.end);
@ -825,7 +825,7 @@ static Optional<CalendarPattern> parse_date_time_pattern_raw(String pattern, Str
// Era
if (all_of(segment, is_char('G'))) {
builder.append("{era}");
builder.append("{era}"sv);
if (segment.length() <= 3)
format.era = CalendarPatternStyle::Short;
@ -837,7 +837,7 @@ static Optional<CalendarPattern> parse_date_time_pattern_raw(String pattern, Str
// Year
else if (all_of(segment, is_any_of("yYuUr"sv))) {
builder.append("{year}");
builder.append("{year}"sv);
if (segment.length() == 2)
format.year = CalendarPatternStyle::TwoDigit;
@ -853,7 +853,7 @@ static Optional<CalendarPattern> parse_date_time_pattern_raw(String pattern, Str
// Month
else if (all_of(segment, is_any_of("ML"sv))) {
builder.append("{month}");
builder.append("{month}"sv);
if (segment.length() == 1)
format.month = CalendarPatternStyle::Numeric;
@ -878,20 +878,20 @@ static Optional<CalendarPattern> parse_date_time_pattern_raw(String pattern, Str
// Day
else if (all_of(segment, is_char('d'))) {
builder.append("{day}");
builder.append("{day}"sv);
if (segment.length() == 1)
format.day = CalendarPatternStyle::Numeric;
else
format.day = CalendarPatternStyle::TwoDigit;
} else if (all_of(segment, is_any_of("DFg"sv))) {
builder.append("{day}");
builder.append("{day}"sv);
format.day = CalendarPatternStyle::Numeric;
}
// Weekday
else if (all_of(segment, is_char('E'))) {
builder.append("{weekday}");
builder.append("{weekday}"sv);
if (segment.length() == 4)
format.weekday = CalendarPatternStyle::Long;
@ -900,7 +900,7 @@ static Optional<CalendarPattern> parse_date_time_pattern_raw(String pattern, Str
else
format.weekday = CalendarPatternStyle::Short;
} else if (all_of(segment, is_any_of("ec"sv))) {
builder.append("{weekday}");
builder.append("{weekday}"sv);
// TR-35 defines "e", "c", and "cc" as as numeric, and "ee" as 2-digit, but those
// pattern styles are not supported by Intl.DateTimeFormat.
@ -917,10 +917,10 @@ static Optional<CalendarPattern> parse_date_time_pattern_raw(String pattern, Str
// Period
else if (all_of(segment, is_any_of("ab"sv))) {
builder.append("{ampm}");
builder.append("{ampm}"sv);
hour12 = true;
} else if (all_of(segment, is_char('B'))) {
builder.append("{dayPeriod}");
builder.append("{dayPeriod}"sv);
hour12 = true;
if (segment.length() == 4)
@ -933,7 +933,7 @@ static Optional<CalendarPattern> parse_date_time_pattern_raw(String pattern, Str
// Hour
else if (all_of(segment, is_any_of("hHKk"sv))) {
builder.append("{hour}");
builder.append("{hour}"sv);
if ((segment[0] == 'h') || (segment[0] == 'K'))
hour12 = true;
@ -949,7 +949,7 @@ static Optional<CalendarPattern> parse_date_time_pattern_raw(String pattern, Str
// Minute
else if (all_of(segment, is_char('m'))) {
builder.append("{minute}");
builder.append("{minute}"sv);
if (segment.length() == 1)
format.minute = CalendarPatternStyle::Numeric;
@ -959,14 +959,14 @@ static Optional<CalendarPattern> parse_date_time_pattern_raw(String pattern, Str
// Second
else if (all_of(segment, is_char('s'))) {
builder.append("{second}");
builder.append("{second}"sv);
if (segment.length() == 1)
format.second = CalendarPatternStyle::Numeric;
else
format.second = CalendarPatternStyle::TwoDigit;
} else if (all_of(segment, is_char('S'))) {
builder.append("{fractionalSecondDigits}");
builder.append("{fractionalSecondDigits}"sv);
VERIFY(segment.length() <= 3);
format.fractional_second_digits = static_cast<u8>(segment.length());
@ -977,21 +977,21 @@ static Optional<CalendarPattern> parse_date_time_pattern_raw(String pattern, Str
// Zone
else if (all_of(segment, is_any_of("zV"sv))) {
builder.append("{timeZoneName}");
builder.append("{timeZoneName}"sv);
if (segment.length() < 4)
format.time_zone_name = CalendarPatternStyle::Short;
else
format.time_zone_name = CalendarPatternStyle::Long;
} else if (all_of(segment, is_any_of("ZOXx"sv))) {
builder.append("{timeZoneName}");
builder.append("{timeZoneName}"sv);
if (segment.length() < 4)
format.time_zone_name = CalendarPatternStyle::ShortOffset;
else
format.time_zone_name = CalendarPatternStyle::LongOffset;
} else if (all_of(segment, is_char('v'))) {
builder.append("{timeZoneName}");
builder.append("{timeZoneName}"sv);
if (segment.length() < 4)
format.time_zone_name = CalendarPatternStyle::ShortGeneric;
@ -1166,7 +1166,7 @@ static void generate_missing_patterns(Calendar& calendar, CalendarPatternList& f
auto time_pattern = locale_data.unique_strings.get(time_format);
auto date_pattern = locale_data.unique_strings.get(date_format);
auto new_pattern = pattern.replace("{0}", time_pattern, ReplaceMode::FirstOnly).replace("{1}", date_pattern, ReplaceMode::FirstOnly);
auto new_pattern = pattern.replace("{0}"sv, time_pattern, ReplaceMode::FirstOnly).replace("{1}"sv, date_pattern, ReplaceMode::FirstOnly);
return locale_data.unique_strings.ensure(move(new_pattern));
};
@ -1958,7 +1958,7 @@ static constexpr Array<@calendar_index_type@, @size@> @name@ { {)~~~");
for (auto const& calendar_key : locale_data.calendars) {
auto calendar = calendars.find(calendar_key)->value;
generator.append(first ? " " : ", ");
generator.append(first ? " "sv : ", "sv);
generator.append(String::number(calendar));
first = false;
}
@ -1979,7 +1979,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~");
auto const& value = map.find(key)->value;
auto mapping = mapping_getter(value);
generator.append(first ? " " : ", ");
generator.append(first ? " "sv : ", "sv);
generator.append(String::number(mapping));
first = false;
}
@ -1990,7 +1990,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~");
auto locales = locale_data.locales.keys();
quick_sort(locales);
generate_mapping(generator, locale_data.locales, s_calendar_index_type, "s_locale_calendars"sv, "s_calendars_{}", format_identifier, [&](auto const& name, auto const& value) { append_calendars(name, value.calendars); });
generate_mapping(generator, locale_data.locales, s_calendar_index_type, "s_locale_calendars"sv, "s_calendars_{}"sv, format_identifier, [&](auto const& name, auto const& value) { append_calendars(name, value.calendars); });
append_mapping(locales, locale_data.locales, s_time_zone_index_type, "s_locale_time_zones"sv, [](auto const& locale) { return locale.time_zones; });
append_mapping(locales, locale_data.locales, s_time_zone_format_index_type, "s_locale_time_zone_formats"sv, [](auto const& locale) { return locale.time_zone_formats; });
append_mapping(locales, locale_data.locales, s_day_period_index_type, "s_locale_day_periods"sv, [](auto const& locale) { return locale.day_periods; });

View file

@ -90,7 +90,7 @@ struct AK::Formatter<DisplayPattern> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, DisplayPattern const& patterns)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {} }}",
"{{ {}, {} }}"sv,
patterns.locale_pattern,
patterns.locale_separator);
}
@ -135,7 +135,7 @@ struct AK::Formatter<ListPatterns> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, ListPatterns const& patterns)
{
return Formatter<FormatString>::format(builder,
"{{ ListPatternType::{}, Style::{}, {}, {}, {}, {} }}",
"{{ ListPatternType::{}, Style::{}, {}, {}, {}, {} }}"sv,
format_identifier({}, patterns.type),
format_identifier({}, patterns.style),
patterns.start,
@ -169,7 +169,7 @@ struct AK::Formatter<TextLayout> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, TextLayout const& patterns)
{
return Formatter<FormatString>::format(builder,
"{{ CharacterOrder::{} }}",
"{{ CharacterOrder::{} }}"sv,
format_identifier({}, patterns.character_order));
}
};
@ -425,7 +425,7 @@ static ErrorOr<void> parse_unicode_extension_keywords(String bcp47_path, Unicode
if (!desired_keywords.span().contains_slow(key))
return;
auto const& name = value.as_object().get("_alias");
auto const& name = value.as_object().get("_alias"sv);
locale_data.keyword_names.set(key, name.as_string());
auto& keywords = locale_data.keywords.ensure(key);
@ -1156,7 +1156,7 @@ struct TextLayout {
bool first = true;
generator.append(", {");
for (auto const& item : list) {
generator.append(first ? " " : ", ");
generator.append(first ? " "sv : ", "sv);
generator.append(String::number(item));
first = false;
}
@ -1176,7 +1176,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~");
auto const& value = map.find(key)->value;
auto mapping = mapping_getter(value);
generator.append(first ? " " : ", ");
generator.append(first ? " "sv : ", "sv);
generator.append(String::number(mapping));
first = false;
}

View file

@ -97,7 +97,7 @@ struct AK::Formatter<NumberFormat> : Formatter<FormatString> {
identifier_indices.join(", "sv, format.identifier_indices);
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {}, {}, {}, {{ {} }} }}",
"{{ {}, {}, {}, {}, {}, {}, {{ {} }} }}"sv,
format.magnitude,
format.exponent,
to_underlying(format.plurality),
@ -173,7 +173,7 @@ struct AK::Formatter<NumberSystem> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, NumberSystem const& system)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }}",
"{{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }}"sv,
system.symbols,
system.primary_grouping_size,
system.secondary_grouping_size,
@ -223,7 +223,7 @@ struct AK::Formatter<Unit> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, Unit const& system)
{
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {} }}",
"{{ {}, {}, {}, {} }}"sv,
system.unit,
system.long_formats,
system.short_formats,
@ -868,7 +868,7 @@ static constexpr Array<u8, @size@> s_minimum_grouping_digits { { )~~~");
bool first = true;
for (auto const& locale : locales) {
generator.append(first ? " " : ", ");
generator.append(first ? " "sv : ", "sv);
generator.append(String::number(locale_data.locales.find(locale)->value.minimum_grouping_digits));
first = false;
}
@ -884,7 +884,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~");
bool first = true;
for (auto const& item : map) {
generator.append(first ? " " : ", ");
generator.append(first ? " "sv : ", "sv);
if constexpr (requires { item.value; })
generator.append(String::number(item.value));
else
@ -895,9 +895,9 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~");
generator.append(" } };");
};
generate_mapping(generator, locale_data.number_system_digits, "u32"sv, "s_number_systems_digits"sv, "s_number_systems_digits_{}", nullptr, [&](auto const& name, auto const& value) { append_map(name, "u32"sv, value); });
generate_mapping(generator, locale_data.locales, s_number_system_index_type, "s_locale_number_systems"sv, "s_number_systems_{}", nullptr, [&](auto const& name, auto const& value) { append_map(name, s_number_system_index_type, value.number_systems); });
generate_mapping(generator, locale_data.locales, s_unit_index_type, "s_locale_units"sv, "s_units_{}", nullptr, [&](auto const& name, auto const& value) { append_map(name, s_unit_index_type, value.units); });
generate_mapping(generator, locale_data.number_system_digits, "u32"sv, "s_number_systems_digits"sv, "s_number_systems_digits_{}"sv, nullptr, [&](auto const& name, auto const& value) { append_map(name, "u32"sv, value); });
generate_mapping(generator, locale_data.locales, s_number_system_index_type, "s_locale_number_systems"sv, "s_number_systems_{}"sv, nullptr, [&](auto const& name, auto const& value) { append_map(name, s_number_system_index_type, value.number_systems); });
generate_mapping(generator, locale_data.locales, s_unit_index_type, "s_locale_units"sv, "s_units_{}"sv, nullptr, [&](auto const& name, auto const& value) { append_map(name, s_unit_index_type, value.units); });
generator.append(R"~~~(
static Optional<NumberSystem> keyword_to_number_system(KeywordNumbers keyword)

View file

@ -591,13 +591,13 @@ static constexpr Array<PluralCategory, @size@> @name@ { { PluralCategory::Other)
append_lookup_table("PluralCategoryFunction"sv, "ordinal"sv, "default_category"sv, [](auto& rules, auto form) -> Conditions& { return rules.rules_for_form(form); });
append_lookup_table("PluralRangeFunction"sv, "range"sv, "default_range"sv, [](auto& rules, auto) -> Ranges& { return rules.plural_ranges; });
generate_mapping(generator, locales, "PluralCategory"sv, "s_cardinal_categories"sv, "s_cardinal_categories_{}", format_identifier,
generate_mapping(generator, locales, "PluralCategory"sv, "s_cardinal_categories"sv, "s_cardinal_categories_{}"sv, format_identifier,
[&](auto const& name, auto const& locale) {
auto& rules = locale_data.locales.find(locale)->value;
append_categories(name, rules.rules_for_form("cardinal"sv));
});
generate_mapping(generator, locales, "PluralCategory"sv, "s_ordinal_categories"sv, "s_ordinal_categories_{}", format_identifier,
generate_mapping(generator, locales, "PluralCategory"sv, "s_ordinal_categories"sv, "s_ordinal_categories_{}"sv, format_identifier,
[&](auto const& name, auto const& locale) {
auto& rules = locale_data.locales.find(locale)->value;
append_categories(name, rules.rules_for_form("ordinal"sv));

View file

@ -58,7 +58,7 @@ struct AK::Formatter<RelativeTimeFormat> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, RelativeTimeFormat const& format)
{
return Formatter<FormatString>::format(builder,
"{{ TimeUnit::{}, Style::{}, PluralCategory::{}, {}, {} }}",
"{{ TimeUnit::{}, Style::{}, PluralCategory::{}, {}, {} }}"sv,
format.time_unit,
format.style,
format.plurality,
@ -242,7 +242,7 @@ static constexpr Array<@relative_time_format_index_type@, @size@> @name@ { {)~~~
bool first = true;
for (auto index : list) {
generator.append(first ? " " : ", ");
generator.append(first ? " "sv : ", "sv);
generator.append(String::number(index));
first = false;
}
@ -250,7 +250,7 @@ static constexpr Array<@relative_time_format_index_type@, @size@> @name@ { {)~~~
generator.append(" } };");
};
generate_mapping(generator, locale_data.locales, s_relative_time_format_index_type, "s_locale_relative_time_formats"sv, "s_number_systems_digits_{}", nullptr, [&](auto const& name, auto const& value) { append_list(name, value.time_units); });
generate_mapping(generator, locale_data.locales, s_relative_time_format_index_type, "s_locale_relative_time_formats"sv, "s_number_systems_digits_{}"sv, nullptr, [&](auto const& name, auto const& value) { append_list(name, value.time_units); });
generator.append(R"~~~(
Vector<RelativeTimeFormat> get_relative_time_format_patterns(StringView locale, TimeUnit time_unit, StringView tense_or_number, Style style)

View file

@ -136,7 +136,7 @@ static constexpr Array<@type@, @size@> @name@@index@ { {)~~~");
bool first = true;
for (auto const& value : list) {
generator.append(first ? " " : ", ");
generator.append(first ? " "sv : ", "sv);
generator.append(String::formatted("{}", value));
first = false;
}
@ -538,7 +538,7 @@ Span<StringView const> @name@()
bool first = true;
for (auto const& value : values) {
generator.append(first ? " " : ", ");
generator.append(first ? " "sv : ", "sv);
first = false;
if (auto it = aliases.find_if([&](auto const& alias) { return alias.alias == value; }); it != aliases.end())

View file

@ -137,8 +137,8 @@ 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"));
auto feature_type = feature.get("type");
VERIFY(feature.has("type"sv));
auto feature_type = feature.get("type"sv);
VERIFY(feature_type.is_string());
member_generator.set("is_range", feature_type.as_string() == "range" ? "true" : "false");
member_generator.append(R"~~~(
@ -165,7 +165,7 @@ bool media_feature_accepts_type(MediaFeatureID media_feature_id, MediaFeatureVal
case MediaFeatureID::@name:titlecase@:)~~~");
bool have_output_value_type_switch = false;
if (feature.has("values")) {
if (feature.has("values"sv)) {
auto append_value_type_switch_if_needed = [&]() {
if (!have_output_value_type_switch) {
member_generator.append(R"~~~(
@ -173,7 +173,7 @@ bool media_feature_accepts_type(MediaFeatureID media_feature_id, MediaFeatureVal
}
have_output_value_type_switch = true;
};
auto& values = feature.get("values");
auto& values = feature.get("values"sv);
VERIFY(values.is_array());
auto& values_array = values.as_array();
for (auto& type : values_array.values()) {
@ -243,7 +243,7 @@ bool media_feature_accepts_identifier(MediaFeatureID media_feature_id, ValueID i
case MediaFeatureID::@name:titlecase@:)~~~");
bool have_output_identifier_switch = false;
if (feature.has("values")) {
if (feature.has("values"sv)) {
auto append_identifier_switch_if_needed = [&]() {
if (!have_output_identifier_switch) {
member_generator.append(R"~~~(
@ -251,7 +251,7 @@ bool media_feature_accepts_identifier(MediaFeatureID media_feature_id, ValueID i
}
have_output_identifier_switch = true;
};
auto& values = feature.get("values");
auto& values = feature.get("values"sv);
VERIFY(values.is_array());
auto& values_array = values.as_array();
for (auto& identifier : values_array.values()) {

View file

@ -63,7 +63,7 @@ enum class PropertyID {
properties.for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
if (value.as_object().has("longhands"))
if (value.as_object().has("longhands"sv))
shorthand_property_ids.append(name);
else
longhand_property_ids.append(name);
@ -104,7 +104,7 @@ enum class PropertyID {
PropertyID property_id_from_camel_case_string(StringView);
PropertyID property_id_from_string(StringView);
const char* string_from_property_id(PropertyID);
StringView string_from_property_id(PropertyID);
bool is_inherited_property(PropertyID);
NonnullRefPtr<StyleValue> property_initial_value(PropertyID);
@ -189,7 +189,7 @@ PropertyID property_id_from_string(StringView string)
member_generator.set("name", name);
member_generator.set("name:titlecase", title_casify(name));
member_generator.append(R"~~~(
if (string.equals_ignoring_case("@name@"))
if (string.equals_ignoring_case("@name@"sv))
return PropertyID::@name:titlecase@;
)~~~");
});
@ -198,7 +198,7 @@ PropertyID property_id_from_string(StringView string)
return PropertyID::Invalid;
}
const char* string_from_property_id(PropertyID property_id) {
StringView string_from_property_id(PropertyID property_id) {
switch (property_id) {
)~~~");
@ -210,13 +210,13 @@ const char* string_from_property_id(PropertyID property_id) {
member_generator.set("name:titlecase", title_casify(name));
member_generator.append(R"~~~(
case PropertyID::@name:titlecase@:
return "@name@";
return "@name@"sv;
)~~~");
});
generator.append(R"~~~(
default:
return "(invalid CSS::PropertyID)";
return "(invalid CSS::PropertyID)"sv;
}
}
@ -229,8 +229,8 @@ bool is_inherited_property(PropertyID property_id)
VERIFY(value.is_object());
bool inherited = false;
if (value.as_object().has("inherited")) {
auto& inherited_value = value.as_object().get("inherited");
if (value.as_object().has("inherited"sv)) {
auto& inherited_value = value.as_object().get("inherited"sv);
VERIFY(inherited_value.is_bool());
inherited = inherited_value.as_bool();
}
@ -260,8 +260,8 @@ bool property_affects_layout(PropertyID property_id)
VERIFY(value.is_object());
bool affects_layout = true;
if (value.as_object().has("affects-layout"))
affects_layout = value.as_object().get("affects-layout").to_bool();
if (value.as_object().has("affects-layout"sv))
affects_layout = value.as_object().get("affects-layout"sv).to_bool();
if (affects_layout) {
auto member_generator = generator.fork();
@ -288,8 +288,8 @@ bool property_affects_stacking_context(PropertyID property_id)
VERIFY(value.is_object());
bool affects_stacking_context = false;
if (value.as_object().has("affects-stacking-context"))
affects_stacking_context = value.as_object().get("affects-stacking-context").to_bool();
if (value.as_object().has("affects-stacking-context"sv))
affects_stacking_context = value.as_object().get("affects-stacking-context"sv).to_bool();
if (affects_stacking_context) {
auto member_generator = generator.fork();
@ -322,11 +322,11 @@ NonnullRefPtr<StyleValue> property_initial_value(PropertyID property_id)
// works for now! :^)
auto output_initial_value_code = [&](auto& name, auto& object) {
if (!object.has("initial")) {
if (!object.has("initial"sv)) {
dbgln("No initial value specified for property '{}'", name);
VERIFY_NOT_REACHED();
}
auto& initial_value = object.get("initial");
auto& initial_value = object.get("initial"sv);
VERIFY(initial_value.is_string());
auto initial_value_string = initial_value.as_string();
@ -335,7 +335,7 @@ NonnullRefPtr<StyleValue> property_initial_value(PropertyID property_id)
member_generator.set("initial_value_string", initial_value_string);
member_generator.append(R"~~~(
{
auto parsed_value = parse_css_value(parsing_context, "@initial_value_string@", PropertyID::@name:titlecase@);
auto parsed_value = parse_css_value(parsing_context, "@initial_value_string@"sv, PropertyID::@name:titlecase@);
VERIFY(!parsed_value.is_null());
initial_values[to_underlying(PropertyID::@name:titlecase@)] = parsed_value.release_nonnull();
}
@ -344,14 +344,14 @@ NonnullRefPtr<StyleValue> property_initial_value(PropertyID property_id)
properties.for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
if (value.as_object().has("longhands"))
if (value.as_object().has("longhands"sv))
return;
output_initial_value_code(name, value.as_object());
});
properties.for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
if (!value.as_object().has("longhands"))
if (!value.as_object().has("longhands"sv))
return;
output_initial_value_code(name, value.as_object());
});
@ -369,8 +369,8 @@ 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")) {
auto& quirks_value = value.as_object().get("quirks");
if (value.as_object().has("quirks"sv)) {
auto& quirks_value = value.as_object().get("quirks"sv);
VERIFY(quirks_value.is_array());
auto& quirks = quirks_value.as_array();
@ -417,8 +417,8 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
properties.for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
auto& object = value.as_object();
bool has_valid_types = object.has("valid-types");
auto has_valid_identifiers = object.has("valid-identifiers");
bool has_valid_types = object.has("valid-types"sv);
auto has_valid_identifiers = object.has("valid-identifiers"sv);
if (has_valid_types || has_valid_identifiers) {
auto property_generator = generator.fork();
property_generator.set("name:titlecase", title_casify(name));
@ -461,7 +461,7 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
};
if (has_valid_types) {
auto valid_types_value = object.get("valid-types");
auto valid_types_value = object.get("valid-types"sv);
VERIFY(valid_types_value.is_array());
auto valid_types = valid_types_value.as_array();
if (!valid_types.is_empty()) {
@ -480,36 +480,36 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
}
if (type_name == "angle") {
output_numeric_value_check(property_generator, "is_angle", "as_angle().angle().to_degrees()", Array { "Angle"sv }, min_value, max_value);
output_numeric_value_check(property_generator, "is_angle"sv, "as_angle().angle().to_degrees()"sv, Array { "Angle"sv }, min_value, max_value);
} else if (type_name == "color") {
property_generator.append(R"~~~(
if (style_value.has_color())
return true;
)~~~");
} else if (type_name == "frequency") {
output_numeric_value_check(property_generator, "is_frequency", "as_frequency().frequency().to_hertz()", Array { "Frequency"sv }, min_value, max_value);
output_numeric_value_check(property_generator, "is_frequency"sv, "as_frequency().frequency().to_hertz()"sv, Array { "Frequency"sv }, min_value, max_value);
} else if (type_name == "image") {
property_generator.append(R"~~~(
if (style_value.is_image())
return true;
)~~~");
} else if (type_name == "integer") {
output_numeric_value_check(property_generator, "has_integer", "to_integer()", Array { "Integer"sv }, min_value, max_value);
output_numeric_value_check(property_generator, "has_integer"sv, "to_integer()"sv, Array { "Integer"sv }, min_value, max_value);
} else if (type_name == "length") {
output_numeric_value_check(property_generator, "has_length", "to_length().raw_value()", Array { "Length"sv }, min_value, max_value);
output_numeric_value_check(property_generator, "has_length"sv, "to_length().raw_value()"sv, Array { "Length"sv }, min_value, max_value);
} else if (type_name == "number") {
output_numeric_value_check(property_generator, "has_number", "to_number()", Array { "Integer"sv, "Number"sv }, min_value, max_value);
output_numeric_value_check(property_generator, "has_number"sv, "to_number()"sv, Array { "Integer"sv, "Number"sv }, min_value, max_value);
} else if (type_name == "percentage") {
output_numeric_value_check(property_generator, "is_percentage", "as_percentage().percentage().value()", Array { "Percentage"sv }, min_value, max_value);
output_numeric_value_check(property_generator, "is_percentage"sv, "as_percentage().percentage().value()"sv, Array { "Percentage"sv }, min_value, max_value);
} else if (type_name == "resolution") {
output_numeric_value_check(property_generator, "is_resolution", "as_resolution().resolution().to_dots_per_pixel()", Array<StringView, 0> {}, min_value, max_value);
output_numeric_value_check(property_generator, "is_resolution"sv, "as_resolution().resolution().to_dots_per_pixel()"sv, Array<StringView, 0> {}, min_value, max_value);
} else if (type_name == "string") {
property_generator.append(R"~~~(
if (style_value.is_string())
return true;
)~~~");
} else if (type_name == "time") {
output_numeric_value_check(property_generator, "is_time", "as_time().time().to_seconds()", Array { "Time"sv }, min_value, max_value);
output_numeric_value_check(property_generator, "is_time"sv, "as_time().time().to_seconds()"sv, Array { "Time"sv }, min_value, max_value);
} else if (type_name == "url") {
// FIXME: Handle urls!
} else {
@ -526,7 +526,7 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
}
if (has_valid_identifiers) {
auto valid_identifiers_value = object.get("valid-identifiers");
auto valid_identifiers_value = object.get("valid-identifiers"sv);
VERIFY(valid_identifiers_value.is_array());
auto valid_identifiers = valid_identifiers_value.as_array();
if (!valid_identifiers.is_empty()) {
@ -570,8 +570,8 @@ 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")) {
auto max_values = value.as_object().get("max-values");
if (value.as_object().has("max-values"sv)) {
auto max_values = value.as_object().get("max-values"sv);
VERIFY(max_values.is_number() && !max_values.is_double());
auto property_generator = generator.fork();
property_generator.set("name:titlecase", title_casify(name));

View file

@ -153,7 +153,7 @@ TransformFunctionMetadata transform_function_metadata(TransformFunction transfor
)~~~");
transforms_data.for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
auto parameters_string = value.as_object().get("parameters").as_string();
auto parameters_string = value.as_object().get("parameters"sv).as_string();
GenericLexer lexer { parameters_string };
VERIFY(lexer.consume_specific('<'));

View file

@ -98,7 +98,7 @@ ValueID value_id_from_string(StringView string)
member_generator.set("name", name.to_string());
member_generator.set("name:titlecase", title_casify(name.to_string()));
member_generator.append(R"~~~(
if (string.equals_ignoring_case("@name@"))
if (string.equals_ignoring_case("@name@"sv))
return ValueID::@name:titlecase@;
)~~~");
});

View file

@ -51,7 +51,7 @@ String camel_casify(StringView dashy_name)
String snake_casify(String const& dashy_name)
{
return dashy_name.replace("-", "_", ReplaceMode::All);
return dashy_name.replace("-"sv, "_"sv, ReplaceMode::All);
}
ErrorOr<JsonValue> read_entire_file_as_json(StringView filename)

View file

@ -28,9 +28,9 @@ static bool is_wrappable_type(Type const& type)
return true;
if (type.name == "DocumentType")
return true;
if (type.name.ends_with("Element"))
if (type.name.ends_with("Element"sv))
return true;
if (type.name.ends_with("Event"))
if (type.name.ends_with("Event"sv))
return true;
if (type.name == "ImageData")
return true;
@ -155,7 +155,7 @@ static String make_input_acceptable_cpp(String const& input)
return builder.to_string();
}
return input.replace("-", "_", ReplaceMode::All);
return input.replace("-"sv, "_"sv, ReplaceMode::All);
}
static void generate_include_for_wrapper(auto& generator, auto& wrapper_name)
@ -239,7 +239,7 @@ static void emit_includes_for_all_imports(auto& interface, auto& generator, bool
if (is_iterator) {
auto iterator_name = String::formatted("{}Iterator", interface->name);
auto iterator_path = String::formatted("{}Iterator", interface->fully_qualified_name.replace("::", "/", ReplaceMode::All));
auto iterator_path = String::formatted("{}Iterator", interface->fully_qualified_name.replace("::"sv, "/"sv, ReplaceMode::All));
generate_include_for_iterator(generator, iterator_path, iterator_name);
}
@ -263,9 +263,9 @@ static bool should_emit_wrapper_factory(IDL::Interface const& interface)
return false;
if (interface.name == "DocumentType")
return false;
if (interface.name.ends_with("Element"))
if (interface.name.ends_with("Element"sv))
return false;
if (interface.name.starts_with("CSS") && interface.name.ends_with("Rule"))
if (interface.name.starts_with("CSS"sv) && interface.name.ends_with("Rule"sv))
return false;
return true;
}
@ -580,7 +580,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
auto default_value_cpp_name = enumeration.translated_cpp_names.get(enum_member_name);
VERIFY(default_value_cpp_name.has_value());
enum_generator.set("enum.default.cpp_value", *default_value_cpp_name);
enum_generator.set("js_name.as_string", String::formatted("{}{}_string", enum_generator.get("js_name"), enum_generator.get("js_suffix")));
enum_generator.set("js_name.as_string", String::formatted("{}{}_string", enum_generator.get("js_name"sv), enum_generator.get("js_suffix"sv)));
enum_generator.append(R"~~~(
@parameter.type.name@ @cpp_name@ { @parameter.type.name@::@enum.default.cpp_value@ };
)~~~");
@ -1291,7 +1291,7 @@ static void generate_arguments(SourceGenerator& generator, Vector<IDL::Parameter
++argument_index;
}
arguments_builder.join(", ", parameter_names);
arguments_builder.join(", "sv, parameter_names);
}
// https://webidl.spec.whatwg.org/#create-sequence-from-iterable
@ -1674,7 +1674,7 @@ static Optional<String> generate_arguments_match_check_for_count(Vector<IDL::Par
}
if (conditions.is_empty())
return {};
return String::formatted("({})", String::join(" && ", conditions));
return String::formatted("({})", String::join(" && "sv, conditions));
}
static String generate_arguments_match_check(Function const& function)
@ -1692,7 +1692,7 @@ static String generate_arguments_match_check(Function const& function)
if (match_check.has_value())
options.append(match_check.release_value());
}
return String::join(" || ", options);
return String::join(" || "sv, options);
}
static void generate_overload_arbiter(SourceGenerator& generator, auto const& overload_set, String const& class_name)
@ -3679,7 +3679,7 @@ void generate_iterator_prototype_implementation(IDL::Interface const& interface)
generator.set("prototype_class", String::formatted("{}IteratorPrototype", interface.name));
generator.set("wrapper_class", String::formatted("{}IteratorWrapper", interface.name));
generator.set("fully_qualified_name", String::formatted("{}Iterator", interface.fully_qualified_name));
generator.set("possible_include_path", String::formatted("{}Iterator", interface.name.replace("::", "/", ReplaceMode::All)));
generator.set("possible_include_path", String::formatted("{}Iterator", interface.name.replace("::"sv, "/"sv, ReplaceMode::All)));
generator.append(R"~~~(
#include <AK/Function.h>

View file

@ -40,7 +40,7 @@
error_message.appendff("{}\n", input.substring_view(start_line, line_length));
for (size_t i = 0; i < colno - 1; ++i)
error_message.append(' ');
error_message.append("\033[1;31m^\n");
error_message.append("\033[1;31m^\n"sv);
error_message.appendff("{}:{}: error: {}\033[0m\n", filename, lineno, message);
warnln("{}", error_message.string_view());
@ -65,7 +65,7 @@ static String convert_enumeration_value_to_cpp_enum_member(String const& value,
}
if (builder.is_empty())
builder.append("Empty");
builder.append("Empty"sv);
while (names_already_seen.contains(builder.string_view()))
builder.append('_');
@ -158,7 +158,7 @@ NonnullRefPtr<Type> Parser::parse_type()
NonnullRefPtrVector<Type> union_member_types;
union_member_types.append(parse_type());
consume_whitespace();
assert_string("or");
assert_string("or"sv);
consume_whitespace();
union_member_types.append(parse_type());
consume_whitespace();
@ -185,7 +185,7 @@ NonnullRefPtr<Type> Parser::parse_type()
if (name.equals_ignoring_case("long"sv)) {
consume_whitespace();
if (lexer.consume_specific("long"sv))
name = "long long";
name = "long long"sv;
}
NonnullRefPtrVector<Type> parameters;
@ -202,7 +202,7 @@ NonnullRefPtr<Type> Parser::parse_type()
auto nullable = lexer.consume_specific('?');
StringBuilder builder;
if (unsigned_)
builder.append("unsigned ");
builder.append("unsigned "sv);
builder.append(name);
if (is_parameterized_type)
@ -341,7 +341,7 @@ Function Parser::parse_function(HashMap<String, String>& extended_attributes, In
void Parser::parse_constructor(Interface& interface)
{
assert_string("constructor");
assert_string("constructor"sv);
consume_whitespace();
assert_specific('(');
auto parameters = parse_parameters();
@ -354,10 +354,10 @@ void Parser::parse_constructor(Interface& interface)
void Parser::parse_stringifier(HashMap<String, String>& extended_attributes, Interface& interface)
{
assert_string("stringifier");
assert_string("stringifier"sv);
consume_whitespace();
interface.has_stringifier = true;
if (lexer.next_is("readonly") || lexer.next_is("attribute")) {
if (lexer.next_is("readonly"sv) || lexer.next_is("attribute"sv)) {
parse_attribute(extended_attributes, interface);
interface.stringifier_attribute = interface.attributes.last().name;
} else {
@ -367,12 +367,12 @@ void Parser::parse_stringifier(HashMap<String, String>& extended_attributes, Int
void Parser::parse_iterable(Interface& interface)
{
assert_string("iterable");
assert_string("iterable"sv);
assert_specific('<');
auto first_type = parse_type();
if (lexer.next_is(',')) {
if (interface.supports_indexed_properties())
report_parsing_error("Interfaces with a pair iterator must not supported indexed properties.", filename, input, lexer.tell());
report_parsing_error("Interfaces with a pair iterator must not supported indexed properties."sv, filename, input, lexer.tell());
assert_specific(',');
consume_whitespace();
@ -380,7 +380,7 @@ void Parser::parse_iterable(Interface& interface)
interface.pair_iterator_types = Tuple { move(first_type), move(second_type) };
} else {
if (!interface.supports_indexed_properties())
report_parsing_error("Interfaces with a value iterator must supported indexed properties.", filename, input, lexer.tell());
report_parsing_error("Interfaces with a value iterator must supported indexed properties."sv, filename, input, lexer.tell());
interface.value_iterator_type = move(first_type);
}
@ -390,7 +390,7 @@ void Parser::parse_iterable(Interface& interface)
void Parser::parse_getter(HashMap<String, String>& extended_attributes, Interface& interface)
{
assert_string("getter");
assert_string("getter"sv);
consume_whitespace();
auto function = parse_function(extended_attributes, interface, IsSpecialOperation::Yes);
@ -400,21 +400,21 @@ void Parser::parse_getter(HashMap<String, String>& extended_attributes, Interfac
auto& identifier = function.parameters.first();
if (identifier.type->nullable)
report_parsing_error("identifier's type must not be nullable.", filename, input, lexer.tell());
report_parsing_error("identifier's type must not be nullable."sv, filename, input, lexer.tell());
if (identifier.optional)
report_parsing_error("identifier must not be optional.", filename, input, lexer.tell());
report_parsing_error("identifier must not be optional."sv, filename, input, lexer.tell());
// FIXME: Disallow variadic functions once they're supported.
if (identifier.type->name == "DOMString") {
if (interface.named_property_getter.has_value())
report_parsing_error("An interface can only have one named property getter.", filename, input, lexer.tell());
report_parsing_error("An interface can only have one named property getter."sv, filename, input, lexer.tell());
interface.named_property_getter = move(function);
} else if (identifier.type->name == "unsigned long") {
if (interface.indexed_property_getter.has_value())
report_parsing_error("An interface can only have one indexed property getter.", filename, input, lexer.tell());
report_parsing_error("An interface can only have one indexed property getter."sv, filename, input, lexer.tell());
interface.indexed_property_getter = move(function);
} else {
@ -424,7 +424,7 @@ void Parser::parse_getter(HashMap<String, String>& extended_attributes, Interfac
void Parser::parse_setter(HashMap<String, String>& extended_attributes, Interface& interface)
{
assert_string("setter");
assert_string("setter"sv);
consume_whitespace();
auto function = parse_function(extended_attributes, interface, IsSpecialOperation::Yes);
@ -434,27 +434,27 @@ void Parser::parse_setter(HashMap<String, String>& extended_attributes, Interfac
auto& identifier = function.parameters.first();
if (identifier.type->nullable)
report_parsing_error("identifier's type must not be nullable.", filename, input, lexer.tell());
report_parsing_error("identifier's type must not be nullable."sv, filename, input, lexer.tell());
if (identifier.optional)
report_parsing_error("identifier must not be optional.", filename, input, lexer.tell());
report_parsing_error("identifier must not be optional."sv, filename, input, lexer.tell());
// FIXME: Disallow variadic functions once they're supported.
if (identifier.type->name == "DOMString") {
if (interface.named_property_setter.has_value())
report_parsing_error("An interface can only have one named property setter.", filename, input, lexer.tell());
report_parsing_error("An interface can only have one named property setter."sv, filename, input, lexer.tell());
if (!interface.named_property_getter.has_value())
report_parsing_error("A named property setter must be accompanied by a named property getter.", filename, input, lexer.tell());
report_parsing_error("A named property setter must be accompanied by a named property getter."sv, filename, input, lexer.tell());
interface.named_property_setter = move(function);
} else if (identifier.type->name == "unsigned long") {
if (interface.indexed_property_setter.has_value())
report_parsing_error("An interface can only have one indexed property setter.", filename, input, lexer.tell());
report_parsing_error("An interface can only have one indexed property setter."sv, filename, input, lexer.tell());
if (!interface.indexed_property_getter.has_value())
report_parsing_error("An indexed property setter must be accompanied by an indexed property getter.", filename, input, lexer.tell());
report_parsing_error("An indexed property setter must be accompanied by an indexed property getter."sv, filename, input, lexer.tell());
interface.indexed_property_setter = move(function);
} else {
@ -464,7 +464,7 @@ void Parser::parse_setter(HashMap<String, String>& extended_attributes, Interfac
void Parser::parse_deleter(HashMap<String, String>& extended_attributes, Interface& interface)
{
assert_string("deleter");
assert_string("deleter"sv);
consume_whitespace();
auto function = parse_function(extended_attributes, interface, IsSpecialOperation::Yes);
@ -474,19 +474,19 @@ void Parser::parse_deleter(HashMap<String, String>& extended_attributes, Interfa
auto& identifier = function.parameters.first();
if (identifier.type->nullable)
report_parsing_error("identifier's type must not be nullable.", filename, input, lexer.tell());
report_parsing_error("identifier's type must not be nullable."sv, filename, input, lexer.tell());
if (identifier.optional)
report_parsing_error("identifier must not be optional.", filename, input, lexer.tell());
report_parsing_error("identifier must not be optional."sv, filename, input, lexer.tell());
// FIXME: Disallow variadic functions once they're supported.
if (identifier.type->name == "DOMString") {
if (interface.named_property_deleter.has_value())
report_parsing_error("An interface can only have one named property deleter.", filename, input, lexer.tell());
report_parsing_error("An interface can only have one named property deleter."sv, filename, input, lexer.tell());
if (!interface.named_property_getter.has_value())
report_parsing_error("A named property deleter must be accompanied by a named property getter.", filename, input, lexer.tell());
report_parsing_error("A named property deleter must be accompanied by a named property getter."sv, filename, input, lexer.tell());
interface.named_property_deleter = move(function);
} else {
@ -576,7 +576,7 @@ void Parser::parse_interface(Interface& interface)
void Parser::parse_enumeration(Interface& interface)
{
assert_string("enum");
assert_string("enum"sv);
consume_whitespace();
Enumeration enumeration {};
@ -626,7 +626,7 @@ void Parser::parse_enumeration(Interface& interface)
void Parser::parse_typedef(Interface& interface)
{
assert_string("typedef");
assert_string("typedef"sv);
consume_whitespace();
HashMap<String, String> extended_attributes;
@ -645,7 +645,7 @@ void Parser::parse_typedef(Interface& interface)
void Parser::parse_dictionary(Interface& interface)
{
assert_string("dictionary");
assert_string("dictionary"sv);
consume_whitespace();
Dictionary dictionary {};
@ -723,14 +723,14 @@ void Parser::parse_interface_mixin(Interface& interface)
mixin_interface.module_own_path = interface.module_own_path;
mixin_interface.is_mixin = true;
assert_string("interface");
assert_string("interface"sv);
consume_whitespace();
assert_string("mixin");
assert_string("mixin"sv);
auto offset = lexer.tell();
parse_interface(mixin_interface);
if (!mixin_interface.parent_name.is_empty())
report_parsing_error("Mixin interfaces are not allowed to have inherited parents", filename, input, offset);
report_parsing_error("Mixin interfaces are not allowed to have inherited parents"sv, filename, input, offset);
auto name = mixin_interface.name;
interface.mixins.set(move(name), &mixin_interface);
@ -738,7 +738,7 @@ void Parser::parse_interface_mixin(Interface& interface)
void Parser::parse_callback_function(HashMap<String, String>& extended_attributes, Interface& interface)
{
assert_string("callback");
assert_string("callback"sv);
consume_whitespace();
auto name = lexer.consume_until([](auto ch) { return is_ascii_space(ch); });
@ -787,7 +787,7 @@ void Parser::parse_non_interface_entities(bool allow_interface, Interface& inter
assert_specific(';');
consume_whitespace();
} else {
report_parsing_error("expected 'enum' or 'dictionary'", filename, input, current_offset);
report_parsing_error("expected 'enum' or 'dictionary'"sv, filename, input, current_offset);
}
} else {
interface.extended_attributes = move(extended_attributes);

View file

@ -340,21 +340,21 @@ struct UnionType : public Type {
String to_variant(IDL::Interface const& interface) const
{
StringBuilder builder;
builder.append("Variant<");
builder.append("Variant<"sv);
auto flattened_types = flattened_member_types();
for (size_t type_index = 0; type_index < flattened_types.size(); ++type_index) {
auto& type = flattened_types.at(type_index);
if (type_index > 0)
builder.append(", ");
builder.append(", "sv);
auto cpp_type = idl_type_name_to_cpp_type(type, interface);
builder.append(cpp_type.name);
}
if (includes_undefined())
builder.append(", Empty");
builder.append(", Empty"sv);
builder.append('>');
return builder.to_string();

View file

@ -88,7 +88,7 @@ int main(int argc, char** argv)
if (namespace_.is_one_of("Crypto", "CSS", "DOM", "DOMParsing", "Encoding", "HTML", "UIEvents", "Geometry", "HighResolutionTime", "IntersectionObserver", "NavigationTiming", "RequestIdleCallback", "ResizeObserver", "SVG", "Selection", "URL", "WebGL", "WebSockets", "XHR")) {
StringBuilder builder;
builder.append(namespace_);
builder.append("::");
builder.append("::"sv);
builder.append(interface.name);
interface.fully_qualified_name = builder.to_string();
} else {

View file

@ -200,7 +200,7 @@ static Result<Vector<String>, int> run_whiptail(WhiptailMode mode, Vector<Whipta
static bool run_system_command(String const& command, StringView command_name)
{
if (command.starts_with("cmake"))
if (command.starts_with("cmake"sv))
warnln("\e[34mRunning CMake...\e[0m");
else
warnln("\e[34mRunning '{}'...\e[0m", command);
@ -261,7 +261,7 @@ int main()
configs.append({ "CUSTOM_FULL", "Full", "Customizable.", false });
configs.append({ "CUSTOM_CURRENT", "Current", "Customize current configuration.", false });
auto configs_result = run_whiptail(WhiptailMode::Menu, configs, "SerenityOS - System Configurations", "Which system configuration do you want to use or customize?");
auto configs_result = run_whiptail(WhiptailMode::Menu, configs, "SerenityOS - System Configurations"sv, "Which system configuration do you want to use or customize?"sv);
if (configs_result.is_error()) {
warnln("ConfigureComponents cancelled.");
return 0;
@ -270,7 +270,7 @@ int main()
VERIFY(configs_result.value().size() == 1);
auto type = configs_result.value().first();
bool customize = type.starts_with("CUSTOM_");
bool customize = type.starts_with("CUSTOM_"sv);
StringView build_type = customize ? type.substring_view(7) : type.view();
// Step 4: Customize the configuration if the user requested to. In any case, set the components component.is_selected value correctly.
@ -286,7 +286,7 @@ int main()
if (is_required) {
if (!description_builder.is_empty())
description_builder.append(' ');
description_builder.append("[required]");
description_builder.append("[required]"sv);
}
// NOTE: Required components will always be preselected.
@ -307,7 +307,7 @@ int main()
options.append(move(option));
}
auto result = run_whiptail(WhiptailMode::Checklist, options, "SerenityOS - System Components", "Which optional system components do you want to include?");
auto result = run_whiptail(WhiptailMode::Checklist, options, "SerenityOS - System Components"sv, "Which optional system components do you want to include?"sv);
if (result.is_error()) {
warnln("ConfigureComponents cancelled.");
return 0;
@ -352,11 +352,11 @@ int main()
// Step 6: Run CMake, 'ninja clean' and 'rm -rf Root'
auto command = String::join(' ', cmake_arguments);
if (!run_system_command(command, "CMake"))
if (!run_system_command(command, "CMake"sv))
return 1;
if (!run_system_command("ninja clean", "Ninja"))
if (!run_system_command("ninja clean"sv, "Ninja"sv))
return 1;
if (!run_system_command("rm -rf Root", "rm"))
if (!run_system_command("rm -rf Root"sv, "rm"sv))
return 1;
return 0;
}

View file

@ -2,9 +2,11 @@
# $1 name of the variable
# $2 input path
echo "extern const char $1[];"
printf "const char %s[] = R\"~~~(" "$1"
echo "#include <AK/StringView.h>"
echo
echo "extern StringView $1;"
printf "StringView %s = R\"~~~(" "$1"
grep -v '^ *#' < "$2" | while IFS= read -r line; do
echo "$line"
done
echo ")~~~\";"
echo ")~~~\"sv;"