mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
IPCCompiler: Remove invalid state from IPC message classes
At some point, we stopped ever constructing invalid messages. This makes that clearer, and will allow us to stop requiring that IPC arguments be default-constructible.
This commit is contained in:
Notes:
github-actions[bot]
2025-02-17 16:38:44 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/b3b7e76c10b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3601 Reviewed-by: https://github.com/trflynn89 ✅
@@ -345,7 +345,6 @@ public:)~~~");
|
||||
typedef class @message.response_type@ ResponseType;)~~~");
|
||||
|
||||
message_generator.appendln(R"~~~(
|
||||
@message.pascal_name@(decltype(nullptr)) : m_ipc_message_valid(false) { }
|
||||
@message.pascal_name@(@message.pascal_name@ const&) = default;
|
||||
@message.pascal_name@(@message.pascal_name@&&) = default;
|
||||
@message.pascal_name@& operator=(@message.pascal_name@ const&) = default;
|
||||
@@ -412,12 +411,8 @@ public:)~~~");
|
||||
})~~~");
|
||||
|
||||
message_generator.appendln(R"~~~(
|
||||
virtual bool valid() const override { return m_ipc_message_valid; }
|
||||
|
||||
virtual ErrorOr<IPC::MessageBuffer> encode() const override
|
||||
{
|
||||
VERIFY(valid());
|
||||
|
||||
IPC::MessageBuffer buffer;
|
||||
IPC::Encoder stream(buffer);
|
||||
TRY(stream.encode(endpoint_magic()));
|
||||
@@ -445,8 +440,7 @@ public:)~~~");
|
||||
}
|
||||
|
||||
message_generator.appendln(R"~~~(
|
||||
private:
|
||||
bool m_ipc_message_valid { true };)~~~");
|
||||
private:)~~~");
|
||||
|
||||
for (auto const& parameter : parameters) {
|
||||
auto parameter_generator = message_generator.fork();
|
||||
@@ -715,8 +709,6 @@ public:
|
||||
message_generator.appendln(R"~~~(
|
||||
[[maybe_unused]] auto& request = static_cast<const Messages::@endpoint.name@::@message.pascal_name@&>(message);
|
||||
auto response = @handler_name@(@arguments@);
|
||||
if (!response.valid())
|
||||
return Error::from_string_literal("Failed to handle @endpoint.name@::@message.pascal_name@ message");
|
||||
return make<IPC::MessageBuffer>(TRY(response.encode()));)~~~");
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user