GitOrigin-RevId: 0bb7986447b8c9fcdc80b8caf1feb03f8a945d90
This commit is contained in:
levlam 2018-09-26 03:54:37 +03:00
parent b7c2248c72
commit eb4c85a797
15 changed files with 30 additions and 22 deletions

View File

@ -1033,7 +1033,7 @@ class TlWriterCCommon : public tl::TL_writer {
std::vector<tl::var_description> &vars, int parser_type) const override { std::vector<tl::var_description> &vars, int parser_type) const override {
return ""; return "";
} }
std::string gen_fetch_function_end(int field_num, const std::vector<tl::var_description> &vars, std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
int parser_type) const override { int parser_type) const override {
return ""; return "";
} }

View File

@ -534,7 +534,8 @@ std::string TD_TL_writer_cpp::gen_fetch_function_begin(const std::string &parser
(parser_type == -1 ? "" : " " + fetched_type + "res = make_tl_object<" + class_name + ">();\n"); (parser_type == -1 ? "" : " " + fetched_type + "res = make_tl_object<" + class_name + ">();\n");
} }
std::string TD_TL_writer_cpp::gen_fetch_function_end(int field_num, const std::vector<tl::var_description> &vars, std::string TD_TL_writer_cpp::gen_fetch_function_end(bool has_parent, int field_num,
const std::vector<tl::var_description> &vars,
int parser_type) const { int parser_type) const {
for (std::size_t i = 0; i < vars.size(); i++) { for (std::size_t i = 0; i < vars.size(); i++) {
assert(vars[i].is_stored); assert(vars[i].is_stored);
@ -552,7 +553,9 @@ std::string TD_TL_writer_cpp::gen_fetch_function_end(int field_num, const std::v
} }
return " if (p.get_error()) { FAIL(\"\"); }\n" return " if (p.get_error()) { FAIL(\"\"); }\n"
" return res;\n" " return " +
std::string(has_parent ? "std::move(res)" : "res") +
";\n"
"#undef FAIL\n" "#undef FAIL\n"
"}\n"; "}\n";
} }

View File

@ -79,7 +79,7 @@ class TD_TL_writer_cpp : public TD_TL_writer {
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name, std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
const std::string &parent_class_name, int arity, const std::string &parent_class_name, int arity,
std::vector<tl::var_description> &vars, int parser_type) const override; std::vector<tl::var_description> &vars, int parser_type) const override;
std::string gen_fetch_function_end(int field_num, const std::vector<tl::var_description> &vars, std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
int parser_type) const override; int parser_type) const override;
std::string gen_fetch_function_result_begin(const std::string &parser_name, const std::string &class_name, std::string gen_fetch_function_result_begin(const std::string &parser_name, const std::string &class_name,

View File

@ -472,7 +472,7 @@ class TlWriterDotNet : public TL_writer {
std::vector<var_description> &vars, int parser_type) const override { std::vector<var_description> &vars, int parser_type) const override {
return ""; return "";
} }
std::string gen_fetch_function_end(int field_num, const std::vector<var_description> &vars, std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<var_description> &vars,
int parser_type) const override { int parser_type) const override {
return ""; return "";
} }

View File

@ -271,7 +271,8 @@ std::string TD_TL_writer_h::gen_fetch_function_begin(const std::string &parser_n
returned_type + "fetch(" + parser_name + " &p);\n"; returned_type + "fetch(" + parser_name + " &p);\n";
} }
std::string TD_TL_writer_h::gen_fetch_function_end(int field_num, const std::vector<tl::var_description> &vars, std::string TD_TL_writer_h::gen_fetch_function_end(bool has_parent, int field_num,
const std::vector<tl::var_description> &vars,
int parser_type) const { int parser_type) const {
return ""; return "";
} }

View File

@ -65,7 +65,7 @@ class TD_TL_writer_h : public TD_TL_writer {
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name, std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
const std::string &parent_class_name, int arity, const std::string &parent_class_name, int arity,
std::vector<tl::var_description> &vars, int parser_type) const override; std::vector<tl::var_description> &vars, int parser_type) const override;
std::string gen_fetch_function_end(int field_num, const std::vector<tl::var_description> &vars, std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
int parser_type) const override; int parser_type) const override;
std::string gen_fetch_function_result_begin(const std::string &parser_name, const std::string &class_name, std::string gen_fetch_function_result_begin(const std::string &parser_name, const std::string &class_name,

View File

@ -143,7 +143,8 @@ std::string TD_TL_writer_hpp::gen_fetch_function_begin(const std::string &parser
return ""; return "";
} }
std::string TD_TL_writer_hpp::gen_fetch_function_end(int field_num, const std::vector<tl::var_description> &vars, std::string TD_TL_writer_hpp::gen_fetch_function_end(bool has_parent, int field_num,
const std::vector<tl::var_description> &vars,
int parser_type) const { int parser_type) const {
return ""; return "";
} }

View File

@ -66,7 +66,7 @@ class TD_TL_writer_hpp : public TD_TL_writer {
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name, std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
const std::string &parent_class_name, int arity, const std::string &parent_class_name, int arity,
std::vector<tl::var_description> &vars, int parser_type) const override; std::vector<tl::var_description> &vars, int parser_type) const override;
std::string gen_fetch_function_end(int field_num, const std::vector<tl::var_description> &vars, std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
int parser_type) const override; int parser_type) const override;
std::string gen_fetch_function_result_begin(const std::string &parser_name, const std::string &class_name, std::string gen_fetch_function_result_begin(const std::string &parser_name, const std::string &class_name,

View File

@ -351,7 +351,8 @@ std::string TD_TL_writer_java::gen_fetch_function_begin(const std::string &parse
return ""; return "";
} }
std::string TD_TL_writer_java::gen_fetch_function_end(int field_num, const std::vector<tl::var_description> &vars, std::string TD_TL_writer_java::gen_fetch_function_end(bool has_parent, int field_num,
const std::vector<tl::var_description> &vars,
int parser_type) const { int parser_type) const {
return ""; return "";
} }

View File

@ -90,7 +90,7 @@ class TD_TL_writer_java : public tl::TL_writer {
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name, std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
const std::string &parent_class_name, int arity, const std::string &parent_class_name, int arity,
std::vector<tl::var_description> &vars, int parser_type) const override; std::vector<tl::var_description> &vars, int parser_type) const override;
std::string gen_fetch_function_end(int field_num, const std::vector<tl::var_description> &vars, std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
int parser_type) const override; int parser_type) const override;
std::string gen_fetch_function_result_begin(const std::string &parser_name, const std::string &class_name, std::string gen_fetch_function_result_begin(const std::string &parser_name, const std::string &class_name,

View File

@ -399,7 +399,8 @@ std::string TD_TL_writer_jni_cpp::gen_fetch_function_begin(const std::string &pa
fetched_type + "res = make_object<" + class_name + ">();\n"); fetched_type + "res = make_object<" + class_name + ">();\n");
} }
std::string TD_TL_writer_jni_cpp::gen_fetch_function_end(int field_num, const std::vector<tl::var_description> &vars, std::string TD_TL_writer_jni_cpp::gen_fetch_function_end(bool has_parent, int field_num,
const std::vector<tl::var_description> &vars,
int parser_type) const { int parser_type) const {
for (std::size_t i = 0; i < vars.size(); i++) { for (std::size_t i = 0; i < vars.size(); i++) {
assert(vars[i].is_stored); assert(vars[i].is_stored);
@ -411,7 +412,8 @@ std::string TD_TL_writer_jni_cpp::gen_fetch_function_end(int field_num, const st
return "}\n"; return "}\n";
} }
return " return res;\n" return " return " + std::string(has_parent ? "std::move(res)" : "res") +
";\n"
"}\n"; "}\n";
} }

View File

@ -76,7 +76,7 @@ class TD_TL_writer_jni_cpp : public TD_TL_writer_cpp {
std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name, std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
const std::string &parent_class_name, int arity, const std::string &parent_class_name, int arity,
std::vector<tl::var_description> &vars, int parser_type) const override; std::vector<tl::var_description> &vars, int parser_type) const override;
std::string gen_fetch_function_end(int field_num, const std::vector<tl::var_description> &vars, std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<tl::var_description> &vars,
int parser_type) const override; int parser_type) const override;
std::string gen_fetch_function_result_begin(const std::string &parser_name, const std::string &class_name, std::string gen_fetch_function_result_begin(const std::string &parser_name, const std::string &class_name,

View File

@ -3344,7 +3344,7 @@ class CliClient final : public Actor {
if (!user.empty() && password.empty()) { if (!user.empty() && password.empty()) {
type = make_tl_object<td_api::proxyTypeMtproto>(user); type = make_tl_object<td_api::proxyTypeMtproto>(user);
} else { } else {
if (port == "80") { if (port == "80" || port == "8080") {
type = make_tl_object<td_api::proxyTypeHttp>(user, password, op.back() != 'p'); type = make_tl_object<td_api::proxyTypeHttp>(user, password, op.back() != 'p');
} else { } else {
type = make_tl_object<td_api::proxyTypeSocks5>(user, password); type = make_tl_object<td_api::proxyTypeSocks5>(user, password);
@ -3381,7 +3381,7 @@ class CliClient final : public Actor {
td::Log::set_verbosity_level(static_cast<int>(op.size())); td::Log::set_verbosity_level(static_cast<int>(op.size()));
} else if (op[0] == 'v' && ('0' <= op[1] && op[1] <= '9')) { } else if (op[0] == 'v' && ('0' <= op[1] && op[1] <= '9')) {
td::Log::set_verbosity_level(to_integer<int>(op.substr(1))); td::Log::set_verbosity_level(to_integer<int>(op.substr(1)));
} else if (op == "sltvl" || op == "sltvle") { } else if (op == "sltvl" || op == "sltvle" || op == "tag") {
string tag; string tag;
string level; string level;
std::tie(tag, level) = split(args); std::tie(tag, level) = split(args);

View File

@ -103,7 +103,7 @@ static void write_function_fetch(tl_outputer &out, const std::string &parser_nam
} }
} }
out.append(w.gen_fetch_function_end(field_num, vars, parser_type)); out.append(w.gen_fetch_function_end(false, field_num, vars, parser_type));
} }
static std::vector<var_description> write_function_store(tl_outputer &out, const std::string &storer_name, static std::vector<var_description> write_function_store(tl_outputer &out, const std::string &storer_name,
@ -192,7 +192,7 @@ static void write_constructor_fetch(tl_outputer &out, const std::string &parser_
} }
} }
out.append(w.gen_fetch_function_end(field_num, vars, parser_type)); out.append(w.gen_fetch_function_end(class_name != parent_class_name, field_num, vars, parser_type));
} }
static void write_constructor_store(tl_outputer &out, const std::string &storer_name, const tl_combinator *t, static void write_constructor_store(tl_outputer &out, const std::string &storer_name, const tl_combinator *t,
@ -378,7 +378,7 @@ void write_class(tl_outputer &out, const tl_type *t, const std::set<std::string>
} }
out.append(w.gen_fetch_switch_end()); out.append(w.gen_fetch_switch_end());
out.append(w.gen_fetch_function_end(-1, empty_vars, -1)); out.append(w.gen_fetch_function_end(false, -1, empty_vars, -1));
} }
std::vector<std::string> storers = w.get_storers(); std::vector<std::string> storers = w.get_storers();
@ -672,7 +672,7 @@ void write_tl(const tl_config &config, tl_outputer &out, const TL_writer &w) {
} }
} }
out.append(w.gen_fetch_switch_end()); out.append(w.gen_fetch_switch_end());
out.append(w.gen_fetch_function_end(-1, empty_vars, -1)); out.append(w.gen_fetch_function_end(false, -1, empty_vars, -1));
} }
std::vector<std::string> additional_functions = w.get_additional_functions(); std::vector<std::string> additional_functions = w.get_additional_functions();
@ -737,7 +737,7 @@ void write_tl(const tl_config &config, tl_outputer &out, const TL_writer &w) {
} }
} }
out.append(w.gen_fetch_switch_end()); out.append(w.gen_fetch_switch_end());
out.append(w.gen_fetch_function_end(-1, empty_vars, -1)); out.append(w.gen_fetch_function_end(false, -1, empty_vars, -1));
} }
std::vector<std::string> storers = w.get_storers(); std::vector<std::string> storers = w.get_storers();

View File

@ -121,7 +121,7 @@ class TL_writer {
virtual std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name, virtual std::string gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
const std::string &parent_class_name, int arity, const std::string &parent_class_name, int arity,
std::vector<var_description> &vars, int parser_type) const = 0; std::vector<var_description> &vars, int parser_type) const = 0;
virtual std::string gen_fetch_function_end(int field_num, const std::vector<var_description> &vars, virtual std::string gen_fetch_function_end(bool has_parent, int field_num, const std::vector<var_description> &vars,
int parser_type) const = 0; int parser_type) const = 0;
virtual std::string gen_fetch_function_result_begin(const std::string &parser_name, const std::string &class_name, virtual std::string gen_fetch_function_result_begin(const std::string &parser_name, const std::string &class_name,