Don't generate MASK for parsed object/vector fields.
This commit is contained in:
parent
0522ba178a
commit
4533f79338
@ -164,13 +164,34 @@ std::string TD_TL_writer_h::gen_function_vars(const tl::tl_combinator *t,
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string TD_TL_writer_h::gen_flags_definitions(const tl::tl_combinator *t) const {
|
||||
bool TD_TL_writer_h::need_arg_mask(const tl::arg &a, bool can_be_stored) const {
|
||||
if (a.exist_var_num == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (can_be_stored) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (a.type->get_type() != tl::NODE_TYPE_TYPE) {
|
||||
return true;
|
||||
}
|
||||
const tl::tl_tree_type *tree_type = static_cast<tl::tl_tree_type *>(a.type);
|
||||
const std::string &name = tree_type->type->name;
|
||||
|
||||
if (!is_built_in_simple_type(name)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string TD_TL_writer_h::gen_flags_definitions(const tl::tl_combinator *t, bool can_be_stored) const {
|
||||
std::vector<std::pair<std::string, std::int32_t>> flags;
|
||||
|
||||
for (std::size_t i = 0; i < t->args.size(); i++) {
|
||||
const tl::arg &a = t->args[i];
|
||||
|
||||
if (a.exist_var_num != -1) {
|
||||
if (need_arg_mask(a, can_be_stored)) {
|
||||
auto name = a.name;
|
||||
for (auto &c : name) {
|
||||
c = to_upper(c);
|
||||
|
@ -20,6 +20,8 @@ class TD_TL_writer_h : public TD_TL_writer {
|
||||
|
||||
static std::string forward_declaration(std::string type);
|
||||
|
||||
bool need_arg_mask(const tl::arg &a, bool can_be_stored) const;
|
||||
|
||||
public:
|
||||
TD_TL_writer_h(const std::string &tl_name, const std::string &string_type, const std::string &bytes_type,
|
||||
const std::vector<std::string> &ext_include)
|
||||
@ -40,7 +42,7 @@ class TD_TL_writer_h : public TD_TL_writer {
|
||||
std::string gen_field_definition(const std::string &class_name, const std::string &type_name,
|
||||
const std::string &field_name) const override;
|
||||
|
||||
std::string gen_flags_definitions(const tl::tl_combinator *t) const override;
|
||||
std::string gen_flags_definitions(const tl::tl_combinator *t, bool can_be_stored) const override;
|
||||
std::string gen_vars(const tl::tl_combinator *t, const tl::tl_tree_type *result_type,
|
||||
std::vector<tl::var_description> &vars) const override;
|
||||
std::string gen_function_vars(const tl::tl_combinator *t, std::vector<tl::var_description> &vars) const override;
|
||||
|
@ -8724,7 +8724,6 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) {
|
||||
|
||||
telegram_api::object_ptr<telegram_api::userProfilePhoto> profile_photo;
|
||||
if (!G()->is_test_dc() && profile_photo_id != 0) {
|
||||
flags |= telegram_api::user::PHOTO_MASK;
|
||||
profile_photo = telegram_api::make_object<telegram_api::userProfilePhoto>(0, false /*ignored*/, profile_photo_id,
|
||||
BufferSlice(), profile_photo_dc_id);
|
||||
}
|
||||
|
@ -3848,9 +3848,9 @@ static auto secret_to_telegram_document(secret_api::decryptedMessageMediaExterna
|
||||
}
|
||||
vector<telegram_api::object_ptr<telegram_api::PhotoSize>> thumbnails;
|
||||
thumbnails.push_back(secret_to_telegram<telegram_api::PhotoSize>(*from.thumb_));
|
||||
return make_tl_object<telegram_api::document>(
|
||||
telegram_api::document::THUMBS_MASK, from.id_, from.access_hash_, BufferSlice(), from.date_, from.mime_type_,
|
||||
from.size_, std::move(thumbnails), Auto(), from.dc_id_, secret_to_telegram(from.attributes_));
|
||||
return make_tl_object<telegram_api::document>(0, from.id_, from.access_hash_, BufferSlice(), from.date_,
|
||||
from.mime_type_, from.size_, std::move(thumbnails), Auto(), from.dc_id_,
|
||||
secret_to_telegram(from.attributes_));
|
||||
}
|
||||
|
||||
template <class ToT, class FromT>
|
||||
@ -4116,7 +4116,7 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
||||
return make_unique<MessageText>(std::move(message), WebPageId());
|
||||
case telegram_api::messageMediaPhoto::ID: {
|
||||
auto message_photo = move_tl_object_as<telegram_api::messageMediaPhoto>(media);
|
||||
if ((message_photo->flags_ & telegram_api::messageMediaPhoto::PHOTO_MASK) == 0) {
|
||||
if (message_photo->photo_ == nullptr) {
|
||||
if ((message_photo->flags_ & telegram_api::messageMediaPhoto::TTL_SECONDS_MASK) == 0) {
|
||||
LOG(ERROR) << "Receive messageMediaPhoto without photo and TTL: " << oneline(to_string(message_photo));
|
||||
break;
|
||||
@ -4196,7 +4196,7 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
||||
}
|
||||
case telegram_api::messageMediaDocument::ID: {
|
||||
auto message_document = move_tl_object_as<telegram_api::messageMediaDocument>(media);
|
||||
if ((message_document->flags_ & telegram_api::messageMediaDocument::DOCUMENT_MASK) == 0) {
|
||||
if (message_document->document_ == nullptr) {
|
||||
if ((message_document->flags_ & telegram_api::messageMediaDocument::TTL_SECONDS_MASK) == 0) {
|
||||
LOG(ERROR) << "Receive messageMediaDocument without document and TTL: "
|
||||
<< oneline(to_string(message_document));
|
||||
|
@ -26621,7 +26621,7 @@ unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_for
|
||||
message_id = MessageId();
|
||||
}
|
||||
}
|
||||
if ((flags & telegram_api::messageFwdHeader::SAVED_FROM_PEER_MASK) != 0) {
|
||||
if (forward_header->saved_from_peer_ != nullptr) {
|
||||
from_dialog_id = DialogId(forward_header->saved_from_peer_);
|
||||
from_message_id = MessageId(ServerMessageId(forward_header->saved_from_msg_id_));
|
||||
if (!from_dialog_id.is_valid() || !from_message_id.is_valid()) {
|
||||
|
@ -3280,9 +3280,6 @@ Status NotificationManager::process_push_notification_payload(string payload, bo
|
||||
// set phone number flag to show that this is a full access hash
|
||||
flags |= telegram_api::user::ACCESS_HASH_MASK | telegram_api::user::PHONE_MASK;
|
||||
}
|
||||
if (sender_photo != nullptr) {
|
||||
flags |= telegram_api::user::PHOTO_MASK;
|
||||
}
|
||||
auto user_name = sender_user_id.get() == 136817688 ? "Channel" : sender_name;
|
||||
auto user = telegram_api::make_object<telegram_api::user>(
|
||||
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
|
@ -248,7 +248,7 @@ static void write_function(tl_outputer &out, const tl_combinator *t, const std::
|
||||
out.append(w.gen_class_begin(class_name, w.gen_base_function_class_name(), false));
|
||||
|
||||
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, true));
|
||||
|
||||
std::vector<var_description> vars(t->var_count);
|
||||
out.append(w.gen_function_vars(t, vars));
|
||||
@ -304,7 +304,6 @@ static void write_constructor(tl_outputer &out, const tl_combinator *t, const st
|
||||
|
||||
out.append(w.gen_class_begin(class_name, base_class, is_proxy));
|
||||
int required_args = gen_field_definitions(out, t, class_name, w);
|
||||
out.append(w.gen_flags_definitions(t));
|
||||
|
||||
bool can_be_parsed = false;
|
||||
bool is_can_be_parsed_inited = false;
|
||||
@ -334,6 +333,7 @@ static void write_constructor(tl_outputer &out, const tl_combinator *t, const st
|
||||
can_be_stored = true;
|
||||
}
|
||||
|
||||
out.append(w.gen_flags_definitions(t, can_be_stored));
|
||||
if (w.is_default_constructor_generated(t, can_be_parsed, can_be_stored)) {
|
||||
write_class_constructor(out, t, class_name, true, w);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ class TL_writer {
|
||||
|
||||
virtual std::string gen_field_definition(const std::string &class_name, const std::string &type_name,
|
||||
const std::string &field_name) const = 0;
|
||||
virtual std::string gen_flags_definitions(const tl_combinator *t) const {
|
||||
virtual std::string gen_flags_definitions(const tl_combinator *t, bool can_be_stored) const {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user