From 40db52670da293bdf19918fc82cffc2dffa7823c Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 11 May 2018 13:53:49 +0300 Subject: [PATCH] Vector support in .NET binding. GitOrigin-RevId: b9b168c865bb2144e902229e36776bdce92f22dc --- td/generate/tl_writer_dotnet.h | 3 ++- td/tl/tl_dotnet_object.h | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/td/generate/tl_writer_dotnet.h b/td/generate/tl_writer_dotnet.h index 8228fa233..d6f6f3d90 100644 --- a/td/generate/tl_writer_dotnet.h +++ b/td/generate/tl_writer_dotnet.h @@ -376,7 +376,8 @@ class TlWriterDotNet : public TL_writer { } else { ss << ", "; } - ss << (gen_field_type(it) == "Array^" ? "Bytes" : "") << "FromUnmanaged(from." << gen_native_field_name(it.name) << ")"; + bool need_bytes = gen_field_type(it) == "Array^" || gen_field_type(it) == "Array^>^"; + ss << (need_bytes ? "Bytes" : "") << "FromUnmanaged(from." << gen_native_field_name(it.name) << ")"; } ss << ");\n}\n"; } diff --git a/td/tl/tl_dotnet_object.h b/td/tl/tl_dotnet_object.h index 57b18b22c..d81420a20 100644 --- a/td/tl/tl_dotnet_object.h +++ b/td/tl/tl_dotnet_object.h @@ -82,6 +82,16 @@ auto CLRCALL FromUnmanaged(std::vector &vec) { return res; } +inline auto CLRCALL BytesFromUnmanaged(const std::vector &vec) { + using ToT = decltype(BytesFromUnmanaged(vec[0])); + Array^ res = REF_NEW Vector(static_cast(vec.size())); + ArrayIndexType i = 0; + for (auto &from : vec) { + ArraySet(res, i++, BytesFromUnmanaged(from)); + } + return res; +} + template auto CLRCALL FromUnmanaged(td::td_api::object_ptr &from) -> decltype(FromUnmanaged(*from.get())) { if (!from) {