summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-08-03 17:24:47 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-08-03 17:24:47 +0200
commit8dd07c3075a365d7589ac79bd20fdf0dcf7f6b7f (patch)
tree19f297cc865889a377221737b9c9e23399a2ddb7
parentc255cedd7aca8bb839bc291215ac78201d11c928 (diff)
downloadserenity-8dd07c3075a365d7589ac79bd20fdf0dcf7f6b7f.zip
IPCCompiler: Emit message parameter getters
For simplicity's sake, they are all "const type& name() const"
-rw-r--r--DevTools/IPCCompiler/main.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/DevTools/IPCCompiler/main.cpp b/DevTools/IPCCompiler/main.cpp
index 04cf175b62..8278b71d32 100644
--- a/DevTools/IPCCompiler/main.cpp
+++ b/DevTools/IPCCompiler/main.cpp
@@ -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:";