From 9f48a7467733186266abd299881cc39aff83db40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=9C=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=BD=D0=BA=D0=B5=D0=B2=D0=B8=D1=87?= Date: Tue, 2 Dec 2025 19:49:04 +0700 Subject: [PATCH] move marshaller out of template --- src/client.cpp | 6 ++++-- tools/templates/proxy.cpp.j2 | 11 +++++------ tools/templates/proxy.h.j2 | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index b1fa9e0..654f590 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1,5 +1,6 @@ #include "MyService.proxy.h" #include "ipc/IpcPipeChannel.h" +#include "proxy/ProxyMarshaller.h" #include @@ -15,8 +16,9 @@ int main() { // и читает из fifo, в который пишет сервер (fifo_to_client). IpcPipeChannel ch("/tmp/fifo_to_client", "/tmp/fifo_to_server"); - // RPC‑уровень: прокси поверх канала. - MyServiceProxy proxy(ch); + // RPC‑уровень: создаём marshaller поверх канала и передаём его в прокси. + ProxyMarshaller marshaller(ch); + MyServiceProxy proxy(marshaller); int r = proxy.add(7, 8); std::cout << "RESULT: " << r << std::endl; diff --git a/tools/templates/proxy.cpp.j2 b/tools/templates/proxy.cpp.j2 index c0530b7..6e21917 100644 --- a/tools/templates/proxy.cpp.j2 +++ b/tools/templates/proxy.cpp.j2 @@ -1,16 +1,15 @@ #include "{{ cls.name }}.proxy.h" -#include "proxy/ProxyMarshaller.h" class {{ cls.name }}Proxy::Impl { public: - explicit Impl(IpcChannel& ch) - : client(ch) {} + explicit Impl(ProxyMarshaller& m) + : client(m) {} - ProxyMarshaller client; + ProxyMarshaller& client; }; -{{ cls.name }}Proxy::{{ cls.name }}Proxy(IpcChannel& ch) - : impl(new Impl(ch)) {} +{{ cls.name }}Proxy::{{ cls.name }}Proxy(ProxyMarshaller& marshaller) + : impl(new 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 %}) { diff --git a/tools/templates/proxy.h.j2 b/tools/templates/proxy.h.j2 index eb5117d..1b0c06b 100644 --- a/tools/templates/proxy.h.j2 +++ b/tools/templates/proxy.h.j2 @@ -1,10 +1,10 @@ #pragma once -#include "ipc/IpcChannel.h" +#include "proxy/ProxyMarshaller.h" class {{ cls.name }}Proxy { public: - explicit {{ cls.name }}Proxy(IpcChannel& ch); + explicit {{ cls.name }}Proxy(ProxyMarshaller& marshaller); {% 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 %}); {% endfor %}