IPCCompiler: Typedef the response message types as "ResponseType"

Each message will now have a typedef called ResponseType as an alias
for the expected response type. This will aid in implementing the sync
messaging code.
This commit is contained in:
Andreas Kling 2019-08-03 16:05:53 +02:00
parent 016335edde
commit fae3091999
Notes: sideshowbarker 2024-07-19 12:55:24 +09:00

View file

@ -182,9 +182,11 @@ int main(int argc, char** argv)
dbg() << "namespace " << endpoint.name << " {";
dbg();
auto do_message = [&](const String& name, const Vector<Parameter>& parameters) {
auto do_message = [&](const String& name, const Vector<Parameter>& parameters, String response_type = {}) {
dbg() << "class " << name << " final : public IMessage {";
dbg() << "public:";
if (!response_type.is_null())
dbg() << " typedef " << response_type << " ResponseType;";
dbg() << " virtual ~" << name << "() override {}";
dbg() << " virtual ByteBuffer encode() override";
dbg() << " {";
@ -209,13 +211,15 @@ int main(int argc, char** argv)
dbg();
};
for (auto& message : endpoint.messages) {
String response_name;
if (message.is_synchronous) {
StringBuilder builder;
builder.append(message.name);
builder.append("Response");
do_message(builder.to_string(), message.outputs);
response_name = builder.to_string();
do_message(response_name, message.outputs);
}
do_message(message.name, message.inputs);
do_message(message.name, message.inputs, response_name);
}
dbg() << "} // namespace " << endpoint.name;
dbg();