summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2021-04-25 13:19:53 +0200
committerLinus Groh <mail@linusgroh.de>2021-04-25 14:06:56 +0200
commit62af6cd4f9637b8937e59832f5af00f4556c496b (patch)
treebdf998938966c8fb949f655d95ba697e830eba87 /Userland
parent64d05152f74fd2b6bb4cb723700335282fb32659 (diff)
downloadserenity-62af6cd4f9637b8937e59832f5af00f4556c496b.zip
IPCCompiler: Remove hardcoded endpoint magic, attempt deux
This patch removes the IPC endpoint numbers that needed to be specified in the IPC files. Since the string hash is a (hopefully) collision free number that depends on the name of the endpoint, we now use that instead. :^) Additionally, endpoint magic is now treated as a u32, because endpoint numbers were never negative anyway. For cases where the endpoint number does have to be hardcoded (a current case is LookupServer because the endpoint number must be known in LibC), the syntax has been made more explicit to avoid confusing those unfamiliar. To hardcode the endpoint magic, the following syntax is now used: endpoint EndpointName [magic=1234]
Diffstat (limited to 'Userland')
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/LanguageClient.ipc2
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc2
-rw-r--r--Userland/DevTools/IPCCompiler/main.cpp42
-rw-r--r--Userland/Libraries/LibC/netdb.cpp5
-rw-r--r--Userland/Libraries/LibIPC/Endpoint.h2
-rw-r--r--Userland/Libraries/LibIPC/Message.h2
-rw-r--r--Userland/Services/AudioServer/AudioClient.ipc2
-rw-r--r--Userland/Services/AudioServer/AudioServer.ipc2
-rw-r--r--Userland/Services/Clipboard/ClipboardClient.ipc2
-rw-r--r--Userland/Services/Clipboard/ClipboardServer.ipc2
-rw-r--r--Userland/Services/ImageDecoder/ImageDecoderClient.ipc2
-rw-r--r--Userland/Services/ImageDecoder/ImageDecoderServer.ipc2
-rw-r--r--Userland/Services/LaunchServer/LaunchClient.ipc2
-rw-r--r--Userland/Services/LaunchServer/LaunchServer.ipc2
-rw-r--r--Userland/Services/LookupServer/LookupClient.ipc2
-rw-r--r--Userland/Services/LookupServer/LookupServer.ipc2
-rw-r--r--Userland/Services/NotificationServer/NotificationClient.ipc2
-rw-r--r--Userland/Services/NotificationServer/NotificationServer.ipc2
-rw-r--r--Userland/Services/ProtocolServer/ProtocolClient.ipc2
-rw-r--r--Userland/Services/ProtocolServer/ProtocolServer.ipc2
-rw-r--r--Userland/Services/SymbolServer/SymbolClient.ipc2
-rw-r--r--Userland/Services/SymbolServer/SymbolServer.ipc2
-rw-r--r--Userland/Services/WebContent/WebContentClient.ipc2
-rw-r--r--Userland/Services/WebContent/WebContentServer.ipc2
-rw-r--r--Userland/Services/WindowServer/WindowClient.ipc2
-rw-r--r--Userland/Services/WindowServer/WindowManagerClient.ipc2
-rw-r--r--Userland/Services/WindowServer/WindowManagerServer.ipc2
-rw-r--r--Userland/Services/WindowServer/WindowServer.ipc2
28 files changed, 62 insertions, 37 deletions
diff --git a/Userland/DevTools/HackStudio/LanguageServers/LanguageClient.ipc b/Userland/DevTools/HackStudio/LanguageServers/LanguageClient.ipc
index 889a37623e..8a20b31fb8 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/LanguageClient.ipc
+++ b/Userland/DevTools/HackStudio/LanguageServers/LanguageClient.ipc
@@ -1,4 +1,4 @@
-endpoint LanguageClient = 8002
+endpoint LanguageClient
{
AutoCompleteSuggestions(Vector<GUI::AutocompleteProvider::Entry> suggestions) =|
DeclarationLocation(GUI::AutocompleteProvider::ProjectLocation location) =|
diff --git a/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc b/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc
index c8d804410a..938d616be2 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc
+++ b/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc
@@ -1,4 +1,4 @@
-endpoint LanguageServer = 8001
+endpoint LanguageServer
{
Greet(String project_root) => ()
diff --git a/Userland/DevTools/IPCCompiler/main.cpp b/Userland/DevTools/IPCCompiler/main.cpp
index 1f5aa08a25..869f1f48d0 100644
--- a/Userland/DevTools/IPCCompiler/main.cpp
+++ b/Userland/DevTools/IPCCompiler/main.cpp
@@ -37,7 +37,7 @@ struct Message {
struct Endpoint {
String name;
- int magic;
+ u32 magic;
Vector<Message> messages;
};
@@ -164,12 +164,32 @@ int main(int argc, char** argv)
lexer.consume_specific("endpoint");
consume_whitespace();
endpoints.last().name = lexer.consume_while([](char ch) { return !isspace(ch); });
+ endpoints.last().magic = Traits<String>::hash(endpoints.last().name);
consume_whitespace();
- assert_specific('=');
- consume_whitespace();
- auto magic_string = lexer.consume_while([](char ch) { return !isspace(ch) && ch != '{'; });
- endpoints.last().magic = magic_string.to_int().value();
- consume_whitespace();
+ if (lexer.peek() == '[') {
+ // This only supports a single parameter for now, and adding multiple
+ // endpoint parameter support is left as an exercise for the reader. :^)
+
+ lexer.consume_specific('[');
+ consume_whitespace();
+
+ auto parameter = lexer.consume_while([](char ch) { return !isspace(ch) && ch != '='; });
+ consume_whitespace();
+ assert_specific('=');
+ consume_whitespace();
+
+ if (parameter == "magic") {
+ // "magic" overwrites the default magic with a hardcoded one.
+ auto magic_string = lexer.consume_while([](char ch) { return !isspace(ch) && ch != ']'; });
+ endpoints.last().magic = magic_string.to_uint().value();
+ } else {
+ warnln("parse_endpoint: unknown parameter '{}' passed", parameter);
+ VERIFY_NOT_REACHED();
+ }
+
+ assert_specific(']');
+ consume_whitespace();
+ }
assert_specific('{');
parse_messages();
assert_specific('}');
@@ -292,7 +312,7 @@ public:
@message.constructor@
virtual ~@message.name@() override {}
- virtual i32 endpoint_magic() const override { return @endpoint.magic@; }
+ virtual u32 endpoint_magic() const override { return @endpoint.magic@; }
virtual i32 message_id() const override { return (int)MessageID::@message.name@; }
static i32 static_message_id() { return (int)MessageID::@message.name@; }
virtual const char* message_name() const override { return "@endpoint.name@::@message.name@"; }
@@ -412,15 +432,15 @@ public:
@endpoint.name@Endpoint() { }
virtual ~@endpoint.name@Endpoint() override { }
- static int static_magic() { return @endpoint.magic@; }
- virtual int magic() const override { return @endpoint.magic@; }
+ static u32 static_magic() { return @endpoint.magic@; }
+ virtual u32 magic() const override { return @endpoint.magic@; }
static String static_name() { return "@endpoint.name@"; }
virtual String name() const override { return "@endpoint.name@"; }
static OwnPtr<IPC::Message> decode_message(ReadonlyBytes buffer, int sockfd)
{
InputMemoryStream stream { buffer };
- i32 message_endpoint_magic = 0;
+ u32 message_endpoint_magic = 0;
stream >> message_endpoint_magic;
if (stream.handle_any_error()) {
)~~~");
@@ -437,7 +457,7 @@ public:
)~~~");
#if GENERATE_DEBUG_CODE
endpoint_generator.append(R"~~~(
- dbgln("Endpoint magic number message_endpoint_magic != @endpoint.magic@");
+ dbgln("@endpoint.name@: Endpoint magic number message_endpoint_magic != @endpoint.magic@, not my message! (the other endpoint may have handled it)");
)~~~");
#endif
endpoint_generator.append(R"~~~(
diff --git a/Userland/Libraries/LibC/netdb.cpp b/Userland/Libraries/LibC/netdb.cpp
index 7b3605f1f9..0fb7b72259 100644
--- a/Userland/Libraries/LibC/netdb.cpp
+++ b/Userland/Libraries/LibC/netdb.cpp
@@ -26,6 +26,11 @@ static in_addr_t* __gethostbyname_address_list_buffer[2];
static hostent __gethostbyaddr_buffer;
static in_addr_t* __gethostbyaddr_address_list_buffer[2];
+// XXX: IPCCompiler depends on LibC. Because of this, it cannot be compiled
+// before LibC is. However, the lookup magic can only be obtained from the
+// endpoint itself if IPCCompiler has compiled the IPC file, so this creates
+// a chicken-and-egg situation. Because of this, the LookupServer endpoint magic
+// is hardcoded here.
static constexpr i32 lookup_server_endpoint_magic = 9001;
// Get service entry buffers and file information for the getservent() family of functions.
diff --git a/Userland/Libraries/LibIPC/Endpoint.h b/Userland/Libraries/LibIPC/Endpoint.h
index ee027a308c..96176899f4 100644
--- a/Userland/Libraries/LibIPC/Endpoint.h
+++ b/Userland/Libraries/LibIPC/Endpoint.h
@@ -21,7 +21,7 @@ class Endpoint {
public:
virtual ~Endpoint();
- virtual int magic() const = 0;
+ virtual u32 magic() const = 0;
virtual String name() const = 0;
virtual OwnPtr<Message> handle(const Message&) = 0;
diff --git a/Userland/Libraries/LibIPC/Message.h b/Userland/Libraries/LibIPC/Message.h
index b3ae172160..f2aae86633 100644
--- a/Userland/Libraries/LibIPC/Message.h
+++ b/Userland/Libraries/LibIPC/Message.h
@@ -20,7 +20,7 @@ class Message {
public:
virtual ~Message();
- virtual int endpoint_magic() const = 0;
+ virtual u32 endpoint_magic() const = 0;
virtual int message_id() const = 0;
virtual const char* message_name() const = 0;
virtual MessageBuffer encode() const = 0;
diff --git a/Userland/Services/AudioServer/AudioClient.ipc b/Userland/Services/AudioServer/AudioClient.ipc
index b43db52dd0..d444c6c007 100644
--- a/Userland/Services/AudioServer/AudioClient.ipc
+++ b/Userland/Services/AudioServer/AudioClient.ipc
@@ -1,4 +1,4 @@
-endpoint AudioClient = 82
+endpoint AudioClient
{
FinishedPlayingBuffer(i32 buffer_id) =|
MutedStateChanged(bool muted) =|
diff --git a/Userland/Services/AudioServer/AudioServer.ipc b/Userland/Services/AudioServer/AudioServer.ipc
index a52a837f41..f268e747bd 100644
--- a/Userland/Services/AudioServer/AudioServer.ipc
+++ b/Userland/Services/AudioServer/AudioServer.ipc
@@ -1,4 +1,4 @@
-endpoint AudioServer = 85
+endpoint AudioServer
{
// Basic protocol
Greet() => ()
diff --git a/Userland/Services/Clipboard/ClipboardClient.ipc b/Userland/Services/Clipboard/ClipboardClient.ipc
index 50d695e92a..d0d3a061a6 100644
--- a/Userland/Services/Clipboard/ClipboardClient.ipc
+++ b/Userland/Services/Clipboard/ClipboardClient.ipc
@@ -1,4 +1,4 @@
-endpoint ClipboardClient = 804
+endpoint ClipboardClient
{
ClipboardDataChanged([UTF8] String mime_type) =|
}
diff --git a/Userland/Services/Clipboard/ClipboardServer.ipc b/Userland/Services/Clipboard/ClipboardServer.ipc
index 1c6372cb4e..9fe63e2fc0 100644
--- a/Userland/Services/Clipboard/ClipboardServer.ipc
+++ b/Userland/Services/Clipboard/ClipboardServer.ipc
@@ -1,4 +1,4 @@
-endpoint ClipboardServer = 802
+endpoint ClipboardServer
{
Greet() => ()
diff --git a/Userland/Services/ImageDecoder/ImageDecoderClient.ipc b/Userland/Services/ImageDecoder/ImageDecoderClient.ipc
index 49dc3862c2..4b486e38b2 100644
--- a/Userland/Services/ImageDecoder/ImageDecoderClient.ipc
+++ b/Userland/Services/ImageDecoder/ImageDecoderClient.ipc
@@ -1,4 +1,4 @@
-endpoint ImageDecoderClient = 7002
+endpoint ImageDecoderClient
{
Dummy() =|
}
diff --git a/Userland/Services/ImageDecoder/ImageDecoderServer.ipc b/Userland/Services/ImageDecoder/ImageDecoderServer.ipc
index c2808822df..41f135c4b0 100644
--- a/Userland/Services/ImageDecoder/ImageDecoderServer.ipc
+++ b/Userland/Services/ImageDecoder/ImageDecoderServer.ipc
@@ -1,4 +1,4 @@
-endpoint ImageDecoderServer = 7001
+endpoint ImageDecoderServer
{
Greet() => ()
diff --git a/Userland/Services/LaunchServer/LaunchClient.ipc b/Userland/Services/LaunchServer/LaunchClient.ipc
index abd4e9ba3d..2e4f324702 100644
--- a/Userland/Services/LaunchServer/LaunchClient.ipc
+++ b/Userland/Services/LaunchServer/LaunchClient.ipc
@@ -1,4 +1,4 @@
-endpoint LaunchClient = 102
+endpoint LaunchClient
{
Dummy() =|
}
diff --git a/Userland/Services/LaunchServer/LaunchServer.ipc b/Userland/Services/LaunchServer/LaunchServer.ipc
index 34ac5a6db3..7d160f484f 100644
--- a/Userland/Services/LaunchServer/LaunchServer.ipc
+++ b/Userland/Services/LaunchServer/LaunchServer.ipc
@@ -1,4 +1,4 @@
-endpoint LaunchServer = 101
+endpoint LaunchServer
{
Greet() => ()
OpenURL(URL url, String handler_name) => (bool response)
diff --git a/Userland/Services/LookupServer/LookupClient.ipc b/Userland/Services/LookupServer/LookupClient.ipc
index 6455140d91..567b6fcb82 100644
--- a/Userland/Services/LookupServer/LookupClient.ipc
+++ b/Userland/Services/LookupServer/LookupClient.ipc
@@ -1,4 +1,4 @@
-endpoint LookupClient = 9002
+endpoint LookupClient
{
Dummy() =|
}
diff --git a/Userland/Services/LookupServer/LookupServer.ipc b/Userland/Services/LookupServer/LookupServer.ipc
index e23182346a..a3e88a19c0 100644
--- a/Userland/Services/LookupServer/LookupServer.ipc
+++ b/Userland/Services/LookupServer/LookupServer.ipc
@@ -1,4 +1,4 @@
-endpoint LookupServer = 9001
+endpoint LookupServer [magic=9001]
{
LookupName(String name) => (int code, Vector<String> addresses)
LookupAddress(String address) => (int code, String name)
diff --git a/Userland/Services/NotificationServer/NotificationClient.ipc b/Userland/Services/NotificationServer/NotificationClient.ipc
index fc85168f76..9742ea513d 100644
--- a/Userland/Services/NotificationServer/NotificationClient.ipc
+++ b/Userland/Services/NotificationServer/NotificationClient.ipc
@@ -1,4 +1,4 @@
-endpoint NotificationClient = 92
+endpoint NotificationClient
{
Dummy() =|
}
diff --git a/Userland/Services/NotificationServer/NotificationServer.ipc b/Userland/Services/NotificationServer/NotificationServer.ipc
index 830e9d6312..2a3c61932b 100644
--- a/Userland/Services/NotificationServer/NotificationServer.ipc
+++ b/Userland/Services/NotificationServer/NotificationServer.ipc
@@ -1,4 +1,4 @@
-endpoint NotificationServer = 95
+endpoint NotificationServer
{
// Basic protocol
Greet() => ()
diff --git a/Userland/Services/ProtocolServer/ProtocolClient.ipc b/Userland/Services/ProtocolServer/ProtocolClient.ipc
index 88f4cfc96d..37707472a6 100644
--- a/Userland/Services/ProtocolServer/ProtocolClient.ipc
+++ b/Userland/Services/ProtocolServer/ProtocolClient.ipc
@@ -1,4 +1,4 @@
-endpoint ProtocolClient = 13
+endpoint ProtocolClient
{
// Download notifications
DownloadProgress(i32 download_id, Optional<u32> total_size, u32 downloaded_size) =|
diff --git a/Userland/Services/ProtocolServer/ProtocolServer.ipc b/Userland/Services/ProtocolServer/ProtocolServer.ipc
index 3a8ecdabad..2348e01af8 100644
--- a/Userland/Services/ProtocolServer/ProtocolServer.ipc
+++ b/Userland/Services/ProtocolServer/ProtocolServer.ipc
@@ -1,4 +1,4 @@
-endpoint ProtocolServer = 9
+endpoint ProtocolServer
{
// Basic protocol
Greet() => ()
diff --git a/Userland/Services/SymbolServer/SymbolClient.ipc b/Userland/Services/SymbolServer/SymbolClient.ipc
index 575a17f509..8b4a1be029 100644
--- a/Userland/Services/SymbolServer/SymbolClient.ipc
+++ b/Userland/Services/SymbolServer/SymbolClient.ipc
@@ -1,4 +1,4 @@
-endpoint SymbolClient = 4541511
+endpoint SymbolClient
{
Dummy() =|
}
diff --git a/Userland/Services/SymbolServer/SymbolServer.ipc b/Userland/Services/SymbolServer/SymbolServer.ipc
index a578b01809..d1eed6ac03 100644
--- a/Userland/Services/SymbolServer/SymbolServer.ipc
+++ b/Userland/Services/SymbolServer/SymbolServer.ipc
@@ -1,4 +1,4 @@
-endpoint SymbolServer = 4541510
+endpoint SymbolServer
{
Greet() => ()
diff --git a/Userland/Services/WebContent/WebContentClient.ipc b/Userland/Services/WebContent/WebContentClient.ipc
index c74abbc3af..c7aad24ca0 100644
--- a/Userland/Services/WebContent/WebContentClient.ipc
+++ b/Userland/Services/WebContent/WebContentClient.ipc
@@ -1,4 +1,4 @@
-endpoint WebContentClient = 90
+endpoint WebContentClient
{
DidStartLoading(URL url) =|
DidFinishLoading(URL url) =|
diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc
index 1b429c5579..1f6e30ce22 100644
--- a/Userland/Services/WebContent/WebContentServer.ipc
+++ b/Userland/Services/WebContent/WebContentServer.ipc
@@ -1,4 +1,4 @@
-endpoint WebContentServer = 89
+endpoint WebContentServer
{
Greet() => ()
diff --git a/Userland/Services/WindowServer/WindowClient.ipc b/Userland/Services/WindowServer/WindowClient.ipc
index c7ffb91a5b..ea8f49635d 100644
--- a/Userland/Services/WindowServer/WindowClient.ipc
+++ b/Userland/Services/WindowServer/WindowClient.ipc
@@ -1,4 +1,4 @@
-endpoint WindowClient = 4
+endpoint WindowClient
{
Paint(i32 window_id, Gfx::IntSize window_size, Vector<Gfx::IntRect> rects) =|
MouseMove(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta, bool is_drag, Vector<String> mime_types) =|
diff --git a/Userland/Services/WindowServer/WindowManagerClient.ipc b/Userland/Services/WindowServer/WindowManagerClient.ipc
index 4c3c9c071d..facda30d8e 100644
--- a/Userland/Services/WindowServer/WindowManagerClient.ipc
+++ b/Userland/Services/WindowServer/WindowManagerClient.ipc
@@ -1,4 +1,4 @@
-endpoint WindowManagerClient = 1872
+endpoint WindowManagerClient
{
WindowRemoved(i32 wm_id, i32 client_id, i32 window_id) =|
WindowStateChanged(i32 wm_id, i32 client_id, i32 window_id, i32 parent_client_id, i32 parent_window_id, bool is_active, bool is_minimized, bool is_modal, bool is_frameless, i32 window_type, [UTF8] String title, Gfx::IntRect rect, i32 progress) =|
diff --git a/Userland/Services/WindowServer/WindowManagerServer.ipc b/Userland/Services/WindowServer/WindowManagerServer.ipc
index 2973d31241..e0c12f72c9 100644
--- a/Userland/Services/WindowServer/WindowManagerServer.ipc
+++ b/Userland/Services/WindowServer/WindowManagerServer.ipc
@@ -1,4 +1,4 @@
-endpoint WindowManagerServer = 1871
+endpoint WindowManagerServer
{
SetEventMask(u32 event_mask) => ()
SetManagerWindow(i32 window_id) => ()
diff --git a/Userland/Services/WindowServer/WindowServer.ipc b/Userland/Services/WindowServer/WindowServer.ipc
index a0f5135d72..948e6c7bce 100644
--- a/Userland/Services/WindowServer/WindowServer.ipc
+++ b/Userland/Services/WindowServer/WindowServer.ipc
@@ -1,4 +1,4 @@
-endpoint WindowServer = 2
+endpoint WindowServer
{
Greet() => (Gfx::IntRect screen_rect, Core::AnonymousBuffer theme_buffer)