mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 04:27:45 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -70,7 +70,7 @@ AppProvider::AppProvider()
|
|||
});
|
||||
}
|
||||
|
||||
void AppProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
void AppProvider::query(ByteString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
{
|
||||
if (query.starts_with('=') || query.starts_with('$'))
|
||||
return;
|
||||
|
@ -80,7 +80,7 @@ void AppProvider::query(DeprecatedString const& query, Function<void(Vector<Nonn
|
|||
for (auto const& app_file : m_app_file_cache) {
|
||||
auto query_and_arguments = query.split_limit(' ', 2);
|
||||
auto app_name = query_and_arguments.is_empty() ? query : query_and_arguments[0];
|
||||
auto arguments = query_and_arguments.size() < 2 ? DeprecatedString::empty() : query_and_arguments[1];
|
||||
auto arguments = query_and_arguments.size() < 2 ? ByteString::empty() : query_and_arguments[1];
|
||||
auto score = 0;
|
||||
if (app_name.equals_ignoring_ascii_case(app_file->name()))
|
||||
score = NumericLimits<int>::max();
|
||||
|
@ -98,7 +98,7 @@ void AppProvider::query(DeprecatedString const& query, Function<void(Vector<Nonn
|
|||
on_complete(move(results));
|
||||
}
|
||||
|
||||
void CalculatorProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
void CalculatorProvider::query(ByteString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
{
|
||||
if (!query.starts_with('='))
|
||||
return;
|
||||
|
@ -116,11 +116,11 @@ void CalculatorProvider::query(DeprecatedString const& query, Function<void(Vect
|
|||
return;
|
||||
|
||||
auto result = completion.release_value();
|
||||
DeprecatedString calculation;
|
||||
ByteString calculation;
|
||||
if (!result.is_number()) {
|
||||
calculation = "0";
|
||||
} else {
|
||||
calculation = result.to_string_without_side_effects().to_deprecated_string();
|
||||
calculation = result.to_string_without_side_effects().to_byte_string();
|
||||
}
|
||||
|
||||
Vector<NonnullRefPtr<Result>> results;
|
||||
|
@ -138,7 +138,7 @@ FileProvider::FileProvider()
|
|||
build_filesystem_cache();
|
||||
}
|
||||
|
||||
void FileProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
void FileProvider::query(ByteString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
{
|
||||
build_filesystem_cache();
|
||||
|
||||
|
@ -147,7 +147,7 @@ void FileProvider::query(DeprecatedString const& query, Function<void(Vector<Non
|
|||
|
||||
m_fuzzy_match_work = Threading::BackgroundAction<Optional<Vector<NonnullRefPtr<Result>>>>::construct(
|
||||
[this, query](auto& task) -> Optional<Vector<NonnullRefPtr<Result>>> {
|
||||
BinaryHeap<int, DeprecatedString, MAX_SEARCH_RESULTS> sorted_results;
|
||||
BinaryHeap<int, ByteString, MAX_SEARCH_RESULTS> sorted_results;
|
||||
|
||||
for (auto& path : m_full_path_cache) {
|
||||
if (task.is_canceled())
|
||||
|
@ -204,7 +204,7 @@ void FileProvider::build_filesystem_cache()
|
|||
|
||||
(void)Threading::BackgroundAction<int>::construct(
|
||||
[this, strong_ref = NonnullRefPtr(*this)](auto&) {
|
||||
DeprecatedString slash = "/";
|
||||
ByteString slash = "/";
|
||||
auto timer = Core::ElapsedTimer::start_new();
|
||||
while (!m_work_queue.is_empty()) {
|
||||
auto base_directory = m_work_queue.dequeue();
|
||||
|
@ -241,7 +241,7 @@ void FileProvider::build_filesystem_cache()
|
|||
});
|
||||
}
|
||||
|
||||
void TerminalProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
void TerminalProvider::query(ByteString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
{
|
||||
if (!query.starts_with('$'))
|
||||
return;
|
||||
|
@ -253,7 +253,7 @@ void TerminalProvider::query(DeprecatedString const& query, Function<void(Vector
|
|||
on_complete(move(results));
|
||||
}
|
||||
|
||||
void URLProvider::query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
void URLProvider::query(ByteString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete)
|
||||
{
|
||||
if (query.is_empty() || query.starts_with('=') || query.starts_with('$'))
|
||||
return;
|
||||
|
@ -263,7 +263,7 @@ void URLProvider::query(DeprecatedString const& query, Function<void(Vector<Nonn
|
|||
if (url.scheme().is_empty())
|
||||
url.set_scheme("http"_string);
|
||||
if (url.host().has<Empty>() || url.host() == String {})
|
||||
url.set_host(String::from_deprecated_string(query).release_value_but_fixme_should_propagate_errors());
|
||||
url.set_host(String::from_byte_string(query).release_value_but_fixme_should_propagate_errors());
|
||||
if (url.path_segment_count() == 0)
|
||||
url.set_paths({ "" });
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Queue.h>
|
||||
#include <AK/URL.h>
|
||||
#include <LibDesktop/AppFile.h>
|
||||
|
@ -27,7 +27,7 @@ public:
|
|||
|
||||
virtual Gfx::Bitmap const* bitmap() const = 0;
|
||||
|
||||
DeprecatedString const& title() const { return m_title; }
|
||||
ByteString const& title() const { return m_title; }
|
||||
String const& tooltip() const { return m_tooltip; }
|
||||
int score() const { return m_score; }
|
||||
bool equals(Result const& other) const
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
Result(DeprecatedString title, String tooltip, int score = 0)
|
||||
Result(ByteString title, String tooltip, int score = 0)
|
||||
: m_title(move(title))
|
||||
, m_tooltip(move(tooltip))
|
||||
, m_score(score)
|
||||
|
@ -46,14 +46,14 @@ protected:
|
|||
}
|
||||
|
||||
private:
|
||||
DeprecatedString m_title;
|
||||
ByteString m_title;
|
||||
String m_tooltip;
|
||||
int m_score { 0 };
|
||||
};
|
||||
|
||||
class AppResult final : public Result {
|
||||
public:
|
||||
AppResult(RefPtr<Gfx::Bitmap const> bitmap, DeprecatedString title, String tooltip, NonnullRefPtr<Desktop::AppFile> af, DeprecatedString arguments, int score)
|
||||
AppResult(RefPtr<Gfx::Bitmap const> bitmap, ByteString title, String tooltip, NonnullRefPtr<Desktop::AppFile> af, ByteString arguments, int score)
|
||||
: Result(move(title), move(tooltip), score)
|
||||
, m_app_file(move(af))
|
||||
, m_arguments(move(arguments))
|
||||
|
@ -67,13 +67,13 @@ public:
|
|||
|
||||
private:
|
||||
NonnullRefPtr<Desktop::AppFile> m_app_file;
|
||||
DeprecatedString m_arguments;
|
||||
ByteString m_arguments;
|
||||
RefPtr<Gfx::Bitmap const> m_bitmap;
|
||||
};
|
||||
|
||||
class CalculatorResult final : public Result {
|
||||
public:
|
||||
explicit CalculatorResult(DeprecatedString title)
|
||||
explicit CalculatorResult(ByteString title)
|
||||
: Result(move(title), "Copy to Clipboard"_string, 100)
|
||||
, m_bitmap(GUI::Icon::default_icon("app-calculator"sv).bitmap_for_size(16))
|
||||
{
|
||||
|
@ -89,7 +89,7 @@ private:
|
|||
|
||||
class FileResult final : public Result {
|
||||
public:
|
||||
explicit FileResult(DeprecatedString title, int score)
|
||||
explicit FileResult(ByteString title, int score)
|
||||
: Result(move(title), String(), score)
|
||||
{
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public:
|
|||
|
||||
class TerminalResult final : public Result {
|
||||
public:
|
||||
explicit TerminalResult(DeprecatedString command)
|
||||
explicit TerminalResult(ByteString command)
|
||||
: Result(move(command), "Run command in Terminal"_string, 100)
|
||||
, m_bitmap(GUI::Icon::default_icon("app-terminal"sv).bitmap_for_size(16))
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ private:
|
|||
class URLResult final : public Result {
|
||||
public:
|
||||
explicit URLResult(const URL& url)
|
||||
: Result(url.to_deprecated_string(), "Open URL in Browser"_string, 50)
|
||||
: Result(url.to_byte_string(), "Open URL in Browser"_string, 50)
|
||||
, m_bitmap(GUI::Icon::default_icon("app-browser"sv).bitmap_for_size(16))
|
||||
{
|
||||
}
|
||||
|
@ -135,14 +135,14 @@ class Provider : public RefCounted<Provider> {
|
|||
public:
|
||||
virtual ~Provider() = default;
|
||||
|
||||
virtual void query(DeprecatedString const&, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) = 0;
|
||||
virtual void query(ByteString const&, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) = 0;
|
||||
};
|
||||
|
||||
class AppProvider final : public Provider {
|
||||
public:
|
||||
AppProvider();
|
||||
|
||||
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
void query(ByteString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
|
||||
private:
|
||||
Vector<NonnullRefPtr<Desktop::AppFile>> m_app_file_cache;
|
||||
|
@ -150,31 +150,31 @@ private:
|
|||
|
||||
class CalculatorProvider final : public Provider {
|
||||
public:
|
||||
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
void query(ByteString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
};
|
||||
|
||||
class FileProvider final : public Provider {
|
||||
public:
|
||||
FileProvider();
|
||||
|
||||
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
void query(ByteString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
void build_filesystem_cache();
|
||||
|
||||
private:
|
||||
RefPtr<Threading::BackgroundAction<Optional<Vector<NonnullRefPtr<Result>>>>> m_fuzzy_match_work;
|
||||
bool m_building_cache { false };
|
||||
Vector<DeprecatedString> m_full_path_cache;
|
||||
Queue<DeprecatedString> m_work_queue;
|
||||
Vector<ByteString> m_full_path_cache;
|
||||
Queue<ByteString> m_work_queue;
|
||||
};
|
||||
|
||||
class TerminalProvider final : public Provider {
|
||||
public:
|
||||
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
void query(ByteString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
};
|
||||
|
||||
class URLProvider final : public Provider {
|
||||
public:
|
||||
void query(DeprecatedString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
void query(ByteString const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "Providers.h"
|
||||
#include <AK/Array.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/QuickSort.h>
|
||||
|
@ -40,7 +40,7 @@ struct AppState {
|
|||
size_t visible_result_count { 0 };
|
||||
|
||||
Threading::Mutex lock;
|
||||
DeprecatedString last_query;
|
||||
ByteString last_query;
|
||||
};
|
||||
|
||||
class ResultRow final : public GUI::Button {
|
||||
|
@ -57,7 +57,7 @@ class ResultRow final : public GUI::Button {
|
|||
if (!m_context_menu) {
|
||||
m_context_menu = GUI::Menu::construct();
|
||||
|
||||
if (LexicalPath path { text().to_deprecated_string() }; path.is_absolute()) {
|
||||
if (LexicalPath path { text().to_byte_string() }; path.is_absolute()) {
|
||||
m_context_menu->add_action(GUI::Action::create("&Show in File Manager", MUST(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-file-manager.png"sv)), [=](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(path.dirname(), path.basename()));
|
||||
}));
|
||||
|
@ -86,7 +86,7 @@ public:
|
|||
|
||||
Function<void(Vector<NonnullRefPtr<Result const>>&&)> on_new_results;
|
||||
|
||||
void search(DeprecatedString const& query)
|
||||
void search(ByteString const& query)
|
||||
{
|
||||
auto should_display_precached_results = false;
|
||||
for (size_t i = 0; i < ProviderCount; ++i) {
|
||||
|
@ -139,7 +139,7 @@ private:
|
|||
Array<NonnullRefPtr<Provider>, ProviderCount> m_providers;
|
||||
|
||||
Threading::Mutex m_mutex;
|
||||
HashMap<DeprecatedString, Array<OwnPtr<Vector<NonnullRefPtr<Result>>>, ProviderCount>> m_result_cache;
|
||||
HashMap<ByteString, Array<OwnPtr<Vector<NonnullRefPtr<Result>>>, ProviderCount>> m_result_cache;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto& result = app_state.results[i];
|
||||
auto& match = results_container.add<Assistant::ResultRow>();
|
||||
match.set_icon(result->bitmap());
|
||||
match.set_text(String::from_deprecated_string(result->title()).release_value_but_fixme_should_propagate_errors());
|
||||
match.set_text(String::from_byte_string(result->title()).release_value_but_fixme_should_propagate_errors());
|
||||
match.set_tooltip(result->tooltip());
|
||||
match.on_click = [&result](auto) {
|
||||
result->activate();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue