Do not generate empty fetch functions and empty constructors.
GitOrigin-RevId: 65f0f7e37f5af8d6e256b6c7b7c07241354b7b45
This commit is contained in:
parent
6d53f3a85a
commit
0c4433621e
@ -517,15 +517,21 @@ std::string TD_TL_writer_cpp::gen_fetch_function_begin(const std::string &parser
|
|||||||
assert(arity == 0);
|
assert(arity == 0);
|
||||||
|
|
||||||
if (parser_type == 0) {
|
if (parser_type == 0) {
|
||||||
return "\n" + returned_type + class_name + "::fetch(" + parser_name +
|
std::string result = "\n" + returned_type + class_name + "::fetch(" + parser_name +
|
||||||
" &p) {\n"
|
" &p) {\n"
|
||||||
" return make_tl_object<" +
|
" return make_tl_object<" +
|
||||||
class_name +
|
class_name + ">(";
|
||||||
">(p);\n"
|
if (field_num == 0) {
|
||||||
"}\n\n" +
|
result += ");\n";
|
||||||
class_name + "::" + class_name + "(" + parser_name +
|
} else {
|
||||||
" &p)\n"
|
result +=
|
||||||
"#define FAIL(error) p.set_error(error)\n";
|
"p);\n"
|
||||||
|
"}\n\n" +
|
||||||
|
class_name + "::" + class_name + "(" + parser_name +
|
||||||
|
" &p)\n"
|
||||||
|
"#define FAIL(error) p.set_error(error)\n";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "\n" + returned_type + class_name + "::fetch(" + parser_name +
|
return "\n" + returned_type + class_name + "::fetch(" + parser_name +
|
||||||
@ -542,9 +548,11 @@ std::string TD_TL_writer_cpp::gen_fetch_function_end(bool has_parent, int field_
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (parser_type == 0) {
|
if (parser_type == 0) {
|
||||||
|
if (field_num == 0) {
|
||||||
|
return "}\n";
|
||||||
|
}
|
||||||
return "#undef FAIL\n"
|
return "#undef FAIL\n"
|
||||||
"{" +
|
"{}\n";
|
||||||
(field_num == 0 ? "\n (void)p;\n" : std::string()) + "}\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser_type == -1) {
|
if (parser_type == -1) {
|
||||||
|
@ -258,10 +258,15 @@ std::string TD_TL_writer_h::gen_fetch_function_begin(const std::string &parser_n
|
|||||||
std::string returned_type = "object_ptr<" + parent_class_name + "> ";
|
std::string returned_type = "object_ptr<" + parent_class_name + "> ";
|
||||||
|
|
||||||
if (parser_type == 0) {
|
if (parser_type == 0) {
|
||||||
return "\n"
|
std::string result =
|
||||||
" static " +
|
"\n"
|
||||||
returned_type + "fetch(" + parser_name + " &p);\n\n" + " explicit " + class_name + "(" + parser_name +
|
" static " +
|
||||||
" &p);\n";
|
returned_type + "fetch(" + parser_name + " &p);\n";
|
||||||
|
if (field_num != 0) {
|
||||||
|
result += "\n"
|
||||||
|
" explicit " + class_name + "(" + parser_name + " &p);\n";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(arity == 0);
|
assert(arity == 0);
|
||||||
|
@ -50,7 +50,7 @@ bool TD_TL_writer::is_combinator_supported(const tl::tl_combinator *constructor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TD_TL_writer::is_default_constructor_generated(const tl::tl_combinator *t) const {
|
bool TD_TL_writer::is_default_constructor_generated(const tl::tl_combinator *t) const {
|
||||||
return tl_name == "td_api" || t->var_count > 0 || t->args.empty();
|
return tl_name == "td_api" || t->var_count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TD_TL_writer::get_storer_type(const tl::tl_combinator *t, const std::string &storer_name) const {
|
int TD_TL_writer::get_storer_type(const tl::tl_combinator *t, const std::string &storer_name) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user