Do not generate empty constructor for functions.
GitOrigin-RevId: 9a83f40616728dd814ca4ce5424b955b17ca4dfe
This commit is contained in:
parent
003c93f0d6
commit
7842b174b2
@ -49,8 +49,8 @@ bool TD_TL_writer::is_combinator_supported(const tl::tl_combinator *constructor)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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, bool is_function) const {
|
||||||
return tl_name == "td_api" || tl_name == "TdApi" || t->var_count > 0;
|
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 {
|
int TD_TL_writer::get_storer_type(const tl::tl_combinator *t, const std::string &storer_name) const {
|
||||||
|
@ -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_built_in_complex_type(const std::string &name) const override;
|
||||||
bool is_type_bare(const tl::tl_type *t) 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_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;
|
int get_storer_type(const tl::tl_combinator *t, const std::string &storer_name) const override;
|
||||||
Mode get_parser_mode(int type) const override;
|
Mode get_parser_mode(int type) const override;
|
||||||
|
@ -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);
|
std::vector<var_description> vars(t->var_count);
|
||||||
out.append(w.gen_function_vars(t, vars));
|
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);
|
write_class_constructor(out, t, class_name, true, w);
|
||||||
}
|
}
|
||||||
if (required_args) {
|
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);
|
int required_args = gen_field_definitions(out, t, class_name, w);
|
||||||
out.append(w.gen_flags_definitions(t));
|
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);
|
write_class_constructor(out, t, class_name, true, w);
|
||||||
}
|
}
|
||||||
if (required_args) {
|
if (required_args) {
|
||||||
|
@ -135,7 +135,7 @@ bool TL_writer::is_documentation_generated() const {
|
|||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class TL_writer {
|
|||||||
virtual bool is_type_bare(const tl_type *t) const = 0;
|
virtual bool is_type_bare(const tl_type *t) const = 0;
|
||||||
virtual bool is_combinator_supported(const tl_combinator *constructor) const;
|
virtual bool is_combinator_supported(const tl_combinator *constructor) const;
|
||||||
virtual bool is_documentation_generated() 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_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;
|
virtual int get_storer_type(const tl_combinator *t, const std::string &storer_name) const;
|
||||||
|
Reference in New Issue
Block a user