Generate only needed telegram_api full constructors.

This commit is contained in:
levlam 2021-08-01 07:23:50 +03:00
parent 1223c72741
commit a4e1839089
6 changed files with 22 additions and 5 deletions

View File

@ -51,7 +51,19 @@ 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, bool can_be_parsed,
bool can_be_stored) const {
return tl_name == "td_api" || tl_name == "TdApi" || (t->var_count > 0 && can_be_parsed);
return tl_name == "td_api" || tl_name == "TdApi" || (t->var_count > 0 && can_be_parsed) || t->name == "updates";
}
bool TD_TL_writer::is_full_constructor_generated(const tl::tl_combinator *t, bool can_be_parsed,
bool can_be_stored) const {
return tl_name == "td_api" || tl_name == "TdApi" || can_be_stored || t->name == "phone.groupParticipants" ||
t->name == "user" || t->name == "userProfilePhoto" || t->name == "channelForbidden" ||
t->name == "photoSizeEmpty" || t->name == "photoSize" || t->name == "photoCachedSize" ||
t->name == "document" || t->name == "updateDeleteMessages" || t->name == "updateEditChannelMessage" ||
t->name == "encryptedChatWaiting" || t->name == "encryptedChatRequested" || t->name == "encryptedChat" ||
t->name == "langPackString" || t->name == "langPackStringPluralized" || t->name == "langPackStringDeleted" ||
t->name == "peerUser" || t->name == "peerChat" || t->name == "updateServiceNotification" ||
t->name == "updateNewMessage" || t->name == "message" || t->name == "updateChannelTooLong";
}
int TD_TL_writer::get_storer_type(const tl::tl_combinator *t, const std::string &storer_name) const {

View File

@ -37,6 +37,7 @@ class TD_TL_writer : public tl::TL_writer {
bool is_combinator_supported(const tl::tl_combinator *constructor) const override;
bool is_default_constructor_generated(const tl::tl_combinator *t, bool can_be_parsed,
bool can_be_stored) const override;
bool is_full_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;

View File

@ -1501,8 +1501,7 @@ class DeleteChatQuery final : public Td::ResultHandler {
LOG(INFO) << "Receive result for DeleteChatQuery: " << result_ptr.ok();
td->updates_manager_->get_difference("DeleteChatQuery");
td->updates_manager_->on_get_updates(make_tl_object<telegram_api::updates>(Auto(), Auto(), Auto(), 0, 0),
std::move(promise_));
td->updates_manager_->on_get_updates(make_tl_object<telegram_api::updates>(), std::move(promise_));
}
void on_error(uint64 id, Status status) final {

View File

@ -256,7 +256,7 @@ static void write_function(tl_outputer &out, const tl_combinator *t, const std::
if (w.is_default_constructor_generated(t, false, true)) {
write_class_constructor(out, t, class_name, true, w);
}
if (required_args) {
if (required_args && w.is_full_constructor_generated(t, false, true)) {
write_class_constructor(out, t, class_name, false, w);
}
@ -337,7 +337,7 @@ static void write_constructor(tl_outputer &out, const tl_combinator *t, const st
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) {
if (required_args && w.is_full_constructor_generated(t, can_be_parsed, can_be_stored)) {
write_class_constructor(out, t, class_name, false, w);
}

View File

@ -139,6 +139,10 @@ bool TL_writer::is_default_constructor_generated(const tl_combinator *t, bool ca
return true;
}
bool TL_writer::is_full_constructor_generated(const tl_combinator *t, bool can_be_parsed, bool can_be_stored) const {
return true;
}
std::string TL_writer::gen_main_class_name(const tl_type *t) const {
if (t->simple_constructors == 1) {
for (std::size_t i = 0; i < t->constructors_num; i++) {

View File

@ -57,6 +57,7 @@ class TL_writer {
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 can_be_parsed, bool can_be_stored) const;
virtual bool is_full_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;