From da6b928909c6016d1526fbdaf33d37c4c42c49d7 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Fri, 13 Mar 2026 17:11:22 +0100 Subject: [PATCH] LibIPC+LibWeb: Introduce IPC::Attachment abstraction Replace IPC::File / AutoCloseFileDescriptor / MessageFileType in the IPC message pipeline with a new IPC::Attachment class. This wraps a file descriptor transferred alongside IPC messages, and provides a clean extension point for platform-specific transport mechanisms (e.g., Mach ports on macOS) that will be introduced later. --- Libraries/LibIPC/Attachment.cpp | 45 +++++++++++++++++++ Libraries/LibIPC/Attachment.h | 29 ++++++++++++ Libraries/LibIPC/CMakeLists.txt | 2 + Libraries/LibIPC/Connection.cpp | 2 +- Libraries/LibIPC/Connection.h | 10 ++--- Libraries/LibIPC/Decoder.h | 9 ++-- Libraries/LibIPC/Encoder.cpp | 3 +- Libraries/LibIPC/Encoder.h | 5 ++- Libraries/LibIPC/File.cpp | 10 +++-- Libraries/LibIPC/Forward.h | 2 +- Libraries/LibIPC/Message.cpp | 17 ++++--- Libraries/LibIPC/Message.h | 13 +++--- Libraries/LibIPC/MessageWindows.cpp | 8 +++- Libraries/LibIPC/TransportSocket.cpp | 27 ++++++----- Libraries/LibIPC/TransportSocket.h | 9 ++-- Libraries/LibIPC/TransportSocketWindows.h | 4 +- Libraries/LibWeb/HTML/MessagePort.cpp | 2 +- Libraries/LibWeb/HTML/StructuredSerialize.cpp | 32 +++++-------- Libraries/LibWeb/HTML/StructuredSerialize.h | 2 +- .../Tools/CodeGenerators/IPCCompiler/main.cpp | 9 ++-- 20 files changed, 162 insertions(+), 78 deletions(-) create mode 100644 Libraries/LibIPC/Attachment.cpp create mode 100644 Libraries/LibIPC/Attachment.h diff --git a/Libraries/LibIPC/Attachment.cpp b/Libraries/LibIPC/Attachment.cpp new file mode 100644 index 0000000000..aa7fdd230f --- /dev/null +++ b/Libraries/LibIPC/Attachment.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2026, Aliaksandr Kalenik + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include + +namespace IPC { + +Attachment::Attachment(Attachment&& other) + : m_fd(exchange(other.m_fd, -1)) +{ +} + +Attachment& Attachment::operator=(Attachment&& other) +{ + if (this != &other) { + if (m_fd != -1) + (void)Core::System::close(m_fd); + m_fd = exchange(other.m_fd, -1); + } + return *this; +} + +Attachment::~Attachment() +{ + if (m_fd != -1) + (void)Core::System::close(m_fd); +} + +Attachment Attachment::from_fd(int fd) +{ + Attachment attachment; + attachment.m_fd = fd; + return attachment; +} + +int Attachment::to_fd() +{ + return exchange(m_fd, -1); +} + +} diff --git a/Libraries/LibIPC/Attachment.h b/Libraries/LibIPC/Attachment.h new file mode 100644 index 0000000000..12b38584cb --- /dev/null +++ b/Libraries/LibIPC/Attachment.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2026, Aliaksandr Kalenik + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace IPC { + +class Attachment { + AK_MAKE_NONCOPYABLE(Attachment); + +public: + Attachment() = default; + Attachment(Attachment&&); + Attachment& operator=(Attachment&&); + ~Attachment(); + + static Attachment from_fd(int fd); + int to_fd(); + +private: + int m_fd { -1 }; +}; + +} diff --git a/Libraries/LibIPC/CMakeLists.txt b/Libraries/LibIPC/CMakeLists.txt index d833e700b5..a7bac491d3 100644 --- a/Libraries/LibIPC/CMakeLists.txt +++ b/Libraries/LibIPC/CMakeLists.txt @@ -8,11 +8,13 @@ set(SOURCES if (UNIX) list(APPEND SOURCES + Attachment.cpp File.cpp Message.cpp TransportSocket.cpp) else() list(APPEND SOURCES + Attachment.cpp FileWindows.cpp MessageWindows.cpp TransportSocketWindows.cpp) diff --git a/Libraries/LibIPC/Connection.cpp b/Libraries/LibIPC/Connection.cpp index a30e6d5d6a..66eeb45608 100644 --- a/Libraries/LibIPC/Connection.cpp +++ b/Libraries/LibIPC/Connection.cpp @@ -97,7 +97,7 @@ ConnectionBase::PeerEOF ConnectionBase::drain_messages_from_peer() { bool parse_error = false; auto schedule_shutdown = m_transport->read_as_many_messages_as_possible_without_blocking([&](auto&& raw_message) { - if (auto message = try_parse_message(raw_message.bytes, raw_message.fds)) { + if (auto message = try_parse_message(raw_message.bytes, raw_message.attachments)) { m_unprocessed_messages.append(message.release_nonnull()); } else { dbgln("Failed to parse IPC message {:hex-dump}", raw_message.bytes); diff --git a/Libraries/LibIPC/Connection.h b/Libraries/LibIPC/Connection.h index c9b36e7858..0e5665ab40 100644 --- a/Libraries/LibIPC/Connection.h +++ b/Libraries/LibIPC/Connection.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -37,7 +37,7 @@ protected: explicit ConnectionBase(IPC::Stub&, NonnullOwnPtr, u32 local_endpoint_magic); virtual void shutdown_with_error(Error const&); - virtual OwnPtr try_parse_message(ReadonlyBytes, Queue&) = 0; + virtual OwnPtr try_parse_message(ReadonlyBytes, Queue&) = 0; OwnPtr wait_for_specific_endpoint_message_impl(u32 endpoint_magic, int message_id); void wait_for_transport_to_become_readable(); @@ -92,13 +92,13 @@ protected: return {}; } - virtual OwnPtr try_parse_message(ReadonlyBytes bytes, Queue& fds) override + virtual OwnPtr try_parse_message(ReadonlyBytes bytes, Queue& attachments) override { - auto local_message = LocalEndpoint::decode_message(bytes, fds); + auto local_message = LocalEndpoint::decode_message(bytes, attachments); if (!local_message.is_error()) return local_message.release_value(); - auto peer_message = PeerEndpoint::decode_message(bytes, fds); + auto peer_message = PeerEndpoint::decode_message(bytes, attachments); if (!peer_message.is_error()) return peer_message.release_value(); diff --git a/Libraries/LibIPC/Decoder.h b/Libraries/LibIPC/Decoder.h index d44e65a801..1805aa1674 100644 --- a/Libraries/LibIPC/Decoder.h +++ b/Libraries/LibIPC/Decoder.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -37,9 +38,9 @@ inline ErrorOr decode(Decoder&) class Decoder { public: - Decoder(Stream& stream, Queue& files) + Decoder(Stream& stream, Queue& attachments) : m_stream(stream) - , m_files(files) + , m_attachments(attachments) { } @@ -62,11 +63,11 @@ public: ErrorOr decode_size(); Stream& stream() { return m_stream; } - Queue& files() { return m_files; } + Queue& attachments() { return m_attachments; } private: Stream& m_stream; - Queue& m_files; + Queue& m_attachments; }; template diff --git a/Libraries/LibIPC/Encoder.cpp b/Libraries/LibIPC/Encoder.cpp index 2d5b146bb0..183efa2754 100644 --- a/Libraries/LibIPC/Encoder.cpp +++ b/Libraries/LibIPC/Encoder.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -173,7 +174,7 @@ ErrorOr encode(Encoder& encoder, File const& file) int fd = file.take_fd(); VERIFY(fd >= 0); - TRY(encoder.append_file_descriptor(fd)); + TRY(encoder.append_attachment(Attachment::from_fd(fd))); return {}; } diff --git a/Libraries/LibIPC/Encoder.h b/Libraries/LibIPC/Encoder.h index a59fb4565b..989c92ff2e 100644 --- a/Libraries/LibIPC/Encoder.h +++ b/Libraries/LibIPC/Encoder.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -51,9 +52,9 @@ public: return {}; } - ErrorOr append_file_descriptor(int fd) + ErrorOr append_attachment(Attachment attachment) { - TRY(m_buffer.append_file_descriptor(fd)); + TRY(m_buffer.append_attachment(move(attachment))); return {}; } diff --git a/Libraries/LibIPC/File.cpp b/Libraries/LibIPC/File.cpp index 382fb1d9ae..c40a3ceb88 100644 --- a/Libraries/LibIPC/File.cpp +++ b/Libraries/LibIPC/File.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -63,9 +64,12 @@ ErrorOr File::clear_close_on_exec() template<> ErrorOr decode(Decoder& decoder) { - auto file = TRY(decoder.files().try_dequeue()); - TRY(Core::System::set_close_on_exec(file.fd(), true)); - return file; + auto attachment = TRY(decoder.attachments().try_dequeue()); + int fd = attachment.to_fd(); + if (fd < 0) + return Error::from_string_literal("Failed to obtain fd from attachment"); + TRY(Core::System::set_close_on_exec(fd, true)); + return File::adopt_fd(fd); } } diff --git a/Libraries/LibIPC/Forward.h b/Libraries/LibIPC/Forward.h index 569f8d46dd..63be2a49b0 100644 --- a/Libraries/LibIPC/Forward.h +++ b/Libraries/LibIPC/Forward.h @@ -10,6 +10,7 @@ namespace IPC { +class Attachment; class AutoCloseFileDescriptor; class Decoder; class Encoder; @@ -26,6 +27,5 @@ template ErrorOr decode(Decoder&); using MessageDataType = Vector; -using MessageFileType = Vector, 1>; } diff --git a/Libraries/LibIPC/Message.cpp b/Libraries/LibIPC/Message.cpp index 5bef5cf65c..ffdf60ece3 100644 --- a/Libraries/LibIPC/Message.cpp +++ b/Libraries/LibIPC/Message.cpp @@ -27,26 +27,29 @@ ErrorOr MessageBuffer::append_data(u8 const* values, size_t count) ErrorOr MessageBuffer::append_file_descriptor(int fd) { - auto auto_fd = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) AutoCloseFileDescriptor(fd))); - TRY(m_fds.try_append(move(auto_fd))); + TRY(m_attachments.try_append(Attachment::from_fd(fd))); + return {}; +} + +ErrorOr MessageBuffer::append_attachment(Attachment attachment) +{ + TRY(m_attachments.try_append(move(attachment))); return {}; } ErrorOr MessageBuffer::extend(MessageBuffer&& buffer) { TRY(m_data.try_extend(move(buffer.m_data))); - TRY(m_fds.try_extend(move(buffer.m_fds))); + TRY(m_attachments.try_extend(move(buffer.m_attachments))); return {}; } ErrorOr MessageBuffer::transfer_message(Transport& transport) { - // These VERIFYs catch bugs where we try to send messages that exceed IPC limits. - // If we hit these, we have a bug in our encoding code. VERIFY(m_data.size() <= MAX_MESSAGE_PAYLOAD_SIZE); - VERIFY(m_fds.size() <= MAX_MESSAGE_FD_COUNT); + VERIFY(m_attachments.size() <= MAX_MESSAGE_FD_COUNT); - transport.post_message(m_data, m_fds); + transport.post_message(m_data, m_attachments); return {}; } diff --git a/Libraries/LibIPC/Message.h b/Libraries/LibIPC/Message.h index 7ecce67c81..db67cdaf8d 100644 --- a/Libraries/LibIPC/Message.h +++ b/Libraries/LibIPC/Message.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -19,9 +19,9 @@ class MessageBuffer { public: MessageBuffer(); - MessageBuffer(MessageDataType data, MessageFileType fds) + MessageBuffer(MessageDataType data, Vector attachments) : m_data(move(data)) - , m_fds(move(fds)) + , m_attachments(move(attachments)) { } @@ -29,6 +29,7 @@ public: ErrorOr append_data(u8 const* values, size_t count); ErrorOr append_file_descriptor(int fd); + ErrorOr append_attachment(Attachment); ErrorOr extend(MessageBuffer&& buffer); @@ -37,12 +38,12 @@ public: MessageDataType const& data() const { return m_data; } MessageDataType take_data() { return move(m_data); } - MessageFileType const& fds() const { return m_fds; } - MessageFileType take_fds() { return move(m_fds); } + Vector const& attachments() const { return m_attachments; } + Vector take_attachments() { return move(m_attachments); } private: MessageDataType m_data; - MessageFileType m_fds; + Vector m_attachments; #ifdef AK_OS_WINDOWS Vector m_handle_offsets; #endif diff --git a/Libraries/LibIPC/MessageWindows.cpp b/Libraries/LibIPC/MessageWindows.cpp index 3e79ae2f19..c23e7ee681 100644 --- a/Libraries/LibIPC/MessageWindows.cpp +++ b/Libraries/LibIPC/MessageWindows.cpp @@ -34,7 +34,6 @@ ErrorOr MessageBuffer::append_data(u8 const* values, size_t count) ErrorOr MessageBuffer::append_file_descriptor(int handle) { - TRY(m_fds.try_append(adopt_ref(*new AutoCloseFileDescriptor(handle)))); TRY(m_handle_offsets.try_append(m_data.size())); if (Core::System::is_socket(handle)) { @@ -56,10 +55,15 @@ ErrorOr MessageBuffer::append_file_descriptor(int handle) return {}; } +ErrorOr MessageBuffer::append_attachment(Attachment attachment) +{ + return append_file_descriptor(attachment.to_fd()); +} + ErrorOr MessageBuffer::extend(MessageBuffer&& buffer) { TRY(m_data.try_extend(move(buffer.m_data))); - TRY(m_fds.try_extend(move(buffer.m_fds))); + TRY(m_attachments.try_extend(move(buffer.m_attachments))); TRY(m_handle_offsets.try_extend(move(buffer.m_handle_offsets))); return {}; } diff --git a/Libraries/LibIPC/TransportSocket.cpp b/Libraries/LibIPC/TransportSocket.cpp index 03086bc982..e61714b834 100644 --- a/Libraries/LibIPC/TransportSocket.cpp +++ b/Libraries/LibIPC/TransportSocket.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -249,9 +250,9 @@ struct MessageHeader { u32 fd_count { 0 }; }; -void TransportSocket::post_message(Vector const& bytes_to_write, Vector> const& fds) +void TransportSocket::post_message(Vector const& bytes_to_write, Vector& attachments) { - auto num_fds_to_transfer = fds.size(); + auto num_fds_to_transfer = attachments.size(); MessageHeader header { .type = MessageHeader::Type::Payload, @@ -259,17 +260,15 @@ void TransportSocket::post_message(Vector const& bytes_to_write, Vector(num_fds_to_transfer), }; - { - Threading::MutexLocker locker(m_fds_retained_until_received_by_peer_mutex); - for (auto const& fd : fds) - m_fds_retained_until_received_by_peer.enqueue(fd); - } - auto raw_fds = Vector {}; if (num_fds_to_transfer > 0) { raw_fds.ensure_capacity(num_fds_to_transfer); - for (auto const& owned_fd : fds) { - raw_fds.unchecked_append(owned_fd->value()); + Threading::MutexLocker locker(m_fds_retained_until_received_by_peer_mutex); + for (auto& attachment : attachments) { + int fd = attachment.to_fd(); + auto auto_fd = adopt_ref(*new AutoCloseFileDescriptor(fd)); + raw_fds.unchecked_append(auto_fd->value()); + m_fds_retained_until_received_by_peer.enqueue(move(auto_fd)); } } @@ -366,13 +365,13 @@ void TransportSocket::read_incoming_messages() m_peer_eof = true; break; } - if (m_unprocessed_fds.size() + received_fds.size() > MAX_UNPROCESSED_FDS) { + if (m_unprocessed_attachments.size() + received_fds.size() > MAX_UNPROCESSED_FDS) { dbgln("TransportSocket: Unprocessed FDs would exceed {}, disconnecting peer", MAX_UNPROCESSED_FDS); m_peer_eof = true; break; } for (auto const& fd : received_fds) { - m_unprocessed_fds.enqueue(File::adopt_fd(fd)); + m_unprocessed_attachments.enqueue(Attachment::from_fd(fd)); } } @@ -397,7 +396,7 @@ void TransportSocket::read_incoming_messages() message_size += sizeof(MessageHeader); if (message_size.has_overflow() || message_size.value() > m_unprocessed_bytes.size() - index) break; - if (header.fd_count > m_unprocessed_fds.size()) + if (header.fd_count > m_unprocessed_attachments.size()) break; auto message = make(); received_fd_count += header.fd_count; @@ -407,7 +406,7 @@ void TransportSocket::read_incoming_messages() break; } for (size_t i = 0; i < header.fd_count; ++i) - message->fds.enqueue(m_unprocessed_fds.dequeue()); + message->attachments.enqueue(m_unprocessed_attachments.dequeue()); if (message->bytes.try_append(m_unprocessed_bytes.data() + index + sizeof(MessageHeader), header.payload_size).is_error()) { dbgln("TransportSocket: Failed to allocate message buffer for payload_size {}", header.payload_size); m_peer_eof = true; diff --git a/Libraries/LibIPC/TransportSocket.h b/Libraries/LibIPC/TransportSocket.h index 4a164934e7..6bbb66712b 100644 --- a/Libraries/LibIPC/TransportSocket.h +++ b/Libraries/LibIPC/TransportSocket.h @@ -10,8 +10,9 @@ #include #include #include +#include #include -#include +#include #include #include @@ -57,7 +58,7 @@ public: void wait_until_readable(); - void post_message(Vector const&, Vector> const&); + void post_message(Vector const&, Vector& attachments); enum class ShouldShutdown { No, @@ -65,7 +66,7 @@ public: }; struct Message { Vector bytes; - Queue fds; + Queue attachments; }; ShouldShutdown read_as_many_messages_as_possible_without_blocking(Function&&); @@ -104,7 +105,7 @@ private: Atomic m_io_thread_state { IOThreadState::Running }; Atomic m_peer_eof { false }; ByteBuffer m_unprocessed_bytes; - Queue m_unprocessed_fds; + Queue m_unprocessed_attachments; Threading::Mutex m_incoming_mutex; Threading::ConditionVariable m_incoming_cv { m_incoming_mutex }; Vector> m_incoming_messages; diff --git a/Libraries/LibIPC/TransportSocketWindows.h b/Libraries/LibIPC/TransportSocketWindows.h index 0a1038997f..6cac173cbb 100644 --- a/Libraries/LibIPC/TransportSocketWindows.h +++ b/Libraries/LibIPC/TransportSocketWindows.h @@ -9,7 +9,7 @@ #include #include -#include +#include namespace IPC { @@ -42,7 +42,7 @@ public: }; struct Message { Vector bytes; - Queue fds; // always empty, present to avoid OS #ifdefs in Connection.cpp + Queue attachments; // always empty, present to avoid OS #ifdefs in Connection.cpp }; ShouldShutdown read_as_many_messages_as_possible_without_blocking(Function&&); diff --git a/Libraries/LibWeb/HTML/MessagePort.cpp b/Libraries/LibWeb/HTML/MessagePort.cpp index dfff44e3d2..4ac979f96c 100644 --- a/Libraries/LibWeb/HTML/MessagePort.cpp +++ b/Libraries/LibWeb/HTML/MessagePort.cpp @@ -294,7 +294,7 @@ void MessagePort::read_from_transport() auto schedule_shutdown = m_transport->read_as_many_messages_as_possible_without_blocking([this](auto&& raw_message) { FixedMemoryStream stream { raw_message.bytes.span(), FixedMemoryStream::Mode::ReadOnly }; - IPC::Decoder decoder { stream, raw_message.fds }; + IPC::Decoder decoder { stream, raw_message.attachments }; auto serialized_transfer_record = MUST(decoder.decode()); diff --git a/Libraries/LibWeb/HTML/StructuredSerialize.cpp b/Libraries/LibWeb/HTML/StructuredSerialize.cpp index 1724ab5bd9..61a3bc7325 100644 --- a/Libraries/LibWeb/HTML/StructuredSerialize.cpp +++ b/Libraries/LibWeb/HTML/StructuredSerialize.cpp @@ -1305,19 +1305,17 @@ void TransferDataEncoder::extend(Vector data_holders) TransferDataDecoder::TransferDataDecoder(SerializationRecord const& record) : m_stream(record.span()) - , m_decoder(m_stream, m_files) + , m_decoder(m_stream, m_attachments) { } TransferDataDecoder::TransferDataDecoder(TransferDataEncoder&& data_holder) : m_buffer(data_holder.take_buffer()) , m_stream(m_buffer.data().span()) - , m_decoder(m_stream, m_files) + , m_decoder(m_stream, m_attachments) { - // FIXME: The churn between IPC::File and IPC::AutoCloseFileDescriptor is pretty awkward, we should find a way to - // consolidate the way we use these type. - for (auto& auto_fd : m_buffer.take_fds()) - m_files.enqueue(IPC::File::adopt_fd(auto_fd->take_fd())); + for (auto& attachment : m_buffer.take_attachments()) + m_attachments.enqueue(move(attachment)); } WebIDL::ExceptionOr TransferDataDecoder::decode_buffer(JS::Realm& realm) @@ -1339,13 +1337,11 @@ namespace IPC { template<> ErrorOr encode(Encoder& encoder, Web::HTML::TransferDataEncoder const& data_holder) { - // FIXME: The churn between IPC::File and IPC::AutoCloseFileDescriptor is pretty awkward, we should find a way to - // consolidate the way we use these type. Vector files; - files.ensure_capacity(data_holder.buffer().fds().size()); + files.ensure_capacity(data_holder.buffer().attachments().size()); - for (auto const& auto_fd : data_holder.buffer().fds()) { - auto fd = const_cast(*auto_fd).take_fd(); + for (auto& attachment : data_holder.buffer().attachments()) { + int fd = const_cast(attachment).to_fd(); files.unchecked_append(IPC::File::adopt_fd(fd)); } @@ -1360,17 +1356,13 @@ ErrorOr decode(Decoder& decoder) auto data = TRY(decoder.decode()); auto files = TRY(decoder.decode>()); - // FIXME: The churn between IPC::File and IPC::AutoCloseFileDescriptor is pretty awkward, we should find a way to - // consolidate the way we use these type. - MessageFileType auto_files; - auto_files.ensure_capacity(files.size()); + Vector attachments; + attachments.ensure_capacity(files.size()); - for (auto& fd : files) { - auto auto_fd = adopt_ref(*new AutoCloseFileDescriptor(fd.take_fd())); - auto_files.unchecked_append(move(auto_fd)); - } + for (auto& file : files) + attachments.unchecked_append(Attachment::from_fd(file.take_fd())); - IPC::MessageBuffer buffer { move(data), move(auto_files) }; + IPC::MessageBuffer buffer { move(data), move(attachments) }; return Web::HTML::TransferDataEncoder { move(buffer) }; } diff --git a/Libraries/LibWeb/HTML/StructuredSerialize.h b/Libraries/LibWeb/HTML/StructuredSerialize.h index d3195225c0..1e8049182b 100644 --- a/Libraries/LibWeb/HTML/StructuredSerialize.h +++ b/Libraries/LibWeb/HTML/StructuredSerialize.h @@ -61,7 +61,7 @@ private: IPC::MessageBuffer m_buffer; FixedMemoryStream m_stream; - Queue m_files; + Queue m_attachments; IPC::Decoder m_decoder; }; diff --git a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp index 8e268be13d..3ea66b7846 100644 --- a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp @@ -405,9 +405,9 @@ public:)~~~"); static i32 static_message_id() { return (int)MessageID::@message.pascal_name@; } virtual const char* message_name() const override { return "@endpoint.name@::@message.pascal_name@"; } - static ErrorOr> decode(Stream& stream, Queue& files) + static ErrorOr> decode(Stream& stream, Queue& attachments) { - IPC::Decoder decoder { stream, files };)~~~"); + IPC::Decoder decoder { stream, attachments };)~~~"); for (auto const& parameter : parameters) { auto parameter_generator = message_generator.fork(); @@ -729,7 +729,7 @@ public: static u32 static_magic() { return @endpoint.magic@; } - static ErrorOr> decode_message(ReadonlyBytes buffer, [[maybe_unused]] Queue& files) + static ErrorOr> decode_message(ReadonlyBytes buffer, [[maybe_unused]] Queue& attachments) { FixedMemoryStream stream { buffer }; auto message_endpoint_magic = TRY(stream.read_value());)~~~"); @@ -758,7 +758,7 @@ public: message_generator.append(R"~~~( case (int)Messages::@endpoint.name@::MessageID::@message.pascal_name@: - return TRY(Messages::@endpoint.name@::@message.pascal_name@::decode(stream, files));)~~~"); + return TRY(Messages::@endpoint.name@::@message.pascal_name@::decode(stream, attachments));)~~~"); }; do_decode_message(message.name); @@ -911,6 +911,7 @@ void build(StringBuilder& builder, Vector const& endpoints) #include #include #include +#include #include #include #include