refactor IPC-dependency out of Proxy

This commit is contained in:
Сергей Маринкевич
2025-12-02 20:54:41 +07:00
parent 6cc64fa6a3
commit f81ac5842c
5 changed files with 97 additions and 35 deletions
+1 -1
View File
@@ -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 %}
+18 -1
View File
@@ -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;
}