1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 15:07:44 +00:00

Everywhere: Rename to_{string => deprecated_string}() where applicable

This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
This commit is contained in:
Linus Groh 2022-12-06 01:12:49 +00:00 committed by Andreas Kling
parent 6e19ab2bbc
commit 57dc179b1f
597 changed files with 1973 additions and 1972 deletions

View file

@ -49,7 +49,7 @@ UnregisteredWidget::UnregisteredWidget(DeprecatedString const& class_name)
StringBuilder builder;
builder.append(class_name);
builder.append("\nnot registered"sv);
m_text = builder.to_string();
m_text = builder.to_deprecated_string();
}
void UnregisteredWidget::paint_event(GUI::PaintEvent& event)
@ -116,7 +116,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
builder.append("[*]"sv);
builder.append(" - GML Playground"sv);
window->set_title(builder.to_string());
window->set_title(builder.to_deprecated_string());
};
editor->on_change = [&] {

View file

@ -60,7 +60,7 @@ DisassemblyModel::DisassemblyModel(Debug::DebugSession const& debug_session, Ptr
if (!insn.has_value())
break;
FlatPtr address_in_profiled_program = symbol.value().value() + offset_into_symbol;
auto disassembly = insn.value().to_string(address_in_profiled_program, &symbol_provider);
auto disassembly = insn.value().to_deprecated_string(address_in_profiled_program, &symbol_provider);
StringView instruction_bytes = view.substring_view(offset_into_symbol, insn.value().length());
m_instructions.append({ insn.value(), disassembly, instruction_bytes, address_in_profiled_program });
@ -99,7 +99,7 @@ GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole
StringBuilder builder;
for (auto ch : insn.bytes)
builder.appendff("{:02x} ", static_cast<unsigned char>(ch));
return builder.to_string();
return builder.to_deprecated_string();
}
if (index.column() == Column::Disassembly)
return insn.disassembly;

View file

@ -117,7 +117,7 @@ void EditorWrapper::update_title()
if (editor().document().is_modified())
title.append(" (*)"sv);
m_filename_title = title.to_string();
m_filename_title = title.to_deprecated_string();
}
void EditorWrapper::set_debug_mode(bool enabled)

View file

@ -105,7 +105,7 @@ static RefPtr<SearchResultsModel> find_in_files(StringView text)
builder.append(file.document().text_in_range(range));
builder.append(0x02);
builder.append(right_part);
matches.append({ file.name(), range, builder.to_string() });
matches.append({ file.name(), range, builder.to_deprecated_string() });
}
});

View file

@ -54,7 +54,7 @@ void GitFilesView::mousedown_event(GUI::MouseEvent& event)
auto data = model()->index(item_index, model_column()).data();
VERIFY(data.is_string());
m_action_callback(data.to_string());
m_action_callback(data.to_deprecated_string());
}
};

View file

@ -279,7 +279,7 @@ void HackStudioWidget::open_project(DeprecatedString const& root_path)
if (recent_projects.size() > recent_projects_history_size)
recent_projects.shrink(recent_projects_history_size);
Config::write_string("HackStudio"sv, "Global"sv, "RecentProjects"sv, JsonArray(recent_projects).to_string());
Config::write_string("HackStudio"sv, "Global"sv, "RecentProjects"sv, JsonArray(recent_projects).to_deprecated_string());
update_recent_projects_submenu();
}
@ -1088,7 +1088,7 @@ DeprecatedString HackStudioWidget::get_full_path_of_serenity_source(DeprecatedSt
relative_path_builder.join('/', path_parts);
constexpr char SERENITY_LIBS_PREFIX[] = "/usr/src/serenity";
LexicalPath serenity_sources_base(SERENITY_LIBS_PREFIX);
return DeprecatedString::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_string());
return DeprecatedString::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_deprecated_string());
}
DeprecatedString HackStudioWidget::get_absolute_path(DeprecatedString const& path) const
@ -1246,7 +1246,7 @@ void HackStudioWidget::create_open_files_view(GUI::Widget& parent)
m_open_files_view->set_model(open_files_model);
m_open_files_view->on_activation = [this](auto& index) {
open_file(index.data().to_string());
open_file(index.data().to_deprecated_string());
};
}
@ -1559,7 +1559,7 @@ void HackStudioWidget::update_statusbar()
builder.appendff("Selected: {} {} ({} {})", selected_text.length(), selected_text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
}
m_statusbar->set_text(0, builder.to_string());
m_statusbar->set_text(0, builder.to_deprecated_string());
m_statusbar->set_text(1, current_editor_wrapper().editor().code_document().language_name());
m_statusbar->set_text(2, DeprecatedString::formatted("Ln {}, Col {}", current_editor().cursor().line() + 1, current_editor().cursor().column()));
}

View file

@ -176,7 +176,7 @@ DeprecatedString ProjectBuilder::generate_cmake_file_content() const
builder.appendff("target_link_libraries({} INTERFACE {})\n", library.key, DeprecatedString::join(' ', library.value->dependencies));
}
return builder.to_string();
return builder.to_deprecated_string();
}
HashMap<DeprecatedString, NonnullOwnPtr<ProjectBuilder::LibraryInfo>> ProjectBuilder::get_defined_libraries()

View file

@ -129,7 +129,7 @@ static void update_path_environment_variable()
if (path.length())
path.append(':');
path.append(DEFAULT_PATH_SV);
setenv("PATH", path.to_string().characters(), true);
setenv("PATH", path.to_deprecated_string().characters(), true);
}
static Optional<DeprecatedString> last_opened_project_path()

View file

@ -53,7 +53,7 @@ GUI::Variant RemoteObjectPropertyModel::data(const GUI::ModelIndex& index, GUI::
if (role == GUI::ModelRole::Display) {
switch (index.column()) {
case Column::Name:
return path->last().to_string();
return path->last().to_deprecated_string();
case Column::Value: {
auto data = path->resolve(m_object.json);
if (data.is_array())
@ -77,7 +77,7 @@ void RemoteObjectPropertyModel::set_data(const GUI::ModelIndex& index, const GUI
return;
FlatPtr address = m_object.address;
RemoteProcess::the().set_property(address, path->first().to_string(), new_value.to_string());
RemoteProcess::the().set_property(address, path->first().to_deprecated_string(), new_value.to_deprecated_string());
did_update();
}
@ -164,7 +164,7 @@ GUI::ModelIndex RemoteObjectPropertyModel::parent_index(const GUI::ModelIndex& i
return create_index(index_in_parent, 0, cpath);
}
dbgln("No cached path found for path {}", path.to_string());
dbgln("No cached path found for path {}", path.to_deprecated_string());
return {};
}

View file

@ -53,8 +53,8 @@ void RemoteProcess::handle_get_all_objects_response(JsonObject const& response)
auto remote_object = make<RemoteObject>();
remote_object->address = object.get("address"sv).to_number<FlatPtr>();
remote_object->parent_address = object.get("parent"sv).to_number<FlatPtr>();
remote_object->name = object.get("name"sv).to_string();
remote_object->class_name = object.get("class_name"sv).to_string();
remote_object->name = object.get("name"sv).to_deprecated_string();
remote_object->class_name = object.get("class_name"sv).to_deprecated_string();
remote_object->json = object;
objects_by_address.set(remote_object->address, remote_object);
remote_objects.append(move(remote_object));
@ -84,7 +84,7 @@ void RemoteProcess::set_inspected_object(FlatPtr address)
void RemoteProcess::set_property(FlatPtr object, StringView name, JsonValue const& value)
{
m_client->async_set_object_property(m_pid, object, name, value.to_string());
m_client->async_set_object_property(m_pid, object, name, value.to_deprecated_string());
}
bool RemoteProcess::is_inspectable()

View file

@ -132,10 +132,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto copy_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"sv).release_value_but_fixme_should_propagate_errors();
auto copy_property_name_action = GUI::Action::create("Copy Property Name", copy_bitmap, [&](auto&) {
GUI::Clipboard::the().set_plain_text(properties_tree_view.selection().first().data().to_string());
GUI::Clipboard::the().set_plain_text(properties_tree_view.selection().first().data().to_deprecated_string());
});
auto copy_property_value_action = GUI::Action::create("Copy Property Value", copy_bitmap, [&](auto&) {
GUI::Clipboard::the().set_plain_text(properties_tree_view.selection().first().sibling_at_column(1).data().to_string());
GUI::Clipboard::the().set_plain_text(properties_tree_view.selection().first().sibling_at_column(1).data().to_deprecated_string());
});
properties_tree_view_context_menu->add_action(copy_property_name_action);

View file

@ -111,7 +111,7 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node)
break;
FlatPtr address_in_profiled_program = node.address() + offset_into_symbol;
auto disassembly = insn.value().to_string(address_in_profiled_program, &symbol_provider);
auto disassembly = insn.value().to_deprecated_string(address_in_profiled_program, &symbol_provider);
StringView instruction_bytes = view.substring_view(offset_into_symbol, insn.value().length());
u32 samples_at_this_instruction = m_node.events_per_address().get(address_in_profiled_program).value_or(0);
@ -199,7 +199,7 @@ GUI::Variant DisassemblyModel::data(GUI::ModelIndex const& index, GUI::ModelRole
for (auto ch : insn.bytes) {
builder.appendff("{:02x} ", (u8)ch);
}
return builder.to_string();
return builder.to_deprecated_string();
}
if (index.column() == Column::Disassembly)

View file

@ -36,7 +36,7 @@ FileEventNode& FileEventNode::find_or_create_node(DeprecatedString const& search
StringBuilder sb;
sb.join('/', parts);
auto new_s = sb.to_string();
auto new_s = sb.to_deprecated_string();
for (auto& child : m_children) {
if (child->m_path == current) {
@ -77,7 +77,7 @@ FileEventNode& FileEventNode::create_recursively(DeprecatedString new_path)
StringBuilder sb;
sb.join('/', parts);
return new_node->create_recursively(sb.to_string());
return new_node->create_recursively(sb.to_deprecated_string());
}
}

View file

@ -180,7 +180,7 @@ DeprecatedString FlameGraphView::bar_label(StackBar const& bar) const
auto label_index = bar.index.sibling_at_column(m_text_column);
DeprecatedString label = "All";
if (label_index.is_valid()) {
label = m_model.data(label_index).to_string();
label = m_model.data(label_index).to_deprecated_string();
}
return label;
}

View file

@ -89,7 +89,7 @@ void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, DeprecatedString co
entry.base = min(entry.base, base);
entry.size = max(entry.size + size, base - entry.base + size);
} else {
DeprecatedString path_string = path.to_string();
DeprecatedString path_string = path.to_deprecated_string();
DeprecatedString full_path;
if (path_string.starts_with('/'))
full_path = path_string;

View file

@ -260,7 +260,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
HashMap<FlatPtr, DeprecatedString> profile_strings;
for (FlatPtr string_id = 0; string_id < strings_value->as_array().size(); ++string_id) {
auto const& value = strings_value->as_array().at(string_id);
profile_strings.set(string_id, value.to_string());
profile_strings.set(string_id, value.to_deprecated_string());
}
auto const* events_value = object.get_ptr("events"sv);
@ -286,7 +286,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
event.pid = perf_event.get("pid"sv).to_i32();
event.tid = perf_event.get("tid"sv).to_i32();
auto type_string = perf_event.get("type"sv).to_string();
auto type_string = perf_event.get("type"sv).to_deprecated_string();
if (type_string == "sample"sv) {
event.data = Event::SampleData {};
@ -308,7 +308,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
} else if (type_string == "mmap"sv) {
auto ptr = perf_event.get("ptr"sv).to_number<FlatPtr>();
auto size = perf_event.get("size"sv).to_number<size_t>();
auto name = perf_event.get("name"sv).to_string();
auto name = perf_event.get("name"sv).to_deprecated_string();
event.data = Event::MmapData {
.ptr = ptr,
@ -328,7 +328,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
continue;
} else if (type_string == "process_create"sv) {
auto parent_pid = perf_event.get("parent_pid"sv).to_number<pid_t>();
auto executable = perf_event.get("executable"sv).to_string();
auto executable = perf_event.get("executable"sv).to_deprecated_string();
event.data = Event::ProcessCreateData {
.parent_pid = parent_pid,
.executable = executable,
@ -346,7 +346,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
all_processes.append(move(sampled_process));
continue;
} else if (type_string == "process_exec"sv) {
auto executable = perf_event.get("executable"sv).to_string();
auto executable = perf_event.get("executable"sv).to_deprecated_string();
event.data = Event::ProcessExecData {
.executable = executable,
};

View file

@ -237,7 +237,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto flamegraph_hovered_index = flamegraph_view->hovered_index();
if (flamegraph_hovered_index.is_valid()) {
auto stack = profile->model().data(flamegraph_hovered_index.sibling_at_column(ProfileModel::Column::StackFrame)).to_string();
auto stack = profile->model().data(flamegraph_hovered_index.sibling_at_column(ProfileModel::Column::StackFrame)).to_deprecated_string();
auto sample_count = profile->model().data(flamegraph_hovered_index.sibling_at_column(ProfileModel::Column::SampleCount));
auto self_count = profile->model().data(flamegraph_hovered_index.sibling_at_column(ProfileModel::Column::SelfCount));
builder.appendff("{}, ", stack);
@ -255,7 +255,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
builder.appendff(", Duration: {} ms", end - start);
}
}
statusbar->set_text(builder.to_string());
statusbar->set_text(builder.to_deprecated_string());
};
timeline_view->on_selection_change = [&] { statusbar_update(); };
flamegraph_view->on_hover_change = [&] { statusbar_update(); };

View file

@ -478,10 +478,10 @@ DeprecatedString MainWidget::read_next_sql_statement_of_editor()
m_editor_line_level = last_token_ended_statement ? 0 : (m_editor_line_level > 0 ? m_editor_line_level : 1);
} while ((m_editor_line_level > 0) || piece.is_empty());
auto statement_id = m_sql_client->prepare_statement(m_connection_id, piece.to_string());
auto statement_id = m_sql_client->prepare_statement(m_connection_id, piece.to_deprecated_string());
m_sql_client->async_execute_statement(statement_id);
return piece.to_string();
return piece.to_deprecated_string();
}
Optional<DeprecatedString> MainWidget::read_next_line_of_editor()

View file

@ -237,7 +237,7 @@ int Emulator::exec()
auto insn = X86::Instruction::from_stream(*m_cpu, X86::OperandSize::Size32, X86::AddressSize::Size32);
// Exec cycle
if constexpr (trace) {
outln("{:p} \033[33;1m{}\033[0m", m_cpu->base_eip(), insn.to_string(m_cpu->base_eip(), symbol_provider));
outln("{:p} \033[33;1m{}\033[0m", m_cpu->base_eip(), insn.to_deprecated_string(m_cpu->base_eip(), symbol_provider));
}
(m_cpu->*insn.handler())(insn);
@ -529,9 +529,9 @@ DeprecatedString Emulator::create_instruction_line(FlatPtr address, X86::Instruc
{
auto symbol = symbol_at(address);
if (!symbol.has_value() || !symbol->source_position.has_value())
return DeprecatedString::formatted("{:p}: {}", address, insn.to_string(address));
return DeprecatedString::formatted("{:p}: {}", address, insn.to_deprecated_string(address));
return DeprecatedString::formatted("{:p}: {} \e[34;1m{}\e[0m:{}", address, insn.to_string(address), LexicalPath::basename(symbol->source_position->file_path), symbol->source_position.value().line_number);
return DeprecatedString::formatted("{:p}: {} \e[34;1m{}\e[0m:{}", address, insn.to_deprecated_string(address), LexicalPath::basename(symbol->source_position->file_path), symbol->source_position.value().line_number);
}
static void emulator_signal_handler(int signum, siginfo_t* signal_info, void* context)

View file

@ -104,7 +104,7 @@ int main(int argc, char** argv, char** env)
perror("set_process_name");
return 1;
}
int rc = pthread_setname_np(pthread_self(), builder.to_string().characters());
int rc = pthread_setname_np(pthread_self(), builder.to_deprecated_string().characters());
if (rc != 0) {
reportln("pthread_setname_np: {}"sv, strerror(rc));
return 1;