1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:47:34 +00:00

LibCore: Put all classes in the Core namespace and remove the leading C

I've been wanting to do this for a long time. It's time we start being
consistent about how this stuff works.

The new convention is:

- "LibFoo" is a userspace library that provides the "Foo" namespace.

That's it :^) This was pretty tedious to convert and I didn't even
start on LibGUI yet. But it's coming up next.
This commit is contained in:
Andreas Kling 2020-02-02 12:34:39 +01:00
parent b7e3810b5c
commit 2d39da5405
265 changed files with 1380 additions and 1167 deletions

View file

@ -44,7 +44,7 @@ BoardListModel::~BoardListModel()
void BoardListModel::update()
{
CHttpRequest request;
Core::HttpRequest request;
request.set_url("http://a.4cdn.org/boards.json");
if (m_pending_job)

View file

@ -51,5 +51,5 @@ private:
BoardListModel();
JsonArray m_boards;
RefPtr<CHttpJob> m_pending_job;
RefPtr<Core::HttpJob> m_pending_job;
};

View file

@ -52,7 +52,7 @@ void ThreadCatalogModel::set_board(const String& board)
void ThreadCatalogModel::update()
{
CHttpRequest request;
Core::HttpRequest request;
request.set_url(String::format("http://a.4cdn.org/%s/catalog.json", m_board.characters()));
if (m_pending_job)

View file

@ -63,5 +63,5 @@ private:
String m_board { "g" };
JsonArray m_catalog;
RefPtr<CHttpJob> m_pending_job;
RefPtr<Core::HttpJob> m_pending_job;
};

View file

@ -48,7 +48,7 @@
#include <Servers/WindowServer/WSWindowManager.h>
DisplayPropertiesWidget::DisplayPropertiesWidget()
: m_wm_config(CConfigFile::get_for_app("WindowManager"))
: m_wm_config(Core::ConfigFile::get_for_app("WindowManager"))
{
create_resolution_list();
create_wallpaper_list();
@ -114,7 +114,7 @@ void DisplayPropertiesWidget::create_wallpaper_list()
m_selected_wallpaper = name_parts[2];
}
CDirIterator iterator("/res/wallpapers/", CDirIterator::Flags::SkipDots);
Core::DirIterator iterator("/res/wallpapers/", Core::DirIterator::Flags::SkipDots);
while (iterator.has_next()) {
m_wallpapers.append(iterator.next_path());

View file

@ -65,7 +65,7 @@ private:
private:
String m_wallpaper_path;
RefPtr<CConfigFile> m_wm_config;
RefPtr<Core::ConfigFile> m_wm_config;
RefPtr<GWidget> m_root_widget;
Vector<Size> m_resolutions;
Vector<String> m_wallpapers;

View file

@ -37,7 +37,7 @@ namespace FileUtils {
int delete_directory(String directory, String& file_that_caused_error)
{
CDirIterator iterator(directory, CDirIterator::SkipDots);
Core::DirIterator iterator(directory, Core::DirIterator::SkipDots);
if (iterator.has_error()) {
file_that_caused_error = directory;
return -1;
@ -104,7 +104,7 @@ bool copy_directory(const String& src_path, const String& dst_path)
if (rc < 0) {
return false;
}
CDirIterator di(src_path, CDirIterator::SkipDots);
Core::DirIterator di(src_path, Core::DirIterator::SkipDots);
if (di.has_error()) {
return false;
}

View file

@ -35,7 +35,7 @@
#include <stdio.h>
#include <unistd.h>
PropertiesDialog::PropertiesDialog(GFileSystemModel& model, String path, bool disable_rename, CObject* parent)
PropertiesDialog::PropertiesDialog(GFileSystemModel& model, String path, bool disable_rename, Core::Object* parent)
: GDialog(parent)
, m_model(model)
{

View file

@ -40,7 +40,7 @@ public:
virtual ~PropertiesDialog() override;
private:
PropertiesDialog(GFileSystemModel&, String, bool disable_rename, CObject* parent = nullptr);
PropertiesDialog(GFileSystemModel&, String, bool disable_rename, Core::Object* parent = nullptr);
struct PropertyValuePair {
String property;

View file

@ -72,7 +72,7 @@ int main(int argc, char** argv)
return 1;
}
RefPtr<CConfigFile> config = CConfigFile::get_for_app("FileManager");
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("FileManager");
GApplication app(argc, argv);

View file

@ -41,7 +41,7 @@ void ManualSectionNode::reify_if_needed() const
return;
m_reified = true;
CDirIterator dir_iter { path(), CDirIterator::Flags::SkipDots };
Core::DirIterator dir_iter { path(), Core::DirIterator::Flags::SkipDots };
while (dir_iter.has_next()) {
FileSystemPath file_path(dir_iter.next_path());

View file

@ -113,10 +113,10 @@ int main(int argc, char* argv[])
dbg() << "Opening page at " << path;
auto file = CFile::construct();
auto file = Core::File::construct();
file->set_filename(path);
if (!file->open(CIODevice::OpenMode::ReadOnly)) {
if (!file->open(Core::IODevice::OpenMode::ReadOnly)) {
int saved_errno = errno;
GMessageBox::show(strerror(saved_errno), "Failed to open man page", GMessageBox::Type::Error, GMessageBox::InputType::OK, window);
return;

View file

@ -564,7 +564,7 @@ void HexEditor::paint_event(GPaintEvent& event)
}
}
void HexEditor::leave_event(CEvent&)
void HexEditor::leave_event(Core::Event&)
{
ASSERT(window());
window()->set_override_cursor(GStandardCursor::None);

View file

@ -73,7 +73,7 @@ protected:
virtual void mousemove_event(GMouseEvent&) override;
virtual void keydown_event(GKeyEvent&) override;
virtual bool accepts_focus() const override { return true; }
virtual void leave_event(CEvent&) override;
virtual void leave_event(Core::Event&) override;
private:
bool m_readonly { false };

View file

@ -235,8 +235,8 @@ void HexEditorWidget::update_title()
void HexEditorWidget::open_file(const String& path)
{
auto file = CFile::construct(path);
if (!file->open(CIODevice::ReadOnly)) {
auto file = Core::File::construct(path);
if (!file->open(Core::IODevice::ReadOnly)) {
GMessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window());
return;
}

View file

@ -60,9 +60,9 @@ IRCClient::IRCClient()
: m_nickname("seren1ty")
, m_client_window_list_model(IRCWindowListModel::create(*this))
, m_log(IRCLogBuffer::create())
, m_config(CConfigFile::get_for_app("IRCClient"))
, m_config(Core::ConfigFile::get_for_app("IRCClient"))
{
m_socket = CTCPSocket::construct(this);
m_socket = Core::TCPSocket::construct(this);
m_nickname = m_config->read_entry("User", "Nickname", "seren1ty");
m_hostname = m_config->read_entry("Connection", "Server", "");
m_port = m_config->read_num_entry("Connection", "Port", 6667);
@ -83,7 +83,7 @@ void IRCClient::set_server(const String& hostname, int port)
void IRCClient::on_socket_connected()
{
m_notifier = CNotifier::construct(m_socket->fd(), CNotifier::Read);
m_notifier = Core::Notifier::construct(m_socket->fd(), Core::Notifier::Read);
m_notifier->on_ready_to_read = [this] { receive_from_server(); };
send_user();

View file

@ -38,9 +38,8 @@
class IRCChannel;
class IRCQuery;
class IRCWindowListModel;
class CNotifier;
class IRCClient final : public CObject {
class IRCClient final : public Core::Object {
C_OBJECT(IRCClient)
friend class IRCChannel;
friend class IRCQuery;
@ -162,10 +161,10 @@ private:
String m_hostname;
int m_port { 6667 };
RefPtr<CTCPSocket> m_socket;
RefPtr<Core::TCPSocket> m_socket;
String m_nickname;
RefPtr<CNotifier> m_notifier;
RefPtr<Core::Notifier> m_notifier;
HashMap<String, RefPtr<IRCChannel>, CaseInsensitiveStringTraits> m_channels;
HashMap<String, RefPtr<IRCQuery>, CaseInsensitiveStringTraits> m_queries;
@ -175,5 +174,5 @@ private:
NonnullRefPtr<IRCWindowListModel> m_client_window_list_model;
NonnullRefPtr<IRCLogBuffer> m_log;
NonnullRefPtr<CConfigFile> m_config;
NonnullRefPtr<Core::ConfigFile> m_config;
};

View file

@ -37,7 +37,7 @@
SprayTool::SprayTool()
{
m_timer = CTimer::construct();
m_timer = Core::Timer::construct();
m_timer->on_timeout = [&]() {
paint_it();
};

View file

@ -46,7 +46,7 @@ public:
private:
virtual const char* class_name() const override { return "SprayTool"; }
void paint_it();
RefPtr<CTimer> m_timer;
RefPtr<Core::Timer> m_timer;
Point m_last_pos;
Color m_color;
RefPtr<GMenu> m_context_menu;

View file

@ -70,7 +70,7 @@ MainWidget::~MainWidget()
// FIXME: There are some unnecessary calls to update() throughout this program,
// which are an easy target for optimization.
void MainWidget::custom_event(CCustomEvent&)
void MainWidget::custom_event(Core::CustomEvent&)
{
m_wave_widget->update();

View file

@ -27,8 +27,8 @@
#pragma once
#include "Music.h"
#include <LibGUI/GWidget.h>
#include <Music.h>
class AudioEngine;
class WaveWidget;
@ -48,7 +48,7 @@ private:
virtual void keydown_event(GKeyEvent&) override;
virtual void keyup_event(GKeyEvent&) override;
virtual void custom_event(CCustomEvent&) override;
virtual void custom_event(Core::CustomEvent&) override;
void note_key_action(int key_code, Switch);
void special_key_action(int key_code);

View file

@ -55,8 +55,8 @@ int main(int argc, char** argv)
window->show();
LibThread::Thread audio_thread([&] {
auto audio = CFile::construct("/dev/audio");
if (!audio->open(CIODevice::WriteOnly)) {
auto audio = Core::File::construct("/dev/audio");
if (!audio->open(Core::IODevice::WriteOnly)) {
dbgprintf("Can't open audio device: %s", audio->error_string());
return 1;
}
@ -65,8 +65,8 @@ int main(int argc, char** argv)
for (;;) {
audio_engine.fill_buffer(buffer);
audio->write(reinterpret_cast<u8*>(buffer.data()), buffer_size);
CEventLoop::current().post_event(*main_widget, make<CCustomEvent>(0));
CEventLoop::wake();
Core::EventLoop::current().post_event(*main_widget, make<Core::CustomEvent>(0));
Core::EventLoop::wake();
}
});
audio_thread.start();

View file

@ -29,7 +29,7 @@
PlaybackManager::PlaybackManager(NonnullRefPtr<AClientConnection> connection)
: m_connection(connection)
{
m_timer = CTimer::construct(100, [&]() {
m_timer = Core::Timer::construct(100, [&]() {
if (!m_loader)
return;
next_buffer();

View file

@ -70,5 +70,5 @@ private:
RefPtr<ABuffer> m_next_buffer;
RefPtr<ABuffer> m_current_buffer;
Vector<RefPtr<ABuffer>> m_buffers;
RefPtr<CTimer> m_timer;
RefPtr<Core::Timer> m_timer;
};

View file

@ -121,8 +121,8 @@ GVariant DevicesModel::data(const GModelIndex& index, Role) const
void DevicesModel::update()
{
auto proc_devices = CFile::construct("/proc/devices");
if (!proc_devices->open(CIODevice::OpenMode::ReadOnly))
auto proc_devices = Core::File::construct("/proc/devices");
if (!proc_devices->open(Core::IODevice::OpenMode::ReadOnly))
ASSERT_NOT_REACHED();
auto json = JsonValue::from_string(proc_devices->read_all()).as_array();
@ -148,7 +148,7 @@ void DevicesModel::update()
});
auto fill_in_paths_from_dir = [this](const String& dir) {
CDirIterator dir_iter { dir, CDirIterator::Flags::SkipDots };
Core::DirIterator dir_iter { dir, Core::DirIterator::Flags::SkipDots };
while (dir_iter.has_next()) {
auto name = dir_iter.next_path();
auto path = String::format("%s/%s", dir.characters(), name.characters());

View file

@ -93,8 +93,8 @@ static inline size_t bytes_to_kb(size_t bytes)
void MemoryStatsWidget::refresh()
{
auto proc_memstat = CFile::construct("/proc/memstat");
if (!proc_memstat->open(CIODevice::OpenMode::ReadOnly))
auto proc_memstat = Core::File::construct("/proc/memstat");
if (!proc_memstat->open(Core::IODevice::OpenMode::ReadOnly))
ASSERT_NOT_REACHED();
auto file_contents = proc_memstat->read_all();

View file

@ -81,7 +81,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GWidget* parent)
net_tcp_fields.empend("bytes_out", "Bytes Out", TextAlignment::CenterRight);
m_socket_table_view->set_model(GJsonArrayModel::create("/proc/net/tcp", move(net_tcp_fields)));
m_update_timer = CTimer::construct(
m_update_timer = Core::Timer::construct(
1000, [this] {
update_models();
},

View file

@ -42,5 +42,5 @@ private:
RefPtr<GTableView> m_adapter_table_view;
RefPtr<GTableView> m_socket_table_view;
RefPtr<CTimer> m_update_timer;
RefPtr<Core::Timer> m_update_timer;
};

View file

@ -73,7 +73,7 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget(GWidget* parent)
m_json_model = GJsonArrayModel::create({}, move(pid_vm_fields));
m_table_view->set_model(GSortingProxyModel::create(*m_json_model));
m_table_view->model()->set_key_column_and_sort_order(0, GSortOrder::Ascending);
m_timer = CTimer::construct(1000, [this] { refresh(); }, this);
m_timer = Core::Timer::construct(1000, [this] { refresh(); }, this);
}
ProcessMemoryMapWidget::~ProcessMemoryMapWidget()

View file

@ -28,7 +28,10 @@
#include <LibGUI/GWidget.h>
class CTimer;
namespace Core {
class Timer;
}
class GJsonArrayModel;
class GTableView;
@ -45,5 +48,5 @@ private:
RefPtr<GTableView> m_table_view;
RefPtr<GJsonArrayModel> m_json_model;
pid_t m_pid { -1 };
RefPtr<CTimer> m_timer;
RefPtr<Core::Timer> m_timer;
};

View file

@ -335,7 +335,7 @@ GVariant ProcessModel::data(const GModelIndex& index, Role role) const
void ProcessModel::update()
{
auto all_processes = CProcessStatisticsReader::get_all();
auto all_processes = Core::ProcessStatisticsReader::get_all();
unsigned last_sum_times_scheduled = 0;
for (auto& it : m_threads)

View file

@ -37,7 +37,7 @@ ProcessStacksWidget::ProcessStacksWidget(GWidget* parent)
m_stacks_editor = GTextEditor::construct(GTextEditor::Type::MultiLine, this);
m_stacks_editor->set_readonly(true);
m_timer = CTimer::construct(1000, [this] { refresh(); }, this);
m_timer = Core::Timer::construct(1000, [this] { refresh(); }, this);
}
ProcessStacksWidget::~ProcessStacksWidget()
@ -54,8 +54,8 @@ void ProcessStacksWidget::set_pid(pid_t pid)
void ProcessStacksWidget::refresh()
{
auto file = CFile::construct(String::format("/proc/%d/stack", m_pid));
if (!file->open(CIODevice::ReadOnly)) {
auto file = Core::File::construct(String::format("/proc/%d/stack", m_pid));
if (!file->open(Core::IODevice::ReadOnly)) {
m_stacks_editor->set_text(String::format("Unable to open %s", file->filename().characters()));
return;
}

View file

@ -29,7 +29,9 @@
#include <LibGUI/GTextEditor.h>
#include <LibGUI/GWidget.h>
class CTimer;
namespace Core {
class Timer;
}
class ProcessStacksWidget final : public GWidget {
C_OBJECT(ProcessStacksWidget)
@ -43,5 +45,5 @@ public:
private:
pid_t m_pid { -1 };
RefPtr<GTextEditor> m_stacks_editor;
RefPtr<CTimer> m_timer;
RefPtr<Core::Timer> m_timer;
};

View file

@ -146,7 +146,7 @@ int main(int argc, char** argv)
toolbar->set_has_frame(false);
auto process_table_view = ProcessTableView::construct(process_table_container);
auto refresh_timer = CTimer::construct(1000, [&] {
auto refresh_timer = Core::Timer::construct(1000, [&] {
process_table_view->refresh();
if (auto* memory_stats_widget = MemoryStatsWidget::the())
memory_stats_widget->refresh();

View file

@ -81,15 +81,15 @@ void TaskbarWindow::create_quick_launch_bar()
int total_width = 6;
bool first = true;
auto config = CConfigFile::get_for_app("Taskbar");
auto config = Core::ConfigFile::get_for_app("Taskbar");
constexpr const char* quick_launch = "QuickLaunch";
// FIXME: CConfigFile does not keep the order of the entries.
// FIXME: Core::ConfigFile does not keep the order of the entries.
for (auto& name : config->keys(quick_launch)) {
auto af_name = config->read_entry(quick_launch, name);
ASSERT(!af_name.is_null());
auto af_path = String::format("/res/apps/%s", af_name.characters());
auto af = CConfigFile::open(af_path);
auto af = Core::ConfigFile::open(af_path);
auto app_executable = af->read_entry("App", "Executable");
auto app_icon_path = af->read_entry("Icons", "16x16");

View file

@ -195,7 +195,7 @@ int main(int argc, char** argv)
const char* command_to_execute = "/bin/Shell";
CArgsParser args_parser;
Core::ArgsParser args_parser;
args_parser.add_option(command_to_execute, "Execute this command inside the terminal", nullptr, 'e', "command");
args_parser.parse(argc, argv);
@ -215,7 +215,7 @@ int main(int argc, char** argv)
window->set_background_color(Color::Black);
window->set_double_buffering_enabled(false);
RefPtr<CConfigFile> config = CConfigFile::get_for_app("Terminal");
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Terminal");
auto terminal = TerminalWidget::construct(ptm_fd, true, config);
terminal->on_command_exit = [&] {
app.quit(0);

View file

@ -431,8 +431,8 @@ void TextEditorWidget::update_title()
void TextEditorWidget::open_sesame(const String& path)
{
auto file = CFile::construct(path);
if (!file->open(CIODevice::ReadOnly)) {
auto file = Core::File::construct(path);
if (!file->open(Core::IODevice::ReadOnly)) {
GMessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window());
return;
}