#include "{{ cls.name }}.skeleton.h" {{ cls.name }}Skeleton::{{ cls.name }}Skeleton({{ cls.name }}& obj) : obj_(obj) { } RpcValue {{ cls.name }}Skeleton::invoke(const std::string& method, const RpcArgs& args) { const auto& table = handlers(); auto it = table.find(method); if (it == table.end()) { // Неизвестный метод — PoC: возвращаем 0. return RpcValue::fromInt(0); } Handler fn = it->second; return (this->*fn)(args); } const std::unordered_map& {{ cls.name }}Skeleton::handlers() { static const std::unordered_map kHandlers = { {% for m in cls.methods %} { "{{ cls.name }}.{{ m.name }}", &{{ cls.name }}Skeleton::call_{{ m.name }} }{% if not loop.last %},{% endif %} {% endfor %} }; return kHandlers; } {% for m in cls.methods %} RpcValue {{ cls.name }}Skeleton::call_{{ m.name }}(const RpcArgs& args) { // PoC: единственный тип аргументов и результата — int. int idx = 0; {% for a in m.args %} int {{ a.name }} = args[idx++].asInt(); {% endfor %} int result = obj_.{{ m.name }}({% for a in m.args %}{{ a.name }}{% if not loop.last %}, {% endif %}{% endfor %}); return RpcValue::fromInt(result); } {% endfor %}