1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:47:45 +00:00

Userland: Split IPC endpoints into proxies and stubs

This enables support for automatically generating client methods.
With this added the user gets code completion support for all
IPC methods which are available on a connection object.
This commit is contained in:
Gunnar Beutner 2021-05-03 08:46:40 +02:00 committed by Andreas Kling
parent 065040872f
commit 78803ce384
20 changed files with 175 additions and 53 deletions

View file

@ -28,8 +28,11 @@ namespace IPC {
template<typename LocalEndpoint, typename PeerEndpoint>
class Connection : public Core::Object {
public:
Connection(LocalEndpoint& local_endpoint, NonnullRefPtr<Core::LocalSocket> socket)
: m_local_endpoint(local_endpoint)
using LocalStub = typename LocalEndpoint::Stub;
using PeerProxy = typename PeerEndpoint::Proxy;
Connection(LocalStub& local_stub, NonnullRefPtr<Core::LocalSocket> socket)
: m_local_stub(local_stub)
, m_socket(move(socket))
, m_notifier(Core::Notifier::construct(m_socket->fd(), Core::Notifier::Read, this))
{
@ -248,13 +251,13 @@ protected:
auto messages = move(m_unprocessed_messages);
for (auto& message : messages) {
if (message.endpoint_magic() == LocalEndpoint::static_magic())
if (auto response = m_local_endpoint.handle(message))
if (auto response = m_local_stub.handle(message))
post_message(*response);
}
}
protected:
LocalEndpoint& m_local_endpoint;
LocalStub& m_local_stub;
NonnullRefPtr<Core::LocalSocket> m_socket;
RefPtr<Core::Timer> m_responsiveness_timer;