refactor IPC-dependency out of Proxy
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
{% for m in cls.methods %}
|
||||
{{ m.return_type }} {{ cls.name }}Proxy::{{ m.name }}({% for a in m.args %}{{ a.type }} {{ a.name }}{% if not loop.last %}, {% endif %}{% endfor %}) {
|
||||
return impl.call<{{ m.return_type }}>("{{ cls.name }}.{{ m.name }}"{% for a in m.args %}, {{ a.name }}{% endfor %});
|
||||
return impl.callTyped<{{ m.return_type }}>("{{ cls.name }}.{{ m.name }}"{% for a in m.args %}, {{ a.name }}{% endfor %});
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
@@ -10,6 +10,23 @@
|
||||
}
|
||||
|
||||
IpcMessage {{ cls.name }}Skeleton::dispatch(const IpcMessage& req) {
|
||||
return invoker.dispatch(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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user