Skip to content

Commit

Permalink
IPCCompiler: Remove invalid state from IPC message classes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AtkinsSJ authored and trflynn89 committed Feb 17, 2025
1 parent e53df7e commit b3b7e76
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
1 change: 0 additions & 1 deletion Libraries/LibIPC/Message.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class Message {
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:
Expand Down
10 changes: 1 addition & 9 deletions Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -715,8 +709,6 @@ class @endpoint.name@Stub : public IPC::Stub {
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 {
Expand Down

0 comments on commit b3b7e76

Please sign in to comment.