1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +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

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Format.h>
#include <AK/LexicalPath.h>
#include <AK/QuickSort.h>
@ -25,18 +25,18 @@ enum class ComponentCategory {
};
struct ComponentData {
DeprecatedString name;
DeprecatedString description;
ByteString name;
ByteString description;
ComponentCategory category { ComponentCategory::Optional };
bool was_selected { false };
Vector<DeprecatedString> dependencies;
Vector<ByteString> dependencies;
bool is_selected { false };
};
struct WhiptailOption {
DeprecatedString tag;
DeprecatedString name;
DeprecatedString description;
ByteString tag;
ByteString name;
ByteString description;
bool checked { false };
};
@ -77,7 +77,7 @@ static Vector<ComponentData> read_component_data(Core::ConfigFile const& config_
return components;
}
static Result<Vector<DeprecatedString>, int> run_whiptail(WhiptailMode mode, Vector<WhiptailOption> const& options, StringView title, StringView description)
static Result<Vector<ByteString>, int> run_whiptail(WhiptailMode mode, Vector<WhiptailOption> const& options, StringView title, StringView description)
{
struct winsize w;
if (ioctl(0, TIOCGWINSZ, &w) < 0) {
@ -97,7 +97,7 @@ static Result<Vector<DeprecatedString>, int> run_whiptail(WhiptailMode mode, Vec
int read_fd = pipefd[0];
int write_fd = pipefd[1];
Vector<DeprecatedString> arguments = { "whiptail", "--notags", "--separate-output", "--output-fd", DeprecatedString::number(write_fd) };
Vector<ByteString> arguments = { "whiptail", "--notags", "--separate-output", "--output-fd", ByteString::number(write_fd) };
if (!title.is_empty()) {
arguments.append("--title");
@ -116,13 +116,13 @@ static Result<Vector<DeprecatedString>, int> run_whiptail(WhiptailMode mode, Vec
}
if (description.is_empty())
arguments.append(DeprecatedString::empty());
arguments.append(ByteString::empty());
else
arguments.append(DeprecatedString::formatted("\n {}", description));
arguments.append(ByteString::formatted("\n {}", description));
arguments.append(DeprecatedString::number(height));
arguments.append(DeprecatedString::number(width));
arguments.append(DeprecatedString::number(height - 9));
arguments.append(ByteString::number(height));
arguments.append(ByteString::number(width));
arguments.append(ByteString::number(height - 9));
// Check how wide the name field needs to be.
size_t max_name_width = 0;
@ -133,7 +133,7 @@ static Result<Vector<DeprecatedString>, int> run_whiptail(WhiptailMode mode, Vec
for (auto& option : options) {
arguments.append(option.tag);
arguments.append(DeprecatedString::formatted("{:{2}} {}", option.name, option.description, max_name_width));
arguments.append(ByteString::formatted("{:{2}} {}", option.name, option.description, max_name_width));
if (mode == WhiptailMode::Checklist)
arguments.append(option.checked ? "1" : "0");
}
@ -151,7 +151,7 @@ static Result<Vector<DeprecatedString>, int> run_whiptail(WhiptailMode mode, Vec
return -1;
}
auto full_term_variable = DeprecatedString::formatted("TERM={}", term_variable);
auto full_term_variable = ByteString::formatted("TERM={}", term_variable);
auto colors = "NEWT_COLORS=root=,black\ncheckbox=black,lightgray";
char* env[3];
@ -202,10 +202,10 @@ static Result<Vector<DeprecatedString>, int> run_whiptail(WhiptailMode mode, Vec
warnln("\e[31mError:\e[0m Could not read data from file descriptor: {}", data_or_error.error());
return -1;
}
return DeprecatedString::copy(data_or_error.value()).split('\n');
return ByteString::copy(data_or_error.value()).split('\n');
}
static bool run_system_command(DeprecatedString const& command, StringView command_name)
static bool run_system_command(ByteString const& command, StringView command_name)
{
if (command.starts_with("cmake"sv))
warnln("\e[34mRunning CMake...\e[0m");
@ -234,7 +234,7 @@ int main()
auto current_working_directory = FileSystem::current_working_directory();
if (current_working_directory.is_error())
return 1;
auto lexical_cwd = LexicalPath(current_working_directory.release_value().to_deprecated_string());
auto lexical_cwd = LexicalPath(current_working_directory.release_value().to_byte_string());
auto& parts = lexical_cwd.parts_view();
if (parts.size() < 2 || parts[parts.size() - 2] != "Build") {
warnln("\e[31mError:\e[0m This program needs to be executed from inside 'Build/*'.");
@ -281,7 +281,7 @@ int main()
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.
Vector<DeprecatedString> activated_components;
Vector<ByteString> activated_components;
if (customize) {
Vector<WhiptailOption> options;
@ -297,7 +297,7 @@ int main()
}
// NOTE: Required components will always be preselected.
WhiptailOption option { component.name, component.name, description_builder.to_deprecated_string(), is_required };
WhiptailOption option { component.name, component.name, description_builder.to_byte_string(), is_required };
if (build_type == "REQUIRED") {
// noop
} else if (build_type == "RECOMMENDED") {
@ -343,13 +343,13 @@ int main()
}
// Step 5: Generate the cmake command.
Vector<DeprecatedString> cmake_arguments = { "cmake", "../..", "-G", "Ninja", "-DBUILD_EVERYTHING=OFF" };
Vector<ByteString> cmake_arguments = { "cmake", "../..", "-G", "Ninja", "-DBUILD_EVERYTHING=OFF" };
for (auto& component : components)
cmake_arguments.append(DeprecatedString::formatted("-DBUILD_{}={}", component.name.to_uppercase(), component.is_selected ? "ON" : "OFF"));
cmake_arguments.append(ByteString::formatted("-DBUILD_{}={}", component.name.to_uppercase(), component.is_selected ? "ON" : "OFF"));
warnln("\e[34mThe following command will be run:\e[0m");
outln("ninja clean \\\n && rm -rf Root \\");
outln(" && {}", DeprecatedString::join(' ', cmake_arguments));
outln(" && {}", ByteString::join(' ', cmake_arguments));
warn("\e[34mDo you want to run the command?\e[0m [Y/n] ");
auto character = getchar();
if (character == 'n' || character == 'N') {
@ -358,7 +358,7 @@ int main()
}
// Step 6: Run 'ninja clean', 'rm -rf Root' and CMake
auto command = DeprecatedString::join(' ', cmake_arguments);
auto command = ByteString::join(' ', cmake_arguments);
if (!run_system_command("ninja clean"sv, "Ninja"sv))
return 1;
if (!run_system_command("rm -rf Root"sv, "rm"sv))