From 1ac97a6ba73b07e93bbce96c7a47d0ec1852569a Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 28 Feb 2018 13:25:07 +0300 Subject: [PATCH] Various fixes. GitOrigin-RevId: 80fa34e64e6824a0f96c38d2e8b0a32455267ea8 --- example/swift/src/main.swift | 16 ++++++++-------- td/generate/CMakeLists.txt | 2 +- td/generate/tl_writer_dotnet.h | 9 +++++---- td/mtproto/TcpTransport.cpp | 2 ++ td/mtproto/TcpTransport.h | 2 -- td/telegram/ClientDotNet.cpp | 2 ++ td/telegram/InlineQueriesManager.cpp | 1 - td/telegram/LogDotNet.cpp | 2 ++ td/telegram/Td.cpp | 1 + td/telegram/files/FileLoaderUtils.cpp | 6 ++++-- td/telegram/net/DcOptionsSet.cpp | 1 + td/tl/tl_dotnet_object.h | 4 ++-- 12 files changed, 28 insertions(+), 20 deletions(-) diff --git a/example/swift/src/main.swift b/example/swift/src/main.swift index 84ca2b96..10b075dc 100644 --- a/example/swift/src/main.swift +++ b/example/swift/src/main.swift @@ -97,8 +97,8 @@ func myReadLine() -> String { } } -func updateAuthorizationState(authState: Dictionary) { - switch(authState["@type"] as! String) { +func updateAuthorizationState(authorizationState: Dictionary) { + switch(authorizationState["@type"] as! String) { case "authorizationStateWaitTdlibParameters": client.queryAsync(query:[ "@type":"setTdlibParameters", @@ -122,13 +122,13 @@ func updateAuthorizationState(authState: Dictionary) { case "authorizationStateWaitPhoneNumber": print("Enter your phone: ") let phone = myReadLine() - client.queryAsync(query:["@type":"setAuthenticationPhoneNumber", "phone_number":phone], f:checkAuthError) + client.queryAsync(query:["@type":"setAuthenticationPhoneNumber", "phone_number":phone], f:checkAuthenticationError) case "authorizationStateWaitCode": var first_name: String = "" var last_name: String = "" var code: String = "" - if let is_registered = authState["is_registered"] as? Bool, is_registered { + if let is_registered = authorizationState["is_registered"] as? Bool, is_registered { } else { print("Enter your first name: ") first_name = myReadLine() @@ -137,12 +137,12 @@ func updateAuthorizationState(authState: Dictionary) { } print("Enter (SMS) code: ") code = myReadLine() - client.queryAsync(query:["@type":"checkAuthenticationCode", "code":code, "first_name":first_name, "last_name":last_name], f:checkAuthError) + client.queryAsync(query:["@type":"checkAuthenticationCode", "code":code, "first_name":first_name, "last_name":last_name], f:checkAuthenticationError) case "authorizationStateWaitPassword": print("Enter password: ") let password = myReadLine() - client.queryAsync(query:["@type":"checkAuthenticationPassword", "password":password], f:checkAuthError) + client.queryAsync(query:["@type":"checkAuthenticationPassword", "password":password], f:checkAuthenticationError) case "authorizationStateReady": () @@ -152,7 +152,7 @@ func updateAuthorizationState(authState: Dictionary) { } } -func checkAuthError(error: Dictionary) { +func checkAuthenticationError(error: Dictionary) { if (error["@type"] as! String == "error") { client.queryAsync(query:["@type":"getAuthorizationState"], f:updateAuthorizationState) } @@ -162,7 +162,7 @@ client.run { let update = $0 print(update) if update["@type"] as! String == "updateAuthorizationState" { - updateAuthorizationState(authState: update["authorization_state"] as! Dictionary) + updateAuthorizationState(authorizationState: update["authorization_state"] as! Dictionary) } } diff --git a/td/generate/CMakeLists.txt b/td/generate/CMakeLists.txt index ffecae6e..e9ab1582 100644 --- a/td/generate/CMakeLists.txt +++ b/td/generate/CMakeLists.txt @@ -131,7 +131,7 @@ if (NOT CMAKE_CROSSCOMPILING) install(FILES JavadocTlDocumentationGenerator.php TlDocumentationGenerator.php DESTINATION bin/td/generate) install(FILES scheme/td_api.tlo scheme/td_api.tl DESTINATION bin/td/generate/scheme) endif() - + if (TD_ENABLE_DOTNET) add_executable(td_generate_dotnet_api generate_dotnet.cpp tl_writer_dotnet.h) target_link_libraries(td_generate_dotnet_api PRIVATE tdtl) diff --git a/td/generate/tl_writer_dotnet.h b/td/generate/tl_writer_dotnet.h index d46d17ed..3d3bada2 100644 --- a/td/generate/tl_writer_dotnet.h +++ b/td/generate/tl_writer_dotnet.h @@ -9,6 +9,7 @@ #include "td/tl/tl_writer.h" #include +#include #include #include #include @@ -362,7 +363,7 @@ class TlWriterDotNet : public TL_writer { void gen_from_unmanaged(std::stringstream &ss, const tl_combinator *t) const { auto native_class_name = gen_native_class_name(t->name); auto class_name = gen_class_name(t->name); - ss << class_name << "^ FromUnmanaged(td::td_api::" << native_class_name << "& from)"; + ss << class_name << "^ FromUnmanaged(td::td_api::" << native_class_name << " &from)"; if (is_header_) { ss << ";\n"; return; @@ -422,7 +423,7 @@ class TlWriterDotNet : public TL_writer { assert(result_type->children.empty()); return ""; } - std::string gen_constructor_id_store(int32_t id, int storer_type) const override { + std::string gen_constructor_id_store(std::int32_t id, int storer_type) const override { return ""; } std::string gen_field_fetch(int field_num, const arg &a, std::vector &vars, bool flat, @@ -454,7 +455,7 @@ class TlWriterDotNet : public TL_writer { return ""; } - std::string gen_get_id(const std::string &class_name, int32_t id, bool is_proxy) const override { + std::string gen_get_id(const std::string &class_name, std::int32_t id, bool is_proxy) const override { return ""; } @@ -520,7 +521,7 @@ class TlWriterDotNet : public TL_writer { << " }\n" << " return td::td_api::move_object_as(from->ToUnmanaged()->get_object_ptr());\n}\n"; } else { - ss << class_name << "^ FromUnmanaged(td::td_api::" << native_class_name << "& from)"; + ss << class_name << "^ FromUnmanaged(td::td_api::" << native_class_name << " &from)"; if (is_header_) { ss << ";\n"; return ss.str(); diff --git a/td/mtproto/TcpTransport.cpp b/td/mtproto/TcpTransport.cpp index ed266cb5..e7613aca 100644 --- a/td/mtproto/TcpTransport.cpp +++ b/td/mtproto/TcpTransport.cpp @@ -6,7 +6,9 @@ // #include "td/mtproto/TcpTransport.h" +#include "td/utils/logging.h" #include "td/utils/Random.h" +#include "td/utils/Slice.h" #include diff --git a/td/mtproto/TcpTransport.h b/td/mtproto/TcpTransport.h index e5e217cd..d5304847 100644 --- a/td/mtproto/TcpTransport.h +++ b/td/mtproto/TcpTransport.h @@ -13,9 +13,7 @@ #include "td/utils/ByteFlow.h" #include "td/utils/common.h" #include "td/utils/crypto.h" -#include "td/utils/logging.h" #include "td/utils/port/Fd.h" -#include "td/utils/Slice.h" #include "td/utils/Status.h" namespace td { diff --git a/td/telegram/ClientDotNet.cpp b/td/telegram/ClientDotNet.cpp index ef73203d..02a7fc07 100644 --- a/td/telegram/ClientDotNet.cpp +++ b/td/telegram/ClientDotNet.cpp @@ -10,6 +10,8 @@ #include "td/utils/port/CxCli.h" +#include + namespace Telegram { namespace Td { diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index 674563b8..03321d73 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -39,7 +39,6 @@ #include "td/utils/HttpUrl.h" #include "td/utils/logging.h" #include "td/utils/misc.h" -#include "td/utils/PathView.h" #include "td/utils/Slice.h" #include "td/utils/Time.h" #include "td/utils/tl_helpers.h" diff --git a/td/telegram/LogDotNet.cpp b/td/telegram/LogDotNet.cpp index c267c8f2..efe0ee81 100644 --- a/td/telegram/LogDotNet.cpp +++ b/td/telegram/LogDotNet.cpp @@ -8,6 +8,8 @@ #include "td/utils/port/CxCli.h" +#include + namespace Telegram { namespace Td { diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index bd8b1ab7..54fafb36 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -72,6 +72,7 @@ #include "td/utils/misc.h" #include "td/utils/PathView.h" #include "td/utils/port/path.h" +#include "td/utils/Random.h" #include "td/utils/Slice.h" #include "td/utils/Status.h" #include "td/utils/Timer.h" diff --git a/td/telegram/files/FileLoaderUtils.cpp b/td/telegram/files/FileLoaderUtils.cpp index bc932959..1e89cb72 100644 --- a/td/telegram/files/FileLoaderUtils.cpp +++ b/td/telegram/files/FileLoaderUtils.cpp @@ -20,6 +20,8 @@ #include "td/utils/Random.h" #include "td/utils/StringBuilder.h" +#include + namespace td { namespace { @@ -104,7 +106,7 @@ bool for_suggested_file_name(CSlice name, bool use_pmc, bool use_random, F &&cal Result create_from_temp(CSlice temp_path, CSlice dir, CSlice name) { LOG(INFO) << "Create file in directory " << dir << " with suggested name " << name << " from temporary file " << temp_path; - Result> res = Status::Error(); + Result> res = Status::Error(500, "Can't find suitable file name"); for_suggested_file_name(name, true, true, [&](CSlice suggested_name) { res = try_create_new_file(PSLICE_SAFE() << dir << suggested_name); return res.is_error(); @@ -117,7 +119,7 @@ Result create_from_temp(CSlice temp_path, CSlice dir, CSlice name) { } Result search_file(CSlice dir, CSlice name, int64 expected_size) { - Result res = Status::Error(); + Result res = Status::Error(500, "Can't find suitable file name"); for_suggested_file_name(name, false, false, [&](CSlice suggested_name) { auto r_pair = try_open_file(PSLICE_SAFE() << dir << suggested_name); if (r_pair.is_error()) { diff --git a/td/telegram/net/DcOptionsSet.cpp b/td/telegram/net/DcOptionsSet.cpp index 00785e28..4aefd3b7 100644 --- a/td/telegram/net/DcOptionsSet.cpp +++ b/td/telegram/net/DcOptionsSet.cpp @@ -6,6 +6,7 @@ // #include "td/telegram/net/DcOptionsSet.h" +#include "td/utils/format.h" #include "td/utils/logging.h" #include diff --git a/td/tl/tl_dotnet_object.h b/td/tl/tl_dotnet_object.h index 424383cc..2d4a7d67 100644 --- a/td/tl/tl_dotnet_object.h +++ b/td/tl/tl_dotnet_object.h @@ -41,7 +41,7 @@ public: virtual NativeObject^ ToUnmanaged(); }; -//from unmanaged +// from unmanaged inline bool FromUnmanaged(bool val) { return val; } @@ -71,7 +71,7 @@ inline auto CLRCALL BytesFromUnmanaged(const std::string &from) { return res; } -template +template auto CLRCALL FromUnmanaged(std::vector &vec) { using ToT = decltype(FromUnmanaged(vec[0])); Array^ res = REF_NEW Vector(td::narrow_cast(vec.size()));