1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:57:35 +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

@ -26,7 +26,7 @@ public:
struct ValueFormat {
Gfx::ColorRole graph_color_role { Gfx::ColorRole::Base };
Color text_shadow_color { Color::Transparent };
Function<DeprecatedString(u64)> text_formatter;
Function<ByteString(u64)> text_formatter;
};
void set_value_format(size_t index, ValueFormat&& format)
{

View file

@ -71,7 +71,7 @@ void MemoryStatsWidget::set_graph_widget(GraphWidget& graph)
m_graph = &graph;
}
void MemoryStatsWidget::set_graph_widget_via_name(DeprecatedString name)
void MemoryStatsWidget::set_graph_widget_via_name(ByteString name)
{
m_graph_widget_name = move(name);
if (!m_graph_widget_name.is_empty()) {
@ -87,7 +87,7 @@ void MemoryStatsWidget::set_graph_widget_via_name(DeprecatedString name)
}
}
DeprecatedString MemoryStatsWidget::graph_widget_name()
ByteString MemoryStatsWidget::graph_widget_name()
{
if (m_graph)
return m_graph->name();

View file

@ -22,8 +22,8 @@ public:
void set_graph_widget(GraphWidget& graph);
void set_graph_widget_via_name(DeprecatedString name);
DeprecatedString graph_widget_name();
void set_graph_widget_via_name(ByteString name);
ByteString graph_widget_name();
void refresh();
@ -33,7 +33,7 @@ private:
GraphWidget* m_graph;
// Is null if we have a valid graph
DeprecatedString m_graph_widget_name {};
ByteString m_graph_widget_name {};
RefPtr<GUI::Label> m_physical_pages_label;
RefPtr<GUI::Label> m_physical_pages_committed_label;
RefPtr<GUI::Label> m_kmalloc_space_label;

View file

@ -48,22 +48,22 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
if (!object.get_bool("link_up"sv).value_or(false))
return *m_network_link_down_bitmap;
else
return object.get_deprecated_string("ipv4_address"sv).value_or("").is_empty() ? *m_network_disconnected_bitmap : *m_network_connected_bitmap;
return object.get_byte_string("ipv4_address"sv).value_or("").is_empty() ? *m_network_disconnected_bitmap : *m_network_connected_bitmap;
});
net_adapters_fields.empend("name", "Name"_string, Gfx::TextAlignment::CenterLeft);
net_adapters_fields.empend("class_name", "Class"_string, Gfx::TextAlignment::CenterLeft);
net_adapters_fields.empend("mac_address", "MAC"_string, Gfx::TextAlignment::CenterLeft);
net_adapters_fields.empend("Link status"_string, Gfx::TextAlignment::CenterLeft,
[](JsonObject const& object) -> DeprecatedString {
[](JsonObject const& object) -> ByteString {
if (!object.get_bool("link_up"sv).value_or(false))
return "Down";
return DeprecatedString::formatted("{} Mb/s {}-duplex", object.get_i32("link_speed"sv).value_or(0),
return ByteString::formatted("{} Mb/s {}-duplex", object.get_i32("link_speed"sv).value_or(0),
object.get_bool("link_full_duplex"sv).value_or(false) ? "full"sv : "half"sv);
});
net_adapters_fields.empend("IPv4"_string, Gfx::TextAlignment::CenterLeft,
[](JsonObject const& object) -> DeprecatedString {
return object.get_deprecated_string("ipv4_address"sv).value_or(""sv);
[](JsonObject const& object) -> ByteString {
return object.get_byte_string("ipv4_address"sv).value_or(""sv);
});
net_adapters_fields.empend("packets_in", "Pkt In"_string, Gfx::TextAlignment::CenterRight);
net_adapters_fields.empend("packets_out", "Pkt Out"_string, Gfx::TextAlignment::CenterRight);

View file

@ -53,7 +53,7 @@ void ProcessFileDescriptorMapWidget::set_pid(pid_t pid)
if (m_pid == pid)
return;
m_pid = pid;
m_model->set_json_path(DeprecatedString::formatted("/proc/{}/fds", m_pid));
m_model->set_json_path(ByteString::formatted("/proc/{}/fds", m_pid));
}
}

View file

@ -25,7 +25,7 @@ public:
virtual void paint(GUI::Painter& painter, Gfx::IntRect const& a_rect, Gfx::Palette const&, const GUI::ModelIndex& index) override
{
auto rect = a_rect.shrunken(2, 2);
auto pagemap = index.data(GUI::ModelRole::Custom).to_deprecated_string();
auto pagemap = index.data(GUI::ModelRole::Custom).to_byte_string();
float scale_factor = (float)pagemap.length() / (float)rect.width();
@ -58,7 +58,7 @@ ErrorOr<NonnullRefPtr<ProcessMemoryMapWidget>> ProcessMemoryMapWidget::try_creat
Vector<GUI::JsonArrayModel::FieldSpec> pid_vm_fields;
TRY(pid_vm_fields.try_empend(
"Address"_string, Gfx::TextAlignment::CenterLeft,
[](auto& object) { return DeprecatedString::formatted("{:p}", object.get_u64("address"sv).value_or(0)); },
[](auto& object) { return ByteString::formatted("{:p}", object.get_u64("address"sv).value_or(0)); },
[](auto& object) { return object.get_u64("address"sv).value_or(0); }));
TRY(pid_vm_fields.try_empend("size", "Size"_string, Gfx::TextAlignment::CenterRight));
TRY(pid_vm_fields.try_empend("amount_resident", "Resident"_string, Gfx::TextAlignment::CenterRight));
@ -77,10 +77,10 @@ ErrorOr<NonnullRefPtr<ProcessMemoryMapWidget>> ProcessMemoryMapWidget::try_creat
builder.append('C');
if (object.get_bool("stack"sv).value_or(false))
builder.append('T');
return builder.to_deprecated_string();
return builder.to_byte_string();
}));
TRY(pid_vm_fields.try_empend("VMObject type"_string, Gfx::TextAlignment::CenterLeft, [](auto& object) {
auto type = object.get_deprecated_string("vmobject"sv).value_or({});
auto type = object.get_byte_string("vmobject"sv).value_or({});
if (type.ends_with("VMObject"sv))
type = type.substring(0, type.length() - 8);
return type;
@ -99,7 +99,7 @@ ErrorOr<NonnullRefPtr<ProcessMemoryMapWidget>> ProcessMemoryMapWidget::try_creat
return GUI::Variant(0);
},
[](JsonObject const& object) {
auto pagemap = object.get_deprecated_string("pagemap"sv).value_or({});
auto pagemap = object.get_byte_string("pagemap"sv).value_or({});
return pagemap;
}));
TRY(pid_vm_fields.try_empend("cow_pages", "# CoW"_string, Gfx::TextAlignment::CenterRight));
@ -121,7 +121,7 @@ void ProcessMemoryMapWidget::set_pid(pid_t pid)
if (m_pid == pid)
return;
m_pid = pid;
m_json_model->set_json_path(DeprecatedString::formatted("/proc/{}/vm", pid));
m_json_model->set_json_path(ByteString::formatted("/proc/{}/vm", pid));
}
void ProcessMemoryMapWidget::refresh()

View file

@ -288,12 +288,12 @@ GUI::Variant ProcessModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
case Column::PurgeableNonvolatile:
return human_readable_size(thread.current_state.amount_purgeable_nonvolatile);
case Column::CPU:
return DeprecatedString::formatted("{:.2}", thread.current_state.cpu_percent);
return ByteString::formatted("{:.2}", thread.current_state.cpu_percent);
case Column::Processor:
return thread.current_state.cpu;
case Column::Name:
if (thread.current_state.kernel)
return DeprecatedString::formatted("{} (*)", thread.current_state.name);
return ByteString::formatted("{} (*)", thread.current_state.name);
return thread.current_state.name;
case Column::Command:
return thread.current_state.command.visit([](String const& cmdline) { return cmdline; }, [](auto const&) { return ""_string; });

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/Vector.h>
#include <LibGUI/Icon.h>
@ -110,14 +110,14 @@ private:
u64 time_user { 0 };
u64 time_kernel { 0 };
bool kernel { false };
DeprecatedString executable { "" };
DeprecatedString name { "" };
ByteString executable { "" };
ByteString name { "" };
Variant<String, EmptyCommand> command { EmptyCommand::NotInitialized };
uid_t uid { 0 };
DeprecatedString state { "" };
DeprecatedString user { "" };
DeprecatedString pledge { "" };
DeprecatedString veil { "" };
ByteString state { "" };
ByteString user { "" };
ByteString pledge { "" };
ByteString veil { "" };
u32 cpu { 0 };
u32 priority { 0 };
size_t amount_virtual { 0 };

View file

@ -36,7 +36,7 @@ void ProcessUnveiledPathsWidget::set_pid(pid_t pid)
if (m_pid == pid)
return;
m_pid = pid;
m_model->set_json_path(DeprecatedString::formatted("/proc/{}/unveil", m_pid));
m_model->set_json_path(ByteString::formatted("/proc/{}/unveil", m_pid));
}
}

View file

@ -49,7 +49,7 @@ public:
auto& symbol = m_symbols[model_index.row()];
switch (model_index.column()) {
case Column::Address:
return DeprecatedString::formatted("{:p}", symbol.address);
return ByteString::formatted("{:p}", symbol.address);
case Column::Object:
return symbol.object;
case Column::Symbol:

View file

@ -75,7 +75,7 @@ public:
auto percentage = index.data(GUI::ModelRole::Custom).to_i32();
auto data = index.data();
DeprecatedString text;
ByteString text;
if (data.is_string())
text = data.as_string();
Gfx::StylePainter::paint_progressbar(painter, rect, palette, 0, 100, percentage, text);
@ -133,7 +133,7 @@ public:
size_builder.append(' ');
size_builder.append(human_readable_size(object.get_u64("total_block_count"sv).value_or(0) * object.get_u64("block_size"sv).value_or(0)));
size_builder.append(' ');
return size_builder.to_deprecated_string();
return size_builder.to_byte_string();
},
[](JsonObject const& object) {
return object.get_u64("total_block_count"sv).value_or(0) * object.get_u64("block_size"sv).value_or(0);
@ -194,8 +194,8 @@ public:
check(MS_AXALLOWED, "axallowed"sv);
check(MS_NOREGULAR, "noregular"sv);
if (builder.string_view().is_empty())
return DeprecatedString("defaults");
return builder.to_deprecated_string();
return ByteString("defaults");
return builder.to_byte_string();
});
df_fields.empend("free_block_count", "Free blocks"_string, Gfx::TextAlignment::CenterRight);
df_fields.empend("total_block_count", "Total blocks"_string, Gfx::TextAlignment::CenterRight);
@ -342,11 +342,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return pid_index.data().to_i32();
};
auto selected_name = [&](ProcessModel::Column column) -> DeprecatedString {
auto selected_name = [&](ProcessModel::Column column) -> ByteString {
if (process_table_view.selection().is_empty())
return {};
auto pid_index = process_table_view.model()->index(process_table_view.selection().first().row(), column, process_table_view.selection().first().parent());
return pid_index.data().to_deprecated_string();
return pid_index.data().to_byte_string();
};
auto kill_action = GUI::Action::create(
@ -354,7 +354,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
pid_t pid = selected_id(ProcessModel::Column::PID);
if (pid == -1)
return;
auto rc = GUI::MessageBox::show(window, DeprecatedString::formatted("Do you really want to kill \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
auto rc = GUI::MessageBox::show(window, ByteString::formatted("Do you really want to kill \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
if (rc == GUI::Dialog::ExecResult::Yes)
kill(pid, SIGKILL);
},
@ -365,7 +365,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
pid_t pid = selected_id(ProcessModel::Column::PID);
if (pid == -1)
return;
auto rc = GUI::MessageBox::show(window, DeprecatedString::formatted("Do you really want to stop \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
auto rc = GUI::MessageBox::show(window, ByteString::formatted("Do you really want to stop \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
if (rc == GUI::Dialog::ExecResult::Yes)
kill(pid, SIGSTOP);
},
@ -385,7 +385,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
pid_t pid = selected_id(ProcessModel::Column::PID);
if (pid == -1)
return;
auto pid_string = DeprecatedString::number(pid);
auto pid_string = ByteString::number(pid);
GUI::Process::spawn_or_show_error(window, "/bin/Profiler"sv, Array { "--pid", pid_string.characters() });
},
&process_table_view);
@ -395,7 +395,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
pid_t pid = selected_id(ProcessModel::Column::PID);
if (pid == -1)
return;
auto pid_string = DeprecatedString::number(pid);
auto pid_string = ByteString::number(pid);
GUI::Process::spawn_or_show_error(window, "/bin/HackStudio"sv, Array { "--pid", pid_string.characters() });
},
&process_table_view);
@ -452,7 +452,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
frequency_action_group.set_exclusive(true);
auto make_frequency_action = [&](int seconds) -> ErrorOr<void> {
auto action = GUI::Action::create_checkable(DeprecatedString::formatted("&{} Sec", seconds), [&refresh_timer, seconds](auto&) {
auto action = GUI::Action::create_checkable(ByteString::formatted("&{} Sec", seconds), [&refresh_timer, seconds](auto&) {
Config::write_i32("SystemMonitor"sv, "Monitor"sv, "Frequency"sv, seconds);
refresh_timer.restart(seconds * 1000);
});
@ -526,7 +526,7 @@ ErrorOr<NonnullRefPtr<GUI::Window>> build_process_window(pid_t pid)
{
auto window = GUI::Window::construct();
window->resize(480, 360);
window->set_title(DeprecatedString::formatted("PID {} - System Monitor", pid));
window->set_title(ByteString::formatted("PID {} - System Monitor", pid));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-system-monitor"sv));
window->set_icon(app_icon.bitmap_for_size(16));
@ -548,7 +548,7 @@ ErrorOr<NonnullRefPtr<GUI::Window>> build_process_window(pid_t pid)
main_widget->find_descendant_of_type_named<GUI::ImageWidget>("process_icon")->set_bitmap(icon_data.as_icon().bitmap_for_size(32));
}
main_widget->find_descendant_of_type_named<GUI::Label>("process_name")->set_text(TRY(String::formatted("{} (PID {})", process_index.sibling_at_column(ProcessModel::Column::Name).data().to_deprecated_string(), pid)));
main_widget->find_descendant_of_type_named<GUI::Label>("process_name")->set_text(TRY(String::formatted("{} (PID {})", process_index.sibling_at_column(ProcessModel::Column::Name).data().to_byte_string(), pid)));
main_widget->find_descendant_of_type_named<SystemMonitor::ProcessStateWidget>("process_state")->set_pid(pid);
main_widget->find_descendant_of_type_named<SystemMonitor::ProcessFileDescriptorMapWidget>("open_files")->set_pid(pid);
@ -587,13 +587,13 @@ ErrorOr<void> build_performance_tab(GUI::Widget& graphs_container)
cpu_graph.set_value_format(0, {
.graph_color_role = ColorRole::SyntaxPreprocessorStatement,
.text_formatter = [](u64 value) {
return DeprecatedString::formatted("Total: {}%", value);
return ByteString::formatted("Total: {}%", value);
},
});
cpu_graph.set_value_format(1, {
.graph_color_role = ColorRole::SyntaxPreprocessorValue,
.text_formatter = [](u64 value) {
return DeprecatedString::formatted("Kernel: {}%", value);
return ByteString::formatted("Kernel: {}%", value);
},
});
cpu_graphs.append(cpu_graph);
@ -613,19 +613,19 @@ ErrorOr<void> build_performance_tab(GUI::Widget& graphs_container)
memory_graph.set_value_format(0, {
.graph_color_role = ColorRole::SyntaxComment,
.text_formatter = [](u64 bytes) {
return DeprecatedString::formatted("Committed: {}", human_readable_size(bytes));
return ByteString::formatted("Committed: {}", human_readable_size(bytes));
},
});
memory_graph.set_value_format(1, {
.graph_color_role = ColorRole::SyntaxPreprocessorStatement,
.text_formatter = [](u64 bytes) {
return DeprecatedString::formatted("Allocated: {}", human_readable_size(bytes));
return ByteString::formatted("Allocated: {}", human_readable_size(bytes));
},
});
memory_graph.set_value_format(2, {
.graph_color_role = ColorRole::SyntaxPreprocessorValue,
.text_formatter = [](u64 bytes) {
return DeprecatedString::formatted("Kernel heap: {}", human_readable_size(bytes));
return ByteString::formatted("Kernel heap: {}", human_readable_size(bytes));
},
});
return {};