Do not generate empty constructor for functions.

GitOrigin-RevId: 9a83f40616728dd814ca4ce5424b955b17ca4dfe
This commit is contained in:
levlam 2019-11-22 18:48:03 +03:00
parent 003c93f0d6
commit 7842b174b2
5 changed files with 7 additions and 7 deletions

View File

@ -49,8 +49,8 @@ bool TD_TL_writer::is_combinator_supported(const tl::tl_combinator *constructor)
return true;
}
bool TD_TL_writer::is_default_constructor_generated(const tl::tl_combinator *t) const {
return tl_name == "td_api" || tl_name == "TdApi" || t->var_count > 0;
bool TD_TL_writer::is_default_constructor_generated(const tl::tl_combinator *t, bool is_function) const {
return tl_name == "td_api" || tl_name == "TdApi" || (t->var_count > 0 && !is_function);
}
int TD_TL_writer::get_storer_type(const tl::tl_combinator *t, const std::string &storer_name) const {

View File

@ -35,7 +35,7 @@ class TD_TL_writer : public tl::TL_writer {
bool is_built_in_complex_type(const std::string &name) const override;
bool is_type_bare(const tl::tl_type *t) const override;
bool is_combinator_supported(const tl::tl_combinator *constructor) const override;
bool is_default_constructor_generated(const tl::tl_combinator *t) const override;
bool is_default_constructor_generated(const tl::tl_combinator *t, bool is_function) const override;
int get_storer_type(const tl::tl_combinator *t, const std::string &storer_name) const override;
Mode get_parser_mode(int type) const override;

View File

@ -253,7 +253,7 @@ static void write_function(tl_outputer &out, const tl_combinator *t, const std::
std::vector<var_description> vars(t->var_count);
out.append(w.gen_function_vars(t, vars));
if (w.is_default_constructor_generated(t)) {
if (w.is_default_constructor_generated(t, true)) {
write_class_constructor(out, t, class_name, true, w);
}
if (required_args) {
@ -306,7 +306,7 @@ static void write_constructor(tl_outputer &out, const tl_combinator *t, const st
int required_args = gen_field_definitions(out, t, class_name, w);
out.append(w.gen_flags_definitions(t));
if (w.is_default_constructor_generated(t)) {
if (w.is_default_constructor_generated(t, false)) {
write_class_constructor(out, t, class_name, true, w);
}
if (required_args) {

View File

@ -135,7 +135,7 @@ bool TL_writer::is_documentation_generated() const {
return false;
}
bool TL_writer::is_default_constructor_generated(const tl_combinator *t) const {
bool TL_writer::is_default_constructor_generated(const tl_combinator *t, bool is_function) const {
return true;
}

View File

@ -56,7 +56,7 @@ class TL_writer {
virtual bool is_type_bare(const tl_type *t) const = 0;
virtual bool is_combinator_supported(const tl_combinator *constructor) const;
virtual bool is_documentation_generated() const;
virtual bool is_default_constructor_generated(const tl_combinator *t) const;
virtual bool is_default_constructor_generated(const tl_combinator *t, bool is_function) const;
virtual int get_parser_type(const tl_combinator *t, const std::string &parser_name) const;
virtual int get_storer_type(const tl_combinator *t, const std::string &storer_name) const;