mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:17: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:
parent
e5f09ea170
commit
3f3f45580a
762 changed files with 8315 additions and 8316 deletions
|
@ -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()) {
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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('<'));
|
||||
|
|
|
@ -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@;
|
||||
)~~~");
|
||||
});
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue