You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
932 B
Django/Jinja

#include "{{ cls.name }}.skeleton.h"
{{ cls.name }}Skeleton::{{ cls.name }}Skeleton({{ cls.name }}& obj)
{
{% for m in cls.methods %}
invoker.registerMethod(&obj,
"{{ cls.name }}.{{ m.name }}",
&{{ cls.name }}::{{ m.name }});
{% endfor %}
}
IpcMessage {{ cls.name }}Skeleton::dispatch(const IpcMessage& req) {
// Перепаковываем IpcMessage в RpcArgs и вызываем type-erased инвокер.
IpcMessage msg = req;
// имя метода
std::string method = msg.get<std::string>();
// аргументы (PoC: только int, читаем все до конца сообщения)
RpcArgs args;
while (!msg.empty()) {
int v = msg.get<int>();
args.emplace_back(RpcValue::fromInt(v));
}
RpcValue result = invoker.dispatch(method, args);
IpcMessage resp;
resp.add(result.asInt()); // PoC: только int
return resp;
}