From 59218007a3034c7770b7fa5277ce1eae85bb1c07 Mon Sep 17 00:00:00 2001 From: sin-ack Date: Sun, 25 Apr 2021 08:04:17 +0200 Subject: [PATCH] IPCCompiler: Use string hashes for IPC endpoint magic 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. :^) --- .../DevTools/HackStudio/LanguageServers/LanguageClient.ipc | 2 +- .../DevTools/HackStudio/LanguageServers/LanguageServer.ipc | 2 +- Userland/DevTools/IPCCompiler/main.cpp | 6 +----- Userland/Services/AudioServer/AudioClient.ipc | 2 +- Userland/Services/AudioServer/AudioServer.ipc | 2 +- Userland/Services/Clipboard/ClipboardClient.ipc | 2 +- Userland/Services/Clipboard/ClipboardServer.ipc | 2 +- Userland/Services/ImageDecoder/ImageDecoderClient.ipc | 2 +- Userland/Services/ImageDecoder/ImageDecoderServer.ipc | 2 +- Userland/Services/LaunchServer/LaunchClient.ipc | 2 +- Userland/Services/LaunchServer/LaunchServer.ipc | 2 +- Userland/Services/LookupServer/LookupClient.ipc | 2 +- Userland/Services/LookupServer/LookupServer.ipc | 2 +- Userland/Services/NotificationServer/NotificationClient.ipc | 2 +- Userland/Services/NotificationServer/NotificationServer.ipc | 2 +- Userland/Services/ProtocolServer/ProtocolClient.ipc | 2 +- Userland/Services/ProtocolServer/ProtocolServer.ipc | 2 +- Userland/Services/SymbolServer/SymbolClient.ipc | 2 +- Userland/Services/SymbolServer/SymbolServer.ipc | 2 +- Userland/Services/WebContent/WebContentClient.ipc | 2 +- Userland/Services/WebContent/WebContentServer.ipc | 2 +- Userland/Services/WindowServer/WindowClient.ipc | 2 +- Userland/Services/WindowServer/WindowManagerClient.ipc | 2 +- Userland/Services/WindowServer/WindowManagerServer.ipc | 2 +- Userland/Services/WindowServer/WindowServer.ipc | 2 +- 25 files changed, 25 insertions(+), 29 deletions(-) diff --git a/Userland/DevTools/HackStudio/LanguageServers/LanguageClient.ipc b/Userland/DevTools/HackStudio/LanguageServers/LanguageClient.ipc index 889a37623e5..8a20b31fb87 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 suggestions) =| DeclarationLocation(GUI::AutocompleteProvider::ProjectLocation location) =| diff --git a/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc b/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc index c8d804410a8..938d616be2a 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 1f5aa08a258..fbd3012de15 100644 --- a/Userland/DevTools/IPCCompiler/main.cpp +++ b/Userland/DevTools/IPCCompiler/main.cpp @@ -164,11 +164,7 @@ int main(int argc, char** argv) lexer.consume_specific("endpoint"); consume_whitespace(); endpoints.last().name = lexer.consume_while([](char ch) { return !isspace(ch); }); - 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(); + endpoints.last().magic = Traits::hash(endpoints.last().name); consume_whitespace(); assert_specific('{'); parse_messages(); diff --git a/Userland/Services/AudioServer/AudioClient.ipc b/Userland/Services/AudioServer/AudioClient.ipc index b43db52dd0f..d444c6c0073 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 a52a837f41e..f268e747bd4 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 50d695e92a2..d0d3a061a6c 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 1c6372cb4e6..9fe63e2fc00 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 49dc3862c25..4b486e38b20 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 c2808822dfd..41f135c4b08 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 abd4e9ba3d4..2e4f324702d 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 34ac5a6db3c..7d160f484f6 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 6455140d91c..567b6fcb82a 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 e23182346ac..499e2290a4a 100644 --- a/Userland/Services/LookupServer/LookupServer.ipc +++ b/Userland/Services/LookupServer/LookupServer.ipc @@ -1,4 +1,4 @@ -endpoint LookupServer = 9001 +endpoint LookupServer { LookupName(String name) => (int code, Vector addresses) LookupAddress(String address) => (int code, String name) diff --git a/Userland/Services/NotificationServer/NotificationClient.ipc b/Userland/Services/NotificationServer/NotificationClient.ipc index fc85168f769..9742ea513d7 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 830e9d63126..2a3c61932ba 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 88f4cfc96d1..37707472a66 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 total_size, u32 downloaded_size) =| diff --git a/Userland/Services/ProtocolServer/ProtocolServer.ipc b/Userland/Services/ProtocolServer/ProtocolServer.ipc index 3a8ecdabad3..2348e01af82 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 575a17f5092..8b4a1be029d 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 a578b018098..d1eed6ac038 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 c74abbc3aff..c7aad24ca09 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 1b429c55794..1f6e30ce224 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 c7ffb91a5b4..ea8f49635da 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 rects) =| MouseMove(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta, bool is_drag, Vector mime_types) =| diff --git a/Userland/Services/WindowServer/WindowManagerClient.ipc b/Userland/Services/WindowServer/WindowManagerClient.ipc index 4c3c9c071d6..facda30d8ef 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 2973d31241c..e0c12f72c92 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 a0f5135d721..948e6c7bce4 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)