Better fix for END_PARSE_FLAGS.

GitOrigin-RevId: 8838c020bb677df926fce87c0e2343600089345d
This commit is contained in:
levlam 2018-04-16 18:02:42 +03:00
parent 166bd07fd9
commit a1d6be72ff
5 changed files with 14 additions and 10 deletions

View File

@ -59,7 +59,7 @@ void DeviceTokenManager::TokenInfo::parse(ParserT &parser) {
PARSE_FLAG(is_unregister);
PARSE_FLAG(is_register);
PARSE_FLAG(is_app_sandbox);
// END_PARSE_FLAGS();
END_PARSE_FLAGS_GENERIC();
CHECK(is_sync + is_unregister + is_register == 1);
if (is_sync) {
state = State::Sync;

View File

@ -188,7 +188,8 @@ class SecretChatActor : public NetQueryCallback {
storer.store_int(ttl);
storer.store_int(my_layer);
//for future usage
storer.store_int(0);
BEGIN_STORE_FLAGS();
END_STORE_FLAGS();
}
template <class ParserT>
@ -200,8 +201,8 @@ class SecretChatActor : public NetQueryCallback {
his_layer &= ~HAS_FLAGS;
my_layer = parser.fetch_int();
// for future usage
int32 flags = parser.fetch_int();
CHECK(flags == 0);
BEGIN_PARSE_FLAGS();
END_PARSE_FLAGS_GENERIC();
}
}

View File

@ -1222,7 +1222,7 @@ class FileData {
PARSE_FLAG(has_owner_dialog_id);
PARSE_FLAG(has_expected_size);
PARSE_FLAG(encryption_key_is_secure);
// END_PARSE_FLAGS();
END_PARSE_FLAGS_GENERIC();
if (has_owner_dialog_id) {
parse(owner_dialog_id_, parser);

View File

@ -72,8 +72,8 @@ struct AesCtrEncryptionEvent {
template <class StorerT>
void store(StorerT &storer) const {
using td::store;
int32 flags = 0;
store(flags, storer);
BEGIN_STORE_FLAGS();
END_STORE_FLAGS();
store(key_salt_, storer);
store(iv_, storer);
store(key_hash_, storer);
@ -81,9 +81,8 @@ struct AesCtrEncryptionEvent {
template <class ParserT>
void parse(ParserT &&parser) {
using td::parse;
int32 flags;
parse(flags, parser);
CHECK(flags == 0);
BEGIN_PARSE_FLAGS();
END_PARSE_FLAGS_GENERIC();
parse(key_salt_, parser);
parse(iv_, parser);
parse(key_hash_, parser);

View File

@ -44,6 +44,10 @@
CHECK((flags_parse & ~((1 << bit_offset_parse) - 1)) == 0) \
<< flags_parse << " " << bit_offset_parse << " " << parser.version();
#define END_PARSE_FLAGS_GENERIC() \
CHECK(bit_offset_parse < 31); \
CHECK((flags_parse & ~((1 << bit_offset_parse) - 1)) == 0) << flags_parse << " " << bit_offset_parse;
namespace td {
template <class StorerT>
void store(bool x, StorerT &storer) {