Various fixes.

GitOrigin-RevId: 80fa34e64e6824a0f96c38d2e8b0a32455267ea8
This commit is contained in:
levlam 2018-02-28 13:25:07 +03:00
parent 110f2c5b7b
commit 1ac97a6ba7
12 changed files with 28 additions and 20 deletions

View File

@ -97,8 +97,8 @@ func myReadLine() -> String {
}
}
func updateAuthorizationState(authState: Dictionary<String, Any>) {
switch(authState["@type"] as! String) {
func updateAuthorizationState(authorizationState: Dictionary<String, Any>) {
switch(authorizationState["@type"] as! String) {
case "authorizationStateWaitTdlibParameters":
client.queryAsync(query:[
"@type":"setTdlibParameters",
@ -122,13 +122,13 @@ func updateAuthorizationState(authState: Dictionary<String, Any>) {
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<String, Any>) {
}
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<String, Any>) {
}
}
func checkAuthError(error: Dictionary<String, Any>) {
func checkAuthenticationError(error: Dictionary<String, Any>) {
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<String, Any>)
updateAuthorizationState(authorizationState: update["authorization_state"] as! Dictionary<String, Any>)
}
}

View File

@ -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)

View File

@ -9,6 +9,7 @@
#include "td/tl/tl_writer.h"
#include <cassert>
#include <cstdint>
#include <sstream>
#include <string>
#include <vector>
@ -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<var_description> &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<td::td_api::" << native_class_name << ">(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();

View File

@ -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 <algorithm>

View File

@ -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 {

View File

@ -10,6 +10,8 @@
#include "td/utils/port/CxCli.h"
#include <cstdint>
namespace Telegram {
namespace Td {

View File

@ -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"

View File

@ -8,6 +8,8 @@
#include "td/utils/port/CxCli.h"
#include <cstdint>
namespace Telegram {
namespace Td {

View File

@ -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"

View File

@ -20,6 +20,8 @@
#include "td/utils/Random.h"
#include "td/utils/StringBuilder.h"
#include <tuple>
namespace td {
namespace {
@ -104,7 +106,7 @@ bool for_suggested_file_name(CSlice name, bool use_pmc, bool use_random, F &&cal
Result<string> 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<std::pair<FileFd, string>> res = Status::Error();
Result<std::pair<FileFd, string>> 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<string> create_from_temp(CSlice temp_path, CSlice dir, CSlice name) {
}
Result<string> search_file(CSlice dir, CSlice name, int64 expected_size) {
Result<std::string> res = Status::Error();
Result<std::string> 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()) {

View File

@ -6,6 +6,7 @@
//
#include "td/telegram/net/DcOptionsSet.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"
#include <algorithm>

View File

@ -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 <class FromT>
template <class FromT>
auto CLRCALL FromUnmanaged(std::vector<FromT> &vec) {
using ToT = decltype(FromUnmanaged(vec[0]));
Array<ToT>^ res = REF_NEW Vector<ToT>(td::narrow_cast<int>(vec.size()));