move marshaller to IPC component
parent
31d0496a93
commit
e7aa646a80
@ -1,11 +1,5 @@
|
||||
#include "{{ cls.name }}.proxy.h"
|
||||
|
||||
{{ cls.name }}Proxy::{{ cls.name }}Proxy(ProxyMarshaller& marshaller)
|
||||
: impl(marshaller) {}
|
||||
|
||||
{% 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.callTyped<{{ m.return_type }}>("{{ cls.name }}.{{ m.name }}"{% for a in m.args %}, {{ a.name }}{% endfor %});
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
// Реализация шаблонного прокси целиком находится в заголовочном файле.
|
||||
// Этот cpp остаётся пустым, чтобы сгенерированные файлы по‑прежнему
|
||||
// могли участвовать в сборке как отдельная единица трансляции.
|
||||
|
||||
@ -1,14 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "proxy/ProxyMarshaller.h"
|
||||
#include "{{ cls.name }}.h"
|
||||
|
||||
// Шаблонный прокси, который зависит только от контракта Impl:
|
||||
// Impl должен предоставлять метод
|
||||
// template<typename Ret, typename... Args>
|
||||
// Ret callTyped(const std::string& method, const Args&... args);
|
||||
template<typename Impl>
|
||||
class {{ cls.name }}Proxy {
|
||||
public:
|
||||
explicit {{ cls.name }}Proxy(ProxyMarshaller& marshaller);
|
||||
explicit {{ cls.name }}Proxy(Impl& impl)
|
||||
: impl(impl) {}
|
||||
|
||||
{% for m in cls.methods %}
|
||||
{{ m.return_type }} {{ m.name }}({% for a in m.args %}{{ a.type }} {{ a.name }}{% if not loop.last %}, {% endif %}{% endfor %});
|
||||
{{ m.return_type }} {{ m.name }}({% for a in m.args %}{{ a.type }} {{ a.name }}{% if not loop.last %}, {% endif %}{% endfor %}) {
|
||||
return impl.template callTyped<{{ m.return_type }}>("{{ cls.name }}.{{ m.name }}"{% for a in m.args %}, {{ a.name }}{% endfor %});
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
private:
|
||||
ProxyMarshaller& impl;
|
||||
Impl& impl;
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue