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

@ -36,19 +36,19 @@ class UnregisteredWidget final : public GUI::Widget {
C_OBJECT(UnregisteredWidget);
private:
UnregisteredWidget(DeprecatedString const& class_name);
UnregisteredWidget(ByteString const& class_name);
virtual void paint_event(GUI::PaintEvent& event) override;
DeprecatedString m_text;
ByteString m_text;
};
UnregisteredWidget::UnregisteredWidget(DeprecatedString const& class_name)
UnregisteredWidget::UnregisteredWidget(ByteString const& class_name)
{
StringBuilder builder;
builder.append(class_name);
builder.append("\nnot registered"sv);
m_text = builder.to_deprecated_string();
m_text = builder.to_byte_string();
}
void UnregisteredWidget::paint_event(GUI::PaintEvent& event)
@ -114,7 +114,7 @@ MainWidget::MainWidget()
void MainWidget::update_title()
{
window()->set_title(DeprecatedString::formatted("{}[*] - GML Playground", m_file_path.is_empty() ? "Untitled"sv : m_file_path.view()));
window()->set_title(ByteString::formatted("{}[*] - GML Playground", m_file_path.is_empty() ? "Untitled"sv : m_file_path.view()));
}
void MainWidget::load_file(FileSystemAccessClient::File file)
@ -126,7 +126,7 @@ void MainWidget::load_file(FileSystemAccessClient::File file)
m_editor->set_text(buffer_or_error.release_value());
m_editor->set_focus(true);
m_file_path = file.filename().to_deprecated_string();
m_file_path = file.filename().to_byte_string();
update_title();
GUI::Application::the()->set_most_recently_open_file(file.filename());
@ -144,10 +144,10 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
auto file = response.value().release_stream();
if (auto result = m_editor->write_to_file(*file); result.is_error()) {
GUI::MessageBox::show(&window, DeprecatedString::formatted("Unable to save file: {}\n"sv, result.release_error()), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(&window, ByteString::formatted("Unable to save file: {}\n"sv, result.release_error()), "Error"sv, GUI::MessageBox::Type::Error);
return;
}
m_file_path = response.value().filename().to_deprecated_string();
m_file_path = response.value().filename().to_byte_string();
update_title();
GUI::Application::the()->set_most_recently_open_file(response.value().filename());
@ -164,7 +164,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
auto file = response.value().release_stream();
if (auto result = m_editor->write_to_file(*file); result.is_error()) {
GUI::MessageBox::show(&window, DeprecatedString::formatted("Unable to save file: {}\n"sv, result.release_error()), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(&window, ByteString::formatted("Unable to save file: {}\n"sv, result.release_error()), "Error"sv, GUI::MessageBox::Type::Error);
return;
}
update_title();
@ -225,7 +225,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
} else {
GUI::MessageBox::show(
&window,
DeprecatedString::formatted("GML could not be formatted: {}", formatted_gml_or_error.error()),
ByteString::formatted("GML could not be formatted: {}", formatted_gml_or_error.error()),
"Error"sv,
GUI::MessageBox::Type::Error);
}

View file

@ -51,5 +51,5 @@ private:
RefPtr<GUI::Action> m_view_window_action;
GUI::Icon m_icon;
DeprecatedString m_file_path;
ByteString m_file_path;
};

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Types.h>
#include <LibCpp/Parser.h>
#include <LibGUI/AutocompleteProvider.h>
@ -29,10 +29,10 @@ inline ErrorOr<void> encode(Encoder& encoder, CodeComprehension::AutocompleteRes
template<>
inline ErrorOr<CodeComprehension::AutocompleteResultEntry> decode(Decoder& decoder)
{
auto completion = TRY(decoder.decode<DeprecatedString>());
auto completion = TRY(decoder.decode<ByteString>());
auto partial_input_length = TRY(decoder.decode<size_t>());
auto language = TRY(decoder.decode<CodeComprehension::Language>());
auto display_text = TRY(decoder.decode<DeprecatedString>());
auto display_text = TRY(decoder.decode<ByteString>());
auto hide_autocomplete_after_applying = TRY(decoder.decode<CodeComprehension::AutocompleteResultEntry::HideAutocompleteAfterApplying>());
return CodeComprehension::AutocompleteResultEntry { move(completion), partial_input_length, language, move(display_text), hide_autocomplete_after_applying };
@ -50,7 +50,7 @@ inline ErrorOr<void> encode(Encoder& encoder, CodeComprehension::ProjectLocation
template<>
inline ErrorOr<CodeComprehension::ProjectLocation> decode(Decoder& decoder)
{
auto file = TRY(decoder.decode<DeprecatedString>());
auto file = TRY(decoder.decode<ByteString>());
auto line = TRY(decoder.decode<size_t>());
auto column = TRY(decoder.decode<size_t>());
@ -70,10 +70,10 @@ inline ErrorOr<void> encode(Encoder& encoder, CodeComprehension::Declaration con
template<>
inline ErrorOr<CodeComprehension::Declaration> decode(Decoder& decoder)
{
auto name = TRY(decoder.decode<DeprecatedString>());
auto name = TRY(decoder.decode<ByteString>());
auto position = TRY(decoder.decode<CodeComprehension::ProjectLocation>());
auto type = TRY(decoder.decode<CodeComprehension::DeclarationType>());
auto scope = TRY(decoder.decode<DeprecatedString>());
auto scope = TRY(decoder.decode<ByteString>());
return CodeComprehension::Declaration { move(name), position, type, move(scope) };
}
@ -91,8 +91,8 @@ inline ErrorOr<void> encode(Encoder& encoder, CodeComprehension::TodoEntry const
template<>
inline ErrorOr<CodeComprehension::TodoEntry> decode(Decoder& decoder)
{
auto content = TRY(decoder.decode<DeprecatedString>());
auto filename = TRY(decoder.decode<DeprecatedString>());
auto content = TRY(decoder.decode<ByteString>());
auto filename = TRY(decoder.decode<ByteString>());
auto line = TRY(decoder.decode<size_t>());
auto column = TRY(decoder.decode<size_t>());

View file

@ -9,7 +9,7 @@
namespace HackStudio {
NonnullRefPtr<CodeDocument> CodeDocument::create(DeprecatedString const& file_path, Client* client)
NonnullRefPtr<CodeDocument> CodeDocument::create(ByteString const& file_path, Client* client)
{
return adopt_ref(*new CodeDocument(file_path, client));
}
@ -19,7 +19,7 @@ NonnullRefPtr<CodeDocument> CodeDocument::create(Client* client)
return adopt_ref(*new CodeDocument(client));
}
CodeDocument::CodeDocument(DeprecatedString const& file_path, Client* client)
CodeDocument::CodeDocument(ByteString const& file_path, Client* client)
: TextDocument(client)
, m_file_path(file_path)
{

View file

@ -18,7 +18,7 @@ class Editor;
class CodeDocument final : public GUI::TextDocument {
public:
virtual ~CodeDocument() override = default;
static NonnullRefPtr<CodeDocument> create(DeprecatedString const& file_path, Client* client = nullptr);
static NonnullRefPtr<CodeDocument> create(ByteString const& file_path, Client* client = nullptr);
static NonnullRefPtr<CodeDocument> create(Client* client = nullptr);
Vector<size_t> const& breakpoint_lines() const { return m_breakpoint_lines; }
@ -26,7 +26,7 @@ public:
Optional<size_t> execution_position() const { return m_execution_position; }
void set_execution_position(size_t line) { m_execution_position = line; }
void clear_execution_position() { m_execution_position.clear(); }
DeprecatedString const& file_path() const { return m_file_path; }
ByteString const& file_path() const { return m_file_path; }
Optional<Syntax::Language> const& language() const { return m_language; }
enum class DiffType {
@ -39,10 +39,10 @@ public:
void set_line_differences(Badge<Editor>, Vector<DiffType>);
private:
explicit CodeDocument(DeprecatedString const& file_path, Client* client = nullptr);
explicit CodeDocument(ByteString const& file_path, Client* client = nullptr);
explicit CodeDocument(Client* client = nullptr);
DeprecatedString m_file_path;
ByteString m_file_path;
Optional<Syntax::Language> m_language;
Vector<size_t> m_breakpoint_lines;
Optional<size_t> m_execution_position;

View file

@ -46,7 +46,7 @@ Vector<BacktraceModel::FrameInfo> BacktraceModel::create_backtrace(Debug::Proces
// We need to go back to the 'call' instruction to get accurate source position information.
if (frame_index > 0)
--current_instruction;
DeprecatedString name = lib->debug_info->elf().symbolicate(current_instruction - lib->base_address);
ByteString name = lib->debug_info->elf().symbolicate(current_instruction - lib->base_address);
if (name.is_empty()) {
dbgln("BacktraceModel: couldn't find containing function for address: {:p} (library={})", current_instruction, lib->name);
name = "<missing>";

View file

@ -34,7 +34,7 @@ public:
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override;
struct FrameInfo {
DeprecatedString function_name;
ByteString function_name;
FlatPtr instruction_address { 0 };
FlatPtr frame_base { 0 };
Optional<Debug::DebugInfo::SourcePosition> m_source_position;

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Function.h>
#include <AK/Types.h>
@ -17,5 +17,5 @@ enum class BreakpointChange {
Removed,
};
using BreakpointChangeCallback = Function<void(DeprecatedString const& file, size_t line, BreakpointChange)>;
using BreakpointChangeCallback = Function<void(ByteString const& file, size_t line, BreakpointChange)>;
}

View file

@ -18,7 +18,7 @@ Debugger& Debugger::the()
}
void Debugger::initialize(
DeprecatedString source_root,
ByteString source_root,
Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback,
Function<void()> on_continue_callback,
Function<void()> on_exit_callback,
@ -33,7 +33,7 @@ bool Debugger::is_initialized()
}
Debugger::Debugger(
DeprecatedString source_root,
ByteString source_root,
Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback,
Function<void()> on_continue_callback,
Function<void()> on_exit_callback,
@ -48,7 +48,7 @@ Debugger::Debugger(
pthread_cond_init(&m_ui_action_cond, nullptr);
}
void Debugger::on_breakpoint_change(DeprecatedString const& file, size_t line, BreakpointChange change_type)
void Debugger::on_breakpoint_change(ByteString const& file, size_t line, BreakpointChange change_type)
{
auto position = create_source_position(file, line);
@ -80,7 +80,7 @@ void Debugger::on_breakpoint_change(DeprecatedString const& file, size_t line, B
}
}
bool Debugger::set_execution_position(DeprecatedString const& file, size_t line)
bool Debugger::set_execution_position(ByteString const& file, size_t line)
{
auto position = create_source_position(file, line);
auto session = Debugger::the().session();
@ -95,11 +95,11 @@ bool Debugger::set_execution_position(DeprecatedString const& file, size_t line)
return true;
}
Debug::DebugInfo::SourcePosition Debugger::create_source_position(DeprecatedString const& file, size_t line)
Debug::DebugInfo::SourcePosition Debugger::create_source_position(ByteString const& file, size_t line)
{
if (file.starts_with('/'))
return { file, line + 1 };
return { LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", m_source_root, file)), line + 1 };
return { LexicalPath::canonicalized_path(ByteString::formatted("{}/{}", m_source_root, file)), line + 1 };
}
intptr_t Debugger::start_static()

View file

@ -26,7 +26,7 @@ public:
};
static void initialize(
DeprecatedString source_root,
ByteString source_root,
Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback,
Function<void()> on_continue_callback,
Function<void()> on_exit_callback,
@ -34,11 +34,11 @@ public:
static bool is_initialized();
void on_breakpoint_change(DeprecatedString const& file, size_t line, BreakpointChange change_type);
bool set_execution_position(DeprecatedString const& file, size_t line);
void on_breakpoint_change(ByteString const& file, size_t line, BreakpointChange change_type);
bool set_execution_position(ByteString const& file, size_t line);
void set_executable_path(DeprecatedString const& path) { m_executable_path = path; }
void set_source_root(DeprecatedString const& source_root) { m_source_root = source_root; }
void set_executable_path(ByteString const& path) { m_executable_path = path; }
void set_source_root(ByteString const& source_root) { m_source_root = source_root; }
void set_pid_to_attach(pid_t pid) { m_pid_to_attach = pid; }
Debug::DebugSession* session() { return m_debug_session.ptr(); }
@ -94,13 +94,13 @@ private:
};
explicit Debugger(
DeprecatedString source_root,
ByteString source_root,
Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback,
Function<void()> on_continue_callback,
Function<void()> on_exit_callback,
Function<void(float)> on_initialization_progress);
Debug::DebugInfo::SourcePosition create_source_position(DeprecatedString const& file, size_t line);
Debug::DebugInfo::SourcePosition create_source_position(ByteString const& file, size_t line);
void start();
int debugger_loop(Debug::DebugSession::DesiredInitialDebugeeState);
@ -118,7 +118,7 @@ private:
CreateDebugSessionResult create_debug_session();
OwnPtr<Debug::DebugSession> m_debug_session;
DeprecatedString m_source_root;
ByteString m_source_root;
DebuggingState m_state;
pthread_mutex_t m_ui_action_mutex {};
@ -127,7 +127,7 @@ private:
Vector<Debug::DebugInfo::SourcePosition> m_breakpoints;
DeprecatedString m_executable_path;
ByteString m_executable_path;
Optional<pid_t> m_pid_to_attach;
Function<HasControlPassedToUser(PtraceRegisters const&)> m_on_stopped_callback;

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_deprecated_string(address_in_profiled_program, &symbol_provider);
auto disassembly = insn.value().to_byte_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 });
@ -93,12 +93,12 @@ GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole
if (role == GUI::ModelRole::Display) {
if (index.column() == Column::Address)
return DeprecatedString::formatted("{:p}", insn.address);
return ByteString::formatted("{:p}", insn.address);
if (index.column() == Column::InstructionBytes) {
StringBuilder builder;
for (auto ch : insn.bytes)
builder.appendff("{:02x} ", static_cast<unsigned char>(ch));
return builder.to_deprecated_string();
return builder.to_byte_string();
}
if (index.column() == Column::Disassembly)
return insn.disassembly;

View file

@ -22,7 +22,7 @@ namespace HackStudio {
struct InstructionData {
X86::Instruction insn;
DeprecatedString disassembly;
ByteString disassembly;
StringView bytes;
FlatPtr address { 0 };
};

View file

@ -49,7 +49,7 @@ void DisassemblyWidget::update_state(Debug::DebugSession const& debug_session, P
return;
auto containing_function = lib->debug_info->get_containing_function(regs.ip() - lib->base_address);
if (containing_function.has_value())
m_function_name_label->set_text(String::from_deprecated_string(containing_function.value().name).release_value_but_fixme_should_propagate_errors());
m_function_name_label->set_text(String::from_byte_string(containing_function.value().name).release_value_but_fixme_should_propagate_errors());
else
m_function_name_label->set_text("<missing>"_string);
show_disassembly();
@ -73,7 +73,7 @@ void DisassemblyWidget::show_disassembly()
m_unavailable_disassembly_widget->set_visible(false);
}
void DisassemblyWidget::hide_disassembly(DeprecatedString const& reason)
void DisassemblyWidget::hide_disassembly(ByteString const& reason)
{
m_top_container->set_visible(false);
m_disassembly_view->set_visible(false);

View file

@ -21,18 +21,18 @@ class UnavailableDisassemblyWidget final : public GUI::Frame {
public:
virtual ~UnavailableDisassemblyWidget() override { }
DeprecatedString const& reason() const { return m_reason; }
void set_reason(DeprecatedString const& text) { m_reason = text; }
ByteString const& reason() const { return m_reason; }
void set_reason(ByteString const& text) { m_reason = text; }
private:
UnavailableDisassemblyWidget(DeprecatedString const& reason)
UnavailableDisassemblyWidget(ByteString const& reason)
: m_reason(reason)
{
}
virtual void paint_event(GUI::PaintEvent& event) override;
DeprecatedString m_reason;
ByteString m_reason;
};
class DisassemblyWidget final : public GUI::Widget {
@ -47,7 +47,7 @@ private:
DisassemblyWidget();
void show_disassembly();
void hide_disassembly(DeprecatedString const&);
void hide_disassembly(ByteString const&);
RefPtr<GUI::Widget> m_top_container;
RefPtr<GUI::TableView> m_disassembly_view;

View file

@ -118,7 +118,7 @@ GUI::Variant RegistersModel::data(const GUI::ModelIndex& index, GUI::ModelRole r
if (index.column() == Column::Register)
return reg.name;
if (index.column() == Column::Value)
return DeprecatedString::formatted("{:p}", reg.value);
return ByteString::formatted("{:p}", reg.value);
return {};
}
return {};

View file

@ -14,7 +14,7 @@
namespace HackStudio {
struct RegisterData {
DeprecatedString name;
ByteString name;
FlatPtr value;
bool changed { false };
};

View file

@ -55,7 +55,7 @@ int VariablesModel::row_count(const GUI::ModelIndex& index) const
return node->members.size();
}
static DeprecatedString variable_value_as_string(Debug::DebugInfo::VariableInfo const& variable)
static ByteString variable_value_as_string(Debug::DebugInfo::VariableInfo const& variable)
{
if (variable.location_type != Debug::DebugInfo::VariableInfo::LocationType::Address)
return "N/A";
@ -69,20 +69,20 @@ static DeprecatedString variable_value_as_string(Debug::DebugInfo::VariableInfo
return enumerator->constant_data.as_u32 == enumerator_value;
});
if (it.is_end())
return DeprecatedString::formatted("Unknown ({})", value.value());
return DeprecatedString::formatted("{}::{}", variable.type_name, (*it)->name);
return ByteString::formatted("Unknown ({})", value.value());
return ByteString::formatted("{}::{}", variable.type_name, (*it)->name);
}
if (variable.type_name == "int") {
auto value = Debugger::the().session()->peek(variable_address);
VERIFY(value.has_value());
return DeprecatedString::formatted("{}", static_cast<int>(value.value()));
return ByteString::formatted("{}", static_cast<int>(value.value()));
}
if (variable.type_name == "char") {
auto value = Debugger::the().session()->peek(variable_address);
VERIFY(value.has_value());
return DeprecatedString::formatted("'{0:c}'", (char)value.value());
return ByteString::formatted("'{0:c}'", (char)value.value());
}
if (variable.type_name == "bool") {
@ -91,13 +91,13 @@ static DeprecatedString variable_value_as_string(Debug::DebugInfo::VariableInfo
return (value.value() & 1) ? "true" : "false";
}
return DeprecatedString::formatted("type: {} @ {:p}, ", variable.type_name, variable_address);
return ByteString::formatted("type: {} @ {:p}, ", variable.type_name, variable_address);
}
static Optional<u32> string_to_variable_value(StringView string_value, Debug::DebugInfo::VariableInfo const& variable)
{
if (variable.is_enum_type()) {
auto prefix_string = DeprecatedString::formatted("{}::", variable.type_name);
auto prefix_string = ByteString::formatted("{}::", variable.type_name);
auto string_to_use = string_value;
if (string_value.starts_with(prefix_string))
string_to_use = string_value.substring_view(prefix_string.length(), string_value.length() - prefix_string.length());
@ -143,7 +143,7 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, StringView
GUI::MessageBox::show(
parent_window,
DeprecatedString::formatted("String value \"{}\" could not be converted to a value of type {}.", string_value, variable->type_name),
ByteString::formatted("String value \"{}\" could not be converted to a value of type {}.", string_value, variable->type_name),
"Set value failed"sv,
GUI::MessageBox::Type::Error);
}
@ -154,7 +154,7 @@ GUI::Variant VariablesModel::data(const GUI::ModelIndex& index, GUI::ModelRole r
switch (role) {
case GUI::ModelRole::Display: {
auto value_as_string = variable_value_as_string(*variable);
return DeprecatedString::formatted("{}: {}", variable->name, value_as_string);
return ByteString::formatted("{}: {}", variable->name, value_as_string);
}
case GUI::ModelRole::Icon:
return m_variable_icon;

View file

@ -15,7 +15,7 @@
namespace HackStudio {
using OnCommitCallback = Function<void(DeprecatedString const& message)>;
using OnCommitCallback = Function<void(ByteString const& message)>;
class GitCommitDialog final : public GUI::Dialog {
C_OBJECT(GitCommitDialog);

View file

@ -10,7 +10,7 @@
#include <DevTools/HackStudio/Dialogs/NewProjectDialogGML.h>
#include <DevTools/HackStudio/ProjectTemplate.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/LexicalPath.h>
#include <LibCore/Directory.h>
#include <LibFileSystem/FileSystem.h>
@ -89,7 +89,7 @@ NewProjectDialog::NewProjectDialog(GUI::Window* parent)
m_browse_button = *find_descendant_of_type_named<GUI::Button>("browse_button");
m_browse_button->on_click = [this](auto) {
Optional<DeprecatedString> path = GUI::FilePicker::get_open_filepath(this, {}, Core::StandardPaths::home_directory(), true);
Optional<ByteString> path = GUI::FilePicker::get_open_filepath(this, {}, Core::StandardPaths::home_directory(), true);
if (path.has_value())
m_create_in_input->set_text(path.value().view());
};
@ -113,7 +113,7 @@ void NewProjectDialog::update_dialog()
m_input_valid = true;
if (project_template) {
m_description_label->set_text(String::from_deprecated_string(project_template->description()).release_value_but_fixme_should_propagate_errors());
m_description_label->set_text(String::from_byte_string(project_template->description()).release_value_but_fixme_should_propagate_errors());
} else {
m_description_label->set_text("Select a project template to continue."_string);
m_input_valid = false;
@ -122,7 +122,7 @@ void NewProjectDialog::update_dialog()
auto maybe_project_path = get_project_full_path();
if (maybe_project_path.has_value()) {
m_full_path_label->set_text(String::from_deprecated_string(maybe_project_path.value()).release_value_but_fixme_should_propagate_errors());
m_full_path_label->set_text(String::from_byte_string(maybe_project_path.value()).release_value_but_fixme_should_propagate_errors());
} else {
m_full_path_label->set_text("Invalid name or creation directory."_string);
m_input_valid = false;
@ -131,7 +131,7 @@ void NewProjectDialog::update_dialog()
m_ok_button->set_enabled(m_input_valid);
}
Optional<DeprecatedString> NewProjectDialog::get_available_project_name()
Optional<ByteString> NewProjectDialog::get_available_project_name()
{
auto create_in = m_create_in_input->text();
auto chosen_name = m_name_input->text();
@ -148,16 +148,16 @@ Optional<DeprecatedString> NewProjectDialog::get_available_project_name()
for (int i = 0; i < 1000; i++) {
auto candidate = (i == 0)
? chosen_name
: DeprecatedString::formatted("{}-{}", chosen_name, i);
: ByteString::formatted("{}-{}", chosen_name, i);
if (!FileSystem::exists(DeprecatedString::formatted("{}/{}", create_in, candidate)))
if (!FileSystem::exists(ByteString::formatted("{}/{}", create_in, candidate)))
return candidate;
}
return {};
}
Optional<DeprecatedString> NewProjectDialog::get_project_full_path()
Optional<ByteString> NewProjectDialog::get_project_full_path()
{
// Do not permit forward-slashes in project names
if (m_name_input->text().contains('/'))
@ -189,13 +189,13 @@ void NewProjectDialog::do_create_project()
auto create_in = m_create_in_input->text();
if (!FileSystem::exists(create_in) || !FileSystem::is_directory(create_in)) {
auto result = GUI::MessageBox::show(this, DeprecatedString::formatted("The directory \"{}\" does not exist yet, would you like to create it?", create_in), "New Project"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
auto result = GUI::MessageBox::show(this, ByteString::formatted("The directory \"{}\" does not exist yet, would you like to create it?", create_in), "New Project"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
if (result != GUI::MessageBox::ExecResult::Yes)
return;
auto created = Core::Directory::create(maybe_project_full_path.value(), Core::Directory::CreateDirectories::Yes);
if (created.is_error()) {
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Could not create directory \"{}\"", create_in));
GUI::MessageBox::show_error(this, ByteString::formatted("Could not create directory \"{}\"", create_in));
return;
}
}
@ -206,7 +206,7 @@ void NewProjectDialog::do_create_project()
m_created_project_path = maybe_project_full_path.value();
done(ExecResult::OK);
} else {
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Could not create project: {}", creation_result.error()));
GUI::MessageBox::show_error(this, ByteString::formatted("Could not create project: {}", creation_result.error()));
}
}

View file

@ -24,15 +24,15 @@ class NewProjectDialog : public GUI::Dialog {
public:
static ExecResult show(GUI::Window* parent_window);
Optional<DeprecatedString> created_project_path() const { return m_created_project_path; }
Optional<ByteString> created_project_path() const { return m_created_project_path; }
private:
NewProjectDialog(GUI::Window* parent);
virtual ~NewProjectDialog() override = default;
void update_dialog();
Optional<DeprecatedString> get_available_project_name();
Optional<DeprecatedString> get_project_full_path();
Optional<ByteString> get_available_project_name();
Optional<ByteString> get_project_full_path();
void do_create_project();
@ -53,7 +53,7 @@ private:
RefPtr<GUI::Button> m_cancel_button;
RefPtr<GUI::Button> m_browse_button;
Optional<DeprecatedString> m_created_project_path;
Optional<ByteString> m_created_project_path;
};
}

View file

@ -163,9 +163,9 @@ void Editor::paint_event(GUI::PaintEvent& event)
}
}
static HashMap<DeprecatedString, DeprecatedString>& man_paths()
static HashMap<ByteString, ByteString>& man_paths()
{
static HashMap<DeprecatedString, DeprecatedString> paths;
static HashMap<ByteString, ByteString> paths;
if (paths.is_empty()) {
auto json = Config::read_string("HackStudio"sv, "Global"sv, "DocumentationSearchPaths"sv);
AK::JsonParser parser(json);
@ -194,7 +194,7 @@ static HashMap<DeprecatedString, DeprecatedString>& man_paths()
return paths;
}
void Editor::show_documentation_tooltip_if_available(DeprecatedString const& hovered_token, Gfx::IntPoint screen_location)
void Editor::show_documentation_tooltip_if_available(ByteString const& hovered_token, Gfx::IntPoint screen_location)
{
auto it = man_paths().find(hovered_token);
if (it == man_paths().end()) {
@ -384,11 +384,11 @@ void Editor::leave_event(Core::Event& event)
GUI::TextEditor::leave_event(event);
}
static HashMap<DeprecatedString, DeprecatedString>& include_paths()
static HashMap<ByteString, ByteString>& include_paths()
{
static HashMap<DeprecatedString, DeprecatedString> paths;
static HashMap<ByteString, ByteString> paths;
auto add_directory = [](DeprecatedString base, Optional<DeprecatedString> recursive, auto handle_directory) -> void {
auto add_directory = [](ByteString base, Optional<ByteString> recursive, auto handle_directory) -> void {
Core::DirIterator it(recursive.value_or(base), Core::DirIterator::Flags::SkipDots);
while (it.has_next()) {
auto path = it.next_full_path();
@ -412,7 +412,7 @@ static HashMap<DeprecatedString, DeprecatedString>& include_paths()
return paths;
}
void Editor::navigate_to_include_if_available(DeprecatedString path)
void Editor::navigate_to_include_if_available(ByteString path)
{
auto it = include_paths().find(path);
if (it == include_paths().end()) {
@ -587,7 +587,7 @@ void Editor::on_identifier_click(const GUI::TextDocumentSpan& span)
if (!m_language_client)
return;
m_language_client->on_declaration_found = [](DeprecatedString const& file, size_t line, size_t column) {
m_language_client->on_declaration_found = [](ByteString const& file, size_t line, size_t column) {
HackStudio::open_file(file, line, column);
};
m_language_client->search_declaration(code_document().file_path(), span.range.start().line(), span.range.start().column());
@ -704,7 +704,7 @@ void Editor::handle_function_parameters_hint_request()
if (!m_language_client)
return;
m_language_client->on_function_parameters_hint_result = [this](Vector<DeprecatedString> const& params, size_t argument_index) {
m_language_client->on_function_parameters_hint_result = [this](Vector<ByteString> const& params, size_t argument_index) {
dbgln("on_function_parameters_hint_result");
StringBuilder html;
@ -722,7 +722,7 @@ void Editor::handle_function_parameters_hint_request()
}
html.append("<style>body { background-color: #dac7b5; }</style>"sv);
s_tooltip_page_view->load_html(html.to_deprecated_string());
s_tooltip_page_view->load_html(html.to_byte_string());
auto cursor_rect = current_editor().cursor_content_rect().location().translated(screen_relative_rect().location());

View file

@ -28,7 +28,7 @@ public:
virtual ~Editor() override = default;
Function<void(DeprecatedString)> on_open;
Function<void(ByteString)> on_open;
EditorWrapper& wrapper();
EditorWrapper const& wrapper() const;
@ -72,8 +72,8 @@ private:
virtual void leave_event(Core::Event&) override;
virtual void keydown_event(GUI::KeyEvent&) override;
void show_documentation_tooltip_if_available(DeprecatedString const&, Gfx::IntPoint screen_location);
void navigate_to_include_if_available(DeprecatedString);
void show_documentation_tooltip_if_available(ByteString const&, Gfx::IntPoint screen_location);
void navigate_to_include_if_available(ByteString);
void on_navigatable_link_click(const GUI::TextDocumentSpan&);
void on_identifier_click(const GUI::TextDocumentSpan&);
@ -111,7 +111,7 @@ private:
explicit Editor();
DeprecatedString m_last_parsed_token;
ByteString m_last_parsed_token;
GUI::TextPosition m_previous_text_position { 0, 0 };
bool m_hovering_editor { false };
bool m_hovering_clickable { false };

View file

@ -34,7 +34,7 @@ EditorWrapper::EditorWrapper()
set_current_editor_wrapper(this);
};
m_editor->on_open = [](DeprecatedString const& path) {
m_editor->on_open = [](ByteString const& path) {
open_file(path);
};
@ -64,7 +64,7 @@ void EditorWrapper::set_mode_non_displayable()
editor().document().set_text("The contents of this file could not be displayed. Is it a binary file?"sv);
}
void EditorWrapper::set_filename(DeprecatedString const& filename)
void EditorWrapper::set_filename(ByteString const& filename)
{
m_filename = filename;
update_title();
@ -75,7 +75,7 @@ bool EditorWrapper::save()
{
if (filename().is_empty()) {
auto file_picker_action = GUI::CommonActions::make_save_as_action([&](auto&) {
Optional<DeprecatedString> save_path = GUI::FilePicker::get_save_filepath(window(), "file"sv, "txt"sv, project_root().value());
Optional<ByteString> save_path = GUI::FilePicker::get_save_filepath(window(), "file"sv, "txt"sv, project_root().value());
if (save_path.has_value())
set_filename(save_path.value());
});
@ -99,7 +99,7 @@ void EditorWrapper::update_diff()
}
}
void EditorWrapper::set_project_root(DeprecatedString const& project_root)
void EditorWrapper::set_project_root(ByteString const& project_root)
{
m_project_root = project_root;
auto result = GitRepo::try_to_create(*m_project_root);
@ -126,7 +126,7 @@ void EditorWrapper::update_title()
if (editor().document().is_modified())
title.append(" (*)"sv);
m_filename_title = title.to_deprecated_string();
m_filename_title = title.to_byte_string();
}
void EditorWrapper::set_debug_mode(bool enabled)

View file

@ -37,12 +37,12 @@ public:
void set_mode_displayable();
void set_mode_non_displayable();
void set_debug_mode(bool);
void set_filename(DeprecatedString const&);
DeprecatedString const& filename() const { return m_filename; }
DeprecatedString const& filename_title() const { return m_filename_title; }
void set_filename(ByteString const&);
ByteString const& filename() const { return m_filename; }
ByteString const& filename_title() const { return m_filename_title; }
Optional<DeprecatedString> const& project_root() const { return m_project_root; }
void set_project_root(DeprecatedString const& project_root);
Optional<ByteString> const& project_root() const { return m_project_root; }
void set_project_root(ByteString const& project_root);
GitRepo const* git_repo() const { return m_git_repo; }
@ -59,11 +59,11 @@ private:
void update_title();
DeprecatedString m_filename;
DeprecatedString m_filename_title;
ByteString m_filename;
ByteString m_filename_title;
RefPtr<Editor> m_editor;
Optional<DeprecatedString> m_project_root;
Optional<ByteString> m_project_root;
RefPtr<GitRepo> m_git_repo;
Vector<Diff::Hunk> m_hunks;
};

View file

@ -17,9 +17,9 @@
namespace HackStudio {
struct Match {
DeprecatedString filename;
ByteString filename;
GUI::TextRange range;
DeprecatedString text;
ByteString text;
};
class SearchResultsModel final : public GUI::Model {
@ -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_deprecated_string() });
matches.append({ file.name(), range, builder.to_byte_string() });
}
});

View file

@ -10,13 +10,13 @@
namespace HackStudio {
GMLPreviewWidget::GMLPreviewWidget(DeprecatedString const& gml_content)
GMLPreviewWidget::GMLPreviewWidget(ByteString const& gml_content)
{
set_layout<GUI::VerticalBoxLayout>();
load_gml(gml_content);
}
void GMLPreviewWidget::load_gml(DeprecatedString const& gml)
void GMLPreviewWidget::load_gml(ByteString const& gml)
{
remove_all_children();

View file

@ -14,10 +14,10 @@ namespace HackStudio {
class GMLPreviewWidget final : public GUI::Widget {
C_OBJECT(GMLPreviewWidget)
public:
void load_gml(DeprecatedString const&);
void load_gml(ByteString const&);
private:
explicit GMLPreviewWidget(DeprecatedString const&);
explicit GMLPreviewWidget(ByteString const&);
};
}

View file

@ -135,7 +135,7 @@ Gfx::IntRect DiffViewer::separator_rect() const
frame_inner_rect().height() };
}
void DiffViewer::set_content(DeprecatedString const& original, DeprecatedString const& diff)
void DiffViewer::set_content(ByteString const& original, ByteString const& diff)
{
m_original_lines = split_to_lines(original);
m_hunks = Diff::parse_hunks(diff).release_value_but_fixme_should_propagate_errors();
@ -151,7 +151,7 @@ DiffViewer::DiffViewer()
setup_properties();
}
DiffViewer::DiffViewer(DeprecatedString const& original, DeprecatedString const& diff)
DiffViewer::DiffViewer(ByteString const& original, ByteString const& diff)
: m_original_lines(split_to_lines(original))
, m_hunks(Diff::parse_hunks(diff).release_value_but_fixme_should_propagate_errors())
{
@ -165,10 +165,10 @@ void DiffViewer::setup_properties()
set_foreground_role(ColorRole::BaseText);
}
Vector<DeprecatedString> DiffViewer::split_to_lines(DeprecatedString const& text)
Vector<ByteString> DiffViewer::split_to_lines(ByteString const& text)
{
// NOTE: This is slightly different than text.split('\n')
Vector<DeprecatedString> lines;
Vector<ByteString> lines;
size_t next_line_start_index = 0;
for (size_t i = 0; i < text.length(); ++i) {
if (text[i] == '\n') {

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Vector.h>
#include <LibDiff/Hunks.h>
#include <LibGUI/AbstractScrollableWidget.h>
@ -18,10 +18,10 @@ class DiffViewer final : public GUI::AbstractScrollableWidget {
public:
virtual ~DiffViewer() override = default;
void set_content(DeprecatedString const& original, DeprecatedString const& diff);
void set_content(ByteString const& original, ByteString const& diff);
private:
DiffViewer(DeprecatedString const& original, DeprecatedString const& diff);
DiffViewer(ByteString const& original, ByteString const& diff);
DiffViewer();
void setup_properties();
@ -45,7 +45,7 @@ private:
void draw_line(GUI::Painter&, StringView line, size_t y_offset, LinePosition, LineType);
static Vector<DeprecatedString> split_to_lines(DeprecatedString const& text);
static Vector<ByteString> split_to_lines(ByteString const& text);
static Gfx::Color red_background();
static Gfx::Color green_background();
@ -55,7 +55,7 @@ private:
Gfx::IntRect separator_rect() const;
Vector<DeprecatedString> m_original_lines;
Vector<ByteString> m_original_lines;
Vector<Diff::Hunk> m_hunks;
};
}

View file

@ -8,12 +8,12 @@
namespace HackStudio {
NonnullRefPtr<GitFilesModel> GitFilesModel::create(Vector<DeprecatedString>&& files)
NonnullRefPtr<GitFilesModel> GitFilesModel::create(Vector<ByteString>&& files)
{
return adopt_ref(*new GitFilesModel(move(files)));
}
GitFilesModel::GitFilesModel(Vector<DeprecatedString>&& files)
GitFilesModel::GitFilesModel(Vector<ByteString>&& files)
: m_files(move(files))
{
}

View file

@ -14,7 +14,7 @@ namespace HackStudio {
class GitFilesModel final : public GUI::Model {
public:
static NonnullRefPtr<GitFilesModel> create(Vector<DeprecatedString>&& files);
static NonnullRefPtr<GitFilesModel> create(Vector<ByteString>&& files);
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_files.size(); }
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return 1; }
@ -26,7 +26,7 @@ public:
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override;
private:
explicit GitFilesModel(Vector<DeprecatedString>&& files);
Vector<DeprecatedString> m_files;
explicit GitFilesModel(Vector<ByteString>&& files);
Vector<ByteString> m_files;
};
}

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_deprecated_string());
m_action_callback(data.to_byte_string());
}
};

View file

@ -13,7 +13,7 @@
namespace HackStudio {
// A "GitFileAction" is either the staging or the unstaging of a file.
using GitFileActionCallback = Function<void(DeprecatedString const& file)>;
using GitFileActionCallback = Function<void(ByteString const& file)>;
class GitFilesView : public GUI::ListView {
C_OBJECT(GitFilesView)

View file

@ -9,7 +9,7 @@
namespace HackStudio {
GitRepo::CreateResult GitRepo::try_to_create(DeprecatedString const& repository_root)
GitRepo::CreateResult GitRepo::try_to_create(ByteString const& repository_root)
{
if (!git_is_installed()) {
return { CreateResult::Type::GitProgramNotFound, nullptr };
@ -21,7 +21,7 @@ GitRepo::CreateResult GitRepo::try_to_create(DeprecatedString const& repository_
return { CreateResult::Type::Success, adopt_ref(*new GitRepo(repository_root)) };
}
RefPtr<GitRepo> GitRepo::initialize_repository(DeprecatedString const& repository_root)
RefPtr<GitRepo> GitRepo::initialize_repository(ByteString const& repository_root)
{
auto res = command_wrapper({ "init" }, repository_root);
if (!res.has_value())
@ -31,7 +31,7 @@ RefPtr<GitRepo> GitRepo::initialize_repository(DeprecatedString const& repositor
return adopt_ref(*new GitRepo(repository_root));
}
Vector<DeprecatedString> GitRepo::unstaged_files() const
Vector<ByteString> GitRepo::unstaged_files() const
{
auto modified = modified_files();
auto untracked = untracked_files();
@ -39,7 +39,7 @@ Vector<DeprecatedString> GitRepo::unstaged_files() const
return modified;
}
//
Vector<DeprecatedString> GitRepo::staged_files() const
Vector<ByteString> GitRepo::staged_files() const
{
auto raw_result = command({ "diff", "--cached", "--name-only" });
if (!raw_result.has_value())
@ -47,7 +47,7 @@ Vector<DeprecatedString> GitRepo::staged_files() const
return parse_files_list(*raw_result);
}
Vector<DeprecatedString> GitRepo::modified_files() const
Vector<ByteString> GitRepo::modified_files() const
{
auto raw_result = command({ "ls-files", "--modified", "--exclude-standard" });
if (!raw_result.has_value())
@ -55,7 +55,7 @@ Vector<DeprecatedString> GitRepo::modified_files() const
return parse_files_list(*raw_result);
}
Vector<DeprecatedString> GitRepo::untracked_files() const
Vector<ByteString> GitRepo::untracked_files() const
{
auto raw_result = command({ "ls-files", "--others", "--exclude-standard" });
if (!raw_result.has_value())
@ -63,27 +63,27 @@ Vector<DeprecatedString> GitRepo::untracked_files() const
return parse_files_list(*raw_result);
}
Vector<DeprecatedString> GitRepo::parse_files_list(DeprecatedString const& raw_result)
Vector<ByteString> GitRepo::parse_files_list(ByteString const& raw_result)
{
auto lines = raw_result.split('\n');
Vector<DeprecatedString> files;
Vector<ByteString> files;
for (auto const& line : lines) {
files.empend(line);
}
return files;
}
Optional<DeprecatedString> GitRepo::command(Vector<DeprecatedString> const& command_parts) const
Optional<ByteString> GitRepo::command(Vector<ByteString> const& command_parts) const
{
return command_wrapper(command_parts, m_repository_root);
}
Optional<DeprecatedString> GitRepo::command_wrapper(Vector<DeprecatedString> const& command_parts, DeprecatedString const& chdir)
Optional<ByteString> GitRepo::command_wrapper(Vector<ByteString> const& command_parts, ByteString const& chdir)
{
auto const result = Core::command("git", command_parts, LexicalPath(chdir));
if (result.is_error() || result.value().exit_code != 0)
return {};
return DeprecatedString(result.value().output.bytes());
return ByteString(result.value().output.bytes());
}
bool GitRepo::git_is_installed()
@ -91,37 +91,37 @@ bool GitRepo::git_is_installed()
return command_wrapper({ "--help" }, "/").has_value();
}
bool GitRepo::git_repo_exists(DeprecatedString const& repo_root)
bool GitRepo::git_repo_exists(ByteString const& repo_root)
{
return command_wrapper({ "status" }, repo_root).has_value();
}
bool GitRepo::stage(DeprecatedString const& file)
bool GitRepo::stage(ByteString const& file)
{
return command({ "add", file }).has_value();
}
bool GitRepo::unstage(DeprecatedString const& file)
bool GitRepo::unstage(ByteString const& file)
{
return command({ "reset", "HEAD", "--", file }).has_value();
}
bool GitRepo::commit(DeprecatedString const& message)
bool GitRepo::commit(ByteString const& message)
{
return command({ "commit", "-m", message }).has_value();
}
Optional<DeprecatedString> GitRepo::original_file_content(DeprecatedString const& file) const
Optional<ByteString> GitRepo::original_file_content(ByteString const& file) const
{
return command({ "show", DeprecatedString::formatted("HEAD:{}", file) });
return command({ "show", ByteString::formatted("HEAD:{}", file) });
}
Optional<DeprecatedString> GitRepo::unstaged_diff(DeprecatedString const& file) const
Optional<ByteString> GitRepo::unstaged_diff(ByteString const& file) const
{
return command({ "diff", "-U0", file.characters() });
}
bool GitRepo::is_tracked(DeprecatedString const& file) const
bool GitRepo::is_tracked(ByteString const& file) const
{
auto res = command({ "ls-files", file });
if (!res.has_value())

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/LexicalPath.h>
#include <AK/Optional.h>
#include <AK/RefCounted.h>
@ -28,37 +28,37 @@ public:
RefPtr<GitRepo> repo;
};
static CreateResult try_to_create(DeprecatedString const& repository_root);
static RefPtr<GitRepo> initialize_repository(DeprecatedString const& repository_root);
static CreateResult try_to_create(ByteString const& repository_root);
static RefPtr<GitRepo> initialize_repository(ByteString const& repository_root);
bool stage(DeprecatedString const& file);
bool unstage(DeprecatedString const& file);
bool commit(DeprecatedString const& message);
bool is_tracked(DeprecatedString const& file) const;
bool stage(ByteString const& file);
bool unstage(ByteString const& file);
bool commit(ByteString const& message);
bool is_tracked(ByteString const& file) const;
Vector<DeprecatedString> unstaged_files() const;
Vector<DeprecatedString> staged_files() const;
Optional<DeprecatedString> original_file_content(DeprecatedString const& file) const;
Optional<DeprecatedString> unstaged_diff(DeprecatedString const& file) const;
Vector<ByteString> unstaged_files() const;
Vector<ByteString> staged_files() const;
Optional<ByteString> original_file_content(ByteString const& file) const;
Optional<ByteString> unstaged_diff(ByteString const& file) const;
private:
static bool git_is_installed();
static bool git_repo_exists(DeprecatedString const& repo_root);
static bool git_repo_exists(ByteString const& repo_root);
static Optional<DeprecatedString> command_wrapper(Vector<DeprecatedString> const& command_parts, DeprecatedString const& chdir);
static Vector<DeprecatedString> parse_files_list(DeprecatedString const&);
static Optional<ByteString> command_wrapper(Vector<ByteString> const& command_parts, ByteString const& chdir);
static Vector<ByteString> parse_files_list(ByteString const&);
explicit GitRepo(DeprecatedString const& repository_root)
explicit GitRepo(ByteString const& repository_root)
: m_repository_root(repository_root)
{
}
Vector<DeprecatedString> modified_files() const;
Vector<DeprecatedString> untracked_files() const;
Vector<ByteString> modified_files() const;
Vector<ByteString> untracked_files() const;
Optional<DeprecatedString> command(Vector<DeprecatedString> const& command_parts) const;
Optional<ByteString> command(Vector<ByteString> const& command_parts) const;
DeprecatedString m_repository_root;
ByteString m_repository_root;
};
}

View file

@ -118,7 +118,7 @@ void GitWidget::refresh()
m_staged_files->set_model(GitFilesModel::create(m_git_repo->staged_files()));
}
void GitWidget::stage_file(DeprecatedString const& file)
void GitWidget::stage_file(ByteString const& file)
{
dbgln("staging: {}", file);
bool rc = m_git_repo->stage(file);
@ -126,7 +126,7 @@ void GitWidget::stage_file(DeprecatedString const& file)
refresh();
}
void GitWidget::unstage_file(DeprecatedString const& file)
void GitWidget::unstage_file(ByteString const& file)
{
dbgln("unstaging: {}", file);
bool rc = m_git_repo->unstage(file);
@ -154,7 +154,7 @@ void GitWidget::set_view_diff_callback(ViewDiffCallback callback)
m_view_diff_callback = move(callback);
}
void GitWidget::show_diff(DeprecatedString const& file_path)
void GitWidget::show_diff(ByteString const& file_path)
{
if (!m_git_repo->is_tracked(file_path)) {
auto file = Core::File::open(file_path, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
@ -168,7 +168,7 @@ void GitWidget::show_diff(DeprecatedString const& file_path)
m_view_diff_callback(original_content.value(), diff.value());
}
void GitWidget::change_repo(DeprecatedString const& repo_root)
void GitWidget::change_repo(ByteString const& repo_root)
{
m_repo_root = repo_root;
m_git_repo = nullptr;

View file

@ -14,7 +14,7 @@
namespace HackStudio {
using ViewDiffCallback = Function<void(DeprecatedString const& original_content, DeprecatedString const& diff)>;
using ViewDiffCallback = Function<void(ByteString const& original_content, ByteString const& diff)>;
class GitWidget final : public GUI::Widget {
C_OBJECT(GitWidget)
@ -24,19 +24,19 @@ public:
void refresh();
void set_view_diff_callback(ViewDiffCallback callback);
bool initialized() const { return !m_git_repo.is_null(); }
void change_repo(DeprecatedString const& repo_root);
void change_repo(ByteString const& repo_root);
private:
explicit GitWidget();
bool initialize();
bool initialize_if_needed();
void stage_file(DeprecatedString const&);
void unstage_file(DeprecatedString const&);
void stage_file(ByteString const&);
void unstage_file(ByteString const&);
void commit();
void show_diff(DeprecatedString const&);
void show_diff(ByteString const&);
DeprecatedString m_repo_root;
ByteString m_repo_root;
RefPtr<GitFilesView> m_unstaged_files;
RefPtr<GitFilesView> m_staged_files;
RefPtr<GitRepo> m_git_repo;

View file

@ -9,17 +9,17 @@
#include "EditorWrapper.h"
#include "LanguageClients/ConnectionsToServer.h"
#include "Project.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibGUI/TextEditor.h>
namespace HackStudio {
GUI::TextEditor& current_editor();
void open_file(DeprecatedString const&);
void open_file(ByteString const&);
RefPtr<EditorWrapper> current_editor_wrapper();
void open_file(DeprecatedString const&, size_t line, size_t column);
void open_file(ByteString const&, size_t line, size_t column);
Project& project();
DeprecatedString currently_open_file();
ByteString currently_open_file();
void set_current_editor_wrapper(RefPtr<EditorWrapper>);
void update_editor_window_title();
void for_each_open_file(Function<void(ProjectFile const&)>);

View file

@ -80,7 +80,7 @@
namespace HackStudio {
ErrorOr<NonnullRefPtr<HackStudioWidget>> HackStudioWidget::create(DeprecatedString path_to_project)
ErrorOr<NonnullRefPtr<HackStudioWidget>> HackStudioWidget::create(ByteString path_to_project)
{
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) HackStudioWidget));
@ -174,7 +174,7 @@ ErrorOr<NonnullRefPtr<HackStudioWidget>> HackStudioWidget::create(DeprecatedStri
return;
if (event.event_path.starts_with(widget->project().root_path())) {
DeprecatedString relative_path = LexicalPath::relative_path(event.event_path, widget->project().root_path());
ByteString relative_path = LexicalPath::relative_path(event.event_path, widget->project().root_path());
widget->handle_external_file_deletion(relative_path);
} else {
widget->handle_external_file_deletion(event.event_path);
@ -213,7 +213,7 @@ void HackStudioWidget::on_action_tab_change()
}
}
Vector<DeprecatedString> HackStudioWidget::read_recent_projects()
Vector<ByteString> HackStudioWidget::read_recent_projects()
{
auto json = Config::read_string("HackStudio"sv, "Global"sv, "RecentProjects"sv);
AK::JsonParser parser(json);
@ -225,7 +225,7 @@ Vector<DeprecatedString> HackStudioWidget::read_recent_projects()
if (!value.is_array())
return {};
Vector<DeprecatedString> paths;
Vector<ByteString> paths;
for (auto& json_value : value.as_array().values()) {
if (!json_value.is_string())
return {};
@ -235,7 +235,7 @@ Vector<DeprecatedString> HackStudioWidget::read_recent_projects()
return paths;
}
void HackStudioWidget::open_project(DeprecatedString const& root_path)
void HackStudioWidget::open_project(ByteString const& root_path)
{
if (warn_unsaved_changes("There are unsaved changes, do you want to save before closing current project?") == ContinueDecision::No)
return;
@ -280,20 +280,20 @@ 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_deprecated_string());
Config::write_string("HackStudio"sv, "Global"sv, "RecentProjects"sv, JsonArray(recent_projects).to_byte_string());
update_recent_projects_submenu();
}
Vector<DeprecatedString> HackStudioWidget::selected_file_paths() const
Vector<ByteString> HackStudioWidget::selected_file_paths() const
{
Vector<DeprecatedString> files;
Vector<ByteString> files;
m_project_tree_view->selection().for_each_index([&](const GUI::ModelIndex& index) {
DeprecatedString sub_path = index.data().as_string();
ByteString sub_path = index.data().as_string();
GUI::ModelIndex parent_or_invalid = index.parent();
while (parent_or_invalid.is_valid()) {
sub_path = DeprecatedString::formatted("{}/{}", parent_or_invalid.data().as_string(), sub_path);
sub_path = ByteString::formatted("{}/{}", parent_or_invalid.data().as_string(), sub_path);
parent_or_invalid = parent_or_invalid.parent();
}
@ -303,9 +303,9 @@ Vector<DeprecatedString> HackStudioWidget::selected_file_paths() const
return files;
}
bool HackStudioWidget::open_file(DeprecatedString const& full_filename, size_t line, size_t column)
bool HackStudioWidget::open_file(ByteString const& full_filename, size_t line, size_t column)
{
DeprecatedString filename = full_filename;
ByteString filename = full_filename;
if (full_filename.starts_with(project().root_path())) {
filename = LexicalPath::relative_path(full_filename, project().root_path());
}
@ -371,7 +371,7 @@ bool HackStudioWidget::open_file(DeprecatedString const& full_filename, size_t l
set_edit_mode(EditMode::Text);
DeprecatedString relative_file_path = filename;
ByteString relative_file_path = filename;
if (filename.starts_with(m_project->root_path()))
relative_file_path = filename.substring(m_project->root_path().length() + 1);
@ -390,16 +390,16 @@ bool HackStudioWidget::open_file(DeprecatedString const& full_filename, size_t l
return true;
}
void HackStudioWidget::close_file_in_all_editors(DeprecatedString const& filename)
void HackStudioWidget::close_file_in_all_editors(ByteString const& filename)
{
m_open_files.remove(filename);
m_open_files_vector.remove_all_matching(
[&filename](DeprecatedString const& element) { return element == filename; });
[&filename](ByteString const& element) { return element == filename; });
for (auto& editor_wrapper : m_all_editor_wrappers) {
Editor& editor = editor_wrapper->editor();
DeprecatedString editor_file_path = editor.code_document().file_path();
DeprecatedString relative_editor_file_path = LexicalPath::relative_path(editor_file_path, project().root_path());
ByteString editor_file_path = editor.code_document().file_path();
ByteString relative_editor_file_path = LexicalPath::relative_path(editor_file_path, project().root_path());
if (relative_editor_file_path == filename) {
if (m_open_files_vector.is_empty()) {
@ -515,7 +515,7 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> HackStudioWidget::create_project_tree_view_con
return project_tree_view_context_menu;
}
ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_file_action(DeprecatedString const& label, DeprecatedString const& icon, DeprecatedString const& extension)
ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_file_action(ByteString const& label, ByteString const& icon, ByteString const& extension)
{
auto icon_no_shadow = TRY(Gfx::Bitmap::load_from_file(icon));
return GUI::Action::create(label, icon_no_shadow, [this, extension](const GUI::Action&) {
@ -523,34 +523,34 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_file_action(Dep
if (GUI::InputBox::show(window(), filename, "Enter a name:"sv, "New File"sv) != GUI::InputBox::ExecResult::OK)
return;
if (!extension.is_empty() && !AK::StringUtils::ends_with(filename, DeprecatedString::formatted(".{}", extension), CaseSensitivity::CaseSensitive)) {
if (!extension.is_empty() && !AK::StringUtils::ends_with(filename, ByteString::formatted(".{}", extension), CaseSensitivity::CaseSensitive)) {
filename = String::formatted("{}.{}", filename, extension).release_value_but_fixme_should_propagate_errors();
}
auto path_to_selected = selected_file_paths();
DeprecatedString filepath;
ByteString filepath;
if (!path_to_selected.is_empty()) {
VERIFY(FileSystem::exists(path_to_selected.first()));
LexicalPath selected(path_to_selected.first());
DeprecatedString dir_path;
ByteString dir_path;
if (FileSystem::is_directory(selected.string()))
dir_path = selected.string();
else
dir_path = selected.dirname();
filepath = DeprecatedString::formatted("{}/", dir_path);
filepath = ByteString::formatted("{}/", dir_path);
}
filepath = DeprecatedString::formatted("{}{}", filepath, filename);
filepath = ByteString::formatted("{}{}", filepath, filename);
auto file_or_error = Core::File::open(filepath, Core::File::OpenMode::Write | Core::File::OpenMode::MustBeNew);
if (file_or_error.is_error()) {
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to create '{}': {}", filepath, file_or_error.error()));
GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to create '{}': {}", filepath, file_or_error.error()));
return;
}
open_file(filepath);
@ -570,7 +570,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_directory_actio
if (!path_to_selected.is_empty()) {
LexicalPath selected(path_to_selected.first());
DeprecatedString dir_path;
ByteString dir_path;
if (FileSystem::is_directory(selected.string()))
dir_path = selected.string();
@ -580,7 +580,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_directory_actio
directory_name = String::formatted("{}/{}", dir_path, directory_name).release_value_but_fixme_should_propagate_errors();
}
auto formatted_dir_name = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", m_project->model().root_path(), directory_name));
auto formatted_dir_name = LexicalPath::canonicalized_path(ByteString::formatted("{}/{}", m_project->model().root_path(), directory_name));
int rc = mkdir(formatted_dir_name.characters(), 0755);
if (rc < 0) {
GUI::MessageBox::show(window(), "Failed to create new directory"sv, "Error"sv, GUI::MessageBox::Type::Error);
@ -620,7 +620,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_copy_relative_path_action()
auto copy_relative_path_action = GUI::Action::create("Copy &Relative Path", [this](const GUI::Action&) {
auto paths = selected_file_paths();
VERIFY(!paths.is_empty());
auto paths_string = DeprecatedString::join('\n', paths);
auto paths_string = ByteString::join('\n', paths);
GUI::Clipboard::the().set_plain_text(paths_string);
});
copy_relative_path_action->set_enabled(true);
@ -634,10 +634,10 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_copy_full_path_action()
auto copy_full_path_action = GUI::Action::create("Copy &Full Path", [this](const GUI::Action&) {
auto paths = selected_file_paths();
VERIFY(!paths.is_empty());
Vector<DeprecatedString> full_paths;
Vector<ByteString> full_paths;
for (auto& path : paths)
full_paths.append(get_absolute_path(path));
auto paths_string = DeprecatedString::join('\n', full_paths);
auto paths_string = ByteString::join('\n', full_paths);
GUI::Clipboard::the().set_plain_text(paths_string);
});
copy_full_path_action->set_enabled(true);
@ -653,12 +653,12 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
if (files.is_empty())
return;
DeprecatedString message;
ByteString message;
if (files.size() == 1) {
LexicalPath file(files[0]);
message = DeprecatedString::formatted("Really remove \"{}\" from disk?", file.basename());
message = ByteString::formatted("Really remove \"{}\" from disk?", file.basename());
} else {
message = DeprecatedString::formatted("Really remove \"{}\" files from disk?", files.size());
message = ByteString::formatted("Really remove \"{}\" files from disk?", files.size());
}
auto result = GUI::MessageBox::show(window(),
@ -673,7 +673,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
struct stat st;
if (lstat(file.characters(), &st) < 0) {
GUI::MessageBox::show(window(),
DeprecatedString::formatted("lstat ({}) failed: {}", file, strerror(errno)),
ByteString::formatted("lstat ({}) failed: {}", file, strerror(errno)),
"Removal Failed"sv,
GUI::MessageBox::Type::Error);
break;
@ -684,12 +684,12 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
auto& error = result.error();
if (is_directory) {
GUI::MessageBox::show(window(),
DeprecatedString::formatted("Removing directory \"{}\" from the project failed: {}", file, error),
ByteString::formatted("Removing directory \"{}\" from the project failed: {}", file, error),
"Removal Failed"sv,
GUI::MessageBox::Type::Error);
} else {
GUI::MessageBox::show(window(),
DeprecatedString::formatted("Removing file \"{}\" from the project failed: {}", file, error),
ByteString::formatted("Removing file \"{}\" from the project failed: {}", file, error),
"Removal Failed"sv,
GUI::MessageBox::Type::Error);
}
@ -908,7 +908,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_save_as_action()
LexicalPath const old_path(old_filename);
auto suggested_path = FileSystem::absolute_path(old_path.string()).release_value_but_fixme_should_propagate_errors();
Optional<DeprecatedString> save_path = GUI::FilePicker::get_save_filepath(window(),
Optional<ByteString> save_path = GUI::FilePicker::get_save_filepath(window(),
old_filename.is_empty() ? "Untitled"sv : old_path.title(),
old_filename.is_empty() ? "txt"sv : old_path.extension(),
suggested_path);
@ -916,7 +916,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_save_as_action()
return;
}
DeprecatedString const relative_file_path = LexicalPath::relative_path(save_path.value(), m_project->root_path());
ByteString const relative_file_path = LexicalPath::relative_path(save_path.value(), m_project->root_path());
if (current_editor_wrapper().filename().is_empty()) {
current_editor_wrapper().set_filename(relative_file_path);
} else {
@ -1009,7 +1009,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_debug_action()
auto icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-run.png"sv));
return GUI::Action::create("&Debug", icon, [this](auto&) {
if (!FileSystem::exists(get_project_executable_path())) {
GUI::MessageBox::show(window(), DeprecatedString::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), ByteString::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error"sv, GUI::MessageBox::Type::Error);
return;
}
if (Debugger::the().session()) {
@ -1104,7 +1104,7 @@ void HackStudioWidget::initialize_debugger()
});
}
DeprecatedString HackStudioWidget::get_full_path_of_serenity_source(DeprecatedString const& file)
ByteString HackStudioWidget::get_full_path_of_serenity_source(ByteString const& file)
{
auto path_parts = LexicalPath(file).parts();
while (!path_parts.is_empty() && path_parts[0] == "..") {
@ -1114,10 +1114,10 @@ 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_deprecated_string());
return ByteString::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_byte_string());
}
DeprecatedString HackStudioWidget::get_absolute_path(DeprecatedString const& path) const
ByteString HackStudioWidget::get_absolute_path(ByteString const& path) const
{
// TODO: We can probably do a more specific condition here, something like
// "if (file.starts_with("../Libraries/") || file.starts_with("../AK/"))"
@ -1127,9 +1127,9 @@ DeprecatedString HackStudioWidget::get_absolute_path(DeprecatedString const& pat
return m_project->to_absolute_path(path);
}
RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(DeprecatedString const& filename)
RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(ByteString const& filename)
{
DeprecatedString file_path = filename;
ByteString file_path = filename;
if (filename.starts_with("../"sv)) {
file_path = get_full_path_of_serenity_source(filename);
@ -1140,19 +1140,19 @@ RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(DeprecatedString cons
return current_editor_wrapper();
}
DeprecatedString HackStudioWidget::get_project_executable_path() const
ByteString HackStudioWidget::get_project_executable_path() const
{
// FIXME: Dumb heuristic ahead!
// e.g /my/project => /my/project/project
// TODO: Perhaps a Makefile rule for getting the value of $(PROGRAM) would be better?
return DeprecatedString::formatted("{}/{}", m_project->root_path(), LexicalPath::basename(m_project->root_path()));
return ByteString::formatted("{}/{}", m_project->root_path(), LexicalPath::basename(m_project->root_path()));
}
void HackStudioWidget::build()
{
auto result = m_project_builder->build(active_file());
if (result.is_error()) {
GUI::MessageBox::show(window(), DeprecatedString::formatted("{}", result.error()), "Build Failed"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), ByteString::formatted("{}", result.error()), "Build Failed"sv, GUI::MessageBox::Type::Error);
m_build_action->set_enabled(true);
m_stop_action->set_enabled(false);
} else {
@ -1164,7 +1164,7 @@ void HackStudioWidget::run()
{
auto result = m_project_builder->run(active_file());
if (result.is_error()) {
GUI::MessageBox::show(window(), DeprecatedString::formatted("{}", result.error()), "Run Failed"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), ByteString::formatted("{}", result.error()), "Run Failed"sv, GUI::MessageBox::Type::Error);
m_run_action->set_enabled(true);
m_stop_action->set_enabled(false);
} else {
@ -1202,7 +1202,7 @@ void HackStudioWidget::set_current_editor_wrapper(RefPtr<EditorWrapper> editor_w
update_statusbar();
}
void HackStudioWidget::file_renamed(DeprecatedString const& old_name, DeprecatedString const& new_name)
void HackStudioWidget::file_renamed(ByteString const& old_name, ByteString const& new_name)
{
auto editor_or_none = m_all_editor_wrappers.first_matching([&old_name](auto const& editor) {
return editor->filename() == old_name;
@ -1272,11 +1272,11 @@ void HackStudioWidget::configure_project_tree_view()
void HackStudioWidget::create_open_files_view(GUI::Widget& parent)
{
m_open_files_view = parent.add<GUI::ListView>();
auto open_files_model = GUI::ItemListModel<DeprecatedString>::create(m_open_files_vector);
auto open_files_model = GUI::ItemListModel<ByteString>::create(m_open_files_vector);
m_open_files_view->set_model(open_files_model);
m_open_files_view->on_activation = [this](auto& index) {
open_file(index.data().to_deprecated_string());
open_file(index.data().to_byte_string());
};
}
@ -1638,7 +1638,7 @@ void HackStudioWidget::update_statusbar()
{
StringBuilder builder;
if (current_editor().has_selection()) {
DeprecatedString selected_text = current_editor().selected_text();
ByteString selected_text = current_editor().selected_text();
auto word_count = current_editor().number_of_selected_words();
builder.appendff("Selected: {:'d} {} ({:'d} {})", selected_text.length(), selected_text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
}
@ -1648,7 +1648,7 @@ void HackStudioWidget::update_statusbar()
m_statusbar->set_text(2, String::formatted("Ln {:'d} Col {:'d}", current_editor().cursor().line() + 1, current_editor().cursor().column()).release_value_but_fixme_should_propagate_errors());
}
void HackStudioWidget::handle_external_file_deletion(DeprecatedString const& filepath)
void HackStudioWidget::handle_external_file_deletion(ByteString const& filepath)
{
close_file_in_all_editors(filepath);
}
@ -1686,7 +1686,7 @@ HackStudioWidget::~HackStudioWidget()
stop_debugger_if_running();
}
HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(DeprecatedString const& prompt)
HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(ByteString const& prompt)
{
if (!any_document_is_dirty())
return ContinueDecision::Yes;
@ -1747,13 +1747,13 @@ void HackStudioWidget::update_toolbar_actions()
void HackStudioWidget::update_window_title()
{
window()->set_title(DeprecatedString::formatted("{} - {} - Hack Studio", m_current_editor_wrapper->filename_title(), m_project->name()));
window()->set_title(ByteString::formatted("{} - {} - Hack Studio", m_current_editor_wrapper->filename_title(), m_project->name()));
window()->set_modified(any_document_is_dirty());
}
void HackStudioWidget::update_current_editor_title()
{
current_editor_tab_widget().set_tab_title(current_editor_wrapper(), String::from_deprecated_string(current_editor_wrapper().filename_title()).release_value_but_fixme_should_propagate_errors());
current_editor_tab_widget().set_tab_title(current_editor_wrapper(), String::from_byte_string(current_editor_wrapper().filename_title()).release_value_but_fixme_should_propagate_errors());
}
void HackStudioWidget::on_cursor_change()
@ -1831,13 +1831,13 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_open_project_config
auto parent_directory = LexicalPath::dirname(Project::config_file_path);
auto absolute_config_file_path = LexicalPath::absolute_path(m_project->root_path(), Project::config_file_path);
DeprecatedString formatted_error_string_holder;
ByteString formatted_error_string_holder;
auto save_configuration_or_error = [&]() -> ErrorOr<void> {
if (FileSystem::exists(absolute_config_file_path))
return {};
if (FileSystem::exists(parent_directory) && !FileSystem::is_directory(parent_directory)) {
formatted_error_string_holder = DeprecatedString::formatted("Cannot create the '{}' directory because there is already a file with that name", parent_directory);
formatted_error_string_holder = ByteString::formatted("Cannot create the '{}' directory because there is already a file with that name", parent_directory);
return Error::from_string_view(formatted_error_string_holder.view());
}
@ -1854,7 +1854,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_open_project_config
return {};
}();
if (save_configuration_or_error.is_error()) {
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Saving configuration failed: {}.", save_configuration_or_error.error()));
GUI::MessageBox::show_error(window(), ByteString::formatted("Saving configuration failed: {}.", save_configuration_or_error.error()));
return;
}

View file

@ -37,11 +37,11 @@ class HackStudioWidget : public GUI::Widget {
C_OBJECT_ABSTRACT(HackStudioWidget)
public:
static ErrorOr<NonnullRefPtr<HackStudioWidget>> create(DeprecatedString path_to_project);
static ErrorOr<NonnullRefPtr<HackStudioWidget>> create(ByteString path_to_project);
virtual ~HackStudioWidget() override;
bool open_file(DeprecatedString const& filename, size_t line = 0, size_t column = 0);
void close_file_in_all_editors(DeprecatedString const& filename);
bool open_file(ByteString const& filename, size_t line = 0, size_t column = 0);
void close_file_in_all_editors(ByteString const& filename);
void update_actions();
Project& project();
@ -55,7 +55,7 @@ public:
GUI::TabWidget& current_editor_tab_widget();
GUI::TabWidget const& current_editor_tab_widget() const;
DeprecatedString const& active_file() const { return m_current_editor_wrapper->filename(); }
ByteString const& active_file() const { return m_current_editor_wrapper->filename(); }
ErrorOr<void> initialize_menubar(GUI::Window&);
Locator& locator()
@ -68,7 +68,7 @@ public:
No,
Yes
};
ContinueDecision warn_unsaved_changes(DeprecatedString const& prompt);
ContinueDecision warn_unsaved_changes(ByteString const& prompt);
enum class Mode {
Code,
@ -80,7 +80,7 @@ public:
void for_each_open_file(Function<void(ProjectFile const&)>);
bool semantic_syntax_highlighting_is_enabled() const;
static Vector<DeprecatedString> read_recent_projects();
static Vector<ByteString> read_recent_projects();
void update_current_editor_title();
void update_window_title();
@ -88,11 +88,11 @@ public:
private:
static constexpr size_t recent_projects_history_size = 15;
static DeprecatedString get_full_path_of_serenity_source(DeprecatedString const& file);
DeprecatedString get_absolute_path(DeprecatedString const&) const;
Vector<DeprecatedString> selected_file_paths() const;
static ByteString get_full_path_of_serenity_source(ByteString const& file);
ByteString get_absolute_path(ByteString const&) const;
Vector<ByteString> selected_file_paths() const;
void open_project(DeprecatedString const& root_path);
void open_project(ByteString const& root_path);
enum class EditMode {
Text,
@ -102,7 +102,7 @@ private:
void set_edit_mode(EditMode);
ErrorOr<NonnullRefPtr<GUI::Menu>> create_project_tree_view_context_menu();
ErrorOr<NonnullRefPtr<GUI::Action>> create_new_file_action(DeprecatedString const& label, DeprecatedString const& icon, DeprecatedString const& extension);
ErrorOr<NonnullRefPtr<GUI::Action>> create_new_file_action(ByteString const& label, ByteString const& icon, ByteString const& extension);
ErrorOr<NonnullRefPtr<GUI::Action>> create_new_directory_action();
ErrorOr<NonnullRefPtr<GUI::Action>> create_open_selected_action();
NonnullRefPtr<GUI::Action> create_delete_action();
@ -133,15 +133,15 @@ private:
void add_new_editor_tab_widget(GUI::Widget& parent);
void add_new_editor(GUI::TabWidget& parent);
RefPtr<EditorWrapper> get_editor_of_file(DeprecatedString const& filename);
DeprecatedString get_project_executable_path() const;
RefPtr<EditorWrapper> get_editor_of_file(ByteString const& filename);
ByteString get_project_executable_path() const;
void on_action_tab_change();
void reveal_action_tab(GUI::Widget&);
void initialize_debugger();
void update_statusbar();
void handle_external_file_deletion(DeprecatedString const& filepath);
void handle_external_file_deletion(ByteString const& filepath);
void stop_debugger_if_running();
void close_current_project();
@ -167,11 +167,11 @@ private:
void update_tree_view();
void update_toolbar_actions();
void on_cursor_change();
void file_renamed(DeprecatedString const& old_name, DeprecatedString const& new_name);
void file_renamed(ByteString const& old_name, ByteString const& new_name);
bool save_file_changes();
struct ProjectLocation {
DeprecatedString filename;
ByteString filename;
size_t line { 0 };
size_t column { 0 };
};
@ -184,9 +184,9 @@ private:
Vector<NonnullRefPtr<GUI::TabWidget>> m_all_editor_tab_widgets;
RefPtr<GUI::TabWidget> m_current_editor_tab_widget;
HashMap<DeprecatedString, NonnullRefPtr<ProjectFile>> m_open_files;
HashMap<ByteString, NonnullRefPtr<ProjectFile>> m_open_files;
RefPtr<Core::FileWatcher> m_file_watcher;
Vector<DeprecatedString> m_open_files_vector; // NOTE: This contains the keys from m_open_files and m_file_watchers
Vector<ByteString> m_open_files_vector; // NOTE: This contains the keys from m_open_files and m_file_watchers
OwnPtr<Project> m_project;

View file

@ -8,7 +8,7 @@
#include "HackStudio.h"
#include "ProjectDeclarations.h"
#include "ToDoEntries.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Vector.h>
#include <LibGUI/Notification.h>
@ -32,7 +32,7 @@ void ConnectionToServer::declaration_location(CodeComprehension::ProjectLocation
m_current_language_client->declaration_found(location.file, location.line, location.column);
}
void ConnectionToServer::parameters_hint_result(Vector<DeprecatedString> const& params, int argument_index)
void ConnectionToServer::parameters_hint_result(Vector<ByteString> const& params, int argument_index)
{
if (!m_current_language_client) {
dbgln("Language Server connection has no attached language client");
@ -60,35 +60,35 @@ void ConnectionToServer::die()
m_wrapper->on_crash();
}
void LanguageClient::open_file(DeprecatedString const& path, int fd)
void LanguageClient::open_file(ByteString const& path, int fd)
{
if (!m_connection_wrapper.connection())
return;
m_connection_wrapper.connection()->async_file_opened(path, fd);
}
void LanguageClient::set_file_content(DeprecatedString const& path, DeprecatedString const& content)
void LanguageClient::set_file_content(ByteString const& path, ByteString const& content)
{
if (!m_connection_wrapper.connection())
return;
m_connection_wrapper.connection()->async_set_file_content(path, content);
}
void LanguageClient::insert_text(DeprecatedString const& path, DeprecatedString const& text, size_t line, size_t column)
void LanguageClient::insert_text(ByteString const& path, ByteString const& text, size_t line, size_t column)
{
if (!m_connection_wrapper.connection())
return;
m_connection_wrapper.connection()->async_file_edit_insert_text(path, text, line, column);
}
void LanguageClient::remove_text(DeprecatedString const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column)
void LanguageClient::remove_text(ByteString const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column)
{
if (!m_connection_wrapper.connection())
return;
m_connection_wrapper.connection()->async_file_edit_remove_text(path, from_line, from_column, to_line, to_column);
}
void LanguageClient::request_autocomplete(DeprecatedString const& path, size_t cursor_line, size_t cursor_column)
void LanguageClient::request_autocomplete(ByteString const& path, size_t cursor_line, size_t cursor_column)
{
if (!m_connection_wrapper.connection())
return;
@ -118,19 +118,19 @@ bool LanguageClient::is_active_client() const
return m_connection_wrapper.connection()->active_client() == this;
}
HashMap<DeprecatedString, NonnullOwnPtr<ConnectionToServerWrapper>> ConnectionToServerInstances::s_instance_for_language;
HashMap<ByteString, NonnullOwnPtr<ConnectionToServerWrapper>> ConnectionToServerInstances::s_instance_for_language;
void ConnectionToServer::declarations_in_document(DeprecatedString const& filename, Vector<CodeComprehension::Declaration> const& declarations)
void ConnectionToServer::declarations_in_document(ByteString const& filename, Vector<CodeComprehension::Declaration> const& declarations)
{
ProjectDeclarations::the().set_declared_symbols(filename, declarations);
}
void ConnectionToServer::todo_entries_in_document(DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry> const& todo_entries)
void ConnectionToServer::todo_entries_in_document(ByteString const& filename, Vector<CodeComprehension::TodoEntry> const& todo_entries)
{
ToDoEntries::the().set_entries(filename, move(todo_entries));
}
void LanguageClient::search_declaration(DeprecatedString const& path, size_t line, size_t column)
void LanguageClient::search_declaration(ByteString const& path, size_t line, size_t column)
{
if (!m_connection_wrapper.connection())
return;
@ -138,7 +138,7 @@ void LanguageClient::search_declaration(DeprecatedString const& path, size_t lin
m_connection_wrapper.connection()->async_find_declaration(CodeComprehension::ProjectLocation { path, line, column });
}
void LanguageClient::get_parameters_hint(DeprecatedString const& path, size_t line, size_t column)
void LanguageClient::get_parameters_hint(ByteString const& path, size_t line, size_t column)
{
if (!m_connection_wrapper.connection())
return;
@ -146,7 +146,7 @@ void LanguageClient::get_parameters_hint(DeprecatedString const& path, size_t li
m_connection_wrapper.connection()->async_get_parameters_hint(CodeComprehension::ProjectLocation { path, line, column });
}
void LanguageClient::get_tokens_info(DeprecatedString const& filename)
void LanguageClient::get_tokens_info(ByteString const& filename)
{
if (!m_connection_wrapper.connection())
return;
@ -154,7 +154,7 @@ void LanguageClient::get_tokens_info(DeprecatedString const& filename)
m_connection_wrapper.connection()->async_get_tokens_info(filename);
}
void LanguageClient::declaration_found(DeprecatedString const& file, size_t line, size_t column) const
void LanguageClient::declaration_found(ByteString const& file, size_t line, size_t column) const
{
if (!on_declaration_found) {
dbgln("on_declaration_found callback is not set");
@ -163,7 +163,7 @@ void LanguageClient::declaration_found(DeprecatedString const& file, size_t line
on_declaration_found(file, line, column);
}
void LanguageClient::parameters_hint_result(Vector<DeprecatedString> const& params, size_t argument_index) const
void LanguageClient::parameters_hint_result(Vector<ByteString> const& params, size_t argument_index) const
{
if (!on_function_parameters_hint_result) {
dbgln("on_function_parameters_hint_result callback is not set");
@ -172,17 +172,17 @@ void LanguageClient::parameters_hint_result(Vector<DeprecatedString> const& para
on_function_parameters_hint_result(params, argument_index);
}
void ConnectionToServerInstances::set_instance_for_language(DeprecatedString const& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper)
void ConnectionToServerInstances::set_instance_for_language(ByteString const& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper)
{
s_instance_for_language.set(language_name, move(connection_wrapper));
}
void ConnectionToServerInstances::remove_instance_for_language(DeprecatedString const& language_name)
void ConnectionToServerInstances::remove_instance_for_language(ByteString const& language_name)
{
s_instance_for_language.remove(language_name);
}
ConnectionToServerWrapper* ConnectionToServerInstances::get_instance_wrapper(DeprecatedString const& language_name)
ConnectionToServerWrapper* ConnectionToServerInstances::get_instance_wrapper(ByteString const& language_name)
{
if (auto instance = s_instance_for_language.get(language_name); instance.has_value()) {
return const_cast<ConnectionToServerWrapper*>(instance.value());
@ -225,7 +225,7 @@ void ConnectionToServerWrapper::show_crash_notification() const
notification->show();
}
ConnectionToServerWrapper::ConnectionToServerWrapper(DeprecatedString const& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator)
ConnectionToServerWrapper::ConnectionToServerWrapper(ByteString const& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator)
: m_language(Syntax::language_from_name(language_name).value())
, m_connection_creator(move(connection_creator))
{

View file

@ -31,7 +31,7 @@ class ConnectionToServer
friend class ConnectionToServerWrapper;
public:
ConnectionToServer(NonnullOwnPtr<Core::LocalSocket> socket, DeprecatedString const& project_path)
ConnectionToServer(NonnullOwnPtr<Core::LocalSocket> socket, ByteString const& project_path)
: IPC::ConnectionToServer<LanguageClientEndpoint, LanguageServerEndpoint>(*this, move(socket))
{
m_project_path = project_path;
@ -39,7 +39,7 @@ public:
}
WeakPtr<LanguageClient> language_client() { return m_current_language_client; }
DeprecatedString const& project_path() const { return m_project_path; }
ByteString const& project_path() const { return m_project_path; }
virtual void die() override;
@ -48,13 +48,13 @@ public:
protected:
virtual void auto_complete_suggestions(Vector<CodeComprehension::AutocompleteResultEntry> const&) override;
virtual void declaration_location(CodeComprehension::ProjectLocation const&) override;
virtual void declarations_in_document(DeprecatedString const&, Vector<CodeComprehension::Declaration> const&) override;
virtual void todo_entries_in_document(DeprecatedString const&, Vector<CodeComprehension::TodoEntry> const&) override;
virtual void parameters_hint_result(Vector<DeprecatedString> const&, int index) override;
virtual void declarations_in_document(ByteString const&, Vector<CodeComprehension::Declaration> const&) override;
virtual void todo_entries_in_document(ByteString const&, Vector<CodeComprehension::TodoEntry> const&) override;
virtual void parameters_hint_result(Vector<ByteString> const&, int index) override;
virtual void tokens_info_result(Vector<CodeComprehension::TokenInfo> const&) override;
void set_wrapper(ConnectionToServerWrapper& wrapper) { m_wrapper = &wrapper; }
DeprecatedString m_project_path;
ByteString m_project_path;
WeakPtr<LanguageClient> m_current_language_client;
ConnectionToServerWrapper* m_wrapper { nullptr };
};
@ -63,11 +63,11 @@ class ConnectionToServerWrapper {
AK_MAKE_NONCOPYABLE(ConnectionToServerWrapper);
public:
explicit ConnectionToServerWrapper(DeprecatedString const& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator);
explicit ConnectionToServerWrapper(ByteString const& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator);
~ConnectionToServerWrapper() = default;
template<typename LanguageServerType>
static ConnectionToServerWrapper& get_or_create(DeprecatedString const& project_path);
static ConnectionToServerWrapper& get_or_create(ByteString const& project_path);
Syntax::Language language() const { return m_language; }
ConnectionToServer* connection();
@ -93,13 +93,13 @@ private:
class ConnectionToServerInstances {
public:
static void set_instance_for_language(DeprecatedString const& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper);
static void remove_instance_for_language(DeprecatedString const& language_name);
static void set_instance_for_language(ByteString const& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper);
static void remove_instance_for_language(ByteString const& language_name);
static ConnectionToServerWrapper* get_instance_wrapper(DeprecatedString const& language_name);
static ConnectionToServerWrapper* get_instance_wrapper(ByteString const& language_name);
private:
static HashMap<DeprecatedString, NonnullOwnPtr<ConnectionToServerWrapper>> s_instance_for_language;
static HashMap<ByteString, NonnullOwnPtr<ConnectionToServerWrapper>> s_instance_for_language;
};
class LanguageClient : public Weakable<LanguageClient> {
@ -128,23 +128,23 @@ public:
Syntax::Language language() const { return m_connection_wrapper.language(); }
void set_active_client();
bool is_active_client() const;
virtual void open_file(DeprecatedString const& path, int fd);
virtual void set_file_content(DeprecatedString const& path, DeprecatedString const& content);
virtual void insert_text(DeprecatedString const& path, DeprecatedString const& text, size_t line, size_t column);
virtual void remove_text(DeprecatedString const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column);
virtual void request_autocomplete(DeprecatedString const& path, size_t cursor_line, size_t cursor_column);
virtual void search_declaration(DeprecatedString const& path, size_t line, size_t column);
virtual void get_parameters_hint(DeprecatedString const& path, size_t line, size_t column);
virtual void get_tokens_info(DeprecatedString const& filename);
virtual void open_file(ByteString const& path, int fd);
virtual void set_file_content(ByteString const& path, ByteString const& content);
virtual void insert_text(ByteString const& path, ByteString const& text, size_t line, size_t column);
virtual void remove_text(ByteString const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column);
virtual void request_autocomplete(ByteString const& path, size_t cursor_line, size_t cursor_column);
virtual void search_declaration(ByteString const& path, size_t line, size_t column);
virtual void get_parameters_hint(ByteString const& path, size_t line, size_t column);
virtual void get_tokens_info(ByteString const& filename);
void provide_autocomplete_suggestions(Vector<CodeComprehension::AutocompleteResultEntry> const&) const;
void declaration_found(DeprecatedString const& file, size_t line, size_t column) const;
void parameters_hint_result(Vector<DeprecatedString> const& params, size_t argument_index) const;
void declaration_found(ByteString const& file, size_t line, size_t column) const;
void parameters_hint_result(Vector<ByteString> const& params, size_t argument_index) const;
// Callbacks that get called when the result of a language server query is ready
Function<void(Vector<CodeComprehension::AutocompleteResultEntry>)> on_autocomplete_suggestions;
Function<void(DeprecatedString const&, size_t, size_t)> on_declaration_found;
Function<void(Vector<DeprecatedString> const&, size_t)> on_function_parameters_hint_result;
Function<void(ByteString const&, size_t, size_t)> on_declaration_found;
Function<void(Vector<ByteString> const&, size_t)> on_function_parameters_hint_result;
Function<void(Vector<CodeComprehension::TokenInfo> const&)> on_tokens_info_result;
private:
@ -153,13 +153,13 @@ private:
};
template<typename ConnectionToServerT>
static inline NonnullOwnPtr<LanguageClient> get_language_client(DeprecatedString const& project_path)
static inline NonnullOwnPtr<LanguageClient> get_language_client(ByteString const& project_path)
{
return make<LanguageClient>(ConnectionToServerWrapper::get_or_create<ConnectionToServerT>(project_path));
}
template<typename LanguageServerType>
ConnectionToServerWrapper& ConnectionToServerWrapper::get_or_create(DeprecatedString const& project_path)
ConnectionToServerWrapper& ConnectionToServerWrapper::get_or_create(ByteString const& project_path)
{
auto* wrapper = ConnectionToServerInstances::get_instance_wrapper(LanguageServerType::language_name());
if (wrapper)

View file

@ -12,22 +12,22 @@
#include <DevTools/HackStudio/LanguageServers/LanguageServerEndpoint.h>
#include <LibIPC/ConnectionToServer.h>
#define LANGUAGE_CLIENT(language_name_, socket_name) \
namespace language_name_ { \
class ConnectionToServer final : public HackStudio::ConnectionToServer { \
IPC_CLIENT_CONNECTION(ConnectionToServer, "/tmp/session/%sid/portal/language/" socket_name) \
public: \
static char const* language_name() \
{ \
return #language_name_; \
} \
\
private: \
ConnectionToServer(NonnullOwnPtr<Core::LocalSocket> socket, DeprecatedString const& project_path) \
: HackStudio::ConnectionToServer(move(socket), project_path) \
{ \
} \
}; \
#define LANGUAGE_CLIENT(language_name_, socket_name) \
namespace language_name_ { \
class ConnectionToServer final : public HackStudio::ConnectionToServer { \
IPC_CLIENT_CONNECTION(ConnectionToServer, "/tmp/session/%sid/portal/language/" socket_name) \
public: \
static char const* language_name() \
{ \
return #language_name_; \
} \
\
private: \
ConnectionToServer(NonnullOwnPtr<Core::LocalSocket> socket, ByteString const& project_path) \
: HackStudio::ConnectionToServer(move(socket), project_path) \
{ \
} \
}; \
}
namespace LanguageClients {

View file

@ -26,7 +26,7 @@ void ConnectionFromClient::die()
exit(0);
}
void ConnectionFromClient::greet(DeprecatedString const& project_root)
void ConnectionFromClient::greet(ByteString const& project_root)
{
m_filedb.set_project_root(project_root);
if (unveil(project_root.characters(), "r") < 0) {
@ -39,7 +39,7 @@ void ConnectionFromClient::greet(DeprecatedString const& project_root)
}
}
void ConnectionFromClient::file_opened(DeprecatedString const& filename, IPC::File const& file)
void ConnectionFromClient::file_opened(ByteString const& filename, IPC::File const& file)
{
if (m_filedb.is_open(filename)) {
return;
@ -48,7 +48,7 @@ void ConnectionFromClient::file_opened(DeprecatedString const& filename, IPC::Fi
m_autocomplete_engine->file_opened(filename);
}
void ConnectionFromClient::file_edit_insert_text(DeprecatedString const& filename, DeprecatedString const& text, i32 start_line, i32 start_column)
void ConnectionFromClient::file_edit_insert_text(ByteString const& filename, ByteString const& text, i32 start_line, i32 start_column)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "InsertText for file: {}", filename);
dbgln_if(LANGUAGE_SERVER_DEBUG, "Text: {}", text);
@ -57,7 +57,7 @@ void ConnectionFromClient::file_edit_insert_text(DeprecatedString const& filenam
m_autocomplete_engine->on_edit(filename);
}
void ConnectionFromClient::file_edit_remove_text(DeprecatedString const& filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column)
void ConnectionFromClient::file_edit_remove_text(ByteString const& filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "RemoveText for file: {}", filename);
dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{} - {}:{}]", start_line, start_column, end_line, end_column);
@ -80,7 +80,7 @@ void ConnectionFromClient::auto_complete_suggestions(CodeComprehension::ProjectL
async_auto_complete_suggestions(move(suggestions));
}
void ConnectionFromClient::set_file_content(DeprecatedString const& filename, DeprecatedString const& content)
void ConnectionFromClient::set_file_content(ByteString const& filename, ByteString const& content)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "SetFileContent: {}", filename);
auto document = m_filedb.get_document(filename);
@ -139,7 +139,7 @@ void ConnectionFromClient::get_parameters_hint(CodeComprehension::ProjectLocatio
async_parameters_hint_result(params->params, params->current_index);
}
void ConnectionFromClient::get_tokens_info(DeprecatedString const& filename)
void ConnectionFromClient::get_tokens_info(ByteString const& filename)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "GetTokenInfo: {}", filename);
auto document = m_filedb.get_document(filename);

View file

@ -27,15 +27,15 @@ public:
virtual void die() override;
protected:
virtual void greet(DeprecatedString const&) override;
virtual void file_opened(DeprecatedString const&, IPC::File const&) override;
virtual void file_edit_insert_text(DeprecatedString const&, DeprecatedString const&, i32, i32) override;
virtual void file_edit_remove_text(DeprecatedString const&, i32, i32, i32, i32) override;
virtual void set_file_content(DeprecatedString const&, DeprecatedString const&) override;
virtual void greet(ByteString const&) override;
virtual void file_opened(ByteString const&, IPC::File const&) override;
virtual void file_edit_insert_text(ByteString const&, ByteString const&, i32, i32) override;
virtual void file_edit_remove_text(ByteString const&, i32, i32, i32, i32) override;
virtual void set_file_content(ByteString const&, ByteString const&) override;
virtual void auto_complete_suggestions(CodeComprehension::ProjectLocation const&) override;
virtual void find_declaration(CodeComprehension::ProjectLocation const&) override;
virtual void get_parameters_hint(CodeComprehension::ProjectLocation const&) override;
virtual void get_tokens_info(DeprecatedString const&) override;
virtual void get_tokens_info(ByteString const&) override;
FileDB m_filedb;
OwnPtr<CodeComprehension::CodeComprehensionEngine> m_autocomplete_engine;

View file

@ -19,10 +19,10 @@ private:
: LanguageServers::ConnectionFromClient(move(socket))
{
m_autocomplete_engine = adopt_own(*new CodeComprehension::Cpp::CppComprehensionEngine(m_filedb));
m_autocomplete_engine->set_declarations_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
m_autocomplete_engine->set_declarations_of_document_callback = [this](ByteString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
async_declarations_in_document(filename, move(declarations));
};
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](ByteString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
async_todo_entries_in_document(filename, move(todo_entries));
};
}

View file

@ -13,7 +13,7 @@
namespace LanguageServers {
RefPtr<const GUI::TextDocument> FileDB::get_document(DeprecatedString const& filename) const
RefPtr<const GUI::TextDocument> FileDB::get_document(ByteString const& filename) const
{
auto absolute_path = to_absolute_path(filename);
auto document_optional = m_open_files.get(absolute_path);
@ -23,7 +23,7 @@ RefPtr<const GUI::TextDocument> FileDB::get_document(DeprecatedString const& fil
return *document_optional.value();
}
RefPtr<GUI::TextDocument> FileDB::get_document(DeprecatedString const& filename)
RefPtr<GUI::TextDocument> FileDB::get_document(ByteString const& filename)
{
auto document = reinterpret_cast<FileDB const*>(this)->get_document(filename);
if (document.is_null())
@ -31,7 +31,7 @@ RefPtr<GUI::TextDocument> FileDB::get_document(DeprecatedString const& filename)
return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref()));
}
Optional<DeprecatedString> FileDB::get_or_read_from_filesystem(StringView filename) const
Optional<ByteString> FileDB::get_or_read_from_filesystem(StringView filename) const
{
auto absolute_path = to_absolute_path(filename);
auto document = get_document(absolute_path);
@ -46,12 +46,12 @@ Optional<DeprecatedString> FileDB::get_or_read_from_filesystem(StringView filena
return document_or_error.value()->text();
}
bool FileDB::is_open(DeprecatedString const& filename) const
bool FileDB::is_open(ByteString const& filename) const
{
return m_open_files.contains(to_absolute_path(filename));
}
bool FileDB::add(DeprecatedString const& filename, int fd)
bool FileDB::add(ByteString const& filename, int fd)
{
auto document_or_error = create_from_fd(fd);
if (document_or_error.is_error()) {
@ -63,17 +63,17 @@ bool FileDB::add(DeprecatedString const& filename, int fd)
return true;
}
DeprecatedString FileDB::to_absolute_path(DeprecatedString const& filename) const
ByteString FileDB::to_absolute_path(ByteString const& filename) const
{
if (LexicalPath { filename }.is_absolute()) {
return filename;
}
if (!m_project_root.has_value())
return filename;
return LexicalPath { DeprecatedString::formatted("{}/{}", *m_project_root, filename) }.string();
return LexicalPath { ByteString::formatted("{}/{}", *m_project_root, filename) }.string();
}
ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_filesystem(DeprecatedString const& filename) const
ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_filesystem(ByteString const& filename) const
{
auto file = TRY(Core::File::open(to_absolute_path(filename), Core::File::OpenMode::Read));
return create_from_file(move(file));
@ -110,7 +110,7 @@ ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_file(NonnullOwnPtr
return document;
}
void FileDB::on_file_edit_insert_text(DeprecatedString const& filename, DeprecatedString const& inserted_text, size_t start_line, size_t start_column)
void FileDB::on_file_edit_insert_text(ByteString const& filename, ByteString const& inserted_text, size_t start_line, size_t start_column)
{
VERIFY(is_open(filename));
auto document = get_document(filename);
@ -121,7 +121,7 @@ void FileDB::on_file_edit_insert_text(DeprecatedString const& filename, Deprecat
dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text());
}
void FileDB::on_file_edit_remove_text(DeprecatedString const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column)
void FileDB::on_file_edit_remove_text(ByteString const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column)
{
// TODO: If file is not open - need to get its contents
// Otherwise- somehow verify that respawned language server is synced with all file contents
@ -138,7 +138,7 @@ void FileDB::on_file_edit_remove_text(DeprecatedString const& filename, size_t s
dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text());
}
RefPtr<GUI::TextDocument> FileDB::create_with_content(DeprecatedString const& content)
RefPtr<GUI::TextDocument> FileDB::create_with_content(ByteString const& content)
{
StringView content_view(content);
auto document = GUI::TextDocument::create(&s_default_document_client);
@ -146,7 +146,7 @@ RefPtr<GUI::TextDocument> FileDB::create_with_content(DeprecatedString const& co
return document;
}
bool FileDB::add(DeprecatedString const& filename, DeprecatedString const& content)
bool FileDB::add(ByteString const& filename, ByteString const& content)
{
auto document = create_with_content(content);
if (!document) {

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/NonnullRefPtr.h>
#include <LibCodeComprehension/FileDB.h>
@ -17,28 +17,28 @@ namespace LanguageServers {
class FileDB final : public CodeComprehension::FileDB {
public:
FileDB() = default;
virtual Optional<DeprecatedString> get_or_read_from_filesystem(StringView filename) const override;
virtual Optional<ByteString> get_or_read_from_filesystem(StringView filename) const override;
RefPtr<const GUI::TextDocument> get_document(DeprecatedString const& filename) const;
RefPtr<GUI::TextDocument> get_document(DeprecatedString const& filename);
RefPtr<const GUI::TextDocument> get_document(ByteString const& filename) const;
RefPtr<GUI::TextDocument> get_document(ByteString const& filename);
bool add(DeprecatedString const& filename, int fd);
bool add(DeprecatedString const& filename, DeprecatedString const& content);
bool add(ByteString const& filename, int fd);
bool add(ByteString const& filename, ByteString const& content);
void on_file_edit_insert_text(DeprecatedString const& filename, DeprecatedString const& inserted_text, size_t start_line, size_t start_column);
void on_file_edit_remove_text(DeprecatedString const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column);
DeprecatedString to_absolute_path(DeprecatedString const& filename) const;
bool is_open(DeprecatedString const& filename) const;
void on_file_edit_insert_text(ByteString const& filename, ByteString const& inserted_text, size_t start_line, size_t start_column);
void on_file_edit_remove_text(ByteString const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column);
ByteString to_absolute_path(ByteString const& filename) const;
bool is_open(ByteString const& filename) const;
private:
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_filesystem(DeprecatedString const& filename) const;
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_filesystem(ByteString const& filename) const;
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_fd(int fd) const;
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_file(NonnullOwnPtr<Core::File>) const;
static RefPtr<GUI::TextDocument> create_with_content(DeprecatedString const&);
static RefPtr<GUI::TextDocument> create_with_content(ByteString const&);
private:
HashMap<DeprecatedString, NonnullRefPtr<GUI::TextDocument>> m_open_files;
Optional<DeprecatedString> m_project_root;
HashMap<ByteString, NonnullRefPtr<GUI::TextDocument>> m_open_files;
Optional<ByteString> m_project_root;
};
}

View file

@ -2,8 +2,8 @@ endpoint LanguageClient
{
auto_complete_suggestions(Vector<CodeComprehension::AutocompleteResultEntry> suggestions) =|
declaration_location(CodeComprehension::ProjectLocation location) =|
declarations_in_document(DeprecatedString filename, Vector<CodeComprehension::Declaration> declarations) =|
todo_entries_in_document(DeprecatedString filename, Vector<CodeComprehension::TodoEntry> todo_entries) =|
parameters_hint_result(Vector<DeprecatedString> params, int current_index) =|
declarations_in_document(ByteString filename, Vector<CodeComprehension::Declaration> declarations) =|
todo_entries_in_document(ByteString filename, Vector<CodeComprehension::TodoEntry> todo_entries) =|
parameters_hint_result(Vector<ByteString> params, int current_index) =|
tokens_info_result(Vector<CodeComprehension::TokenInfo> tokens_info) =|
}

View file

@ -1,15 +1,15 @@
endpoint LanguageServer
{
greet(DeprecatedString project_root) =|
greet(ByteString project_root) =|
file_opened(DeprecatedString filename, IPC::File file) =|
file_edit_insert_text(DeprecatedString filename, DeprecatedString text, i32 start_line, i32 start_column) =|
file_edit_remove_text(DeprecatedString filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column) =|
set_file_content(DeprecatedString filename, DeprecatedString content) =|
file_opened(ByteString filename, IPC::File file) =|
file_edit_insert_text(ByteString filename, ByteString text, i32 start_line, i32 start_column) =|
file_edit_remove_text(ByteString filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column) =|
set_file_content(ByteString filename, ByteString content) =|
auto_complete_suggestions(CodeComprehension::ProjectLocation location) =|
find_declaration(CodeComprehension::ProjectLocation location) =|
get_parameters_hint(CodeComprehension::ProjectLocation location) =|
get_tokens_info(DeprecatedString filename) =|
get_tokens_info(ByteString filename) =|
}

View file

@ -20,10 +20,10 @@ private:
: LanguageServers::ConnectionFromClient(move(socket))
{
m_autocomplete_engine = make<CodeComprehension::Shell::ShellComprehensionEngine>(m_filedb);
m_autocomplete_engine->set_declarations_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
m_autocomplete_engine->set_declarations_of_document_callback = [this](ByteString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
async_declarations_in_document(filename, move(declarations));
};
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](ByteString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
async_todo_entries_in_document(filename, move(todo_entries));
};
}

View file

@ -21,13 +21,13 @@ namespace HackStudio {
class LocatorSuggestionModel final : public GUI::Model {
public:
struct Suggestion {
static Suggestion create_filename(DeprecatedString const& filename);
static Suggestion create_filename(ByteString const& filename);
static Suggestion create_symbol_declaration(CodeComprehension::Declaration const&);
bool is_filename() const { return as_filename.has_value(); }
bool is_symbol_declaration() const { return as_symbol_declaration.has_value(); }
Optional<DeprecatedString> as_filename;
Optional<ByteString> as_filename;
Optional<CodeComprehension::Declaration> as_symbol_declaration;
};
@ -62,7 +62,7 @@ public:
if (index.column() == Column::Name) {
if (!suggestion.as_symbol_declaration.value().scope.is_empty())
return suggestion.as_symbol_declaration.value().name;
return DeprecatedString::formatted("{}::{}", suggestion.as_symbol_declaration.value().scope, suggestion.as_symbol_declaration.value().name);
return ByteString::formatted("{}::{}", suggestion.as_symbol_declaration.value().scope, suggestion.as_symbol_declaration.value().name);
}
if (index.column() == Column::Filename)
return suggestion.as_symbol_declaration.value().position.file;
@ -82,7 +82,7 @@ private:
Vector<Suggestion> m_suggestions;
};
LocatorSuggestionModel::Suggestion LocatorSuggestionModel::Suggestion::create_filename(DeprecatedString const& filename)
LocatorSuggestionModel::Suggestion LocatorSuggestionModel::Suggestion::create_filename(ByteString const& filename)
{
LocatorSuggestionModel::Suggestion s;
s.as_filename = filename;

View file

@ -10,13 +10,13 @@
namespace HackStudio {
Project::Project(DeprecatedString const& root_path)
Project::Project(ByteString const& root_path)
: m_root_path(root_path)
{
m_model = GUI::FileSystemModel::create(root_path, GUI::FileSystemModel::Mode::FilesAndDirectories);
}
OwnPtr<Project> Project::open_with_root_path(DeprecatedString const& root_path)
OwnPtr<Project> Project::open_with_root_path(ByteString const& root_path)
{
if (!FileSystem::is_directory(root_path))
return {};
@ -45,18 +45,18 @@ void Project::for_each_text_file(Function<void(ProjectFile const&)> callback) co
});
}
NonnullRefPtr<ProjectFile> Project::create_file(DeprecatedString const& path) const
NonnullRefPtr<ProjectFile> Project::create_file(ByteString const& path) const
{
auto full_path = to_absolute_path(path);
return ProjectFile::construct_with_name(full_path);
}
DeprecatedString Project::to_absolute_path(DeprecatedString const& path) const
ByteString Project::to_absolute_path(ByteString const& path) const
{
if (LexicalPath { path }.is_absolute()) {
return path;
}
return LexicalPath { DeprecatedString::formatted("{}/{}", m_root_path, path) }.string();
return LexicalPath { ByteString::formatted("{}/{}", m_root_path, path) }.string();
}
bool Project::project_is_serenity() const

View file

@ -20,28 +20,28 @@ class Project {
AK_MAKE_NONMOVABLE(Project);
public:
static OwnPtr<Project> open_with_root_path(DeprecatedString const& root_path);
static OwnPtr<Project> open_with_root_path(ByteString const& root_path);
GUI::FileSystemModel& model() { return *m_model; }
const GUI::FileSystemModel& model() const { return *m_model; }
DeprecatedString name() const { return LexicalPath::basename(m_root_path); }
DeprecatedString root_path() const { return m_root_path; }
ByteString name() const { return LexicalPath::basename(m_root_path); }
ByteString root_path() const { return m_root_path; }
NonnullRefPtr<ProjectFile> create_file(DeprecatedString const& path) const;
NonnullRefPtr<ProjectFile> create_file(ByteString const& path) const;
void for_each_text_file(Function<void(ProjectFile const&)>) const;
DeprecatedString to_absolute_path(DeprecatedString const&) const;
ByteString to_absolute_path(ByteString const&) const;
bool project_is_serenity() const;
static constexpr auto config_file_path = ".hackstudio/config.json"sv;
NonnullOwnPtr<ProjectConfig> config() const;
private:
explicit Project(DeprecatedString const& root_path);
explicit Project(ByteString const& root_path);
RefPtr<GUI::FileSystemModel> m_model;
DeprecatedString m_root_path;
ByteString m_root_path;
};
}

View file

@ -35,7 +35,7 @@ ErrorOr<void> ProjectBuilder::build(StringView active_file)
return Error::from_string_literal("no active file");
if (active_file.ends_with(".js"sv)) {
TRY(m_terminal->run_command(DeprecatedString::formatted("js -A {}", active_file)));
TRY(m_terminal->run_command(ByteString::formatted("js -A {}", active_file)));
return {};
}
@ -61,7 +61,7 @@ ErrorOr<void> ProjectBuilder::run(StringView active_file)
return Error::from_string_literal("no active file");
if (active_file.ends_with(".js"sv)) {
TRY(m_terminal->run_command(DeprecatedString::formatted("js {}", active_file)));
TRY(m_terminal->run_command(ByteString::formatted("js {}", active_file)));
return {};
}
@ -105,11 +105,11 @@ ErrorOr<void> ProjectBuilder::update_active_file(StringView active_file)
ErrorOr<void> ProjectBuilder::build_serenity_component()
{
TRY(verify_make_is_installed());
TRY(m_terminal->run_command(DeprecatedString::formatted("make {}", m_serenity_component_name), build_directory(), TerminalWrapper::WaitForExit::Yes, "Make failed"sv));
TRY(m_terminal->run_command(ByteString::formatted("make {}", m_serenity_component_name), build_directory(), TerminalWrapper::WaitForExit::Yes, "Make failed"sv));
return {};
}
ErrorOr<DeprecatedString> ProjectBuilder::component_name(StringView cmake_file_path)
ErrorOr<ByteString> ProjectBuilder::component_name(StringView cmake_file_path)
{
auto file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Read));
auto content = TRY(file->read_until_eof());
@ -119,7 +119,7 @@ ErrorOr<DeprecatedString> ProjectBuilder::component_name(StringView cmake_file_p
if (!component_name.search(StringView { content }, result))
return Error::from_string_literal("component not found");
return DeprecatedString { result.capture_group_matches.at(0).at(0).view.string_view() };
return ByteString { result.capture_group_matches.at(0).at(0).view.string_view() };
}
ErrorOr<void> ProjectBuilder::initialize_build_directory()
@ -137,15 +137,15 @@ ErrorOr<void> ProjectBuilder::initialize_build_directory()
auto cmake_file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Write));
TRY(cmake_file->write_until_depleted(generate_cmake_file_content().bytes()));
TRY(m_terminal->run_command(DeprecatedString::formatted("cmake -S {} -DHACKSTUDIO_BUILD=ON -DHACKSTUDIO_BUILD_CMAKE_FILE={}"
" -DENABLE_UNICODE_DATABASE_DOWNLOAD=OFF",
TRY(m_terminal->run_command(ByteString::formatted("cmake -S {} -DHACKSTUDIO_BUILD=ON -DHACKSTUDIO_BUILD_CMAKE_FILE={}"
" -DENABLE_UNICODE_DATABASE_DOWNLOAD=OFF",
m_project_root, cmake_file_path),
build_directory(), TerminalWrapper::WaitForExit::Yes, "CMake error"sv));
return {};
}
Optional<DeprecatedString> ProjectBuilder::find_cmake_file_for(StringView file_path) const
Optional<ByteString> ProjectBuilder::find_cmake_file_for(StringView file_path) const
{
auto directory = LexicalPath::dirname(file_path);
while (!directory.is_empty()) {
@ -157,7 +157,7 @@ Optional<DeprecatedString> ProjectBuilder::find_cmake_file_for(StringView file_p
return {};
}
DeprecatedString ProjectBuilder::generate_cmake_file_content() const
ByteString ProjectBuilder::generate_cmake_file_content() const
{
StringBuilder builder;
builder.appendff("add_subdirectory({})\n", LexicalPath::dirname(m_serenity_component_cmake_file));
@ -174,20 +174,20 @@ DeprecatedString ProjectBuilder::generate_cmake_file_content() const
// all of their direct dependencies in the CMakeLists file.
// For example, a target may directly use LibGFX but only specify LibGUI as a dependency (which in turn depends on LibGFX).
// In this example, if we don't specify the dependencies of LibGUI in the CMake file, linking will fail because of undefined LibGFX symbols.
builder.appendff("target_link_libraries({} INTERFACE {})\n", library.key, DeprecatedString::join(' ', library.value->dependencies));
builder.appendff("target_link_libraries({} INTERFACE {})\n", library.key, ByteString::join(' ', library.value->dependencies));
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
HashMap<DeprecatedString, NonnullOwnPtr<ProjectBuilder::LibraryInfo>> ProjectBuilder::get_defined_libraries()
HashMap<ByteString, NonnullOwnPtr<ProjectBuilder::LibraryInfo>> ProjectBuilder::get_defined_libraries()
{
HashMap<DeprecatedString, NonnullOwnPtr<ProjectBuilder::LibraryInfo>> libraries;
HashMap<ByteString, NonnullOwnPtr<ProjectBuilder::LibraryInfo>> libraries;
for_each_library_definition([&libraries](DeprecatedString name, DeprecatedString path) {
for_each_library_definition([&libraries](ByteString name, ByteString path) {
libraries.set(name, make<ProjectBuilder::LibraryInfo>(move(path)));
});
for_each_library_dependencies([&libraries](DeprecatedString name, Vector<StringView> const& dependencies) {
for_each_library_dependencies([&libraries](ByteString name, Vector<StringView> const& dependencies) {
auto library = libraries.get(name);
if (!library.has_value())
return;
@ -199,9 +199,9 @@ HashMap<DeprecatedString, NonnullOwnPtr<ProjectBuilder::LibraryInfo>> ProjectBui
return libraries;
}
void ProjectBuilder::for_each_library_definition(Function<void(DeprecatedString, DeprecatedString)> func)
void ProjectBuilder::for_each_library_definition(Function<void(ByteString, ByteString)> func)
{
Vector<DeprecatedString> arguments = { "-c", "find Userland -name CMakeLists.txt | xargs grep serenity_lib" };
Vector<ByteString> arguments = { "-c", "find Userland -name CMakeLists.txt | xargs grep serenity_lib" };
auto res = Core::command("/bin/sh", arguments, {});
if (res.is_error()) {
warnln("{}", res.error());
@ -218,7 +218,7 @@ void ProjectBuilder::for_each_library_definition(Function<void(DeprecatedString,
auto library_name = result.capture_group_matches.at(0).at(0).view.string_view();
auto library_obj_name = result.capture_group_matches.at(0).at(1).view.string_view();
auto so_path = DeprecatedString::formatted("{}.so", LexicalPath::join("/usr/lib"sv, DeprecatedString::formatted("lib{}", library_obj_name)).string());
auto so_path = ByteString::formatted("{}.so", LexicalPath::join("/usr/lib"sv, ByteString::formatted("lib{}", library_obj_name)).string());
func(library_name, so_path);
}
@ -226,9 +226,9 @@ void ProjectBuilder::for_each_library_definition(Function<void(DeprecatedString,
func("ssp", "/usr/lib/libssp.a");
}
void ProjectBuilder::for_each_library_dependencies(Function<void(DeprecatedString, Vector<StringView>)> func)
void ProjectBuilder::for_each_library_dependencies(Function<void(ByteString, Vector<StringView>)> func)
{
Vector<DeprecatedString> arguments = { "-c", "find Userland/Libraries -name CMakeLists.txt | xargs grep target_link_libraries" };
Vector<ByteString> arguments = { "-c", "find Userland/Libraries -name CMakeLists.txt | xargs grep target_link_libraries" };
auto res = Core::command("/bin/sh", arguments, {});
if (res.is_error()) {
warnln("{}", res.error());
@ -267,7 +267,7 @@ ErrorOr<void> ProjectBuilder::verify_make_is_installed()
return Error::from_string_literal("Make port is not installed");
}
DeprecatedString ProjectBuilder::build_directory() const
ByteString ProjectBuilder::build_directory() const
{
return LexicalPath::join(m_project_root, "Build"sv).string();
}

View file

@ -32,27 +32,27 @@ private:
ErrorOr<void> build_serenity_component();
ErrorOr<void> run_serenity_component();
ErrorOr<void> initialize_build_directory();
Optional<DeprecatedString> find_cmake_file_for(StringView file_path) const;
DeprecatedString generate_cmake_file_content() const;
Optional<ByteString> find_cmake_file_for(StringView file_path) const;
ByteString generate_cmake_file_content() const;
ErrorOr<void> update_active_file(StringView active_file);
DeprecatedString build_directory() const;
ByteString build_directory() const;
struct LibraryInfo {
DeprecatedString path;
Vector<DeprecatedString> dependencies {};
ByteString path;
Vector<ByteString> dependencies {};
};
static HashMap<DeprecatedString, NonnullOwnPtr<LibraryInfo>> get_defined_libraries();
static void for_each_library_definition(Function<void(DeprecatedString, DeprecatedString)>);
static void for_each_library_dependencies(Function<void(DeprecatedString, Vector<StringView>)>);
static ErrorOr<DeprecatedString> component_name(StringView cmake_file_path);
static HashMap<ByteString, NonnullOwnPtr<LibraryInfo>> get_defined_libraries();
static void for_each_library_definition(Function<void(ByteString, ByteString)>);
static void for_each_library_dependencies(Function<void(ByteString, Vector<StringView>)>);
static ErrorOr<ByteString> component_name(StringView cmake_file_path);
static ErrorOr<void> verify_cmake_is_installed();
static ErrorOr<void> verify_make_is_installed();
DeprecatedString m_project_root;
ByteString m_project_root;
Project const& m_project;
NonnullRefPtr<TerminalWrapper> m_terminal;
IsSerenityRepo m_is_serenity { IsSerenityRepo::No };
DeprecatedString m_serenity_component_cmake_file;
DeprecatedString m_serenity_component_name;
ByteString m_serenity_component_cmake_file;
ByteString m_serenity_component_name;
};
}

View file

@ -15,7 +15,7 @@ ProjectConfig::ProjectConfig(JsonObject config)
{
}
ErrorOr<NonnullOwnPtr<ProjectConfig>> ProjectConfig::try_load_project_config(DeprecatedString path)
ErrorOr<NonnullOwnPtr<ProjectConfig>> ProjectConfig::try_load_project_config(ByteString path)
{
auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
auto file_contents = TRY(file->read_until_eof());
@ -33,9 +33,9 @@ NonnullOwnPtr<ProjectConfig> ProjectConfig::create_empty()
return adopt_own(*new ProjectConfig(empty));
}
Optional<DeprecatedString> ProjectConfig::read_key(DeprecatedString key_name) const
Optional<ByteString> ProjectConfig::read_key(ByteString key_name) const
{
return m_config.get_deprecated_string(key_name);
return m_config.get_byte_string(key_name);
}
}

View file

@ -16,16 +16,16 @@ namespace HackStudio {
class ProjectConfig {
public:
static ErrorOr<NonnullOwnPtr<ProjectConfig>> try_load_project_config(DeprecatedString path);
static ErrorOr<NonnullOwnPtr<ProjectConfig>> try_load_project_config(ByteString path);
static NonnullOwnPtr<ProjectConfig> create_empty();
ProjectConfig(JsonObject);
Optional<DeprecatedString> build_command() const { return read_key("build_command"); }
Optional<DeprecatedString> run_command() const { return read_key("run_command"); }
Optional<ByteString> build_command() const { return read_key("build_command"); }
Optional<ByteString> run_command() const { return read_key("run_command"); }
private:
Optional<DeprecatedString> read_key(DeprecatedString key_name) const;
Optional<ByteString> read_key(ByteString key_name) const;
JsonObject m_config;
};

View file

@ -11,7 +11,7 @@ HackStudio::ProjectDeclarations& HackStudio::ProjectDeclarations::the()
static ProjectDeclarations s_instance;
return s_instance;
}
void HackStudio::ProjectDeclarations::set_declared_symbols(DeprecatedString const& filename, Vector<CodeComprehension::Declaration> const& declarations)
void HackStudio::ProjectDeclarations::set_declared_symbols(ByteString const& filename, Vector<CodeComprehension::Declaration> const& declarations)
{
m_document_to_declarations.set(filename, declarations);
if (on_update)

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Function.h>
#include <AK/HashMap.h>
#include <AK/Noncopyable.h>
@ -23,7 +23,7 @@ public:
template<typename Func>
void for_each_declared_symbol(Func);
void set_declared_symbols(DeprecatedString const& filename, Vector<CodeComprehension::Declaration> const&);
void set_declared_symbols(ByteString const& filename, Vector<CodeComprehension::Declaration> const&);
static Optional<GUI::Icon> get_icon_for(CodeComprehension::DeclarationType);
@ -31,7 +31,7 @@ public:
private:
ProjectDeclarations() = default;
HashMap<DeprecatedString, Vector<CodeComprehension::Declaration>> m_document_to_declarations;
HashMap<ByteString, Vector<CodeComprehension::Declaration>> m_document_to_declarations;
};
template<typename Func>

View file

@ -9,7 +9,7 @@
namespace HackStudio {
ProjectFile::ProjectFile(DeprecatedString const& name)
ProjectFile::ProjectFile(ByteString const& name)
: m_name(name)
{
}

View file

@ -8,7 +8,7 @@
#include "CodeDocument.h"
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/NonnullRefPtr.h>
#include <AK/RefCounted.h>
@ -16,12 +16,12 @@ namespace HackStudio {
class ProjectFile : public RefCounted<ProjectFile> {
public:
static NonnullRefPtr<ProjectFile> construct_with_name(DeprecatedString const& name)
static NonnullRefPtr<ProjectFile> construct_with_name(ByteString const& name)
{
return adopt_ref(*new ProjectFile(name));
}
DeprecatedString const& name() const { return m_name; }
ByteString const& name() const { return m_name; }
bool could_render_text() const { return m_could_render_text; }
GUI::TextDocument& document() const;
@ -33,10 +33,10 @@ public:
void horizontal_scroll_value(int);
private:
explicit ProjectFile(DeprecatedString const& name);
explicit ProjectFile(ByteString const& name);
void create_document_if_needed() const;
DeprecatedString m_name;
ByteString m_name;
mutable RefPtr<CodeDocument> m_document;
mutable bool m_could_render_text { false };
int m_vertical_scroll_value { 0 };

View file

@ -5,7 +5,7 @@
*/
#include "ProjectTemplate.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/LexicalPath.h>
#include <AK/StringBuilder.h>
#include <LibCore/ConfigFile.h>
@ -19,7 +19,7 @@
namespace HackStudio {
ProjectTemplate::ProjectTemplate(DeprecatedString const& id, DeprecatedString const& name, DeprecatedString const& description, const GUI::Icon& icon, int priority)
ProjectTemplate::ProjectTemplate(ByteString const& id, ByteString const& name, ByteString const& description, const GUI::Icon& icon, int priority)
: m_id(id)
, m_name(name)
, m_description(description)
@ -28,7 +28,7 @@ ProjectTemplate::ProjectTemplate(DeprecatedString const& id, DeprecatedString co
{
}
RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(DeprecatedString const& manifest_path)
RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(ByteString const& manifest_path)
{
auto maybe_config = Core::ConfigFile::open(manifest_path);
if (maybe_config.is_error())
@ -50,7 +50,7 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(DeprecatedString con
// Fallback to a generic executable icon if one isn't found
auto icon = GUI::Icon::default_icon("filetype-executable"sv);
auto bitmap_path_32 = DeprecatedString::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x"));
auto bitmap_path_32 = ByteString::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x"));
if (FileSystem::exists(bitmap_path_32)) {
auto bitmap_or_error = Gfx::Bitmap::load_from_file(bitmap_path_32);
@ -61,11 +61,11 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(DeprecatedString con
return adopt_ref(*new ProjectTemplate(id, name, description, icon, priority));
}
Result<void, DeprecatedString> ProjectTemplate::create_project(DeprecatedString const& name, DeprecatedString const& path)
Result<void, ByteString> ProjectTemplate::create_project(ByteString const& name, ByteString const& path)
{
// Check if a file or directory already exists at the project path
if (FileSystem::exists(path))
return DeprecatedString("File or directory already exists at specified location.");
return ByteString("File or directory already exists at specified location.");
dbgln("Creating project at path '{}' with name '{}'", path, name);
@ -75,19 +75,19 @@ Result<void, DeprecatedString> ProjectTemplate::create_project(DeprecatedString
auto result = FileSystem::copy_file_or_directory(path, content_path());
dbgln("Copying {} -> {}", content_path(), path);
if (result.is_error())
return DeprecatedString::formatted("Failed to copy template contents. Error code: {}", static_cast<Error const&>(result.error()));
return ByteString::formatted("Failed to copy template contents. Error code: {}", static_cast<Error const&>(result.error()));
} else {
dbgln("No template content directory found for '{}', creating an empty directory for the project.", m_id);
int rc;
if ((rc = mkdir(path.characters(), 0755)) < 0) {
return DeprecatedString::formatted("Failed to mkdir empty project directory, error: {}, rc: {}.", strerror(errno), rc);
return ByteString::formatted("Failed to mkdir empty project directory, error: {}, rc: {}.", strerror(errno), rc);
}
}
// Check for an executable post-create script in $TEMPLATES_DIR/$ID.postcreate,
// and run it with the path and name
auto postcreate_script_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}.postcreate", templates_path(), m_id));
auto postcreate_script_path = LexicalPath::canonicalized_path(ByteString::formatted("{}/{}.postcreate", templates_path(), m_id));
struct stat postcreate_st;
int result = stat(postcreate_script_path.characters(), &postcreate_st);
if (result == 0 && (postcreate_st.st_mode & S_IXOTH) == S_IXOTH) {
@ -101,19 +101,19 @@ Result<void, DeprecatedString> ProjectTemplate::create_project(DeprecatedString
if ((errno = posix_spawn(&child_pid, postcreate_script_path.characters(), nullptr, nullptr, const_cast<char**>(argv), environ))) {
perror("posix_spawn");
return DeprecatedString("Failed to spawn project post-create script.");
return ByteString("Failed to spawn project post-create script.");
}
// Command spawned, wait for exit.
int status;
if (waitpid(child_pid, &status, 0) < 0)
return DeprecatedString("Failed to spawn project post-create script.");
return ByteString("Failed to spawn project post-create script.");
int child_error = WEXITSTATUS(status);
dbgln("Post-create script exited with code {}", child_error);
if (child_error != 0)
return DeprecatedString("Project post-creation script exited with non-zero error code.");
return ByteString("Project post-creation script exited with non-zero error code.");
}
return {};

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/LexicalPath.h>
#include <AK/RefCounted.h>
#include <AK/Result.h>
@ -18,28 +18,28 @@ namespace HackStudio {
class ProjectTemplate : public RefCounted<ProjectTemplate> {
public:
static DeprecatedString templates_path() { return "/res/devel/templates"; }
static ByteString templates_path() { return "/res/devel/templates"; }
static RefPtr<ProjectTemplate> load_from_manifest(DeprecatedString const& manifest_path);
static RefPtr<ProjectTemplate> load_from_manifest(ByteString const& manifest_path);
explicit ProjectTemplate(DeprecatedString const& id, DeprecatedString const& name, DeprecatedString const& description, const GUI::Icon& icon, int priority);
explicit ProjectTemplate(ByteString const& id, ByteString const& name, ByteString const& description, const GUI::Icon& icon, int priority);
Result<void, DeprecatedString> create_project(DeprecatedString const& name, DeprecatedString const& path);
Result<void, ByteString> create_project(ByteString const& name, ByteString const& path);
DeprecatedString const& id() const { return m_id; }
DeprecatedString const& name() const { return m_name; }
DeprecatedString const& description() const { return m_description; }
ByteString const& id() const { return m_id; }
ByteString const& name() const { return m_name; }
ByteString const& description() const { return m_description; }
const GUI::Icon& icon() const { return m_icon; }
const DeprecatedString content_path() const
const ByteString content_path() const
{
return LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", templates_path(), m_id));
return LexicalPath::canonicalized_path(ByteString::formatted("{}/{}", templates_path(), m_id));
}
int priority() const { return m_priority; }
private:
DeprecatedString m_id;
DeprecatedString m_name;
DeprecatedString m_description;
ByteString m_id;
ByteString m_name;
ByteString m_description;
GUI::Icon m_icon;
int m_priority { 0 };
};

View file

@ -6,7 +6,7 @@
*/
#include "TerminalWrapper.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibCore/System.h>
#include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h>
@ -24,7 +24,7 @@
namespace HackStudio {
ErrorOr<void> TerminalWrapper::run_command(DeprecatedString const& command, Optional<DeprecatedString> working_directory, WaitForExit wait_for_exit, Optional<StringView> failure_message)
ErrorOr<void> TerminalWrapper::run_command(ByteString const& command, Optional<ByteString> working_directory, WaitForExit wait_for_exit, Optional<StringView> failure_message)
{
if (m_pid != -1) {
GUI::MessageBox::show(window(),
@ -92,11 +92,11 @@ ErrorOr<int> TerminalWrapper::setup_master_pseudoterminal(WaitForChildOnExit wai
int wstatus = result.release_value().status;
if (WIFEXITED(wstatus)) {
m_terminal_widget->inject_string(DeprecatedString::formatted("\033[{};1m(Command exited with code {})\033[0m\r\n", wstatus == 0 ? 32 : 31, WEXITSTATUS(wstatus)));
m_terminal_widget->inject_string(ByteString::formatted("\033[{};1m(Command exited with code {})\033[0m\r\n", wstatus == 0 ? 32 : 31, WEXITSTATUS(wstatus)));
} else if (WIFSTOPPED(wstatus)) {
m_terminal_widget->inject_string("\033[34;1m(Command stopped!)\033[0m\r\n"sv);
} else if (WIFSIGNALED(wstatus)) {
m_terminal_widget->inject_string(DeprecatedString::formatted("\033[34;1m(Command signaled with {}!)\033[0m\r\n", strsignal(WTERMSIG(wstatus))));
m_terminal_widget->inject_string(ByteString::formatted("\033[34;1m(Command signaled with {}!)\033[0m\r\n", strsignal(WTERMSIG(wstatus))));
}
m_child_exit_status = WEXITSTATUS(wstatus);

View file

@ -21,7 +21,7 @@ public:
No,
Yes
};
ErrorOr<void> run_command(DeprecatedString const&, Optional<DeprecatedString> working_directory = {}, WaitForExit = WaitForExit::No, Optional<StringView> failure_message = {});
ErrorOr<void> run_command(ByteString const&, Optional<ByteString> working_directory = {}, WaitForExit = WaitForExit::No, Optional<StringView> failure_message = {});
ErrorOr<void> kill_running_command();
void clear_including_history();

View file

@ -14,7 +14,7 @@ ToDoEntries& HackStudio::ToDoEntries::the()
return s_instance;
}
void ToDoEntries::set_entries(DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry> const&& entries)
void ToDoEntries::set_entries(ByteString const& filename, Vector<CodeComprehension::TodoEntry> const&& entries)
{
m_document_to_entries.set(filename, move(entries));
if (on_update)

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Function.h>
#include <AK/HashMap.h>
#include <AK/Noncopyable.h>
@ -20,7 +20,7 @@ class ToDoEntries {
public:
static ToDoEntries& the();
void set_entries(DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry> const&& entries);
void set_entries(ByteString const& filename, Vector<CodeComprehension::TodoEntry> const&& entries);
Vector<CodeComprehension::TodoEntry> get_entries();
@ -30,7 +30,7 @@ public:
private:
ToDoEntries() = default;
HashMap<DeprecatedString, Vector<CodeComprehension::TodoEntry>> m_document_to_entries;
HashMap<ByteString, Vector<CodeComprehension::TodoEntry>> m_document_to_entries;
};
}

View file

@ -63,9 +63,9 @@ public:
case Column::Text:
return match.content;
case Column::Line:
return DeprecatedString::formatted("{}", match.line + 1);
return ByteString::formatted("{}", match.line + 1);
case Column::Column:
return DeprecatedString::formatted("{}", match.column);
return ByteString::formatted("{}", match.column);
}
}
return {};

View file

@ -33,7 +33,7 @@ static WeakPtr<HackStudioWidget> s_hack_studio_widget;
static bool make_is_available();
static ErrorOr<void> notify_make_not_available();
static void update_path_environment_variable();
static Optional<DeprecatedString> last_opened_project_path();
static Optional<ByteString> last_opened_project_path();
static ErrorOr<NonnullRefPtr<HackStudioWidget>> create_hack_studio_widget(bool mode_coredump, StringView path, pid_t pid_to_debug);
ErrorOr<int> serenity_main(Main::Arguments arguments)
@ -68,7 +68,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_main_widget(hack_studio_widget);
s_hack_studio_widget = hack_studio_widget;
window->set_title(DeprecatedString::formatted("{} - Hack Studio", hack_studio_widget->project().name()));
window->set_title(ByteString::formatted("{} - Hack Studio", hack_studio_widget->project().name()));
TRY(hack_studio_widget->initialize_menubar(*window));
@ -131,10 +131,10 @@ static void update_path_environment_variable()
if (path.length())
path.append(':');
path.append(DEFAULT_PATH_SV);
setenv("PATH", path.to_deprecated_string().characters(), true);
setenv("PATH", path.to_byte_string().characters(), true);
}
static Optional<DeprecatedString> last_opened_project_path()
static Optional<ByteString> last_opened_project_path()
{
auto projects = HackStudioWidget::read_recent_projects();
if (projects.size() == 0)
@ -153,12 +153,12 @@ GUI::TextEditor& current_editor()
return s_hack_studio_widget->current_editor();
}
void open_file(DeprecatedString const& filename)
void open_file(ByteString const& filename)
{
s_hack_studio_widget->open_file(filename);
}
void open_file(DeprecatedString const& filename, size_t line, size_t column)
void open_file(ByteString const& filename, size_t line, size_t column)
{
s_hack_studio_widget->open_file(filename, line, column);
}
@ -175,7 +175,7 @@ Project& project()
return s_hack_studio_widget->project();
}
DeprecatedString currently_open_file()
ByteString currently_open_file()
{
if (!s_hack_studio_widget)
return {};
@ -212,16 +212,16 @@ bool semantic_syntax_highlighting_is_enabled()
static ErrorOr<NonnullRefPtr<HackStudioWidget>> create_hack_studio_widget(bool mode_coredump, StringView raw_path_argument, pid_t pid_to_debug)
{
DeprecatedString project_path;
ByteString project_path;
if (pid_to_debug != -1 || mode_coredump)
project_path = "/usr/src/serenity";
else if (!raw_path_argument.is_null())
// FIXME: Validation is unintentional, and should be removed when migrating to String.
project_path = TRY(DeprecatedString::from_utf8(raw_path_argument));
project_path = TRY(ByteString::from_utf8(raw_path_argument));
else if (auto last_path = last_opened_project_path(); last_path.has_value())
project_path = last_path.release_value();
else
project_path = TRY(FileSystem::real_path("."sv)).to_deprecated_string();
project_path = TRY(FileSystem::real_path("."sv)).to_byte_string();
return HackStudioWidget::create(project_path);
}

View file

@ -51,7 +51,7 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node)
if (elf == nullptr)
return;
if (g_kernel_debug_info == nullptr)
g_kernel_debug_info = make<Debug::DebugInfo>(g_kernel_debuginfo_object->elf, DeprecatedString::empty(), base_address);
g_kernel_debug_info = make<Debug::DebugInfo>(g_kernel_debuginfo_object->elf, ByteString::empty(), base_address);
debug_info = g_kernel_debug_info.ptr();
} else {
auto const& process = node.process();
@ -114,7 +114,7 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node)
break;
FlatPtr address_in_profiled_program = node.address() + offset_into_symbol;
auto disassembly = insn.value().to_deprecated_string(address_in_profiled_program, &symbol_provider);
auto disassembly = insn.value().to_byte_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);
@ -200,14 +200,14 @@ GUI::Variant DisassemblyModel::data(GUI::ModelIndex const& index, GUI::ModelRole
}
if (index.column() == Column::Address)
return DeprecatedString::formatted("{:p}", insn.address);
return ByteString::formatted("{:p}", insn.address);
if (index.column() == Column::InstructionBytes) {
StringBuilder builder;
for (auto ch : insn.bytes) {
builder.appendff("{:02x} ", (u8)ch);
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
if (index.column() == Column::Disassembly)
@ -229,7 +229,7 @@ GUI::Variant DisassemblyModel::data(GUI::ModelIndex const& index, GUI::ModelRole
auto const& entry = insn.source_position_with_inlines.source_position.value();
builder.appendff("{}:{}", entry.file_path, entry.line_number);
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
return {};

View file

@ -18,7 +18,7 @@ class ProfileNode;
struct InstructionData {
X86::Instruction insn;
DeprecatedString disassembly;
ByteString disassembly;
StringView bytes;
FlatPtr address { 0 };
u32 event_count { 0 };

View file

@ -32,7 +32,7 @@ Duration FileEventNode::total_duration() const
return m_open.duration + m_close.duration + m_readv.duration + m_read.duration + m_pread.duration;
}
FileEventNode& FileEventNode::find_or_create_node(DeprecatedString const& searched_path)
FileEventNode& FileEventNode::find_or_create_node(ByteString const& searched_path)
{
// TODO: Optimize this function.
if (searched_path == ""sv || searched_path == "/"sv) {
@ -45,7 +45,7 @@ FileEventNode& FileEventNode::find_or_create_node(DeprecatedString const& search
StringBuilder sb;
sb.join('/', parts);
auto new_s = sb.to_deprecated_string();
auto new_s = sb.to_byte_string();
for (auto& child : m_children) {
if (child->m_path == current) {
@ -70,7 +70,7 @@ FileEventNode& FileEventNode::find_or_create_node(DeprecatedString const& search
}
}
FileEventNode& FileEventNode::create_recursively(DeprecatedString new_path)
FileEventNode& FileEventNode::create_recursively(ByteString new_path)
{
auto const lex_path = LexicalPath(new_path);
auto parts = lex_path.parts();
@ -86,7 +86,7 @@ FileEventNode& FileEventNode::create_recursively(DeprecatedString new_path)
StringBuilder sb;
sb.join('/', parts);
return new_node->create_recursively(sb.to_deprecated_string());
return new_node->create_recursively(sb.to_byte_string());
}
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Function.h>
#include <AK/LexicalPath.h>
#include <AK/Time.h>
@ -18,23 +18,23 @@ class Profile;
class FileEventNode : public RefCounted<FileEventNode> {
public:
static NonnullRefPtr<FileEventNode> create(DeprecatedString const& path, FileEventNode* parent = nullptr)
static NonnullRefPtr<FileEventNode> create(ByteString const& path, FileEventNode* parent = nullptr)
{
return adopt_ref(*new FileEventNode(path, parent));
}
FileEventNode& find_or_create_node(DeprecatedString const&);
FileEventNode& find_or_create_node(ByteString const&);
Vector<NonnullRefPtr<FileEventNode>>& children() { return m_children; }
Vector<NonnullRefPtr<FileEventNode>> const& children() const { return m_children; }
FileEventNode* parent() { return m_parent; }
FileEventNode& create_recursively(DeprecatedString);
FileEventNode& create_recursively(ByteString);
void for_each_parent_node(Function<void(FileEventNode&)> callback);
DeprecatedString const& path() const { return m_path; }
ByteString const& path() const { return m_path; }
u64 total_count() const;
Duration total_duration() const;
@ -51,11 +51,11 @@ public:
FileEventType& pread() { return m_pread; }
private:
FileEventNode(DeprecatedString const& path, FileEventNode* parent = nullptr)
FileEventNode(ByteString const& path, FileEventNode* parent = nullptr)
: m_path(path)
, m_parent(parent) {};
DeprecatedString m_path;
ByteString m_path;
FileEventType m_open;
FileEventType m_close;

View file

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

View file

@ -50,7 +50,7 @@ GUI::Variant IndividualSampleModel::data(GUI::ModelIndex const& index, GUI::Mode
if (role == GUI::ModelRole::Display) {
if (index.column() == Column::Address)
return DeprecatedString::formatted("{:p}", frame.address);
return ByteString::formatted("{:p}", frame.address);
if (index.column() == Column::Symbol) {
return frame.symbol;

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/IntegralMath.h>
#include <AK/Math.h>
@ -16,10 +16,10 @@ namespace Profiler {
static constexpr int const number_of_percent_digits = 2;
static constexpr int const percent_digits_rounding = AK::pow(10, number_of_percent_digits);
DeprecatedString format_percentage(auto value, auto total)
ByteString format_percentage(auto value, auto total)
{
auto percentage_full_precision = round_to<u64>(value * 100.f / total * percent_digits_rounding);
return DeprecatedString::formatted(
return ByteString::formatted(
"{}.{:02}",
percentage_full_precision / percent_digits_rounding,
percentage_full_precision % percent_digits_rounding);

View file

@ -41,9 +41,9 @@ void Process::handle_thread_exit(pid_t tid, EventSerialNumber serial)
thread->end_valid = serial;
}
HashMap<DeprecatedString, OwnPtr<MappedObject>> g_mapped_object_cache;
HashMap<ByteString, OwnPtr<MappedObject>> g_mapped_object_cache;
static MappedObject* get_or_create_mapped_object(DeprecatedString const& path)
static MappedObject* get_or_create_mapped_object(ByteString const& path)
{
if (auto it = g_mapped_object_cache.find(path); it != g_mapped_object_cache.end())
return it->value.ptr();
@ -67,7 +67,7 @@ static MappedObject* get_or_create_mapped_object(DeprecatedString const& path)
return ptr;
}
void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, DeprecatedString const& name)
void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, ByteString const& name)
{
StringView path;
if (name.contains("Loader.so"sv))
@ -82,25 +82,25 @@ void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, DeprecatedString co
// associated base address and size as new regions are discovered.
// We don't allocate a temporary String object if an entry already exists.
// This assumes that DeprecatedString::hash and StringView::hash return the same result.
// This assumes that ByteString::hash and StringView::hash return the same result.
auto string_view_compare = [&path](auto& entry) { return path == entry.key.view(); };
if (auto existing_it = m_libraries.find(path.hash(), string_view_compare); existing_it != m_libraries.end()) {
auto& entry = *existing_it->value;
entry.base = min(entry.base, base);
entry.size = max(entry.size + size, base - entry.base + size);
} else {
DeprecatedString path_string = path.to_deprecated_string();
DeprecatedString full_path;
ByteString path_string = path.to_byte_string();
ByteString full_path;
if (path_string.starts_with('/'))
full_path = path_string;
else if (FileSystem::looks_like_shared_library(path_string))
full_path = DeprecatedString::formatted("/usr/lib/{}", path);
full_path = ByteString::formatted("/usr/lib/{}", path);
else
full_path = path_string;
auto* mapped_object = get_or_create_mapped_object(full_path);
if (!mapped_object) {
full_path = DeprecatedString::formatted("/usr/local/lib/{}", path);
full_path = ByteString::formatted("/usr/local/lib/{}", path);
mapped_object = get_or_create_mapped_object(full_path);
if (!mapped_object)
return;
@ -112,14 +112,14 @@ void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, DeprecatedString co
Debug::DebugInfo const& LibraryMetadata::Library::load_debug_info(FlatPtr base_address) const
{
if (debug_info == nullptr)
debug_info = make<Debug::DebugInfo>(object->elf, DeprecatedString::empty(), base_address);
debug_info = make<Debug::DebugInfo>(object->elf, ByteString::empty(), base_address);
return *debug_info.ptr();
}
DeprecatedString LibraryMetadata::Library::symbolicate(FlatPtr ptr, u32* offset) const
ByteString LibraryMetadata::Library::symbolicate(FlatPtr ptr, u32* offset) const
{
if (!object)
return DeprecatedString::formatted("?? <{:p}>", ptr);
return ByteString::formatted("?? <{:p}>", ptr);
return object->elf.symbolicate(ptr - base, offset);
}

View file

@ -21,27 +21,27 @@ struct MappedObject {
ELF::Image elf;
};
extern HashMap<DeprecatedString, OwnPtr<MappedObject>> g_mapped_object_cache;
extern HashMap<ByteString, OwnPtr<MappedObject>> g_mapped_object_cache;
class LibraryMetadata {
public:
struct Library {
FlatPtr base;
size_t size;
DeprecatedString name;
ByteString name;
MappedObject* object { nullptr };
// This is loaded lazily because we only need it in disassembly view
mutable OwnPtr<Debug::DebugInfo> debug_info;
DeprecatedString symbolicate(FlatPtr, u32* offset) const;
ByteString symbolicate(FlatPtr, u32* offset) const;
Debug::DebugInfo const& load_debug_info(FlatPtr base_address) const;
};
void handle_mmap(FlatPtr base, size_t size, DeprecatedString const& name);
void handle_mmap(FlatPtr base, size_t size, ByteString const& name);
Library const* library_containing(FlatPtr) const;
private:
mutable HashMap<DeprecatedString, NonnullOwnPtr<Library>> m_libraries;
mutable HashMap<ByteString, NonnullOwnPtr<Library>> m_libraries;
};
struct Thread {
@ -57,8 +57,8 @@ struct Thread {
struct Process {
pid_t pid {};
DeprecatedString executable;
DeprecatedString basename;
ByteString executable;
ByteString basename;
HashMap<int, Vector<Thread>> threads {};
LibraryMetadata library_metadata {};
EventSerialNumber start_valid;

View file

@ -289,10 +289,10 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
return Error::from_string_literal("Malformed profile (strings is not an array)");
auto const& strings = strings_value.value();
HashMap<FlatPtr, DeprecatedString> profile_strings;
HashMap<FlatPtr, ByteString> profile_strings;
for (FlatPtr string_id = 0; string_id < strings.size(); ++string_id) {
auto const& value = strings.at(string_id);
profile_strings.set(string_id, value.to_deprecated_string());
profile_strings.set(string_id, value.to_byte_string());
}
auto events_value = object.get_array("events"sv);
@ -317,7 +317,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
event.pid = perf_event.get_i32("pid"sv).value_or(0);
event.tid = perf_event.get_i32("tid"sv).value_or(0);
auto type_string = perf_event.get_deprecated_string("type"sv).value_or({});
auto type_string = perf_event.get_byte_string("type"sv).value_or({});
if (type_string == "sample"sv) {
event.data = Event::SampleData {};
@ -333,13 +333,13 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
} else if (type_string == "signpost"sv) {
auto string_id = perf_event.get_addr("arg1"sv).value_or(0);
event.data = Event::SignpostData {
.string = profile_strings.get(string_id).value_or(DeprecatedString::formatted("Signpost #{}", string_id)),
.string = profile_strings.get(string_id).value_or(ByteString::formatted("Signpost #{}", string_id)),
.arg = perf_event.get_addr("arg2"sv).value_or(0),
};
} else if (type_string == "mmap"sv) {
auto ptr = perf_event.get_addr("ptr"sv).value_or(0);
auto size = perf_event.get_integer<size_t>("size"sv).value_or(0);
auto name = perf_event.get_deprecated_string("name"sv).value_or({});
auto name = perf_event.get_byte_string("name"sv).value_or({});
event.data = Event::MmapData {
.ptr = ptr,
@ -359,7 +359,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_integer<pid_t>("parent_pid"sv).value_or(0);
auto executable = perf_event.get_deprecated_string("executable"sv).value_or({});
auto executable = perf_event.get_byte_string("executable"sv).value_or({});
event.data = Event::ProcessCreateData {
.parent_pid = parent_pid,
.executable = executable,
@ -377,7 +377,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_deprecated_string("executable"sv).value_or({});
auto executable = perf_event.get_byte_string("executable"sv).value_or({});
event.data = Event::ProcessExecData {
.executable = executable,
};
@ -482,13 +482,13 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
auto ptr = frame.to_number<u64>();
u32 offset = 0;
DeprecatedFlyString object_name;
DeprecatedString symbol;
ByteString symbol;
if (maybe_kernel_base.has_value() && ptr >= maybe_kernel_base.value()) {
if (g_kernel_debuginfo_object.has_value()) {
symbol = g_kernel_debuginfo_object->elf.symbolicate(ptr - maybe_kernel_base.value(), &offset);
} else {
symbol = DeprecatedString::formatted("?? <{:p}>", ptr);
symbol = ByteString::formatted("?? <{:p}>", ptr);
}
} else {
auto it = current_processes.find(event.pid);
@ -500,7 +500,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
object_name = library->name;
symbol = library->symbolicate(ptr, &offset);
} else {
symbol = DeprecatedString::formatted("?? <{:p}>", ptr);
symbol = ByteString::formatted("?? <{:p}>", ptr);
}
}
@ -681,7 +681,7 @@ ProfileNode::ProfileNode(Process const& process)
{
}
ProfileNode::ProfileNode(Process const& process, DeprecatedFlyString const& object_name, DeprecatedString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid)
ProfileNode::ProfileNode(Process const& process, DeprecatedFlyString const& object_name, ByteString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid)
: m_process(process)
, m_symbol(move(symbol))
, m_pid(pid)
@ -689,7 +689,7 @@ ProfileNode::ProfileNode(Process const& process, DeprecatedFlyString const& obje
, m_offset(offset)
, m_timestamp(timestamp)
{
DeprecatedString object;
ByteString object;
if (object_name.ends_with(": .text"sv)) {
object = object_name.view().substring_view(0, object_name.length() - 7);
} else {

View file

@ -35,7 +35,7 @@ extern OwnPtr<Debug::DebugInfo> g_kernel_debug_info;
class ProfileNode : public RefCounted<ProfileNode> {
public:
static NonnullRefPtr<ProfileNode> create(Process const& process, DeprecatedFlyString const& object_name, DeprecatedString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid)
static NonnullRefPtr<ProfileNode> create(Process const& process, DeprecatedFlyString const& object_name, ByteString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid)
{
return adopt_ref(*new ProfileNode(process, object_name, move(symbol), address, offset, timestamp, pid));
}
@ -55,7 +55,7 @@ public:
void did_see_event(size_t event_index) { m_seen_events.set(event_index, true); }
DeprecatedFlyString const& object_name() const { return m_object_name; }
DeprecatedString const& symbol() const { return m_symbol; }
ByteString const& symbol() const { return m_symbol; }
FlatPtr address() const { return m_address; }
u32 offset() const { return m_offset; }
u64 timestamp() const { return m_timestamp; }
@ -75,7 +75,7 @@ public:
m_children.append(child);
}
ProfileNode& find_or_create_child(DeprecatedFlyString const& object_name, DeprecatedString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid)
ProfileNode& find_or_create_child(DeprecatedFlyString const& object_name, ByteString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid)
{
for (size_t i = 0; i < m_children.size(); ++i) {
auto& child = m_children[i];
@ -113,13 +113,13 @@ public:
private:
explicit ProfileNode(Process const&);
explicit ProfileNode(Process const&, DeprecatedFlyString const& object_name, DeprecatedString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t);
explicit ProfileNode(Process const&, DeprecatedFlyString const& object_name, ByteString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t);
bool m_root { false };
Process const& m_process;
ProfileNode* m_parent { nullptr };
DeprecatedFlyString m_object_name;
DeprecatedString m_symbol;
ByteString m_symbol;
pid_t m_pid { 0 };
FlatPtr m_address { 0 };
u32 m_offset { 0 };
@ -168,7 +168,7 @@ public:
struct Frame {
DeprecatedFlyString object_name;
DeprecatedString symbol;
ByteString symbol;
FlatPtr address { 0 };
u32 offset { 0 };
};
@ -196,14 +196,14 @@ public:
};
struct SignpostData {
DeprecatedString string;
ByteString string;
FlatPtr arg {};
};
struct MmapData {
FlatPtr ptr {};
size_t size {};
DeprecatedString name;
ByteString name;
};
struct MunmapData {
@ -213,11 +213,11 @@ public:
struct ProcessCreateData {
pid_t parent_pid { 0 };
DeprecatedString executable;
ByteString executable;
};
struct ProcessExecData {
DeprecatedString executable;
ByteString executable;
};
struct ThreadCreateData {
@ -227,31 +227,31 @@ public:
// Based on Syscall::SC_open_params
struct OpenEventData {
int dirfd;
DeprecatedString path;
ByteString path;
int options;
u64 mode;
};
struct CloseEventData {
int fd;
DeprecatedString path;
ByteString path;
};
struct ReadvEventData {
int fd;
DeprecatedString path;
ByteString path;
// struct iovec* iov; // TODO: Implement
// int iov_count; // TODO: Implement
};
struct ReadEventData {
int fd;
DeprecatedString path;
ByteString path;
};
struct PreadEventData {
int fd;
DeprecatedString path;
ByteString path;
FlatPtr buffer_ptr;
size_t size;
off_t offset;

View file

@ -126,7 +126,7 @@ GUI::Variant ProfileModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
return node->object_name();
if (index.column() == Column::StackFrame) {
if (node->is_root()) {
return DeprecatedString::formatted("{} ({})", node->process().basename, node->process().pid);
return ByteString::formatted("{} ({})", node->process().basename, node->process().pid);
}
return node->symbol();
}
@ -136,7 +136,7 @@ GUI::Variant ProfileModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
auto const* library = node->process().library_metadata.library_containing(node->address());
if (!library)
return "";
return DeprecatedString::formatted("{:p} (offset {:p})", node->address(), node->address() - library->base);
return ByteString::formatted("{:p} (offset {:p})", node->address(), node->address() - library->base);
}
return {};
}

View file

@ -17,7 +17,7 @@ namespace Profiler {
class SourceFile final {
public:
struct Line {
DeprecatedString content;
ByteString content;
size_t num_samples { 0 };
};
@ -25,7 +25,7 @@ public:
SourceFile(StringView filename)
{
DeprecatedString source_file_name = filename.replace("../../"sv, source_root_path, ReplaceMode::FirstOnly);
ByteString source_file_name = filename.replace("../../"sv, source_root_path, ReplaceMode::FirstOnly);
auto try_read_lines = [&]() -> ErrorOr<void> {
auto unbuffered_file = TRY(Core::File::open(source_file_name, Core::File::OpenMode::Read));
@ -70,7 +70,7 @@ SourceModel::SourceModel(Profile& profile, ProfileNode& node)
return;
base_address = maybe_kernel_base.release_value();
if (g_kernel_debug_info == nullptr)
g_kernel_debug_info = make<Debug::DebugInfo>(g_kernel_debuginfo_object->elf, DeprecatedString::empty(), base_address);
g_kernel_debug_info = make<Debug::DebugInfo>(g_kernel_debuginfo_object->elf, ByteString::empty(), base_address);
debug_info = g_kernel_debug_info.ptr();
} else {
auto const& process = node.process();
@ -86,7 +86,7 @@ SourceModel::SourceModel(Profile& profile, ProfileNode& node)
VERIFY(debug_info != nullptr);
// Try to read all source files contributing to the selected function and aggregate the samples by line.
HashMap<DeprecatedString, SourceFile> source_files;
HashMap<ByteString, SourceFile> source_files;
for (auto const& pair : node.events_per_address()) {
auto position = debug_info->get_source_position(pair.key - base_address);
if (position.has_value()) {

View file

@ -16,9 +16,9 @@ class ProfileNode;
struct SourceLineData {
u32 event_count { 0 };
float percent { 0 };
DeprecatedString location;
ByteString location;
u32 line_number { 0 };
DeprecatedString source_code;
ByteString source_code;
};
class SourceModel final : public GUI::Model {

View file

@ -24,7 +24,7 @@ TimelineHeader::TimelineHeader(Profile& profile, Process const& process)
update_selection();
m_icon = GUI::FileIconProvider::icon_for_executable(m_process.executable).bitmap_for_size(32);
m_text = DeprecatedString::formatted("{} ({})", LexicalPath::basename(m_process.executable), m_process.pid);
m_text = ByteString::formatted("{} ({})", LexicalPath::basename(m_process.executable), m_process.pid);
}
void TimelineHeader::paint_event(GUI::PaintEvent& event)

View file

@ -33,7 +33,7 @@ private:
Profile& m_profile;
Process const& m_process;
RefPtr<Gfx::Bitmap const> m_icon;
DeprecatedString m_text;
ByteString m_text;
bool m_selected;
};

View file

@ -62,18 +62,18 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app = TRY(GUI::Application::create(arguments));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-profiler"sv));
DeprecatedString perfcore_file;
ByteString perfcore_file;
if (perfcore_file_arg.is_empty()) {
if (!generate_profile(pid))
return 0;
perfcore_file = DeprecatedString::formatted("/proc/{}/perf_events", pid);
perfcore_file = ByteString::formatted("/proc/{}/perf_events", pid);
} else {
perfcore_file = perfcore_file_arg;
}
auto profile_or_error = Profile::load_from_perfcore_file(perfcore_file);
if (profile_or_error.is_error()) {
GUI::MessageBox::show(nullptr, DeprecatedString::formatted("{}", profile_or_error.error()), "Profiler"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(nullptr, ByteString::formatted("{}", profile_or_error.error()), "Profiler"sv, GUI::MessageBox::Type::Error);
return 0;
}
@ -224,8 +224,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
// FIXME: Make this constexpr once String is able to.
auto const format_sample_count = [&profile](auto const sample_count) {
if (profile->show_percentages())
return DeprecatedString::formatted("{}%", sample_count.as_string());
return DeprecatedString::formatted("{} Samples", sample_count.to_i32());
return ByteString::formatted("{}%", sample_count.as_string());
return ByteString::formatted("{} Samples", sample_count.to_i32());
};
auto& statusbar = main_widget->add<GUI::Statusbar>();
@ -235,7 +235,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_deprecated_string();
auto stack = profile->model().data(flamegraph_hovered_index.sibling_at_column(ProfileModel::Column::StackFrame)).to_byte_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);
@ -312,10 +312,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return app->exec();
}
static bool prompt_to_stop_profiling(pid_t pid, DeprecatedString const& process_name)
static bool prompt_to_stop_profiling(pid_t pid, ByteString const& process_name)
{
auto window = GUI::Window::construct();
window->set_title(DeprecatedString::formatted("Profiling {}({})", process_name, pid));
window->set_title(ByteString::formatted("Profiling {}({})", process_name, pid));
window->resize(240, 100);
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-profiler.png"sv).release_value_but_fixme_should_propagate_errors());
window->center_on_screen();
@ -351,7 +351,7 @@ bool generate_profile(pid_t& pid)
pid = process_chooser->pid();
}
DeprecatedString process_name;
ByteString process_name;
auto all_processes = Core::ProcessStatisticsReader::get_all();
if (!all_processes.is_error()) {
@ -369,7 +369,7 @@ bool generate_profile(pid_t& pid)
if (profiling_enable(pid, event_mask) < 0) {
int saved_errno = errno;
GUI::MessageBox::show(nullptr, DeprecatedString::formatted("Unable to profile process {}({}): {}", process_name, pid, strerror(saved_errno)), "Profiler"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(nullptr, ByteString::formatted("Unable to profile process {}({}): {}", process_name, pid, strerror(saved_errno)), "Profiler"sv, GUI::MessageBox::Type::Error);
return false;
}

View file

@ -41,16 +41,16 @@ REGISTER_WIDGET(SQLStudio, MainWidget);
namespace SQLStudio {
static Vector<DeprecatedString> lookup_database_names()
static Vector<ByteString> lookup_database_names()
{
static constexpr auto database_extension = ".db"sv;
auto database_path = DeprecatedString::formatted("{}/sql", Core::StandardPaths::data_directory());
auto database_path = ByteString::formatted("{}/sql", Core::StandardPaths::data_directory());
if (!FileSystem::exists(database_path))
return {};
Core::DirIterator iterator(move(database_path), Core::DirIterator::SkipParentAndBaseDir);
Vector<DeprecatedString> database_names;
Vector<ByteString> database_names;
while (iterator.has_next()) {
if (auto database = iterator.next_path(); database.ends_with(database_extension))
@ -86,7 +86,7 @@ ErrorOr<void> MainWidget::setup()
VERIFY(editor);
if (auto result = editor->save(); result.is_error())
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save {}\n{}", editor->path(), result.error()));
GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to save {}\n{}", editor->path(), result.error()));
});
m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) {
@ -94,7 +94,7 @@ ErrorOr<void> MainWidget::setup()
VERIFY(editor);
if (auto result = editor->save_as(); result.is_error())
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save {}\n{}", editor->path(), result.error()));
GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to save {}\n{}", editor->path(), result.error()));
});
m_save_all_action = GUI::Action::create("Save All", { Mod_Ctrl | Mod_Alt, Key_S }, [this](auto&) {
@ -106,7 +106,7 @@ ErrorOr<void> MainWidget::setup()
m_tab_widget->set_active_widget(&editor);
if (auto result = editor.save(); result.is_error()) {
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save {}\n{}", editor.path(), result.error()));
GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to save {}\n{}", editor.path(), result.error()));
return IterationDecision::Break;
} else if (!result.value()) {
return IterationDecision::Break;
@ -176,7 +176,7 @@ ErrorOr<void> MainWidget::setup()
m_connection_id = *connection_id;
m_run_script_action->set_enabled(true);
} else {
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Could not connect to {}", database_name));
GUI::MessageBox::show_error(window(), ByteString::formatted("Could not connect to {}", database_name));
}
});
@ -191,7 +191,7 @@ ErrorOr<void> MainWidget::setup()
m_databases_combo_box = GUI::ComboBox::construct();
m_databases_combo_box->set_editor_placeholder("Enter new database or select existing database"sv);
m_databases_combo_box->set_max_width(font().width(m_databases_combo_box->editor_placeholder()) + font().max_glyph_width() + 16);
m_databases_combo_box->set_model(*GUI::ItemListModel<DeprecatedString>::create(database_names));
m_databases_combo_box->set_model(*GUI::ItemListModel<ByteString>::create(database_names));
m_databases_combo_box->on_return_pressed = [this]() {
m_connect_to_database_action->activate(m_databases_combo_box);
};
@ -220,7 +220,7 @@ ErrorOr<void> MainWidget::setup()
auto& editor = verify_cast<ScriptEditor>(widget);
if (auto result = editor.attempt_to_close(); result.is_error()) {
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save {}\n{}", editor.path(), result.error()));
GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to save {}\n{}", editor.path(), result.error()));
} else if (result.value()) {
m_tab_widget->remove_tab(editor);
update_title();
@ -266,14 +266,14 @@ ErrorOr<void> MainWidget::setup()
auto* editor = active_editor();
VERIFY(editor);
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Error executing {}\n{}", editor->path(), result.error_message));
GUI::MessageBox::show_error(window(), ByteString::formatted("Error executing {}\n{}", editor->path(), result.error_message));
};
m_sql_client->on_next_result = [this](auto result) {
m_results.append({});
m_results.last().ensure_capacity(result.values.size());
for (auto const& value : result.values)
m_results.last().unchecked_append(value.to_deprecated_string());
m_results.last().unchecked_append(value.to_byte_string());
};
m_sql_client->on_results_exhausted = [this](auto) {
if (m_results.size() == 0)
@ -283,7 +283,7 @@ ErrorOr<void> MainWidget::setup()
Vector<GUI::JsonArrayModel::FieldSpec> query_result_fields;
for (auto& column_name : m_result_column_names)
query_result_fields.empend(column_name, String::from_deprecated_string(column_name).release_value_but_fixme_should_propagate_errors(), Gfx::TextAlignment::CenterLeft);
query_result_fields.empend(column_name, String::from_byte_string(column_name).release_value_but_fixme_should_propagate_errors(), Gfx::TextAlignment::CenterLeft);
auto query_results_model = GUI::JsonArrayModel::create("{}", move(query_result_fields));
m_query_results_table_view->set_model(MUST(GUI::SortingProxyModel::create(*query_results_model)));
@ -333,10 +333,10 @@ ErrorOr<void> MainWidget::initialize_menu(GUI::Window* window)
void MainWidget::open_new_script()
{
auto new_script_name = DeprecatedString::formatted("New Script - {}", m_new_script_counter);
auto new_script_name = ByteString::formatted("New Script - {}", m_new_script_counter);
++m_new_script_counter;
auto& editor = m_tab_widget->add_tab<ScriptEditor>(String::from_deprecated_string(new_script_name).release_value_but_fixme_should_propagate_errors());
auto& editor = m_tab_widget->add_tab<ScriptEditor>(String::from_byte_string(new_script_name).release_value_but_fixme_should_propagate_errors());
editor.new_script_with_temp_name(new_script_name);
editor.on_cursor_change = [this] { on_editor_change(); };
@ -351,7 +351,7 @@ void MainWidget::open_script_from_file(LexicalPath const& file_path)
auto& editor = m_tab_widget->add_tab<ScriptEditor>(String::from_utf8(file_path.title()).release_value_but_fixme_should_propagate_errors());
if (auto result = editor.open_script_from_file(file_path); result.is_error()) {
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to open {}\n{}", file_path, result.error()));
GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to open {}\n{}", file_path, result.error()));
return;
}
@ -407,7 +407,7 @@ ScriptEditor* MainWidget::active_editor()
void MainWidget::update_title()
{
if (auto* editor = active_editor())
window()->set_title(DeprecatedString::formatted("{} - SQL Studio", editor->name()));
window()->set_title(ByteString::formatted("{} - SQL Studio", editor->name()));
else
window()->set_title("SQL Studio");
}
@ -548,7 +548,7 @@ void 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 sql_statement = piece.to_deprecated_string();
auto sql_statement = piece.to_byte_string();
if (auto statement_id = m_sql_client->prepare_statement(*m_connection_id, sql_statement); statement_id.has_value()) {
m_sql_client->async_execute_statement(*statement_id, {});
@ -556,11 +556,11 @@ void MainWidget::read_next_sql_statement_of_editor()
auto* editor = active_editor();
VERIFY(editor);
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Could not parse {}\n{}", editor->path(), sql_statement));
GUI::MessageBox::show_error(window(), ByteString::formatted("Could not parse {}\n{}", editor->path(), sql_statement));
}
}
Optional<DeprecatedString> MainWidget::read_next_line_of_editor()
Optional<ByteString> MainWidget::read_next_line_of_editor()
{
auto* editor = active_editor();
if (!editor)

View file

@ -65,11 +65,11 @@ private:
RefPtr<SQL::SQLClient> m_sql_client;
Optional<SQL::ConnectionID> m_connection_id;
Vector<DeprecatedString> m_result_column_names;
Vector<Vector<DeprecatedString>> m_results;
Vector<ByteString> m_result_column_names;
Vector<Vector<ByteString>> m_results;
void read_next_sql_statement_of_editor();
Optional<DeprecatedString> read_next_line_of_editor();
Optional<ByteString> read_next_line_of_editor();
size_t m_current_line_for_parsing { 0 };
int m_editor_line_level { 0 };
};

View file

@ -21,7 +21,7 @@ ScriptEditor::ScriptEditor()
set_ruler_visible(true);
}
void ScriptEditor::new_script_with_temp_name(DeprecatedString name)
void ScriptEditor::new_script_with_temp_name(ByteString name)
{
set_name(name);
}
@ -37,7 +37,7 @@ ErrorOr<void> ScriptEditor::open_script_from_file(LexicalPath const& file_path)
return {};
}
static ErrorOr<void> save_text_to_file(StringView filename, DeprecatedString text)
static ErrorOr<void> save_text_to_file(StringView filename, ByteString text)
{
auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Write));

View file

@ -17,19 +17,19 @@ class ScriptEditor : public GUI::TextEditor {
public:
virtual ~ScriptEditor() = default;
void new_script_with_temp_name(DeprecatedString);
void new_script_with_temp_name(ByteString);
ErrorOr<void> open_script_from_file(LexicalPath const&);
ErrorOr<bool> save();
ErrorOr<bool> save_as();
ErrorOr<bool> attempt_to_close();
DeprecatedString const& path() const { return m_path; }
ByteString const& path() const { return m_path; }
private:
ScriptEditor();
DeprecatedString m_path;
ByteString m_path;
};
}

View file

@ -42,7 +42,7 @@ Emulator& Emulator::the()
return *s_the;
}
Emulator::Emulator(DeprecatedString const& executable_path, Vector<StringView> const& arguments, Vector<DeprecatedString> const& environment)
Emulator::Emulator(ByteString const& executable_path, Vector<StringView> const& arguments, Vector<ByteString> const& environment)
: m_executable_path(executable_path)
, m_arguments(arguments)
, m_environment(environment)
@ -70,7 +70,7 @@ Emulator::Emulator(DeprecatedString const& executable_path, Vector<StringView> c
setup_signal_trampoline();
}
Vector<ELF::AuxiliaryValue> Emulator::generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, DeprecatedString const& executable_path, int executable_fd) const
Vector<ELF::AuxiliaryValue> Emulator::generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, ByteString const& executable_path, int executable_fd) const
{
// FIXME: This is not fully compatible with the auxiliary vector the kernel generates, this is just the bare
// minimum to get the loader going.
@ -227,7 +227,7 @@ int Emulator::exec()
size_t instructions_until_next_profile_dump = profile_instruction_interval();
if (is_profiling() && m_loader_text_size.has_value())
emit_profile_event(profile_stream(), "mmap"sv, DeprecatedString::formatted(R"("ptr": {}, "size": {}, "name": "/usr/lib/Loader.so")", *m_loader_text_base, *m_loader_text_size));
emit_profile_event(profile_stream(), "mmap"sv, ByteString::formatted(R"("ptr": {}, "size": {}, "name": "/usr/lib/Loader.so")", *m_loader_text_base, *m_loader_text_size));
while (!m_shutdown) {
if (m_steps_til_pause) [[likely]] {
@ -235,7 +235,7 @@ int Emulator::exec()
auto insn = X86::Instruction::from_stream(*m_cpu, X86::ProcessorMode::Protected);
// Exec cycle
if constexpr (trace) {
outln("{:p} \033[33;1m{}\033[0m", m_cpu->base_eip(), insn.to_deprecated_string(m_cpu->base_eip(), symbol_provider));
outln("{:p} \033[33;1m{}\033[0m", m_cpu->base_eip(), insn.to_byte_string(m_cpu->base_eip(), symbol_provider));
}
(m_cpu->*insn.handler())(insn);
@ -419,13 +419,13 @@ MmapRegion const* Emulator::load_library_from_address(FlatPtr address)
if (!region)
return {};
DeprecatedString lib_name = region->lib_name();
ByteString lib_name = region->lib_name();
if (lib_name.is_null())
return {};
DeprecatedString lib_path = lib_name;
ByteString lib_path = lib_name;
if (FileSystem::looks_like_shared_library(lib_name))
lib_path = DeprecatedString::formatted("/usr/lib/{}", lib_path);
lib_path = ByteString::formatted("/usr/lib/{}", lib_path);
if (!m_dynamic_library_cache.contains(lib_path)) {
auto file_or_error = Core::MappedFile::map(lib_path);
@ -463,7 +463,7 @@ Optional<Emulator::SymbolInfo> Emulator::symbol_at(FlatPtr address)
VERIFY(first_region);
auto lib_path = lib_name;
if (FileSystem::looks_like_shared_library(lib_name)) {
lib_path = DeprecatedString::formatted("/usr/lib/{}", lib_name);
lib_path = ByteString::formatted("/usr/lib/{}", lib_name);
}
auto it = m_dynamic_library_cache.find(lib_path);
@ -474,18 +474,18 @@ Optional<Emulator::SymbolInfo> Emulator::symbol_at(FlatPtr address)
return { { lib_name, symbol, source_position } };
}
DeprecatedString Emulator::create_backtrace_line(FlatPtr address)
ByteString Emulator::create_backtrace_line(FlatPtr address)
{
auto maybe_symbol = symbol_at(address);
if (!maybe_symbol.has_value()) {
return DeprecatedString::formatted("=={}== {:p}", getpid(), address);
return ByteString::formatted("=={}== {:p}", getpid(), address);
}
if (!maybe_symbol->source_position.has_value()) {
return DeprecatedString::formatted("=={}== {:p} [{}]: {}", getpid(), address, maybe_symbol->lib_name, maybe_symbol->symbol);
return ByteString::formatted("=={}== {:p} [{}]: {}", getpid(), address, maybe_symbol->lib_name, maybe_symbol->symbol);
}
auto const& source_position = maybe_symbol->source_position.value();
return DeprecatedString::formatted("=={}== {:p} [{}]: {} (\e[34;1m{}\e[0m:{})", getpid(), address, maybe_symbol->lib_name, maybe_symbol->symbol, LexicalPath::basename(source_position.file_path), source_position.line_number);
return ByteString::formatted("=={}== {:p} [{}]: {} (\e[34;1m{}\e[0m:{})", getpid(), address, maybe_symbol->lib_name, maybe_symbol->symbol, LexicalPath::basename(source_position.file_path), source_position.line_number);
}
void Emulator::dump_backtrace(Vector<FlatPtr> const& backtrace)
@ -513,7 +513,7 @@ void Emulator::emit_profile_sample(Stream& output)
output.write_until_depleted(builder.string_view().bytes()).release_value_but_fixme_should_propagate_errors();
}
void Emulator::emit_profile_event(Stream& output, StringView event_name, DeprecatedString const& contents)
void Emulator::emit_profile_event(Stream& output, StringView event_name, ByteString const& contents)
{
StringBuilder builder;
timeval tv {};
@ -523,13 +523,13 @@ void Emulator::emit_profile_event(Stream& output, StringView event_name, Depreca
output.write_until_depleted(builder.string_view().bytes()).release_value_but_fixme_should_propagate_errors();
}
DeprecatedString Emulator::create_instruction_line(FlatPtr address, X86::Instruction const& insn)
ByteString Emulator::create_instruction_line(FlatPtr address, X86::Instruction const& insn)
{
auto symbol = symbol_at(address);
if (!symbol.has_value() || !symbol->source_position.has_value())
return DeprecatedString::formatted("{:p}: {}", address, insn.to_deprecated_string(address));
return ByteString::formatted("{:p}: {}", address, insn.to_byte_string(address));
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);
return ByteString::formatted("{:p}: {} \e[34;1m{}\e[0m:{}", address, insn.to_byte_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

@ -30,9 +30,9 @@ class Emulator {
public:
static Emulator& the();
Emulator(DeprecatedString const& executable_path, Vector<StringView> const& arguments, Vector<DeprecatedString> const& environment);
Emulator(ByteString const& executable_path, Vector<StringView> const& arguments, Vector<ByteString> const& environment);
void set_profiling_details(bool should_dump_profile, size_t instruction_interval, Stream* profile_stream, Vector<NonnullOwnPtr<DeprecatedString>>* profiler_strings, Vector<int>* profiler_string_id_map)
void set_profiling_details(bool should_dump_profile, size_t instruction_interval, Stream* profile_stream, Vector<NonnullOwnPtr<ByteString>>* profiler_strings, Vector<int>* profiler_string_id_map)
{
m_is_profiling = should_dump_profile;
m_profile_instruction_interval = instruction_interval;
@ -47,7 +47,7 @@ public:
}
Stream& profile_stream() { return *m_profile_stream; }
Vector<NonnullOwnPtr<DeprecatedString>>& profiler_strings() { return *m_profiler_strings; }
Vector<NonnullOwnPtr<ByteString>>& profiler_strings() { return *m_profiler_strings; }
Vector<int>& profiler_string_id_map() { return *m_profiler_string_id_map; }
bool is_profiling() const { return m_is_profiling; }
@ -113,8 +113,8 @@ public:
}
struct SymbolInfo {
DeprecatedString lib_name;
DeprecatedString symbol;
ByteString lib_name;
ByteString symbol;
Optional<Debug::DebugInfo::SourcePosition> source_position;
};
@ -123,9 +123,9 @@ public:
void dump_regions() const;
private:
const DeprecatedString m_executable_path;
const ByteString m_executable_path;
Vector<StringView> const m_arguments;
Vector<DeprecatedString> const m_environment;
Vector<ByteString> const m_environment;
SoftMMU m_mmu;
NonnullOwnPtr<SoftCPU> m_cpu;
@ -133,14 +133,14 @@ private:
OwnPtr<MallocTracer> m_malloc_tracer;
void setup_stack(Vector<ELF::AuxiliaryValue>);
Vector<ELF::AuxiliaryValue> generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, DeprecatedString const& executable_path, int executable_fd) const;
Vector<ELF::AuxiliaryValue> generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, ByteString const& executable_path, int executable_fd) const;
void register_signal_handlers();
void setup_signal_trampoline();
void send_signal(int);
void emit_profile_sample(Stream&);
void emit_profile_event(Stream&, StringView event_name, DeprecatedString const& contents);
void emit_profile_event(Stream&, StringView event_name, ByteString const& contents);
int virt$accept4(FlatPtr);
u32 virt$allocate_tls(FlatPtr, size_t);
@ -254,8 +254,8 @@ private:
MmapRegion const* find_text_region(FlatPtr address);
MmapRegion const* load_library_from_address(FlatPtr address);
MmapRegion const* first_region_for_object(StringView name);
DeprecatedString create_backtrace_line(FlatPtr address);
DeprecatedString create_instruction_line(FlatPtr address, X86::Instruction const& insn);
ByteString create_backtrace_line(FlatPtr address);
ByteString create_instruction_line(FlatPtr address, X86::Instruction const& insn);
bool m_shutdown { false };
int m_exit_status { 0 };
@ -290,13 +290,13 @@ private:
NonnullOwnPtr<ELF::Image> image;
};
HashMap<DeprecatedString, CachedELF> m_dynamic_library_cache;
HashMap<ByteString, CachedELF> m_dynamic_library_cache;
RangeAllocator m_range_allocator;
Stream* m_profile_stream { nullptr };
Vector<int>* m_profiler_string_id_map { nullptr };
Vector<NonnullOwnPtr<DeprecatedString>>* m_profiler_strings { nullptr };
Vector<NonnullOwnPtr<ByteString>>* m_profiler_strings { nullptr };
bool m_is_profiling { false };
size_t m_profile_instruction_interval { 0 };

View file

@ -292,7 +292,7 @@ FlatPtr Emulator::virt$perf_event(int event, FlatPtr arg1, FlatPtr arg2)
if (event == PERF_EVENT_SIGNPOST) {
if (is_profiling()) {
if (profiler_string_id_map().size() > arg1)
emit_profile_event(profile_stream(), "signpost"sv, DeprecatedString::formatted("\"arg1\": {}, \"arg2\": {}", arg1, arg2));
emit_profile_event(profile_stream(), "signpost"sv, ByteString::formatted("\"arg1\": {}, \"arg2\": {}", arg1, arg2));
syscall(SC_perf_event, PERF_EVENT_SIGNPOST, profiler_string_id_map().at(arg1), arg2);
} else {
syscall(SC_perf_event, PERF_EVENT_SIGNPOST, arg1, arg2);
@ -311,7 +311,7 @@ FlatPtr Emulator::virt$perf_register_string(FlatPtr string, size_t size)
auto ret = (int)syscall(SC_perf_register_string, buffer, size + 4);
if (ret >= 0 && is_profiling()) {
profiler_strings().append(make<DeprecatedString>(StringView { buffer + 4, size }));
profiler_strings().append(make<ByteString>(StringView { buffer + 4, size }));
profiler_string_id_map().append(ret);
ret = profiler_string_id_map().size() - 1;
}
@ -564,7 +564,7 @@ int Emulator::virt$set_mmap_name(FlatPtr params_addr)
auto* region = mmu().find_region({ 0x23, (FlatPtr)params.addr });
if (!region || !is<MmapRegion>(*region))
return -EINVAL;
static_cast<MmapRegion&>(*region).set_name(DeprecatedString::copy(name));
static_cast<MmapRegion&>(*region).set_name(ByteString::copy(name));
return 0;
}
@ -802,7 +802,7 @@ static void round_to_page_size(FlatPtr& address, size_t& size)
u32 Emulator::virt$munmap(FlatPtr address, size_t size)
{
if (is_profiling())
emit_profile_event(profile_stream(), "munmap"sv, DeprecatedString::formatted("\"ptr\": {}, \"size\": {}", address, size));
emit_profile_event(profile_stream(), "munmap"sv, ByteString::formatted("\"ptr\": {}, \"size\": {}", address, size));
round_to_page_size(address, size);
Vector<Region*, 4> marked_for_deletion;
bool has_non_mmap_region = false;
@ -861,7 +861,7 @@ u32 Emulator::virt$mmap(u32 params_addr)
final_address = result.value().base().get();
auto final_size = result.value().size();
DeprecatedString name_str;
ByteString name_str;
if (params.name.characters) {
auto buffer_result = ByteBuffer::create_uninitialized(params.name.length);
if (buffer_result.is_error())
@ -872,7 +872,7 @@ u32 Emulator::virt$mmap(u32 params_addr)
}
if (is_profiling())
emit_profile_event(profile_stream(), "mmap"sv, DeprecatedString::formatted(R"("ptr": {}, "size": {}, "name": "{}")", final_address, final_size, name_str));
emit_profile_event(profile_stream(), "mmap"sv, ByteString::formatted(R"("ptr": {}, "size": {}, "name": "{}")", final_address, final_size, name_str));
if (params.flags & MAP_ANONYMOUS) {
mmu().add_region(MmapRegion::create_anonymous(final_address, final_size, params.prot, move(name_str)));
@ -1216,15 +1216,15 @@ int Emulator::virt$execve(FlatPtr params_addr)
Syscall::SC_execve_params params;
mmu().copy_from_vm(&params, params_addr, sizeof(params));
auto path = DeprecatedString::copy(mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length));
Vector<DeprecatedString> arguments;
Vector<DeprecatedString> environment;
auto path = ByteString::copy(mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length));
Vector<ByteString> arguments;
Vector<ByteString> environment;
auto copy_string_list = [this](auto& output_vector, auto& string_list) {
for (size_t i = 0; i < string_list.length; ++i) {
Syscall::StringArgument string;
mmu().copy_from_vm(&string, (FlatPtr)&string_list.strings[i], sizeof(string));
output_vector.append(DeprecatedString::copy(mmu().copy_buffer_from_vm((FlatPtr)string.characters, string.length)));
output_vector.append(ByteString::copy(mmu().copy_buffer_from_vm((FlatPtr)string.characters, string.length)));
}
};
@ -1270,7 +1270,7 @@ int Emulator::virt$stat(FlatPtr params_addr)
Syscall::SC_stat_params params;
mmu().copy_from_vm(&params, params_addr, sizeof(params));
auto path = DeprecatedString::copy(mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length));
auto path = ByteString::copy(mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length));
struct stat host_statbuf;
int rc;
if (params.follow_symlinks)

View file

@ -26,20 +26,20 @@ static void free_pages(void* ptr, size_t bytes)
VERIFY(rc == 0);
}
NonnullOwnPtr<MmapRegion> MmapRegion::create_anonymous(u32 base, u32 size, u32 prot, DeprecatedString name)
NonnullOwnPtr<MmapRegion> MmapRegion::create_anonymous(u32 base, u32 size, u32 prot, ByteString name)
{
auto* data = (u8*)mmap_initialized(size, 0, DeprecatedString::formatted("(UE) {}", name).characters());
auto* data = (u8*)mmap_initialized(size, 0, ByteString::formatted("(UE) {}", name).characters());
auto* shadow_data = (u8*)mmap_initialized(size, 1, "MmapRegion ShadowData");
auto region = adopt_own(*new MmapRegion(base, size, prot, data, shadow_data));
region->m_name = move(name);
return region;
}
NonnullOwnPtr<MmapRegion> MmapRegion::create_file_backed(u32 base, u32 size, u32 prot, int flags, int fd, off_t offset, DeprecatedString name)
NonnullOwnPtr<MmapRegion> MmapRegion::create_file_backed(u32 base, u32 size, u32 prot, int flags, int fd, off_t offset, ByteString name)
{
// Since we put the memory to an arbitrary location, do not pass MAP_FIXED and MAP_FIXED_NOREPLACE to the Kernel.
auto real_flags = flags & ~(MAP_FIXED | MAP_FIXED_NOREPLACE);
auto* data = (u8*)mmap_with_name(nullptr, size, prot, real_flags, fd, offset, name.is_empty() ? nullptr : DeprecatedString::formatted("(UE) {}", name).characters());
auto* data = (u8*)mmap_with_name(nullptr, size, prot, real_flags, fd, offset, name.is_empty() ? nullptr : ByteString::formatted("(UE) {}", name).characters());
VERIFY(data != MAP_FAILED);
auto* shadow_data = (u8*)mmap_initialized(size, 1, "MmapRegion ShadowData");
auto region = adopt_own(*new MmapRegion(base, size, prot, data, shadow_data));
@ -318,10 +318,10 @@ void MmapRegion::set_prot(int prot)
}
}
void MmapRegion::set_name(DeprecatedString name)
void MmapRegion::set_name(ByteString name)
{
m_name = move(name);
set_mmap_name(range().base().as_ptr(), range().size(), DeprecatedString::formatted("(UE) {}", m_name).characters());
set_mmap_name(range().base().as_ptr(), range().size(), ByteString::formatted("(UE) {}", m_name).characters());
}
}

View file

@ -16,8 +16,8 @@ class MallocTracer;
class MmapRegion final : public Region {
public:
static NonnullOwnPtr<MmapRegion> create_anonymous(u32 base, u32 size, u32 prot, DeprecatedString name);
static NonnullOwnPtr<MmapRegion> create_file_backed(u32 base, u32 size, u32 prot, int flags, int fd, off_t offset, DeprecatedString name);
static NonnullOwnPtr<MmapRegion> create_anonymous(u32 base, u32 size, u32 prot, ByteString name);
static NonnullOwnPtr<MmapRegion> create_file_backed(u32 base, u32 size, u32 prot, int flags, int fd, off_t offset, ByteString name);
virtual ~MmapRegion() override;
virtual ValueWithShadow<u8> read8(u32 offset) override;
@ -51,8 +51,8 @@ public:
MallocRegionMetadata* malloc_metadata() { return m_malloc_metadata; }
void set_malloc_metadata(Badge<MallocTracer>, NonnullOwnPtr<MallocRegionMetadata> metadata) { m_malloc_metadata = move(metadata); }
DeprecatedString const& name() const { return m_name; }
DeprecatedString lib_name() const
ByteString const& name() const { return m_name; }
ByteString lib_name() const
{
if (m_name.contains("Loader.so"sv))
return "Loader.so";
@ -61,7 +61,7 @@ public:
return {};
return m_name.substring(0, *maybe_separator);
}
void set_name(DeprecatedString name);
void set_name(ByteString name);
private:
MmapRegion(u32 base, u32 size, int prot, u8* data, u8* shadow_data);
@ -72,7 +72,7 @@ private:
bool m_malloc { false };
OwnPtr<MallocRegionMetadata> m_malloc_metadata;
DeprecatedString m_name;
ByteString m_name;
};
template<>

View file

@ -114,7 +114,7 @@ private:
}
}
DeprecatedString fpu_exception_string(FPU_Exception ex)
ByteString fpu_exception_string(FPU_Exception ex)
{
switch (ex) {
case FPU_Exception::StackFault:

View file

@ -23,7 +23,7 @@ int main(int argc, char** argv, char** env)
{
Vector<StringView> arguments;
bool pause_on_startup { false };
DeprecatedString profile_dump_path;
ByteString profile_dump_path;
bool enable_roi_mode { false };
bool dump_profile { false };
unsigned profile_instruction_interval { 0 };
@ -51,13 +51,13 @@ int main(int argc, char** argv, char** env)
reportln("Cannot find executable for '{}'."sv, arguments[0]);
return 1;
}
auto executable_path = executable_path_or_error.release_value().to_deprecated_string();
auto executable_path = executable_path_or_error.release_value().to_byte_string();
if (dump_profile && profile_dump_path.is_empty())
profile_dump_path = DeprecatedString::formatted("{}.{}.profile", LexicalPath(executable_path).basename(), getpid());
profile_dump_path = ByteString::formatted("{}.{}.profile", LexicalPath(executable_path).basename(), getpid());
OwnPtr<Stream> profile_stream;
OwnPtr<Vector<NonnullOwnPtr<DeprecatedString>>> profile_strings;
OwnPtr<Vector<NonnullOwnPtr<ByteString>>> profile_strings;
OwnPtr<Vector<int>> profile_string_id_map;
if (dump_profile) {
@ -67,21 +67,21 @@ int main(int argc, char** argv, char** env)
return 1;
}
profile_stream = profile_stream_or_error.release_value();
profile_strings = make<Vector<NonnullOwnPtr<DeprecatedString>>>();
profile_strings = make<Vector<NonnullOwnPtr<ByteString>>>();
profile_string_id_map = make<Vector<int>>();
profile_stream->write_until_depleted(R"({"events":[)"sv.bytes()).release_value_but_fixme_should_propagate_errors();
timeval tv {};
gettimeofday(&tv, nullptr);
profile_stream->write_until_depleted(
DeprecatedString::formatted(
ByteString::formatted(
R"~({{"type": "process_create", "parent_pid": 1, "executable": "{}", "pid": {}, "tid": {}, "timestamp": {}, "lost_samples": 0, "stack": []}})~",
executable_path, getpid(), gettid(), tv.tv_sec * 1000 + tv.tv_usec / 1000)
.bytes())
.release_value_but_fixme_should_propagate_errors();
}
Vector<DeprecatedString> environment;
Vector<ByteString> environment;
for (int i = 0; env[i]; ++i) {
environment.append(env[i]);
}
@ -112,8 +112,8 @@ int main(int argc, char** argv, char** env)
emulator.profile_stream().write_until_depleted("], \"strings\": ["sv.bytes()).release_value_but_fixme_should_propagate_errors();
if (emulator.profiler_strings().size()) {
for (size_t i = 0; i < emulator.profiler_strings().size() - 1; ++i)
emulator.profile_stream().write_until_depleted(DeprecatedString::formatted("\"{}\", ", emulator.profiler_strings().at(i)).bytes()).release_value_but_fixme_should_propagate_errors();
emulator.profile_stream().write_until_depleted(DeprecatedString::formatted("\"{}\"", emulator.profiler_strings().last()).bytes()).release_value_but_fixme_should_propagate_errors();
emulator.profile_stream().write_until_depleted(ByteString::formatted("\"{}\", ", emulator.profiler_strings().at(i)).bytes()).release_value_but_fixme_should_propagate_errors();
emulator.profile_stream().write_until_depleted(ByteString::formatted("\"{}\"", emulator.profiler_strings().last()).bytes()).release_value_but_fixme_should_propagate_errors();
}
emulator.profile_stream().write_until_depleted("]}"sv.bytes()).release_value_but_fixme_should_propagate_errors();
}