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

@ -135,7 +135,7 @@ void Service::setup_socket()
ASSERT_NOT_REACHED();
}
auto socket_address = CSocketAddress::local(m_socket_path);
auto socket_address = Core::SocketAddress::local(m_socket_path);
auto un = socket_address.to_sockaddr_un();
int rc = bind(m_socket_fd, (const sockaddr*)&un, sizeof(un));
if (rc < 0) {
@ -156,7 +156,7 @@ void Service::setup_notifier()
ASSERT(m_socket_fd >= 0);
ASSERT(!m_socket_notifier);
m_socket_notifier = CNotifier::construct(m_socket_fd, CNotifier::Event::Read, this);
m_socket_notifier = Core::Notifier::construct(m_socket_fd, Core::Notifier::Event::Read, this);
m_socket_notifier->on_ready_to_read = [this] {
dbg() << "Ready to read on behalf of " << name();
remove_child(*m_socket_notifier);
@ -267,8 +267,8 @@ void Service::did_exit(int exit_code)
activate();
}
Service::Service(const CConfigFile& config, const StringView& name)
: CObject(nullptr)
Service::Service(const Core::ConfigFile& config, const StringView& name)
: Core::Object(nullptr)
{
ASSERT(config.has_group(name));
@ -304,7 +304,7 @@ Service::Service(const CConfigFile& config, const StringView& name)
void Service::save_to(JsonObject& json)
{
CObject::save_to(json);
Core::Object::save_to(json);
json.set("executable_path", m_executable_path);

View file

@ -31,13 +31,14 @@
#include <LibCore/CNotifier.h>
#include <LibCore/CObject.h>
class CConfigFile;
namespace AK {
class JsonObject;
}
namespace Core {
class ConfigFile;
}
class Service final : public CObject {
class Service final : public Core::Object {
C_OBJECT(Service)
public:
@ -49,7 +50,7 @@ public:
void save_to(AK::JsonObject&) override;
private:
Service(const CConfigFile&, const StringView& name);
Service(const Core::ConfigFile&, const StringView& name);
void spawn();
@ -78,7 +79,7 @@ private:
pid_t m_pid { -1 };
// An open fd to the socket.
int m_socket_fd { -1 };
RefPtr<CNotifier> m_socket_notifier;
RefPtr<Core::Notifier> m_socket_notifier;
void resolve_user();
void setup_socket();

View file

@ -54,16 +54,16 @@ static void sigchld_handler(int)
// We wouldn't want to run the complex logic, such
// as possibly spawning the service again, from the
// signal handler, so defer it.
CEventLoop::main().post_event(*service, make<CDeferredInvocationEvent>([=](CObject&) {
Core::EventLoop::main().post_event(*service, make<Core::DeferredInvocationEvent>([=](auto&) {
service->did_exit(status);
}));
CEventLoop::wake();
Core::EventLoop::wake();
}
static void check_for_test_mode()
{
auto f = CFile::construct("/proc/cmdline");
if (!f->open(CIODevice::ReadOnly)) {
auto f = Core::File::construct("/proc/cmdline");
if (!f->open(Core::IODevice::ReadOnly)) {
dbg() << "Failed to read command line: " << f->error_string();
ASSERT(false);
}
@ -117,12 +117,12 @@ int main(int, char**)
};
sigaction(SIGCHLD, &sa, nullptr);
CEventLoop event_loop;
Core::EventLoop event_loop;
// Read our config and instantiate services.
// This takes care of setting up sockets.
Vector<RefPtr<Service>> services;
auto config = CConfigFile::get_for_system("SystemServer");
auto config = Core::ConfigFile::get_for_system("SystemServer");
for (auto name : config->groups())
services.append(Service::construct(*config, name));