Remove more default constructors of telegram_api classes.
This commit is contained in:
parent
efa770ce73
commit
8398a6f19d
@ -49,8 +49,9 @@ 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, bool is_function) const {
|
||||
return tl_name == "td_api" || tl_name == "TdApi" || (t->var_count > 0 && !is_function);
|
||||
bool TD_TL_writer::is_default_constructor_generated(const tl::tl_combinator *t, bool can_be_parsed,
|
||||
bool can_be_stored) const {
|
||||
return tl_name == "td_api" || tl_name == "TdApi" || (t->var_count > 0 && can_be_parsed);
|
||||
}
|
||||
|
||||
int TD_TL_writer::get_storer_type(const tl::tl_combinator *t, const std::string &storer_name) const {
|
||||
|
@ -35,7 +35,8 @@ 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, bool is_function) const override;
|
||||
bool is_default_constructor_generated(const tl::tl_combinator *t, bool can_be_parsed,
|
||||
bool can_be_stored) 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;
|
||||
|
@ -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, true)) {
|
||||
if (w.is_default_constructor_generated(t, false, true)) {
|
||||
write_class_constructor(out, t, class_name, true, w);
|
||||
}
|
||||
if (required_args) {
|
||||
@ -306,7 +306,35 @@ 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, false)) {
|
||||
bool can_be_parsed = false;
|
||||
bool is_can_be_parsed_inited = false;
|
||||
std::vector<std::string> parsers = w.get_parsers();
|
||||
for (std::size_t i = 0; i < parsers.size(); i++) {
|
||||
int parser_type = w.get_parser_type(t, parsers[i]);
|
||||
if (w.get_parser_mode(parser_type) != TL_writer::All) {
|
||||
can_be_parsed |= is_reachable_for_parser(parser_type, t->name, request_types, result_types, w);
|
||||
is_can_be_parsed_inited = true;
|
||||
}
|
||||
}
|
||||
if (!is_can_be_parsed_inited) {
|
||||
can_be_parsed = true;
|
||||
}
|
||||
|
||||
bool can_be_stored = false;
|
||||
bool is_can_be_stored_inited = false;
|
||||
std::vector<std::string> storers = w.get_storers();
|
||||
for (std::size_t i = 0; i < storers.size(); i++) {
|
||||
int storer_type = w.get_storer_type(t, storers[i]);
|
||||
if (w.get_storer_mode(storer_type) != TL_writer::All) {
|
||||
can_be_stored |= is_reachable_for_storer(storer_type, t->name, request_types, result_types, w);
|
||||
is_can_be_stored_inited = true;
|
||||
}
|
||||
}
|
||||
if (!is_can_be_stored_inited) {
|
||||
can_be_stored = true;
|
||||
}
|
||||
|
||||
if (w.is_default_constructor_generated(t, can_be_parsed, can_be_stored)) {
|
||||
write_class_constructor(out, t, class_name, true, w);
|
||||
}
|
||||
if (required_args) {
|
||||
@ -319,7 +347,6 @@ static void write_constructor(tl_outputer &out, const tl_combinator *t, const st
|
||||
assert(t->result->get_type() == NODE_TYPE_TYPE);
|
||||
const tl_tree_type *result_type = static_cast<const tl_tree_type *>(t->result);
|
||||
|
||||
std::vector<std::string> parsers = w.get_parsers();
|
||||
for (std::size_t i = 0; i < parsers.size(); i++) {
|
||||
write_constructor_fetch(out, parsers[i], t, class_name, parent_class, result_type,
|
||||
required_args == 1 && result_type->type->simple_constructors == 1, request_types,
|
||||
@ -327,7 +354,6 @@ static void write_constructor(tl_outputer &out, const tl_combinator *t, const st
|
||||
}
|
||||
|
||||
// STORER
|
||||
std::vector<std::string> storers = w.get_storers();
|
||||
for (std::size_t i = 0; i < storers.size(); i++) {
|
||||
write_constructor_store(out, storers[i], t, class_name, result_type,
|
||||
required_args == 1 && result_type->type->simple_constructors == 1, request_types,
|
||||
|
@ -135,7 +135,7 @@ bool TL_writer::is_documentation_generated() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TL_writer::is_default_constructor_generated(const tl_combinator *t, bool is_function) const {
|
||||
bool TL_writer::is_default_constructor_generated(const tl_combinator *t, bool can_be_parsed, bool can_be_stored) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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, bool is_function) const;
|
||||
virtual bool is_default_constructor_generated(const tl_combinator *t, bool can_be_parsed, bool can_be_stored) 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;
|
||||
|
Loading…
Reference in New Issue
Block a user