Do not generate default constructors.
GitOrigin-RevId: 89afa038ad99739ca0465e05a2e123ac60e7fa7a
This commit is contained in:
parent
0f353009f8
commit
26c5328b89
@ -47,7 +47,7 @@ class F {
|
||||
};
|
||||
|
||||
BENCH(Call, "TL Call") {
|
||||
tl_object_ptr<telegram_api::Function> x = make_tl_object<telegram_api::account_getWallPapers>();
|
||||
tl_object_ptr<telegram_api::Function> x = make_tl_object<telegram_api::account_getWallPapers>(0);
|
||||
uint32 res = 0;
|
||||
F f(res);
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
@ -49,6 +49,10 @@ 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" || t->var_count > 0 || t->args.empty();
|
||||
}
|
||||
|
||||
int TD_TL_writer::get_storer_type(const tl::tl_combinator *t, const std::string &storer_name) const {
|
||||
return storer_name == "TlStorerToString";
|
||||
}
|
||||
|
@ -35,6 +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;
|
||||
|
||||
int get_storer_type(const tl::tl_combinator *t, const std::string &storer_name) const override;
|
||||
Mode get_parser_mode(int type) const override;
|
||||
|
@ -77,12 +77,10 @@ Result<RSA> RSA::from_pem(Slice pem) {
|
||||
}
|
||||
|
||||
int64 RSA::get_fingerprint() const {
|
||||
mtproto_api::rsa_public_key public_key;
|
||||
// string objects are necessary, because mtproto_api::rsa_public_key contains Slice inside
|
||||
string n_str = n_.to_binary();
|
||||
string e_str = e_.to_binary();
|
||||
public_key.n_ = n_str;
|
||||
public_key.e_ = e_str;
|
||||
mtproto_api::rsa_public_key public_key(n_str, e_str);
|
||||
size_t size = tl_calc_length(public_key);
|
||||
std::vector<unsigned char> tmp(size);
|
||||
size = tl_store_unsafe(public_key, tmp.data());
|
||||
|
@ -744,7 +744,7 @@ void PasswordManager::get_ton_wallet_password_salt(Promise<td_api::object_ptr<td
|
||||
|
||||
get_ton_wallet_password_salt_queries_.push_back(std::move(promise));
|
||||
if (get_ton_wallet_password_salt_queries_.size() == 1) {
|
||||
send_with_promise(G()->net_query_creator().create(create_storer(telegram_api::wallet_getKeySecretSalt())),
|
||||
send_with_promise(G()->net_query_creator().create(create_storer(telegram_api::wallet_getKeySecretSalt(false))),
|
||||
PromiseCreator::lambda([actor_id = actor_id(this)](Result<NetQueryPtr> r_query) mutable {
|
||||
auto r_result = fetch_result<telegram_api::wallet_getKeySecretSalt>(std::move(r_query));
|
||||
send_closure(actor_id, &PasswordManager::on_get_ton_wallet_password_salt, std::move(r_result));
|
||||
|
@ -470,7 +470,7 @@ void SecretChatActor::notify_screenshot_taken(Promise<> promise) {
|
||||
promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
return;
|
||||
}
|
||||
send_action(make_tl_object<secret_api::decryptedMessageActionScreenshotMessages>(), SendFlag::Push,
|
||||
send_action(make_tl_object<secret_api::decryptedMessageActionScreenshotMessages>(vector<int64>()), SendFlag::Push,
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
@ -565,10 +565,8 @@ Status SecretChatActor::run_auth() {
|
||||
return Status::OK();
|
||||
}
|
||||
// messages.requestEncryption#f64daf43 user_id:InputUser random_id:int g_a:bytes = EncryptedChat;
|
||||
telegram_api::messages_requestEncryption tl_query;
|
||||
tl_query.user_id_ = get_input_user();
|
||||
tl_query.random_id_ = auth_state_.random_id;
|
||||
tl_query.g_a_ = BufferSlice(auth_state_.handshake.get_g_b());
|
||||
telegram_api::messages_requestEncryption tl_query(get_input_user(), auth_state_.random_id,
|
||||
BufferSlice(auth_state_.handshake.get_g_b()));
|
||||
auto query = context_->net_query_creator().create(
|
||||
UniqueId::next(UniqueId::Type::Default, static_cast<uint8>(QueryType::EncryptedChat)),
|
||||
create_storer(tl_query));
|
||||
@ -584,12 +582,9 @@ Status SecretChatActor::run_auth() {
|
||||
auto id_and_key = auth_state_.handshake.gen_key();
|
||||
pfs_state_.auth_key = mtproto::AuthKey(id_and_key.first, std::move(id_and_key.second));
|
||||
calc_key_hash();
|
||||
// messages.acceptEncryption#3dbc0415 peer:InputEncryptedChat g_b:bytes key_fingerprint:long =
|
||||
// EncryptedChat;
|
||||
telegram_api::messages_acceptEncryption tl_query;
|
||||
tl_query.peer_ = get_input_chat();
|
||||
tl_query.g_b_ = BufferSlice(auth_state_.handshake.get_g_b());
|
||||
tl_query.key_fingerprint_ = pfs_state_.auth_key.id();
|
||||
// messages.acceptEncryption#3dbc0415 peer:InputEncryptedChat g_b:bytes key_fingerprint:long = EncryptedChat;
|
||||
telegram_api::messages_acceptEncryption tl_query(get_input_chat(), BufferSlice(auth_state_.handshake.get_g_b()),
|
||||
pfs_state_.auth_key.id());
|
||||
auto query = context_->net_query_creator().create(
|
||||
UniqueId::next(UniqueId::Type::Default, static_cast<uint8>(QueryType::EncryptedChat)),
|
||||
create_storer(tl_query));
|
||||
|
@ -1695,7 +1695,7 @@ SecretInputMedia StickersManager::get_secret_input_media(FileId sticker_file_id,
|
||||
return SecretInputMedia{nullptr, make_tl_object<secret_api::decryptedMessageMediaExternalDocument>(
|
||||
remote_location.get_id(), remote_location.get_access_hash(), 0 /*date*/,
|
||||
get_sticker_mime_type(sticker), narrow_cast<int32>(file_view.size()),
|
||||
make_tl_object<secret_api::photoSizeEmpty>(),
|
||||
make_tl_object<secret_api::photoSizeEmpty>("t"),
|
||||
remote_location.get_dc_id().get_raw_id(), std::move(attributes))};
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +252,9 @@ 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));
|
||||
|
||||
write_class_constructor(out, t, class_name, true, w);
|
||||
if (w.is_default_constructor_generated(t)) {
|
||||
write_class_constructor(out, t, class_name, true, w);
|
||||
}
|
||||
if (required_args) {
|
||||
write_class_constructor(out, t, class_name, false, w);
|
||||
}
|
||||
@ -303,7 +305,9 @@ 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));
|
||||
|
||||
write_class_constructor(out, t, class_name, true, w);
|
||||
if (w.is_default_constructor_generated(t)) {
|
||||
write_class_constructor(out, t, class_name, true, w);
|
||||
}
|
||||
if (required_args) {
|
||||
write_class_constructor(out, t, class_name, false, w);
|
||||
}
|
||||
|
@ -135,6 +135,10 @@ bool TL_writer::is_documentation_generated() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TL_writer::is_default_constructor_generated(const tl_combinator *t) 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++) {
|
||||
|
@ -56,6 +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 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;
|
||||
|
Reference in New Issue
Block a user