mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48: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:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/SourceGenerator.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
|
@ -15,11 +15,11 @@
|
|||
#include <LibMain/Main.h>
|
||||
|
||||
static ErrorOr<void> add_to_interface_sets(IDL::Interface&, Vector<IDL::Interface&>& intrinsics, Vector<IDL::Interface&>& window_exposed, Vector<IDL::Interface&>& dedicated_worker_exposed, Vector<IDL::Interface&>& shared_worker_exposed);
|
||||
static DeprecatedString s_error_string;
|
||||
static ByteString s_error_string;
|
||||
|
||||
struct LegacyConstructor {
|
||||
DeprecatedString name;
|
||||
DeprecatedString constructor_class;
|
||||
ByteString name;
|
||||
ByteString constructor_class;
|
||||
};
|
||||
|
||||
static void consume_whitespace(GenericLexer& lexer)
|
||||
|
@ -52,7 +52,7 @@ static Optional<LegacyConstructor> const& lookup_legacy_constructor(IDL::Interfa
|
|||
consume_whitespace(function_lexer);
|
||||
|
||||
auto name = function_lexer.consume_until([](auto ch) { return is_ascii_space(ch) || ch == '('; });
|
||||
auto constructor_class = DeprecatedString::formatted("{}Constructor", name);
|
||||
auto constructor_class = ByteString::formatted("{}Constructor", name);
|
||||
|
||||
s_legacy_constructors.set(interface.name, LegacyConstructor { name, move(constructor_class) });
|
||||
return s_legacy_constructors.get(interface.name).value();
|
||||
|
@ -264,7 +264,7 @@ static ErrorOr<void> generate_exposed_interface_header(StringView class_name, St
|
|||
StringBuilder builder;
|
||||
SourceGenerator generator(builder);
|
||||
|
||||
generator.set("global_object_snake_name", DeprecatedString(class_name).to_snakecase());
|
||||
generator.set("global_object_snake_name", ByteString(class_name).to_snakecase());
|
||||
generator.append(R"~~~(
|
||||
#pragma once
|
||||
|
||||
|
@ -278,7 +278,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object&);
|
|||
|
||||
)~~~");
|
||||
|
||||
auto generated_header_path = LexicalPath(output_path).append(DeprecatedString::formatted("{}ExposedInterfaces.h", class_name)).string();
|
||||
auto generated_header_path = LexicalPath(output_path).append(ByteString::formatted("{}ExposedInterfaces.h", class_name)).string();
|
||||
auto generated_header_file = TRY(Core::File::open(generated_header_path, Core::File::OpenMode::Write));
|
||||
TRY(generated_header_file->write_until_depleted(generator.as_string_view().bytes()));
|
||||
|
||||
|
@ -291,7 +291,7 @@ static ErrorOr<void> generate_exposed_interface_implementation(StringView class_
|
|||
SourceGenerator generator(builder);
|
||||
|
||||
generator.set("global_object_name", class_name);
|
||||
generator.set("global_object_snake_name", DeprecatedString(class_name).to_snakecase());
|
||||
generator.set("global_object_snake_name", ByteString(class_name).to_snakecase());
|
||||
|
||||
generator.append(R"~~~(
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
@ -366,7 +366,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global)
|
|||
}
|
||||
)~~~");
|
||||
|
||||
auto generated_implementation_path = LexicalPath(output_path).append(DeprecatedString::formatted("{}ExposedInterfaces.cpp", class_name)).string();
|
||||
auto generated_implementation_path = LexicalPath(output_path).append(ByteString::formatted("{}ExposedInterfaces.cpp", class_name)).string();
|
||||
auto generated_implementation_file = TRY(Core::File::open(generated_implementation_path, Core::File::OpenMode::Write));
|
||||
TRY(generated_implementation_file->write_until_depleted(generator.as_string_view().bytes()));
|
||||
|
||||
|
@ -379,7 +379,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
StringView output_path;
|
||||
StringView base_path;
|
||||
Vector<DeprecatedString> paths;
|
||||
Vector<ByteString> paths;
|
||||
|
||||
args_parser.add_option(output_path, "Path to output generated files into", "output-path", 'o', "output-path");
|
||||
args_parser.add_option(base_path, "Path to root of IDL file tree", "base-path", 'b', "base-path");
|
||||
|
@ -392,16 +392,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
const LexicalPath lexical_base(base_path);
|
||||
|
||||
// Read in all IDL files, we must own the storage for all of these for the lifetime of the program
|
||||
Vector<DeprecatedString> file_contents;
|
||||
for (DeprecatedString const& path : paths) {
|
||||
Vector<ByteString> file_contents;
|
||||
for (ByteString const& path : paths) {
|
||||
auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
s_error_string = DeprecatedString::formatted("Unable to open file {}", path);
|
||||
s_error_string = ByteString::formatted("Unable to open file {}", path);
|
||||
return Error::from_string_view(s_error_string.view());
|
||||
}
|
||||
auto file = file_or_error.release_value();
|
||||
auto string = MUST(file->read_until_eof());
|
||||
file_contents.append(DeprecatedString(ReadonlyBytes(string)));
|
||||
file_contents.append(ByteString(ReadonlyBytes(string)));
|
||||
}
|
||||
VERIFY(paths.size() == file_contents.size());
|
||||
|
||||
|
@ -453,7 +453,7 @@ static ErrorOr<ExposedTo> parse_exposure_set(IDL::Interface& interface)
|
|||
|
||||
auto maybe_exposed = interface.extended_attributes.get("Exposed");
|
||||
if (!maybe_exposed.has_value()) {
|
||||
s_error_string = DeprecatedString::formatted("Interface {} is missing extended attribute Exposed", interface.name);
|
||||
s_error_string = ByteString::formatted("Interface {} is missing extended attribute Exposed", interface.name);
|
||||
return Error::from_string_view(s_error_string.view());
|
||||
}
|
||||
auto exposed = maybe_exposed.value().trim_whitespace();
|
||||
|
@ -485,18 +485,18 @@ static ErrorOr<ExposedTo> parse_exposure_set(IDL::Interface& interface)
|
|||
} else if (candidate == "AudioWorklet"sv) {
|
||||
whom |= ExposedTo::AudioWorklet;
|
||||
} else {
|
||||
s_error_string = DeprecatedString::formatted("Unknown Exposed attribute candidate {} in {} in {}", candidate, exposed, interface.name);
|
||||
s_error_string = ByteString::formatted("Unknown Exposed attribute candidate {} in {} in {}", candidate, exposed, interface.name);
|
||||
return Error::from_string_view(s_error_string.view());
|
||||
}
|
||||
}
|
||||
if (whom == ExposedTo::Nobody) {
|
||||
s_error_string = DeprecatedString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name);
|
||||
s_error_string = ByteString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name);
|
||||
return Error::from_string_view(s_error_string.view());
|
||||
}
|
||||
return whom;
|
||||
}
|
||||
|
||||
s_error_string = DeprecatedString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name);
|
||||
s_error_string = ByteString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name);
|
||||
return Error::from_string_view(s_error_string.view());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue