Skip to content

Commit

Permalink
LibCore: Put all classes in the Core namespace and remove the leading C
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
awesomekling committed Feb 2, 2020
1 parent b7e3810 commit 2d39da5
Show file tree
Hide file tree
Showing 265 changed files with 1,380 additions and 1,167 deletions.
2 changes: 1 addition & 1 deletion Applications/ChanViewer/BoardListModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ BoardListModel::~BoardListModel()

void BoardListModel::update()
{
CHttpRequest request;
Core::HttpRequest request;
request.set_url("http:https://a.4cdn.org/boards.json");

if (m_pending_job)
Expand Down
2 changes: 1 addition & 1 deletion Applications/ChanViewer/BoardListModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ class BoardListModel final : public GModel {
BoardListModel();

JsonArray m_boards;
RefPtr<CHttpJob> m_pending_job;
RefPtr<Core::HttpJob> m_pending_job;
};
2 changes: 1 addition & 1 deletion Applications/ChanViewer/ThreadCatalogModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:https://a.4cdn.org/%s/catalog.json", m_board.characters()));

if (m_pending_job)
Expand Down
2 changes: 1 addition & 1 deletion Applications/ChanViewer/ThreadCatalogModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ class ThreadCatalogModel final : public GModel {

String m_board { "g" };
JsonArray m_catalog;
RefPtr<CHttpJob> m_pending_job;
RefPtr<Core::HttpJob> m_pending_job;
};
4 changes: 2 additions & 2 deletions Applications/DisplayProperties/DisplayProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion Applications/DisplayProperties/DisplayProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DisplayPropertiesWidget final {

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;
Expand Down
4 changes: 2 additions & 2 deletions Applications/FileManager/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Applications/FileManager/PropertiesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion Applications/FileManager/PropertiesDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PropertiesDialog final : public GDialog {
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;
Expand Down
2 changes: 1 addition & 1 deletion Applications/FileManager/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion Applications/Help/ManualSectionNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions Applications/Help/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Applications/HexEditor/HexEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Applications/HexEditor/HexEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class HexEditor : public GScrollableWidget {
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 };
Expand Down
4 changes: 2 additions & 2 deletions Applications/HexEditor/HexEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions Applications/IRCClient/IRCClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
9 changes: 4 additions & 5 deletions Applications/IRCClient/IRCClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -162,10 +161,10 @@ class IRCClient final : public CObject {
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;

Expand All @@ -175,5 +174,5 @@ class IRCClient final : public CObject {

NonnullRefPtr<IRCWindowListModel> m_client_window_list_model;
NonnullRefPtr<IRCLogBuffer> m_log;
NonnullRefPtr<CConfigFile> m_config;
NonnullRefPtr<Core::ConfigFile> m_config;
};
2 changes: 1 addition & 1 deletion Applications/PaintBrush/SprayTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

SprayTool::SprayTool()
{
m_timer = CTimer::construct();
m_timer = Core::Timer::construct();
m_timer->on_timeout = [&]() {
paint_it();
};
Expand Down
2 changes: 1 addition & 1 deletion Applications/PaintBrush/SprayTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SprayTool final : public Tool {
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;
Expand Down
2 changes: 1 addition & 1 deletion Applications/Piano/MainWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions Applications/Piano/MainWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

#pragma once

#include "Music.h"
#include <LibGUI/GWidget.h>
#include <Music.h>

class AudioEngine;
class WaveWidget;
Expand All @@ -48,7 +48,7 @@ class MainWidget final : public GWidget {

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);
Expand Down
8 changes: 4 additions & 4 deletions Applications/Piano/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Applications/SoundPlayer/PlaybackManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Applications/SoundPlayer/PlaybackManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ class PlaybackManager final {
RefPtr<ABuffer> m_next_buffer;
RefPtr<ABuffer> m_current_buffer;
Vector<RefPtr<ABuffer>> m_buffers;
RefPtr<CTimer> m_timer;
RefPtr<Core::Timer> m_timer;
};
6 changes: 3 additions & 3 deletions Applications/SystemMonitor/DevicesModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions Applications/SystemMonitor/MemoryStatsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Applications/SystemMonitor/NetworkStatisticsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down
2 changes: 1 addition & 1 deletion Applications/SystemMonitor/NetworkStatisticsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ class NetworkStatisticsWidget final : public GLazyWidget {

RefPtr<GTableView> m_adapter_table_view;
RefPtr<GTableView> m_socket_table_view;
RefPtr<CTimer> m_update_timer;
RefPtr<Core::Timer> m_update_timer;
};
2 changes: 1 addition & 1 deletion Applications/SystemMonitor/ProcessMemoryMapWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 5 additions & 2 deletions Applications/SystemMonitor/ProcessMemoryMapWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@

#include <LibGUI/GWidget.h>

class CTimer;
namespace Core {
class Timer;
}

class GJsonArrayModel;
class GTableView;

Expand All @@ -45,5 +48,5 @@ class ProcessMemoryMapWidget final : public GWidget {
RefPtr<GTableView> m_table_view;
RefPtr<GJsonArrayModel> m_json_model;
pid_t m_pid { -1 };
RefPtr<CTimer> m_timer;
RefPtr<Core::Timer> m_timer;
};
2 changes: 1 addition & 1 deletion Applications/SystemMonitor/ProcessModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions Applications/SystemMonitor/ProcessStacksWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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;
}
Expand Down
Loading

0 comments on commit 2d39da5

Please sign in to comment.