diff --git a/protobuf/echo/Serialization.cpp b/protobuf/echo/Serialization.cpp index 0e9a49906..0dd750de1 100644 --- a/protobuf/echo/Serialization.cpp +++ b/protobuf/echo/Serialization.cpp @@ -25,6 +25,15 @@ namespace services return false; } + infra::SharedPtr MethodDeserializerFactory::MakeDummyDeserializer(Echo& echo) + { + using Deserializer = MethodDeserializerDummy; + + auto memory = DeserializerMemory(sizeof(Deserializer)); + auto deserializer = new (memory->begin()) Deserializer(echo); + return infra::MakeContainedSharedObject(*deserializer, memory); + } + infra::SharedPtr MethodDeserializerFactory::OnHeap::DeserializerMemory(uint32_t size) { auto m = reinterpret_cast(malloc(size)); diff --git a/protobuf/echo/Serialization.hpp b/protobuf/echo/Serialization.hpp index 0c520ea03..66c969e40 100644 --- a/protobuf/echo/Serialization.hpp +++ b/protobuf/echo/Serialization.hpp @@ -88,6 +88,8 @@ namespace services template infra::SharedPtr MakeDeserializer(const infra::Function& method); + + infra::SharedPtr MakeDummyDeserializer(Echo& echo); }; template @@ -111,7 +113,7 @@ namespace services template<> struct MaxServiceSize<> { - static constexpr std::size_t maxSize = 0; + static constexpr std::size_t maxSize = sizeof(MethodDeserializerDummy); }; template diff --git a/protobuf/echo/test_doubles/ServiceStub.cpp b/protobuf/echo/test_doubles/ServiceStub.cpp index 6118c1975..53a6c4ef7 100644 --- a/protobuf/echo/test_doubles/ServiceStub.cpp +++ b/protobuf/echo/test_doubles/ServiceStub.cpp @@ -42,7 +42,7 @@ namespace services })); default: errorPolicy.MethodNotFound(serviceId, methodId); - return infra::MakeSharedOnHeap(Rpc()); + return deserializerfactory.MakeDummyDeserializer(Rpc()); } } diff --git a/protobuf/protoc_echo_plugin/ProtoCEchoPlugin.cpp b/protobuf/protoc_echo_plugin/ProtoCEchoPlugin.cpp index 84dad0cfe..90794bcc9 100644 --- a/protobuf/protoc_echo_plugin/ProtoCEchoPlugin.cpp +++ b/protobuf/protoc_echo_plugin/ProtoCEchoPlugin.cpp @@ -1062,7 +1062,7 @@ namespace application printer.Print(R"( default: errorPolicy.MethodNotFound(serviceId, methodId); - return infra::MakeSharedOnHeap(Rpc()); + return deserializerfactory.MakeDummyDeserializer(Rpc()); )"); printer.Print("}\n");