mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +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
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue