mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
IPCCompiler: Emit message parameter getters
For simplicity's sake, they are all "const type& name() const"
This commit is contained in:
parent
c255cedd7a
commit
8dd07c3075
Notes:
sideshowbarker
2024-07-19 12:55:03 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8dd07c3075a
1 changed files with 12 additions and 3 deletions
|
@ -182,6 +182,7 @@ int main(int argc, char** argv)
|
|||
while (index < file_contents.size())
|
||||
parse_endpoint();
|
||||
|
||||
dbg() << "#pragma once";
|
||||
dbg() << "#include <AK/BufferStream.h>";
|
||||
dbg() << "#include <AK/OwnPtr.h>";
|
||||
dbg() << "#include <LibIPC/IEndpoint.h>";
|
||||
|
@ -255,8 +256,13 @@ int main(int argc, char** argv)
|
|||
dbg() << " (void)stream;";
|
||||
|
||||
for (auto& parameter : parameters) {
|
||||
dbg() << " " << parameter.type << " " << parameter.name << ";";
|
||||
String initial_value = "{}";
|
||||
if (parameter.type == "bool")
|
||||
initial_value = "false";
|
||||
dbg() << " " << parameter.type << " " << parameter.name << " = " << initial_value << ";";
|
||||
dbg() << " stream >> " << parameter.name << ";";
|
||||
dbg() << " if (stream.handle_read_failure())";
|
||||
dbg() << " return nullptr;";
|
||||
}
|
||||
|
||||
StringBuilder builder;
|
||||
|
@ -280,6 +286,9 @@ int main(int argc, char** argv)
|
|||
dbg() << " stream.snip();";
|
||||
dbg() << " return buffer;";
|
||||
dbg() << " }";
|
||||
for (auto& parameter : parameters) {
|
||||
dbg() << " const " << parameter.type << "& " << parameter.name << "() const { return m_" << parameter.name << "; }";
|
||||
}
|
||||
dbg() << "private:";
|
||||
for (auto& parameter : parameters) {
|
||||
dbg() << " " << parameter.type << " m_" << parameter.name << ";";
|
||||
|
@ -298,7 +307,7 @@ int main(int argc, char** argv)
|
|||
dbg() << "} // namespace " << endpoint.name;
|
||||
dbg();
|
||||
|
||||
dbg() << "class " << endpoint.name << "Endpoint final : public IEndpoint {";
|
||||
dbg() << "class " << endpoint.name << "Endpoint : public IEndpoint {";
|
||||
dbg() << "public:";
|
||||
dbg() << " " << endpoint.name << "Endpoint() {}";
|
||||
dbg() << " virtual ~" << endpoint.name << "Endpoint() override {}";
|
||||
|
@ -335,7 +344,7 @@ int main(int argc, char** argv)
|
|||
builder.append("Response");
|
||||
return_type = builder.to_string();
|
||||
}
|
||||
dbg() << " " << return_type << " handle(const " << endpoint.name << "::" << message.name << "&);";
|
||||
dbg() << " virtual " << return_type << " handle(const " << endpoint.name << "::" << message.name << "&) = 0;";
|
||||
}
|
||||
|
||||
dbg() << "private:";
|
||||
|
|
Loading…
Reference in a new issue