diff --git a/td/generate/tl_writer_cpp.cpp b/td/generate/tl_writer_cpp.cpp index 738f13b9..b2b5c5f5 100644 --- a/td/generate/tl_writer_cpp.cpp +++ b/td/generate/tl_writer_cpp.cpp @@ -517,15 +517,21 @@ std::string TD_TL_writer_cpp::gen_fetch_function_begin(const std::string &parser assert(arity == 0); if (parser_type == 0) { - return "\n" + returned_type + class_name + "::fetch(" + parser_name + - " &p) {\n" - " return make_tl_object<" + - class_name + - ">(p);\n" - "}\n\n" + - class_name + "::" + class_name + "(" + parser_name + - " &p)\n" - "#define FAIL(error) p.set_error(error)\n"; + std::string result = "\n" + returned_type + class_name + "::fetch(" + parser_name + + " &p) {\n" + " return make_tl_object<" + + class_name + ">("; + if (field_num == 0) { + result += ");\n"; + } else { + result += + "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 + @@ -542,9 +548,11 @@ std::string TD_TL_writer_cpp::gen_fetch_function_end(bool has_parent, int field_ } if (parser_type == 0) { + if (field_num == 0) { + return "}\n"; + } return "#undef FAIL\n" - "{" + - (field_num == 0 ? "\n (void)p;\n" : std::string()) + "}\n"; + "{}\n"; } if (parser_type == -1) { diff --git a/td/generate/tl_writer_h.cpp b/td/generate/tl_writer_h.cpp index 1bae4887..5b07b350 100644 --- a/td/generate/tl_writer_h.cpp +++ b/td/generate/tl_writer_h.cpp @@ -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 + "> "; if (parser_type == 0) { - return "\n" - " static " + - returned_type + "fetch(" + parser_name + " &p);\n\n" + " explicit " + class_name + "(" + parser_name + - " &p);\n"; + std::string result = + "\n" + " static " + + 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); diff --git a/td/generate/tl_writer_td.cpp b/td/generate/tl_writer_td.cpp index 93f16749..4877fc2b 100644 --- a/td/generate/tl_writer_td.cpp +++ b/td/generate/tl_writer_td.cpp @@ -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 { - 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 {