mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +00: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:
parent
e53df7e6c9
commit
b3b7e76c10
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 ✅
2 changed files with 1 additions and 10 deletions
|
@ -69,7 +69,6 @@ public:
|
|||
virtual u32 endpoint_magic() const = 0;
|
||||
virtual int message_id() const = 0;
|
||||
virtual char const* message_name() const = 0;
|
||||
virtual bool valid() const = 0;
|
||||
virtual ErrorOr<MessageBuffer> encode() const = 0;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue