1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -246,7 +246,7 @@ ErrorOr<void, ParseError> Parser::parse_internal()
if (auto it = find_if(matched_source.begin(), matched_source.end(), s_restricted_characters); !it.is_end()) {
return parse_error(
it.index(),
DeprecatedString::formatted("Invalid character #{:x} used in document", *it));
ByteString::formatted("Invalid character #{:x} used in document", *it));
}
if (!m_lexer.is_eof())
@ -261,7 +261,7 @@ ErrorOr<void, ParseError> Parser::expect(StringView expected)
if (!m_lexer.consume_specific(expected)) {
if (m_options.treat_errors_as_fatal)
return parse_error(m_lexer.tell(), DeprecatedString::formatted("Expected '{}'", expected));
return parse_error(m_lexer.tell(), ByteString::formatted("Expected '{}'", expected));
}
rollback.disarm();
@ -275,7 +275,7 @@ requires(IsCallableWithArguments<Pred, bool, char>) ErrorOr<StringView, ParseErr
auto start = m_lexer.tell();
if (!m_lexer.next_is(predicate)) {
if (m_options.treat_errors_as_fatal)
return parse_error(m_lexer.tell(), DeprecatedString::formatted("Expected {}", description));
return parse_error(m_lexer.tell(), ByteString::formatted("Expected {}", description));
}
m_lexer.ignore();
@ -296,7 +296,7 @@ requires(IsCallableWithArguments<Pred, bool, char>) ErrorOr<StringView, ParseErr
if (m_lexer.tell() == start) {
if (m_options.treat_errors_as_fatal) {
return parse_error(m_lexer.tell(), DeprecatedString::formatted("Expected {}", description));
return parse_error(m_lexer.tell(), ByteString::formatted("Expected {}", description));
}
}
@ -378,7 +378,7 @@ ErrorOr<void, ParseError> Parser::parse_version_info()
m_in_compatibility_mode = true;
} else {
if (version_string != "1.1" && m_options.treat_errors_as_fatal)
return parse_error(m_lexer.tell(), DeprecatedString::formatted("Expected '1.1', found '{}'", version_string));
return parse_error(m_lexer.tell(), ByteString::formatted("Expected '1.1', found '{}'", version_string));
}
m_version = Version::Version11;
@ -524,7 +524,7 @@ ErrorOr<void, ParseError> Parser::parse_processing_instruction()
auto accept = accept_rule();
auto target = TRY(parse_processing_instruction_target());
DeprecatedString data;
ByteString data;
if (auto result = skip_whitespace(Required::Yes); !result.is_error())
data = m_lexer.consume_until("?>");
TRY(expect("?>"sv));
@ -576,7 +576,7 @@ ErrorOr<Name, ParseError> Parser::parse_name()
builder.append(rest);
rollback.disarm();
return builder.to_deprecated_string();
return builder.to_byte_string();
}
// 2.8.28. doctypedecl, https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-doctypedecl
@ -601,7 +601,7 @@ ErrorOr<void, ParseError> Parser::parse_doctype_decl()
if (resource_result.is_error()) {
return parse_error(
id_start,
DeprecatedString::formatted("Failed to resolve external subset '{}': {}", doctype.external_id->system_id.system_literal, resource_result.error()));
ByteString::formatted("Failed to resolve external subset '{}': {}", doctype.external_id->system_id.system_literal, resource_result.error()));
}
StringView resolved_source = resource_result.value();
TemporaryChange source { m_source, resolved_source };
@ -610,7 +610,7 @@ ErrorOr<void, ParseError> Parser::parse_doctype_decl()
if (!m_lexer.is_eof()) {
return parse_error(
m_lexer.tell(),
DeprecatedString::formatted("Failed to resolve external subset '{}': garbage after declarations", doctype.external_id->system_id.system_literal));
ByteString::formatted("Failed to resolve external subset '{}': garbage after declarations", doctype.external_id->system_id.system_literal));
}
doctype.markup_declarations.extend(move(declarations));
}
@ -681,7 +681,7 @@ ErrorOr<NonnullOwnPtr<Node>, ParseError> Parser::parse_empty_element_tag()
auto accept = accept_rule();
auto name = TRY(parse_name());
HashMap<Name, DeprecatedString> attributes;
HashMap<Name, ByteString> attributes;
while (true) {
if (auto result = skip_whitespace(Required::Yes); result.is_error())
@ -723,7 +723,7 @@ ErrorOr<Attribute, ParseError> Parser::parse_attribute()
}
// 2.3.10. AttValue, https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-AttValue
ErrorOr<DeprecatedString, ParseError> Parser::parse_attribute_value()
ErrorOr<ByteString, ParseError> Parser::parse_attribute_value()
{
auto rollback = rollback_point();
auto rule = enter_rule();
@ -740,7 +740,7 @@ ErrorOr<DeprecatedString, ParseError> Parser::parse_attribute_value()
return text;
}
ErrorOr<DeprecatedString, ParseError> Parser::parse_attribute_value_inner(StringView disallow)
ErrorOr<ByteString, ParseError> Parser::parse_attribute_value_inner(StringView disallow)
{
StringBuilder builder;
while (true) {
@ -754,7 +754,7 @@ ErrorOr<DeprecatedString, ParseError> Parser::parse_attribute_value_inner(String
if (m_lexer.next_is('&')) {
auto reference = TRY(parse_reference());
if (auto* char_reference = reference.get_pointer<DeprecatedString>())
if (auto* char_reference = reference.get_pointer<ByteString>())
builder.append(*char_reference);
else
builder.append(TRY(resolve_reference(reference.get<EntityReference>(), ReferencePlacement::AttributeValue)));
@ -762,14 +762,14 @@ ErrorOr<DeprecatedString, ParseError> Parser::parse_attribute_value_inner(String
builder.append(m_lexer.consume());
}
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
// Char ::= [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
constexpr static auto s_characters = ranges_for_search<Range(0x1, 0xd7ff), Range(0xe000, 0xfffd), Range(0x10000, 0x10ffff)>();
// 4.1.67. Reference, https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-Reference
ErrorOr<Variant<Parser::EntityReference, DeprecatedString>, ParseError> Parser::parse_reference()
ErrorOr<Variant<Parser::EntityReference, ByteString>, ParseError> Parser::parse_reference()
{
auto rollback = rollback_point();
auto rule = enter_rule();
@ -811,7 +811,7 @@ ErrorOr<Variant<Parser::EntityReference, DeprecatedString>, ParseError> Parser::
builder.append_code_point(*code_point);
rollback.disarm();
return builder.to_deprecated_string();
return builder.to_byte_string();
}
auto name = name_result.release_value();
@ -833,7 +833,7 @@ ErrorOr<NonnullOwnPtr<Node>, ParseError> Parser::parse_start_tag()
auto accept = accept_rule();
auto name = TRY(parse_name());
HashMap<Name, DeprecatedString> attributes;
HashMap<Name, ByteString> attributes;
while (true) {
if (auto result = skip_whitespace(Required::Yes); result.is_error())
@ -891,7 +891,7 @@ ErrorOr<void, ParseError> Parser::parse_content()
if (auto result = parse_reference(); !result.is_error()) {
auto reference = result.release_value();
auto reference_offset = m_lexer.offset_for(node_start);
if (auto char_reference = reference.get_pointer<DeprecatedString>())
if (auto char_reference = reference.get_pointer<ByteString>())
append_text(*char_reference, reference_offset);
else
append_text(TRY(resolve_reference(reference.get<EntityReference>(), ReferencePlacement::Content)), reference_offset);
@ -1028,7 +1028,7 @@ ErrorOr<Optional<MarkupDeclaration>, ParseError> Parser::parse_markup_declaratio
}
// 2.8.28a DeclSep, https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-DeclSep
ErrorOr<Optional<DeprecatedString>, ParseError> Parser::parse_declaration_separator()
ErrorOr<Optional<ByteString>, ParseError> Parser::parse_declaration_separator()
{
auto rollback = rollback_point();
auto rule = enter_rule();
@ -1042,7 +1042,7 @@ ErrorOr<Optional<DeprecatedString>, ParseError> Parser::parse_declaration_separa
if (auto result = skip_whitespace(Required::Yes); !result.is_error()) {
rollback.disarm();
return Optional<DeprecatedString> {};
return Optional<ByteString> {};
}
return parse_error(m_lexer.tell(), "Expected either whitespace, or a PEReference");
@ -1178,7 +1178,7 @@ ErrorOr<AttributeListDeclaration::Definition, ParseError> Parser::parse_attribut
TRY(expect(")"sv));
type = AttributeListDeclaration::NotationType { move(names) };
} else {
HashTable<DeprecatedString> names;
HashTable<ByteString> names;
TRY(expect("("sv));
TRY(skip_whitespace());
names.set(TRY(parse_nm_token()));
@ -1463,7 +1463,7 @@ ErrorOr<EntityDeclaration, ParseError> Parser::parse_general_entity_declaration(
{
auto rollback = rollback_point();
auto rule = enter_rule();
Variant<DeprecatedString, EntityDefinition, Empty> definition;
Variant<ByteString, EntityDefinition, Empty> definition;
// GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>'
TRY(expect("<!ENTITY"sv));
@ -1493,7 +1493,7 @@ ErrorOr<EntityDeclaration, ParseError> Parser::parse_general_entity_declaration(
rollback.disarm();
return GEDeclaration {
move(name),
move(definition).downcast<DeprecatedString, EntityDefinition>(),
move(definition).downcast<ByteString, EntityDefinition>(),
};
}
@ -1503,7 +1503,7 @@ ErrorOr<EntityDeclaration, ParseError> Parser::parse_parameter_entity_declaratio
auto rollback = rollback_point();
auto rule = enter_rule();
Variant<DeprecatedString, ExternalID, Empty> definition;
Variant<ByteString, ExternalID, Empty> definition;
// PEDecl ::= '<!ENTITY' S '%' S Name S PEDef S? '>'
TRY(expect("<!ENTITY"sv));
auto accept = accept_rule();
@ -1525,7 +1525,7 @@ ErrorOr<EntityDeclaration, ParseError> Parser::parse_parameter_entity_declaratio
rollback.disarm();
return PEDeclaration {
move(name),
move(definition).downcast<DeprecatedString, ExternalID>(),
move(definition).downcast<ByteString, ExternalID>(),
};
}
@ -1639,7 +1639,7 @@ ErrorOr<Name, ParseError> Parser::parse_notation_data_declaration()
}
// 2.3.9 EntityValue, https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EntityValue
ErrorOr<DeprecatedString, ParseError> Parser::parse_entity_value()
ErrorOr<ByteString, ParseError> Parser::parse_entity_value()
{
auto rollback = rollback_point();
auto rule = enter_rule();
@ -1672,7 +1672,7 @@ ErrorOr<DeprecatedString, ParseError> Parser::parse_entity_value()
TRY(expect(quote));
rollback.disarm();
return builder.to_deprecated_string();
return builder.to_byte_string();
}
// 2.7.18 CDSect, https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-CDSect
@ -1734,11 +1734,11 @@ ErrorOr<void, ParseError> Parser::parse_text_declaration()
return {};
}
ErrorOr<DeprecatedString, ParseError> Parser::resolve_reference(EntityReference const& reference, ReferencePlacement placement)
ErrorOr<ByteString, ParseError> Parser::resolve_reference(EntityReference const& reference, ReferencePlacement placement)
{
static HashTable<Name> reference_lookup {};
if (reference_lookup.contains(reference.name))
return parse_error(m_lexer.tell(), DeprecatedString::formatted("Invalid recursive definition for '{}'", reference.name));
return parse_error(m_lexer.tell(), ByteString::formatted("Invalid recursive definition for '{}'", reference.name));
reference_lookup.set(reference.name);
ScopeGuard remove_lookup {
@ -1747,7 +1747,7 @@ ErrorOr<DeprecatedString, ParseError> Parser::resolve_reference(EntityReference
}
};
Optional<DeprecatedString> resolved;
Optional<ByteString> resolved;
if (m_doctype.has_value()) {
// FIXME: Split these up and resolve them ahead of time.
for (auto& declaration : m_doctype->markup_declarations) {
@ -1760,23 +1760,23 @@ ErrorOr<DeprecatedString, ParseError> Parser::resolve_reference(EntityReference
if (ge_declaration->name != reference.name)
continue;
TRY(ge_declaration->definition.visit(
[&](DeprecatedString const& definition) -> ErrorOr<void, ParseError> {
[&](ByteString const& definition) -> ErrorOr<void, ParseError> {
resolved = definition;
return {};
},
[&](EntityDefinition const& definition) -> ErrorOr<void, ParseError> {
if (placement == ReferencePlacement::AttributeValue)
return parse_error(m_lexer.tell(), DeprecatedString::formatted("Attribute references external entity '{}'", reference.name));
return parse_error(m_lexer.tell(), ByteString::formatted("Attribute references external entity '{}'", reference.name));
if (definition.notation.has_value())
return parse_error(0u, DeprecatedString::formatted("Entity reference to unparsed entity '{}'", reference.name));
return parse_error(0u, ByteString::formatted("Entity reference to unparsed entity '{}'", reference.name));
if (!m_options.resolve_external_resource)
return parse_error(0u, DeprecatedString::formatted("Failed to resolve external entity '{}'", reference.name));
return parse_error(0u, ByteString::formatted("Failed to resolve external entity '{}'", reference.name));
auto result = m_options.resolve_external_resource(definition.id.system_id, definition.id.public_id);
if (result.is_error())
return parse_error(0u, DeprecatedString::formatted("Failed to resolve external entity '{}': {}", reference.name, result.error()));
return parse_error(0u, ByteString::formatted("Failed to resolve external entity '{}': {}", reference.name, result.error()));
resolved = result.release_value();
return {};
@ -1796,7 +1796,7 @@ ErrorOr<DeprecatedString, ParseError> Parser::resolve_reference(EntityReference
return "'";
if (reference.name == "quot")
return "\"";
return parse_error(0u, DeprecatedString::formatted("Reference to undeclared entity '{}'", reference.name));
return parse_error(0u, ByteString::formatted("Reference to undeclared entity '{}'", reference.name));
}
StringView resolved_source = *resolved;