diff --git a/r5dev/protoc/cl_rcon.pb.cc b/r5dev/protoc/cl_rcon.pb.cc index 1cd5aceb..db33d890 100644 --- a/r5dev/protoc/cl_rcon.pb.cc +++ b/r5dev/protoc/cl_rcon.pb.cc @@ -13,23 +13,28 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + namespace cl_rcon { -constexpr request::request( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : requestbuf_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , requestval_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , requestid_(0) - , requesttype_(0) -{} +PROTOBUF_CONSTEXPR request::request( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.requestbuf_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.requestval_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.requestid_)*/0 + , /*decltype(_impl_.requesttype_)*/0} {} struct requestDefaultTypeInternal { - constexpr requestDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR requestDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~requestDefaultTypeInternal() {} union { request _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT requestDefaultTypeInternal _request_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 requestDefaultTypeInternal _request_default_instance_; } // namespace cl_rcon namespace cl_rcon { bool request_t_IsValid(int value) { @@ -104,7 +109,7 @@ bool request_t_Parse( class request::_Internal { public: - using HasBits = decltype(std::declval<request>()._has_bits_); + using HasBits = decltype(std::declval<request>()._impl_._has_bits_); static void set_has_requestid(HasBits* has_bits) { (*has_bits)[0] |= 4u; } @@ -122,74 +127,82 @@ class request::_Internal { request::request(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:cl_rcon.request) } request::request(const request& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(), - _has_bits_(from._has_bits_) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + request* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.requestbuf_){} + , decltype(_impl_.requestval_){} + , decltype(_impl_.requestid_){} + , decltype(_impl_.requesttype_){}}; + _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); - requestbuf_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.requestbuf_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - requestbuf_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.requestbuf_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_requestbuf()) { - requestbuf_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_requestbuf(), - GetArenaForAllocation()); + _this->_impl_.requestbuf_.Set(from._internal_requestbuf(), + _this->GetArenaForAllocation()); } - requestval_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.requestval_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - requestval_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.requestval_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_requestval()) { - requestval_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_requestval(), - GetArenaForAllocation()); + _this->_impl_.requestval_.Set(from._internal_requestval(), + _this->GetArenaForAllocation()); } - ::memcpy(&requestid_, &from.requestid_, - static_cast<size_t>(reinterpret_cast<char*>(&requesttype_) - - reinterpret_cast<char*>(&requestid_)) + sizeof(requesttype_)); + ::memcpy(&_impl_.requestid_, &from._impl_.requestid_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.requesttype_) - + reinterpret_cast<char*>(&_impl_.requestid_)) + sizeof(_impl_.requesttype_)); // @@protoc_insertion_point(copy_constructor:cl_rcon.request) } -inline void request::SharedCtor() { -requestbuf_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - requestbuf_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -requestval_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - requestval_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&requestid_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&requesttype_) - - reinterpret_cast<char*>(&requestid_)) + sizeof(requesttype_)); +inline void request::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.requestbuf_){} + , decltype(_impl_.requestval_){} + , decltype(_impl_.requestid_){0} + , decltype(_impl_.requesttype_){0} + }; + _impl_.requestbuf_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.requestbuf_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.requestval_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.requestval_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } request::~request() { // @@protoc_insertion_point(destructor:cl_rcon.request) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<std::string>(); } inline void request::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - requestbuf_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - requestval_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.requestbuf_.Destroy(); + _impl_.requestval_.Destroy(); } -void request::ArenaDtor(void* object) { - request* _this = reinterpret_cast< request* >(object); - (void)_this; -} -void request::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void request::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void request::Clear() { @@ -198,36 +211,36 @@ void request::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - requestbuf_.ClearNonDefaultToEmpty(); + _impl_.requestbuf_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - requestval_.ClearNonDefaultToEmpty(); + _impl_.requestval_.ClearNonDefaultToEmpty(); } } if (cached_has_bits & 0x0000000cu) { - ::memset(&requestid_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&requesttype_) - - reinterpret_cast<char*>(&requestid_)) + sizeof(requesttype_)); + ::memset(&_impl_.requestid_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.requesttype_) - + reinterpret_cast<char*>(&_impl_.requestid_)) + sizeof(_impl_.requesttype_)); } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<std::string>(); } -const char* request::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* request::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional int32 requestID = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { _Internal::set_has_requestid(&has_bits); - requestid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.requestid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -245,9 +258,9 @@ const char* request::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) { auto str = _internal_mutable_requestbuf(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, nullptr)); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, nullptr)); } else goto handle_unusual; continue; @@ -255,9 +268,9 @@ const char* request::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) { auto str = _internal_mutable_requestval(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, nullptr)); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, nullptr)); } else goto handle_unusual; continue; @@ -277,7 +290,7 @@ const char* request::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -294,13 +307,13 @@ uint8_t* request::_InternalSerialize( // optional int32 requestID = 1; if (_internal_has_requestid()) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_requestid(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_requestid(), target); } // optional .cl_rcon.request_t requestType = 2; if (_internal_has_requesttype()) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 2, this->_internal_requesttype(), target); } @@ -340,7 +353,7 @@ size_t request::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { // optional string requestBuf = 3; if (cached_has_bits & 0x00000001u) { @@ -358,53 +371,54 @@ size_t request::ByteSizeLong() const { // optional int32 requestID = 1; if (cached_has_bits & 0x00000004u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_requestid()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_requestid()); } // optional .cl_rcon.request_t requestType = 2; if (cached_has_bits & 0x00000008u) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_requesttype()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_requesttype()); } } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + int cached_size = ::_pbi::ToCachedSize(total_size); SetCachedSize(cached_size); return total_size; } void request::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const request*>( + MergeFrom(*::_pbi::DownCast<const request*>( &from)); } void request::MergeFrom(const request& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:cl_rcon.request) - GOOGLE_DCHECK_NE(&from, this); + request* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:cl_rcon.request) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _internal_set_requestbuf(from._internal_requestbuf()); + _this->_internal_set_requestbuf(from._internal_requestbuf()); } if (cached_has_bits & 0x00000002u) { - _internal_set_requestval(from._internal_requestval()); + _this->_internal_set_requestval(from._internal_requestval()); } if (cached_has_bits & 0x00000004u) { - requestid_ = from.requestid_; + _this->_impl_.requestid_ = from._impl_.requestid_; } if (cached_has_bits & 0x00000008u) { - requesttype_ = from.requesttype_; + _this->_impl_.requesttype_ = from._impl_.requesttype_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); } void request::CopyFrom(const request& from) { @@ -423,23 +437,21 @@ void request::InternalSwap(request* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &requestbuf_, lhs_arena, - &other->requestbuf_, rhs_arena + &_impl_.requestbuf_, lhs_arena, + &other->_impl_.requestbuf_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &requestval_, lhs_arena, - &other->requestval_, rhs_arena + &_impl_.requestval_, lhs_arena, + &other->_impl_.requestval_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(request, requesttype_) - + sizeof(request::requesttype_) - - PROTOBUF_FIELD_OFFSET(request, requestid_)>( - reinterpret_cast<char*>(&requestid_), - reinterpret_cast<char*>(&other->requestid_)); + PROTOBUF_FIELD_OFFSET(request, _impl_.requesttype_) + + sizeof(request::_impl_.requesttype_) + - PROTOBUF_FIELD_OFFSET(request, _impl_.requestid_)>( + reinterpret_cast<char*>(&_impl_.requestid_), + reinterpret_cast<char*>(&other->_impl_.requestid_)); } std::string request::GetTypeName() const { @@ -450,7 +462,8 @@ std::string request::GetTypeName() const { // @@protoc_insertion_point(namespace_scope) } // namespace cl_rcon PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::cl_rcon::request* Arena::CreateMaybeMessage< ::cl_rcon::request >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::cl_rcon::request* +Arena::CreateMaybeMessage< ::cl_rcon::request >(Arena* arena) { return Arena::CreateMessageInternal< ::cl_rcon::request >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/protoc/cl_rcon.pb.h b/r5dev/protoc/cl_rcon.pb.h index 3a477c4d..19c5f1f4 100644 --- a/r5dev/protoc/cl_rcon.pb.h +++ b/r5dev/protoc/cl_rcon.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/message_lite.h> @@ -41,14 +40,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct TableStruct_cl_5frcon_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; namespace cl_rcon { @@ -93,7 +84,7 @@ class request final : public: inline request() : request(nullptr) {} ~request() override; - explicit constexpr request(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR request(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); request(const request& from); request(request&& from) noexcept @@ -166,10 +157,10 @@ class request final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(request* other); @@ -182,9 +173,6 @@ class request final : protected: explicit request(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: std::string GetTypeName() const final; @@ -268,12 +256,15 @@ class request final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr requestbuf_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr requestval_; - int32_t requestid_; - int requesttype_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr requestbuf_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr requestval_; + int32_t requestid_; + int requesttype_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_cl_5frcon_2eproto; }; // =================================================================== @@ -289,26 +280,26 @@ class request final : // optional int32 requestID = 1; inline bool request::_internal_has_requestid() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool request::has_requestid() const { return _internal_has_requestid(); } inline void request::clear_requestid() { - requestid_ = 0; - _has_bits_[0] &= ~0x00000004u; + _impl_.requestid_ = 0; + _impl_._has_bits_[0] &= ~0x00000004u; } inline int32_t request::_internal_requestid() const { - return requestid_; + return _impl_.requestid_; } inline int32_t request::requestid() const { // @@protoc_insertion_point(field_get:cl_rcon.request.requestID) return _internal_requestid(); } inline void request::_internal_set_requestid(int32_t value) { - _has_bits_[0] |= 0x00000004u; - requestid_ = value; + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.requestid_ = value; } inline void request::set_requestid(int32_t value) { _internal_set_requestid(value); @@ -317,26 +308,26 @@ inline void request::set_requestid(int32_t value) { // optional .cl_rcon.request_t requestType = 2; inline bool request::_internal_has_requesttype() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } inline bool request::has_requesttype() const { return _internal_has_requesttype(); } inline void request::clear_requesttype() { - requesttype_ = 0; - _has_bits_[0] &= ~0x00000008u; + _impl_.requesttype_ = 0; + _impl_._has_bits_[0] &= ~0x00000008u; } inline ::cl_rcon::request_t request::_internal_requesttype() const { - return static_cast< ::cl_rcon::request_t >(requesttype_); + return static_cast< ::cl_rcon::request_t >(_impl_.requesttype_); } inline ::cl_rcon::request_t request::requesttype() const { // @@protoc_insertion_point(field_get:cl_rcon.request.requestType) return _internal_requesttype(); } inline void request::_internal_set_requesttype(::cl_rcon::request_t value) { - _has_bits_[0] |= 0x00000008u; - requesttype_ = value; + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.requesttype_ = value; } inline void request::set_requesttype(::cl_rcon::request_t value) { _internal_set_requesttype(value); @@ -345,15 +336,15 @@ inline void request::set_requesttype(::cl_rcon::request_t value) { // optional string requestBuf = 3; inline bool request::_internal_has_requestbuf() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool request::has_requestbuf() const { return _internal_has_requestbuf(); } inline void request::clear_requestbuf() { - requestbuf_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.requestbuf_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& request::requestbuf() const { // @@protoc_insertion_point(field_get:cl_rcon.request.requestBuf) @@ -362,8 +353,8 @@ inline const std::string& request::requestbuf() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void request::set_requestbuf(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - requestbuf_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.requestbuf_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:cl_rcon.request.requestBuf) } inline std::string* request::mutable_requestbuf() { @@ -372,41 +363,40 @@ inline std::string* request::mutable_requestbuf() { return _s; } inline const std::string& request::_internal_requestbuf() const { - return requestbuf_.Get(); + return _impl_.requestbuf_.Get(); } inline void request::_internal_set_requestbuf(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - requestbuf_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.requestbuf_.Set(value, GetArenaForAllocation()); } inline std::string* request::_internal_mutable_requestbuf() { - _has_bits_[0] |= 0x00000001u; - return requestbuf_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.requestbuf_.Mutable(GetArenaForAllocation()); } inline std::string* request::release_requestbuf() { // @@protoc_insertion_point(field_release:cl_rcon.request.requestBuf) if (!_internal_has_requestbuf()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = requestbuf_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.requestbuf_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (requestbuf_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - requestbuf_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.requestbuf_.IsDefault()) { + _impl_.requestbuf_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void request::set_allocated_requestbuf(std::string* requestbuf) { if (requestbuf != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - requestbuf_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), requestbuf, - GetArenaForAllocation()); + _impl_.requestbuf_.SetAllocated(requestbuf, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (requestbuf_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - requestbuf_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.requestbuf_.IsDefault()) { + _impl_.requestbuf_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:cl_rcon.request.requestBuf) @@ -414,15 +404,15 @@ inline void request::set_allocated_requestbuf(std::string* requestbuf) { // optional string requestVal = 4; inline bool request::_internal_has_requestval() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool request::has_requestval() const { return _internal_has_requestval(); } inline void request::clear_requestval() { - requestval_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; + _impl_.requestval_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const std::string& request::requestval() const { // @@protoc_insertion_point(field_get:cl_rcon.request.requestVal) @@ -431,8 +421,8 @@ inline const std::string& request::requestval() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void request::set_requestval(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000002u; - requestval_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.requestval_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:cl_rcon.request.requestVal) } inline std::string* request::mutable_requestval() { @@ -441,41 +431,40 @@ inline std::string* request::mutable_requestval() { return _s; } inline const std::string& request::_internal_requestval() const { - return requestval_.Get(); + return _impl_.requestval_.Get(); } inline void request::_internal_set_requestval(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - requestval_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.requestval_.Set(value, GetArenaForAllocation()); } inline std::string* request::_internal_mutable_requestval() { - _has_bits_[0] |= 0x00000002u; - return requestval_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.requestval_.Mutable(GetArenaForAllocation()); } inline std::string* request::release_requestval() { // @@protoc_insertion_point(field_release:cl_rcon.request.requestVal) if (!_internal_has_requestval()) { return nullptr; } - _has_bits_[0] &= ~0x00000002u; - auto* p = requestval_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.requestval_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (requestval_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - requestval_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.requestval_.IsDefault()) { + _impl_.requestval_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void request::set_allocated_requestval(std::string* requestval) { if (requestval != nullptr) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - requestval_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), requestval, - GetArenaForAllocation()); + _impl_.requestval_.SetAllocated(requestval, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (requestval_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - requestval_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.requestval_.IsDefault()) { + _impl_.requestval_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:cl_rcon.request.requestVal) diff --git a/r5dev/protoc/sig_map.pb.cc b/r5dev/protoc/sig_map.pb.cc index c93d85b3..5aa20032 100644 --- a/r5dev/protoc/sig_map.pb.cc +++ b/r5dev/protoc/sig_map.pb.cc @@ -13,29 +13,34 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG -constexpr SigMap_Pb_SMapEntry_DoNotUse::SigMap_Pb_SMapEntry_DoNotUse( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized){} + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + +PROTOBUF_CONSTEXPR SigMap_Pb_SMapEntry_DoNotUse::SigMap_Pb_SMapEntry_DoNotUse( + ::_pbi::ConstantInitialized) {} struct SigMap_Pb_SMapEntry_DoNotUseDefaultTypeInternal { - constexpr SigMap_Pb_SMapEntry_DoNotUseDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR SigMap_Pb_SMapEntry_DoNotUseDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~SigMap_Pb_SMapEntry_DoNotUseDefaultTypeInternal() {} union { SigMap_Pb_SMapEntry_DoNotUse _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SigMap_Pb_SMapEntry_DoNotUseDefaultTypeInternal _SigMap_Pb_SMapEntry_DoNotUse_default_instance_; -constexpr SigMap_Pb::SigMap_Pb( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : smap_(){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SigMap_Pb_SMapEntry_DoNotUseDefaultTypeInternal _SigMap_Pb_SMapEntry_DoNotUse_default_instance_; +PROTOBUF_CONSTEXPR SigMap_Pb::SigMap_Pb( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.smap_)*/{} + , /*decltype(_impl_._cached_size_)*/{}} {} struct SigMap_PbDefaultTypeInternal { - constexpr SigMap_PbDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR SigMap_PbDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~SigMap_PbDefaultTypeInternal() {} union { SigMap_Pb _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SigMap_PbDefaultTypeInternal _SigMap_Pb_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SigMap_PbDefaultTypeInternal _SigMap_Pb_default_instance_; // =================================================================== @@ -54,43 +59,49 @@ class SigMap_Pb::_Internal { SigMap_Pb::SigMap_Pb(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned), - smap_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:SigMap_Pb) } SigMap_Pb::SigMap_Pb(const SigMap_Pb& from) : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + SigMap_Pb* const _this = this; (void)_this; + new (&_impl_) Impl_{ + /*decltype(_impl_.smap_)*/{} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); - smap_.MergeFrom(from.smap_); + _this->_impl_.smap_.MergeFrom(from._impl_.smap_); // @@protoc_insertion_point(copy_constructor:SigMap_Pb) } -inline void SigMap_Pb::SharedCtor() { +inline void SigMap_Pb::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_.smap_)*/{::_pbi::ArenaInitialized(), arena} + , /*decltype(_impl_._cached_size_)*/{} + }; } SigMap_Pb::~SigMap_Pb() { // @@protoc_insertion_point(destructor:SigMap_Pb) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<std::string>(); } inline void SigMap_Pb::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.smap_.Destruct(); + _impl_.smap_.~MapFieldLite(); } -void SigMap_Pb::ArenaDtor(void* object) { - SigMap_Pb* _this = reinterpret_cast< SigMap_Pb* >(object); - (void)_this; -} -void SigMap_Pb::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void SigMap_Pb::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void SigMap_Pb::Clear() { @@ -99,15 +110,15 @@ void SigMap_Pb::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - smap_.Clear(); + _impl_.smap_.Clear(); _internal_metadata_.Clear<std::string>(); } -const char* SigMap_Pb::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* SigMap_Pb::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // map<string, uint64> sMap = 1; case 1: @@ -115,7 +126,7 @@ const char* SigMap_Pb::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:: ptr -= 1; do { ptr += 1; - ptr = ctx->ParseMessage(&smap_, ptr); + ptr = ctx->ParseMessage(&_impl_.smap_, ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); @@ -153,42 +164,26 @@ uint8_t* SigMap_Pb::_InternalSerialize( // map<string, uint64> sMap = 1; if (!this->_internal_smap().empty()) { - typedef ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >::const_pointer - ConstPtr; - typedef ConstPtr SortItem; - typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByDerefFirst<SortItem> Less; - struct Utf8Check { - static void Check(ConstPtr p) { - (void)p; - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - p->first.data(), static_cast<int>(p->first.length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "SigMap_Pb.SMapEntry.key"); - } + using MapType = ::_pb::Map<std::string, uint64_t>; + using WireHelper = SigMap_Pb_SMapEntry_DoNotUse::Funcs; + const auto& map_field = this->_internal_smap(); + auto check_utf8 = [](const MapType::value_type& entry) { + (void)entry; + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + entry.first.data(), static_cast<int>(entry.first.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "SigMap_Pb.SMapEntry.key"); }; - if (stream->IsSerializationDeterministic() && - this->_internal_smap().size() > 1) { - ::std::unique_ptr<SortItem[]> items( - new SortItem[this->_internal_smap().size()]); - typedef ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >::size_type size_type; - size_type n = 0; - for (::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >::const_iterator - it = this->_internal_smap().begin(); - it != this->_internal_smap().end(); ++it, ++n) { - items[static_cast<ptrdiff_t>(n)] = SortItem(&*it); - } - ::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less()); - for (size_type i = 0; i < n; i++) { - target = SigMap_Pb_SMapEntry_DoNotUse::Funcs::InternalSerialize(1, items[static_cast<ptrdiff_t>(i)]->first, items[static_cast<ptrdiff_t>(i)]->second, target, stream); - Utf8Check::Check(&(*items[static_cast<ptrdiff_t>(i)])); + if (stream->IsSerializationDeterministic() && map_field.size() > 1) { + for (const auto& entry : ::_pbi::MapSorterPtr<MapType>(map_field)) { + target = WireHelper::InternalSerialize(1, entry.first, entry.second, target, stream); + check_utf8(entry); } } else { - for (::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >::const_iterator - it = this->_internal_smap().begin(); - it != this->_internal_smap().end(); ++it) { - target = SigMap_Pb_SMapEntry_DoNotUse::Funcs::InternalSerialize(1, it->first, it->second, target, stream); - Utf8Check::Check(&(*it)); + for (const auto& entry : map_field) { + target = WireHelper::InternalSerialize(1, entry.first, entry.second, target, stream); + check_utf8(entry); } } } @@ -221,25 +216,26 @@ size_t SigMap_Pb::ByteSizeLong() const { if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + int cached_size = ::_pbi::ToCachedSize(total_size); SetCachedSize(cached_size); return total_size; } void SigMap_Pb::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const SigMap_Pb*>( + MergeFrom(*::_pbi::DownCast<const SigMap_Pb*>( &from)); } void SigMap_Pb::MergeFrom(const SigMap_Pb& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:SigMap_Pb) - GOOGLE_DCHECK_NE(&from, this); + SigMap_Pb* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:SigMap_Pb) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - smap_.MergeFrom(from.smap_); - _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); + _this->_impl_.smap_.MergeFrom(from._impl_.smap_); + _this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); } void SigMap_Pb::CopyFrom(const SigMap_Pb& from) { @@ -256,7 +252,7 @@ bool SigMap_Pb::IsInitialized() const { void SigMap_Pb::InternalSwap(SigMap_Pb* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - smap_.InternalSwap(&other->smap_); + _impl_.smap_.InternalSwap(&other->_impl_.smap_); } std::string SigMap_Pb::GetTypeName() const { @@ -266,10 +262,12 @@ std::string SigMap_Pb::GetTypeName() const { // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::SigMap_Pb_SMapEntry_DoNotUse* Arena::CreateMaybeMessage< ::SigMap_Pb_SMapEntry_DoNotUse >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::SigMap_Pb_SMapEntry_DoNotUse* +Arena::CreateMaybeMessage< ::SigMap_Pb_SMapEntry_DoNotUse >(Arena* arena) { return Arena::CreateMessageInternal< ::SigMap_Pb_SMapEntry_DoNotUse >(arena); } -template<> PROTOBUF_NOINLINE ::SigMap_Pb* Arena::CreateMaybeMessage< ::SigMap_Pb >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::SigMap_Pb* +Arena::CreateMaybeMessage< ::SigMap_Pb >(Arena* arena) { return Arena::CreateMessageInternal< ::SigMap_Pb >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/protoc/sig_map.pb.h b/r5dev/protoc/sig_map.pb.h index f5c73082..8c9775d3 100644 --- a/r5dev/protoc/sig_map.pb.h +++ b/r5dev/protoc/sig_map.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/message_lite.h> @@ -43,14 +42,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct TableStruct_sig_5fmap_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[2] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; class SigMap_Pb; @@ -76,7 +67,7 @@ public: ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_UINT64> SuperType; SigMap_Pb_SMapEntry_DoNotUse(); - explicit constexpr SigMap_Pb_SMapEntry_DoNotUse( + explicit PROTOBUF_CONSTEXPR SigMap_Pb_SMapEntry_DoNotUse( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); explicit SigMap_Pb_SMapEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena); void MergeFrom(const SigMap_Pb_SMapEntry_DoNotUse& other); @@ -85,6 +76,7 @@ public: return ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(s->data(), static_cast<int>(s->size()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "SigMap_Pb.SMapEntry.key"); } static bool ValidateValue(void*) { return true; } + friend struct ::TableStruct_sig_5fmap_2eproto; }; // ------------------------------------------------------------------- @@ -94,7 +86,7 @@ class SigMap_Pb final : public: inline SigMap_Pb() : SigMap_Pb(nullptr) {} ~SigMap_Pb() override; - explicit constexpr SigMap_Pb(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR SigMap_Pb(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); SigMap_Pb(const SigMap_Pb& from); SigMap_Pb(SigMap_Pb&& from) noexcept @@ -167,10 +159,10 @@ class SigMap_Pb final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(SigMap_Pb* other); @@ -183,9 +175,6 @@ class SigMap_Pb final : protected: explicit SigMap_Pb(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: std::string GetTypeName() const final; @@ -222,12 +211,15 @@ class SigMap_Pb final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::MapFieldLite< - SigMap_Pb_SMapEntry_DoNotUse, - std::string, uint64_t, - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_UINT64> smap_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::MapFieldLite< + SigMap_Pb_SMapEntry_DoNotUse, + std::string, uint64_t, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_UINT64> smap_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_sig_5fmap_2eproto; }; // =================================================================== @@ -245,17 +237,17 @@ class SigMap_Pb final : // map<string, uint64> sMap = 1; inline int SigMap_Pb::_internal_smap_size() const { - return smap_.size(); + return _impl_.smap_.size(); } inline int SigMap_Pb::smap_size() const { return _internal_smap_size(); } inline void SigMap_Pb::clear_smap() { - smap_.Clear(); + _impl_.smap_.Clear(); } inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >& SigMap_Pb::_internal_smap() const { - return smap_.GetMap(); + return _impl_.smap_.GetMap(); } inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >& SigMap_Pb::smap() const { @@ -264,7 +256,7 @@ SigMap_Pb::smap() const { } inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >* SigMap_Pb::_internal_mutable_smap() { - return smap_.MutableMap(); + return _impl_.smap_.MutableMap(); } inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, uint64_t >* SigMap_Pb::mutable_smap() { diff --git a/r5dev/protoc/sv_rcon.pb.cc b/r5dev/protoc/sv_rcon.pb.cc index e40ef59b..147717db 100644 --- a/r5dev/protoc/sv_rcon.pb.cc +++ b/r5dev/protoc/sv_rcon.pb.cc @@ -13,23 +13,28 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + namespace sv_rcon { -constexpr response::response( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : responsebuf_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , responseval_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , responseid_(0) - , responsetype_(0) -{} +PROTOBUF_CONSTEXPR response::response( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.responsebuf_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.responseval_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.responseid_)*/0 + , /*decltype(_impl_.responsetype_)*/0} {} struct responseDefaultTypeInternal { - constexpr responseDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR responseDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~responseDefaultTypeInternal() {} union { response _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT responseDefaultTypeInternal _response_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 responseDefaultTypeInternal _response_default_instance_; } // namespace sv_rcon namespace sv_rcon { bool response_t_IsValid(int value) { @@ -104,7 +109,7 @@ bool response_t_Parse( class response::_Internal { public: - using HasBits = decltype(std::declval<response>()._has_bits_); + using HasBits = decltype(std::declval<response>()._impl_._has_bits_); static void set_has_responseid(HasBits* has_bits) { (*has_bits)[0] |= 4u; } @@ -122,74 +127,82 @@ class response::_Internal { response::response(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:sv_rcon.response) } response::response(const response& from) - : ::PROTOBUF_NAMESPACE_ID::MessageLite(), - _has_bits_(from._has_bits_) { + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + response* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.responsebuf_){} + , decltype(_impl_.responseval_){} + , decltype(_impl_.responseid_){} + , decltype(_impl_.responsetype_){}}; + _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); - responsebuf_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.responsebuf_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - responsebuf_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.responsebuf_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_responsebuf()) { - responsebuf_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_responsebuf(), - GetArenaForAllocation()); + _this->_impl_.responsebuf_.Set(from._internal_responsebuf(), + _this->GetArenaForAllocation()); } - responseval_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.responseval_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - responseval_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.responseval_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_responseval()) { - responseval_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_responseval(), - GetArenaForAllocation()); + _this->_impl_.responseval_.Set(from._internal_responseval(), + _this->GetArenaForAllocation()); } - ::memcpy(&responseid_, &from.responseid_, - static_cast<size_t>(reinterpret_cast<char*>(&responsetype_) - - reinterpret_cast<char*>(&responseid_)) + sizeof(responsetype_)); + ::memcpy(&_impl_.responseid_, &from._impl_.responseid_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.responsetype_) - + reinterpret_cast<char*>(&_impl_.responseid_)) + sizeof(_impl_.responsetype_)); // @@protoc_insertion_point(copy_constructor:sv_rcon.response) } -inline void response::SharedCtor() { -responsebuf_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - responsebuf_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -responseval_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - responseval_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&responseid_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&responsetype_) - - reinterpret_cast<char*>(&responseid_)) + sizeof(responsetype_)); +inline void response::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.responsebuf_){} + , decltype(_impl_.responseval_){} + , decltype(_impl_.responseid_){0} + , decltype(_impl_.responsetype_){0} + }; + _impl_.responsebuf_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.responsebuf_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.responseval_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.responseval_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } response::~response() { // @@protoc_insertion_point(destructor:sv_rcon.response) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<std::string>(); } inline void response::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - responsebuf_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - responseval_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.responsebuf_.Destroy(); + _impl_.responseval_.Destroy(); } -void response::ArenaDtor(void* object) { - response* _this = reinterpret_cast< response* >(object); - (void)_this; -} -void response::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void response::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void response::Clear() { @@ -198,36 +211,36 @@ void response::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - responsebuf_.ClearNonDefaultToEmpty(); + _impl_.responsebuf_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - responseval_.ClearNonDefaultToEmpty(); + _impl_.responseval_.ClearNonDefaultToEmpty(); } } if (cached_has_bits & 0x0000000cu) { - ::memset(&responseid_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&responsetype_) - - reinterpret_cast<char*>(&responseid_)) + sizeof(responsetype_)); + ::memset(&_impl_.responseid_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.responsetype_) - + reinterpret_cast<char*>(&_impl_.responseid_)) + sizeof(_impl_.responsetype_)); } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<std::string>(); } -const char* response::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* response::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional int32 responseID = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { _Internal::set_has_responseid(&has_bits); - responseid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.responseid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -245,9 +258,9 @@ const char* response::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::i case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) { auto str = _internal_mutable_responsebuf(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, nullptr)); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, nullptr)); } else goto handle_unusual; continue; @@ -255,9 +268,9 @@ const char* response::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::i case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) { auto str = _internal_mutable_responseval(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, nullptr)); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, nullptr)); } else goto handle_unusual; continue; @@ -277,7 +290,7 @@ const char* response::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::i CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -294,13 +307,13 @@ uint8_t* response::_InternalSerialize( // optional int32 responseID = 1; if (_internal_has_responseid()) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_responseid(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_responseid(), target); } // optional .sv_rcon.response_t responseType = 2; if (_internal_has_responsetype()) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 2, this->_internal_responsetype(), target); } @@ -340,7 +353,7 @@ size_t response::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { // optional string responseBuf = 3; if (cached_has_bits & 0x00000001u) { @@ -358,53 +371,54 @@ size_t response::ByteSizeLong() const { // optional int32 responseID = 1; if (cached_has_bits & 0x00000004u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_responseid()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_responseid()); } // optional .sv_rcon.response_t responseType = 2; if (cached_has_bits & 0x00000008u) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_responsetype()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_responsetype()); } } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + int cached_size = ::_pbi::ToCachedSize(total_size); SetCachedSize(cached_size); return total_size; } void response::CheckTypeAndMergeFrom( const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { - MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const response*>( + MergeFrom(*::_pbi::DownCast<const response*>( &from)); } void response::MergeFrom(const response& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:sv_rcon.response) - GOOGLE_DCHECK_NE(&from, this); + response* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:sv_rcon.response) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _internal_set_responsebuf(from._internal_responsebuf()); + _this->_internal_set_responsebuf(from._internal_responsebuf()); } if (cached_has_bits & 0x00000002u) { - _internal_set_responseval(from._internal_responseval()); + _this->_internal_set_responseval(from._internal_responseval()); } if (cached_has_bits & 0x00000004u) { - responseid_ = from.responseid_; + _this->_impl_.responseid_ = from._impl_.responseid_; } if (cached_has_bits & 0x00000008u) { - responsetype_ = from.responsetype_; + _this->_impl_.responsetype_ = from._impl_.responsetype_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); } void response::CopyFrom(const response& from) { @@ -423,23 +437,21 @@ void response::InternalSwap(response* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &responsebuf_, lhs_arena, - &other->responsebuf_, rhs_arena + &_impl_.responsebuf_, lhs_arena, + &other->_impl_.responsebuf_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &responseval_, lhs_arena, - &other->responseval_, rhs_arena + &_impl_.responseval_, lhs_arena, + &other->_impl_.responseval_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(response, responsetype_) - + sizeof(response::responsetype_) - - PROTOBUF_FIELD_OFFSET(response, responseid_)>( - reinterpret_cast<char*>(&responseid_), - reinterpret_cast<char*>(&other->responseid_)); + PROTOBUF_FIELD_OFFSET(response, _impl_.responsetype_) + + sizeof(response::_impl_.responsetype_) + - PROTOBUF_FIELD_OFFSET(response, _impl_.responseid_)>( + reinterpret_cast<char*>(&_impl_.responseid_), + reinterpret_cast<char*>(&other->_impl_.responseid_)); } std::string response::GetTypeName() const { @@ -450,7 +462,8 @@ std::string response::GetTypeName() const { // @@protoc_insertion_point(namespace_scope) } // namespace sv_rcon PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::sv_rcon::response* Arena::CreateMaybeMessage< ::sv_rcon::response >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::sv_rcon::response* +Arena::CreateMaybeMessage< ::sv_rcon::response >(Arena* arena) { return Arena::CreateMessageInternal< ::sv_rcon::response >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/protoc/sv_rcon.pb.h b/r5dev/protoc/sv_rcon.pb.h index a912ea4c..b8bcd8c6 100644 --- a/r5dev/protoc/sv_rcon.pb.h +++ b/r5dev/protoc/sv_rcon.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/message_lite.h> @@ -41,14 +40,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct TableStruct_sv_5frcon_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; namespace sv_rcon { @@ -93,7 +84,7 @@ class response final : public: inline response() : response(nullptr) {} ~response() override; - explicit constexpr response(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR response(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); response(const response& from); response(response&& from) noexcept @@ -166,10 +157,10 @@ class response final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const; void InternalSwap(response* other); @@ -182,9 +173,6 @@ class response final : protected: explicit response(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: std::string GetTypeName() const final; @@ -268,12 +256,15 @@ class response final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr responsebuf_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr responseval_; - int32_t responseid_; - int responsetype_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr responsebuf_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr responseval_; + int32_t responseid_; + int responsetype_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_sv_5frcon_2eproto; }; // =================================================================== @@ -289,26 +280,26 @@ class response final : // optional int32 responseID = 1; inline bool response::_internal_has_responseid() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool response::has_responseid() const { return _internal_has_responseid(); } inline void response::clear_responseid() { - responseid_ = 0; - _has_bits_[0] &= ~0x00000004u; + _impl_.responseid_ = 0; + _impl_._has_bits_[0] &= ~0x00000004u; } inline int32_t response::_internal_responseid() const { - return responseid_; + return _impl_.responseid_; } inline int32_t response::responseid() const { // @@protoc_insertion_point(field_get:sv_rcon.response.responseID) return _internal_responseid(); } inline void response::_internal_set_responseid(int32_t value) { - _has_bits_[0] |= 0x00000004u; - responseid_ = value; + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.responseid_ = value; } inline void response::set_responseid(int32_t value) { _internal_set_responseid(value); @@ -317,26 +308,26 @@ inline void response::set_responseid(int32_t value) { // optional .sv_rcon.response_t responseType = 2; inline bool response::_internal_has_responsetype() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } inline bool response::has_responsetype() const { return _internal_has_responsetype(); } inline void response::clear_responsetype() { - responsetype_ = 0; - _has_bits_[0] &= ~0x00000008u; + _impl_.responsetype_ = 0; + _impl_._has_bits_[0] &= ~0x00000008u; } inline ::sv_rcon::response_t response::_internal_responsetype() const { - return static_cast< ::sv_rcon::response_t >(responsetype_); + return static_cast< ::sv_rcon::response_t >(_impl_.responsetype_); } inline ::sv_rcon::response_t response::responsetype() const { // @@protoc_insertion_point(field_get:sv_rcon.response.responseType) return _internal_responsetype(); } inline void response::_internal_set_responsetype(::sv_rcon::response_t value) { - _has_bits_[0] |= 0x00000008u; - responsetype_ = value; + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.responsetype_ = value; } inline void response::set_responsetype(::sv_rcon::response_t value) { _internal_set_responsetype(value); @@ -345,15 +336,15 @@ inline void response::set_responsetype(::sv_rcon::response_t value) { // optional string responseBuf = 3; inline bool response::_internal_has_responsebuf() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool response::has_responsebuf() const { return _internal_has_responsebuf(); } inline void response::clear_responsebuf() { - responsebuf_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.responsebuf_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& response::responsebuf() const { // @@protoc_insertion_point(field_get:sv_rcon.response.responseBuf) @@ -362,8 +353,8 @@ inline const std::string& response::responsebuf() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void response::set_responsebuf(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - responsebuf_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.responsebuf_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:sv_rcon.response.responseBuf) } inline std::string* response::mutable_responsebuf() { @@ -372,41 +363,40 @@ inline std::string* response::mutable_responsebuf() { return _s; } inline const std::string& response::_internal_responsebuf() const { - return responsebuf_.Get(); + return _impl_.responsebuf_.Get(); } inline void response::_internal_set_responsebuf(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - responsebuf_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.responsebuf_.Set(value, GetArenaForAllocation()); } inline std::string* response::_internal_mutable_responsebuf() { - _has_bits_[0] |= 0x00000001u; - return responsebuf_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.responsebuf_.Mutable(GetArenaForAllocation()); } inline std::string* response::release_responsebuf() { // @@protoc_insertion_point(field_release:sv_rcon.response.responseBuf) if (!_internal_has_responsebuf()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = responsebuf_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.responsebuf_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (responsebuf_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - responsebuf_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.responsebuf_.IsDefault()) { + _impl_.responsebuf_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void response::set_allocated_responsebuf(std::string* responsebuf) { if (responsebuf != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - responsebuf_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), responsebuf, - GetArenaForAllocation()); + _impl_.responsebuf_.SetAllocated(responsebuf, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (responsebuf_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - responsebuf_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.responsebuf_.IsDefault()) { + _impl_.responsebuf_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:sv_rcon.response.responseBuf) @@ -414,15 +404,15 @@ inline void response::set_allocated_responsebuf(std::string* responsebuf) { // optional string responseVal = 4; inline bool response::_internal_has_responseval() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool response::has_responseval() const { return _internal_has_responseval(); } inline void response::clear_responseval() { - responseval_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; + _impl_.responseval_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const std::string& response::responseval() const { // @@protoc_insertion_point(field_get:sv_rcon.response.responseVal) @@ -431,8 +421,8 @@ inline const std::string& response::responseval() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void response::set_responseval(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000002u; - responseval_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.responseval_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:sv_rcon.response.responseVal) } inline std::string* response::mutable_responseval() { @@ -441,41 +431,40 @@ inline std::string* response::mutable_responseval() { return _s; } inline const std::string& response::_internal_responseval() const { - return responseval_.Get(); + return _impl_.responseval_.Get(); } inline void response::_internal_set_responseval(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - responseval_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.responseval_.Set(value, GetArenaForAllocation()); } inline std::string* response::_internal_mutable_responseval() { - _has_bits_[0] |= 0x00000002u; - return responseval_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.responseval_.Mutable(GetArenaForAllocation()); } inline std::string* response::release_responseval() { // @@protoc_insertion_point(field_release:sv_rcon.response.responseVal) if (!_internal_has_responseval()) { return nullptr; } - _has_bits_[0] &= ~0x00000002u; - auto* p = responseval_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.responseval_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (responseval_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - responseval_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.responseval_.IsDefault()) { + _impl_.responseval_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void response::set_allocated_responseval(std::string* responseval) { if (responseval != nullptr) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - responseval_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), responseval, - GetArenaForAllocation()); + _impl_.responseval_.SetAllocated(responseval, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (responseval_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - responseval_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.responseval_.IsDefault()) { + _impl_.responseval_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:sv_rcon.response.responseVal) diff --git a/r5dev/thirdparty/protobuf/any.cc b/r5dev/thirdparty/protobuf/any.cc index 357a1864..09e95fd0 100644 --- a/r5dev/thirdparty/protobuf/any.cc +++ b/r5dev/thirdparty/protobuf/any.cc @@ -35,6 +35,7 @@ #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/message.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -48,10 +49,8 @@ bool AnyMetadata::PackFrom(Arena* arena, const Message& message) { bool AnyMetadata::PackFrom(Arena* arena, const Message& message, StringPiece type_url_prefix) { type_url_->Set( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString(), GetTypeUrl(message.GetDescriptor()->full_name(), type_url_prefix), arena); - return message.SerializeToString( - value_->Mutable(ArenaStringPtr::EmptyDefault{}, arena)); + return message.SerializeToString(value_->Mutable(arena)); } bool AnyMetadata::UnpackTo(Message* message) const { diff --git a/r5dev/thirdparty/protobuf/any.h b/r5dev/thirdparty/protobuf/any.h index 6bd83109..143dc68a 100644 --- a/r5dev/thirdparty/protobuf/any.h +++ b/r5dev/thirdparty/protobuf/any.h @@ -37,6 +37,7 @@ #include <thirdparty/protobuf/arenastring.h> #include <thirdparty/protobuf/message_lite.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -129,8 +130,8 @@ class PROTOBUF_EXPORT AnyMetadata { // *full_type_name. Returns false if the type_url does not have a "/" // in the type url separating the full type name. // -// NOTE: this function is available publicly as: -// google::protobuf::Any() // static method on the generated message type. +// NOTE: this function is available publicly as a static method on the +// generated message type: google::protobuf::Any::ParseAnyTypeUrl() bool ParseAnyTypeUrl(StringPiece type_url, std::string* full_type_name); // Get the proto type name and prefix from Any::type_url value. For example, diff --git a/r5dev/thirdparty/protobuf/any.pb.cc b/r5dev/thirdparty/protobuf/any.pb.cc index 328a6d92..d9c2e48d 100644 --- a/r5dev/thirdparty/protobuf/any.pb.cc +++ b/r5dev/thirdparty/protobuf/any.pb.cc @@ -16,25 +16,34 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + +#if defined(__llvm__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wuninitialized" +#endif // __llvm__ PROTOBUF_NAMESPACE_OPEN -constexpr Any::Any( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , _any_metadata_(&type_url_, &value_){} +PROTOBUF_CONSTEXPR Any::Any( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.type_url_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_._any_metadata_)*/{&_impl_.type_url_, &_impl_.value_}} {} struct AnyDefaultTypeInternal { - constexpr AnyDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR AnyDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~AnyDefaultTypeInternal() {} union { Any _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT AnyDefaultTypeInternal _Any_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 AnyDefaultTypeInternal _Any_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fany_2eproto[1]; -static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto = nullptr; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fany_2eproto = nullptr; +static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fany_2eproto[1]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fany_2eproto = nullptr; const uint32_t TableStruct_google_2fprotobuf_2fany_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ @@ -43,15 +52,15 @@ const uint32_t TableStruct_google_2fprotobuf_2fany_2eproto::offsets[] PROTOBUF_S ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, type_url_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _impl_.type_url_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _impl_.value_), }; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Any)}, }; -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Any_default_instance_), +static const ::_pb::Message* const file_default_instances[] = { + &::PROTOBUF_NAMESPACE_ID::_Any_default_instance_._instance, }; const char descriptor_table_protodef_google_2fprotobuf_2fany_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = @@ -62,19 +71,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2fany_2eproto[] PROTOBUF_ "anypb\242\002\003GPB\252\002\036Google.Protobuf.WellKnownT" "ypesb\006proto3" ; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fany_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto = { - false, false, 212, descriptor_table_protodef_google_2fprotobuf_2fany_2eproto, "google/protobuf/any.proto", - &descriptor_table_google_2fprotobuf_2fany_2eproto_once, nullptr, 0, 1, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fany_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fany_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto, file_level_service_descriptors_google_2fprotobuf_2fany_2eproto, +static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fany_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto = { + false, false, 212, descriptor_table_protodef_google_2fprotobuf_2fany_2eproto, + "google/protobuf/any.proto", + &descriptor_table_google_2fprotobuf_2fany_2eproto_once, nullptr, 0, 1, + schemas, file_default_instances, TableStruct_google_2fprotobuf_2fany_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fany_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto, + file_level_service_descriptors_google_2fprotobuf_2fany_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fany_2eproto_getter() { +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fany_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fany_2eproto; } // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fany_2eproto(&descriptor_table_google_2fprotobuf_2fany_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fany_2eproto(&descriptor_table_google_2fprotobuf_2fany_2eproto); PROTOBUF_NAMESPACE_OPEN // =================================================================== @@ -83,14 +94,13 @@ bool Any::GetAnyFieldDescriptors( const ::PROTOBUF_NAMESPACE_ID::Message& message, const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** type_url_field, const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** value_field) { - return ::PROTOBUF_NAMESPACE_ID::internal::GetAnyFieldDescriptors( + return ::_pbi::GetAnyFieldDescriptors( message, type_url_field, value_field); } bool Any::ParseAnyTypeUrl( ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url, std::string* full_type_name) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseAnyTypeUrl(type_url, - full_type_name); + return ::_pbi::ParseAnyTypeUrl(type_url, full_type_name); } class Any::_Internal { @@ -99,69 +109,77 @@ class Any::_Internal { Any::Any(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - _any_metadata_(&type_url_, &value_) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Any) } Any::Any(const Any& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _any_metadata_(&type_url_, &value_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + Any* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.type_url_){} + , decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_._any_metadata_)*/{&_impl_.type_url_, &_impl_.value_}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.type_url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.type_url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_type_url().empty()) { - type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_url(), - GetArenaForAllocation()); + _this->_impl_.type_url_.Set(from._internal_type_url(), + _this->GetArenaForAllocation()); } - value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.value_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.value_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_value().empty()) { - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(), - GetArenaForAllocation()); + _this->_impl_.value_.Set(from._internal_value(), + _this->GetArenaForAllocation()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.Any) } -inline void Any::SharedCtor() { -type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +inline void Any::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.type_url_){} + , decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_._any_metadata_)*/{&_impl_.type_url_, &_impl_.value_} + }; + _impl_.type_url_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.type_url_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.value_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.value_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } Any::~Any() { // @@protoc_insertion_point(destructor:google.protobuf.Any) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Any::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.type_url_.Destroy(); + _impl_.value_.Destroy(); + _impl_._any_metadata_.~AnyMetadata(); } -void Any::ArenaDtor(void* object) { - Any* _this = reinterpret_cast< Any* >(object); - (void)_this; -} -void Any::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Any::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Any::Clear() { @@ -170,24 +188,24 @@ void Any::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - type_url_.ClearToEmpty(); - value_.ClearToEmpty(); + _impl_.type_url_.ClearToEmpty(); + _impl_.value_.ClearToEmpty(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Any::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Any::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // string type_url = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_type_url(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Any.type_url")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Any.type_url")); } else goto handle_unusual; continue; @@ -195,7 +213,7 @@ const char* Any::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_value(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; @@ -246,7 +264,7 @@ uint8_t* Any::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Any) @@ -275,35 +293,31 @@ size_t Any::ByteSizeLong() const { this->_internal_value()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Any::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Any::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Any::GetClassData() const { return &_class_data_; } -void Any::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Any *>(to)->MergeFrom( - static_cast<const Any &>(from)); -} - -void Any::MergeFrom(const Any& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any) - GOOGLE_DCHECK_NE(&from, this); +void Any::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Any*>(&to_msg); + auto& from = static_cast<const Any&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (!from._internal_type_url().empty()) { - _internal_set_type_url(from._internal_type_url()); + _this->_internal_set_type_url(from._internal_type_url()); } if (!from._internal_value().empty()) { - _internal_set_value(from._internal_value()); + _this->_internal_set_value(from._internal_value()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Any::CopyFrom(const Any& from) { @@ -323,19 +337,17 @@ void Any::InternalSwap(Any* other) { auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &type_url_, lhs_arena, - &other->type_url_, rhs_arena + &_impl_.type_url_, lhs_arena, + &other->_impl_.type_url_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &value_, lhs_arena, - &other->value_, rhs_arena + &_impl_.value_, lhs_arena, + &other->_impl_.value_, rhs_arena ); } ::PROTOBUF_NAMESPACE_ID::Metadata Any::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fany_2eproto_getter, &descriptor_table_google_2fprotobuf_2fany_2eproto_once, file_level_metadata_google_2fprotobuf_2fany_2eproto[0]); } @@ -343,10 +355,14 @@ void Any::InternalSwap(Any* other) { // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Any* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Any >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Any* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Any >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Any >(arena); } PROTOBUF_NAMESPACE_CLOSE // @@protoc_insertion_point(global_scope) +#if defined(__llvm__) + #pragma clang diagnostic pop +#endif // __llvm__ #include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/any.pb.h b/r5dev/thirdparty/protobuf/any.pb.h index 3fcb3ee9..145e7bfe 100644 --- a/r5dev/thirdparty/protobuf/any.pb.h +++ b/r5dev/thirdparty/protobuf/any.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/generated_message_reflection.h> @@ -42,14 +41,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fany_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto; @@ -70,7 +61,7 @@ class PROTOBUF_EXPORT Any final : public: inline Any() : Any(nullptr) {} ~Any() override; - explicit constexpr Any(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Any(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Any(const Any& from); Any(Any&& from) noexcept @@ -118,14 +109,16 @@ class PROTOBUF_EXPORT Any final : // implements Any ----------------------------------------------- bool PackFrom(const ::PROTOBUF_NAMESPACE_ID::Message& message) { - return _any_metadata_.PackFrom(GetArena(), message); + GOOGLE_DCHECK_NE(&message, this); + return _impl_._any_metadata_.PackFrom(GetArena(), message); } bool PackFrom(const ::PROTOBUF_NAMESPACE_ID::Message& message, ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url_prefix) { - return _any_metadata_.PackFrom(GetArena(), message, type_url_prefix); + GOOGLE_DCHECK_NE(&message, this); + return _impl_._any_metadata_.PackFrom(GetArena(), message, type_url_prefix); } bool UnpackTo(::PROTOBUF_NAMESPACE_ID::Message* message) const { - return _any_metadata_.UnpackTo(message); + return _impl_._any_metadata_.UnpackTo(message); } static bool GetAnyFieldDescriptors( const ::PROTOBUF_NAMESPACE_ID::Message& message, @@ -133,18 +126,18 @@ class PROTOBUF_EXPORT Any final : const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** value_field); template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type> bool PackFrom(const T& message) { - return _any_metadata_.PackFrom<T>(GetArena(), message); + return _impl_._any_metadata_.PackFrom<T>(GetArena(), message); } template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type> bool PackFrom(const T& message, ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url_prefix) { - return _any_metadata_.PackFrom<T>(GetArena(), message, type_url_prefix);} + return _impl_._any_metadata_.PackFrom<T>(GetArena(), message, type_url_prefix);} template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type> bool UnpackTo(T* message) const { - return _any_metadata_.UnpackTo<T>(message); + return _impl_._any_metadata_.UnpackTo<T>(message); } template<typename T> bool Is() const { - return _any_metadata_.Is<T>(); + return _impl_._any_metadata_.Is<T>(); } static bool ParseAnyTypeUrl(::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url, std::string* full_type_name); @@ -178,9 +171,11 @@ class PROTOBUF_EXPORT Any final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Any& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Any& from); + void MergeFrom( const Any& from) { + Any::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -189,10 +184,10 @@ class PROTOBUF_EXPORT Any final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Any* other); @@ -205,9 +200,6 @@ class PROTOBUF_EXPORT Any final : protected: explicit Any(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -258,10 +250,13 @@ class PROTOBUF_EXPORT Any final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_url_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr value_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata _any_metadata_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_url_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr value_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata _any_metadata_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fany_2eproto; }; // =================================================================== @@ -277,7 +272,7 @@ class PROTOBUF_EXPORT Any final : // string type_url = 1; inline void Any::clear_type_url() { - type_url_.ClearToEmpty(); + _impl_.type_url_.ClearToEmpty(); } inline const std::string& Any::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url) @@ -287,7 +282,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Any::set_type_url(ArgT0&& arg0, ArgT... args) { - type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url) } inline std::string* Any::mutable_type_url() { @@ -296,19 +291,19 @@ inline std::string* Any::mutable_type_url() { return _s; } inline const std::string& Any::_internal_type_url() const { - return type_url_.Get(); + return _impl_.type_url_.Get(); } inline void Any::_internal_set_type_url(const std::string& value) { - type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.type_url_.Set(value, GetArenaForAllocation()); } inline std::string* Any::_internal_mutable_type_url() { - return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.type_url_.Mutable(GetArenaForAllocation()); } inline std::string* Any::release_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Any.type_url) - return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.type_url_.Release(); } inline void Any::set_allocated_type_url(std::string* type_url) { if (type_url != nullptr) { @@ -316,11 +311,10 @@ inline void Any::set_allocated_type_url(std::string* type_url) { } else { } - type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url, - GetArenaForAllocation()); + _impl_.type_url_.SetAllocated(type_url, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (type_url_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.type_url_.IsDefault()) { + _impl_.type_url_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url) @@ -328,7 +322,7 @@ inline void Any::set_allocated_type_url(std::string* type_url) { // bytes value = 2; inline void Any::clear_value() { - value_.ClearToEmpty(); + _impl_.value_.ClearToEmpty(); } inline const std::string& Any::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.value) @@ -338,7 +332,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Any::set_value(ArgT0&& arg0, ArgT... args) { - value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.value_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Any.value) } inline std::string* Any::mutable_value() { @@ -347,19 +341,19 @@ inline std::string* Any::mutable_value() { return _s; } inline const std::string& Any::_internal_value() const { - return value_.Get(); + return _impl_.value_.Get(); } inline void Any::_internal_set_value(const std::string& value) { - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.value_.Set(value, GetArenaForAllocation()); } inline std::string* Any::_internal_mutable_value() { - return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.value_.Mutable(GetArenaForAllocation()); } inline std::string* Any::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.Any.value) - return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.value_.Release(); } inline void Any::set_allocated_value(std::string* value) { if (value != nullptr) { @@ -367,11 +361,10 @@ inline void Any::set_allocated_value(std::string* value) { } else { } - value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, - GetArenaForAllocation()); + _impl_.value_.SetAllocated(value, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.value_.IsDefault()) { + _impl_.value_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value) diff --git a/r5dev/thirdparty/protobuf/any.proto b/r5dev/thirdparty/protobuf/any.proto index 6ed8a23c..e2c2042f 100644 --- a/r5dev/thirdparty/protobuf/any.proto +++ b/r5dev/thirdparty/protobuf/any.proto @@ -64,7 +64,7 @@ option objc_class_prefix = "GPB"; // foo = any.unpack(Foo.class); // } // -// Example 3: Pack and unpack a message in Python. +// Example 3: Pack and unpack a message in Python. // // foo = Foo(...) // any = Any() @@ -74,7 +74,7 @@ option objc_class_prefix = "GPB"; // any.Unpack(foo) // ... // -// Example 4: Pack and unpack a message in Go +// Example 4: Pack and unpack a message in Go // // foo := &pb.Foo{...} // any, err := anypb.New(foo) @@ -95,7 +95,7 @@ option objc_class_prefix = "GPB"; // // // JSON -// ==== +// // The JSON representation of an `Any` value uses the regular // representation of the deserialized, embedded message, with an // additional field `@type` which contains the type URL. Example: diff --git a/r5dev/thirdparty/protobuf/any_lite.cc b/r5dev/thirdparty/protobuf/any_lite.cc index 7b8fe66a..63b4aa65 100644 --- a/r5dev/thirdparty/protobuf/any_lite.cc +++ b/r5dev/thirdparty/protobuf/any_lite.cc @@ -28,12 +28,11 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <thirdparty/protobuf/any.h> - #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> +#include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/any.h> #include <thirdparty/protobuf/arenastring.h> #include <thirdparty/protobuf/generated_message_util.h> -#include <thirdparty/protobuf/stubs/strutil.h> namespace google { namespace protobuf { @@ -56,10 +55,8 @@ const char kTypeGoogleProdComPrefix[] = "type.googleprod.com/"; bool AnyMetadata::InternalPackFrom(Arena* arena, const MessageLite& message, StringPiece type_url_prefix, StringPiece type_name) { - type_url_->Set(&::google::protobuf::internal::GetEmptyString(), - GetTypeUrl(type_name, type_url_prefix), arena); - return message.SerializeToString( - value_->Mutable(ArenaStringPtr::EmptyDefault{}, arena)); + type_url_->Set(GetTypeUrl(type_name, type_url_prefix), arena); + return message.SerializeToString(value_->Mutable(arena)); } bool AnyMetadata::InternalUnpackTo(StringPiece type_name, diff --git a/r5dev/thirdparty/protobuf/any_test.cc b/r5dev/thirdparty/protobuf/any_test.cc index 91e74f53..e32adfd1 100644 --- a/r5dev/thirdparty/protobuf/any_test.cc +++ b/r5dev/thirdparty/protobuf/any_test.cc @@ -176,6 +176,16 @@ TEST(AnyTest, MoveAssignment) { EXPECT_EQ(12345, payload.int32_value()); } +#ifdef PROTOBUF_HAS_DEATH_TEST +#ifndef NDEBUG +TEST(AnyTest, PackSelfDeath) { + google::protobuf::Any any; + EXPECT_DEATH(any.PackFrom(any), "&message"); + EXPECT_DEATH(any.PackFrom(any, ""), "&message"); +} +#endif // !NDEBUG +#endif // PROTOBUF_HAS_DEATH_TEST + } // namespace } // namespace protobuf diff --git a/r5dev/thirdparty/protobuf/api.pb.cc b/r5dev/thirdparty/protobuf/api.pb.cc index 517213d0..0b8c5c24 100644 --- a/r5dev/thirdparty/protobuf/api.pb.cc +++ b/r5dev/thirdparty/protobuf/api.pb.cc @@ -16,62 +16,67 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + PROTOBUF_NAMESPACE_OPEN -constexpr Api::Api( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : methods_() - , options_() - , mixins_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , version_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , source_context_(nullptr) - , syntax_(0) -{} +PROTOBUF_CONSTEXPR Api::Api( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.methods_)*/{} + , /*decltype(_impl_.options_)*/{} + , /*decltype(_impl_.mixins_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.version_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.source_context_)*/nullptr + , /*decltype(_impl_.syntax_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} struct ApiDefaultTypeInternal { - constexpr ApiDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR ApiDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~ApiDefaultTypeInternal() {} union { Api _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ApiDefaultTypeInternal _Api_default_instance_; -constexpr Method::Method( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : options_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , request_type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , response_type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , request_streaming_(false) - , response_streaming_(false) - , syntax_(0) -{} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ApiDefaultTypeInternal _Api_default_instance_; +PROTOBUF_CONSTEXPR Method::Method( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.options_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.request_type_url_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.response_type_url_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.request_streaming_)*/false + , /*decltype(_impl_.response_streaming_)*/false + , /*decltype(_impl_.syntax_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} struct MethodDefaultTypeInternal { - constexpr MethodDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR MethodDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~MethodDefaultTypeInternal() {} union { Method _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT MethodDefaultTypeInternal _Method_default_instance_; -constexpr Mixin::Mixin( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , root_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDefaultTypeInternal _Method_default_instance_; +PROTOBUF_CONSTEXPR Mixin::Mixin( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.root_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} struct MixinDefaultTypeInternal { - constexpr MixinDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR MixinDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~MixinDefaultTypeInternal() {} union { Mixin _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT MixinDefaultTypeInternal _Mixin_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MixinDefaultTypeInternal _Mixin_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fapi_2eproto[3]; -static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr; +static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fapi_2eproto[3]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr; const uint32_t TableStruct_google_2fprotobuf_2fapi_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ @@ -80,45 +85,45 @@ const uint32_t TableStruct_google_2fprotobuf_2fapi_2eproto::offsets[] PROTOBUF_S ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, methods_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, version_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, source_context_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, mixins_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, syntax_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.methods_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.version_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.source_context_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.mixins_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.syntax_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, request_type_url_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, request_streaming_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, response_type_url_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, response_streaming_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, syntax_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.request_type_url_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.request_streaming_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.response_type_url_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.response_streaming_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.syntax_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, root_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _impl_.root_), }; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Api)}, { 13, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Method)}, { 26, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Mixin)}, }; -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Api_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Method_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Mixin_default_instance_), +static const ::_pb::Message* const file_default_instances[] = { + &::PROTOBUF_NAMESPACE_ID::_Api_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_Method_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_Mixin_default_instance_._instance, }; const char descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = @@ -142,23 +147,25 @@ const char descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto[] PROTOBUF_ "otobuf/types/known/apipb\242\002\003GPB\252\002\036Google." "Protobuf.WellKnownTypesb\006proto3" ; -static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fapi_2eproto_deps[2] = { +static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2fapi_2eproto_deps[2] = { &::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto, &::descriptor_table_google_2fprotobuf_2ftype_2eproto, }; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fapi_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto = { - false, false, 751, descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto, "google/protobuf/api.proto", - &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, descriptor_table_google_2fprotobuf_2fapi_2eproto_deps, 2, 3, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fapi_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fapi_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto, file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto, +static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fapi_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto = { + false, false, 751, descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto, + "google/protobuf/api.proto", + &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, descriptor_table_google_2fprotobuf_2fapi_2eproto_deps, 2, 3, + schemas, file_default_instances, TableStruct_google_2fprotobuf_2fapi_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fapi_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto, + file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fapi_2eproto_getter() { +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fapi_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fapi_2eproto; } // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fapi_2eproto(&descriptor_table_google_2fprotobuf_2fapi_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fapi_2eproto(&descriptor_table_google_2fprotobuf_2fapi_2eproto); PROTOBUF_NAMESPACE_OPEN // =================================================================== @@ -170,97 +177,105 @@ class Api::_Internal { const ::PROTOBUF_NAMESPACE_ID::SourceContext& Api::_Internal::source_context(const Api* msg) { - return *msg->source_context_; + return *msg->_impl_.source_context_; } void Api::clear_options() { - options_.Clear(); + _impl_.options_.Clear(); } void Api::clear_source_context() { - if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) { - delete source_context_; + if (GetArenaForAllocation() == nullptr && _impl_.source_context_ != nullptr) { + delete _impl_.source_context_; } - source_context_ = nullptr; + _impl_.source_context_ = nullptr; } Api::Api(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - methods_(arena), - options_(arena), - mixins_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Api) } Api::Api(const Api& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - methods_(from.methods_), - options_(from.options_), - mixins_(from.mixins_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + Api* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.methods_){from._impl_.methods_} + , decltype(_impl_.options_){from._impl_.options_} + , decltype(_impl_.mixins_){from._impl_.mixins_} + , decltype(_impl_.name_){} + , decltype(_impl_.version_){} + , decltype(_impl_.source_context_){nullptr} + , decltype(_impl_.syntax_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_name().empty()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } - version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.version_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.version_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_version().empty()) { - version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_version(), - GetArenaForAllocation()); + _this->_impl_.version_.Set(from._internal_version(), + _this->GetArenaForAllocation()); } if (from._internal_has_source_context()) { - source_context_ = new ::PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_); - } else { - source_context_ = nullptr; + _this->_impl_.source_context_ = new ::PROTOBUF_NAMESPACE_ID::SourceContext(*from._impl_.source_context_); } - syntax_ = from.syntax_; + _this->_impl_.syntax_ = from._impl_.syntax_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Api) } -inline void Api::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&source_context_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&syntax_) - - reinterpret_cast<char*>(&source_context_)) + sizeof(syntax_)); +inline void Api::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.methods_){arena} + , decltype(_impl_.options_){arena} + , decltype(_impl_.mixins_){arena} + , decltype(_impl_.name_){} + , decltype(_impl_.version_){} + , decltype(_impl_.source_context_){nullptr} + , decltype(_impl_.syntax_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.version_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.version_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } Api::~Api() { // @@protoc_insertion_point(destructor:google.protobuf.Api) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Api::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - version_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete source_context_; + _impl_.methods_.~RepeatedPtrField(); + _impl_.options_.~RepeatedPtrField(); + _impl_.mixins_.~RepeatedPtrField(); + _impl_.name_.Destroy(); + _impl_.version_.Destroy(); + if (this != internal_default_instance()) delete _impl_.source_context_; } -void Api::ArenaDtor(void* object) { - Api* _this = reinterpret_cast< Api* >(object); - (void)_this; -} -void Api::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Api::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Api::Clear() { @@ -269,32 +284,32 @@ void Api::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - methods_.Clear(); - options_.Clear(); - mixins_.Clear(); - name_.ClearToEmpty(); - version_.ClearToEmpty(); - if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) { - delete source_context_; + _impl_.methods_.Clear(); + _impl_.options_.Clear(); + _impl_.mixins_.Clear(); + _impl_.name_.ClearToEmpty(); + _impl_.version_.ClearToEmpty(); + if (GetArenaForAllocation() == nullptr && _impl_.source_context_ != nullptr) { + delete _impl_.source_context_; } - source_context_ = nullptr; - syntax_ = 0; + _impl_.source_context_ = nullptr; + _impl_.syntax_ = 0; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Api::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Api.name")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Api.name")); } else goto handle_unusual; continue; @@ -328,9 +343,9 @@ const char* Api::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) { auto str = _internal_mutable_version(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Api.version")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Api.version")); } else goto handle_unusual; continue; @@ -404,19 +419,19 @@ uint8_t* Api::_InternalSerialize( } // repeated .google.protobuf.Method methods = 2; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_methods_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_methods_size()); i < n; i++) { + const auto& repfield = this->_internal_methods(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, this->_internal_methods(i), target, stream); + InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream); } // repeated .google.protobuf.Option options = 3; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_options_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) { + const auto& repfield = this->_internal_options(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, this->_internal_options(i), target, stream); + InternalWriteMessage(3, repfield, repfield.GetCachedSize(), target, stream); } // string version = 4; @@ -431,29 +446,28 @@ uint8_t* Api::_InternalSerialize( // .google.protobuf.SourceContext source_context = 5; if (this->_internal_has_source_context()) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 5, _Internal::source_context(this), target, stream); + InternalWriteMessage(5, _Internal::source_context(this), + _Internal::source_context(this).GetCachedSize(), target, stream); } // repeated .google.protobuf.Mixin mixins = 6; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_mixins_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_mixins_size()); i < n; i++) { + const auto& repfield = this->_internal_mixins(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(6, this->_internal_mixins(i), target, stream); + InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream); } // .google.protobuf.Syntax syntax = 7; if (this->_internal_syntax() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 7, this->_internal_syntax(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Api) @@ -470,21 +484,21 @@ size_t Api::ByteSizeLong() const { // repeated .google.protobuf.Method methods = 2; total_size += 1UL * this->_internal_methods_size(); - for (const auto& msg : this->methods_) { + for (const auto& msg : this->_impl_.methods_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.Option options = 3; total_size += 1UL * this->_internal_options_size(); - for (const auto& msg : this->options_) { + for (const auto& msg : this->_impl_.options_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.Mixin mixins = 6; total_size += 1UL * this->_internal_mixins_size(); - for (const auto& msg : this->mixins_) { + for (const auto& msg : this->_impl_.mixins_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } @@ -507,53 +521,50 @@ size_t Api::ByteSizeLong() const { if (this->_internal_has_source_context()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *source_context_); + *_impl_.source_context_); } // .google.protobuf.Syntax syntax = 7; if (this->_internal_syntax() != 0) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_syntax()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Api::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Api::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Api::GetClassData() const { return &_class_data_; } -void Api::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Api *>(to)->MergeFrom( - static_cast<const Api &>(from)); -} - -void Api::MergeFrom(const Api& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api) - GOOGLE_DCHECK_NE(&from, this); +void Api::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Api*>(&to_msg); + auto& from = static_cast<const Api&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - methods_.MergeFrom(from.methods_); - options_.MergeFrom(from.options_); - mixins_.MergeFrom(from.mixins_); + _this->_impl_.methods_.MergeFrom(from._impl_.methods_); + _this->_impl_.options_.MergeFrom(from._impl_.options_); + _this->_impl_.mixins_.MergeFrom(from._impl_.mixins_); if (!from._internal_name().empty()) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (!from._internal_version().empty()) { - _internal_set_version(from._internal_version()); + _this->_internal_set_version(from._internal_version()); } if (from._internal_has_source_context()) { - _internal_mutable_source_context()->::PROTOBUF_NAMESPACE_ID::SourceContext::MergeFrom(from._internal_source_context()); + _this->_internal_mutable_source_context()->::PROTOBUF_NAMESPACE_ID::SourceContext::MergeFrom( + from._internal_source_context()); } if (from._internal_syntax() != 0) { - _internal_set_syntax(from._internal_syntax()); + _this->_internal_set_syntax(from._internal_syntax()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Api::CopyFrom(const Api& from) { @@ -572,29 +583,27 @@ void Api::InternalSwap(Api* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - methods_.InternalSwap(&other->methods_); - options_.InternalSwap(&other->options_); - mixins_.InternalSwap(&other->mixins_); + _impl_.methods_.InternalSwap(&other->_impl_.methods_); + _impl_.options_.InternalSwap(&other->_impl_.options_); + _impl_.mixins_.InternalSwap(&other->_impl_.mixins_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &version_, lhs_arena, - &other->version_, rhs_arena + &_impl_.version_, lhs_arena, + &other->_impl_.version_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Api, syntax_) - + sizeof(Api::syntax_) - - PROTOBUF_FIELD_OFFSET(Api, source_context_)>( - reinterpret_cast<char*>(&source_context_), - reinterpret_cast<char*>(&other->source_context_)); + PROTOBUF_FIELD_OFFSET(Api, _impl_.syntax_) + + sizeof(Api::_impl_.syntax_) + - PROTOBUF_FIELD_OFFSET(Api, _impl_.source_context_)>( + reinterpret_cast<char*>(&_impl_.source_context_), + reinterpret_cast<char*>(&other->_impl_.source_context_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Api::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, file_level_metadata_google_2fprotobuf_2fapi_2eproto[0]); } @@ -606,93 +615,105 @@ class Method::_Internal { }; void Method::clear_options() { - options_.Clear(); + _impl_.options_.Clear(); } Method::Method(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - options_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Method) } Method::Method(const Method& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - options_(from.options_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + Method* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.options_){from._impl_.options_} + , decltype(_impl_.name_){} + , decltype(_impl_.request_type_url_){} + , decltype(_impl_.response_type_url_){} + , decltype(_impl_.request_streaming_){} + , decltype(_impl_.response_streaming_){} + , decltype(_impl_.syntax_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_name().empty()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } - request_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.request_type_url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.request_type_url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_request_type_url().empty()) { - request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_request_type_url(), - GetArenaForAllocation()); + _this->_impl_.request_type_url_.Set(from._internal_request_type_url(), + _this->GetArenaForAllocation()); } - response_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.response_type_url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.response_type_url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_response_type_url().empty()) { - response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_response_type_url(), - GetArenaForAllocation()); + _this->_impl_.response_type_url_.Set(from._internal_response_type_url(), + _this->GetArenaForAllocation()); } - ::memcpy(&request_streaming_, &from.request_streaming_, - static_cast<size_t>(reinterpret_cast<char*>(&syntax_) - - reinterpret_cast<char*>(&request_streaming_)) + sizeof(syntax_)); + ::memcpy(&_impl_.request_streaming_, &from._impl_.request_streaming_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.syntax_) - + reinterpret_cast<char*>(&_impl_.request_streaming_)) + sizeof(_impl_.syntax_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Method) } -inline void Method::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -request_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -response_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&request_streaming_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&syntax_) - - reinterpret_cast<char*>(&request_streaming_)) + sizeof(syntax_)); +inline void Method::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.options_){arena} + , decltype(_impl_.name_){} + , decltype(_impl_.request_type_url_){} + , decltype(_impl_.response_type_url_){} + , decltype(_impl_.request_streaming_){false} + , decltype(_impl_.response_streaming_){false} + , decltype(_impl_.syntax_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.request_type_url_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.request_type_url_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.response_type_url_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.response_type_url_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } Method::~Method() { // @@protoc_insertion_point(destructor:google.protobuf.Method) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Method::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - request_type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - response_type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.options_.~RepeatedPtrField(); + _impl_.name_.Destroy(); + _impl_.request_type_url_.Destroy(); + _impl_.response_type_url_.Destroy(); } -void Method::ArenaDtor(void* object) { - Method* _this = reinterpret_cast< Method* >(object); - (void)_this; -} -void Method::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Method::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Method::Clear() { @@ -701,29 +722,29 @@ void Method::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - options_.Clear(); - name_.ClearToEmpty(); - request_type_url_.ClearToEmpty(); - response_type_url_.ClearToEmpty(); - ::memset(&request_streaming_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&syntax_) - - reinterpret_cast<char*>(&request_streaming_)) + sizeof(syntax_)); + _impl_.options_.Clear(); + _impl_.name_.ClearToEmpty(); + _impl_.request_type_url_.ClearToEmpty(); + _impl_.response_type_url_.ClearToEmpty(); + ::memset(&_impl_.request_streaming_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.syntax_) - + reinterpret_cast<char*>(&_impl_.request_streaming_)) + sizeof(_impl_.syntax_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Method::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Method.name")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Method.name")); } else goto handle_unusual; continue; @@ -731,16 +752,16 @@ const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_request_type_url(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Method.request_type_url")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Method.request_type_url")); } else goto handle_unusual; continue; // bool request_streaming = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) { - request_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.request_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -749,16 +770,16 @@ const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) { auto str = _internal_mutable_response_type_url(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Method.response_type_url")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Method.response_type_url")); } else goto handle_unusual; continue; // bool response_streaming = 5; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) { - response_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.response_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -837,7 +858,7 @@ uint8_t* Method::_InternalSerialize( // bool request_streaming = 3; if (this->_internal_request_streaming() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_request_streaming(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_request_streaming(), target); } // string response_type_url = 4; @@ -853,26 +874,26 @@ uint8_t* Method::_InternalSerialize( // bool response_streaming = 5; if (this->_internal_response_streaming() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_response_streaming(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_response_streaming(), target); } // repeated .google.protobuf.Option options = 6; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_options_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) { + const auto& repfield = this->_internal_options(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(6, this->_internal_options(i), target, stream); + InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream); } // .google.protobuf.Syntax syntax = 7; if (this->_internal_syntax() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 7, this->_internal_syntax(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Method) @@ -889,7 +910,7 @@ size_t Method::ByteSizeLong() const { // repeated .google.protobuf.Option options = 6; total_size += 1UL * this->_internal_options_size(); - for (const auto& msg : this->options_) { + for (const auto& msg : this->_impl_.options_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } @@ -928,51 +949,47 @@ size_t Method::ByteSizeLong() const { // .google.protobuf.Syntax syntax = 7; if (this->_internal_syntax() != 0) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_syntax()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Method::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Method::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Method::GetClassData() const { return &_class_data_; } -void Method::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Method *>(to)->MergeFrom( - static_cast<const Method &>(from)); -} - -void Method::MergeFrom(const Method& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method) - GOOGLE_DCHECK_NE(&from, this); +void Method::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Method*>(&to_msg); + auto& from = static_cast<const Method&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - options_.MergeFrom(from.options_); + _this->_impl_.options_.MergeFrom(from._impl_.options_); if (!from._internal_name().empty()) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (!from._internal_request_type_url().empty()) { - _internal_set_request_type_url(from._internal_request_type_url()); + _this->_internal_set_request_type_url(from._internal_request_type_url()); } if (!from._internal_response_type_url().empty()) { - _internal_set_response_type_url(from._internal_response_type_url()); + _this->_internal_set_response_type_url(from._internal_response_type_url()); } if (from._internal_request_streaming() != 0) { - _internal_set_request_streaming(from._internal_request_streaming()); + _this->_internal_set_request_streaming(from._internal_request_streaming()); } if (from._internal_response_streaming() != 0) { - _internal_set_response_streaming(from._internal_response_streaming()); + _this->_internal_set_response_streaming(from._internal_response_streaming()); } if (from._internal_syntax() != 0) { - _internal_set_syntax(from._internal_syntax()); + _this->_internal_set_syntax(from._internal_syntax()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Method::CopyFrom(const Method& from) { @@ -991,32 +1008,29 @@ void Method::InternalSwap(Method* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - options_.InternalSwap(&other->options_); + _impl_.options_.InternalSwap(&other->_impl_.options_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &request_type_url_, lhs_arena, - &other->request_type_url_, rhs_arena + &_impl_.request_type_url_, lhs_arena, + &other->_impl_.request_type_url_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &response_type_url_, lhs_arena, - &other->response_type_url_, rhs_arena + &_impl_.response_type_url_, lhs_arena, + &other->_impl_.response_type_url_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Method, syntax_) - + sizeof(Method::syntax_) - - PROTOBUF_FIELD_OFFSET(Method, request_streaming_)>( - reinterpret_cast<char*>(&request_streaming_), - reinterpret_cast<char*>(&other->request_streaming_)); + PROTOBUF_FIELD_OFFSET(Method, _impl_.syntax_) + + sizeof(Method::_impl_.syntax_) + - PROTOBUF_FIELD_OFFSET(Method, _impl_.request_streaming_)>( + reinterpret_cast<char*>(&_impl_.request_streaming_), + reinterpret_cast<char*>(&other->_impl_.request_streaming_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Method::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, file_level_metadata_google_2fprotobuf_2fapi_2eproto[1]); } @@ -1030,66 +1044,73 @@ class Mixin::_Internal { Mixin::Mixin(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Mixin) } Mixin::Mixin(const Mixin& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + Mixin* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.name_){} + , decltype(_impl_.root_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_name().empty()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } - root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.root_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.root_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_root().empty()) { - root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_root(), - GetArenaForAllocation()); + _this->_impl_.root_.Set(from._internal_root(), + _this->GetArenaForAllocation()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin) } -inline void Mixin::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +inline void Mixin::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.name_){} + , decltype(_impl_.root_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.root_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.root_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } Mixin::~Mixin() { // @@protoc_insertion_point(destructor:google.protobuf.Mixin) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Mixin::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - root_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.Destroy(); + _impl_.root_.Destroy(); } -void Mixin::ArenaDtor(void* object) { - Mixin* _this = reinterpret_cast< Mixin* >(object); - (void)_this; -} -void Mixin::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Mixin::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Mixin::Clear() { @@ -1098,24 +1119,24 @@ void Mixin::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - name_.ClearToEmpty(); - root_.ClearToEmpty(); + _impl_.name_.ClearToEmpty(); + _impl_.root_.ClearToEmpty(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Mixin::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Mixin::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Mixin.name")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Mixin.name")); } else goto handle_unusual; continue; @@ -1123,9 +1144,9 @@ const char* Mixin::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_root(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Mixin.root")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Mixin.root")); } else goto handle_unusual; continue; @@ -1179,7 +1200,7 @@ uint8_t* Mixin::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Mixin) @@ -1208,35 +1229,31 @@ size_t Mixin::ByteSizeLong() const { this->_internal_root()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Mixin::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Mixin::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Mixin::GetClassData() const { return &_class_data_; } -void Mixin::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Mixin *>(to)->MergeFrom( - static_cast<const Mixin &>(from)); -} - -void Mixin::MergeFrom(const Mixin& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin) - GOOGLE_DCHECK_NE(&from, this); +void Mixin::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Mixin*>(&to_msg); + auto& from = static_cast<const Mixin&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (!from._internal_name().empty()) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (!from._internal_root().empty()) { - _internal_set_root(from._internal_root()); + _this->_internal_set_root(from._internal_root()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Mixin::CopyFrom(const Mixin& from) { @@ -1256,19 +1273,17 @@ void Mixin::InternalSwap(Mixin* other) { auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &root_, lhs_arena, - &other->root_, rhs_arena + &_impl_.root_, lhs_arena, + &other->_impl_.root_, rhs_arena ); } ::PROTOBUF_NAMESPACE_ID::Metadata Mixin::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, file_level_metadata_google_2fprotobuf_2fapi_2eproto[2]); } @@ -1276,13 +1291,16 @@ void Mixin::InternalSwap(Mixin* other) { // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Api* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Api >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Api* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Api >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Api >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Method* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Method >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Method* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Method >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Method >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Mixin* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Mixin >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Mixin* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Mixin >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Mixin >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/thirdparty/protobuf/api.pb.h b/r5dev/thirdparty/protobuf/api.pb.h index 843337ff..e7e7960b 100644 --- a/r5dev/thirdparty/protobuf/api.pb.h +++ b/r5dev/thirdparty/protobuf/api.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/generated_message_reflection.h> @@ -44,14 +43,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fapi_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[3] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fapi_2eproto; @@ -80,7 +71,7 @@ class PROTOBUF_EXPORT Api final : public: inline Api() : Api(nullptr) {} ~Api() override; - explicit constexpr Api(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Api(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Api(const Api& from); Api(Api&& from) noexcept @@ -155,9 +146,11 @@ class PROTOBUF_EXPORT Api final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Api& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Api& from); + void MergeFrom( const Api& from) { + Api::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -166,10 +159,10 @@ class PROTOBUF_EXPORT Api final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Api* other); @@ -182,9 +175,6 @@ class PROTOBUF_EXPORT Api final : protected: explicit Api(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -321,14 +311,17 @@ class PROTOBUF_EXPORT Api final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Method > methods_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Mixin > mixins_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr version_; - ::PROTOBUF_NAMESPACE_ID::SourceContext* source_context_; - int syntax_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Method > methods_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Mixin > mixins_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr version_; + ::PROTOBUF_NAMESPACE_ID::SourceContext* source_context_; + int syntax_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fapi_2eproto; }; // ------------------------------------------------------------------- @@ -338,7 +331,7 @@ class PROTOBUF_EXPORT Method final : public: inline Method() : Method(nullptr) {} ~Method() override; - explicit constexpr Method(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Method(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Method(const Method& from); Method(Method&& from) noexcept @@ -413,9 +406,11 @@ class PROTOBUF_EXPORT Method final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Method& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Method& from); + void MergeFrom( const Method& from) { + Method::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -424,10 +419,10 @@ class PROTOBUF_EXPORT Method final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Method* other); @@ -440,9 +435,6 @@ class PROTOBUF_EXPORT Method final : protected: explicit Method(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -557,14 +549,17 @@ class PROTOBUF_EXPORT Method final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr request_type_url_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr response_type_url_; - bool request_streaming_; - bool response_streaming_; - int syntax_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr request_type_url_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr response_type_url_; + bool request_streaming_; + bool response_streaming_; + int syntax_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fapi_2eproto; }; // ------------------------------------------------------------------- @@ -574,7 +569,7 @@ class PROTOBUF_EXPORT Mixin final : public: inline Mixin() : Mixin(nullptr) {} ~Mixin() override; - explicit constexpr Mixin(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Mixin(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Mixin(const Mixin& from); Mixin(Mixin&& from) noexcept @@ -649,9 +644,11 @@ class PROTOBUF_EXPORT Mixin final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Mixin& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Mixin& from); + void MergeFrom( const Mixin& from) { + Mixin::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -660,10 +657,10 @@ class PROTOBUF_EXPORT Mixin final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Mixin* other); @@ -676,9 +673,6 @@ class PROTOBUF_EXPORT Mixin final : protected: explicit Mixin(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -729,9 +723,12 @@ class PROTOBUF_EXPORT Mixin final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr root_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr root_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fapi_2eproto; }; // =================================================================== @@ -747,7 +744,7 @@ class PROTOBUF_EXPORT Mixin final : // string name = 1; inline void Api::clear_name() { - name_.ClearToEmpty(); + _impl_.name_.ClearToEmpty(); } inline const std::string& Api::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.name) @@ -757,7 +754,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Api::set_name(ArgT0&& arg0, ArgT... args) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Api.name) } inline std::string* Api::mutable_name() { @@ -766,19 +763,19 @@ inline std::string* Api::mutable_name() { return _s; } inline const std::string& Api::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void Api::_internal_set_name(const std::string& value) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* Api::_internal_mutable_name() { - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* Api::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Api.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.name_.Release(); } inline void Api::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -786,11 +783,10 @@ inline void Api::set_allocated_name(std::string* name) { } else { } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name) @@ -798,32 +794,32 @@ inline void Api::set_allocated_name(std::string* name) { // repeated .google.protobuf.Method methods = 2; inline int Api::_internal_methods_size() const { - return methods_.size(); + return _impl_.methods_.size(); } inline int Api::methods_size() const { return _internal_methods_size(); } inline void Api::clear_methods() { - methods_.Clear(); + _impl_.methods_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::Method* Api::mutable_methods(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Api.methods) - return methods_.Mutable(index); + return _impl_.methods_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Method >* Api::mutable_methods() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.methods) - return &methods_; + return &_impl_.methods_; } inline const ::PROTOBUF_NAMESPACE_ID::Method& Api::_internal_methods(int index) const { - return methods_.Get(index); + return _impl_.methods_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::Method& Api::methods(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Api.methods) return _internal_methods(index); } inline ::PROTOBUF_NAMESPACE_ID::Method* Api::_internal_add_methods() { - return methods_.Add(); + return _impl_.methods_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::Method* Api::add_methods() { ::PROTOBUF_NAMESPACE_ID::Method* _add = _internal_add_methods(); @@ -833,34 +829,34 @@ inline ::PROTOBUF_NAMESPACE_ID::Method* Api::add_methods() { inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Method >& Api::methods() const { // @@protoc_insertion_point(field_list:google.protobuf.Api.methods) - return methods_; + return _impl_.methods_; } // repeated .google.protobuf.Option options = 3; inline int Api::_internal_options_size() const { - return options_.size(); + return _impl_.options_.size(); } inline int Api::options_size() const { return _internal_options_size(); } inline ::PROTOBUF_NAMESPACE_ID::Option* Api::mutable_options(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Api.options) - return options_.Mutable(index); + return _impl_.options_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >* Api::mutable_options() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.options) - return &options_; + return &_impl_.options_; } inline const ::PROTOBUF_NAMESPACE_ID::Option& Api::_internal_options(int index) const { - return options_.Get(index); + return _impl_.options_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::Option& Api::options(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Api.options) return _internal_options(index); } inline ::PROTOBUF_NAMESPACE_ID::Option* Api::_internal_add_options() { - return options_.Add(); + return _impl_.options_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::Option* Api::add_options() { ::PROTOBUF_NAMESPACE_ID::Option* _add = _internal_add_options(); @@ -870,12 +866,12 @@ inline ::PROTOBUF_NAMESPACE_ID::Option* Api::add_options() { inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >& Api::options() const { // @@protoc_insertion_point(field_list:google.protobuf.Api.options) - return options_; + return _impl_.options_; } // string version = 4; inline void Api::clear_version() { - version_.ClearToEmpty(); + _impl_.version_.ClearToEmpty(); } inline const std::string& Api::version() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.version) @@ -885,7 +881,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Api::set_version(ArgT0&& arg0, ArgT... args) { - version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.version_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Api.version) } inline std::string* Api::mutable_version() { @@ -894,19 +890,19 @@ inline std::string* Api::mutable_version() { return _s; } inline const std::string& Api::_internal_version() const { - return version_.Get(); + return _impl_.version_.Get(); } inline void Api::_internal_set_version(const std::string& value) { - version_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.version_.Set(value, GetArenaForAllocation()); } inline std::string* Api::_internal_mutable_version() { - return version_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.version_.Mutable(GetArenaForAllocation()); } inline std::string* Api::release_version() { // @@protoc_insertion_point(field_release:google.protobuf.Api.version) - return version_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.version_.Release(); } inline void Api::set_allocated_version(std::string* version) { if (version != nullptr) { @@ -914,11 +910,10 @@ inline void Api::set_allocated_version(std::string* version) { } else { } - version_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), version, - GetArenaForAllocation()); + _impl_.version_.SetAllocated(version, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (version_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.version_.IsDefault()) { + _impl_.version_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version) @@ -926,13 +921,13 @@ inline void Api::set_allocated_version(std::string* version) { // .google.protobuf.SourceContext source_context = 5; inline bool Api::_internal_has_source_context() const { - return this != internal_default_instance() && source_context_ != nullptr; + return this != internal_default_instance() && _impl_.source_context_ != nullptr; } inline bool Api::has_source_context() const { return _internal_has_source_context(); } inline const ::PROTOBUF_NAMESPACE_ID::SourceContext& Api::_internal_source_context() const { - const ::PROTOBUF_NAMESPACE_ID::SourceContext* p = source_context_; + const ::PROTOBUF_NAMESPACE_ID::SourceContext* p = _impl_.source_context_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::SourceContext&>( ::PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_); } @@ -943,9 +938,9 @@ inline const ::PROTOBUF_NAMESPACE_ID::SourceContext& Api::source_context() const inline void Api::unsafe_arena_set_allocated_source_context( ::PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.source_context_); } - source_context_ = source_context; + _impl_.source_context_ = source_context; if (source_context) { } else { @@ -955,8 +950,8 @@ inline void Api::unsafe_arena_set_allocated_source_context( } inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Api::release_source_context() { - ::PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; - source_context_ = nullptr; + ::PROTOBUF_NAMESPACE_ID::SourceContext* temp = _impl_.source_context_; + _impl_.source_context_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -971,17 +966,17 @@ inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Api::release_source_context() { inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Api::unsafe_arena_release_source_context() { // @@protoc_insertion_point(field_release:google.protobuf.Api.source_context) - ::PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; - source_context_ = nullptr; + ::PROTOBUF_NAMESPACE_ID::SourceContext* temp = _impl_.source_context_; + _impl_.source_context_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Api::_internal_mutable_source_context() { - if (source_context_ == nullptr) { + if (_impl_.source_context_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceContext>(GetArenaForAllocation()); - source_context_ = p; + _impl_.source_context_ = p; } - return source_context_; + return _impl_.source_context_; } inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Api::mutable_source_context() { ::PROTOBUF_NAMESPACE_ID::SourceContext* _msg = _internal_mutable_source_context(); @@ -991,12 +986,11 @@ inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Api::mutable_source_context() { inline void Api::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.source_context_); } if (source_context) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper< - ::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena( + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)); if (message_arena != submessage_arena) { source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( @@ -1006,38 +1000,38 @@ inline void Api::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCon } else { } - source_context_ = source_context; + _impl_.source_context_ = source_context; // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.source_context) } // repeated .google.protobuf.Mixin mixins = 6; inline int Api::_internal_mixins_size() const { - return mixins_.size(); + return _impl_.mixins_.size(); } inline int Api::mixins_size() const { return _internal_mixins_size(); } inline void Api::clear_mixins() { - mixins_.Clear(); + _impl_.mixins_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::Mixin* Api::mutable_mixins(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Api.mixins) - return mixins_.Mutable(index); + return _impl_.mixins_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Mixin >* Api::mutable_mixins() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.mixins) - return &mixins_; + return &_impl_.mixins_; } inline const ::PROTOBUF_NAMESPACE_ID::Mixin& Api::_internal_mixins(int index) const { - return mixins_.Get(index); + return _impl_.mixins_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::Mixin& Api::mixins(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Api.mixins) return _internal_mixins(index); } inline ::PROTOBUF_NAMESPACE_ID::Mixin* Api::_internal_add_mixins() { - return mixins_.Add(); + return _impl_.mixins_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::Mixin* Api::add_mixins() { ::PROTOBUF_NAMESPACE_ID::Mixin* _add = _internal_add_mixins(); @@ -1047,15 +1041,15 @@ inline ::PROTOBUF_NAMESPACE_ID::Mixin* Api::add_mixins() { inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Mixin >& Api::mixins() const { // @@protoc_insertion_point(field_list:google.protobuf.Api.mixins) - return mixins_; + return _impl_.mixins_; } // .google.protobuf.Syntax syntax = 7; inline void Api::clear_syntax() { - syntax_ = 0; + _impl_.syntax_ = 0; } inline ::PROTOBUF_NAMESPACE_ID::Syntax Api::_internal_syntax() const { - return static_cast< ::PROTOBUF_NAMESPACE_ID::Syntax >(syntax_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::Syntax >(_impl_.syntax_); } inline ::PROTOBUF_NAMESPACE_ID::Syntax Api::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.syntax) @@ -1063,7 +1057,7 @@ inline ::PROTOBUF_NAMESPACE_ID::Syntax Api::syntax() const { } inline void Api::_internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) { - syntax_ = value; + _impl_.syntax_ = value; } inline void Api::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) { _internal_set_syntax(value); @@ -1076,7 +1070,7 @@ inline void Api::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) { // string name = 1; inline void Method::clear_name() { - name_.ClearToEmpty(); + _impl_.name_.ClearToEmpty(); } inline const std::string& Method::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.name) @@ -1086,7 +1080,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Method::set_name(ArgT0&& arg0, ArgT... args) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Method.name) } inline std::string* Method::mutable_name() { @@ -1095,19 +1089,19 @@ inline std::string* Method::mutable_name() { return _s; } inline const std::string& Method::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void Method::_internal_set_name(const std::string& value) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* Method::_internal_mutable_name() { - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* Method::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Method.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.name_.Release(); } inline void Method::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -1115,11 +1109,10 @@ inline void Method::set_allocated_name(std::string* name) { } else { } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name) @@ -1127,7 +1120,7 @@ inline void Method::set_allocated_name(std::string* name) { // string request_type_url = 2; inline void Method::clear_request_type_url() { - request_type_url_.ClearToEmpty(); + _impl_.request_type_url_.ClearToEmpty(); } inline const std::string& Method::request_type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url) @@ -1137,7 +1130,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Method::set_request_type_url(ArgT0&& arg0, ArgT... args) { - request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.request_type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url) } inline std::string* Method::mutable_request_type_url() { @@ -1146,19 +1139,19 @@ inline std::string* Method::mutable_request_type_url() { return _s; } inline const std::string& Method::_internal_request_type_url() const { - return request_type_url_.Get(); + return _impl_.request_type_url_.Get(); } inline void Method::_internal_set_request_type_url(const std::string& value) { - request_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.request_type_url_.Set(value, GetArenaForAllocation()); } inline std::string* Method::_internal_mutable_request_type_url() { - return request_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.request_type_url_.Mutable(GetArenaForAllocation()); } inline std::string* Method::release_request_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Method.request_type_url) - return request_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.request_type_url_.Release(); } inline void Method::set_allocated_request_type_url(std::string* request_type_url) { if (request_type_url != nullptr) { @@ -1166,11 +1159,10 @@ inline void Method::set_allocated_request_type_url(std::string* request_type_url } else { } - request_type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), request_type_url, - GetArenaForAllocation()); + _impl_.request_type_url_.SetAllocated(request_type_url, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (request_type_url_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - request_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.request_type_url_.IsDefault()) { + _impl_.request_type_url_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url) @@ -1178,10 +1170,10 @@ inline void Method::set_allocated_request_type_url(std::string* request_type_url // bool request_streaming = 3; inline void Method::clear_request_streaming() { - request_streaming_ = false; + _impl_.request_streaming_ = false; } inline bool Method::_internal_request_streaming() const { - return request_streaming_; + return _impl_.request_streaming_; } inline bool Method::request_streaming() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.request_streaming) @@ -1189,7 +1181,7 @@ inline bool Method::request_streaming() const { } inline void Method::_internal_set_request_streaming(bool value) { - request_streaming_ = value; + _impl_.request_streaming_ = value; } inline void Method::set_request_streaming(bool value) { _internal_set_request_streaming(value); @@ -1198,7 +1190,7 @@ inline void Method::set_request_streaming(bool value) { // string response_type_url = 4; inline void Method::clear_response_type_url() { - response_type_url_.ClearToEmpty(); + _impl_.response_type_url_.ClearToEmpty(); } inline const std::string& Method::response_type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url) @@ -1208,7 +1200,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Method::set_response_type_url(ArgT0&& arg0, ArgT... args) { - response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.response_type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url) } inline std::string* Method::mutable_response_type_url() { @@ -1217,19 +1209,19 @@ inline std::string* Method::mutable_response_type_url() { return _s; } inline const std::string& Method::_internal_response_type_url() const { - return response_type_url_.Get(); + return _impl_.response_type_url_.Get(); } inline void Method::_internal_set_response_type_url(const std::string& value) { - response_type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.response_type_url_.Set(value, GetArenaForAllocation()); } inline std::string* Method::_internal_mutable_response_type_url() { - return response_type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.response_type_url_.Mutable(GetArenaForAllocation()); } inline std::string* Method::release_response_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Method.response_type_url) - return response_type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.response_type_url_.Release(); } inline void Method::set_allocated_response_type_url(std::string* response_type_url) { if (response_type_url != nullptr) { @@ -1237,11 +1229,10 @@ inline void Method::set_allocated_response_type_url(std::string* response_type_u } else { } - response_type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), response_type_url, - GetArenaForAllocation()); + _impl_.response_type_url_.SetAllocated(response_type_url, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (response_type_url_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - response_type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.response_type_url_.IsDefault()) { + _impl_.response_type_url_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url) @@ -1249,10 +1240,10 @@ inline void Method::set_allocated_response_type_url(std::string* response_type_u // bool response_streaming = 5; inline void Method::clear_response_streaming() { - response_streaming_ = false; + _impl_.response_streaming_ = false; } inline bool Method::_internal_response_streaming() const { - return response_streaming_; + return _impl_.response_streaming_; } inline bool Method::response_streaming() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.response_streaming) @@ -1260,7 +1251,7 @@ inline bool Method::response_streaming() const { } inline void Method::_internal_set_response_streaming(bool value) { - response_streaming_ = value; + _impl_.response_streaming_ = value; } inline void Method::set_response_streaming(bool value) { _internal_set_response_streaming(value); @@ -1269,29 +1260,29 @@ inline void Method::set_response_streaming(bool value) { // repeated .google.protobuf.Option options = 6; inline int Method::_internal_options_size() const { - return options_.size(); + return _impl_.options_.size(); } inline int Method::options_size() const { return _internal_options_size(); } inline ::PROTOBUF_NAMESPACE_ID::Option* Method::mutable_options(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Method.options) - return options_.Mutable(index); + return _impl_.options_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >* Method::mutable_options() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Method.options) - return &options_; + return &_impl_.options_; } inline const ::PROTOBUF_NAMESPACE_ID::Option& Method::_internal_options(int index) const { - return options_.Get(index); + return _impl_.options_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::Option& Method::options(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Method.options) return _internal_options(index); } inline ::PROTOBUF_NAMESPACE_ID::Option* Method::_internal_add_options() { - return options_.Add(); + return _impl_.options_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::Option* Method::add_options() { ::PROTOBUF_NAMESPACE_ID::Option* _add = _internal_add_options(); @@ -1301,15 +1292,15 @@ inline ::PROTOBUF_NAMESPACE_ID::Option* Method::add_options() { inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >& Method::options() const { // @@protoc_insertion_point(field_list:google.protobuf.Method.options) - return options_; + return _impl_.options_; } // .google.protobuf.Syntax syntax = 7; inline void Method::clear_syntax() { - syntax_ = 0; + _impl_.syntax_ = 0; } inline ::PROTOBUF_NAMESPACE_ID::Syntax Method::_internal_syntax() const { - return static_cast< ::PROTOBUF_NAMESPACE_ID::Syntax >(syntax_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::Syntax >(_impl_.syntax_); } inline ::PROTOBUF_NAMESPACE_ID::Syntax Method::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.syntax) @@ -1317,7 +1308,7 @@ inline ::PROTOBUF_NAMESPACE_ID::Syntax Method::syntax() const { } inline void Method::_internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) { - syntax_ = value; + _impl_.syntax_ = value; } inline void Method::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) { _internal_set_syntax(value); @@ -1330,7 +1321,7 @@ inline void Method::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) { // string name = 1; inline void Mixin::clear_name() { - name_.ClearToEmpty(); + _impl_.name_.ClearToEmpty(); } inline const std::string& Mixin::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name) @@ -1340,7 +1331,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Mixin::set_name(ArgT0&& arg0, ArgT... args) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name) } inline std::string* Mixin::mutable_name() { @@ -1349,19 +1340,19 @@ inline std::string* Mixin::mutable_name() { return _s; } inline const std::string& Mixin::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void Mixin::_internal_set_name(const std::string& value) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* Mixin::_internal_mutable_name() { - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* Mixin::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Mixin.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.name_.Release(); } inline void Mixin::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -1369,11 +1360,10 @@ inline void Mixin::set_allocated_name(std::string* name) { } else { } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name) @@ -1381,7 +1371,7 @@ inline void Mixin::set_allocated_name(std::string* name) { // string root = 2; inline void Mixin::clear_root() { - root_.ClearToEmpty(); + _impl_.root_.ClearToEmpty(); } inline const std::string& Mixin::root() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root) @@ -1391,7 +1381,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Mixin::set_root(ArgT0&& arg0, ArgT... args) { - root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.root_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root) } inline std::string* Mixin::mutable_root() { @@ -1400,19 +1390,19 @@ inline std::string* Mixin::mutable_root() { return _s; } inline const std::string& Mixin::_internal_root() const { - return root_.Get(); + return _impl_.root_.Get(); } inline void Mixin::_internal_set_root(const std::string& value) { - root_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.root_.Set(value, GetArenaForAllocation()); } inline std::string* Mixin::_internal_mutable_root() { - return root_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.root_.Mutable(GetArenaForAllocation()); } inline std::string* Mixin::release_root() { // @@protoc_insertion_point(field_release:google.protobuf.Mixin.root) - return root_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.root_.Release(); } inline void Mixin::set_allocated_root(std::string* root) { if (root != nullptr) { @@ -1420,11 +1410,10 @@ inline void Mixin::set_allocated_root(std::string* root) { } else { } - root_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), root, - GetArenaForAllocation()); + _impl_.root_.SetAllocated(root, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (root_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.root_.IsDefault()) { + _impl_.root_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root) diff --git a/r5dev/thirdparty/protobuf/arena.cc b/r5dev/thirdparty/protobuf/arena.cc index 68878282..5df18faa 100644 --- a/r5dev/thirdparty/protobuf/arena.cc +++ b/r5dev/thirdparty/protobuf/arena.cc @@ -38,12 +38,15 @@ #include <typeinfo> #include <thirdparty/protobuf/arena_impl.h> +#include <thirdparty/protobuf/arenaz_sampler.h> +#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/stubs/mutex.h> #ifdef ADDRESS_SANITIZER #include <sanitizer/asan_interface.h> #endif // ADDRESS_SANITIZER +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -91,11 +94,7 @@ class GetDeallocator { if (dealloc_) { dealloc_(mem.ptr, mem.size); } else { -#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) - ::operator delete(mem.ptr, mem.size); -#else - ::operator delete(mem.ptr); -#endif + internal::SizedDelete(mem.ptr, mem.size); } *space_allocated_ += mem.size; } @@ -105,18 +104,22 @@ class GetDeallocator { size_t* space_allocated_; }; -SerialArena::SerialArena(Block* b, void* owner) : space_allocated_(b->size) { +SerialArena::SerialArena(Block* b, void* owner, ThreadSafeArenaStats* stats) + : space_allocated_(b->size) { owner_ = owner; head_ = b; ptr_ = b->Pointer(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize); limit_ = b->Pointer(b->size & static_cast<size_t>(-8)); + arena_stats_ = stats; } -SerialArena* SerialArena::New(Memory mem, void* owner) { +SerialArena* SerialArena::New(Memory mem, void* owner, + ThreadSafeArenaStats* stats) { GOOGLE_DCHECK_LE(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize, mem.size); - + ThreadSafeArenaStats::RecordAllocateStats( + stats, /*requested=*/mem.size, /*allocated=*/mem.size, /*wasted=*/0); auto b = new (mem.ptr) Block{nullptr, mem.size}; - return new (b->Pointer(kBlockHeaderSize)) SerialArena(b, owner); + return new (b->Pointer(kBlockHeaderSize)) SerialArena(b, owner, stats); } template <typename Deallocator> @@ -151,7 +154,14 @@ void SerialArena::AllocateNewBlock(size_t n, const AllocationPolicy* policy) { head_->start = reinterpret_cast<CleanupNode*>(limit_); // Record how much used in this block. - space_used_ += ptr_ - head_->Pointer(kBlockHeaderSize); + size_t used = ptr_ - head_->Pointer(kBlockHeaderSize); + size_t wasted = head_->size - used; + space_used_ += used; + + // TODO(sbenza): Evaluate if pushing unused space into the cached blocks is a + // win. In preliminary testing showed increased memory savings as expected, + // but with a CPU regression. The regression might have been an artifact of + // the microbenchmark. auto mem = AllocateMemory(policy, head_->size, n); // We don't want to emit an expensive RMW instruction that requires @@ -159,6 +169,8 @@ void SerialArena::AllocateNewBlock(size_t n, const AllocationPolicy* policy) { // regular add. auto relaxed = std::memory_order_relaxed; space_allocated_.store(space_allocated_.load(relaxed) + mem.size, relaxed); + ThreadSafeArenaStats::RecordAllocateStats(arena_stats_, /*requested=*/n, + /*allocated=*/mem.size, wasted); head_ = new (mem.ptr) Block{head_, mem.size}; ptr_ = head_->Pointer(kBlockHeaderSize); limit_ = head_->Pointer(head_->size); @@ -312,10 +324,12 @@ void ThreadSafeArena::Init() { #ifndef NDEBUG GOOGLE_CHECK_EQ(was_message_owned, IsMessageOwned()); #endif // NDEBUG + arena_stats_ = Sample(); } void ThreadSafeArena::SetInitialBlock(void* mem, size_t size) { - SerialArena* serial = SerialArena::New({mem, size}, &thread_cache()); + SerialArena* serial = SerialArena::New({mem, size}, &thread_cache(), + arena_stats_.MutableStats()); serial->set_next(NULL); threads_.store(serial, std::memory_order_relaxed); CacheSerialArena(serial); @@ -334,6 +348,10 @@ ThreadSafeArena::~ThreadSafeArena() { ArenaMetricsCollector* collector = p ? p->metrics_collector : nullptr; if (alloc_policy_.is_user_owned_initial_block()) { +#ifdef ADDRESS_SANITIZER + // Unpoison the initial block, now that it's going back to the user. + ASAN_UNPOISON_MEMORY_REGION(mem.ptr, mem.size); +#endif // ADDRESS_SANITIZER space_allocated += mem.size; } else { GetDeallocator(alloc_policy_.get(), &space_allocated)(mem); @@ -360,6 +378,7 @@ uint64_t ThreadSafeArena::Reset() { // Discard all blocks except the special block (if present). size_t space_allocated = 0; auto mem = Free(&space_allocated); + arena_stats_.RecordReset(); AllocationPolicy* policy = alloc_policy_.get(); if (policy) { @@ -474,7 +493,8 @@ SerialArena* ThreadSafeArena::GetSerialArenaFallback(void* me) { // This thread doesn't have any SerialArena, which also means it doesn't // have any blocks yet. So we'll allocate its first block now. serial = SerialArena::New( - AllocateMemory(alloc_policy_.get(), 0, kSerialArenaSize), me); + AllocateMemory(alloc_policy_.get(), 0, kSerialArenaSize), me, + arena_stats_.MutableStats()); SerialArena* head = threads_.load(std::memory_order_relaxed); do { @@ -499,6 +519,12 @@ void* Arena::AllocateAlignedWithHook(size_t n, const std::type_info* type) { return impl_.AllocateAligned(n, type); } +PROTOBUF_FUNC_ALIGN(32) +void* Arena::AllocateAlignedWithHookForArray(size_t n, + const std::type_info* type) { + return impl_.AllocateAligned<internal::AllocationClient::kArray>(n, type); +} + PROTOBUF_FUNC_ALIGN(32) std::pair<void*, internal::SerialArena::CleanupNode*> Arena::AllocateAlignedWithCleanup(size_t n, const std::type_info* type) { diff --git a/r5dev/thirdparty/protobuf/arena.h b/r5dev/thirdparty/protobuf/arena.h index a2eef2f0..942b7f37 100644 --- a/r5dev/thirdparty/protobuf/arena.h +++ b/r5dev/thirdparty/protobuf/arena.h @@ -37,9 +37,6 @@ #include <limits> #include <type_traits> #include <utility> -#ifdef max -#undef max // Visual Studio defines this macro -#endif #if defined(_MSC_VER) && !defined(_LIBCPP_STD_VER) && !_HAS_EXCEPTIONS // Work around bugs in MSVC <typeinfo> header when _HAS_EXCEPTIONS=0. #include <exception> @@ -55,6 +52,7 @@ using type_info = ::type_info; #include <thirdparty/protobuf/arena_impl.h> #include <thirdparty/protobuf/port.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG @@ -83,10 +81,11 @@ class ReflectionTester; // defined in test_util.h namespace internal { -struct ArenaStringPtr; // defined in arenastring.h -class InlinedStringField; // defined in inlined_string_field.h -class LazyField; // defined in lazy_field.h -class EpsCopyInputStream; // defined in parse_context.h +struct ArenaTestPeer; // defined in arena_test_util.h +class InternalMetadata; // defined in metadata_lite.h +class LazyField; // defined in lazy_field.h +class EpsCopyInputStream; // defined in parse_context.h +class RepeatedPtrFieldBase; // defined in repeated_ptr_field.h template <typename Type> class GenericTypeHandler; // defined in repeated_field.h @@ -316,6 +315,20 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { static_cast<Args&&>(args)...); } + // Allocates memory with the specific size and alignment. + void* AllocateAligned(size_t size, size_t align = 8) { + if (align <= 8) { + return AllocateAlignedNoHook(internal::AlignUpTo8(size)); + } else { + // We are wasting space by over allocating align - 8 bytes. Compared + // to a dedicated function that takes current alignment in consideration. + // Such a scheme would only waste (align - 8)/2 bytes on average, but + // requires a dedicated function in the outline arena allocation + // functions. Possibly re-evaluate tradeoffs later. + return internal::AlignTo(AllocateAlignedNoHook(size + align - 8), align); + } + } + // Create an array of object type T on the arena *without* invoking the // constructor of T. If `arena` is null, then the return value should be freed // with `delete[] x;` (or `::operator delete[](x);`). @@ -397,27 +410,12 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { template <typename T> class InternalHelper { - public: + private: // Provides access to protected GetOwningArena to generated messages. static Arena* GetOwningArena(const T* p) { return p->GetOwningArena(); } - // Provides access to protected GetArenaForAllocation to generated messages. - static Arena* GetArenaForAllocation(const T* p) { - return GetArenaForAllocationInternal( - p, std::is_convertible<T*, MessageLite*>()); - } + static void InternalSwap(T* a, T* b) { a->InternalSwap(b); } - // Creates message-owned arena. - static Arena* CreateMessageOwnedArena() { - return new Arena(internal::MessageOwned{}); - } - - // Checks whether the given arena is message-owned. - static bool IsMessageOwnedArena(Arena* arena) { - return arena->IsMessageOwned(); - } - - private: static Arena* GetArenaForAllocationInternal( const T* p, std::true_type /*is_derived_from<MessageLite>*/) { return p->GetArenaForAllocation(); @@ -500,6 +498,29 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { friend class TestUtil::ReflectionTester; }; + // Provides access to protected GetOwningArena to generated messages. For + // internal use only. + template <typename T> + static Arena* InternalGetOwningArena(const T* p) { + return InternalHelper<T>::GetOwningArena(p); + } + + // Provides access to protected GetArenaForAllocation to generated messages. + // For internal use only. + template <typename T> + static Arena* InternalGetArenaForAllocation(const T* p) { + return InternalHelper<T>::GetArenaForAllocationInternal( + p, std::is_convertible<T*, MessageLite*>()); + } + + // Creates message-owned arena. For internal use only. + static Arena* InternalCreateMessageOwnedArena() { + return new Arena(internal::MessageOwned{}); + } + + // Checks whether this arena is message-owned. For internal use only. + bool InternalIsMessageOwnedArena() { return IsMessageOwned(); } + // Helper typetraits that indicates support for arenas in a type T at compile // time. This is public only to allow construction of higher-level templated // utilities. @@ -532,6 +553,10 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { return impl_.IsMessageOwned(); } + void ReturnArrayMemory(void* p, size_t size) { + impl_.ReturnArrayMemory(p, size); + } + template <typename T, typename... Args> PROTOBUF_NDEBUG_INLINE static T* CreateMessageInternal(Arena* arena, Args&&... args) { @@ -622,7 +647,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { // 8 AlignUpTo can be elided. const size_t n = sizeof(T) * num_elements; return static_cast<T*>( - AllocateAlignedWithHook(n, alignof(T), RTTI_TYPE_ID(T))); + AllocateAlignedWithHookForArray(n, alignof(T), RTTI_TYPE_ID(T))); } template <typename T, typename... Args> @@ -765,17 +790,18 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { return nullptr; } - // For friends of arena. - void* AllocateAligned(size_t n, size_t align = 8) { + void* AllocateAlignedWithHookForArray(size_t n, size_t align, + const std::type_info* type) { if (align <= 8) { - return AllocateAlignedNoHook(internal::AlignUpTo8(n)); + return AllocateAlignedWithHookForArray(internal::AlignUpTo8(n), type); } else { // We are wasting space by over allocating align - 8 bytes. Compared // to a dedicated function that takes current alignment in consideration. // Such a scheme would only waste (align - 8)/2 bytes on average, but // requires a dedicated function in the outline arena allocation // functions. Possibly re-evaluate tradeoffs later. - return internal::AlignTo(AllocateAlignedNoHook(n + align - 8), align); + return internal::AlignTo( + AllocateAlignedWithHookForArray(n + align - 8, type), align); } } @@ -786,7 +812,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { } else { // We are wasting space by over allocating align - 8 bytes. Compared // to a dedicated function that takes current alignment in consideration. - // Such a schemee would only waste (align - 8)/2 bytes on average, but + // Such a scheme would only waste (align - 8)/2 bytes on average, but // requires a dedicated function in the outline arena allocation // functions. Possibly re-evaluate tradeoffs later. return internal::AlignTo(AllocateAlignedWithHook(n + align - 8, type), @@ -796,18 +822,22 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { void* AllocateAlignedNoHook(size_t n); void* AllocateAlignedWithHook(size_t n, const std::type_info* type); + void* AllocateAlignedWithHookForArray(size_t n, const std::type_info* type); std::pair<void*, internal::SerialArena::CleanupNode*> AllocateAlignedWithCleanup(size_t n, const std::type_info* type); template <typename Type> friend class internal::GenericTypeHandler; - friend struct internal::ArenaStringPtr; // For AllocateAligned. - friend class internal::InlinedStringField; // For AllocateAligned. + friend class internal::InternalMetadata; // For user_arena(). friend class internal::LazyField; // For CreateMaybeMessage. friend class internal::EpsCopyInputStream; // For parser performance friend class MessageLite; template <typename Key, typename T> friend class Map; + template <typename> + friend class RepeatedField; // For ReturnArrayMemory + friend class internal::RepeatedPtrFieldBase; // For ReturnArrayMemory + friend struct internal::ArenaTestPeer; }; // Defined above for supporting environments without RTTI. diff --git a/r5dev/thirdparty/protobuf/arena_impl.h b/r5dev/thirdparty/protobuf/arena_impl.h index 136c1b7f..6a7d56a3 100644 --- a/r5dev/thirdparty/protobuf/arena_impl.h +++ b/r5dev/thirdparty/protobuf/arena_impl.h @@ -39,11 +39,15 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> +#include <thirdparty/protobuf/stubs/port.h> #ifdef ADDRESS_SANITIZER #include <sanitizer/asan_interface.h> #endif // ADDRESS_SANITIZER +#include <thirdparty/protobuf/arenaz_sampler.h> + +// Must be included last. #include <thirdparty/protobuf/port_def.inc> @@ -51,6 +55,13 @@ namespace google { namespace protobuf { namespace internal { +// To prevent sharing cache lines between threads +#ifdef __cpp_aligned_new +enum { kCacheAlignment = 64 }; +#else +enum { kCacheAlignment = alignof(max_align_t) }; // do the best we can +#endif + inline constexpr size_t AlignUpTo8(size_t n) { // Align n to next multiple of 8 (from Hacker's Delight, Chapter 3.) return (n + 7) & static_cast<size_t>(-8); @@ -177,6 +188,8 @@ class TaggedAllocationPolicyPtr { uintptr_t policy_; }; +enum class AllocationClient { kDefault, kArray }; + // A simple arena allocator. Calls to allocate functions must be properly // serialized by the caller, hence this class cannot be used as a general // purpose allocator in a multi-threaded program. It serves as a building block @@ -208,11 +221,47 @@ class PROTOBUF_EXPORT SerialArena { } uint64_t SpaceUsed() const; - bool HasSpace(size_t n) { return n <= static_cast<size_t>(limit_ - ptr_); } + bool HasSpace(size_t n) const { + return n <= static_cast<size_t>(limit_ - ptr_); + } + // See comments on `cached_blocks_` member for details. + PROTOBUF_ALWAYS_INLINE void* TryAllocateFromCachedBlock(size_t size) { + if (PROTOBUF_PREDICT_FALSE(size < 16)) return nullptr; + // We round up to the next larger block in case the memory doesn't match + // the pattern we are looking for. + const size_t index = Bits::Log2FloorNonZero64(size - 1) - 3; + + if (index >= cached_block_length_) return nullptr; + auto& cached_head = cached_blocks_[index]; + if (cached_head == nullptr) return nullptr; + + void* ret = cached_head; +#ifdef ADDRESS_SANITIZER + ASAN_UNPOISON_MEMORY_REGION(ret, size); +#endif // ADDRESS_SANITIZER + cached_head = cached_head->next; + return ret; + } + + // In kArray mode we look through cached blocks. + // We do not do this by default because most non-array allocations will not + // have the right size and will fail to find an appropriate cached block. + // + // TODO(sbenza): Evaluate if we should use cached blocks for message types of + // the right size. We can statically know if the allocation size can benefit + // from it. + template <AllocationClient alloc_client = AllocationClient::kDefault> void* AllocateAligned(size_t n, const AllocationPolicy* policy) { GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned. GOOGLE_DCHECK_GE(limit_, ptr_); + + if (alloc_client == AllocationClient::kArray) { + if (void* res = TryAllocateFromCachedBlock(n)) { + return res; + } + } + if (PROTOBUF_PREDICT_FALSE(!HasSpace(n))) { return AllocateAlignedFallback(n, policy); } @@ -229,6 +278,50 @@ class PROTOBUF_EXPORT SerialArena { return ret; } + // See comments on `cached_blocks_` member for details. + void ReturnArrayMemory(void* p, size_t size) { + // We only need to check for 32-bit platforms. + // In 64-bit platforms the minimum allocation size from Repeated*Field will + // be 16 guaranteed. + if (sizeof(void*) < 8) { + if (PROTOBUF_PREDICT_FALSE(size < 16)) return; + } else { + GOOGLE_DCHECK(size >= 16); + } + + // We round down to the next smaller block in case the memory doesn't match + // the pattern we are looking for. eg, someone might have called Reserve() + // on the repeated field. + const size_t index = Bits::Log2FloorNonZero64(size) - 4; + + if (PROTOBUF_PREDICT_FALSE(index >= cached_block_length_)) { + // We can't put this object on the freelist so make this object the + // freelist. It is guaranteed it is larger than the one we have, and + // large enough to hold another allocation of `size`. + CachedBlock** new_list = static_cast<CachedBlock**>(p); + size_t new_size = size / sizeof(CachedBlock*); + + std::copy(cached_blocks_, cached_blocks_ + cached_block_length_, + new_list); + std::fill(new_list + cached_block_length_, new_list + new_size, nullptr); + cached_blocks_ = new_list; + // Make the size fit in uint8_t. This is the power of two, so we don't + // need anything larger. + cached_block_length_ = + static_cast<uint8_t>(std::min(size_t{64}, new_size)); + + return; + } + + auto& cached_head = cached_blocks_[index]; + auto* new_node = static_cast<CachedBlock*>(p); + new_node->next = cached_head; + cached_head = new_node; +#ifdef ADDRESS_SANITIZER + ASAN_POISON_MEMORY_REGION(p, size); +#endif // ADDRESS_SANITIZER + } + public: // Allocate space if the current region provides enough space. bool MaybeAllocateAligned(size_t n, void** out) { @@ -279,7 +372,8 @@ class PROTOBUF_EXPORT SerialArena { // Creates a new SerialArena inside mem using the remaining memory as for // future allocations. - static SerialArena* New(SerialArena::Memory mem, void* owner); + static SerialArena* New(SerialArena::Memory mem, void* owner, + ThreadSafeArenaStats* stats); // Free SerialArena returning the memory passed in to New template <typename Deallocator> Memory Free(Deallocator deallocator); @@ -310,10 +404,28 @@ class PROTOBUF_EXPORT SerialArena { // head_ (and head_->pos will always be non-canonical). We keep these // here to reduce indirection. char* ptr_; + // Limiting address up to which memory can be allocated from the head block. char* limit_; + // For holding sampling information. The pointer is owned by the + // ThreadSafeArena that holds this serial arena. + ThreadSafeArenaStats* arena_stats_; + + // Repeated*Field and Arena play together to reduce memory consumption by + // reusing blocks. Currently, natural growth of the repeated field types makes + // them allocate blocks of size `8 + 2^N, N>=3`. + // When the repeated field grows returns the previous block and we put it in + // this free list. + // `cached_blocks_[i]` points to the free list for blocks of size `8+2^(i+3)`. + // The array of freelists is grown when needed in `ReturnArrayMemory()`. + struct CachedBlock { + // Simple linked list. + CachedBlock* next; + }; + uint8_t cached_block_length_ = 0; + CachedBlock** cached_blocks_ = nullptr; // Constructor is private as only New() should be used. - inline SerialArena(Block* b, void* owner); + inline SerialArena(Block* b, void* owner, ThreadSafeArenaStats* stats); void* AllocateAlignedFallback(size_t n, const AllocationPolicy* policy); std::pair<void*, CleanupNode*> AllocateAlignedWithCleanupFallback( size_t n, const AllocationPolicy* policy); @@ -368,26 +480,34 @@ class PROTOBUF_EXPORT ThreadSafeArena { uint64_t SpaceAllocated() const; uint64_t SpaceUsed() const; + template <AllocationClient alloc_client = AllocationClient::kDefault> void* AllocateAligned(size_t n, const std::type_info* type) { SerialArena* arena; if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() && GetSerialArenaFast(&arena))) { - return arena->AllocateAligned(n, AllocPolicy()); + return arena->AllocateAligned<alloc_client>(n, AllocPolicy()); } else { return AllocateAlignedFallback(n, type); } } + void ReturnArrayMemory(void* p, size_t size) { + SerialArena* arena; + if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) { + arena->ReturnArrayMemory(p, size); + } + } + // This function allocates n bytes if the common happy case is true and // returns true. Otherwise does nothing and returns false. This strange // semantics is necessary to allow callers to program functions that only // have fallback function calls in tail position. This substantially improves // code for the happy path. PROTOBUF_NDEBUG_INLINE bool MaybeAllocateAligned(size_t n, void** out) { - SerialArena* a; + SerialArena* arena; if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() && - GetSerialArenaFromThreadCache(&a))) { - return a->MaybeAllocateAligned(n, out); + GetSerialArenaFromThreadCache(&arena))) { + return arena->MaybeAllocateAligned(n, out); } return false; } @@ -411,6 +531,8 @@ class PROTOBUF_EXPORT ThreadSafeArena { TaggedAllocationPolicyPtr alloc_policy_; // Tagged pointer to AllocPolicy. + static_assert(std::is_trivially_destructible<SerialArena>{}, + "SerialArena needs to be trivially destructible."); // Pointer to a linked list of SerialArena. std::atomic<SerialArena*> threads_; std::atomic<SerialArena*> hint_; // Fast thread-local block access @@ -449,7 +571,7 @@ class PROTOBUF_EXPORT ThreadSafeArena { // fast path optimizes the case where a single thread uses multiple arenas. ThreadCache* tc = &thread_cache(); SerialArena* serial = hint_.load(std::memory_order_acquire); - if (PROTOBUF_PREDICT_TRUE(serial != NULL && serial->owner() == tc)) { + if (PROTOBUF_PREDICT_TRUE(serial != nullptr && serial->owner() == tc)) { *arena = serial; return true; } @@ -487,7 +609,7 @@ class PROTOBUF_EXPORT ThreadSafeArena { #ifdef _MSC_VER #pragma warning(disable : 4324) #endif - struct alignas(64) ThreadCache { + struct alignas(kCacheAlignment) ThreadCache { #if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) // If we are using the ThreadLocalStorage class to store the ThreadCache, // then the ThreadCache's default constructor has to be responsible for @@ -495,7 +617,7 @@ class PROTOBUF_EXPORT ThreadSafeArena { ThreadCache() : next_lifecycle_id(0), last_lifecycle_id_seen(-1), - last_serial_arena(NULL) {} + last_serial_arena(nullptr) {} #endif // Number of per-thread lifecycle IDs to reserve. Must be power of two. @@ -518,7 +640,7 @@ class PROTOBUF_EXPORT ThreadSafeArena { #ifdef _MSC_VER #pragma warning(disable : 4324) #endif - struct alignas(64) CacheAlignedLifecycleIdGenerator { + struct alignas(kCacheAlignment) CacheAlignedLifecycleIdGenerator { std::atomic<LifecycleIdAtomic> id; }; static CacheAlignedLifecycleIdGenerator lifecycle_id_generator_; @@ -535,6 +657,8 @@ class PROTOBUF_EXPORT ThreadSafeArena { static ThreadCache& thread_cache() { return thread_cache_; } #endif + ThreadSafeArenaStatsHandle arena_stats_; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ThreadSafeArena); // All protos have pointers back to the arena hence Arena must have // pointer stability. diff --git a/r5dev/thirdparty/protobuf/arena_test_util.cc b/r5dev/thirdparty/protobuf/arena_test_util.cc index 6dde81fa..b0c60693 100644 --- a/r5dev/thirdparty/protobuf/arena_test_util.cc +++ b/r5dev/thirdparty/protobuf/arena_test_util.cc @@ -29,6 +29,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <thirdparty/protobuf/arena_test_util.h> + #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> diff --git a/r5dev/thirdparty/protobuf/arena_test_util.h b/r5dev/thirdparty/protobuf/arena_test_util.h index 83bf5fe3..005d4331 100644 --- a/r5dev/thirdparty/protobuf/arena_test_util.h +++ b/r5dev/thirdparty/protobuf/arena_test_util.h @@ -33,9 +33,9 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> +#include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> -#include <thirdparty/protobuf/arena.h> namespace google { namespace protobuf { @@ -76,6 +76,12 @@ void TestParseCorruptedString(const T& message) { namespace internal { +struct ArenaTestPeer { + static void ReturnArrayMemory(Arena* arena, void* p, size_t size) { + arena->ReturnArrayMemory(p, size); + } +}; + class NoHeapChecker { public: NoHeapChecker() { capture_alloc.Hook(); } diff --git a/r5dev/thirdparty/protobuf/arena_unittest.cc b/r5dev/thirdparty/protobuf/arena_unittest.cc index 9bfab708..796fa6fe 100644 --- a/r5dev/thirdparty/protobuf/arena_unittest.cc +++ b/r5dev/thirdparty/protobuf/arena_unittest.cc @@ -41,27 +41,29 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/arena_test_util.h> -#include <thirdparty/protobuf/test_util.h> #include <thirdparty/protobuf/unittest.pb.h> #include <thirdparty/protobuf/unittest_arena.pb.h> -#include <thirdparty/protobuf/io/coded_stream.h> -#include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> +#include <gmock/gmock.h> +#include <gtest/gtest.h> +#include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/arena_test_util.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/extension_set.h> +#include <thirdparty/protobuf/io/coded_stream.h> +#include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> #include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/message_lite.h> #include <thirdparty/protobuf/repeated_field.h> +#include <thirdparty/protobuf/test_util.h> #include <thirdparty/protobuf/unknown_field_set.h> #include <thirdparty/protobuf/wire_format_lite.h> -#include <gtest/gtest.h> -#include <thirdparty/protobuf/stubs/strutil.h> // Must be included last #include <thirdparty/protobuf/port_def.inc> using proto2_arena_unittest::ArenaMessage; +using protobuf_unittest::ForeignMessage; using protobuf_unittest::TestAllExtensions; using protobuf_unittest::TestAllTypes; using protobuf_unittest::TestEmptyMessage; @@ -542,6 +544,16 @@ TEST(ArenaTest, UnsafeArenaSwap) { TestUtil::ExpectAllFieldsSet(*message2); } +TEST(ArenaTest, GetOwningArena) { + Arena arena; + auto* m1 = Arena::CreateMessage<TestAllTypes>(&arena); + EXPECT_EQ(Arena::InternalGetOwningArena(m1), &arena); + EXPECT_EQ(&arena, Arena::InternalGetOwningArena( + m1->mutable_repeated_foreign_message())); + EXPECT_EQ(&arena, + Arena::InternalGetOwningArena(m1->mutable_repeated_int32())); +} + TEST(ArenaTest, SwapBetweenArenasUsingReflection) { Arena arena1; TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1); @@ -1465,6 +1477,71 @@ TEST(ArenaTest, AddCleanup) { } } +TEST(ArenaTest, SpaceReuseForArraysSizeChecks) { + // Limit to 1<<20 to avoid using too much memory on the test. + for (int i = 0; i < 20; ++i) { + SCOPED_TRACE(i); + Arena arena; + std::vector<void*> pointers; + + const size_t size = 16 << i; + + for (int j = 0; j < 10; ++j) { + pointers.push_back(Arena::CreateArray<char>(&arena, size)); + } + + for (void* p : pointers) { + internal::ArenaTestPeer::ReturnArrayMemory(&arena, p, size); + } + + std::vector<void*> second_pointers; + for (int j = 9; j != 0; --j) { + second_pointers.push_back(Arena::CreateArray<char>(&arena, size)); + } + + // The arena will give us back the pointers we returned, except the first + // one. That one becomes part of the freelist data structure. + ASSERT_THAT(second_pointers, + testing::UnorderedElementsAreArray( + std::vector<void*>(pointers.begin() + 1, pointers.end()))); + } +} + +TEST(ArenaTest, SpaceReusePoisonsAndUnpoisonsMemory) { +#ifdef ADDRESS_SANITIZER + char buf[1024]{}; + { + Arena arena(buf, sizeof(buf)); + std::vector<void*> pointers; + for (int i = 0; i < 100; ++i) { + pointers.push_back(Arena::CreateArray<char>(&arena, 16)); + } + for (void* p : pointers) { + internal::ArenaTestPeer::ReturnArrayMemory(&arena, p, 16); + // The first one is not poisoned because it becomes the freelist. + if (p != pointers[0]) EXPECT_TRUE(__asan_address_is_poisoned(p)); + } + + bool found_poison = false; + for (char& c : buf) { + if (__asan_address_is_poisoned(&c)) { + found_poison = true; + break; + } + } + EXPECT_TRUE(found_poison); + } + + // Should not be poisoned after destruction. + for (char& c : buf) { + ASSERT_FALSE(__asan_address_is_poisoned(&c)); + } + +#else // ADDRESS_SANITIZER + GTEST_SKIP(); +#endif // ADDRESS_SANITIZER +} + namespace { uint32_t hooks_num_init = 0; uint32_t hooks_num_allocations = 0; diff --git a/r5dev/thirdparty/protobuf/arenastring.cc b/r5dev/thirdparty/protobuf/arenastring.cc index 022ba369..1b9e8606 100644 --- a/r5dev/thirdparty/protobuf/arenastring.cc +++ b/r5dev/thirdparty/protobuf/arenastring.cc @@ -30,13 +30,14 @@ #include <thirdparty/protobuf/arenastring.h> +#include <cstddef> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/coded_stream.h> -#include <thirdparty/protobuf/message_lite.h> #include <thirdparty/protobuf/stubs/mutex.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/message_lite.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/stubs/stl_util.h> // clang-format off @@ -47,6 +48,28 @@ namespace google { namespace protobuf { namespace internal { +namespace { + +// TaggedStringPtr::Flags uses the lower 2 bits as tags. +// Enforce that allocated data aligns to at least 4 bytes, and that +// the alignment of the global const string value does as well. +// The alignment guaranteed by `new std::string` depends on both: +// - new align = __STDCPP_DEFAULT_NEW_ALIGNMENT__ / max_align_t +// - alignof(std::string) +#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__ +constexpr size_t kNewAlign = __STDCPP_DEFAULT_NEW_ALIGNMENT__; +#elif (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900 +constexpr size_t kNewAlign = alignof(::max_align_t); +#else +constexpr size_t kNewAlign = alignof(std::max_align_t); +#endif +constexpr size_t kStringAlign = alignof(std::string); + +static_assert((kStringAlign > kNewAlign ? kStringAlign : kNewAlign) >= 4, ""); +static_assert(alignof(ExplicitlyConstructedArenaString) >= 4, ""); + +} // namespace + const std::string& LazyString::Init() const { static WrappedMutex mu{GOOGLE_PROTOBUF_LINKER_INITIALIZED}; mu.Lock(); @@ -61,185 +84,150 @@ const std::string& LazyString::Init() const { return *res; } +namespace { -std::string* ArenaStringPtr::SetAndReturnNewString() { - std::string* new_string = new std::string(); - tagged_ptr_.Set(new_string); - return new_string; + +#if defined(NDEBUG) || !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL + +class ScopedCheckPtrInvariants { + public: + explicit ScopedCheckPtrInvariants(const TaggedStringPtr*) {} +}; + +#endif // NDEBUG || !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL + +// Creates a heap allocated std::string value. +inline TaggedStringPtr CreateString(ConstStringParam value) { + TaggedStringPtr res; + res.SetAllocated(new std::string(value.data(), value.length())); + return res; } -void ArenaStringPtr::DestroyNoArenaSlowPath() { delete UnsafeMutablePointer(); } +#if !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL -void ArenaStringPtr::Set(const std::string* default_value, - ConstStringParam value, ::google::protobuf::Arena* arena) { - if (IsDefault(default_value)) { - tagged_ptr_.Set(Arena::Create<std::string>(arena, value)); +// Creates an arena allocated std::string value. +TaggedStringPtr CreateArenaString(Arena& arena, ConstStringParam s) { + TaggedStringPtr res; + res.SetMutableArena(Arena::Create<std::string>(&arena, s.data(), s.length())); + return res; +} + +#endif // !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL + +} // namespace + +void ArenaStringPtr::Set(ConstStringParam value, Arena* arena) { + ScopedCheckPtrInvariants check(&tagged_ptr_); + if (IsDefault()) { + // If we're not on an arena, skip straight to a true string to avoid + // possible copy cost later. + tagged_ptr_ = arena != nullptr ? CreateArenaString(*arena, value) + : CreateString(value); } else { UnsafeMutablePointer()->assign(value.data(), value.length()); } } -void ArenaStringPtr::Set(const std::string* default_value, std::string&& value, - ::google::protobuf::Arena* arena) { - if (IsDefault(default_value)) { - if (arena == nullptr) { - tagged_ptr_.Set(new std::string(std::move(value))); - } else { - tagged_ptr_.Set(Arena::Create<std::string>(arena, std::move(value))); - } - } else if (IsDonatedString()) { +void ArenaStringPtr::Set(std::string&& value, Arena* arena) { + ScopedCheckPtrInvariants check(&tagged_ptr_); + if (IsDefault()) { + NewString(arena, std::move(value)); + } else if (IsFixedSizeArena()) { std::string* current = tagged_ptr_.Get(); auto* s = new (current) std::string(std::move(value)); arena->OwnDestructor(s); - tagged_ptr_.Set(s); - } else /* !IsDonatedString() */ { + tagged_ptr_.SetMutableArena(s); + } else /* !IsFixedSizeArena() */ { *UnsafeMutablePointer() = std::move(value); } } -void ArenaStringPtr::Set(EmptyDefault, ConstStringParam value, - ::google::protobuf::Arena* arena) { - Set(&GetEmptyStringAlreadyInited(), value, arena); -} - -void ArenaStringPtr::Set(EmptyDefault, std::string&& value, - ::google::protobuf::Arena* arena) { - Set(&GetEmptyStringAlreadyInited(), std::move(value), arena); -} - -void ArenaStringPtr::Set(NonEmptyDefault, ConstStringParam value, - ::google::protobuf::Arena* arena) { - Set(nullptr, value, arena); -} - -void ArenaStringPtr::Set(NonEmptyDefault, std::string&& value, - ::google::protobuf::Arena* arena) { - Set(nullptr, std::move(value), arena); -} - -std::string* ArenaStringPtr::Mutable(EmptyDefault, ::google::protobuf::Arena* arena) { - if (!IsDonatedString() && !IsDefault(&GetEmptyStringAlreadyInited())) { - return UnsafeMutablePointer(); +std::string* ArenaStringPtr::Mutable(Arena* arena) { + ScopedCheckPtrInvariants check(&tagged_ptr_); + if (tagged_ptr_.IsMutable()) { + return tagged_ptr_.Get(); } else { return MutableSlow(arena); } } std::string* ArenaStringPtr::Mutable(const LazyString& default_value, - ::google::protobuf::Arena* arena) { - if (!IsDonatedString() && !IsDefault(nullptr)) { - return UnsafeMutablePointer(); + Arena* arena) { + ScopedCheckPtrInvariants check(&tagged_ptr_); + if (tagged_ptr_.IsMutable()) { + return tagged_ptr_.Get(); } else { return MutableSlow(arena, default_value); } } -std::string* ArenaStringPtr::MutableNoCopy(const std::string* default_value, - ::google::protobuf::Arena* arena) { - if (!IsDonatedString() && !IsDefault(default_value)) { - return UnsafeMutablePointer(); +std::string* ArenaStringPtr::MutableNoCopy(Arena* arena) { + ScopedCheckPtrInvariants check(&tagged_ptr_); + if (tagged_ptr_.IsMutable()) { + return tagged_ptr_.Get(); } else { - GOOGLE_DCHECK(IsDefault(default_value)); + GOOGLE_DCHECK(IsDefault()); // Allocate empty. The contents are not relevant. - std::string* new_string = Arena::Create<std::string>(arena); - tagged_ptr_.Set(new_string); - return new_string; + return NewString(arena); } } template <typename... Lazy> std::string* ArenaStringPtr::MutableSlow(::google::protobuf::Arena* arena, const Lazy&... lazy_default) { - const std::string* const default_value = - sizeof...(Lazy) == 0 ? &GetEmptyStringAlreadyInited() : nullptr; - GOOGLE_DCHECK(IsDefault(default_value)); - std::string* new_string = - Arena::Create<std::string>(arena, lazy_default.get()...); - tagged_ptr_.Set(new_string); - return new_string; + GOOGLE_DCHECK(IsDefault()); + + // For empty defaults, this ends up calling the default constructor which is + // more efficient than a copy construction from + // GetEmptyStringAlreadyInited(). + return NewString(arena, lazy_default.get()...); } -std::string* ArenaStringPtr::Release(const std::string* default_value, - ::google::protobuf::Arena* arena) { - if (IsDefault(default_value)) { - return nullptr; - } else { - return ReleaseNonDefault(default_value, arena); +std::string* ArenaStringPtr::Release() { + ScopedCheckPtrInvariants check(&tagged_ptr_); + if (IsDefault()) return nullptr; + + std::string* released = tagged_ptr_.Get(); + if (tagged_ptr_.IsArena()) { + released = tagged_ptr_.IsMutable() ? new std::string(std::move(*released)) + : new std::string(*released); } + InitDefault(); + return released; } -std::string* ArenaStringPtr::ReleaseNonDefault(const std::string* default_value, - ::google::protobuf::Arena* arena) { - GOOGLE_DCHECK(!IsDefault(default_value)); - - if (!IsDonatedString()) { - std::string* released; - if (arena != nullptr) { - released = new std::string; - released->swap(*UnsafeMutablePointer()); - } else { - released = UnsafeMutablePointer(); - } - tagged_ptr_.Set(const_cast<std::string*>(default_value)); - return released; - } else /* IsDonatedString() */ { - GOOGLE_DCHECK(arena != nullptr); - std::string* released = new std::string(Get()); - tagged_ptr_.Set(const_cast<std::string*>(default_value)); - return released; - } -} - -void ArenaStringPtr::SetAllocated(const std::string* default_value, - std::string* value, ::google::protobuf::Arena* arena) { +void ArenaStringPtr::SetAllocated(std::string* value, Arena* arena) { + ScopedCheckPtrInvariants check(&tagged_ptr_); // Release what we have first. - if (arena == nullptr && !IsDefault(default_value)) { - delete UnsafeMutablePointer(); - } + Destroy(); + if (value == nullptr) { - tagged_ptr_.Set(const_cast<std::string*>(default_value)); + InitDefault(); } else { -#ifdef NDEBUG - tagged_ptr_.Set(value); - if (arena != nullptr) { - arena->Own(value); - } -#else +#ifndef NDEBUG // On debug builds, copy the string so the address differs. delete will // fail if value was a stack-allocated temporary/etc., which would have // failed when arena ran its cleanup list. - std::string* new_value = Arena::Create<std::string>(arena, *value); + std::string* new_value = new std::string(std::move(*value)); delete value; - tagged_ptr_.Set(new_value); -#endif + value = new_value; +#endif // !NDEBUG + InitAllocated(value, arena); } } -void ArenaStringPtr::Destroy(const std::string* default_value, - ::google::protobuf::Arena* arena) { - if (arena == nullptr) { - GOOGLE_DCHECK(!IsDonatedString()); - if (!IsDefault(default_value)) { - delete UnsafeMutablePointer(); - } - } -} - -void ArenaStringPtr::Destroy(EmptyDefault, ::google::protobuf::Arena* arena) { - Destroy(&GetEmptyStringAlreadyInited(), arena); -} - -void ArenaStringPtr::Destroy(NonEmptyDefault, ::google::protobuf::Arena* arena) { - Destroy(nullptr, arena); +void ArenaStringPtr::Destroy() { + delete tagged_ptr_.GetIfAllocated(); } void ArenaStringPtr::ClearToEmpty() { - if (IsDefault(&GetEmptyStringAlreadyInited())) { + ScopedCheckPtrInvariants check(&tagged_ptr_); + if (IsDefault()) { // Already set to default -- do nothing. } else { // Unconditionally mask away the tag. // - // UpdateDonatedString uses assign when capacity is larger than the new + // UpdateArenaString uses assign when capacity is larger than the new // value, which is trivially true in the donated string case. // const_cast<std::string*>(PtrValue<std::string>())->clear(); tagged_ptr_.Get()->clear(); @@ -248,34 +236,27 @@ void ArenaStringPtr::ClearToEmpty() { void ArenaStringPtr::ClearToDefault(const LazyString& default_value, ::google::protobuf::Arena* arena) { + ScopedCheckPtrInvariants check(&tagged_ptr_); (void)arena; - if (IsDefault(nullptr)) { + if (IsDefault()) { // Already set to default -- do nothing. - } else if (!IsDonatedString()) { + } else { UnsafeMutablePointer()->assign(default_value.get()); } } -inline void SetStrWithHeapBuffer(std::string* str, ArenaStringPtr* s) { - TaggedPtr<std::string> res; - res.Set(str); - s->UnsafeSetTaggedPointer(res); -} - const char* EpsCopyInputStream::ReadArenaString(const char* ptr, ArenaStringPtr* s, Arena* arena) { + ScopedCheckPtrInvariants check(&s->tagged_ptr_); GOOGLE_DCHECK(arena != nullptr); int size = ReadSize(&ptr); if (!ptr) return nullptr; - auto* str = Arena::Create<std::string>(arena); + auto* str = s->NewString(arena); ptr = ReadString(ptr, size, str); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - - SetStrWithHeapBuffer(str, s); - return ptr; } diff --git a/r5dev/thirdparty/protobuf/arenastring.h b/r5dev/thirdparty/protobuf/arenastring.h index 7450986e..ca38b6f7 100644 --- a/r5dev/thirdparty/protobuf/arenastring.h +++ b/r5dev/thirdparty/protobuf/arenastring.h @@ -31,6 +31,7 @@ #ifndef GOOGLE_PROTOBUF_ARENASTRING_H__ #define GOOGLE_PROTOBUF_ARENASTRING_H__ +#include <algorithm> #include <string> #include <type_traits> #include <utility> @@ -39,7 +40,9 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/port.h> +#include <thirdparty/protobuf/explicitly_constructed.h> +// must be last: #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG @@ -50,12 +53,14 @@ namespace google { namespace protobuf { namespace internal { - -template <typename T> -class ExplicitlyConstructed; +class EpsCopyInputStream; class SwapFieldHelper; +// Declared in message_lite.h +PROTOBUF_EXPORT extern ExplicitlyConstructedArenaString + fixed_address_empty_string; + // Lazy string instance to support string fields with non-empty default. // These are initialized on the first call to .get(). class PROTOBUF_EXPORT LazyString { @@ -89,182 +94,229 @@ class PROTOBUF_EXPORT LazyString { const std::string& Init() const; }; -template <typename T> -class TaggedPtr { +class TaggedStringPtr { public: - TaggedPtr() = default; - explicit constexpr TaggedPtr(const ExplicitlyConstructed<std::string>* ptr) - : ptr_(const_cast<ExplicitlyConstructed<std::string>*>(ptr)) {} + // Bit flags qualifying string properties. We can use 2 bits as + // ptr_ is guaranteed and enforced to be aligned on 4 byte boundaries. + enum Flags { + kArenaBit = 0x1, // ptr is arena allocated + kMutableBit = 0x2, // ptr contents are fully mutable + kMask = 0x3 // Bit mask + }; - void SetTagged(T* p) { - Set(p); - ptr_ = reinterpret_cast<void*>(as_int() | 1); + // Composed logical types + enum Type { + // Default strings are immutable and never owned. + kDefault = 0, + + // Allocated strings are mutable and (as the name implies) owned. + // A heap allocated string must be deleted. + kAllocated = kMutableBit, + + // Mutable arena strings are strings where the string instance is owned + // by the arena, but the string contents itself are owned by the string + // instance. Mutable arena string instances need to be destroyed which is + // typically done through a cleanup action added to the arena owning it. + kMutableArena = kArenaBit | kMutableBit, + + // Fixed size arena strings are strings where both the string instance and + // the string contents are fully owned by the arena. Fixed size arena + // strings are a platform and c++ library specific customization. Fixed + // size arena strings are immutable, with the exception of custom internal + // updates to the content that fit inside the existing capacity. + // Fixed size arena strings must never be deleted or destroyed. + kFixedSizeArena = kArenaBit, + }; + + TaggedStringPtr() = default; + explicit constexpr TaggedStringPtr(ExplicitlyConstructedArenaString* ptr) + : ptr_(ptr) {} + + // Sets the value to `p`, tagging the value as being a 'default' value. + // See documentation for kDefault for more info. + inline const std::string* SetDefault(const std::string* p) { + return TagAs(kDefault, const_cast<std::string*>(p)); } - void Set(T* p) { ptr_ = p; } - T* Get() const { return reinterpret_cast<T*>(as_int() & -2); } - bool IsTagged() const { return as_int() & 1; } - // Returned value is only safe to dereference if IsTagged() == false. - // It is safe to compare. - T* UnsafeGet() const { return static_cast<T*>(ptr_); } + // Sets the value to `p`, tagging the value as a heap allocated value. + // Allocated strings are mutable and (as the name implies) owned. + // `p` must not be null + inline std::string* SetAllocated(std::string* p) { + return TagAs(kAllocated, p); + } - bool IsNull() { return ptr_ == nullptr; } + // Sets the value to `p`, tagging the value as a fixed size arena string. + // See documentation for kFixedSizeArena for more info. + // `p` must not be null + inline std::string* SetFixedSizeArena(std::string* p) { + return TagAs(kFixedSizeArena, p); + } + + // Sets the value to `p`, tagging the value as a mutable arena string. + // See documentation for kMutableArena for more info. + // `p` must not be null + inline std::string* SetMutableArena(std::string* p) { + return TagAs(kMutableArena, p); + } + + // Returns true if the contents of the current string are fully mutable. + inline bool IsMutable() const { return as_int() & kMutableBit; } + + // Returns true if the current string is an immutable default value. + inline bool IsDefault() const { return (as_int() & kMask) == kDefault; } + + // If the current string is a heap-allocated mutable value, returns a pointer + // to it. Returns nullptr otherwise. + inline std::string *GetIfAllocated() const { + auto allocated = as_int() ^ kAllocated; + if (allocated & kMask) return nullptr; + + auto ptr = reinterpret_cast<std::string*>(allocated); + PROTOBUF_ASSUME(ptr != nullptr); + return ptr; + } + + // Returns true if the current string is an arena allocated value. + // This means it's either a mutable or fixed size arena string. + inline bool IsArena() const { return as_int() & kArenaBit; } + + // Returns true if the current string is a fixed size arena allocated value. + inline bool IsFixedSizeArena() const { + return (as_int() & kMask) == kFixedSizeArena; + } + + // Returns the contained string pointer. + inline std::string* Get() const { + return reinterpret_cast<std::string*>(as_int() & ~kMask); + } + + // Returns true if the contained pointer is null, indicating some error. + // The Null value is only used during parsing for temporary values. + // A persisted ArenaStringPtr value is never null. + inline bool IsNull() { return ptr_ == nullptr; } private: + static inline void assert_aligned(const void* p) { + GOOGLE_DCHECK_EQ(reinterpret_cast<uintptr_t>(p) & kMask, 0UL); + } + + inline std::string* TagAs(Type type, std::string* p) { + GOOGLE_DCHECK(p != nullptr); + assert_aligned(p); + ptr_ = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(p) | type); + return p; + } + uintptr_t as_int() const { return reinterpret_cast<uintptr_t>(ptr_); } void* ptr_; }; -static_assert(std::is_trivial<TaggedPtr<std::string>>::value, - "TaggedPtr must be trivial"); +static_assert(std::is_trivial<TaggedStringPtr>::value, + "TaggedStringPtr must be trivial"); -// This class encapsulates a pointer to a std::string with or without a donated -// buffer, tagged by bottom bit. It is a high-level wrapper that almost directly -// corresponds to the interface required by string fields in generated -// code. It replaces the old std::string* pointer in such cases. +// This class encapsulates a pointer to a std::string with or without arena +// owned contents, tagged by the bottom bits of the string pointer. It is a +// high-level wrapper that almost directly corresponds to the interface required +// by string fields in generated code. It replaces the old std::string* pointer +// in such cases. // -// The object has different but similar code paths for when the default value is -// the empty string and when it is a non-empty string. -// The empty string is handled different throughout the library and there is a -// single global instance of it we can share. +// The string pointer is tagged to be either a default, externally owned value, +// a mutable heap allocated value, or an arena allocated value. The object uses +// a single global instance of an empty string that is used as the initial +// default value. Fields that have empty default values directly use this global +// default. Fields that have non empty default values are supported through +// lazily initialized default values managed by the LazyString class. // -// For fields with an empty string default value, there are three distinct -// states: -// -// - Pointer set to 'String' tag (LSB is 0), equal to -// &GetEmptyStringAlreadyInited(): field is set to its default value. Points -// to a true std::string*, but we do not own that std::string* (it's a -// globally shared instance). -// -// - Pointer set to 'String' tag (LSB is 0), but not equal to the global empty -// string: field points to a true std::string* instance that we own. This -// instance is either on the heap or on the arena (i.e. registered on -// free()/destructor-call list) as appropriate. -// -// - Pointer set to 'DonatedString' tag (LSB is 1): points to a std::string -// instance with a buffer on the arena (arena is never nullptr in this case). -// -// For fields with a non-empty string default value, there are three distinct -// states: -// -// - Pointer set to 'String' tag (LSB is 0), equal to `nullptr`: -// Field is in "default" mode and does not point to any actual instance. -// Methods that might need to create an instance of the object will pass a -// `const LazyString&` for it. -// -// - Pointer set to 'String' tag (LSB is 0), but not equal to `nullptr`: -// field points to a true std::string* instance that we own. This instance is -// either on the heap or on the arena (i.e. registered on -// free()/destructor-call list) as appropriate. -// -// - Pointer set to 'DonatedString' tag (LSB is 1): points to a std::string -// instance with a buffer on the arena (arena is never nullptr in this case). -// -// Generated code and reflection code both ensure that ptr_ is never null for -// fields with an empty default. +// Generated code and reflection code both ensure that ptr_ is never null. // Because ArenaStringPtr is used in oneof unions, its constructor is a NOP and -// so the field is always manually initialized via method calls. +// the field is always manually initialized via method calls. // -// Side-note: why pass information about the default on every API call? Because -// we don't want to hold it in a member variable, or else this would go into -// every proto message instance. This would be a huge waste of space, since the -// default instance pointer is typically a global (static class field). We want -// the generated code to be as efficient as possible, and if we take -// the default value information as a parameter that's in practice taken from a -// static class field, and compare ptr_ to the default value, we end up with a -// single "cmp %reg, GLOBAL" in the resulting machine code. (Note that this also -// requires the String tag to be 0 so we can avoid the mask before comparing.) +// See TaggedStringPtr for more information about the types of string values +// being held, and the mutable and ownership invariants for each type. struct PROTOBUF_EXPORT ArenaStringPtr { ArenaStringPtr() = default; - explicit constexpr ArenaStringPtr( - const ExplicitlyConstructed<std::string>* default_value) + constexpr ArenaStringPtr(ExplicitlyConstructedArenaString* default_value, + ConstantInitialized) : tagged_ptr_(default_value) {} - // Some methods below are overloaded on a `default_value` and on tags. - // The tagged overloads help reduce code size in the callers in generated - // code, while the `default_value` overloads are useful from reflection. - // By-value empty struct arguments are elided in the ABI. - struct EmptyDefault {}; - struct NonEmptyDefault {}; + // Called from generated code / reflection runtime only. Resets value to point + // to a default string pointer, with the semantics that this ArenaStringPtr + // does not own the pointed-to memory. Disregards initial value of ptr_ (so + // this is the *ONLY* safe method to call after construction or when + // reinitializing after becoming the active field in a oneof union). + inline void InitDefault(); - void Set(const std::string* default_value, ConstStringParam value, - ::google::protobuf::Arena* arena); - void Set(const std::string* default_value, std::string&& value, - ::google::protobuf::Arena* arena); - void Set(EmptyDefault, ConstStringParam value, ::google::protobuf::Arena* arena); - void Set(EmptyDefault, std::string&& value, ::google::protobuf::Arena* arena); - void Set(NonEmptyDefault, ConstStringParam value, ::google::protobuf::Arena* arena); - void Set(NonEmptyDefault, std::string&& value, ::google::protobuf::Arena* arena); - template <typename FirstParam> - void Set(FirstParam p1, const char* str, ::google::protobuf::Arena* arena) { - Set(p1, ConstStringParam(str), arena); - } - template <typename FirstParam> - void Set(FirstParam p1, const char* str, size_t size, + // Similar to `InitDefault` except that it allows the default value to be + // initialized to an externally owned string. This method is called from + // parsing code. `str` must not be null and outlive this instance. + inline void InitExternal(const std::string* str); + + // Called from generated code / reflection runtime only. Resets the value of + // this instances to the heap allocated value in `str`. `str` must not be + // null. Invokes `arena->Own(str)` to transfer ownership into the arena if + // `arena` is not null, else, `str` will be owned by ArenaStringPtr. This + // function should only be used to initialize a ArenaStringPtr or on an + // instance known to not carry any heap allocated value. + inline void InitAllocated(std::string* str, Arena* arena); + + void Set(ConstStringParam value, Arena* arena); + void Set(std::string&& value, Arena* arena); + void Set(const char* s, Arena* arena); + void Set(const char* s, size_t n, Arena* arena); + + void SetBytes(ConstStringParam value, Arena* arena); + void SetBytes(std::string&& value, Arena* arena); + void SetBytes(const char* s, Arena* arena); + void SetBytes(const void* p, size_t n, Arena* arena); + + template <typename RefWrappedType> + void Set(std::reference_wrapper<RefWrappedType> const_string_ref, ::google::protobuf::Arena* arena) { - ConstStringParam sp{str, size}; // for string_view and `const string &` - Set(p1, sp, arena); - } - template <typename FirstParam, typename RefWrappedType> - void Set(FirstParam p1, - std::reference_wrapper<RefWrappedType> const_string_ref, - ::google::protobuf::Arena* arena) { - Set(p1, const_string_ref.get(), arena); + Set(const_string_ref.get(), arena); } - template <typename FirstParam, typename SecondParam> - void SetBytes(FirstParam p1, SecondParam&& p2, ::google::protobuf::Arena* arena) { - Set(p1, static_cast<SecondParam&&>(p2), arena); - } - template <typename FirstParam> - void SetBytes(FirstParam p1, const void* str, size_t size, - ::google::protobuf::Arena* arena) { - // must work whether ConstStringParam is string_view or `const string &` - ConstStringParam sp{static_cast<const char*>(str), size}; - Set(p1, sp, arena); - } + // Returns a mutable std::string reference. + // The version accepting a `LazyString` value is used in the generated code to + // initialize mutable copies for fields with a non-empty default where the + // default value is lazily initialized. + std::string* Mutable(Arena* arena); + std::string* Mutable(const LazyString& default_value, Arena* arena); + + // Gets a mutable pointer with unspecified contents. + // This function is identical to Mutable(), except it is optimized for the + // case where the caller is not interested in the current contents. For + // example, if the current field is not mutable, it will re-initialize the + // value with an empty string rather than a (non-empty) default value. + // Likewise, if the current value is a fixed size arena string with contents, + // it will be initialized into an empty mutable arena string. + std::string* MutableNoCopy(Arena* arena); // Basic accessors. PROTOBUF_NDEBUG_INLINE const std::string& Get() const { // Unconditionally mask away the tag. return *tagged_ptr_.Get(); } - PROTOBUF_NDEBUG_INLINE const std::string* GetPointer() const { - // Unconditionally mask away the tag. + + // Returns a pointer to the stored contents for this instance. + // This method is for internal debugging and tracking purposes only. + PROTOBUF_NDEBUG_INLINE const std::string* UnsafeGetPointer() const + PROTOBUF_RETURNS_NONNULL { return tagged_ptr_.Get(); } - // For fields with an empty default value. - std::string* Mutable(EmptyDefault, ::google::protobuf::Arena* arena); - // For fields with a non-empty default value. - std::string* Mutable(const LazyString& default_value, ::google::protobuf::Arena* arena); - // Release returns a std::string* instance that is heap-allocated and is not // Own()'d by any arena. If the field is not set, this returns nullptr. The - // caller retains ownership. Clears this field back to nullptr state. Used to - // implement release_<field>() methods on generated classes. - PROTOBUF_NODISCARD std::string* Release(const std::string* default_value, - ::google::protobuf::Arena* arena); - PROTOBUF_NODISCARD std::string* ReleaseNonDefault( - const std::string* default_value, ::google::protobuf::Arena* arena); + // caller retains ownership. Clears this field back to the default state. + // Used to implement release_<field>() methods on generated classes. + PROTOBUF_NODISCARD std::string* Release(); // Takes a std::string that is heap-allocated, and takes ownership. The // std::string's destructor is registered with the arena. Used to implement // set_allocated_<field> in generated classes. - void SetAllocated(const std::string* default_value, std::string* value, - ::google::protobuf::Arena* arena); - - // Swaps internal pointers. Arena-safety semantics: this is guarded by the - // logic in Swap()/UnsafeArenaSwap() at the message level, so this method is - // 'unsafe' if called directly. - inline PROTOBUF_NDEBUG_INLINE static void InternalSwap( - const std::string* default_value, ArenaStringPtr* rhs, Arena* rhs_arena, - ArenaStringPtr* lhs, Arena* lhs_arena); + void SetAllocated(std::string* value, Arena* arena); // Frees storage (if not on an arena). - void Destroy(const std::string* default_value, ::google::protobuf::Arena* arena); - void Destroy(EmptyDefault, ::google::protobuf::Arena* arena); - void Destroy(NonEmptyDefault, ::google::protobuf::Arena* arena); + void Destroy(); // Clears content, but keeps allocated std::string, to avoid the overhead of // heap operations. After this returns, the content (as seen by the user) will @@ -281,48 +333,40 @@ struct PROTOBUF_EXPORT ArenaStringPtr { // (as seen by the user) will always be equal to |default_value|. void ClearToDefault(const LazyString& default_value, ::google::protobuf::Arena* arena); - // Called from generated code / reflection runtime only. Resets value to point - // to a default string pointer, with the semantics that this - // ArenaStringPtr does not own the pointed-to memory. Disregards initial value - // of ptr_ (so this is the *ONLY* safe method to call after construction or - // when reinitializing after becoming the active field in a oneof union). - inline void UnsafeSetDefault(const std::string* default_value); - - // Returns a mutable pointer, but doesn't initialize the string to the - // default value. - std::string* MutableNoArenaNoDefault(const std::string* default_value); - - // Get a mutable pointer with unspecified contents. - // Similar to `MutableNoArenaNoDefault`, but also handles the arena case. - // If the value was donated, the contents are discarded. - std::string* MutableNoCopy(const std::string* default_value, - ::google::protobuf::Arena* arena); - - // Destroy the string. Assumes `arena == nullptr`. - void DestroyNoArena(const std::string* default_value); + // Swaps internal pointers. Arena-safety semantics: this is guarded by the + // logic in Swap()/UnsafeArenaSwap() at the message level, so this method is + // 'unsafe' if called directly. + inline PROTOBUF_NDEBUG_INLINE static void InternalSwap(ArenaStringPtr* rhs, + Arena* rhs_arena, + ArenaStringPtr* lhs, + Arena* lhs_arena); // Internal setter used only at parse time to directly set a donated string // value. - void UnsafeSetTaggedPointer(TaggedPtr<std::string> value) { - tagged_ptr_ = value; - } + void UnsafeSetTaggedPointer(TaggedStringPtr value) { tagged_ptr_ = value; } // Generated code only! An optimization, in certain cases the generated // code is certain we can obtain a std::string with no default checks and // tag tests. std::string* UnsafeMutablePointer() PROTOBUF_RETURNS_NONNULL; - inline bool IsDefault(const std::string* default_value) const { - // Relies on the fact that kPtrTagString == 0, so if IsString(), ptr_ is the - // actual std::string pointer (and if !IsString(), ptr_ will never be equal - // to any aligned |default_value| pointer). The key is that we want to avoid - // masking in the fastpath const-pointer Get() case for non-arena code. - return tagged_ptr_.UnsafeGet() == default_value; - } + // Returns true if this instances holds an immutable default value. + inline bool IsDefault() const { return tagged_ptr_.IsDefault(); } private: - TaggedPtr<std::string> tagged_ptr_; + template <typename... Args> + inline std::string* NewString(Arena* arena, Args&&... args) { + if (arena == nullptr) { + auto* s = new std::string(std::forward<Args>(args)...); + return tagged_ptr_.SetAllocated(s); + } else { + auto* s = Arena::Create<std::string>(arena, std::forward<Args>(args)...); + return tagged_ptr_.SetMutableArena(s); + } + } - bool IsDonatedString() const { return false; } + TaggedStringPtr tagged_ptr_; + + bool IsFixedSizeArena() const { return false; } // Swaps tagged pointer without debug hardening. This is to allow python // protobuf to maintain pointer stability even in DEBUG builds. @@ -332,46 +376,81 @@ struct PROTOBUF_EXPORT ArenaStringPtr { } friend class ::google::protobuf::internal::SwapFieldHelper; + friend class TcParser; // Slow paths. // MutableSlow requires that !IsString() || IsDefault - // Variadic to support 0 args for EmptyDefault and 1 arg for LazyString. + // Variadic to support 0 args for empty default and 1 arg for LazyString. template <typename... Lazy> std::string* MutableSlow(::google::protobuf::Arena* arena, const Lazy&... lazy_default); - // Sets value to a newly allocated string and returns it - std::string* SetAndReturnNewString(); - - // Destroys the non-default string value out-of-line - void DestroyNoArenaSlowPath(); - + friend class EpsCopyInputStream; }; -inline void ArenaStringPtr::UnsafeSetDefault(const std::string* value) { - tagged_ptr_.Set(const_cast<std::string*>(value)); +inline void ArenaStringPtr::InitDefault() { + tagged_ptr_ = TaggedStringPtr(&fixed_address_empty_string); +} + +inline void ArenaStringPtr::InitExternal(const std::string* str) { + tagged_ptr_.SetDefault(str); +} + +inline void ArenaStringPtr::InitAllocated(std::string* str, Arena* arena) { + if (arena != nullptr) { + tagged_ptr_.SetMutableArena(str); + arena->Own(str); + } else { + tagged_ptr_.SetAllocated(str); + } +} + +inline void ArenaStringPtr::Set(const char* s, Arena* arena) { + Set(ConstStringParam{s}, arena); +} + +inline void ArenaStringPtr::Set(const char* s, size_t n, Arena* arena) { + Set(ConstStringParam{s, n}, arena); +} + +inline void ArenaStringPtr::SetBytes(ConstStringParam value, Arena* arena) { + Set(value, arena); +} + +inline void ArenaStringPtr::SetBytes(std::string&& value, Arena* arena) { + Set(std::move(value), arena); +} + +inline void ArenaStringPtr::SetBytes(const char* s, Arena* arena) { + Set(s, arena); +} + +inline void ArenaStringPtr::SetBytes(const void* p, size_t n, Arena* arena) { + Set(ConstStringParam{static_cast<const char*>(p), n}, arena); } // Make sure rhs_arena allocated rhs, and lhs_arena allocated lhs. inline PROTOBUF_NDEBUG_INLINE void ArenaStringPtr::InternalSwap( // - const std::string* default_value, // ArenaStringPtr* rhs, Arena* rhs_arena, // ArenaStringPtr* lhs, Arena* lhs_arena) { // Silence unused variable warnings in release buildls. - (void)default_value; (void)rhs_arena; (void)lhs_arena; std::swap(lhs->tagged_ptr_, rhs->tagged_ptr_); #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - auto force_realloc = [default_value](ArenaStringPtr* p, Arena* arena) { - if (p->IsDefault(default_value)) return; + auto force_realloc = [](ArenaStringPtr* p, Arena* arena) { + if (p->IsDefault()) return; std::string* old_value = p->tagged_ptr_.Get(); std::string* new_value = - p->IsDonatedString() + p->IsFixedSizeArena() ? Arena::Create<std::string>(arena, *old_value) : Arena::Create<std::string>(arena, std::move(*old_value)); - if (arena == nullptr) delete old_value; - p->tagged_ptr_.Set(new_value); + if (arena == nullptr) { + delete old_value; + p->tagged_ptr_.SetAllocated(new_value); + } else { + p->tagged_ptr_.SetMutableArena(new_value); + } }; // Because, at this point, tagged_ptr_ has been swapped, arena should also be // swapped. @@ -385,29 +464,10 @@ inline void ArenaStringPtr::ClearNonDefaultToEmpty() { tagged_ptr_.Get()->clear(); } -inline std::string* ArenaStringPtr::MutableNoArenaNoDefault( - const std::string* default_value) { - // VERY IMPORTANT for performance and code size: this will reduce to a member - // variable load, a pointer check (against |default_value|, in practice a - // static global) and a branch to the slowpath (which calls operator new and - // the ctor). DO NOT add any tagged-pointer operations here. - if (IsDefault(default_value)) { - return SetAndReturnNewString(); - } else { - return UnsafeMutablePointer(); - } -} - -inline void ArenaStringPtr::DestroyNoArena(const std::string* default_value) { - if (!IsDefault(default_value)) { - DestroyNoArenaSlowPath(); - } -} - inline std::string* ArenaStringPtr::UnsafeMutablePointer() { - GOOGLE_DCHECK(!tagged_ptr_.IsTagged()); - GOOGLE_DCHECK(tagged_ptr_.UnsafeGet() != nullptr); - return tagged_ptr_.UnsafeGet(); + GOOGLE_DCHECK(tagged_ptr_.IsMutable()); + GOOGLE_DCHECK(tagged_ptr_.Get() != nullptr); + return tagged_ptr_.Get(); } diff --git a/r5dev/thirdparty/protobuf/arenastring_unittest.cc b/r5dev/thirdparty/protobuf/arenastring_unittest.cc index 0c7c8158..45eaab2d 100644 --- a/r5dev/thirdparty/protobuf/arenastring_unittest.cc +++ b/r5dev/thirdparty/protobuf/arenastring_unittest.cc @@ -34,6 +34,7 @@ #include <cstdlib> #include <memory> #include <string> +#include <utility> #include <vector> #include <thirdparty/protobuf/stubs/logging.h> @@ -54,8 +55,6 @@ namespace protobuf { using internal::ArenaStringPtr; -using EmptyDefault = ArenaStringPtr::EmptyDefault; - const internal::LazyString nonempty_default{{{"default", 7}}, {nullptr}}; const std::string* empty_default = &internal::GetEmptyString(); @@ -72,37 +71,36 @@ INSTANTIATE_TEST_SUITE_P(ArenaString, SingleArena, testing::Bool()); TEST_P(SingleArena, GetSet) { auto arena = GetArena(); ArenaStringPtr field; - field.UnsafeSetDefault(empty_default); + field.InitDefault(); EXPECT_EQ("", field.Get()); - field.Set(empty_default, "Test short", arena.get()); + field.Set("Test short", arena.get()); EXPECT_EQ("Test short", field.Get()); - field.Set(empty_default, "Test long long long long value", arena.get()); + field.Set("Test long long long long value", arena.get()); EXPECT_EQ("Test long long long long value", field.Get()); - field.Set(empty_default, "", arena.get()); - field.Destroy(empty_default, arena.get()); + field.Set("", arena.get()); + field.Destroy(); } TEST_P(SingleArena, MutableAccessor) { auto arena = GetArena(); ArenaStringPtr field; - const std::string* empty_default = &internal::GetEmptyString(); - field.UnsafeSetDefault(empty_default); + field.InitDefault(); - std::string* mut = field.Mutable(EmptyDefault{}, arena.get()); - EXPECT_EQ(mut, field.Mutable(EmptyDefault{}, arena.get())); + std::string* mut = field.Mutable(arena.get()); + EXPECT_EQ(mut, field.Mutable(arena.get())); EXPECT_EQ(mut, &field.Get()); EXPECT_NE(empty_default, mut); EXPECT_EQ("", *mut); *mut = "Test long long long long value"; // ensure string allocates storage EXPECT_EQ("Test long long long long value", field.Get()); - field.Destroy(empty_default, arena.get()); + field.Destroy(); } TEST_P(SingleArena, NullDefault) { auto arena = GetArena(); ArenaStringPtr field; - field.UnsafeSetDefault(nullptr); + field.InitDefault(); std::string* mut = field.Mutable(nonempty_default, arena.get()); EXPECT_EQ(mut, field.Mutable(nonempty_default, arena.get())); EXPECT_EQ(mut, &field.Get()); @@ -110,7 +108,7 @@ TEST_P(SingleArena, NullDefault) { EXPECT_EQ("default", *mut); *mut = "Test long long long long value"; // ensure string allocates storage EXPECT_EQ("Test long long long long value", field.Get()); - field.Destroy(nullptr, arena.get()); + field.Destroy(); } class DualArena : public testing::TestWithParam<std::tuple<bool, bool>> { @@ -131,23 +129,22 @@ INSTANTIATE_TEST_SUITE_P(ArenaString, DualArena, TEST_P(DualArena, Swap) { auto lhs_arena = GetLhsArena(); ArenaStringPtr lhs; - lhs.UnsafeSetDefault(empty_default); + lhs.InitDefault(); ArenaStringPtr rhs; - rhs.UnsafeSetDefault(empty_default); + rhs.InitDefault(); { auto rhs_arena = GetRhsArena(); - lhs.Set(empty_default, "lhs value that has some heft", lhs_arena.get()); - rhs.Set(empty_default, "rhs value that has some heft", rhs_arena.get()); - ArenaStringPtr::InternalSwap(empty_default, // - &lhs, lhs_arena.get(), // + lhs.Set("lhs value that has some heft", lhs_arena.get()); + rhs.Set("rhs value that has some heft", rhs_arena.get()); + ArenaStringPtr::InternalSwap(&lhs, lhs_arena.get(), // &rhs, rhs_arena.get()); EXPECT_EQ("rhs value that has some heft", lhs.Get()); EXPECT_EQ("lhs value that has some heft", rhs.Get()); - lhs.Destroy(empty_default, rhs_arena.get()); + lhs.Destroy(); } EXPECT_EQ("lhs value that has some heft", rhs.Get()); - rhs.Destroy(empty_default, lhs_arena.get()); + rhs.Destroy(); } diff --git a/r5dev/thirdparty/protobuf/arenaz_sampler.cc b/r5dev/thirdparty/protobuf/arenaz_sampler.cc new file mode 100644 index 00000000..b30f4399 --- /dev/null +++ b/r5dev/thirdparty/protobuf/arenaz_sampler.cc @@ -0,0 +1,177 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <thirdparty/protobuf/arenaz_sampler.h> + +#include <atomic> +#include <cstdint> +#include <limits> + + +// Must be included last. +#include <thirdparty/protobuf/port_def.inc> + +namespace google { +namespace protobuf { +namespace internal { + +ThreadSafeArenazSampler& GlobalThreadSafeArenazSampler() { + static auto* sampler = new ThreadSafeArenazSampler(); + return *sampler; +} + +void UnsampleSlow(ThreadSafeArenaStats* info) { + GlobalThreadSafeArenazSampler().Unregister(info); +} + +#if defined(PROTOBUF_ARENAZ_SAMPLE) +namespace { + +PROTOBUF_CONSTINIT std::atomic<bool> g_arenaz_enabled{true}; +PROTOBUF_CONSTINIT std::atomic<int32_t> g_arenaz_sample_parameter{1 << 10}; +PROTOBUF_THREAD_LOCAL absl::profiling_internal::ExponentialBiased + g_exponential_biased_generator; + +} // namespace + +PROTOBUF_THREAD_LOCAL int64_t global_next_sample = 1LL << 10; + +ThreadSafeArenaStats::ThreadSafeArenaStats() { PrepareForSampling(); } +ThreadSafeArenaStats::~ThreadSafeArenaStats() = default; + +void ThreadSafeArenaStats::PrepareForSampling() { + num_allocations.store(0, std::memory_order_relaxed); + num_resets.store(0, std::memory_order_relaxed); + bytes_requested.store(0, std::memory_order_relaxed); + bytes_allocated.store(0, std::memory_order_relaxed); + bytes_wasted.store(0, std::memory_order_relaxed); + max_bytes_allocated.store(0, std::memory_order_relaxed); + thread_ids.store(0, std::memory_order_relaxed); + // The inliner makes hardcoded skip_count difficult (especially when combined + // with LTO). We use the ability to exclude stacks by regex when encoding + // instead. + depth = absl::GetStackTrace(stack, kMaxStackDepth, /* skip_count= */ 0); +} + +void RecordResetSlow(ThreadSafeArenaStats* info) { + const size_t max_bytes = + info->max_bytes_allocated.load(std::memory_order_relaxed); + const size_t allocated_bytes = + info->bytes_allocated.load(std::memory_order_relaxed); + if (max_bytes < allocated_bytes) { + info->max_bytes_allocated.store(allocated_bytes); + } + info->bytes_requested.store(0, std::memory_order_relaxed); + info->bytes_allocated.store(0, std::memory_order_relaxed); + info->bytes_wasted.fetch_add(0, std::memory_order_relaxed); + info->num_allocations.fetch_add(0, std::memory_order_relaxed); + info->num_resets.fetch_add(1, std::memory_order_relaxed); +} + +void RecordAllocateSlow(ThreadSafeArenaStats* info, size_t requested, + size_t allocated, size_t wasted) { + info->bytes_requested.fetch_add(requested, std::memory_order_relaxed); + info->bytes_allocated.fetch_add(allocated, std::memory_order_relaxed); + info->bytes_wasted.fetch_add(wasted, std::memory_order_relaxed); + info->num_allocations.fetch_add(1, std::memory_order_relaxed); + const uint64_t tid = (1ULL << (GetCachedTID() % 63)); + const uint64_t thread_ids = info->thread_ids.load(std::memory_order_relaxed); + if (!(thread_ids & tid)) { + info->thread_ids.store(thread_ids | tid, std::memory_order_relaxed); + } +} + +ThreadSafeArenaStats* SampleSlow(int64_t* next_sample) { + bool first = *next_sample < 0; + *next_sample = g_exponential_biased_generator.GetStride( + g_arenaz_sample_parameter.load(std::memory_order_relaxed)); + // Small values of interval are equivalent to just sampling next time. + ABSL_ASSERT(*next_sample >= 1); + + // g_arenaz_enabled can be dynamically flipped, we need to set a threshold low + // enough that we will start sampling in a reasonable time, so we just use the + // default sampling rate. + if (!g_arenaz_enabled.load(std::memory_order_relaxed)) return nullptr; + // We will only be negative on our first count, so we should just retry in + // that case. + if (first) { + if (PROTOBUF_PREDICT_TRUE(--*next_sample > 0)) return nullptr; + return SampleSlow(next_sample); + } + + return GlobalThreadSafeArenazSampler().Register(); +} + +void SetThreadSafeArenazEnabled(bool enabled) { + g_arenaz_enabled.store(enabled, std::memory_order_release); +} + +void SetThreadSafeArenazSampleParameter(int32_t rate) { + if (rate > 0) { + g_arenaz_sample_parameter.store(rate, std::memory_order_release); + } else { + ABSL_RAW_LOG(ERROR, "Invalid thread safe arenaz sample rate: %lld", + static_cast<long long>(rate)); // NOLINT(runtime/int) + } +} + +void SetThreadSafeArenazMaxSamples(int32_t max) { + if (max > 0) { + GlobalThreadSafeArenazSampler().SetMaxSamples(max); + } else { + ABSL_RAW_LOG(ERROR, "Invalid thread safe arenaz max samples: %lld", + static_cast<long long>(max)); // NOLINT(runtime/int) + } +} + +void SetThreadSafeArenazGlobalNextSample(int64_t next_sample) { + if (next_sample >= 0) { + global_next_sample = next_sample; + } else { + ABSL_RAW_LOG(ERROR, "Invalid thread safe arenaz next sample: %lld", + static_cast<long long>(next_sample)); // NOLINT(runtime/int) + } +} + +#else +ThreadSafeArenaStats* SampleSlow(int64_t* next_sample) { + *next_sample = std::numeric_limits<int64_t>::max(); + return nullptr; +} + +void SetThreadSafeArenazEnabled(bool enabled) {} +void SetThreadSafeArenazSampleParameter(int32_t rate) {} +void SetThreadSafeArenazMaxSamples(int32_t max) {} +void SetThreadSafeArenazGlobalNextSample(int64_t next_sample) {} +#endif // defined(PROTOBUF_ARENAZ_SAMPLE) + +} // namespace internal +} // namespace protobuf +} // namespace google diff --git a/r5dev/thirdparty/protobuf/arenaz_sampler.h b/r5dev/thirdparty/protobuf/arenaz_sampler.h new file mode 100644 index 00000000..6c324ca9 --- /dev/null +++ b/r5dev/thirdparty/protobuf/arenaz_sampler.h @@ -0,0 +1,207 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef GOOGLE_PROTOBUF_SRC_GOOGLE_PROTOBUF_ARENAZ_SAMPLER_H__ +#define GOOGLE_PROTOBUF_SRC_GOOGLE_PROTOBUF_ARENAZ_SAMPLER_H__ + +#include <atomic> +#include <cstddef> +#include <cstdint> + + +// Must be included last. +#include <thirdparty/protobuf/port_def.inc> + +namespace google { +namespace protobuf { +namespace internal { + +#if defined(PROTOBUF_ARENAZ_SAMPLE) +struct ThreadSafeArenaStats; +void RecordResetSlow(ThreadSafeArenaStats* info); +void RecordAllocateSlow(ThreadSafeArenaStats* info, size_t requested, + size_t allocated, size_t wasted); +// Stores information about a sampled thread safe arena. All mutations to this +// *must* be made through `Record*` functions below. All reads from this *must* +// only occur in the callback to `ThreadSafeArenazSampler::Iterate`. +struct ThreadSafeArenaStats + : public absl::profiling_internal::Sample<ThreadSafeArenaStats> { + // Constructs the object but does not fill in any fields. + ThreadSafeArenaStats(); + ~ThreadSafeArenaStats(); + + // Puts the object into a clean state, fills in the logically `const` members, + // blocking for any readers that are currently sampling the object. + void PrepareForSampling() ABSL_EXCLUSIVE_LOCKS_REQUIRED(init_mu); + + // These fields are mutated by the various Record* APIs and need to be + // thread-safe. + std::atomic<int> num_allocations; + std::atomic<int> num_resets; + std::atomic<size_t> bytes_requested; + std::atomic<size_t> bytes_allocated; + std::atomic<size_t> bytes_wasted; + // Records the largest size an arena ever had. Maintained across resets. + std::atomic<size_t> max_bytes_allocated; + // Bit i when set to 1 indicates that a thread with tid % 63 = i accessed the + // underlying arena. The field is maintained across resets. + std::atomic<uint64_t> thread_ids; + + // All of the fields below are set by `PrepareForSampling`, they must not + // be mutated in `Record*` functions. They are logically `const` in that + // sense. These are guarded by init_mu, but that is not externalized to + // clients, who can only read them during + // `ThreadSafeArenazSampler::Iterate` which will hold the lock. + static constexpr int kMaxStackDepth = 64; + int32_t depth; + void* stack[kMaxStackDepth]; + static void RecordAllocateStats(ThreadSafeArenaStats* info, size_t requested, + size_t allocated, size_t wasted) { + if (PROTOBUF_PREDICT_TRUE(info == nullptr)) return; + RecordAllocateSlow(info, requested, allocated, wasted); + } +}; + +ThreadSafeArenaStats* SampleSlow(int64_t* next_sample); +void UnsampleSlow(ThreadSafeArenaStats* info); + +class ThreadSafeArenaStatsHandle { + public: + explicit ThreadSafeArenaStatsHandle() = default; + explicit ThreadSafeArenaStatsHandle(ThreadSafeArenaStats* info) + : info_(info) {} + + ~ThreadSafeArenaStatsHandle() { + if (PROTOBUF_PREDICT_TRUE(info_ == nullptr)) return; + UnsampleSlow(info_); + } + + ThreadSafeArenaStatsHandle(ThreadSafeArenaStatsHandle&& other) noexcept + : info_(absl::exchange(other.info_, nullptr)) {} + + ThreadSafeArenaStatsHandle& operator=( + ThreadSafeArenaStatsHandle&& other) noexcept { + if (PROTOBUF_PREDICT_FALSE(info_ != nullptr)) { + UnsampleSlow(info_); + } + info_ = absl::exchange(other.info_, nullptr); + return *this; + } + + void RecordReset() { + if (PROTOBUF_PREDICT_TRUE(info_ == nullptr)) return; + RecordResetSlow(info_); + } + + ThreadSafeArenaStats* MutableStats() { return info_; } + + friend void swap(ThreadSafeArenaStatsHandle& lhs, + ThreadSafeArenaStatsHandle& rhs) { + std::swap(lhs.info_, rhs.info_); + } + + friend class ThreadSafeArenaStatsHandlePeer; + + private: + ThreadSafeArenaStats* info_ = nullptr; +}; + +using ThreadSafeArenazSampler = + ::absl::profiling_internal::SampleRecorder<ThreadSafeArenaStats>; + +extern PROTOBUF_THREAD_LOCAL int64_t global_next_sample; + +// Returns an RAII sampling handle that manages registration and unregistation +// with the global sampler. +inline ThreadSafeArenaStatsHandle Sample() { + if (PROTOBUF_PREDICT_TRUE(--global_next_sample > 0)) { + return ThreadSafeArenaStatsHandle(nullptr); + } + return ThreadSafeArenaStatsHandle(SampleSlow(&global_next_sample)); +} + +#else +struct ThreadSafeArenaStats { + static void RecordAllocateStats(ThreadSafeArenaStats*, size_t /*requested*/, + size_t /*allocated*/, size_t /*wasted*/) {} +}; + +ThreadSafeArenaStats* SampleSlow(int64_t* next_sample); +void UnsampleSlow(ThreadSafeArenaStats* info); + +class ThreadSafeArenaStatsHandle { + public: + explicit ThreadSafeArenaStatsHandle() = default; + explicit ThreadSafeArenaStatsHandle(ThreadSafeArenaStats*) {} + + void RecordReset() {} + + ThreadSafeArenaStats* MutableStats() { return nullptr; } + + friend void swap(ThreadSafeArenaStatsHandle&, ThreadSafeArenaStatsHandle&) {} + + private: + friend class ThreadSafeArenaStatsHandlePeer; +}; + +class ThreadSafeArenazSampler { + public: + void Unregister(ThreadSafeArenaStats*) {} + void SetMaxSamples(int32_t) {} +}; + +// Returns an RAII sampling handle that manages registration and unregistation +// with the global sampler. +inline ThreadSafeArenaStatsHandle Sample() { + return ThreadSafeArenaStatsHandle(nullptr); +} +#endif // defined(PROTOBUF_ARENAZ_SAMPLE) + +// Returns a global Sampler. +ThreadSafeArenazSampler& GlobalThreadSafeArenazSampler(); + +// Enables or disables sampling for thread safe arenas. +void SetThreadSafeArenazEnabled(bool enabled); + +// Sets the rate at which thread safe arena will be sampled. +void SetThreadSafeArenazSampleParameter(int32_t rate); + +// Sets a soft max for the number of samples that will be kept. +void SetThreadSafeArenazMaxSamples(int32_t max); + +// Sets the current value for when arenas should be next sampled. +void SetThreadSafeArenazGlobalNextSample(int64_t next_sample); + +} // namespace internal +} // namespace protobuf +} // namespace google + +#include <thirdparty/protobuf/port_undef.inc> +#endif // GOOGLE_PROTOBUF_SRC_PROTOBUF_ARENAZ_SAMPLER_H__ diff --git a/r5dev/thirdparty/protobuf/arenaz_sampler_test.cc b/r5dev/thirdparty/protobuf/arenaz_sampler_test.cc new file mode 100644 index 00000000..0b12f38c --- /dev/null +++ b/r5dev/thirdparty/protobuf/arenaz_sampler_test.cc @@ -0,0 +1,382 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <thirdparty/protobuf/arenaz_sampler.h> + +#include <memory> +#include <random> +#include <vector> + +#include <gmock/gmock.h> +#include <gtest/gtest.h> +#include <thirdparty/protobuf/stubs/strutil.h> + + +// Must be included last. +#include <thirdparty/protobuf/port_def.inc> + +namespace google { +namespace protobuf { +namespace internal { +#if defined(PROTOBUF_ARENAZ_SAMPLE) +class ThreadSafeArenaStatsHandlePeer { + public: + static bool IsSampled(const ThreadSafeArenaStatsHandle& h) { + return h.info_ != nullptr; + } + + static ThreadSafeArenaStats* GetInfo(ThreadSafeArenaStatsHandle* h) { + return h->info_; + } +}; +std::vector<size_t> GetBytesAllocated(ThreadSafeArenazSampler* s) { + std::vector<size_t> res; + s->Iterate([&](const ThreadSafeArenaStats& info) { + res.push_back(info.bytes_allocated.load(std::memory_order_acquire)); + }); + return res; +} + +ThreadSafeArenaStats* Register(ThreadSafeArenazSampler* s, size_t size) { + auto* info = s->Register(); + assert(info != nullptr); + info->bytes_allocated.store(size); + return info; +} + +#endif // defined(PROTOBUF_ARENAZ_SAMPLE) + +namespace { + +#if defined(PROTOBUF_ARENAZ_SAMPLE) + +TEST(ThreadSafeArenaStatsTest, PrepareForSampling) { + ThreadSafeArenaStats info; + MutexLock l(&info.init_mu); + info.PrepareForSampling(); + + EXPECT_EQ(info.num_allocations.load(), 0); + EXPECT_EQ(info.num_resets.load(), 0); + EXPECT_EQ(info.bytes_requested.load(), 0); + EXPECT_EQ(info.bytes_allocated.load(), 0); + EXPECT_EQ(info.bytes_wasted.load(), 0); + EXPECT_EQ(info.max_bytes_allocated.load(), 0); + + info.num_allocations.store(1, std::memory_order_relaxed); + info.num_resets.store(1, std::memory_order_relaxed); + info.bytes_requested.store(1, std::memory_order_relaxed); + info.bytes_allocated.store(1, std::memory_order_relaxed); + info.bytes_wasted.store(1, std::memory_order_relaxed); + info.max_bytes_allocated.store(1, std::memory_order_relaxed); + + info.PrepareForSampling(); + EXPECT_EQ(info.num_allocations.load(), 0); + EXPECT_EQ(info.num_resets.load(), 0); + EXPECT_EQ(info.bytes_requested.load(), 0); + EXPECT_EQ(info.bytes_allocated.load(), 0); + EXPECT_EQ(info.bytes_wasted.load(), 0); + EXPECT_EQ(info.max_bytes_allocated.load(), 0); +} + +TEST(ThreadSafeArenaStatsTest, RecordAllocateSlow) { + ThreadSafeArenaStats info; + MutexLock l(&info.init_mu); + info.PrepareForSampling(); + RecordAllocateSlow(&info, /*requested=*/100, /*allocated=*/128, /*wasted=*/0); + EXPECT_EQ(info.num_allocations.load(), 1); + EXPECT_EQ(info.num_resets.load(), 0); + EXPECT_EQ(info.bytes_requested.load(), 100); + EXPECT_EQ(info.bytes_allocated.load(), 128); + EXPECT_EQ(info.bytes_wasted.load(), 0); + EXPECT_EQ(info.max_bytes_allocated.load(), 0); + RecordAllocateSlow(&info, /*requested=*/100, /*allocated=*/256, + /*wasted=*/28); + EXPECT_EQ(info.num_allocations.load(), 2); + EXPECT_EQ(info.num_resets.load(), 0); + EXPECT_EQ(info.bytes_requested.load(), 200); + EXPECT_EQ(info.bytes_allocated.load(), 384); + EXPECT_EQ(info.bytes_wasted.load(), 28); + EXPECT_EQ(info.max_bytes_allocated.load(), 0); +} + +TEST(ThreadSafeArenaStatsTest, RecordResetSlow) { + ThreadSafeArenaStats info; + MutexLock l(&info.init_mu); + info.PrepareForSampling(); + EXPECT_EQ(info.num_resets.load(), 0); + EXPECT_EQ(info.bytes_allocated.load(), 0); + RecordAllocateSlow(&info, /*requested=*/100, /*allocated=*/128, /*wasted=*/0); + EXPECT_EQ(info.num_resets.load(), 0); + EXPECT_EQ(info.bytes_allocated.load(), 128); + RecordResetSlow(&info); + EXPECT_EQ(info.num_resets.load(), 1); + EXPECT_EQ(info.bytes_allocated.load(), 0); +} + +TEST(ThreadSafeArenazSamplerTest, SmallSampleParameter) { + SetThreadSafeArenazEnabled(true); + SetThreadSafeArenazSampleParameter(100); + + for (int i = 0; i < 1000; ++i) { + int64_t next_sample = 0; + ThreadSafeArenaStats* sample = SampleSlow(&next_sample); + EXPECT_GT(next_sample, 0); + EXPECT_NE(sample, nullptr); + UnsampleSlow(sample); + } +} + +TEST(ThreadSafeArenazSamplerTest, LargeSampleParameter) { + SetThreadSafeArenazEnabled(true); + SetThreadSafeArenazSampleParameter(std::numeric_limits<int32_t>::max()); + + for (int i = 0; i < 1000; ++i) { + int64_t next_sample = 0; + ThreadSafeArenaStats* sample = SampleSlow(&next_sample); + EXPECT_GT(next_sample, 0); + EXPECT_NE(sample, nullptr); + UnsampleSlow(sample); + } +} + +TEST(ThreadSafeArenazSamplerTest, Sample) { + SetThreadSafeArenazEnabled(true); + SetThreadSafeArenazSampleParameter(100); + SetThreadSafeArenazGlobalNextSample(0); + int64_t num_sampled = 0; + int64_t total = 0; + double sample_rate = 0.0; + for (int i = 0; i < 1000000; ++i) { + ThreadSafeArenaStatsHandle h = Sample(); + ++total; + if (ThreadSafeArenaStatsHandlePeer::IsSampled(h)) { + ++num_sampled; + } + sample_rate = static_cast<double>(num_sampled) / total; + if (0.005 < sample_rate && sample_rate < 0.015) break; + } + EXPECT_NEAR(sample_rate, 0.01, 0.005); +} + +TEST(ThreadSafeArenazSamplerTest, Handle) { + auto& sampler = GlobalThreadSafeArenazSampler(); + ThreadSafeArenaStatsHandle h(sampler.Register()); + auto* info = ThreadSafeArenaStatsHandlePeer::GetInfo(&h); + info->bytes_allocated.store(0x12345678, std::memory_order_relaxed); + + bool found = false; + sampler.Iterate([&](const ThreadSafeArenaStats& h) { + if (&h == info) { + EXPECT_EQ(h.bytes_allocated.load(), 0x12345678); + found = true; + } + }); + EXPECT_TRUE(found); + + h = ThreadSafeArenaStatsHandle(); + found = false; + sampler.Iterate([&](const ThreadSafeArenaStats& h) { + if (&h == info) { + // this will only happen if some other thread has resurrected the info + // the old handle was using. + if (h.bytes_allocated.load() == 0x12345678) { + found = true; + } + } + }); + EXPECT_FALSE(found); +} + +TEST(ThreadSafeArenazSamplerTest, Registration) { + ThreadSafeArenazSampler sampler; + auto* info1 = Register(&sampler, 1); + EXPECT_THAT(GetBytesAllocated(&sampler), UnorderedElementsAre(1)); + + auto* info2 = Register(&sampler, 2); + EXPECT_THAT(GetBytesAllocated(&sampler), UnorderedElementsAre(1, 2)); + info1->bytes_allocated.store(3); + EXPECT_THAT(GetBytesAllocated(&sampler), UnorderedElementsAre(3, 2)); + + sampler.Unregister(info1); + sampler.Unregister(info2); +} + +TEST(ThreadSafeArenazSamplerTest, Unregistration) { + ThreadSafeArenazSampler sampler; + std::vector<ThreadSafeArenaStats*> infos; + for (size_t i = 0; i < 3; ++i) { + infos.push_back(Register(&sampler, i)); + } + EXPECT_THAT(GetBytesAllocated(&sampler), UnorderedElementsAre(0, 1, 2)); + + sampler.Unregister(infos[1]); + EXPECT_THAT(GetBytesAllocated(&sampler), UnorderedElementsAre(0, 2)); + + infos.push_back(Register(&sampler, 3)); + infos.push_back(Register(&sampler, 4)); + EXPECT_THAT(GetBytesAllocated(&sampler), UnorderedElementsAre(0, 2, 3, 4)); + sampler.Unregister(infos[3]); + EXPECT_THAT(GetBytesAllocated(&sampler), UnorderedElementsAre(0, 2, 4)); + + sampler.Unregister(infos[0]); + sampler.Unregister(infos[2]); + sampler.Unregister(infos[4]); + EXPECT_THAT(GetBytesAllocated(&sampler), IsEmpty()); +} + +TEST(ThreadSafeArenazSamplerTest, MultiThreaded) { + ThreadSafeArenazSampler sampler; + absl::Notification stop; + ThreadPool pool(10); + + for (int i = 0; i < 10; ++i) { + pool.Schedule([&sampler, &stop]() { + std::random_device rd; + std::mt19937 gen(rd()); + + std::vector<ThreadSafeArenaStats*> infoz; + while (!stop.HasBeenNotified()) { + if (infoz.empty()) { + infoz.push_back(sampler.Register()); + } + switch (std::uniform_int_distribution<>(0, 1)(gen)) { + case 0: { + infoz.push_back(sampler.Register()); + break; + } + case 1: { + size_t p = + std::uniform_int_distribution<>(0, infoz.size() - 1)(gen); + ThreadSafeArenaStats* info = infoz[p]; + infoz[p] = infoz.back(); + infoz.pop_back(); + sampler.Unregister(info); + break; + } + } + } + }); + } + // The threads will hammer away. Give it a little bit of time for tsan to + // spot errors. + absl::SleepFor(absl::Seconds(3)); + stop.Notify(); +} + +TEST(ThreadSafeArenazSamplerTest, Callback) { + ThreadSafeArenazSampler sampler; + + auto* info1 = Register(&sampler, 1); + auto* info2 = Register(&sampler, 2); + + static const ThreadSafeArenaStats* expected; + + auto callback = [](const ThreadSafeArenaStats& info) { + // We can't use `info` outside of this callback because the object will be + // disposed as soon as we return from here. + EXPECT_EQ(&info, expected); + }; + + // Set the callback. + EXPECT_EQ(sampler.SetDisposeCallback(callback), nullptr); + expected = info1; + sampler.Unregister(info1); + + // Unset the callback. + EXPECT_EQ(callback, sampler.SetDisposeCallback(nullptr)); + expected = nullptr; // no more calls. + sampler.Unregister(info2); +} + +class ThreadSafeArenazSamplerTestThread : public Thread { + protected: + void Run() override { + google::protobuf::ArenaSafeUniquePtr< + protobuf_test_messages::proto2::TestAllTypesProto2> + message = google::protobuf::MakeArenaSafeUnique< + protobuf_test_messages::proto2::TestAllTypesProto2>(arena_); + GOOGLE_CHECK(message != nullptr); + // Signal that a message on the arena has been created. This should create + // a SerialArena for this thread. + if (barrier_->Block()) { + delete barrier_; + } + } + + public: + ThreadSafeArenazSamplerTestThread(const thread::Options& options, + StringPiece name, + google::protobuf::Arena* arena, + absl::Barrier* barrier) + : Thread(options, name), arena_(arena), barrier_(barrier) {} + + private: + google::protobuf::Arena* arena_; + absl::Barrier* barrier_; +}; + +TEST(ThreadSafeArenazSamplerTest, MultiThread) { + SetThreadSafeArenazEnabled(true); + // Setting 1 as the parameter value means one in every two arenas would be + // sampled, on average. + SetThreadSafeArenazSampleParameter(1); + SetThreadSafeArenazGlobalNextSample(0); + auto& sampler = GlobalThreadSafeArenazSampler(); + int count = 0; + for (int i = 0; i < 10; ++i) { + const int kNumThreads = 10; + absl::Barrier* barrier = new absl::Barrier(kNumThreads + 1); + google::protobuf::Arena arena; + thread::Options options; + options.set_joinable(true); + std::vector<std::unique_ptr<ThreadSafeArenazSamplerTestThread>> threads; + for (int i = 0; i < kNumThreads; i++) { + auto t = std::make_unique<ThreadSafeArenazSamplerTestThread>( + options, StrCat("thread", i), &arena, barrier); + t->Start(); + threads.push_back(std::move(t)); + } + // Wait till each thread has created a message on the arena. + if (barrier->Block()) { + delete barrier; + } + sampler.Iterate([&](const ThreadSafeArenaStats& h) { ++count; }); + for (int i = 0; i < kNumThreads; i++) { + threads[i]->Join(); + } + } + EXPECT_GT(count, 0); +} +#endif // defined(PROTOBUF_ARENAZ_SAMPLE) + +} // namespace +} // namespace internal +} // namespace protobuf +} // namespace google diff --git a/r5dev/thirdparty/protobuf/compiler/annotation_test_util.cc b/r5dev/thirdparty/protobuf/compiler/annotation_test_util.cc index 0dc5addf..8fd4072a 100644 --- a/r5dev/thirdparty/protobuf/compiler/annotation_test_util.cc +++ b/r5dev/thirdparty/protobuf/compiler/annotation_test_util.cc @@ -58,9 +58,8 @@ class DescriptorCapturingGenerator : public CodeGenerator { explicit DescriptorCapturingGenerator(FileDescriptorProto* file) : file_(file) {} - virtual bool Generate(const FileDescriptor* file, - const std::string& parameter, GeneratorContext* context, - std::string* error) const { + bool Generate(const FileDescriptor* file, const std::string& parameter, + GeneratorContext* context, std::string* error) const override { file->CopyTo(file_); return true; } @@ -128,7 +127,7 @@ const GeneratedCodeInfo::Annotation* FindAnnotationOnPath( std::vector<const GeneratedCodeInfo::Annotation*> annotations; FindAnnotationsOnPath(info, source_file, path, &annotations); if (annotations.empty()) { - return NULL; + return nullptr; } return annotations[0]; } diff --git a/r5dev/thirdparty/protobuf/compiler/annotation_test_util.h b/r5dev/thirdparty/protobuf/compiler/annotation_test_util.h index 0811f689..b830098a 100644 --- a/r5dev/thirdparty/protobuf/compiler/annotation_test_util.h +++ b/r5dev/thirdparty/protobuf/compiler/annotation_test_util.h @@ -78,7 +78,7 @@ bool RunProtoCompiler(const std::string& filename, bool DecodeMetadata(const std::string& path, GeneratedCodeInfo* info); // Finds all of the Annotations for a given source file and path. -// See Location.path in https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/descriptor.proto for +// See Location.path in https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto for // explanation of what path vector is. void FindAnnotationsOnPath( const GeneratedCodeInfo& info, const std::string& source_file, @@ -88,7 +88,7 @@ void FindAnnotationsOnPath( // Finds the Annotation for a given source file and path (or returns null if it // couldn't). If there are several annotations for given path, returns the first // one. See Location.path in -// https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/descriptor.proto for explanation of what path +// https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto for explanation of what path // vector is. const GeneratedCodeInfo::Annotation* FindAnnotationOnPath( const GeneratedCodeInfo& info, const std::string& source_file, diff --git a/r5dev/thirdparty/protobuf/compiler/code_generator.cc b/r5dev/thirdparty/protobuf/compiler/code_generator.cc index 9dc4aa01..a523d678 100644 --- a/r5dev/thirdparty/protobuf/compiler/code_generator.cc +++ b/r5dev/thirdparty/protobuf/compiler/code_generator.cc @@ -76,13 +76,13 @@ GeneratorContext::~GeneratorContext() {} io::ZeroCopyOutputStream* GeneratorContext::OpenForAppend( const std::string& filename) { - return NULL; + return nullptr; } io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert( const std::string& filename, const std::string& insertion_point) { GOOGLE_LOG(FATAL) << "This GeneratorContext does not support insertion."; - return NULL; // make compiler happy + return nullptr; // make compiler happy } io::ZeroCopyOutputStream* GeneratorContext::OpenForInsertWithGeneratedCodeInfo( diff --git a/r5dev/thirdparty/protobuf/compiler/code_generator.h b/r5dev/thirdparty/protobuf/compiler/code_generator.h index 7cdc5196..84340792 100644 --- a/r5dev/thirdparty/protobuf/compiler/code_generator.h +++ b/r5dev/thirdparty/protobuf/compiler/code_generator.h @@ -43,6 +43,7 @@ #include <vector> #include <thirdparty/protobuf/stubs/common.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -188,9 +189,9 @@ typedef GeneratorContext OutputDirectory; // Several code generators treat the parameter argument as holding a // list of options separated by commas. This helper function parses // a set of comma-delimited name/value pairs: e.g., -// "foo=bar,baz,qux=corge" +// "foo=bar,baz,moo=corge" // parses to the pairs: -// ("foo", "bar"), ("baz", ""), ("qux", "corge") +// ("foo", "bar"), ("baz", ""), ("moo", "corge") PROTOC_EXPORT void ParseGeneratorParameter( const std::string&, std::vector<std::pair<std::string, std::string> >*); diff --git a/r5dev/thirdparty/protobuf/compiler/command_line_interface.cc b/r5dev/thirdparty/protobuf/compiler/command_line_interface.cc index 2deefaa5..d98b7942 100644 --- a/r5dev/thirdparty/protobuf/compiler/command_line_interface.cc +++ b/r5dev/thirdparty/protobuf/compiler/command_line_interface.cc @@ -34,8 +34,6 @@ #include <thirdparty/protobuf/compiler/command_line_interface.h> -#include <cstdint> - #include <thirdparty/protobuf/stubs/platform_macros.h> #include <stdio.h> @@ -53,10 +51,11 @@ #endif #include <ctype.h> #include <errno.h> + #include <fstream> #include <iostream> -#include <limits.h> //For PATH_MAX +#include <limits.h> // For PATH_MAX #include <memory> @@ -68,25 +67,26 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/compiler/subprocess.h> -#include <thirdparty/protobuf/compiler/zip_writer.h> #include <thirdparty/protobuf/compiler/plugin.pb.h> +#include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/stubs/stringprintf.h> +#include <thirdparty/protobuf/stubs/substitute.h> #include <thirdparty/protobuf/compiler/code_generator.h> #include <thirdparty/protobuf/compiler/importer.h> -#include <thirdparty/protobuf/io/coded_stream.h> -#include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/io/zero_copy_stream_impl.h> +#include <thirdparty/protobuf/compiler/zip_writer.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/dynamic_message.h> -#include <thirdparty/protobuf/text_format.h> -#include <thirdparty/protobuf/stubs/strutil.h> -#include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/io_win32.h> +#include <thirdparty/protobuf/io/printer.h> +#include <thirdparty/protobuf/io/zero_copy_stream_impl.h> +#include <thirdparty/protobuf/text_format.h> #include <thirdparty/protobuf/stubs/map_util.h> #include <thirdparty/protobuf/stubs/stl_util.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -195,7 +195,7 @@ bool TryCreateParentDirectory(const std::string& prefix, bool GetProtocAbsolutePath(std::string* path) { #ifdef _WIN32 char buffer[MAX_PATH]; - int len = GetModuleFileNameA(NULL, buffer, MAX_PATH); + int len = GetModuleFileNameA(nullptr, buffer, MAX_PATH); #elif defined(__APPLE__) char buffer[PATH_MAX]; int len = 0; @@ -210,7 +210,7 @@ bool GetProtocAbsolutePath(std::string* path) { char buffer[PATH_MAX]; size_t len = PATH_MAX; int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; - if (sysctl(mib, 4, &buffer, &len, NULL, 0) != 0) { + if (sysctl(mib, 4, &buffer, &len, nullptr, 0) != 0) { len = 0; } #else @@ -289,12 +289,12 @@ class CommandLineInterface::ErrorPrinter public io::ErrorCollector, public DescriptorPool::ErrorCollector { public: - ErrorPrinter(ErrorFormat format, DiskSourceTree* tree = NULL) + ErrorPrinter(ErrorFormat format, DiskSourceTree* tree = nullptr) : format_(format), tree_(tree), found_errors_(false), found_warnings_(false) {} - ~ErrorPrinter() {} + ~ErrorPrinter() override {} // implements MultiFileErrorCollector ------------------------------ void AddError(const std::string& filename, int line, int column, @@ -341,8 +341,8 @@ class CommandLineInterface::ErrorPrinter std::ostream& out) { // Print full path when running under MSVS std::string dfile; - if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS && tree_ != NULL && - tree_->VirtualFileToDiskFile(filename, &dfile)) { + if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS && + tree_ != nullptr && tree_->VirtualFileToDiskFile(filename, &dfile)) { out << dfile; } else { out << filename; @@ -434,7 +434,7 @@ class CommandLineInterface::MemoryOutputStream const std::string& filename, const std::string& insertion_point, const google::protobuf::GeneratedCodeInfo& info); - virtual ~MemoryOutputStream(); + ~MemoryOutputStream() override; // implements ZeroCopyOutputStream --------------------------------- bool Next(void** data, int* size) override { @@ -1116,7 +1116,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { FileDescriptorProto file; file.set_name("empty_message.proto"); file.add_message_type()->set_name("EmptyMessage"); - GOOGLE_CHECK(pool.BuildFile(file) != NULL); + GOOGLE_CHECK(pool.BuildFile(file) != nullptr); codec_type_ = "EmptyMessage"; if (!EncodeOrDecode(&pool)) { return 1; @@ -1270,7 +1270,7 @@ bool CommandLineInterface::ParseInputFiles( // Import the file. const FileDescriptor* parsed_file = descriptor_pool->FindFileByName(input_file); - if (parsed_file == NULL) { + if (parsed_file == nullptr) { result = false; break; } @@ -1496,7 +1496,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments( for (std::vector<OutputDirective>::const_iterator j = output_directives_.begin(); j != output_directives_.end(); ++j) { - if (j->generator == NULL) { + if (j->generator == nullptr) { std::string plugin_name = PluginName(plugin_prefix_, j->name); if (plugin_name == i->first) { foundImplicitPlugin = true; @@ -1606,7 +1606,7 @@ bool CommandLineInterface::ParseArgument(const char* arg, std::string* name, // Two dashes: Multi-character name, with '=' separating name and // value. const char* equals_pos = strchr(arg, '='); - if (equals_pos != NULL) { + if (equals_pos != nullptr) { *name = std::string(arg, equals_pos - arg); *value = equals_pos + 1; parsed_value = true; @@ -1674,8 +1674,9 @@ CommandLineInterface::InterpretArgument(const std::string& name, // On Windows, the shell (typically cmd.exe) does not expand wildcards in // file names (e.g. foo\*.proto), so we do it ourselves. switch (google::protobuf::io::win32::ExpandWildcards( - value, - [this](const string& path) { this->input_files_.push_back(path); })) { + value, [this](const std::string& path) { + this->input_files_.push_back(path); + })) { case google::protobuf::io::win32::ExpandWildcardsResult::kSuccess: break; case google::protobuf::io::win32::ExpandWildcardsResult:: @@ -1946,11 +1947,11 @@ CommandLineInterface::InterpretArgument(const std::string& name, // Some other flag. Look it up in the generators list. const GeneratorInfo* generator_info = FindOrNull(generators_by_flag_name_, name); - if (generator_info == NULL && + if (generator_info == nullptr && (plugin_prefix_.empty() || !HasSuffixString(name, "_out"))) { // Check if it's a generator option flag. generator_info = FindOrNull(generators_by_option_name_, name); - if (generator_info != NULL) { + if (generator_info != nullptr) { std::string* parameters = &generator_parameters_[generator_info->flag_name]; if (!parameters->empty()) { @@ -1979,8 +1980,8 @@ CommandLineInterface::InterpretArgument(const std::string& name, OutputDirective directive; directive.name = name; - if (generator_info == NULL) { - directive.generator = NULL; + if (generator_info == nullptr) { + directive.generator = nullptr; } else { directive.generator = generator_info->generator; } @@ -2136,7 +2137,7 @@ bool CommandLineInterface::GenerateOutput( GeneratorContext* generator_context) { // Call the generator. std::string error; - if (output_directive.generator == NULL) { + if (output_directive.generator == nullptr) { // This is a plugin. GOOGLE_CHECK(HasPrefixString(output_directive.name, "--") && HasSuffixString(output_directive.name, "_out")) @@ -2208,6 +2209,10 @@ bool CommandLineInterface::GenerateDependencyManifestFile( } } + if (!descriptor_set_out_name_.empty()) { + output_filenames.push_back(descriptor_set_out_name_); + } + int fd; do { fd = open(dependency_out_name_.c_str(), @@ -2304,7 +2309,7 @@ bool CommandLineInterface::GeneratePluginOutput( if (!output_file.insertion_point().empty()) { std::string filename = output_file.name(); // Open a file for insert. - // We reset current_output to NULL first so that the old file is closed + // We reset current_output to nullptr first so that the old file is closed // before the new one is opened. current_output.reset(); current_output.reset( @@ -2313,11 +2318,11 @@ bool CommandLineInterface::GeneratePluginOutput( output_file.generated_code_info())); } else if (!output_file.name().empty()) { // Starting a new file. Open it. - // We reset current_output to NULL first so that the old file is closed + // We reset current_output to nullptr first so that the old file is closed // before the new one is opened. current_output.reset(); current_output.reset(generator_context->Open(output_file.name())); - } else if (current_output == NULL) { + } else if (current_output == nullptr) { *error = strings::Substitute( "$0: First file chunk returned by plugin did not specify a file " "name.", @@ -2347,7 +2352,7 @@ bool CommandLineInterface::GeneratePluginOutput( bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) { // Look up the type. const Descriptor* type = pool->FindMessageTypeByName(codec_type_); - if (type == NULL) { + if (type == nullptr) { std::cerr << "Type not defined: " << codec_type_ << std::endl; return false; } @@ -2586,7 +2591,8 @@ void FormatFreeFieldNumbers(const std::string& name, StringAppendF(&output, " %d", next_free_number); } else { // Range - StringAppendF(&output, " %d-%d", next_free_number, i->first - 1); + StringAppendF(&output, " %d-%d", next_free_number, + i->first - 1); } } next_free_number = i->second; diff --git a/r5dev/thirdparty/protobuf/compiler/command_line_interface.h b/r5dev/thirdparty/protobuf/compiler/command_line_interface.h index cc55b5c3..0b479ed4 100644 --- a/r5dev/thirdparty/protobuf/compiler/command_line_interface.h +++ b/r5dev/thirdparty/protobuf/compiler/command_line_interface.h @@ -49,6 +49,8 @@ #include <vector> #include <thirdparty/protobuf/stubs/common.h> + +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/compiler/command_line_interface_unittest.cc b/r5dev/thirdparty/protobuf/compiler/command_line_interface_unittest.cc index f6cfdf5e..9bf6248e 100644 --- a/r5dev/thirdparty/protobuf/compiler/command_line_interface_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/command_line_interface_unittest.cc @@ -50,24 +50,27 @@ #include <thirdparty/protobuf/testing/file.h> #include <thirdparty/protobuf/testing/file.h> #include <thirdparty/protobuf/any.pb.h> -#include <thirdparty/protobuf/compiler/mock_code_generator.h> -#include <thirdparty/protobuf/compiler/subprocess.h> -#include <thirdparty/protobuf/compiler/code_generator.h> -#include <thirdparty/protobuf/compiler/command_line_interface.h> #include <thirdparty/protobuf/test_util2.h> #include <thirdparty/protobuf/unittest.pb.h> #include <thirdparty/protobuf/unittest_custom_options.pb.h> -#include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/descriptor.pb.h> -#include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/compiler/code_generator.h> +#include <thirdparty/protobuf/compiler/command_line_interface.h> +#include <thirdparty/protobuf/compiler/mock_code_generator.h> +#include <thirdparty/protobuf/compiler/subprocess.h> +#include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/io/io_win32.h> +#include <thirdparty/protobuf/io/printer.h> +#include <thirdparty/protobuf/io/zero_copy_stream.h> +// Must be included last. +#include <thirdparty/protobuf/port_def.inc> + namespace google { namespace protobuf { namespace compiler { @@ -96,8 +99,8 @@ bool FileExists(const std::string& path) { class CommandLineInterfaceTest : public testing::Test { protected: - virtual void SetUp(); - virtual void TearDown(); + void SetUp() override; + void TearDown() override; // Runs the CommandLineInterface with the given command line. The // command is automatically split on spaces, and the string "$tmpdir" @@ -256,14 +259,14 @@ class CommandLineInterfaceTest : public testing::Test { class CommandLineInterfaceTest::NullCodeGenerator : public CodeGenerator { public: NullCodeGenerator() : called_(false) {} - ~NullCodeGenerator() {} + ~NullCodeGenerator() override {} mutable bool called_; mutable std::string parameter_; // implements CodeGenerator ---------------------------------------- bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* context, std::string* error) const { + GeneratorContext* context, std::string* error) const override { called_ = true; parameter_ = parameter; return true; @@ -1714,7 +1717,7 @@ TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFile) { " optional Foo foo = 1;\n" "}\n"); - std::string current_working_directory = getcwd(NULL, 0); + std::string current_working_directory = getcwd(nullptr, 0); SwitchToTempDirectory(); Run("protocol_compiler --dependency_out=manifest --test_out=. " @@ -1753,6 +1756,28 @@ TEST_F(CommandLineInterfaceTest, WriteDependencyManifestFileForAbsolutePath) { "$tmpdir/bar.proto.MockCodeGenerator.test_generator: " "$tmpdir/foo.proto\\\n $tmpdir/bar.proto"); } + +TEST_F(CommandLineInterfaceTest, + WriteDependencyManifestFileWithDescriptorSetOut) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "message Foo {}\n"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n" + "import \"foo.proto\";\n" + "message Bar {\n" + " optional Foo foo = 1;\n" + "}\n"); + + Run("protocol_compiler --dependency_out=$tmpdir/manifest " + "--descriptor_set_out=$tmpdir/bar.pb --proto_path=$tmpdir bar.proto"); + + ExpectNoErrors(); + + ExpectFileContent("manifest", + "$tmpdir/bar.pb: " + "$tmpdir/foo.proto\\\n $tmpdir/bar.proto"); +} #endif // !_WIN32 TEST_F(CommandLineInterfaceTest, TestArgumentFile) { @@ -2518,12 +2543,12 @@ enum EncodeDecodeTestMode { PROTO_PATH, DESCRIPTOR_SET_IN }; class EncodeDecodeTest : public testing::TestWithParam<EncodeDecodeTestMode> { protected: - virtual void SetUp() { + void SetUp() override { WriteUnittestProtoDescriptorSet(); duped_stdin_ = dup(STDIN_FILENO); } - virtual void TearDown() { + void TearDown() override { dup2(duped_stdin_, STDIN_FILENO); close(duped_stdin_); } @@ -2755,6 +2780,8 @@ INSTANTIATE_TEST_SUITE_P(FileDescriptorSetSource, EncodeDecodeTest, #endif // !GOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN +#include <thirdparty/protobuf/port_undef.inc> + } // namespace compiler } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc b/r5dev/thirdparty/protobuf/compiler/cpp/bootstrap_unittest.cc similarity index 94% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/bootstrap_unittest.cc index 3b8eed40..d9b76cb2 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/bootstrap_unittest.cc @@ -46,8 +46,7 @@ #include <thirdparty/protobuf/testing/file.h> #include <thirdparty/protobuf/testing/file.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_generator.h> +#include <thirdparty/protobuf/compiler/cpp/generator.h> #include <thirdparty/protobuf/compiler/importer.h> #include <thirdparty/protobuf/test_util2.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> @@ -56,6 +55,7 @@ #include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> #include <thirdparty/protobuf/stubs/map_util.h> #include <thirdparty/protobuf/stubs/stl_util.h> @@ -69,13 +69,13 @@ namespace { class MockErrorCollector : public MultiFileErrorCollector { public: MockErrorCollector() {} - ~MockErrorCollector() {} + ~MockErrorCollector() override {} std::string text_; // implements ErrorCollector --------------------------------------- void AddError(const std::string& filename, int line, int column, - const std::string& message) { + const std::string& message) override { strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n", filename, line, column, message); } @@ -113,7 +113,7 @@ class MockGeneratorContext : public GeneratorContext { // implements GeneratorContext -------------------------------------- - virtual io::ZeroCopyOutputStream* Open(const std::string& filename) { + io::ZeroCopyOutputStream* Open(const std::string& filename) override { auto& map_slot = files_[filename]; map_slot.reset(new std::string); return new io::StringOutputStream(map_slot.get()); @@ -137,9 +137,9 @@ TEST(BootstrapTest, GeneratedFilesMatch) { // of the data to compare to. std::map<std::string, std::string> vpath_map; std::map<std::string, std::string> rpath_map; - rpath_map["third_party/protobuf/src/google/protobuf/test_messages_proto2"] = + rpath_map["third_party/protobuf/test_messages_proto2"] = "net/proto2/z_generated_example/test_messages_proto2"; - rpath_map["third_party/protobuf/src/google/protobuf/test_messages_proto3"] = + rpath_map["third_party/protobuf/test_messages_proto3"] = "net/proto2/z_generated_example/test_messages_proto3"; rpath_map["net/proto2/internal/proto2_weak"] = "net/proto2/z_generated_example/proto2_weak"; diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_generator.h b/r5dev/thirdparty/protobuf/compiler/cpp/cpp_generator.h index 78acce2e..cf159ebc 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_generator.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/cpp_generator.h @@ -1,106 +1,6 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_CPP_GENERATOR_H_ +#define GOOGLE_PROTOBUF_COMPILER_CPP_CPP_GENERATOR_H_ -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Generates C++ code for a given .proto file. +#include <thirdparty/protobuf/compiler/cpp/generator.h> -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ - -#include <string> -#include <thirdparty/protobuf/compiler/code_generator.h> - -#include <thirdparty/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -// CodeGenerator implementation which generates a C++ source file and -// header. If you create your own protocol compiler binary and you want -// it to support C++ output, you can do so by registering an instance of this -// CodeGenerator with the CommandLineInterface in your main() function. -class PROTOC_EXPORT CppGenerator : public CodeGenerator { - public: - CppGenerator(); - ~CppGenerator(); - - enum class Runtime { - kGoogle3, // Use the internal google3 runtime. - kOpensource, // Use the open-source runtime. - - // Use the open-source runtime with google3 #include paths. We make these - // absolute to avoid ambiguity, so the runtime will be #included like: - // #include "third_party/protobuf/.../google/protobuf/message.h" - kOpensourceGoogle3 - }; - - void set_opensource_runtime(bool opensource) { - opensource_runtime_ = opensource; - } - - // If set to a non-empty string, generated code will do: - // #include "<BASE>/google/protobuf/message.h" - // instead of: - // #include <thirdparty/protobuf/message.h> - // This has no effect if opensource_runtime = false. - void set_runtime_include_base(const std::string& base) { - runtime_include_base_ = base; - } - - // implements CodeGenerator ---------------------------------------- - bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* generator_context, - std::string* error) const override; - - uint64_t GetSupportedFeatures() const override { - // We don't fully support this yet, but this is needed to unblock the tests, - // and we will have full support before the experimental flag is removed. - return FEATURE_PROTO3_OPTIONAL; - } - - private: - bool opensource_runtime_ = true; - std::string runtime_include_base_; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CppGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <thirdparty/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ +#endif // GOOGLE_PROTOBUF_COMPILER_CPP_CPP_GENERATOR_H_ diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_parse_function_generator.cc b/r5dev/thirdparty/protobuf/compiler/cpp/cpp_parse_function_generator.cc deleted file mode 100644 index 5a40ae19..00000000 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_parse_function_generator.cc +++ /dev/null @@ -1,1303 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include <thirdparty/protobuf/compiler/cpp/cpp_parse_function_generator.h> - -#include <algorithm> -#include <limits> -#include <string> - -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/wire_format.h> - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -namespace { -using google::protobuf::internal::TcFieldData; -using google::protobuf::internal::WireFormat; -using google::protobuf::internal::WireFormatLite; - -std::vector<const FieldDescriptor*> GetOrderedFields( - const Descriptor* descriptor, const Options& options) { - std::vector<const FieldDescriptor*> ordered_fields; - for (auto field : FieldRange(descriptor)) { - if (!IsFieldStripped(field, options)) { - ordered_fields.push_back(field); - } - } - std::sort(ordered_fields.begin(), ordered_fields.end(), - [](const FieldDescriptor* a, const FieldDescriptor* b) { - return a->number() < b->number(); - }); - return ordered_fields; -} - -bool HasInternalAccessors(const FieldOptions::CType ctype) { - return ctype == FieldOptions::STRING || ctype == FieldOptions::CORD; -} - -int TagSize(uint32_t field_number) { - if (field_number < 16) return 1; - GOOGLE_CHECK_LT(field_number, (1 << 14)) - << "coded tag for " << field_number << " too big for uint16_t"; - return 2; -} - -const char* CodedTagType(int tag_size) { - return tag_size == 1 ? "uint8_t" : "uint16_t"; -} - -const char* TagType(const FieldDescriptor* field) { - return CodedTagType(TagSize(field->number())); -} - -std::string TcParserName(const Options& options) { - return StrCat("::", ProtobufNamespace(options), - "::internal::TcParser::"); -} - -std::string MessageTcParseFunctionName(const FieldDescriptor* field, - const Options& options) { - if (field->message_type()->field_count() == 0 || - !HasGeneratedMethods(field->message_type()->file(), options)) { - // For files with `option optimize_for = CODE_SIZE`, or which derive from - // `ZeroFieldsBase`, we need to call the `_InternalParse` function, because - // there is no generated tailcall function. For tailcall parsing, this is - // done by helpers in TcParser. - return StrCat(TcParserName(options), - (field->is_repeated() ? "Repeated" : "Singular"), - "ParseMessage<", - QualifiedClassName(field->message_type()), // - ", ", TagType(field), ">"); - } - // This matches macros in generated_message_tctable_impl.h: - return StrCat("PROTOBUF_TC_PARSE_", - (field->is_repeated() ? "REPEATED" : "SINGULAR"), - TagSize(field->number()), "(", - QualifiedClassName(field->message_type()), ")"); -} - -std::string FieldParseFunctionName(const FieldDescriptor* field, - const Options& options); - -} // namespace - -TailCallTableInfo::TailCallTableInfo(const Descriptor* descriptor, - const Options& options, - const std::vector<int>& has_bit_indices, - MessageSCCAnalyzer* scc_analyzer) { - std::vector<const FieldDescriptor*> ordered_fields = - GetOrderedFields(descriptor, options); - - // The table size is rounded up to the nearest power of 2, clamping at 2^5. - // Note that this is a naive approach: a better approach should only consider - // table-eligible fields. We may also want to push rarely-encountered fields - // into the fallback, to make the table smaller. - table_size_log2 = ordered_fields.size() >= 16 ? 5 - : ordered_fields.size() >= 8 ? 4 - : ordered_fields.size() >= 4 ? 3 - : ordered_fields.size() >= 2 ? 2 - : 1; - const unsigned table_size = 1 << table_size_log2; - - // Construct info for each possible entry. Fields that do not use table-driven - // parsing will still have an entry that nominates the fallback function. - fast_path_fields.resize(table_size); - - for (const auto* field : ordered_fields) { - // Eagerly assume slow path. If we can handle this field on the fast path, - // we will pop its entry from `fallback_fields`. - fallback_fields.push_back(field); - - // Anything difficult slow path: - if (field->is_map()) continue; - if (field->real_containing_oneof()) continue; - if (field->options().weak()) continue; - if (IsImplicitWeakField(field, options, scc_analyzer)) continue; - if (IsLazy(field, options, scc_analyzer)) continue; - - // The largest tag that can be read by the tailcall parser is two bytes - // when varint-coded. This allows 14 bits for the numeric tag value: - // byte 0 byte 1 - // 1nnnnttt 0nnnnnnn - // ^^^^^^^ ^^^^^^^ - uint32_t tag = WireFormat::MakeTag(field); - if (tag >= 1 << 14) { - continue; - } else if (tag >= 1 << 7) { - tag = ((tag << 1) & 0x7F00) | 0x80 | (tag & 0x7F); - } - // The field index is determined by the low bits of the field number, where - // the table size determines the width of the mask. The largest table - // supported is 32 entries. The parse loop uses these bits directly, so that - // the dispatch does not require arithmetic: - // byte 0 byte 1 - // 1nnnnttt 0nnnnnnn - // ^^^^^ - // This means that any field number that does not fit in the lower 4 bits - // will always have the top bit of its table index asserted: - uint32_t idx = (tag >> 3) & (table_size - 1); - // If this entry in the table is already used, then this field will be - // handled by the generated fallback function. - if (!fast_path_fields[idx].func_name.empty()) continue; - - // Determine the hasbit mask for this field, if needed. (Note that fields - // without hasbits use different parse functions.) - int hasbit_idx; - if (HasHasbit(field)) { - hasbit_idx = has_bit_indices[field->index()]; - GOOGLE_CHECK_NE(-1, hasbit_idx) << field->DebugString(); - // The tailcall parser can only update the first 32 hasbits. If this - // field's has-bit is beyond that, then it will need to be handled by the - // fallback parse function. - if (hasbit_idx >= 32) continue; - } else { - // The tailcall parser only ever syncs 32 has-bits, so if there is no - // presence, set a bit that will not be used. - hasbit_idx = 63; - } - - // Determine the name of the fastpath parse function to use for this field. - std::string name; - - switch (field->type()) { - case FieldDescriptor::TYPE_MESSAGE: - name = MessageTcParseFunctionName(field, options); - break; - - case FieldDescriptor::TYPE_FIXED64: - case FieldDescriptor::TYPE_FIXED32: - case FieldDescriptor::TYPE_SFIXED64: - case FieldDescriptor::TYPE_SFIXED32: - case FieldDescriptor::TYPE_DOUBLE: - case FieldDescriptor::TYPE_FLOAT: - case FieldDescriptor::TYPE_INT64: - case FieldDescriptor::TYPE_INT32: - case FieldDescriptor::TYPE_UINT64: - case FieldDescriptor::TYPE_UINT32: - case FieldDescriptor::TYPE_SINT64: - case FieldDescriptor::TYPE_SINT32: - case FieldDescriptor::TYPE_BOOL: - name = FieldParseFunctionName(field, options); - break; - - case FieldDescriptor::TYPE_BYTES: - if (field->options().ctype() == FieldOptions::STRING && - field->default_value_string().empty() && - !IsStringInlined(field, options)) { - name = FieldParseFunctionName(field, options); - } - break; - - default: - break; - } - - if (name.empty()) { - continue; - } - // This field made it into the fast path, so remove it from the fallback - // fields and fill in the table entry. - fallback_fields.pop_back(); - fast_path_fields[idx].func_name = name; - fast_path_fields[idx].bits = TcFieldData(tag, hasbit_idx, 0); - fast_path_fields[idx].field = field; - } - - // If there are no fallback fields, and at most one extension range, the - // parser can use a generic fallback function. Otherwise, a message-specific - // fallback routine is needed. - use_generated_fallback = - !fallback_fields.empty() || descriptor->extension_range_count() > 1; -} - -ParseFunctionGenerator::ParseFunctionGenerator( - const Descriptor* descriptor, int max_has_bit_index, - const std::vector<int>& has_bit_indices, - const std::vector<int>& inlined_string_indices, const Options& options, - MessageSCCAnalyzer* scc_analyzer, - const std::map<std::string, std::string>& vars) - : descriptor_(descriptor), - scc_analyzer_(scc_analyzer), - options_(options), - variables_(vars), - inlined_string_indices_(inlined_string_indices), - num_hasbits_(max_has_bit_index) { - if (should_generate_tctable()) { - tc_table_info_.reset(new TailCallTableInfo(descriptor_, options_, - has_bit_indices, scc_analyzer)); - } - SetCommonVars(options_, &variables_); - SetUnknownFieldsVariable(descriptor_, options_, &variables_); - variables_["classname"] = ClassName(descriptor, false); -} - -void ParseFunctionGenerator::GenerateMethodDecls(io::Printer* printer) { - Formatter format(printer, variables_); - if (should_generate_tctable()) { - auto declare_function = [&format](const char* name, - const std::string& guard) { - if (!guard.empty()) { - format.Outdent(); - format("#if $1$\n", guard); - format.Indent(); - } - format("static const char* $1$(PROTOBUF_TC_PARAM_DECL);\n", name); - if (!guard.empty()) { - format.Outdent(); - format("#endif // $1$\n", guard); - format.Indent(); - } - }; - if (should_generate_guarded_tctable()) { - format.Outdent(); - format("#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); - format.Indent(); - } - format("// The Tct_* functions are internal to the protobuf runtime:\n"); - // These guards are defined in port_def.inc: - declare_function("Tct_ParseS1", "PROTOBUF_TC_STATIC_PARSE_SINGULAR1"); - declare_function("Tct_ParseS2", "PROTOBUF_TC_STATIC_PARSE_SINGULAR2"); - declare_function("Tct_ParseR1", "PROTOBUF_TC_STATIC_PARSE_REPEATED1"); - declare_function("Tct_ParseR2", "PROTOBUF_TC_STATIC_PARSE_REPEATED2"); - if (tc_table_info_->use_generated_fallback) { - format.Outdent(); - format( - " private:\n" - " "); - declare_function("Tct_ParseFallback", ""); - format(" public:\n"); - format.Indent(); - } - if (should_generate_guarded_tctable()) { - format.Outdent(); - format("#endif\n"); - format.Indent(); - } - } - format( - "const char* _InternalParse(const char* ptr, " - "::$proto_ns$::internal::ParseContext* ctx) final;\n"); -} - -void ParseFunctionGenerator::GenerateMethodImpls(io::Printer* printer) { - Formatter format(printer, variables_); - bool need_parse_function = true; - if (descriptor_->options().message_set_wire_format()) { - // Special-case MessageSet. - need_parse_function = false; - format( - "const char* $classname$::_InternalParse(const char* ptr,\n" - " ::$proto_ns$::internal::ParseContext* ctx) {\n" - "$annotate_deserialize$" - " return _extensions_.ParseMessageSet(ptr, \n" - " internal_default_instance(), &_internal_metadata_, ctx);\n" - "}\n"); - } - if (!should_generate_tctable()) { - if (need_parse_function) { - GenerateLoopingParseFunction(format); - } - return; - } - if (should_generate_guarded_tctable()) { - format("#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n\n"); - } - if (need_parse_function) { - GenerateTailcallParseFunction(format); - } - if (tc_table_info_->use_generated_fallback) { - GenerateTailcallFallbackFunction(format); - } - GenerateTailcallFieldParseFunctions(format); - if (should_generate_guarded_tctable()) { - if (need_parse_function) { - format("\n#else // PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n\n"); - GenerateLoopingParseFunction(format); - } - format("\n#endif // PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); - } -} - -bool ParseFunctionGenerator::should_generate_tctable() const { - if (options_.tctable_mode == Options::kTCTableNever) { - return false; - } - return true; -} - -void ParseFunctionGenerator::GenerateTailcallParseFunction(Formatter& format) { - GOOGLE_CHECK(should_generate_tctable()); - - // Generate an `_InternalParse` that starts the tail-calling loop. - format( - "const char* $classname$::_InternalParse(\n" - " const char* ptr, ::$proto_ns$::internal::ParseContext* ctx) {\n" - "$annotate_deserialize$" - " ptr = ::$proto_ns$::internal::TcParser::ParseLoop(\n" - " this, ptr, ctx, &_table_.header);\n"); - format( - " return ptr;\n" - "}\n\n"); -} - -void ParseFunctionGenerator::GenerateTailcallFallbackFunction( - Formatter& format) { - GOOGLE_CHECK(should_generate_tctable()); - format( - "const char* $classname$::Tct_ParseFallback(PROTOBUF_TC_PARAM_DECL) {\n" - "#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) return nullptr\n"); - format.Indent(); - format("auto* typed_msg = static_cast<$classname$*>(msg);\n"); - - if (num_hasbits_ > 0) { - // Sync hasbits - format("typed_msg->_has_bits_[0] = hasbits;\n"); - } - - format.Set("msg", "typed_msg->"); - format.Set("this", "typed_msg"); - format.Set("has_bits", "typed_msg->_has_bits_"); - format.Set("next_tag", "goto next_tag"); - GenerateParseIterationBody(format, descriptor_, - tc_table_info_->fallback_fields); - - format.Outdent(); - format( - "next_tag:\n" - "message_done:\n" - " return ptr;\n" - "#undef CHK_\n" - "}\n"); -} - -void ParseFunctionGenerator::GenerateTailcallFieldParseFunctions( - Formatter& format) { - GOOGLE_CHECK(should_generate_tctable()); - // There are four cases where a tailcall target are needed for messages: - // {singular, repeated} x {1, 2}-byte tag - struct { - const char* type; - int size; - } const kTagLayouts[] = { - {"uint8_t", 1}, - {"uint16_t", 2}, - }; - // Singular: - for (const auto& layout : kTagLayouts) { - // Guard macros are defined in port_def.inc. - format( - "#if PROTOBUF_TC_STATIC_PARSE_SINGULAR$1$\n" - "const char* $classname$::Tct_ParseS$1$(PROTOBUF_TC_PARAM_DECL) {\n" - " if (PROTOBUF_PREDICT_FALSE(data.coded_tag<$2$>() != 0))\n" - " PROTOBUF_MUSTTAIL " - "return table->fallback(PROTOBUF_TC_PARAM_PASS);\n" - " ptr += $1$;\n" - " hasbits |= (uint64_t{1} << data.hasbit_idx());\n" - " ::$proto_ns$::internal::TcParser::SyncHasbits" - "(msg, hasbits, table);\n" - " auto& field = ::$proto_ns$::internal::TcParser::" - "RefAt<$classtype$*>(msg, data.offset());\n" - " if (field == nullptr)\n" - " field = CreateMaybeMessage<$classtype$>(ctx->data().arena);\n" - " return ctx->ParseMessage(field, ptr);\n" - "}\n" - "#endif // PROTOBUF_TC_STATIC_PARSE_SINGULAR$1$\n", - layout.size, layout.type); - } - // Repeated: - for (const auto& layout : kTagLayouts) { - // Guard macros are defined in port_def.inc. - format( - "#if PROTOBUF_TC_STATIC_PARSE_REPEATED$1$\n" - "const char* $classname$::Tct_ParseR$1$(PROTOBUF_TC_PARAM_DECL) {\n" - " if (PROTOBUF_PREDICT_FALSE(data.coded_tag<$2$>() != 0)) {\n" - " PROTOBUF_MUSTTAIL " - "return table->fallback(PROTOBUF_TC_PARAM_PASS);\n" - " }\n" - " ptr += $1$;\n" - " auto& field = ::$proto_ns$::internal::TcParser::RefAt<" - "::$proto_ns$::RepeatedPtrField<$classname$>>(msg, data.offset());\n" - " ::$proto_ns$::internal::TcParser::SyncHasbits" - "(msg, hasbits, table);\n" - " ptr = ctx->ParseMessage(field.Add(), ptr);\n" - " return ptr;\n" - "}\n" - "#endif // PROTOBUF_TC_STATIC_PARSE_REPEATED$1$\n", - layout.size, layout.type); - } -} - -void ParseFunctionGenerator::GenerateDataDecls(io::Printer* printer) { - if (!should_generate_tctable()) { - return; - } - Formatter format(printer, variables_); - if (should_generate_guarded_tctable()) { - format.Outdent(); - format("#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); - format.Indent(); - } - format( - "static const ::$proto_ns$::internal::TcParseTable<$1$>\n" - " _table_;\n", - tc_table_info_->table_size_log2); - if (should_generate_guarded_tctable()) { - format.Outdent(); - format("#endif // PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); - format.Indent(); - } -} - -void ParseFunctionGenerator::GenerateDataDefinitions(io::Printer* printer) { - if (!should_generate_tctable()) { - return; - } - Formatter format(printer, variables_); - if (should_generate_guarded_tctable()) { - format("#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); - } - GenerateTailCallTable(format); - if (should_generate_guarded_tctable()) { - format("#endif // PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); - } -} - -void ParseFunctionGenerator::GenerateLoopingParseFunction(Formatter& format) { - format( - "const char* $classname$::_InternalParse(const char* ptr, " - "::$proto_ns$::internal::ParseContext* ctx) {\n" - "$annotate_deserialize$" - "#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure\n"); - format.Indent(); - format.Set("msg", ""); - format.Set("this", "this"); - int hasbits_size = 0; - if (num_hasbits_ > 0) { - hasbits_size = (num_hasbits_ + 31) / 32; - } - // For now only optimize small hasbits. - if (hasbits_size != 1) hasbits_size = 0; - if (hasbits_size) { - format("_Internal::HasBits has_bits{};\n"); - format.Set("has_bits", "has_bits"); - } else { - format.Set("has_bits", "_has_bits_"); - } - format.Set("next_tag", "continue"); - format("while (!ctx->Done(&ptr)) {\n"); - format.Indent(); - - GenerateParseIterationBody(format, descriptor_, - GetOrderedFields(descriptor_, options_)); - - format.Outdent(); - format("} // while\n"); - - format.Outdent(); - format("message_done:\n"); - if (hasbits_size) format(" _has_bits_.Or(has_bits);\n"); - - format( - " return ptr;\n" - "failure:\n" - " ptr = nullptr;\n" - " goto message_done;\n" - "#undef CHK_\n" - "}\n"); -} - -void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) { - GOOGLE_CHECK(should_generate_tctable()); - // All entries without a fast-path parsing function need a fallback. - std::string fallback; - if (tc_table_info_->use_generated_fallback) { - fallback = ClassName(descriptor_) + "::Tct_ParseFallback"; - } else { - fallback = TcParserName(options_) + "GenericFallback"; - if (GetOptimizeFor(descriptor_->file(), options_) == - FileOptions::LITE_RUNTIME) { - fallback += "Lite"; - } - } - - // For simplicity and speed, the table is not covering all proto - // configurations. This model uses a fallback to cover all situations that - // the table can't accommodate, together with unknown fields or extensions. - // These are number of fields over 32, fields with 3 or more tag bytes, - // maps, weak fields, lazy, more than 1 extension range. In the cases - // the table is sufficient we can use a generic routine, that just handles - // unknown fields and potentially an extension range. - format( - "const ::$proto_ns$::internal::TcParseTable<$1$>\n" - " $classname$::_table_ = {\n", - tc_table_info_->table_size_log2); - { - auto table_scope = format.ScopedIndent(); - format("{\n"); - { - auto header_scope = format.ScopedIndent(); - if (num_hasbits_ > 0 || IsMapEntryMessage(descriptor_)) { - format("PROTOBUF_FIELD_OFFSET($classname$, _has_bits_),\n"); - } else { - format("0, // no _has_bits_\n"); - } - if (descriptor_->extension_range_count() == 1) { - format( - "PROTOBUF_FIELD_OFFSET($classname$, _extensions_),\n" - "$1$, $2$, // extension_range_{low,high}\n", - descriptor_->extension_range(0)->start, - descriptor_->extension_range(0)->end); - } else { - format("0, 0, 0, // no _extensions_\n"); - } - format( - "$1$, 0, $2$, // fast_idx_mask, reserved, num_fields\n" - "&$3$._instance,\n" - "$4$ // fallback\n", - (((1 << tc_table_info_->table_size_log2) - 1) << 3), - descriptor_->field_count(), - DefaultInstanceName(descriptor_, options_), fallback); - } - format("}, {\n"); - { - auto fast_scope = format.ScopedIndent(); - GenerateFastFieldEntries(format, fallback); - } - format("},\n"); // entries[] - } - format("};\n\n"); // _table_ -} - -void ParseFunctionGenerator::GenerateFastFieldEntries( - Formatter& format, const std::string& fallback) { - for (const auto& info : tc_table_info_->fast_path_fields) { - if (info.field != nullptr) { - PrintFieldComment(format, info.field); - } - format("{$1$, ", info.func_name.empty() ? fallback : info.func_name); - if (info.bits.data) { - GOOGLE_DCHECK_NE(nullptr, info.field); - format( - "{$1$, $2$, " - "static_cast<uint16_t>(PROTOBUF_FIELD_OFFSET($classname$, $3$_))}", - info.bits.coded_tag(), info.bits.hasbit_idx(), FieldName(info.field)); - } else { - format("{}"); - } - format("},\n"); - } -} - -void ParseFunctionGenerator::GenerateArenaString(Formatter& format, - const FieldDescriptor* field) { - if (HasHasbit(field)) { - format("_Internal::set_has_$1$(&$has_bits$);\n", FieldName(field)); - } - std::string default_string = - field->default_value_string().empty() - ? "::" + ProtobufNamespace(options_) + - "::internal::GetEmptyStringAlreadyInited()" - : QualifiedClassName(field->containing_type(), options_) + - "::" + MakeDefaultName(field) + ".get()"; - format( - "if (arena != nullptr) {\n" - " ptr = ctx->ReadArenaString(ptr, &$msg$$name$_, arena"); - if (IsStringInlined(field, options_)) { - GOOGLE_DCHECK(!inlined_string_indices_.empty()); - int inlined_string_index = inlined_string_indices_[field->index()]; - GOOGLE_DCHECK_GE(inlined_string_index, 0); - format( - ", $msg$_internal_$name$_donated()" - ", &$msg$_inlined_string_donated_[$1$]" - ", ~0x$2$u", - inlined_string_index / 32, - strings::Hex(1u << (inlined_string_index % 32), strings::ZERO_PAD_8)); - } else { - GOOGLE_DCHECK(field->default_value_string().empty()); - } - format( - ");\n" - "} else {\n" - " ptr = ::$proto_ns$::internal::InlineGreedyStringParser(" - "$msg$$name$_.MutableNoArenaNoDefault(&$1$), ptr, ctx);\n" - "}\n" - "const std::string* str = &$msg$$name$_.Get(); (void)str;\n", - default_string); -} - -void ParseFunctionGenerator::GenerateStrings(Formatter& format, - const FieldDescriptor* field, - bool check_utf8) { - FieldOptions::CType ctype = FieldOptions::STRING; - if (!options_.opensource_runtime) { - // Open source doesn't support other ctypes; - ctype = field->options().ctype(); - } - if (!field->is_repeated() && !options_.opensource_runtime && - GetOptimizeFor(field->file(), options_) != FileOptions::LITE_RUNTIME && - // For now only use arena string for strings with empty defaults. - field->default_value_string().empty() && - !field->real_containing_oneof() && ctype == FieldOptions::STRING) { - GenerateArenaString(format, field); - } else { - std::string parser_name; - switch (ctype) { - case FieldOptions::STRING: - parser_name = "GreedyStringParser"; - break; - case FieldOptions::CORD: - parser_name = "CordParser"; - break; - case FieldOptions::STRING_PIECE: - parser_name = "StringPieceParser"; - break; - } - format( - "auto str = $msg$$1$$2$_$name$();\n" - "ptr = ::$proto_ns$::internal::Inline$3$(str, ptr, ctx);\n", - HasInternalAccessors(ctype) ? "_internal_" : "", - field->is_repeated() && !field->is_packable() ? "add" : "mutable", - parser_name); - } - if (!check_utf8) return; // return if this is a bytes field - auto level = GetUtf8CheckMode(field, options_); - switch (level) { - case Utf8CheckMode::kNone: - return; - case Utf8CheckMode::kVerify: - format("#ifndef NDEBUG\n"); - break; - case Utf8CheckMode::kStrict: - format("CHK_("); - break; - } - std::string field_name; - field_name = "nullptr"; - if (HasDescriptorMethods(field->file(), options_)) { - field_name = StrCat("\"", field->full_name(), "\""); - } - format("::$proto_ns$::internal::VerifyUTF8(str, $1$)", field_name); - switch (level) { - case Utf8CheckMode::kNone: - return; - case Utf8CheckMode::kVerify: - format( - ";\n" - "#endif // !NDEBUG\n"); - break; - case Utf8CheckMode::kStrict: - format(");\n"); - break; - } -} - -void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format, - const FieldDescriptor* field) { - if (field->is_packable()) { - if (field->type() == FieldDescriptor::TYPE_ENUM && - !HasPreservingUnknownEnumSemantics(field)) { - std::string enum_type = QualifiedClassName(field->enum_type(), options_); - format( - "ptr = " - "::$proto_ns$::internal::Packed$1$Parser<$unknown_fields_type$>(" - "$msg$_internal_mutable_$name$(), ptr, ctx, $2$_IsValid, " - "&$msg$_internal_metadata_, $3$);\n", - DeclaredTypeMethodName(field->type()), enum_type, field->number()); - } else { - format( - "ptr = ::$proto_ns$::internal::Packed$1$Parser(" - "$msg$_internal_mutable_$name$(), ptr, ctx);\n", - DeclaredTypeMethodName(field->type())); - } - } else { - auto field_type = field->type(); - switch (field_type) { - case FieldDescriptor::TYPE_STRING: - GenerateStrings(format, field, true /* utf8 */); - break; - case FieldDescriptor::TYPE_BYTES: - GenerateStrings(format, field, false /* utf8 */); - break; - case FieldDescriptor::TYPE_MESSAGE: { - if (field->is_map()) { - const FieldDescriptor* val = - field->message_type()->FindFieldByName("value"); - GOOGLE_CHECK(val); - if (val->type() == FieldDescriptor::TYPE_ENUM && - !HasPreservingUnknownEnumSemantics(field)) { - format( - "auto object = " - "::$proto_ns$::internal::InitEnumParseWrapper<" - "$unknown_fields_type$>(&$msg$$name$_, $1$_IsValid, " - "$2$, &$msg$_internal_metadata_);\n" - "ptr = ctx->ParseMessage(&object, ptr);\n", - QualifiedClassName(val->enum_type(), options_), - field->number()); - } else { - format("ptr = ctx->ParseMessage(&$msg$$name$_, ptr);\n"); - } - } else if (IsLazy(field, options_, scc_analyzer_)) { - if (field->real_containing_oneof()) { - format( - "if (!$msg$_internal_has_$name$()) {\n" - " $msg$clear_$1$();\n" - " $msg$$1$_.$name$_ = ::$proto_ns$::Arena::CreateMessage<\n" - " ::$proto_ns$::internal::LazyField>(" - "$msg$GetArenaForAllocation());\n" - " $msg$set_has_$name$();\n" - "}\n" - "auto* lazy_field = $msg$$1$_.$name$_;\n", - field->containing_oneof()->name()); - } else if (HasHasbit(field)) { - format( - "_Internal::set_has_$name$(&$has_bits$);\n" - "auto* lazy_field = &$msg$$name$_;\n"); - } else { - format("auto* lazy_field = &$msg$$name$_;\n"); - } - format( - "::$proto_ns$::internal::LazyFieldParseHelper<\n" - " ::$proto_ns$::internal::LazyField> parse_helper(\n" - " $1$::default_instance(),\n" - " $msg$GetArenaForAllocation(), lazy_field);\n" - "ptr = ctx->ParseMessage(&parse_helper, ptr);\n", - FieldMessageTypeName(field, options_)); - } else if (IsImplicitWeakField(field, options_, scc_analyzer_)) { - if (!field->is_repeated()) { - format( - "ptr = ctx->ParseMessage(_Internal::mutable_$name$($this$), " - "ptr);\n"); - } else { - format( - "ptr = ctx->ParseMessage($msg$$name$_.AddWeak(" - "reinterpret_cast<const ::$proto_ns$::MessageLite*>($1$ptr_)" - "), ptr);\n", - QualifiedDefaultInstanceName(field->message_type(), options_)); - } - } else if (IsWeak(field, options_)) { - format( - "{\n" - " auto* default_ = &reinterpret_cast<const Message&>($1$);\n" - " ptr = ctx->ParseMessage($msg$_weak_field_map_.MutableMessage(" - "$2$, default_), ptr);\n" - "}\n", - QualifiedDefaultInstanceName(field->message_type(), options_), - field->number()); - } else { - format( - "ptr = ctx->ParseMessage($msg$_internal_$mutable_field$(), " - "ptr);\n"); - } - break; - } - default: - GOOGLE_LOG(FATAL) << "Illegal combination for length delimited wiretype " - << " filed type is " << field->type(); - } - } -} - -static bool ShouldRepeat(const FieldDescriptor* descriptor, - WireFormatLite::WireType wiretype) { - constexpr int kMaxTwoByteFieldNumber = 16 * 128; - return descriptor->number() < kMaxTwoByteFieldNumber && - descriptor->is_repeated() && - (!descriptor->is_packable() || - wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED); -} - -void ParseFunctionGenerator::GenerateFieldBody( - Formatter& format, WireFormatLite::WireType wiretype, - const FieldDescriptor* field) { - Formatter::SaveState formatter_state(&format); - format.AddMap( - {{"name", FieldName(field)}, - {"primitive_type", PrimitiveTypeName(options_, field->cpp_type())}}); - if (field->is_repeated()) { - format.AddMap({{"put_field", StrCat("add_", FieldName(field))}, - {"mutable_field", StrCat("add_", FieldName(field))}}); - } else { - format.AddMap( - {{"put_field", StrCat("set_", FieldName(field))}, - {"mutable_field", StrCat("mutable_", FieldName(field))}}); - } - uint32_t tag = WireFormatLite::MakeTag(field->number(), wiretype); - switch (wiretype) { - case WireFormatLite::WIRETYPE_VARINT: { - std::string type = PrimitiveTypeName(options_, field->cpp_type()); - if (field->type() == FieldDescriptor::TYPE_ENUM) { - format.Set("enum_type", - QualifiedClassName(field->enum_type(), options_)); - format( - "$uint64$ val = ::$proto_ns$::internal::ReadVarint64(&ptr);\n" - "CHK_(ptr);\n"); - if (!HasPreservingUnknownEnumSemantics(field)) { - format("if (PROTOBUF_PREDICT_TRUE($enum_type$_IsValid(val))) {\n"); - format.Indent(); - } - format("$msg$_internal_$put_field$(static_cast<$enum_type$>(val));\n"); - if (!HasPreservingUnknownEnumSemantics(field)) { - format.Outdent(); - format( - "} else {\n" - " ::$proto_ns$::internal::WriteVarint(" - "$1$, val, $msg$mutable_unknown_fields());\n" - "}\n", - field->number()); - } - } else { - std::string size = (field->type() == FieldDescriptor::TYPE_INT32 || - field->type() == FieldDescriptor::TYPE_SINT32 || - field->type() == FieldDescriptor::TYPE_UINT32) - ? "32" - : "64"; - std::string zigzag; - if ((field->type() == FieldDescriptor::TYPE_SINT32 || - field->type() == FieldDescriptor::TYPE_SINT64)) { - zigzag = "ZigZag"; - } - if (field->is_repeated() || field->real_containing_oneof()) { - format( - "$msg$_internal_$put_field$(" - "::$proto_ns$::internal::ReadVarint$1$$2$(&ptr));\n" - "CHK_(ptr);\n", - zigzag, size); - } else { - if (HasHasbit(field)) { - format("_Internal::set_has_$name$(&$has_bits$);\n"); - } - format( - "$msg$$name$_ = ::$proto_ns$::internal::ReadVarint$1$$2$(&ptr);\n" - "CHK_(ptr);\n", - zigzag, size); - } - } - break; - } - case WireFormatLite::WIRETYPE_FIXED32: - case WireFormatLite::WIRETYPE_FIXED64: { - if (field->is_repeated() || field->real_containing_oneof()) { - format( - "$msg$_internal_$put_field$(" - "::$proto_ns$::internal::UnalignedLoad<$primitive_type$>(ptr));\n" - "ptr += sizeof($primitive_type$);\n"); - } else { - if (HasHasbit(field)) { - format("_Internal::set_has_$name$(&$has_bits$);\n"); - } - format( - "$msg$$name$_ = " - "::$proto_ns$::internal::UnalignedLoad<$primitive_type$>(ptr);\n" - "ptr += sizeof($primitive_type$);\n"); - } - break; - } - case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: { - GenerateLengthDelim(format, field); - format("CHK_(ptr);\n"); - break; - } - case WireFormatLite::WIRETYPE_START_GROUP: { - format( - "ptr = ctx->ParseGroup($msg$_internal_$mutable_field$(), ptr, $1$);\n" - "CHK_(ptr);\n", - tag); - break; - } - case WireFormatLite::WIRETYPE_END_GROUP: { - GOOGLE_LOG(FATAL) << "Can't have end group field\n"; - break; - } - } // switch (wire_type) -} - -// Returns the tag for this field and in case of repeated packable fields, -// sets a fallback tag in fallback_tag_ptr. -static uint32_t ExpectedTag(const FieldDescriptor* field, - uint32_t* fallback_tag_ptr) { - uint32_t expected_tag; - if (field->is_packable()) { - auto expected_wiretype = WireFormat::WireTypeForFieldType(field->type()); - expected_tag = WireFormatLite::MakeTag(field->number(), expected_wiretype); - GOOGLE_CHECK(expected_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - auto fallback_wiretype = WireFormatLite::WIRETYPE_LENGTH_DELIMITED; - uint32_t fallback_tag = - WireFormatLite::MakeTag(field->number(), fallback_wiretype); - - if (field->is_packed()) std::swap(expected_tag, fallback_tag); - *fallback_tag_ptr = fallback_tag; - } else { - auto expected_wiretype = WireFormat::WireTypeForField(field); - expected_tag = WireFormatLite::MakeTag(field->number(), expected_wiretype); - } - return expected_tag; -} - -// These variables are used by the generated parse iteration, and must already -// be defined in the generated code: -// - `const char* ptr`: the input buffer. -// - `ParseContext* ctx`: the associated context for `ptr`. -// - implicit `this`: i.e., we must be in a non-static member function. -// -// The macro `CHK_(x)` must be defined. It should return an error condition if -// the macro parameter is false. -// -// Whenever an END_GROUP tag was read, or tag 0 was read, the generated code -// branches to the label `message_done`. -// -// These formatter variables are used: -// - `next_tag`: a single statement to begin parsing the next tag. -// -// At the end of the generated code, the enclosing function should proceed to -// parse the next tag in the stream. -void ParseFunctionGenerator::GenerateParseIterationBody( - Formatter& format, const Descriptor* descriptor, - const std::vector<const FieldDescriptor*>& ordered_fields) { - format( - "$uint32$ tag;\n" - "ptr = ::$proto_ns$::internal::ReadTag(ptr, &tag);\n"); - - if (!ordered_fields.empty()) { - GenerateFieldSwitch(format, ordered_fields); - // Each field `case` only considers field number. Field numbers that are - // not defined in the message, or tags with an incompatible wire type, are - // considered "unusual" cases. They will be handled by the logic below. - format.Outdent(); - format("handle_unusual:\n"); - format.Indent(); - } - - // Unusual/extension/unknown case: - format( - "if ((tag == 0) || ((tag & 7) == 4)) {\n" - " CHK_(ptr);\n" - " ctx->SetLastTag(tag);\n" - " goto message_done;\n" - "}\n"); - if (IsMapEntryMessage(descriptor)) { - format("$next_tag$;\n"); - } else { - if (descriptor->extension_range_count() > 0) { - format("if ("); - for (int i = 0; i < descriptor->extension_range_count(); i++) { - const Descriptor::ExtensionRange* range = - descriptor->extension_range(i); - if (i > 0) format(" ||\n "); - - uint32_t start_tag = WireFormatLite::MakeTag( - range->start, static_cast<WireFormatLite::WireType>(0)); - uint32_t end_tag = WireFormatLite::MakeTag( - range->end, static_cast<WireFormatLite::WireType>(0)); - - if (range->end > FieldDescriptor::kMaxNumber) { - format("($1$u <= tag)", start_tag); - } else { - format("($1$u <= tag && tag < $2$u)", start_tag, end_tag); - } - } - format( - ") {\n" - " ptr = $msg$_extensions_.ParseField(tag, ptr, " - "internal_default_instance(), &$msg$_internal_metadata_, ctx);\n" - " CHK_(ptr != nullptr);\n" - " $next_tag$;\n" - "}\n"); - } - format( - "ptr = UnknownFieldParse(\n" - " tag,\n" - " $msg$_internal_metadata_.mutable_unknown_fields<" - "$unknown_fields_type$>(),\n" - " ptr, ctx);\n" - "CHK_(ptr != nullptr);\n"); - } -} - -void ParseFunctionGenerator::GenerateFieldSwitch( - Formatter& format, - const std::vector<const FieldDescriptor*>& ordered_fields) { - format("switch (tag >> 3) {\n"); - format.Indent(); - - for (const auto* field : ordered_fields) { - PrintFieldComment(format, field); - format("case $1$:\n", field->number()); - format.Indent(); - uint32_t fallback_tag = 0; - uint32_t expected_tag = ExpectedTag(field, &fallback_tag); - format("if (PROTOBUF_PREDICT_TRUE(static_cast<$uint8$>(tag) == $1$)) {\n", - expected_tag & 0xFF); - format.Indent(); - auto wiretype = WireFormatLite::GetTagWireType(expected_tag); - uint32_t tag = WireFormatLite::MakeTag(field->number(), wiretype); - int tag_size = io::CodedOutputStream::VarintSize32(tag); - bool is_repeat = ShouldRepeat(field, wiretype); - if (is_repeat) { - format( - "ptr -= $1$;\n" - "do {\n" - " ptr += $1$;\n", - tag_size); - format.Indent(); - } - GenerateFieldBody(format, wiretype, field); - if (is_repeat) { - format.Outdent(); - format( - " if (!ctx->DataAvailable(ptr)) break;\n" - "} while (::$proto_ns$::internal::ExpectTag<$1$>(ptr));\n", - tag); - } - format.Outdent(); - if (fallback_tag) { - format("} else if (static_cast<$uint8$>(tag) == $1$) {\n", - fallback_tag & 0xFF); - format.Indent(); - GenerateFieldBody(format, WireFormatLite::GetTagWireType(fallback_tag), - field); - format.Outdent(); - } - format( - "} else\n" - " goto handle_unusual;\n" - "$next_tag$;\n"); - format.Outdent(); - } // for loop over ordered fields - - format( - "default:\n" - " goto handle_unusual;\n"); - format.Outdent(); - format("} // switch\n"); -} - -namespace { - -std::string FieldParseFunctionName(const FieldDescriptor* field, - const Options& options) { - ParseCardinality card = // - field->is_packed() ? ParseCardinality::kPacked - : field->is_repeated() ? ParseCardinality::kRepeated - : field->real_containing_oneof() ? ParseCardinality::kOneof - : ParseCardinality::kSingular; - - TypeFormat type_format; - switch (field->type()) { - case FieldDescriptor::TYPE_FIXED64: - case FieldDescriptor::TYPE_SFIXED64: - case FieldDescriptor::TYPE_DOUBLE: - type_format = TypeFormat::kFixed64; - break; - - case FieldDescriptor::TYPE_FIXED32: - case FieldDescriptor::TYPE_SFIXED32: - case FieldDescriptor::TYPE_FLOAT: - type_format = TypeFormat::kFixed32; - break; - - case FieldDescriptor::TYPE_INT64: - case FieldDescriptor::TYPE_UINT64: - type_format = TypeFormat::kVar64; - break; - - case FieldDescriptor::TYPE_INT32: - case FieldDescriptor::TYPE_UINT32: - type_format = TypeFormat::kVar32; - break; - - case FieldDescriptor::TYPE_SINT64: - type_format = TypeFormat::kSInt64; - break; - - case FieldDescriptor::TYPE_SINT32: - type_format = TypeFormat::kSInt32; - break; - - case FieldDescriptor::TYPE_BOOL: - type_format = TypeFormat::kBool; - break; - - case FieldDescriptor::TYPE_BYTES: - type_format = TypeFormat::kBytes; - break; - - case FieldDescriptor::TYPE_STRING: - switch (GetUtf8CheckMode(field, options)) { - case Utf8CheckMode::kNone: - type_format = TypeFormat::kBytes; - break; - case Utf8CheckMode::kStrict: - type_format = TypeFormat::kString; - break; - case Utf8CheckMode::kVerify: - type_format = TypeFormat::kStringValidateOnly; - break; - default: - GOOGLE_LOG(DFATAL) << "Mode not handled: " - << static_cast<int>(GetUtf8CheckMode(field, options)); - return ""; - } - break; - - default: - GOOGLE_LOG(DFATAL) << "Type not handled: " << field->DebugString(); - return ""; - } - - return "::" + ProtobufNamespace(options) + "::internal::TcParser::" + - GetTailCallFieldHandlerName(card, type_format, - TagSize(field->number()), options); -} - -} // namespace - -std::string GetTailCallFieldHandlerName(ParseCardinality card, - TypeFormat type_format, - int tag_length_bytes, - const Options& options) { - std::string name; - - // The field implementation functions are prefixed by cardinality: - // `Singular` for optional or implicit fields. - // `Repeated` for non-packed repeated. - // `Packed` for packed repeated. - switch (card) { - case ParseCardinality::kSingular: - name.append("Singular"); - break; - case ParseCardinality::kOneof: - name.append("Oneof"); - break; - case ParseCardinality::kRepeated: - name.append("Repeated"); - break; - case ParseCardinality::kPacked: - name.append("Packed"); - break; - } - - // Next in the function name is the TypeFormat-specific name. - switch (type_format) { - case TypeFormat::kFixed64: - case TypeFormat::kFixed32: - name.append("Fixed"); - break; - - case TypeFormat::kVar64: - case TypeFormat::kVar32: - case TypeFormat::kSInt64: - case TypeFormat::kSInt32: - case TypeFormat::kBool: - name.append("Varint"); - break; - - case TypeFormat::kBytes: - case TypeFormat::kString: - case TypeFormat::kStringValidateOnly: - name.append("String"); - break; - - default: - break; - } - - name.append("<"); - - // Determine the numeric layout type for the parser to use, independent of - // the specific parsing logic used. - switch (type_format) { - case TypeFormat::kVar64: - case TypeFormat::kFixed64: - name.append("uint64_t, "); - break; - - case TypeFormat::kSInt64: - name.append("int64_t, "); - break; - - case TypeFormat::kVar32: - case TypeFormat::kFixed32: - name.append("uint32_t, "); - break; - - case TypeFormat::kSInt32: - name.append("int32_t, "); - break; - - case TypeFormat::kBool: - name.append("bool, "); - break; - - default: - break; - } - - name.append(CodedTagType(tag_length_bytes)); - - switch (type_format) { - case TypeFormat::kVar64: - case TypeFormat::kVar32: - case TypeFormat::kBool: - StrAppend(&name, ", ", TcParserName(options), "kNoConversion"); - break; - - case TypeFormat::kSInt64: - case TypeFormat::kSInt32: - StrAppend(&name, ", ", TcParserName(options), "kZigZag"); - break; - - case TypeFormat::kBytes: - StrAppend(&name, ", ", TcParserName(options), "kNoUtf8"); - break; - - case TypeFormat::kString: - StrAppend(&name, ", ", TcParserName(options), "kUtf8"); - break; - - case TypeFormat::kStringValidateOnly: - StrAppend(&name, ", ", TcParserName(options), "kUtf8ValidateOnly"); - break; - - default: - break; - } - - name.append(">"); - return name; -} - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_enum.cc b/r5dev/thirdparty/protobuf/compiler/cpp/enum.cc similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_enum.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/enum.cc index c72e2cf4..8c5db5dd 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_enum.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/enum.cc @@ -32,16 +32,16 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/cpp/cpp_enum.h> +#include <thirdparty/protobuf/compiler/cpp/enum.h> #include <cstdint> #include <limits> #include <map> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_names.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> +#include <thirdparty/protobuf/compiler/cpp/names.h> namespace google { namespace protobuf { @@ -88,7 +88,7 @@ EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor, variables_["nested_name"] = descriptor_->name(); variables_["resolved_name"] = ResolveKeyword(descriptor_->name()); variables_["prefix"] = - (descriptor_->containing_type() == NULL) ? "" : classname_ + "_"; + (descriptor_->containing_type() == nullptr) ? "" : classname_ + "_"; } EnumGenerator::~EnumGenerator() {} @@ -405,7 +405,7 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* printer) { descriptor_->value_count()); } - if (descriptor_->containing_type() != NULL) { + if (descriptor_->containing_type() != nullptr) { std::string parent = ClassName(descriptor_->containing_type(), false); // Before C++17, we must define the static constants which were // declared in the header, to give the linker a place to put them. diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_enum.h b/r5dev/thirdparty/protobuf/compiler/cpp/enum.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_enum.h rename to r5dev/thirdparty/protobuf/compiler/cpp/enum.h index 8cb31a39..31279f1a 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_enum.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/enum.h @@ -38,8 +38,9 @@ #include <map> #include <set> #include <string> -#include <thirdparty/protobuf/compiler/cpp/cpp_options.h> + #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/compiler/cpp/options.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_enum_field.cc b/r5dev/thirdparty/protobuf/compiler/cpp/enum_field.cc similarity index 77% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_enum_field.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/enum_field.cc index 3ecb06f4..4c6154ba 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_enum_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/enum_field.cc @@ -32,11 +32,13 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/cpp/cpp_enum_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> +#include <thirdparty/protobuf/compiler/cpp/enum_field.h> + #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/cpp/field.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> namespace google { namespace protobuf { @@ -53,6 +55,10 @@ void SetEnumVariables(const FieldDescriptor* descriptor, (*variables)["type"] = QualifiedClassName(descriptor->enum_type(), options); (*variables)["default"] = Int32ToString(default_value->number()); (*variables)["full_name"] = descriptor->full_name(); + (*variables)["cached_byte_size_name"] = MakeVarintCachedSizeName(descriptor); + bool cold = ShouldSplit(descriptor, options); + (*variables)["cached_byte_size_field"] = + MakeVarintCachedSizeFieldName(descriptor, cold); } } // namespace @@ -90,7 +96,7 @@ void EnumFieldGenerator::GenerateInlineAccessorDefinitions( Formatter format(printer, variables_); format( "inline $type$ $classname$::_internal_$name$() const {\n" - " return static_cast< $type$ >($name$_);\n" + " return static_cast< $type$ >($field$);\n" "}\n" "inline $type$ $classname$::$name$() const {\n" "$annotate_get$" @@ -103,9 +109,10 @@ void EnumFieldGenerator::GenerateInlineAccessorDefinitions( } format( " $set_hasbit$\n" - " $name$_ = value;\n" + " $field$ = value;\n" "}\n" "inline void $classname$::set_$name$($type$ value) {\n" + "$maybe_prepare_split_message$" " _internal_set_$name$(value);\n" "$annotate_set$" " // @@protoc_insertion_point(field_set:$full_name$)\n" @@ -114,28 +121,23 @@ void EnumFieldGenerator::GenerateInlineAccessorDefinitions( void EnumFieldGenerator::GenerateClearingCode(io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_ = $default$;\n"); + format("$field$ = $default$;\n"); } void EnumFieldGenerator::GenerateMergingCode(io::Printer* printer) const { Formatter format(printer, variables_); - format("_internal_set_$name$(from._internal_$name$());\n"); + format("_this->_internal_set_$name$(from._internal_$name$());\n"); } void EnumFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { Formatter format(printer, variables_); - format("swap($name$_, other->$name$_);\n"); -} - -void EnumFieldGenerator::GenerateConstructorCode(io::Printer* printer) const { - Formatter format(printer, variables_); - format("$name$_ = $default$;\n"); + format("swap($field$, other->$field$);\n"); } void EnumFieldGenerator::GenerateCopyConstructorCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_ = from.$name$_;\n"); + format("_this->$field$ = from.$field$;\n"); } void EnumFieldGenerator::GenerateSerializeWithCachedSizesToArray( @@ -143,7 +145,7 @@ void EnumFieldGenerator::GenerateSerializeWithCachedSizesToArray( Formatter format(printer, variables_); format( "target = stream->EnsureSpace(target);\n" - "target = ::$proto_ns$::internal::WireFormatLite::WriteEnumToArray(\n" + "target = ::_pbi::WireFormatLite::WriteEnumToArray(\n" " $number$, this->_internal_$name$(), target);\n"); } @@ -151,15 +153,29 @@ void EnumFieldGenerator::GenerateByteSize(io::Printer* printer) const { Formatter format(printer, variables_); format( "total_size += $tag_size$ +\n" - " " - "::$proto_ns$::internal::WireFormatLite::EnumSize(this->_internal_$name$(" - "));\n"); + " ::_pbi::WireFormatLite::EnumSize(this->_internal_$name$());\n"); } -void EnumFieldGenerator::GenerateConstinitInitializer( +void EnumFieldGenerator::GenerateConstexprAggregateInitializer( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_($default$)\n"); + format("/*decltype($field$)*/$default$"); +} + +void EnumFieldGenerator::GenerateAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + if (ShouldSplit(descriptor_, options_)) { + format("decltype(Impl_::Split::$name$_){$default$}"); + return; + } + format("decltype($field$){$default$}"); +} + +void EnumFieldGenerator::GenerateCopyAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("decltype($field$){}"); } // =================================================================== @@ -178,7 +194,7 @@ void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions( format( "inline $type$ $classname$::_internal_$name$() const {\n" " if (_internal_has_$name$()) {\n" - " return static_cast< $type$ >($field_member$);\n" + " return static_cast< $type$ >($field$);\n" " }\n" " return static_cast< $type$ >($default$);\n" "}\n" @@ -196,7 +212,7 @@ void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions( " clear_$oneof_name$();\n" " set_has_$name$();\n" " }\n" - " $field_member$ = value;\n" + " $field$ = value;\n" "}\n" "inline void $classname$::set_$name$($type$ value) {\n" " _internal_set_$name$(value);\n" @@ -207,7 +223,7 @@ void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions( void EnumOneofFieldGenerator::GenerateClearingCode(io::Printer* printer) const { Formatter format(printer, variables_); - format("$field_member$ = $default$;\n"); + format("$field$ = $default$;\n"); } void EnumOneofFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { @@ -217,7 +233,7 @@ void EnumOneofFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { void EnumOneofFieldGenerator::GenerateConstructorCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$ns$::_$classname$_default_instance_.$name$_ = $default$;\n"); + format("$ns$::_$classname$_default_instance_.$field$ = $default$;\n"); } // =================================================================== @@ -236,7 +252,7 @@ void RepeatedEnumFieldGenerator::GeneratePrivateMembers( format("::$proto_ns$::RepeatedField<int> $name$_;\n"); if (descriptor_->is_packed() && HasGeneratedMethods(descriptor_->file(), options_)) { - format("mutable std::atomic<int> _$name$_cached_byte_size_;\n"); + format("mutable std::atomic<int> $cached_byte_size_name$;\n"); } } @@ -265,7 +281,7 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions( Formatter format(printer, variables_); format( "inline $type$ $classname$::_internal_$name$(int index) const {\n" - " return static_cast< $type$ >($name$_.Get(index));\n" + " return static_cast< $type$ >($field$.Get(index));\n" "}\n" "inline $type$ $classname$::$name$(int index) const {\n" "$annotate_get$" @@ -277,7 +293,7 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions( format(" assert($type$_IsValid(value));\n"); } format( - " $name$_.Set(index, value);\n" + " $field$.Set(index, value);\n" "$annotate_set$" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" @@ -286,7 +302,7 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions( format(" assert($type$_IsValid(value));\n"); } format( - " $name$_.Add(value);\n" + " $field$.Add(value);\n" "}\n" "inline void $classname$::add_$name$($type$ value) {\n" " _internal_add_$name$(value);\n" @@ -297,11 +313,11 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions( "$classname$::$name$() const {\n" "$annotate_list$" " // @@protoc_insertion_point(field_list:$full_name$)\n" - " return $name$_;\n" + " return $field$;\n" "}\n" "inline ::$proto_ns$::RepeatedField<int>*\n" "$classname$::_internal_mutable_$name$() {\n" - " return &$name$_;\n" + " return &$field$;\n" "}\n" "inline ::$proto_ns$::RepeatedField<int>*\n" "$classname$::mutable_$name$() {\n" @@ -314,19 +330,19 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions( void RepeatedEnumFieldGenerator::GenerateClearingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.Clear();\n"); + format("$field$.Clear();\n"); } void RepeatedEnumFieldGenerator::GenerateMergingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.MergeFrom(from.$name$_);\n"); + format("_this->$field$.MergeFrom(from.$field$);\n"); } void RepeatedEnumFieldGenerator::GenerateSwappingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.InternalSwap(&other->$name$_);\n"); + format("$field$.InternalSwap(&other->$field$);\n"); } void RepeatedEnumFieldGenerator::GenerateConstructorCode( @@ -334,6 +350,12 @@ void RepeatedEnumFieldGenerator::GenerateConstructorCode( // Not needed for repeated fields. } +void RepeatedEnumFieldGenerator::GenerateDestructorCode( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("$field$.~RepeatedField();\n"); +} + void RepeatedEnumFieldGenerator::GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const { Formatter format(printer, variables_); @@ -342,17 +364,17 @@ void RepeatedEnumFieldGenerator::GenerateSerializeWithCachedSizesToArray( format( "{\n" " int byte_size = " - "_$name$_cached_byte_size_.load(std::memory_order_relaxed);\n" + "$cached_byte_size_field$.load(std::memory_order_relaxed);\n" " if (byte_size > 0) {\n" " target = stream->WriteEnumPacked(\n" - " $number$, $name$_, byte_size, target);\n" + " $number$, $field$, byte_size, target);\n" " }\n" "}\n"); } else { format( "for (int i = 0, n = this->_internal_$name$_size(); i < n; i++) {\n" " target = stream->EnsureSpace(target);\n" - " target = ::$proto_ns$::internal::WireFormatLite::WriteEnumToArray(\n" + " target = ::_pbi::WireFormatLite::WriteEnumToArray(\n" " $number$, this->_internal_$name$(i), target);\n" "}\n"); } @@ -368,7 +390,7 @@ void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const { format.Indent(); format( "for (unsigned int i = 0; i < count; i++) {\n" - " data_size += ::$proto_ns$::internal::WireFormatLite::EnumSize(\n" + " data_size += ::_pbi::WireFormatLite::EnumSize(\n" " this->_internal_$name$(static_cast<int>(i)));\n" "}\n"); @@ -376,11 +398,11 @@ void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const { format( "if (data_size > 0) {\n" " total_size += $tag_size$ +\n" - " ::$proto_ns$::internal::WireFormatLite::Int32Size(\n" - " static_cast<$int32$>(data_size));\n" + " " + "::_pbi::WireFormatLite::Int32Size(static_cast<$int32$>(data_size));\n" "}\n" - "int cached_size = ::$proto_ns$::internal::ToCachedSize(data_size);\n" - "_$name$_cached_byte_size_.store(cached_size,\n" + "int cached_size = ::_pbi::ToCachedSize(data_size);\n" + "$cached_byte_size_field$.store(cached_size,\n" " std::memory_order_relaxed);\n" "total_size += data_size;\n"); } else { @@ -390,13 +412,36 @@ void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const { format("}\n"); } -void RepeatedEnumFieldGenerator::GenerateConstinitInitializer( +void RepeatedEnumFieldGenerator::GenerateConstexprAggregateInitializer( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_()"); + format("/*decltype($field$)*/{}"); if (descriptor_->is_packed() && HasGeneratedMethods(descriptor_->file(), options_)) { - format("\n, _$name$_cached_byte_size_(0)"); + format("\n, /*decltype($cached_byte_size_field$)*/{0}"); + } +} + +void RepeatedEnumFieldGenerator::GenerateAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("decltype($field$){arena}"); + if (descriptor_->is_packed() && + HasGeneratedMethods(descriptor_->file(), options_)) { + // std::atomic has no copy constructor, which prevents explicit aggregate + // initialization pre-C++17. + format("\n, /*decltype($cached_byte_size_field$)*/{0}"); + } +} + +void RepeatedEnumFieldGenerator::GenerateCopyAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("decltype($field$){from.$field$}"); + if (descriptor_->is_packed() && + HasGeneratedMethods(descriptor_->file(), options_)) { + // std::atomic has no copy constructor. + format("\n, /*decltype($cached_byte_size_field$)*/{0}"); } } diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_enum_field.h b/r5dev/thirdparty/protobuf/compiler/cpp/enum_field.h similarity index 84% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_enum_field.h rename to r5dev/thirdparty/protobuf/compiler/cpp/enum_field.h index 9ad58afb..2f15ffe2 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_enum_field.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/enum_field.h @@ -37,7 +37,8 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/cpp/cpp_field.h> + +#include <thirdparty/protobuf/compiler/cpp/field.h> namespace google { namespace protobuf { @@ -47,7 +48,7 @@ namespace cpp { class EnumFieldGenerator : public FieldGenerator { public: EnumFieldGenerator(const FieldDescriptor* descriptor, const Options& options); - ~EnumFieldGenerator(); + ~EnumFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const override; @@ -56,12 +57,15 @@ class EnumFieldGenerator : public FieldGenerator { void GenerateClearingCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateSwappingCode(io::Printer* printer) const override; - void GenerateConstructorCode(io::Printer* printer) const override; + void GenerateConstructorCode(io::Printer* printer) const override {} void GenerateCopyConstructorCode(io::Printer* printer) const override; void GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; - void GenerateConstinitInitializer(io::Printer* printer) const override; + void GenerateConstexprAggregateInitializer( + io::Printer* printer) const override; + void GenerateAggregateInitializer(io::Printer* printer) const override; + void GenerateCopyAggregateInitializer(io::Printer* printer) const override; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); @@ -71,7 +75,7 @@ class EnumOneofFieldGenerator : public EnumFieldGenerator { public: EnumOneofFieldGenerator(const FieldDescriptor* descriptor, const Options& options); - ~EnumOneofFieldGenerator(); + ~EnumOneofFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override; @@ -87,7 +91,7 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { public: RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor, const Options& options); - ~RepeatedEnumFieldGenerator(); + ~RepeatedEnumFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const override; @@ -97,11 +101,17 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const override; void GenerateSwappingCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override; - void GenerateCopyConstructorCode(io::Printer* printer) const override {} + void GenerateCopyConstructorCode(io::Printer* /*printer*/) const override { + GOOGLE_CHECK(!ShouldSplit(descriptor_, options_)); + } + void GenerateDestructorCode(io::Printer* printer) const override; void GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; - void GenerateConstinitInitializer(io::Printer* printer) const override; + void GenerateConstexprAggregateInitializer( + io::Printer* printer) const override; + void GenerateAggregateInitializer(io::Printer* printer) const override; + void GenerateCopyAggregateInitializer(io::Printer* printer) const override; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator); diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_extension.cc b/r5dev/thirdparty/protobuf/compiler/cpp/extension.cc similarity index 91% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_extension.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/extension.cc index 93fe64d5..241c9822 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_extension.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/extension.cc @@ -32,12 +32,14 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/cpp/cpp_extension.h> +#include <thirdparty/protobuf/compiler/cpp/extension.h> + #include <map> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/descriptor.pb.h> + #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> +#include <thirdparty/protobuf/descriptor.pb.h> namespace google { namespace protobuf { @@ -76,6 +78,7 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor, break; } SetCommonVars(options, &variables_); + SetCommonMessageDataVariables(descriptor_->containing_type(), &variables_); variables_["extendee"] = QualifiedClassName(descriptor_->containing_type(), options_); variables_["type_traits"] = type_traits_; @@ -91,6 +94,19 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor, variables_["scope"] = scope; variables_["scoped_name"] = ExtensionName(descriptor_); variables_["number"] = StrCat(descriptor_->number()); + + bool add_verify_fn = + // Only verify msgs. + descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + // Options say to verify. + ShouldVerify(descriptor_->message_type(), options_, scc_analyzer_) && + ShouldVerify(descriptor_->containing_type(), options_, scc_analyzer_); + + variables_["verify_fn"] = + add_verify_fn + ? StrCat("&", FieldMessageTypeName(descriptor_, options_), + "::InternalVerify") + : "nullptr"; } ExtensionGenerator::~ExtensionGenerator() {} @@ -164,23 +180,11 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) { } format( - "PROTOBUF_ATTRIBUTE_INIT_PRIORITY " + "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 " "::$proto_ns$::internal::ExtensionIdentifier< $extendee$,\n" - " ::$proto_ns$::internal::$type_traits$, $field_type$, $packed$ >\n" - " $scoped_name$($constant_name$, $1$);\n", + " ::$proto_ns$::internal::$type_traits$, $field_type$, $packed$>\n" + " $scoped_name$($constant_name$, $1$, $verify_fn$);\n", default_str); - - // Register extension verify function if needed. - if (descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - ShouldVerify(descriptor_->message_type(), options_, scc_analyzer_) && - ShouldVerify(descriptor_->containing_type(), options_, scc_analyzer_)) { - format( - "PROTOBUF_ATTRIBUTE_INIT_PRIORITY " - "::$proto_ns$::internal::RegisterExtensionVerify< $extendee$,\n" - " $1$, $number$> $2$_$name$_register;\n", - ClassName(descriptor_->message_type(), true), - IsScoped() ? ClassName(descriptor_->extension_scope(), false) : ""); - } } } // namespace cpp diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_extension.h b/r5dev/thirdparty/protobuf/compiler/cpp/extension.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_extension.h rename to r5dev/thirdparty/protobuf/compiler/cpp/extension.h index 0ea7c235..c316ba54 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_extension.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/extension.h @@ -39,7 +39,7 @@ #include <string> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_options.h> +#include <thirdparty/protobuf/compiler/cpp/options.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_field.cc b/r5dev/thirdparty/protobuf/compiler/cpp/field.cc similarity index 85% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_field.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/field.cc index 56b0a198..64a98fa8 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/field.cc @@ -32,25 +32,25 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/cpp/cpp_field.h> +#include <thirdparty/protobuf/compiler/cpp/field.h> #include <cstdint> #include <memory> #include <string> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_primitive_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_string_field.h> #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> +#include <thirdparty/protobuf/compiler/cpp/primitive_field.h> +#include <thirdparty/protobuf/compiler/cpp/string_field.h> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_enum_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_map_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_message_field.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/wire_format.h> +#include <thirdparty/protobuf/compiler/cpp/enum_field.h> +#include <thirdparty/protobuf/compiler/cpp/map_field.h> +#include <thirdparty/protobuf/compiler/cpp/message_field.h> +#include <thirdparty/protobuf/descriptor.pb.h> namespace google { namespace protobuf { @@ -81,7 +81,7 @@ std::string GenerateTemplateForOneofString(const FieldDescriptor* descriptor, std::string field_name = google::protobuf::compiler::cpp::FieldName(descriptor); std::string field_pointer = descriptor->options().ctype() == google::protobuf::FieldOptions::STRING - ? "$0.GetPointer()" + ? "$0.UnsafeGetPointer()" : "$0"; if (descriptor->default_value_string().empty()) { @@ -103,7 +103,7 @@ std::string GenerateTemplateForOneofString(const FieldDescriptor* descriptor, return strings::Substitute( StrCat("_internal_has_", field_name, "() ? ", field_pointer, " : ", default_value_pointer), - field_member, MakeDefaultName(descriptor)); + field_member, MakeDefaultFieldName(descriptor)); } std::string GenerateTemplateForSingleString(const FieldDescriptor* descriptor, @@ -114,8 +114,8 @@ std::string GenerateTemplateForSingleString(const FieldDescriptor* descriptor, if (descriptor->options().ctype() == google::protobuf::FieldOptions::STRING) { return strings::Substitute( - "$0.IsDefault(nullptr) ? &$1.get() : $0.GetPointer()", field_member, - MakeDefaultName(descriptor)); + "$0.IsDefault() ? &$1.get() : $0.UnsafeGetPointer()", field_member, + MakeDefaultFieldName(descriptor)); } return StrCat("&", field_member); @@ -150,14 +150,12 @@ void AddAccessorAnnotations(const FieldDescriptor* descriptor, google::protobuf::FileOptions::LITE_RUNTIME) { return; } - std::string field_member = (*variables)["field_member"]; + std::string field_member = (*variables)["field"]; const google::protobuf::OneofDescriptor* oneof_member = descriptor->real_containing_oneof(); - if (oneof_member) { - field_member = StrCat(oneof_member->name(), "_.", field_member); - } const std::string proto_ns = (*variables)["proto_ns"]; - const std::string substitute_template_prefix = " _tracker_.$1<$0>(this, "; + const std::string substitute_template_prefix = + StrCat(" ", (*variables)["tracker"], ".$1<$0>(this, "); std::string prepared_template; // Flat template is needed if the prepared one is introspecting the values @@ -178,7 +176,7 @@ void AddAccessorAnnotations(const FieldDescriptor* descriptor, } else if (descriptor->is_map()) { prepared_template = "nullptr"; } else if (descriptor->type() == FieldDescriptor::TYPE_MESSAGE && - !descriptor->options().lazy()) { + !IsExplicitLazy(descriptor)) { prepared_template = "nullptr"; } else if (descriptor->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { if (oneof_member) { @@ -238,13 +236,16 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, std::map<std::string, std::string>* variables, const Options& options) { SetCommonVars(options, variables); + SetCommonMessageDataVariables(descriptor->containing_type(), variables); + (*variables)["ns"] = Namespace(descriptor, options); (*variables)["name"] = FieldName(descriptor); (*variables)["index"] = StrCat(descriptor->index()); (*variables)["number"] = StrCat(descriptor->number()); (*variables)["classname"] = ClassName(FieldScope(descriptor), false); (*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type()); - (*variables)["field_member"] = FieldName(descriptor) + "_"; + bool split = ShouldSplit(descriptor, options); + (*variables)["field"] = FieldMemberName(descriptor, split); (*variables)["tag_size"] = StrCat( WireFormat::TagSize(descriptor->number(), descriptor->type())); @@ -252,12 +253,8 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, (*variables)["set_hasbit"] = ""; (*variables)["clear_hasbit"] = ""; - if (HasHasbit(descriptor)) { - (*variables)["set_hasbit_io"] = - "_Internal::set_has_" + FieldName(descriptor) + "(&_has_bits_);"; - } else { - (*variables)["set_hasbit_io"] = ""; - } + (*variables)["maybe_prepare_split_message"] = + split ? " PrepareSplitMessageForWrite();\n" : ""; AddAccessorAnnotations(descriptor, options, variables); @@ -275,10 +272,10 @@ void FieldGenerator::SetHasBitIndex(int32_t has_bit_index) { return; } variables_["set_hasbit"] = StrCat( - "_has_bits_[", has_bit_index / 32, "] |= 0x", + variables_["has_bits"], "[", has_bit_index / 32, "] |= 0x", strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8), "u;"); variables_["clear_hasbit"] = StrCat( - "_has_bits_[", has_bit_index / 32, "] &= ~0x", + variables_["has_bits"], "[", has_bit_index / 32, "] &= ~0x", strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8), "u;"); } @@ -287,24 +284,57 @@ void FieldGenerator::SetInlinedStringIndex(int32_t inlined_string_index) { GOOGLE_CHECK_EQ(inlined_string_index, -1); return; } + // The first bit is the tracking bit for on demand registering ArenaDtor. + GOOGLE_CHECK_GT(inlined_string_index, 0) + << "_inlined_string_donated_'s bit 0 is reserved for arena dtor tracking"; variables_["inlined_string_donated"] = StrCat( - "(_inlined_string_donated_[", inlined_string_index / 32, "] & 0x", + "(", variables_["inlined_string_donated_array"], "[", + inlined_string_index / 32, "] & 0x", strings::Hex(1u << (inlined_string_index % 32), strings::ZERO_PAD_8), "u) != 0;"); variables_["donating_states_word"] = - StrCat("_inlined_string_donated_[", inlined_string_index / 32, "]"); + StrCat(variables_["inlined_string_donated_array"], "[", + inlined_string_index / 32, "]"); variables_["mask_for_undonate"] = StrCat( "~0x", strings::Hex(1u << (inlined_string_index % 32), strings::ZERO_PAD_8), "u"); } +void FieldGenerator::GenerateAggregateInitializer(io::Printer* printer) const { + Formatter format(printer, variables_); + if (ShouldSplit(descriptor_, options_)) { + format("decltype(Impl_::Split::$name$_){arena}"); + return; + } + format("decltype($field$){arena}"); +} + +void FieldGenerator::GenerateConstexprAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("/*decltype($field$)*/{}"); +} + +void FieldGenerator::GenerateCopyAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("decltype($field$){from.$field$}"); +} + +void FieldGenerator::GenerateCopyConstructorCode(io::Printer* printer) const { + if (ShouldSplit(descriptor_, options_)) { + // There is no copy constructor for the `Split` struct, so we need to copy + // the value here. + Formatter format(printer, variables_); + format("$field$ = from.$field$;\n"); + } +} + void SetCommonOneofFieldVariables( const FieldDescriptor* descriptor, std::map<std::string, std::string>* variables) { const std::string prefix = descriptor->containing_oneof()->name() + "_."; (*variables)["oneof_name"] = descriptor->containing_oneof()->name(); - (*variables)["field_member"] = - StrCat(prefix, (*variables)["name"], "_"); } FieldGenerator::~FieldGenerator() {} diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_field.h b/r5dev/thirdparty/protobuf/compiler/cpp/field.h similarity index 82% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_field.h rename to r5dev/thirdparty/protobuf/compiler/cpp/field.h index b1f62a13..53dbdfd8 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_field.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/field.h @@ -40,9 +40,9 @@ #include <memory> #include <string> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_options.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> +#include <thirdparty/protobuf/compiler/cpp/options.h> namespace google { namespace protobuf { @@ -136,7 +136,7 @@ class FieldGenerator { virtual void GenerateMergingCode(io::Printer* printer) const = 0; // Generates a copy constructor - virtual void GenerateCopyConstructorCode(io::Printer* printer) const = 0; + virtual void GenerateCopyConstructorCode(io::Printer* printer) const; // Generate lines of code (statements, not declarations) which swaps // this field and the corresponding field of another message, which @@ -150,6 +150,9 @@ class FieldGenerator { // method, invoked by each of the generated constructors. virtual void GenerateConstructorCode(io::Printer* printer) const = 0; + // Generate initialization code for private members in the cold struct. + virtual void GenerateCreateSplitMessageCode(io::Printer* printer) const {} + // Generate any code that needs to go in the class's SharedDtor() method, // invoked by the destructor. // Most field types don't need this, so the default implementation is empty. @@ -158,18 +161,39 @@ class FieldGenerator { // Generate a manual destructor invocation for use when the message is on an // arena. The code that this method generates will be executed inside a // shared-for-the-whole-message-class method registered with - // OwnDestructor(). The method should return |true| if it generated any code - // that requires a call; this allows the message generator to eliminate the - // OwnDestructor() registration if no fields require it. - virtual bool GenerateArenaDestructorCode(io::Printer* printer) const { - return false; + // OwnDestructor(). + virtual void GenerateArenaDestructorCode(io::Printer* printer) const { + GOOGLE_CHECK(NeedsArenaDestructor() == ArenaDtorNeeds::kNone) + << descriptor_->cpp_type_name(); } // Generate initialization code for private members declared by - // GeneratePrivateMembers(), specifically for the constexpr constructor. - // These go into the constructor's initializer list and must follow that - // syntax (eg `field_(args)`). Does not include `:` or `,` separators. - virtual void GenerateConstinitInitializer(io::Printer* printer) const {} + // GeneratePrivateMembers(). These go into the SharedCtor's + // aggregate initialization of the _impl_ struct and must follow the syntax + // (e.g. `decltype($field$){$default$}`). Does not include `:` or `,` + // separators. Default values should be specified here when possible. + // + // Note: We use `decltype($field$)` for both explicit construction and the + // fact that it's self-documenting. Pre-C++17, copy elision isn't guaranteed + // in aggregate initialization so a valid copy/move constructor must exist + // (even though it's not used). Because of this, we need to comment out the + // decltype and fallback to implicit construction. + virtual void GenerateAggregateInitializer(io::Printer* printer) const; + + // Generate constinit initialization code for private members declared by + // GeneratePrivateMembers(). These go into the constexpr constructor's + // aggregate initialization of the _impl_ struct and must follow the syntax + // (e.g. `/*decltype($field$)*/{}`, see above). Does not + // include `:` or `,` separators. + virtual void GenerateConstexprAggregateInitializer( + io::Printer* printer) const; + + // Generate copy initialization code for private members declared by + // GeneratePrivateMembers(). These go into the copy constructor's + // aggregate initialization of the _impl_ struct and must follow the syntax + // (e.g. `decltype($field$){from.$field$}`, see above). Does not + // include `:` or `,` separators. + virtual void GenerateCopyAggregateInitializer(io::Printer* printer) const; // Generate lines to serialize this field directly to the array "target", // which are placed within the message's SerializeWithCachedSizesToArray() @@ -187,6 +211,10 @@ class FieldGenerator { virtual bool IsInlined() const { return false; } + virtual ArenaDtorNeeds NeedsArenaDestructor() const { + return ArenaDtorNeeds::kNone; + } + void SetHasBitIndex(int32_t has_bit_index); void SetInlinedStringIndex(int32_t inlined_string_index); diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_file.cc b/r5dev/thirdparty/protobuf/compiler/cpp/file.cc similarity index 83% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_file.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/file.cc index ba3753c7..f3f88f34 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_file.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/file.cc @@ -32,7 +32,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/cpp/cpp_file.h> +#include <thirdparty/protobuf/compiler/cpp/file.h> #include <iostream> #include <map> @@ -42,16 +42,16 @@ #include <unordered_set> #include <vector> -#include <thirdparty/protobuf/compiler/cpp/cpp_enum.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_extension.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_message.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_service.h> #include <thirdparty/protobuf/compiler/scc.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/cpp/enum.h> +#include <thirdparty/protobuf/compiler/cpp/extension.h> +#include <thirdparty/protobuf/compiler/cpp/field.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> +#include <thirdparty/protobuf/compiler/cpp/message.h> +#include <thirdparty/protobuf/compiler/cpp/service.h> +#include <thirdparty/protobuf/descriptor.pb.h> // Must be last. #include <thirdparty/protobuf/port_def.inc> @@ -87,6 +87,23 @@ std::vector<const T*> Sorted(const std::unordered_set<const T*>& vals) { return sorted; } +// TODO(b/203101078): remove pragmas that suppresses uninitialized warnings when +// clang bug is fixed. +inline void MuteWuninitialized(Formatter& format) { + format( + "#if defined(__llvm__)\n" + " #pragma clang diagnostic push\n" + " #pragma clang diagnostic ignored \"-Wuninitialized\"\n" + "#endif // __llvm__\n"); +} + +inline void UnmuteWuninitialized(Formatter& format) { + format( + "#if defined(__llvm__)\n" + " #pragma clang diagnostic pop\n" + "#endif // __llvm__\n"); +} + } // namespace FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) @@ -335,7 +352,14 @@ void FileGenerator::DoIncludeFile(const std::string& google3_name, options_.runtime_include_base, path); } } else { - format("#include \"$1$\"", google3_name); + std::string path = google3_name; + // The bootstrapped proto generated code needs to use the + // third_party/protobuf header paths to avoid circular dependencies. + if (options_.bootstrap) { + path = StringReplace(google3_name, "net/proto2/public", + "third_party/protobuf", false); + } + format("#include \"$1$\"", path); } if (do_export) { @@ -428,26 +452,72 @@ void FileGenerator::GenerateSourceIncludes(io::Printer* printer) { format("// @@protoc_insertion_point(includes)\n"); IncludeFile("net/proto2/public/port_def.inc", printer); +} + +void FileGenerator::GenerateSourcePrelude(io::Printer* printer) { + Formatter format(printer, variables_); // For MSVC builds, we use #pragma init_seg to move the initialization of our // libraries to happen before the user code. // This worksaround the fact that MSVC does not do constant initializers when // required by the standard. format("\nPROTOBUF_PRAGMA_INIT_SEG\n"); + + // Generate convenience aliases. + format( + "\n" + "namespace _pb = ::$1$;\n" + "namespace _pbi = _pb::internal;\n", + ProtobufNamespace(options_)); + if (HasGeneratedMethods(file_, options_) && + options_.tctable_mode != Options::kTCTableNever) { + format("namespace _fl = _pbi::field_layout;\n"); + } + format("\n"); } void FileGenerator::GenerateSourceDefaultInstance(int idx, io::Printer* printer) { Formatter format(printer, variables_); MessageGenerator* generator = message_generators_[idx].get(); + // Generate the split instance first because it's needed in the constexpr + // constructor. + if (ShouldSplit(generator->descriptor_, options_)) { + // Use a union to disable the destructor of the _instance member. + // We can constant initialize, but the object will still have a non-trivial + // destructor that we need to elide. + format( + "struct $1$ {\n" + " PROTOBUF_CONSTEXPR $1$()\n" + " : _instance{", + DefaultInstanceType(generator->descriptor_, options_, + /*split=*/true)); + generator->GenerateInitDefaultSplitInstance(printer); + format( + "} {}\n" + " ~$1$() {}\n" + " union {\n" + " $2$ _instance;\n" + " };\n" + "};\n", + DefaultInstanceType(generator->descriptor_, options_, /*split=*/true), + StrCat(generator->classname_, "::Impl_::Split")); + // NO_DESTROY is not necessary for correctness. The empty destructor is + // enough. However, the empty destructor fails to be elided in some + // configurations (like non-opt or with certain sanitizers). NO_DESTROY is + // there just to improve performance and binary size in these builds. + format( + "PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT " + "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 $1$ $2$;\n", + DefaultInstanceType(generator->descriptor_, options_, /*split=*/true), + DefaultInstanceName(generator->descriptor_, options_, /*split=*/true)); + } + generator->GenerateConstexprConstructor(printer); - // Use a union to disable the destructor of the _instance member. - // We can constant initialize, but the object will still have a non-trivial - // destructor that we need to elide. format( "struct $1$ {\n" - " constexpr $1$()\n" - " : _instance(::$proto_ns$::internal::ConstantInitialized{}) {}\n" + " PROTOBUF_CONSTEXPR $1$()\n" + " : _instance(::_pbi::ConstantInitialized{}) {}\n" " ~$1$() {}\n" " union {\n" " $2$ _instance;\n" @@ -455,32 +525,32 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx, "};\n", DefaultInstanceType(generator->descriptor_, options_), generator->classname_); - // NO_DESTROY is not necessary for correctness. The empty destructor is - // enough. However, the empty destructor fails to be elided in some - // configurations (like non-opt or with certain sanitizers). NO_DESTROY is - // there just to improve performance and binary size in these builds. - format("PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT $1$ $2$;\n", - DefaultInstanceType(generator->descriptor_, options_), - DefaultInstanceName(generator->descriptor_, options_)); + format( + "PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT " + "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 $1$ $2$;\n", + DefaultInstanceType(generator->descriptor_, options_), + DefaultInstanceName(generator->descriptor_, options_)); for (int i = 0; i < generator->descriptor_->field_count(); i++) { const FieldDescriptor* field = generator->descriptor_->field(i); if (IsStringInlined(field, options_)) { // Force the initialization of the inlined string in the default instance. format( - "PROTOBUF_ATTRIBUTE_INIT_PRIORITY std::true_type " - "$1$::_init_inline_$2$_ = " - "($3$._instance.$2$_.Init(), std::true_type{});\n", + "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 std::true_type " + "$1$::Impl_::_init_inline_$2$_ = " + "($3$._instance.$4$.Init(), std::true_type{});\n", ClassName(generator->descriptor_), FieldName(field), - DefaultInstanceName(generator->descriptor_, options_)); + DefaultInstanceName(generator->descriptor_, options_), + FieldMemberName(field, ShouldSplit(field, options_))); } } if (options_.lite_implicit_weak_fields) { - format("$1$* $2$ = &$3$;\n", - DefaultInstanceType(generator->descriptor_, options_), - DefaultInstancePtr(generator->descriptor_, options_), - DefaultInstanceName(generator->descriptor_, options_)); + format( + "PROTOBUF_CONSTINIT const void* $1$ =\n" + " &$2$;\n", + DefaultInstancePtr(generator->descriptor_, options_), + DefaultInstanceName(generator->descriptor_, options_)); } } @@ -534,11 +604,10 @@ void FileGenerator::GenerateInternalForwardDeclarations( for (auto instance : Sorted(refs.weak_default_instances)) { ns.ChangeTo(Namespace(instance, options_)); if (options_.lite_implicit_weak_fields) { - format("extern $1$ $2$;\n", DefaultInstanceType(instance, options_), - DefaultInstanceName(instance, options_)); - format("__attribute__((weak)) $1$* $2$ = nullptr;\n", - DefaultInstanceType(instance, options_), - DefaultInstancePtr(instance, options_)); + format( + "PROTOBUF_CONSTINIT __attribute__((weak)) const void* $1$ =\n" + " &::_pbi::implicit_weak_message_default_instance;\n", + DefaultInstancePtr(instance, options_)); } else { format("extern __attribute__((weak)) $1$ $2$;\n", DefaultInstanceType(instance, options_), @@ -549,8 +618,7 @@ void FileGenerator::GenerateInternalForwardDeclarations( for (auto file : Sorted(refs.weak_reflection_files)) { format( - "extern __attribute__((weak)) const " - "::$proto_ns$::internal::DescriptorTable $1$;\n", + "extern __attribute__((weak)) const ::_pbi::DescriptorTable $1$;\n", DescriptorTableName(file, options_)); } } @@ -558,6 +626,9 @@ void FileGenerator::GenerateInternalForwardDeclarations( void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) { Formatter format(printer, variables_); GenerateSourceIncludes(printer); + GenerateSourcePrelude(printer); + + if (IsAnyMessage(file_, options_)) MuteWuninitialized(format); CrossFileReferences refs; ForEachField(message_generators_[idx]->descriptor_, @@ -586,6 +657,8 @@ void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) { message_generators_[idx]->GenerateSourceInProto2Namespace(printer); } + if (IsAnyMessage(file_, options_)) UnmuteWuninitialized(format); + format( "\n" "// @@protoc_insertion_point(global_scope)\n"); @@ -594,6 +667,7 @@ void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) { void FileGenerator::GenerateSourceForExtension(int idx, io::Printer* printer) { Formatter format(printer, variables_); GenerateSourceIncludes(printer); + GenerateSourcePrelude(printer); NamespaceOpener ns(Namespace(file_, options_), format); extension_generators_[idx]->GenerateDefinition(printer); } @@ -601,10 +675,9 @@ void FileGenerator::GenerateSourceForExtension(int idx, io::Printer* printer) { void FileGenerator::GenerateGlobalSource(io::Printer* printer) { Formatter format(printer, variables_); GenerateSourceIncludes(printer); + GenerateSourcePrelude(printer); { - GenerateTables(printer); - // Define the code to initialize reflection. This code uses a global // constructor to register reflection data with the runtime pre-main. if (HasDescriptorMethods(file_, options_)) { @@ -623,10 +696,13 @@ void FileGenerator::GenerateGlobalSource(io::Printer* printer) { void FileGenerator::GenerateSource(io::Printer* printer) { Formatter format(printer, variables_); GenerateSourceIncludes(printer); + GenerateSourcePrelude(printer); CrossFileReferences refs; GetCrossFileReferencesForFile(file_, &refs); GenerateInternalForwardDeclarations(refs, printer); + if (IsAnyMessage(file_, options_)) MuteWuninitialized(format); + { NamespaceOpener ns(Namespace(file_, options_), format); @@ -637,8 +713,6 @@ void FileGenerator::GenerateSource(io::Printer* printer) { } { - GenerateTables(printer); - if (HasDescriptorMethods(file_, options_)) { // Define the code to initialize reflection. This code uses a global // constructor to register reflection data with the runtime pre-main. @@ -695,6 +769,8 @@ void FileGenerator::GenerateSource(io::Printer* printer) { "\n" "// @@protoc_insertion_point(global_scope)\n"); + if (IsAnyMessage(file_, options_)) UnmuteWuninitialized(format); + IncludeFile("net/proto2/public/port_undef.inc", printer); } @@ -702,31 +778,30 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { Formatter format(printer, variables_); if (!message_generators_.empty()) { - format("static ::$proto_ns$::Metadata $file_level_metadata$[$1$];\n", + format("static ::_pb::Metadata $file_level_metadata$[$1$];\n", message_generators_.size()); } if (!enum_generators_.empty()) { format( - "static " - "const ::$proto_ns$::EnumDescriptor* " + "static const ::_pb::EnumDescriptor* " "$file_level_enum_descriptors$[$1$];\n", enum_generators_.size()); } else { format( "static " - "constexpr ::$proto_ns$::EnumDescriptor const** " + "constexpr ::_pb::EnumDescriptor const** " "$file_level_enum_descriptors$ = nullptr;\n"); } if (HasGenericServices(file_, options_) && file_->service_count() > 0) { format( "static " - "const ::$proto_ns$::ServiceDescriptor* " + "const ::_pb::ServiceDescriptor* " "$file_level_service_descriptors$[$1$];\n", file_->service_count()); } else { format( "static " - "constexpr ::$proto_ns$::ServiceDescriptor const** " + "constexpr ::_pb::ServiceDescriptor const** " "$file_level_service_descriptors$ = nullptr;\n"); } @@ -744,7 +819,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { format.Outdent(); format( "};\n" - "static const ::$proto_ns$::internal::MigrationSchema schemas[] " + "static const ::_pbi::MigrationSchema schemas[] " "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); format.Indent(); { @@ -758,16 +833,13 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { format.Outdent(); format( "};\n" - "\nstatic " - "::$proto_ns$::Message const * const file_default_instances[] = {\n"); + "\nstatic const ::_pb::Message* const file_default_instances[] = {\n"); format.Indent(); for (int i = 0; i < message_generators_.size(); i++) { const Descriptor* descriptor = message_generators_[i]->descriptor_; - format( - "reinterpret_cast<const " - "::$proto_ns$::Message*>(&$1$::_$2$_default_instance_),\n", - Namespace(descriptor, options_), // 1 - ClassName(descriptor)); // 2 + format("&$1$::_$2$_default_instance_._instance,\n", + Namespace(descriptor, options_), // 1 + ClassName(descriptor)); // 2 } format.Outdent(); format( @@ -778,10 +850,8 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { format( // MSVC doesn't like empty arrays, so we add a dummy. "const $uint32$ $tablename$::offsets[1] = {};\n" - "static constexpr ::$proto_ns$::internal::MigrationSchema* schemas = " - "nullptr;" - "\n" - "static constexpr ::$proto_ns$::Message* const* " + "static constexpr ::_pbi::MigrationSchema* schemas = nullptr;\n" + "static constexpr ::_pb::Message* const* " "file_default_instances = nullptr;\n" "\n"); } @@ -836,7 +906,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { // Build array of DescriptorTable deps. if (num_deps > 0) { format( - "static const ::$proto_ns$::internal::DescriptorTable*const " + "static const ::_pbi::DescriptorTable* const " "$desc_table$_deps[$1$] = {\n", num_deps); @@ -856,13 +926,14 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { // so disable for now. bool eager = false; format( - "static ::$proto_ns$::internal::once_flag $desc_table$_once;\n" - "const ::$proto_ns$::internal::DescriptorTable $desc_table$ = {\n" - " false, $1$, $2$, $3$, \"$filename$\", \n" - " &$desc_table$_once, $4$, $5$, $6$,\n" - " schemas, file_default_instances, $tablename$::offsets,\n" - " $7$, $file_level_enum_descriptors$, " - "$file_level_service_descriptors$,\n" + "static ::_pbi::once_flag $desc_table$_once;\n" + "const ::_pbi::DescriptorTable $desc_table$ = {\n" + " false, $1$, $2$, $3$,\n" + " \"$filename$\",\n" + " &$desc_table$_once, $4$, $5$, $6$,\n" + " schemas, file_default_instances, $tablename$::offsets,\n" + " $7$, $file_level_enum_descriptors$,\n" + " $file_level_service_descriptors$,\n" "};\n" // This function exists to be marked as weak. // It can significantly speed up compilation by breaking up LLVM's SCC in @@ -875,7 +946,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { // vtables -> GetMetadata // By adding a weak function here we break the connection from the // individual vtables back into the descriptor table. - "PROTOBUF_ATTRIBUTE_WEAK const ::$proto_ns$::internal::DescriptorTable* " + "PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* " "$desc_table$_getter() {\n" " return &$desc_table$;\n" "}\n" @@ -893,127 +964,17 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { if (file_->name() != "net/proto2/proto/descriptor.proto") { format( "// Force running AddDescriptors() at dynamic initialization time.\n" - "PROTOBUF_ATTRIBUTE_INIT_PRIORITY " - "static ::$proto_ns$::internal::AddDescriptorsRunner " - "$1$(&$desc_table$);\n", + "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 " + "static ::_pbi::AddDescriptorsRunner $1$(&$desc_table$);\n", UniqueName("dynamic_init_dummy", file_, options_)); } } -void FileGenerator::GenerateTables(io::Printer* printer) { - Formatter format(printer, variables_); - if (options_.table_driven_parsing) { - // TODO(ckennelly): Gate this with the same options flag to enable - // table-driven parsing. - format( - "PROTOBUF_CONSTEXPR_VAR ::$proto_ns$::internal::ParseTableField\n" - " const $tablename$::entries[] " - "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); - format.Indent(); - - std::vector<size_t> entries; - size_t count = 0; - for (int i = 0; i < message_generators_.size(); i++) { - size_t value = message_generators_[i]->GenerateParseOffsets(printer); - entries.push_back(value); - count += value; - } - - // We need these arrays to exist, and MSVC does not like empty arrays. - if (count == 0) { - format("{0, 0, 0, ::$proto_ns$::internal::kInvalidMask, 0, 0},\n"); - } - - format.Outdent(); - format( - "};\n" - "\n" - "PROTOBUF_CONSTEXPR_VAR " - "::$proto_ns$::internal::AuxiliaryParseTableField\n" - " const $tablename$::aux[] " - "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); - format.Indent(); - - std::vector<size_t> aux_entries; - count = 0; - for (int i = 0; i < message_generators_.size(); i++) { - size_t value = message_generators_[i]->GenerateParseAuxTable(printer); - aux_entries.push_back(value); - count += value; - } - - if (count == 0) { - format("::$proto_ns$::internal::AuxiliaryParseTableField(),\n"); - } - - format.Outdent(); - format( - "};\n" - "PROTOBUF_CONSTEXPR_VAR ::$proto_ns$::internal::ParseTable const\n" - " $tablename$::schema[] " - "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); - format.Indent(); - - size_t offset = 0; - size_t aux_offset = 0; - for (int i = 0; i < message_generators_.size(); i++) { - message_generators_[i]->GenerateParseTable(printer, offset, aux_offset); - offset += entries[i]; - aux_offset += aux_entries[i]; - } - - if (message_generators_.empty()) { - format("{ nullptr, nullptr, 0, -1, -1, false },\n"); - } - - format.Outdent(); - format( - "};\n" - "\n"); - } - - if (!message_generators_.empty() && options_.table_driven_serialization) { - format( - "const ::$proto_ns$::internal::FieldMetadata " - "$tablename$::field_metadata[] " - "= {\n"); - format.Indent(); - std::vector<int> field_metadata_offsets; - int idx = 0; - for (int i = 0; i < message_generators_.size(); i++) { - field_metadata_offsets.push_back(idx); - idx += message_generators_[i]->GenerateFieldMetadata(printer); - } - field_metadata_offsets.push_back(idx); - format.Outdent(); - format( - "};\n" - "const ::$proto_ns$::internal::SerializationTable " - "$tablename$::serialization_table[] = {\n"); - format.Indent(); - // We rely on the order we layout the tables to match the order we - // calculate them with FlattenMessagesInFile, so we check here that - // these match exactly. - std::vector<const Descriptor*> calculated_order = - FlattenMessagesInFile(file_); - GOOGLE_CHECK_EQ(calculated_order.size(), message_generators_.size()); - for (int i = 0; i < message_generators_.size(); i++) { - GOOGLE_CHECK_EQ(calculated_order[i], message_generators_[i]->descriptor_); - format("{$1$, $tablename$::field_metadata + $2$},\n", - field_metadata_offsets[i + 1] - field_metadata_offsets[i], // 1 - field_metadata_offsets[i]); // 2 - } - format.Outdent(); - format( - "};\n" - "\n"); - } -} - class FileGenerator::ForwardDeclarations { public: void AddMessage(const Descriptor* d) { classes_[ClassName(d)] = d; } void AddEnum(const EnumDescriptor* d) { enums_[ClassName(d)] = d; } + void AddSplit(const Descriptor* d) { splits_[ClassName(d)] = d; } void Print(const Formatter& format, const Options& options) const { for (const auto& p : enums_) { @@ -1034,6 +995,14 @@ class FileGenerator::ForwardDeclarations { class_desc, classname, DefaultInstanceType(class_desc, options), DefaultInstanceName(class_desc, options)); } + for (const auto& p : splits_) { + const Descriptor* class_desc = p.second; + format( + "struct $1$;\n" + "$dllexport_decl $extern $1$ $2$;\n", + DefaultInstanceType(class_desc, options, /*split=*/true), + DefaultInstanceName(class_desc, options, /*split=*/true)); + } } void PrintTopLevelDecl(const Formatter& format, @@ -1049,6 +1018,7 @@ class FileGenerator::ForwardDeclarations { private: std::map<std::string, const Descriptor*> classes_; std::map<std::string, const EnumDescriptor*> enums_; + std::map<std::string, const Descriptor*> splits_; }; static void PublicImportDFS(const FileDescriptor* fd, @@ -1094,6 +1064,12 @@ void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) { if (d && !public_set.count(d->file())) decls[Namespace(d, options_)].AddEnum(d); } + for (const auto& mg : message_generators_) { + const Descriptor* d = mg->descriptor_; + if ((d != nullptr) && (public_set.count(d->file()) == 0u) && + ShouldSplit(mg->descriptor_, options_)) + decls[Namespace(d, options_)].AddSplit(d); + } { NamespaceOpener ns(format); @@ -1185,7 +1161,6 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { if (HasSimpleBaseClasses(file_, options_)) { IncludeFile("net/proto2/public/generated_message_bases.h", printer); } - IncludeFile("net/proto2/public/generated_message_table_driven.h", printer); if (HasGeneratedMethods(file_, options_) && options_.tctable_mode != Options::kTCTableNever) { IncludeFile("net/proto2/public/generated_message_tctable_decl.h", printer); @@ -1297,20 +1272,8 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( "\n" "// Internal implementation detail -- do not use these members.\n" "struct $dllexport_decl $$tablename$ {\n" - // These tables describe how to serialize and parse messages. Used - // for table driven code. - " static const ::$proto_ns$::internal::ParseTableField entries[]\n" - " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n" - " static const ::$proto_ns$::internal::AuxiliaryParseTableField aux[]\n" - " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n" - " static const ::$proto_ns$::internal::ParseTable schema[$1$]\n" - " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n" - " static const ::$proto_ns$::internal::FieldMetadata field_metadata[];\n" - " static const ::$proto_ns$::internal::SerializationTable " - "serialization_table[];\n" " static const $uint32$ offsets[];\n" - "};\n", - std::max(size_t(1), message_generators_.size())); + "};\n"); if (HasDescriptorMethods(file_, options_)) { format( "$dllexport_decl $extern const ::$proto_ns$::internal::DescriptorTable " diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_file.h b/r5dev/thirdparty/protobuf/compiler/cpp/file.h similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_file.h rename to r5dev/thirdparty/protobuf/compiler/cpp/file.h index 414b08e0..ce0317ff 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_file.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/file.h @@ -40,11 +40,12 @@ #include <set> #include <string> #include <vector> + #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_options.h> +#include <thirdparty/protobuf/compiler/cpp/field.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> #include <thirdparty/protobuf/compiler/scc.h> +#include <thirdparty/protobuf/compiler/cpp/options.h> namespace google { namespace protobuf { @@ -122,11 +123,11 @@ class FileGenerator { void GenerateInternalForwardDeclarations(const CrossFileReferences& refs, io::Printer* printer); void GenerateSourceIncludes(io::Printer* printer); + void GenerateSourcePrelude(io::Printer* printer); void GenerateSourceDefaultInstance(int idx, io::Printer* printer); void GenerateInitForSCC(const SCC* scc, const CrossFileReferences& refs, io::Printer* printer); - void GenerateTables(io::Printer* printer); void GenerateReflectionInitializationCode(io::Printer* printer); // For other imports, generates their forward-declarations. diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_generator.cc b/r5dev/thirdparty/protobuf/compiler/cpp/generator.cc similarity index 91% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_generator.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/generator.cc index 9a93a714..491f9b2c 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_generator.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/generator.cc @@ -32,7 +32,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/cpp/cpp_generator.h> +#include <thirdparty/protobuf/compiler/cpp/generator.h> #include <memory> #include <string> @@ -40,11 +40,11 @@ #include <vector> #include <thirdparty/protobuf/stubs/strutil.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_file.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> +#include <thirdparty/protobuf/compiler/cpp/file.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> +#include <thirdparty/protobuf/descriptor.pb.h> namespace google { namespace protobuf { @@ -82,6 +82,12 @@ bool CppGenerator::Generate(const FileDescriptor* file, // FOO_EXPORT is a macro which should expand to __declspec(dllexport) or // __declspec(dllimport) depending on what is being compiled. // + // If the proto_h option is passed to the compiler, we will generate all + // classes and enums so that they can be forward-declared from files that + // need them from imports. + // + // If the lite option is passed to the compiler, we will generate the + // current files and all transitive dependencies using the LITE runtime. Options file_options; file_options.opensource_runtime = opensource_runtime_; @@ -109,8 +115,10 @@ bool CppGenerator::Generate(const FileDescriptor* file, file_options.lite_implicit_weak_fields = true; if (!options[i].second.empty()) { file_options.num_cc_files = - strto32(options[i].second.c_str(), NULL, 10); + strto32(options[i].second.c_str(), nullptr, 10); } + } else if (options[i].first == "proto_h") { + file_options.proto_h = true; } else if (options[i].first == "annotate_accessor") { file_options.annotate_accessor = true; } else if (options[i].first == "inject_field_listener_events") { @@ -127,14 +135,14 @@ bool CppGenerator::Generate(const FileDescriptor* file, .insert(options[i].second.substr(pos, next_pos - pos)); pos = next_pos + 1; } while (pos < options[i].second.size()); - } else if (options[i].first == "eagerly_verified_lazy") { - file_options.eagerly_verified_lazy = true; + } else if (options[i].first == "verified_lazy") { + file_options.unverified_lazy = false; + } else if (options[i].first == "unverified_lazy_message_sets") { + file_options.unverified_lazy_message_sets = true; + } else if (options[i].first == "message_owned_arena_trial") { + file_options.message_owned_arena_trial = true; } else if (options[i].first == "force_eagerly_verified_lazy") { file_options.force_eagerly_verified_lazy = true; - } else if (options[i].first == "table_driven_parsing") { - file_options.table_driven_parsing = true; - } else if (options[i].first == "table_driven_serialization") { - file_options.table_driven_serialization = true; } else if (options[i].first == "experimental_tail_call_table_mode") { if (options[i].second == "never") { file_options.tctable_mode = Options::kTCTableNever; @@ -183,7 +191,7 @@ bool CppGenerator::Generate(const FileDescriptor* file, std::string info_path = basename + ".proto.h.meta"; io::Printer printer( output.get(), '$', - file_options.annotate_headers ? &annotation_collector : NULL); + file_options.annotate_headers ? &annotation_collector : nullptr); file_generator.GenerateProtoHeader( &printer, file_options.annotate_headers ? info_path : ""); if (file_options.annotate_headers) { @@ -202,7 +210,7 @@ bool CppGenerator::Generate(const FileDescriptor* file, std::string info_path = basename + ".pb.h.meta"; io::Printer printer( output.get(), '$', - file_options.annotate_headers ? &annotation_collector : NULL); + file_options.annotate_headers ? &annotation_collector : nullptr); file_generator.GeneratePBHeader( &printer, file_options.annotate_headers ? info_path : ""); if (file_options.annotate_headers) { diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/generator.h b/r5dev/thirdparty/protobuf/compiler/cpp/generator.h new file mode 100644 index 00000000..d6d2ecda --- /dev/null +++ b/r5dev/thirdparty/protobuf/compiler/cpp/generator.h @@ -0,0 +1,107 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Author: kenton@google.com (Kenton Varda) +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. +// +// Generates C++ code for a given .proto file. + +#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ +#define GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ + +#include <string> +#include <thirdparty/protobuf/compiler/code_generator.h> + +// Must be included last. +#include <thirdparty/protobuf/port_def.inc> + +namespace google { +namespace protobuf { +namespace compiler { +namespace cpp { + +// CodeGenerator implementation which generates a C++ source file and +// header. If you create your own protocol compiler binary and you want +// it to support C++ output, you can do so by registering an instance of this +// CodeGenerator with the CommandLineInterface in your main() function. +class PROTOC_EXPORT CppGenerator : public CodeGenerator { + public: + CppGenerator(); + ~CppGenerator() override; + + enum class Runtime { + kGoogle3, // Use the internal google3 runtime. + kOpensource, // Use the open-source runtime. + + // Use the open-source runtime with google3 #include paths. We make these + // absolute to avoid ambiguity, so the runtime will be #included like: + // #include "third_party/protobuf/.../google/protobuf/message.h" + kOpensourceGoogle3 + }; + + void set_opensource_runtime(bool opensource) { + opensource_runtime_ = opensource; + } + + // If set to a non-empty string, generated code will do: + // #include "<BASE>/google/protobuf/message.h" + // instead of: + // #include <thirdparty/protobuf/message.h> + // This has no effect if opensource_runtime = false. + void set_runtime_include_base(const std::string& base) { + runtime_include_base_ = base; + } + + // implements CodeGenerator ---------------------------------------- + bool Generate(const FileDescriptor* file, const std::string& parameter, + GeneratorContext* generator_context, + std::string* error) const override; + + uint64_t GetSupportedFeatures() const override { + // We don't fully support this yet, but this is needed to unblock the tests, + // and we will have full support before the experimental flag is removed. + return FEATURE_PROTO3_OPTIONAL; + } + + private: + bool opensource_runtime_ = true; + std::string runtime_include_base_; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CppGenerator); +}; + +} // namespace cpp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#include <thirdparty/protobuf/port_undef.inc> + +#endif // GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_helpers.cc b/r5dev/thirdparty/protobuf/compiler/cpp/helpers.cc similarity index 91% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_helpers.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/helpers.cc index 173e2899..9eb3926c 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_helpers.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/helpers.cc @@ -32,22 +32,23 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> #include <cstdint> #include <functional> #include <limits> #include <map> +#include <memory> #include <queue> #include <unordered_set> #include <vector> #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_options.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_names.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/compiler/cpp/names.h> +#include <thirdparty/protobuf/compiler/cpp/options.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/compiler/scc.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> @@ -178,18 +179,53 @@ void SetIntVar(const Options& options, const std::string& type, std::map<std::string, std::string>* variables) { (*variables)[type] = IntTypeName(options, type); } -bool IsEagerlyVerifiedLazyImpl(const FieldDescriptor* field, - const Options& options, - MessageSCCAnalyzer* scc_analyzer) { + +// Returns true if the message can potentially allocate memory for its field. +// This is used to determine if message-owned arena will be useful. +bool AllocExpected(const Descriptor* descriptor) { return false; } +// Describes different approaches to detect non-canonical int32 encoding. Only +// kNever or kAlways is eligible for *simple* verification methods. +enum class VerifyInt32Type { + kCustom, // Only check if field number matches. + kNever, // Do not check. + kAlways, // Always check. +}; + +inline VerifySimpleType VerifyInt32TypeToVerifyCustom(VerifyInt32Type t) { + static VerifySimpleType kCustomTypes[] = { + VerifySimpleType::kCustom, VerifySimpleType::kCustomInt32Never, + VerifySimpleType::kCustomInt32Always}; + return kCustomTypes[static_cast<int32_t>(t) - + static_cast<int32_t>(VerifyInt32Type::kCustom)]; +} + } // namespace bool IsLazy(const FieldDescriptor* field, const Options& options, MessageSCCAnalyzer* scc_analyzer) { return IsLazilyVerifiedLazy(field, options) || - IsEagerlyVerifiedLazyImpl(field, options, scc_analyzer); + IsEagerlyVerifiedLazy(field, options, scc_analyzer); +} + +// Returns true if "field" is a message field that is backed by LazyField per +// profile (go/pdlazy). +inline bool IsEagerlyVerifiedLazyByProfile(const FieldDescriptor* field, + const Options& options, + MessageSCCAnalyzer* scc_analyzer) { + return false; +} + +bool IsEagerlyVerifiedLazy(const FieldDescriptor* field, const Options& options, + MessageSCCAnalyzer* scc_analyzer) { + return false; +} + +bool IsLazilyVerifiedLazy(const FieldDescriptor* field, + const Options& options) { + return false; } void SetCommonVars(const Options& options, @@ -229,6 +265,23 @@ void SetCommonVars(const Options& options, (*variables)["string"] = "std::string"; } +void SetCommonMessageDataVariables( + const Descriptor* descriptor, + std::map<std::string, std::string>* variables) { + std::string prefix = IsMapEntryMessage(descriptor) ? "" : "_impl_."; + (*variables)["any_metadata"] = prefix + "_any_metadata_"; + (*variables)["cached_size"] = prefix + "_cached_size_"; + (*variables)["extensions"] = prefix + "_extensions_"; + (*variables)["has_bits"] = prefix + "_has_bits_"; + (*variables)["inlined_string_donated_array"] = + prefix + "_inlined_string_donated_"; + (*variables)["oneof_case"] = prefix + "_oneof_case_"; + (*variables)["tracker"] = "Impl_::_tracker_"; + (*variables)["weak_field_map"] = prefix + "_weak_field_map_"; + (*variables)["split"] = prefix + "_split_"; + (*variables)["cached_split_ptr"] = "cached_split_ptr"; +} + void SetUnknownFieldsVariable(const Descriptor* descriptor, const Options& options, std::map<std::string, std::string>* variables) { @@ -391,29 +444,32 @@ std::string Namespace(const EnumDescriptor* d, const Options& options) { } std::string DefaultInstanceType(const Descriptor* descriptor, - const Options& options) { - return ClassName(descriptor) + "DefaultTypeInternal"; + const Options& /*options*/, bool split) { + return ClassName(descriptor) + (split ? "__Impl_Split" : "") + + "DefaultTypeInternal"; } std::string DefaultInstanceName(const Descriptor* descriptor, - const Options& options) { - return "_" + ClassName(descriptor, false) + "_default_instance_"; + const Options& /*options*/, bool split) { + return "_" + ClassName(descriptor, false) + (split ? "__Impl_Split" : "") + + "_default_instance_"; } std::string DefaultInstancePtr(const Descriptor* descriptor, - const Options& options) { - return DefaultInstanceName(descriptor, options) + "ptr_"; + const Options& options, bool split) { + return DefaultInstanceName(descriptor, options, split) + "ptr_"; } std::string QualifiedDefaultInstanceName(const Descriptor* descriptor, - const Options& options) { + const Options& options, bool split) { return QualifiedFileLevelSymbol( - descriptor->file(), DefaultInstanceName(descriptor, options), options); + descriptor->file(), DefaultInstanceName(descriptor, options, split), + options); } std::string QualifiedDefaultInstancePtr(const Descriptor* descriptor, - const Options& options) { - return QualifiedDefaultInstanceName(descriptor, options) + "ptr_"; + const Options& options, bool split) { + return QualifiedDefaultInstanceName(descriptor, options, split) + "ptr_"; } std::string DescriptorTableName(const FileDescriptor* file, @@ -453,6 +509,19 @@ std::string FieldName(const FieldDescriptor* field) { return result; } +std::string FieldMemberName(const FieldDescriptor* field, bool split) { + StringPiece prefix = + IsMapEntryMessage(field->containing_type()) ? "" : "_impl_."; + StringPiece split_prefix = split ? "_split_->" : ""; + if (field->real_containing_oneof() == nullptr) { + return StrCat(prefix, split_prefix, FieldName(field), "_"); + } + // Oneof fields are never split. + GOOGLE_CHECK(!split); + return StrCat(prefix, field->containing_oneof()->name(), "_.", + FieldName(field), "_"); +} + std::string OneofCaseConstantName(const FieldDescriptor* field) { GOOGLE_DCHECK(field->containing_oneof()); std::string field_name = UnderscoresToCamelCase(field->name(), true); @@ -831,6 +900,9 @@ bool HasLazyFields(const FileDescriptor* file, const Options& options, return false; } +bool ShouldSplit(const Descriptor*, const Options&) { return false; } +bool ShouldSplit(const FieldDescriptor*, const Options&) { return false; } + static bool HasRepeatedFields(const Descriptor* descriptor) { for (int i = 0; i < descriptor->field_count(); ++i) { if (descriptor->field(i)->label() == FieldDescriptor::LABEL_REPEATED) { @@ -967,6 +1039,16 @@ bool ShouldVerify(const FileDescriptor* file, const Options& options, return false; } +bool IsUtf8String(const FieldDescriptor* field) { + return IsProto3(field->file()) && + field->type() == FieldDescriptor::TYPE_STRING; +} + +VerifySimpleType ShouldVerifySimple(const Descriptor* descriptor) { + (void)descriptor; + return VerifySimpleType::kCustom; +} + bool IsStringOrMessage(const FieldDescriptor* field) { switch (field->cpp_type()) { case FieldDescriptor::CPPTYPE_INT32: @@ -1147,7 +1229,6 @@ bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options, return UsingImplicitWeakFields(field->file(), options) && field->type() == FieldDescriptor::TYPE_MESSAGE && !field->is_required() && !field->is_map() && !field->is_extension() && - !field->real_containing_oneof() && !IsWellKnownMessage(field->message_type()->file()) && field->message_type()->file()->name() != "net/proto2/proto/descriptor.proto" && @@ -1264,7 +1345,7 @@ bool GetBootstrapBasename(const Options& options, const std::string& basename, std::unordered_map<std::string, std::string> bootstrap_mapping{ {"net/proto2/proto/descriptor", - "net/proto2/internal/descriptor"}, + "third_party/protobuf/descriptor"}, {"net/proto2/compiler/proto/plugin", "net/proto2/compiler/proto/plugin"}, {"net/proto2/compiler/proto/profile", @@ -1297,7 +1378,7 @@ bool MaybeBootstrap(const Options& options, GeneratorContext* generator_context, *basename = bootstrap_basename; return false; } else { - std::string forward_to_basename = bootstrap_basename; + const std::string& forward_to_basename = bootstrap_basename; // Generate forwarding headers and empty .pb.cc. { @@ -1486,8 +1567,29 @@ FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file, return FileOptions::SPEED; } -bool EnableMessageOwnedArena(const Descriptor* desc) { +inline bool IsMessageOwnedArenaEligible(const Descriptor* desc, + const Options& options) { + return GetOptimizeFor(desc->file(), options) != FileOptions::LITE_RUNTIME && + !options.bootstrap && !options.opensource_runtime && + AllocExpected(desc); +} + +bool EnableMessageOwnedArena(const Descriptor* desc, const Options& options) { (void)desc; + (void)options; + return false; +} + +bool EnableMessageOwnedArenaTrial(const Descriptor* desc, + const Options& options) { + return false; +} + +bool HasMessageFieldOrExtension(const Descriptor* desc) { + if (desc->extension_range_count() > 0) return true; + for (const auto* f : FieldRange(desc)) { + if (f->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) return true; + } return false; } diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_helpers.h b/r5dev/thirdparty/protobuf/compiler/cpp/helpers.h similarity index 86% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_helpers.h rename to r5dev/thirdparty/protobuf/compiler/cpp/helpers.h index e74e0df6..30f71b0d 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_helpers.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/helpers.h @@ -41,10 +41,10 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/cpp/cpp_options.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_names.h> #include <thirdparty/protobuf/compiler/scc.h> #include <thirdparty/protobuf/compiler/code_generator.h> +#include <thirdparty/protobuf/compiler/cpp/names.h> +#include <thirdparty/protobuf/compiler/cpp/options.h> #include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/descriptor.h> @@ -59,6 +59,8 @@ namespace protobuf { namespace compiler { namespace cpp { +enum class ArenaDtorNeeds { kNone = 0, kOnDemand = 1, kRequired = 2 }; + inline std::string ProtobufNamespace(const Options& /* options */) { return "PROTOBUF_NAMESPACE_ID"; } @@ -85,6 +87,11 @@ extern const char kThinSeparator[]; void SetCommonVars(const Options& options, std::map<std::string, std::string>* variables); +// Variables to access message data from the message scope. +void SetCommonMessageDataVariables( + const Descriptor* descriptor, + std::map<std::string, std::string>* variables); + void SetUnknownFieldsVariable(const Descriptor* descriptor, const Options& options, std::map<std::string, std::string>* variables); @@ -121,11 +128,11 @@ std::string QualifiedClassName(const EnumDescriptor* d); // Returns the non-nested type name for the given type. If "qualified" is // true, prefix the type with the full namespace. For example, if you had: // package foo.bar; -// message Baz { message Qux {} } -// Then the qualified ClassName for Qux would be: -// ::foo::bar::Baz_Qux +// message Baz { message Moo {} } +// Then the qualified ClassName for Moo would be: +// ::foo::bar::Baz_Moo // While the non-qualified version would be: -// Baz_Qux +// Baz_Moo inline std::string ClassName(const Descriptor* descriptor, bool qualified) { return qualified ? QualifiedClassName(descriptor, Options()) : ClassName(descriptor); @@ -146,24 +153,26 @@ std::string QualifiedExtensionName(const FieldDescriptor* d); // Type name of default instance. std::string DefaultInstanceType(const Descriptor* descriptor, - const Options& options); + const Options& options, bool split = false); // Non-qualified name of the default_instance of this message. std::string DefaultInstanceName(const Descriptor* descriptor, - const Options& options); + const Options& options, bool split = false); // Non-qualified name of the default instance pointer. This is used only for // implicit weak fields, where we need an extra indirection. std::string DefaultInstancePtr(const Descriptor* descriptor, - const Options& options); + const Options& options, bool split = false); // Fully qualified name of the default_instance of this message. std::string QualifiedDefaultInstanceName(const Descriptor* descriptor, - const Options& options); + const Options& options, + bool split = false); // Fully qualified name of the default instance pointer. std::string QualifiedDefaultInstancePtr(const Descriptor* descriptor, - const Options& options); + const Options& options, + bool split = false); // DescriptorTable variable name. std::string DescriptorTableName(const FileDescriptor* file, @@ -186,6 +195,9 @@ std::string ResolveKeyword(const std::string& name); // anyway, so normally this just returns field->name(). std::string FieldName(const FieldDescriptor* field); +// Returns the (unqualified) private member name for this field in C++ code. +std::string FieldMemberName(const FieldDescriptor* field, bool split); + // Returns an estimate of the compiler's alignment for the field. This // can't guarantee to be correct because the generated code could be compiled on // different systems with different alignment rules. The estimates below assume @@ -348,19 +360,22 @@ bool HasLazyFields(const FileDescriptor* file, const Options& options, bool IsLazy(const FieldDescriptor* field, const Options& options, MessageSCCAnalyzer* scc_analyzer); -inline bool IsLazilyVerifiedLazy(const FieldDescriptor* field, - const Options& options) { - return field->options().lazy() && !field->is_repeated() && - field->type() == FieldDescriptor::TYPE_MESSAGE && - GetOptimizeFor(field->file(), options) != FileOptions::LITE_RUNTIME && - !options.opensource_runtime; +// Is this an explicit (non-profile driven) lazy field, as denoted by +// lazy/unverified_lazy in the descriptor? +inline bool IsExplicitLazy(const FieldDescriptor* field) { + return field->options().lazy() || field->options().unverified_lazy(); } -inline bool IsEagerlyVerifiedLazy(const FieldDescriptor* field, - const Options& options, - MessageSCCAnalyzer* scc_analyzer) { - return IsLazy(field, options, scc_analyzer) && !field->options().lazy(); -} +bool IsEagerlyVerifiedLazy(const FieldDescriptor* field, const Options& options, + MessageSCCAnalyzer* scc_analyzer); + +bool IsLazilyVerifiedLazy(const FieldDescriptor* field, const Options& options); + +// Is the given message being split (go/pdsplit)? +bool ShouldSplit(const Descriptor* desc, const Options& options); + +// Is the given field being split out? +bool ShouldSplit(const FieldDescriptor* field, const Options& options); inline bool IsFieldUsed(const FieldDescriptor* /* field */, const Options& /* options */) { @@ -468,10 +483,49 @@ inline bool IsCrossFileMessage(const FieldDescriptor* field) { } inline std::string MakeDefaultName(const FieldDescriptor* field) { - return "_i_give_permission_to_break_this_code_default_" + FieldName(field) + - "_"; + return StrCat("_i_give_permission_to_break_this_code_default_", + FieldName(field), "_"); } +// Semantically distinct from MakeDefaultName in that it gives the C++ code +// referencing a default field from the message scope, rather than just the +// variable name. +// For example, declarations of default variables should always use just +// MakeDefaultName to produce code like: +// Type _i_give_permission_to_break_this_code_default_field_; +// +// Code that references these should use MakeDefaultFieldName, in case the field +// exists at some nested level like: +// internal_container_._i_give_permission_to_break_this_code_default_field_; +inline std::string MakeDefaultFieldName(const FieldDescriptor* field) { + return StrCat("Impl_::", MakeDefaultName(field)); +} + +inline std::string MakeVarintCachedSizeName(const FieldDescriptor* field) { + return StrCat("_", FieldName(field), "_cached_byte_size_"); +} + +// Semantically distinct from MakeVarintCachedSizeName in that it gives the C++ +// code referencing the object from the message scope, rather than just the +// variable name. +// For example, declarations of default variables should always use just +// MakeVarintCachedSizeName to produce code like: +// Type _field_cached_byte_size_; +// +// Code that references these variables should use +// MakeVarintCachedSizeFieldName, in case the field exists at some nested level +// like: +// internal_container_._field_cached_byte_size_; +inline std::string MakeVarintCachedSizeFieldName(const FieldDescriptor* field, + bool split) { + return StrCat("_impl_.", split ? "_split_->" : "", "_", + FieldName(field), "_cached_byte_size_"); +} + +// Note: A lot of libraries detect Any protos based on Descriptor::full_name() +// while the two functions below use FileDescriptor::name(). In a sane world the +// two approaches should be equivalent. But if you are dealing with descriptors +// from untrusted sources, you might need to match semantics across libraries. bool IsAnyMessage(const FileDescriptor* descriptor, const Options& options); bool IsAnyMessage(const Descriptor* descriptor, const Options& options); @@ -680,6 +734,18 @@ inline std::string SimpleBaseClass(const Descriptor* desc, return ""; } +// Returns true if this message has a _tracker_ field. +inline bool HasTracker(const Descriptor* desc, const Options& options) { + return options.field_listener_options.inject_field_listener_events && + desc->file()->options().optimize_for() != + google::protobuf::FileOptions::LITE_RUNTIME; +} + +// Returns true if this message needs an Impl_ struct for it's data. +inline bool HasImplData(const Descriptor* desc, const Options& options) { + return !HasSimpleBaseClass(desc, options); +} + // Formatter is a functor class which acts as a closure around printer and // the variable map. It's much like printer->Print except it supports both named // variables that are substituted using a key value map and direct arguments. In @@ -711,7 +777,7 @@ inline std::string SimpleBaseClass(const Descriptor* desc, // but consider using named variables. Named variables like $foo$, with some // identifier foo, are looked up in the map. One additional feature is that // spaces are accepted between the '$' delimiters, $ foo$ will -// substiture to " bar" if foo stands for "bar", but in case it's empty +// substitute to " bar" if foo stands for "bar", but in case it's empty // will substitute to "". Hence, for example, // // Format(vars, "$dllexport $void fun();") -> "void fun();" @@ -955,12 +1021,39 @@ inline OneOfRangeImpl OneOfRange(const Descriptor* desc) { return {desc}; } PROTOC_EXPORT std::string StripProto(const std::string& filename); -bool EnableMessageOwnedArena(const Descriptor* desc); +bool EnableMessageOwnedArena(const Descriptor* desc, const Options& options); + +bool EnableMessageOwnedArenaTrial(const Descriptor* desc, + const Options& options); bool ShouldVerify(const Descriptor* descriptor, const Options& options, MessageSCCAnalyzer* scc_analyzer); bool ShouldVerify(const FileDescriptor* file, const Options& options, MessageSCCAnalyzer* scc_analyzer); + +// Indicates whether to use predefined verify methods for a given message. If a +// message is "simple" and needs no special verification per field (e.g. message +// field, repeated packed, UTF8 string, etc.), we can use either VerifySimple or +// VerifySimpleAlwaysCheckInt32 methods as all verification can be done based on +// the wire type. +// +// Otherwise, we need "custom" verify methods tailored to a message to pass +// which field needs a special verification; i.e. InternalVerify. +enum class VerifySimpleType { + kSimpleInt32Never, // Use VerifySimple + kSimpleInt32Always, // Use VerifySimpleAlwaysCheckInt32 + kCustom, // Use InternalVerify and check only for int32 + kCustomInt32Never, // Use InternalVerify but never check for int32 + kCustomInt32Always, // Use InternalVerify and always check for int32 +}; + +// Returns VerifySimpleType if messages can be verified by predefined methods. +VerifySimpleType ShouldVerifySimple(const Descriptor* descriptor); + +bool IsUtf8String(const FieldDescriptor* field); + +bool HasMessageFieldOrExtension(const Descriptor* desc); + } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_map_field.cc b/r5dev/thirdparty/protobuf/compiler/cpp/map_field.cc similarity index 66% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_map_field.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/map_field.cc index 05cd0ca8..c1bacb80 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_map_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/map_field.cc @@ -28,12 +28,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <thirdparty/protobuf/compiler/cpp/cpp_map_field.h> +#include <thirdparty/protobuf/compiler/cpp/map_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> namespace google { @@ -53,10 +53,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor, (*variables)["type"] = ClassName(descriptor->message_type(), false); (*variables)["full_name"] = descriptor->full_name(); - const FieldDescriptor* key = - descriptor->message_type()->FindFieldByName("key"); - const FieldDescriptor* val = - descriptor->message_type()->FindFieldByName("value"); + const FieldDescriptor* key = descriptor->message_type()->map_key(); + const FieldDescriptor* val = descriptor->message_type()->map_value(); (*variables)["key_cpp"] = PrimitiveTypeName(options, key->cpp_type()); switch (val->cpp_type()) { case FieldDescriptor::CPPTYPE_MESSAGE: @@ -128,7 +126,7 @@ void MapFieldGenerator::GenerateInlineAccessorDefinitions( format( "inline const ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >&\n" "$classname$::_internal_$name$() const {\n" - " return $name$_.GetMap();\n" + " return $field$.GetMap();\n" "}\n" "inline const ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >&\n" "$classname$::$name$() const {\n" @@ -138,7 +136,8 @@ void MapFieldGenerator::GenerateInlineAccessorDefinitions( "}\n" "inline ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n" "$classname$::_internal_mutable_$name$() {\n" - " return $name$_.MutableMap();\n" + "$maybe_prepare_split_message$" + " return $field$.MutableMap();\n" "}\n" "inline ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n" "$classname$::mutable_$name$() {\n" @@ -150,17 +149,17 @@ void MapFieldGenerator::GenerateInlineAccessorDefinitions( void MapFieldGenerator::GenerateClearingCode(io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.Clear();\n"); + format("$field$.Clear();\n"); } void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.MergeFrom(from.$name$_);\n"); + format("_this->$field$.MergeFrom(from.$field$);\n"); } void MapFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.InternalSwap(&other->$name$_);\n"); + format("$field$.InternalSwap(&other->$field$);\n"); } void MapFieldGenerator::GenerateCopyConstructorCode( @@ -169,35 +168,27 @@ void MapFieldGenerator::GenerateCopyConstructorCode( GenerateMergingCode(printer); } -static void GenerateSerializationLoop(const Formatter& format, bool string_key, +static void GenerateSerializationLoop(Formatter& format, bool string_key, bool string_value, bool is_deterministic) { - std::string ptr; if (is_deterministic) { - format("for (size_type i = 0; i < n; i++) {\n"); - ptr = string_key ? "items[static_cast<ptrdiff_t>(i)]" - : "items[static_cast<ptrdiff_t>(i)].second"; - } else { format( - "for (::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::const_iterator\n" - " it = this->_internal_$name$().begin();\n" - " it != this->_internal_$name$().end(); ++it) {\n"); - ptr = "it"; + "for (const auto& entry : " + "::_pbi::MapSorter$1$<MapType>(map_field)) {\n", + (string_key ? "Ptr" : "Flat")); + } else { + format("for (const auto& entry : map_field) {\n"); } - format.Indent(); + { + auto loop_scope = format.ScopedIndent(); + format( + "target = WireHelper::InternalSerialize($number$, " + "entry.first, entry.second, target, stream);\n"); - format( - "target = $map_classname$::Funcs::InternalSerialize($number$, " - "$1$->first, $1$->second, target, stream);\n", - ptr); - - if (string_key || string_value) { - // ptr is either an actual pointer or an iterator, either way we can - // create a pointer by taking the address after de-referencing it. - format("Utf8Check::Check(&(*$1$));\n", ptr); + if (string_key || string_value) { + format("check_utf8(entry);\n"); + } } - - format.Outdent(); format("}\n"); } @@ -206,77 +197,52 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizesToArray( Formatter format(printer, variables_); format("if (!this->_internal_$name$().empty()) {\n"); format.Indent(); - const FieldDescriptor* key_field = - descriptor_->message_type()->FindFieldByName("key"); - const FieldDescriptor* value_field = - descriptor_->message_type()->FindFieldByName("value"); + const FieldDescriptor* key_field = descriptor_->message_type()->map_key(); + const FieldDescriptor* value_field = descriptor_->message_type()->map_value(); const bool string_key = key_field->type() == FieldDescriptor::TYPE_STRING; const bool string_value = value_field->type() == FieldDescriptor::TYPE_STRING; format( - "typedef ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::const_pointer\n" - " ConstPtr;\n"); - if (string_key) { - format( - "typedef ConstPtr SortItem;\n" - "typedef ::$proto_ns$::internal::" - "CompareByDerefFirst<SortItem> Less;\n"); - } else { - format( - "typedef ::$proto_ns$::internal::SortItem< $key_cpp$, ConstPtr > " - "SortItem;\n" - "typedef ::$proto_ns$::internal::CompareByFirstField<SortItem> " - "Less;\n"); - } + "using MapType = ::_pb::Map<$key_cpp$, $val_cpp$>;\n" + "using WireHelper = $map_classname$::Funcs;\n" + "const auto& map_field = this->_internal_$name$();\n"); bool utf8_check = string_key || string_value; if (utf8_check) { - format( - "struct Utf8Check {\n" - " static void Check(ConstPtr p) {\n" - // p may be unused when GetUtf8CheckMode evaluates to kNone, - // thus disabling the validation. - " (void)p;\n"); - format.Indent(); - format.Indent(); - if (string_key) { - GenerateUtf8CheckCodeForString( - key_field, options_, false, - "p->first.data(), static_cast<int>(p->first.length()),\n", format); + format("auto check_utf8 = [](const MapType::value_type& entry) {\n"); + { + auto check_scope = format.ScopedIndent(); + // p may be unused when GetUtf8CheckMode evaluates to kNone, + // thus disabling the validation. + format("(void)entry;\n"); + if (string_key) { + GenerateUtf8CheckCodeForString( + key_field, options_, false, + "entry.first.data(), static_cast<int>(entry.first.length()),\n", + format); + } + if (string_value) { + GenerateUtf8CheckCodeForString( + value_field, options_, false, + "entry.second.data(), static_cast<int>(entry.second.length()),\n", + format); + } } - if (string_value) { - GenerateUtf8CheckCodeForString( - value_field, options_, false, - "p->second.data(), static_cast<int>(p->second.length()),\n", format); - } - format.Outdent(); - format.Outdent(); - format( - " }\n" - "};\n"); + format("};\n"); } format( "\n" - "if (stream->IsSerializationDeterministic() &&\n" - " this->_internal_$name$().size() > 1) {\n" - " ::std::unique_ptr<SortItem[]> items(\n" - " new SortItem[this->_internal_$name$().size()]);\n" - " typedef ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::size_type " - "size_type;\n" - " size_type n = 0;\n" - " for (::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::const_iterator\n" - " it = this->_internal_$name$().begin();\n" - " it != this->_internal_$name$().end(); ++it, ++n) {\n" - " items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);\n" - " }\n" - " ::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());\n"); - format.Indent(); - GenerateSerializationLoop(format, string_key, string_value, true); - format.Outdent(); + "if (stream->IsSerializationDeterministic() && " + "map_field.size() > 1) {\n"); + { + auto deterministic_scope = format.ScopedIndent(); + GenerateSerializationLoop(format, string_key, string_value, true); + } format("} else {\n"); - format.Indent(); - GenerateSerializationLoop(format, string_key, string_value, false); - format.Outdent(); + { + auto map_order_scope = format.ScopedIndent(); + GenerateSerializationLoop(format, string_key, string_value, false); + } format("}\n"); format.Outdent(); format("}\n"); @@ -301,31 +267,69 @@ void MapFieldGenerator::GenerateIsInitialized(io::Printer* printer) const { Formatter format(printer, variables_); format( - "if (!::$proto_ns$::internal::AllAreInitialized($name$_)) return " + "if (!::$proto_ns$::internal::AllAreInitialized($field$)) return " "false;\n"); } -void MapFieldGenerator::GenerateConstinitInitializer( +void MapFieldGenerator::GenerateConstexprAggregateInitializer( io::Printer* printer) const { Formatter format(printer, variables_); if (HasDescriptorMethods(descriptor_->file(), options_)) { - format("$name$_(::$proto_ns$::internal::ConstantInitialized{})"); + format("/*decltype($field$)*/{::_pbi::ConstantInitialized()}"); } else { - format("$name$_()"); + format("/*decltype($field$)*/{}"); } } -bool MapFieldGenerator::GenerateArenaDestructorCode( +void MapFieldGenerator::GenerateCopyAggregateInitializer( io::Printer* printer) const { Formatter format(printer, variables_); - if (HasDescriptorMethods(descriptor_->file(), options_)) { - // _this is the object being destructed (we are inside a static method - // here). - format("_this->$name$_. ~MapField();\n"); - return true; - } else { - return false; + // MapField has no move constructor, which prevents explicit aggregate + // initialization pre-C++17. + format("/*decltype($field$)*/{}"); +} + +void MapFieldGenerator::GenerateAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + if (ShouldSplit(descriptor_, options_)) { + format( + "/*decltype($classname$::Split::$name$_)*/" + "{::_pbi::ArenaInitialized(), arena}"); + return; } + // MapField has no move constructor. + format("/*decltype($field$)*/{::_pbi::ArenaInitialized(), arena}"); +} + +void MapFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { + GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); + + Formatter format(printer, variables_); + if (ShouldSplit(descriptor_, options_)) { + format("$cached_split_ptr$->$name$_.Destruct();\n"); + format("$cached_split_ptr$->$name$_.~MapField$lite$();\n"); + return; + } + format("$field$.Destruct();\n"); + format("$field$.~MapField$lite$();\n"); +} + +void MapFieldGenerator::GenerateArenaDestructorCode( + io::Printer* printer) const { + if (NeedsArenaDestructor() == ArenaDtorNeeds::kNone) { + return; + } + + Formatter format(printer, variables_); + // _this is the object being destructed (we are inside a static method here). + format("_this->$field$.Destruct();\n"); +} + +ArenaDtorNeeds MapFieldGenerator::NeedsArenaDestructor() const { + return HasDescriptorMethods(descriptor_->file(), options_) + ? ArenaDtorNeeds::kRequired + : ArenaDtorNeeds::kNone; } } // namespace cpp diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_map_field.h b/r5dev/thirdparty/protobuf/compiler/cpp/map_field.h similarity index 85% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_map_field.h rename to r5dev/thirdparty/protobuf/compiler/cpp/map_field.h index f4ca368e..8f4691fa 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_map_field.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/map_field.h @@ -34,8 +34,8 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_message_field.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> +#include <thirdparty/protobuf/compiler/cpp/message_field.h> namespace google { namespace protobuf { @@ -61,8 +61,13 @@ class MapFieldGenerator : public FieldGenerator { io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; void GenerateIsInitialized(io::Printer* printer) const override; - void GenerateConstinitInitializer(io::Printer* printer) const override; - bool GenerateArenaDestructorCode(io::Printer* printer) const override; + void GenerateConstexprAggregateInitializer( + io::Printer* printer) const override; + void GenerateCopyAggregateInitializer(io::Printer* printer) const override; + void GenerateAggregateInitializer(io::Printer* printer) const override; + void GenerateDestructorCode(io::Printer* printer) const override; + void GenerateArenaDestructorCode(io::Printer* printer) const override; + ArenaDtorNeeds NeedsArenaDestructor() const override; private: const bool has_required_fields_; diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_message.cc b/r5dev/thirdparty/protobuf/compiler/cpp/message.cc similarity index 78% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_message.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/message.cc index 58e5cadf..6d63c6c5 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_message.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/message.cc @@ -32,7 +32,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/cpp/cpp_message.h> +#include <thirdparty/protobuf/compiler/cpp/message.h> #include <algorithm> #include <cstdint> @@ -44,22 +44,22 @@ #include <vector> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_enum.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_extension.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_padding_optimizer.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_parse_function_generator.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/map_entry_lite.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/compiler/cpp/enum.h> +#include <thirdparty/protobuf/compiler/cpp/extension.h> +#include <thirdparty/protobuf/compiler/cpp/field.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> +#include <thirdparty/protobuf/compiler/cpp/padding_optimizer.h> +#include <thirdparty/protobuf/compiler/cpp/parse_function_generator.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/stubs/hash.h> @@ -84,7 +84,7 @@ static constexpr int kNoHasbit = -1; // masks must be non-zero. std::string ConditionalToCheckBitmasks( const std::vector<uint32_t>& masks, bool return_success = true, - StringPiece has_bits_var = "_has_bits_") { + StringPiece has_bits_var = "_impl_._has_bits_") { std::vector<std::string> parts; for (int i = 0; i < masks.size(); i++) { if (masks[i] == 0) continue; @@ -109,7 +109,7 @@ void PrintPresenceCheck(const Formatter& format, const FieldDescriptor* field, int has_bit_index = has_bit_indices[field->index()]; if (*cached_has_word_index != (has_bit_index / 32)) { *cached_has_word_index = (has_bit_index / 32); - format("cached_has_bits = _has_bits_[$1$];\n", *cached_has_word_index); + format("cached_has_bits = $has_bits$[$1$];\n", *cached_has_word_index); } const std::string mask = StrCat(strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); @@ -276,8 +276,8 @@ void CollectMapInfo(const Options& options, const Descriptor* descriptor, std::map<std::string, std::string>* variables) { GOOGLE_CHECK(IsMapEntryMessage(descriptor)); std::map<std::string, std::string>& vars = *variables; - const FieldDescriptor* key = descriptor->FindFieldByName("key"); - const FieldDescriptor* val = descriptor->FindFieldByName("value"); + const FieldDescriptor* key = descriptor->map_key(); + const FieldDescriptor* val = descriptor->map_value(); vars["key_cpp"] = PrimitiveTypeName(options, key->cpp_type()); switch (val->cpp_type()) { case FieldDescriptor::CPPTYPE_MESSAGE: @@ -323,64 +323,6 @@ bool ShouldSerializeInOrder(const Descriptor* descriptor, return true; } -bool TableDrivenParsingEnabled(const Descriptor* descriptor, - const Options& options, - MessageSCCAnalyzer* scc_analyzer) { - if (!options.table_driven_parsing) { - return false; - } - - // Consider table-driven parsing. We only do this if: - // - We have has_bits for fields. This avoids a check on every field we set - // when are present (the common case). - bool has_hasbit = false; - for (int i = 0; i < descriptor->field_count(); i++) { - if (HasHasbit(descriptor->field(i))) { - has_hasbit = true; - break; - } - } - - if (!has_hasbit) return false; - - const double table_sparseness = 0.5; - int max_field_number = 0; - for (auto field : FieldRange(descriptor)) { - if (max_field_number < field->number()) { - max_field_number = field->number(); - } - - // - There are no weak fields. - if (IsWeak(field, options)) { - return false; - } - - // - There are no lazy fields (they require the non-lite library). - if (IsLazy(field, options, scc_analyzer)) { - return false; - } - } - - // - There range of field numbers is "small" - if (max_field_number >= (2 << 14)) { - return false; - } - - // - Field numbers are relatively dense within the actual number of fields. - // We check for strictly greater than in the case where there are no fields - // (only extensions) so max_field_number == descriptor->field_count() == 0. - if (max_field_number * table_sparseness > descriptor->field_count()) { - return false; - } - - // - This is not a MapEntryMessage. - if (IsMapEntryMessage(descriptor)) { - return false; - } - - return true; -} - bool IsCrossFileMapField(const FieldDescriptor* field) { if (!field->is_map()) { return false; @@ -404,10 +346,10 @@ bool IsRequired(const std::vector<const FieldDescriptor*>& v) { return v.front()->is_required(); } -bool HasSingularString(const Descriptor* desc, const Options& options) { +bool HasNonSplitOptionalString(const Descriptor* desc, const Options& options) { for (const auto* field : FieldRange(desc)) { - if (IsString(field, options) && !IsStringInlined(field, options) && - !field->is_repeated() && !field->real_containing_oneof()) { + if (IsString(field, options) && !field->is_repeated() && + !field->real_containing_oneof() && !ShouldSplit(field, options)) { return true; } } @@ -462,7 +404,7 @@ static int popcnt(uint32_t n) { class ColdChunkSkipper { public: ColdChunkSkipper( - const Options& options, + const Descriptor* descriptor, const Options& options, const std::vector<std::vector<const FieldDescriptor*>>& chunks, const std::vector<int>& has_bit_indices, const double cold_threshold) : chunks_(chunks), @@ -470,6 +412,7 @@ class ColdChunkSkipper { access_info_map_(options.access_info_map), cold_threshold_(cold_threshold) { SetCommonVars(options, &variables_); + SetCommonMessageDataVariables(descriptor, &variables_); } // May open an external if check for a batch of cold fields. "from" is the @@ -553,7 +496,7 @@ void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index, if (this_word == cached_has_word_index) { format("(cached_has_bits & 0x$mask$u) != 0"); } else { - format("($1$_has_bits_[$2$] & 0x$mask$u) != 0", from, this_word); + format("($1$_impl_._has_bits_[$2$] & 0x$mask$u) != 0", from, this_word); } } format(")) {\n"); @@ -605,11 +548,11 @@ void GenerateExtensionAnnotations( for (const auto& annotation : accessor_annotations_to_hooks) { (*variables)[annotation.first] = ""; } - if (!options.field_listener_options.inject_field_listener_events || - descriptor->file()->options().optimize_for() == - google::protobuf::FileOptions::LITE_RUNTIME) { + if (!HasTracker(descriptor, options)) { return; } + StringPiece tracker = (*variables)["tracker"]; + StringPiece extensions = (*variables)["extensions"]; for (const auto& annotation : accessor_annotations_to_hooks) { const std::string& annotation_name = annotation.first; const std::string& listener_call = annotation.second; @@ -619,29 +562,29 @@ void GenerateExtensionAnnotations( // Primitive fields accessors. // "Has" is here as users calling "has" on a repeated field is a mistake. (*variables)[annotation_name] = StrCat( - " _tracker_.", listener_call, - "(this, id.number(), _proto_TypeTraits::GetPtr(id.number(), " - "_extensions_, id.default_value_ref()));"); + " ", tracker, ".", listener_call, + "(this, id.number(), _proto_TypeTraits::GetPtr(id.number(), ", + extensions, ", id.default_value_ref()));"); } else if (StrContains(annotation_name, "repeated") && !StrContains(annotation_name, "list") && !StrContains(annotation_name, "size")) { // Repeated index accessors. std::string str_index = "index"; if (StrContains(annotation_name, "add")) { - str_index = "_extensions_.ExtensionSize(id.number()) - 1"; + str_index = StrCat(extensions, ".ExtensionSize(id.number()) - 1"); } (*variables)[annotation_name] = - StrCat(" _tracker_.", listener_call, + StrCat(" ", tracker, ".", listener_call, "(this, id.number(), " - "_proto_TypeTraits::GetPtr(id.number(), _extensions_, ", - str_index, "));"); + "_proto_TypeTraits::GetPtr(id.number(), ", + extensions, ", ", str_index, "));"); } else if (StrContains(annotation_name, "list") || StrContains(annotation_name, "size")) { // Repeated full accessors. (*variables)[annotation_name] = StrCat( - " _tracker_.", listener_call, - "(this, id.number(), _proto_TypeTraits::GetRepeatedPtr(id.number(), " - "_extensions_));"); + " ", tracker, ".", listener_call, + "(this, id.number(), _proto_TypeTraits::GetRepeatedPtr(id.number(), ", + extensions, "));"); } else { // Generic accessors such as "clear". // TODO(b/190614678): Generalize clear from both repeated and non repeated @@ -673,6 +616,7 @@ MessageGenerator::MessageGenerator( if (!message_layout_helper_) { message_layout_helper_.reset(new PaddingOptimizer()); } + SetCommonMessageDataVariables(descriptor, &variables_); // Variables that apply to this class variables_["classname"] = classname_; @@ -685,10 +629,9 @@ MessageGenerator::MessageGenerator( variables_["annotate_bytesize"] = ""; variables_["annotate_mergefrom"] = ""; - if (options.field_listener_options.inject_field_listener_events && - descriptor->file()->options().optimize_for() != - google::protobuf::FileOptions::LITE_RUNTIME) { - const std::string injector_template = " _tracker_."; + if (HasTracker(descriptor_, options_)) { + const std::string injector_template = + StrCat(" ", variables_["tracker"], "."); MaySetAnnotationVariable(options, "serialize", injector_template, "OnSerialize(this);\n", &variables_); @@ -703,7 +646,7 @@ MessageGenerator::MessageGenerator( MaySetAnnotationVariable(options, "bytesize", injector_template, "OnByteSize(this);\n", &variables_); MaySetAnnotationVariable(options, "mergefrom", injector_template, - "OnMergeFrom(this, &from);\n", &variables_); + "OnMergeFrom(_this, &from);\n", &variables_); } GenerateExtensionAnnotations(descriptor_, options_, &variables_); @@ -738,6 +681,9 @@ MessageGenerator::MessageGenerator( if (IsStringInlined(field, options_)) { if (inlined_string_indices_.empty()) { inlined_string_indices_.resize(descriptor_->field_count(), kNoHasbit); + // The bitset[0] is for arena dtor tracking. Donating states start from + // bitset[1]; + max_inlined_string_index_++; } inlined_string_indices_[field->index()] = max_inlined_string_index_++; } @@ -758,8 +704,6 @@ MessageGenerator::MessageGenerator( } } - table_driven_ = - TableDrivenParsingEnabled(descriptor_, options_, scc_analyzer_); parse_function_generator_.reset(new ParseFunctionGenerator( descriptor_, max_has_bit_index_, has_bit_indices_, inlined_string_indices_, options_, scc_analyzer_, variables_)); @@ -903,7 +847,7 @@ inline bool HasExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) const { $annotate_extension_has$ - return _extensions_.Has(id.number()); + return $extensions$.Has(id.number()); } template <typename _proto_TypeTraits, @@ -912,7 +856,7 @@ template <typename _proto_TypeTraits, inline void ClearExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) { - _extensions_.ClearExtension(id.number()); + $extensions$.ClearExtension(id.number()); $annotate_extension_clear$ } @@ -923,7 +867,7 @@ inline int ExtensionSize( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) const { $annotate_extension_repeated_size$ - return _extensions_.ExtensionSize(id.number()); + return $extensions$.ExtensionSize(id.number()); } template <typename _proto_TypeTraits, @@ -933,7 +877,7 @@ inline typename _proto_TypeTraits::Singular::ConstType GetExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) const { $annotate_extension_get$ - return _proto_TypeTraits::Get(id.number(), _extensions_, + return _proto_TypeTraits::Get(id.number(), $extensions$, id.default_value()); } @@ -945,7 +889,7 @@ inline typename _proto_TypeTraits::Singular::MutableType MutableExtension( $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) { $annotate_extension_mutable$ return _proto_TypeTraits::Mutable(id.number(), _field_type, - &_extensions_); + &$extensions$); } template <typename _proto_TypeTraits, @@ -955,7 +899,7 @@ inline void SetExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< $classname$, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::ConstType value) { - _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), _field_type, value, &$extensions$); $annotate_extension_set$ } @@ -967,7 +911,7 @@ inline void SetAllocatedExtension( $classname$, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::SetAllocated(id.number(), _field_type, value, - &_extensions_); + &$extensions$); $annotate_extension_set$ } template <typename _proto_TypeTraits, @@ -978,7 +922,7 @@ inline void UnsafeArenaSetAllocatedExtension( $classname$, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type, - value, &_extensions_); + value, &$extensions$); $annotate_extension_set$ } template <typename _proto_TypeTraits, @@ -991,7 +935,7 @@ PROTOBUF_NODISCARD inline $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) { $annotate_extension_release$ return _proto_TypeTraits::Release(id.number(), _field_type, - &_extensions_); + &$extensions$); } template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, @@ -1002,7 +946,7 @@ UnsafeArenaReleaseExtension( $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) { $annotate_extension_release$ return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type, - &_extensions_); + &$extensions$); } template <typename _proto_TypeTraits, @@ -1013,7 +957,7 @@ inline typename _proto_TypeTraits::Repeated::ConstType GetExtension( $classname$, _proto_TypeTraits, _field_type, _is_packed>& id, int index) const { $annotate_repeated_extension_get$ - return _proto_TypeTraits::Get(id.number(), _extensions_, index); + return _proto_TypeTraits::Get(id.number(), $extensions$, index); } template <typename _proto_TypeTraits, @@ -1024,7 +968,7 @@ inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension( $classname$, _proto_TypeTraits, _field_type, _is_packed>& id, int index) { $annotate_repeated_extension_mutable$ - return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); + return _proto_TypeTraits::Mutable(id.number(), index, &$extensions$); } template <typename _proto_TypeTraits, @@ -1034,7 +978,7 @@ inline void SetExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< $classname$, _proto_TypeTraits, _field_type, _is_packed>& id, int index, typename _proto_TypeTraits::Repeated::ConstType value) { - _proto_TypeTraits::Set(id.number(), index, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), index, value, &$extensions$); $annotate_repeated_extension_set$ } @@ -1045,7 +989,7 @@ inline typename _proto_TypeTraits::Repeated::MutableType AddExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) { typename _proto_TypeTraits::Repeated::MutableType to_add = - _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); + _proto_TypeTraits::Add(id.number(), _field_type, &$extensions$); $annotate_repeated_extension_add_mutable$ return to_add; } @@ -1058,7 +1002,7 @@ inline void AddExtension( $classname$, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Repeated::ConstType value) { _proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value, - &_extensions_); + &$extensions$); $annotate_repeated_extension_add$ } @@ -1070,7 +1014,7 @@ GetRepeatedExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) const { $annotate_repeated_extension_list$ - return _proto_TypeTraits::GetRepeated(id.number(), _extensions_); + return _proto_TypeTraits::GetRepeated(id.number(), $extensions$); } template <typename _proto_TypeTraits, @@ -1082,7 +1026,7 @@ MutableRepeatedExtension( $classname$, _proto_TypeTraits, _field_type, _is_packed>& id) { $annotate_repeated_extension_list_mutable$ return _proto_TypeTraits::MutableRepeated(id.number(), _field_type, - _is_packed, &_extensions_); + _is_packed, &$extensions$); } )"); @@ -1119,7 +1063,7 @@ void MessageGenerator::GenerateSingularFieldHasBits( format( "inline bool $classname$::has_$name$() const {\n" "$annotate_has$" - " return _weak_field_map_.Has($number$);\n" + " return $weak_field_map$.Has($number$);\n" "}\n"); return; } @@ -1133,14 +1077,14 @@ void MessageGenerator::GenerateSingularFieldHasBits( format( "inline bool $classname$::_internal_has_$name$() const {\n" " bool value = " - "(_has_bits_[$has_array_index$] & 0x$has_mask$u) != 0;\n"); + "($has_bits$[$has_array_index$] & 0x$has_mask$u) != 0;\n"); if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && !IsLazy(field, options_, scc_analyzer_)) { // We maintain the invariant that for a submessage x, has_x() returning // true implies that x_ is not null. By giving this information to the // compiler, we allow it to eliminate unnecessary null checks later on. - format(" PROTOBUF_ASSUME(!value || $name$_ != nullptr);\n"); + format(" PROTOBUF_ASSUME(!value || $field$ != nullptr);\n"); } format( @@ -1155,13 +1099,13 @@ void MessageGenerator::GenerateSingularFieldHasBits( if (IsLazy(field, options_, scc_analyzer_)) { format( "inline bool $classname$::_internal_has_$name$() const {\n" - " return !$name$_.IsCleared();\n" + " return !$field$.IsCleared();\n" "}\n"); } else { format( "inline bool $classname$::_internal_has_$name$() const {\n" " return this != internal_default_instance() " - "&& $name$_ != nullptr;\n" + "&& $field$ != nullptr;\n" "}\n"); } format( @@ -1183,7 +1127,7 @@ void MessageGenerator::GenerateOneofHasBits(io::Printer* printer) { " return $oneof_name$_case() != $cap_oneof_name$_NOT_SET;\n" "}\n" "inline void $classname$::clear_has_$oneof_name$() {\n" - " _oneof_case_[$oneof_index$] = $cap_oneof_name$_NOT_SET;\n" + " $oneof_case$[$oneof_index$] = $cap_oneof_name$_NOT_SET;\n" "}\n"); } } @@ -1229,7 +1173,7 @@ void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field, // annotated. format( "inline void $classname$::set_has_$name$() {\n" - " _oneof_case_[$oneof_index$] = k$field_name$;\n" + " $oneof_case$[$oneof_index$] = k$field_name$;\n" "}\n"); } @@ -1258,13 +1202,16 @@ void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field, format.Outdent(); format("}\n"); } else { + if (ShouldSplit(field, options_)) { + format("if (IsSplitMessageDefault()) return;\n"); + } field_generators_.get(field).GenerateClearingCode(format.printer()); if (HasHasbit(field)) { int has_bit_index = HasBitIndex(field); format.Set("has_array_index", has_bit_index / 32); format.Set("has_mask", strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); - format("_has_bits_[$has_array_index$] &= ~0x$has_mask$u;\n"); + format("$has_bits$[$has_array_index$] &= ~0x$has_mask$u;\n"); } } format("$annotate_clear$"); @@ -1298,7 +1245,7 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) { } else { format( "inline int $classname$::_internal_$name$_size() const {\n" - " return $name$_$1$.size();\n" + " return $field$$1$.size();\n" "}\n" "inline int $classname$::$name$_size() const {\n" "$annotate_size$" @@ -1360,7 +1307,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { " ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> " "SuperType;\n" " $classname$();\n" - " explicit constexpr $classname$(\n" + " explicit PROTOBUF_CONSTEXPR $classname$(\n" " ::$proto_ns$::internal::ConstantInitialized);\n" " explicit $classname$(::$proto_ns$::Arena* arena);\n" " void MergeFrom(const $classname$& other);\n" @@ -1432,7 +1379,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "" " ::$proto_ns$::Metadata GetMetadata() const final;\n"); } - format("};\n"); + format( + " friend struct ::$tablename$;\n" + "};\n"); return; } @@ -1444,11 +1393,15 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format(" public:\n"); format.Indent(); - if (EnableMessageOwnedArena(descriptor_)) { + if (EnableMessageOwnedArena(descriptor_, options_)) { format( "inline $classname$() : $classname$(" - "::$proto_ns$::Arena::InternalHelper<$classname$>::\n" - " CreateMessageOwnedArena(), true) {}\n"); + "::$proto_ns$::Arena::InternalCreateMessageOwnedArena(), true) {}\n"); + } else if (EnableMessageOwnedArenaTrial(descriptor_, options_)) { + format( + "inline $classname$() : $classname$(InMoaTrial() ? " + "::$proto_ns$::Arena::InternalCreateMessageOwnedArena() : nullptr, " + "InMoaTrial()) {}\n"); } else { format("inline $classname$() : $classname$(nullptr) {}\n"); } @@ -1456,7 +1409,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format("~$classname$() override;\n"); } format( - "explicit constexpr " + "explicit PROTOBUF_CONSTEXPR " "$classname$(::$proto_ns$::internal::ConstantInitialized);\n" "\n" "$classname$(const $classname$& from);\n" @@ -1484,14 +1437,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "}\n" "\n"); - if (options_.table_driven_serialization) { - format( - "private:\n" - "const void* InternalGetTable() const override;\n" - "public:\n" - "\n"); - } - if (PublicUnknownFieldsAccessors(descriptor_)) { format( "inline const $unknown_fields_type$& unknown_fields() const {\n" @@ -1569,16 +1514,18 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { if (HasDescriptorMethods(descriptor_->file(), options_)) { format( "bool PackFrom(const ::$proto_ns$::Message& message) {\n" - " return _any_metadata_.PackFrom(GetArena(), message);\n" + " $DCHK$_NE(&message, this);\n" + " return $any_metadata$.PackFrom(GetArena(), message);\n" "}\n" "bool PackFrom(const ::$proto_ns$::Message& message,\n" " ::PROTOBUF_NAMESPACE_ID::ConstStringParam " "type_url_prefix) {\n" - " return _any_metadata_.PackFrom(GetArena(), message, " + " $DCHK$_NE(&message, this);\n" + " return $any_metadata$.PackFrom(GetArena(), message, " "type_url_prefix);\n" "}\n" "bool UnpackTo(::$proto_ns$::Message* message) const {\n" - " return _any_metadata_.UnpackTo(message);\n" + " return $any_metadata$.UnpackTo(message);\n" "}\n" "static bool GetAnyFieldDescriptors(\n" " const ::$proto_ns$::Message& message,\n" @@ -1588,7 +1535,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "!std::is_convertible<T, const ::$proto_ns$::Message&>" "::value>::type>\n" "bool PackFrom(const T& message) {\n" - " return _any_metadata_.PackFrom<T>(GetArena(), message);\n" + " return $any_metadata$.PackFrom<T>(GetArena(), message);\n" "}\n" "template <typename T, class = typename std::enable_if<" "!std::is_convertible<T, const ::$proto_ns$::Message&>" @@ -1596,36 +1543,36 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "bool PackFrom(const T& message,\n" " ::PROTOBUF_NAMESPACE_ID::ConstStringParam " "type_url_prefix) {\n" - " return _any_metadata_.PackFrom<T>(GetArena(), message, " + " return $any_metadata$.PackFrom<T>(GetArena(), message, " "type_url_prefix);" "}\n" "template <typename T, class = typename std::enable_if<" "!std::is_convertible<T, const ::$proto_ns$::Message&>" "::value>::type>\n" "bool UnpackTo(T* message) const {\n" - " return _any_metadata_.UnpackTo<T>(message);\n" + " return $any_metadata$.UnpackTo<T>(message);\n" "}\n"); } else { format( "template <typename T>\n" "bool PackFrom(const T& message) {\n" - " return _any_metadata_.PackFrom(GetArena(), message);\n" + " return $any_metadata$.PackFrom(GetArena(), message);\n" "}\n" "template <typename T>\n" "bool PackFrom(const T& message,\n" " ::PROTOBUF_NAMESPACE_ID::ConstStringParam " "type_url_prefix) {\n" - " return _any_metadata_.PackFrom(GetArena(), message, " + " return $any_metadata$.PackFrom(GetArena(), message, " "type_url_prefix);\n" "}\n" "template <typename T>\n" "bool UnpackTo(T* message) const {\n" - " return _any_metadata_.UnpackTo(message);\n" + " return $any_metadata$.UnpackTo(message);\n" "}\n"); } format( "template<typename T> bool Is() const {\n" - " return _any_metadata_.Is<T>();\n" + " return $any_metadata$.Is<T>();\n" "}\n" "static bool ParseAnyTypeUrl(::PROTOBUF_NAMESPACE_ID::ConstStringParam " "type_url,\n" @@ -1677,27 +1624,28 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { // argument is a generic Message instance, and only define the // custom MergeFrom and CopyFrom instances when the source of the // merge/copy is known to be the same class as the destination. - // TODO(jorg): Define MergeFrom in terms of MergeImpl, rather than - // the other way around, to save even more code size. "using $superclass$::CopyFrom;\n" "void CopyFrom(const $classname$& from);\n" "" "using $superclass$::MergeFrom;\n" - "void MergeFrom(const $classname$& from);\n" + "void MergeFrom(" + " const $classname$& from) {\n" + " $classname$::MergeImpl(*this, from);\n" + "}\n" "private:\n" - "static void MergeImpl(::$proto_ns$::Message* to, const " - "::$proto_ns$::Message& from);\n" + "static void MergeImpl(::$proto_ns$::Message& to_msg, const " + "::$proto_ns$::Message& from_msg);\n" "public:\n"); } else { format( "using $superclass$::CopyFrom;\n" "inline void CopyFrom(const $classname$& from) {\n" - " $superclass$::CopyImpl(this, from);\n" + " $superclass$::CopyImpl(*this, from);\n" "}\n" "" "using $superclass$::MergeFrom;\n" "void MergeFrom(const $classname$& from) {\n" - " $superclass$::MergeImpl(this, from);\n" + " $superclass$::MergeImpl(*this, from);\n" "}\n" "public:\n"); } @@ -1732,9 +1680,10 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { if (!HasSimpleBaseClass(descriptor_, options_)) { format( - "int GetCachedSize() const final { return _cached_size_.Get(); }" + "int GetCachedSize() const final { return " + "$cached_size$.Get(); }" "\n\nprivate:\n" - "void SharedCtor();\n" + "void SharedCtor(::$proto_ns$::Arena* arena, bool is_message_owned);\n" "void SharedDtor();\n" "void SetCachedSize(int size) const$ full_final$;\n" "void InternalSwap($classname$* other);\n"); @@ -1756,13 +1705,32 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { // we rely on. "protected:\n" "explicit $classname$(::$proto_ns$::Arena* arena,\n" - " bool is_message_owned = false);\n" - "private:\n"); + " bool is_message_owned = false);\n"); - if (!HasSimpleBaseClass(descriptor_, options_)) { - format( - "static void ArenaDtor(void* object);\n" - "inline void RegisterArenaDtor(::$proto_ns$::Arena* arena);\n"); + switch (NeedsArenaDestructor()) { + case ArenaDtorNeeds::kOnDemand: + format( + "private:\n" + "static void ArenaDtor(void* object);\n" + "inline void OnDemandRegisterArenaDtor(::$proto_ns$::Arena* arena) " + "override {\n" + " if (arena == nullptr || ($inlined_string_donated_array$[0] & " + "0x1u) " + "== " + "0) {\n" + " return;\n" + " }\n" + " $inlined_string_donated_array$[0] &= 0xFFFFFFFEu;\n" + " arena->OwnCustomDestructor(this, &$classname$::ArenaDtor);\n" + "}\n"); + break; + case ArenaDtorNeeds::kRequired: + format( + "private:\n" + "static void ArenaDtor(void* object);\n"); + break; + case ArenaDtorNeeds::kNone: + break; } format( @@ -1786,6 +1754,17 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "\n"); } + if (ShouldSplit(descriptor_, options_)) { + format( + "private:\n" + "inline bool IsSplitMessageDefault() const {\n" + " return $split$ == reinterpret_cast<Impl_::Split*>(&$1$);\n" + "}\n" + "PROTOBUF_NOINLINE void PrepareSplitMessageForWrite();\n" + "public:\n", + DefaultInstanceName(descriptor_, options_, /*split=*/true)); + } + format( "// nested types ----------------------------------------------------\n" "\n"); @@ -1866,7 +1845,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { // Prepare decls for _cached_size_ and _has_bits_. Their position in the // output will be determined later. - bool need_to_emit_cached_size = true; + bool need_to_emit_cached_size = !HasSimpleBaseClass(descriptor_, options_); const std::string cached_size_decl = "mutable ::$proto_ns$::internal::CachedSize _cached_size_;\n"; @@ -1876,12 +1855,21 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { : StrCat("::$proto_ns$::internal::HasBits<", sizeof_has_bits, "> _has_bits_;\n"); + format( + "template <typename T> friend class " + "::$proto_ns$::Arena::InternalHelper;\n" + "typedef void InternalArenaConstructable_;\n" + "typedef void DestructorSkippable_;\n"); + // To minimize padding, data members are divided into three sections: // (1) members assumed to align to 8 bytes // (2) members corresponding to message fields, re-ordered to optimize // alignment. // (3) members assumed to align to 4 bytes. + format("struct Impl_ {\n"); + format.Indent(); + // Members assumed to align to 8 bytes: if (descriptor_->extension_range_count() > 0) { @@ -1890,9 +1878,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "\n"); } - if (options_.field_listener_options.inject_field_listener_events && - descriptor_->file()->options().optimize_for() != - google::protobuf::FileOptions::LITE_RUNTIME) { + if (HasTracker(descriptor_, options_)) { format("static ::$proto_ns$::AccessListener<$1$> _tracker_;\n", ClassName(descriptor_)); } @@ -1905,20 +1891,16 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { InlinedStringDonatedSize()); } - format( - "template <typename T> friend class " - "::$proto_ns$::Arena::InternalHelper;\n" - "typedef void InternalArenaConstructable_;\n" - "typedef void DestructorSkippable_;\n"); - if (!has_bit_indices_.empty()) { // _has_bits_ is frequently accessed, so to reduce code size and improve // speed, it should be close to the start of the object. Placing // _cached_size_ together with _has_bits_ improves cache locality despite // potential alignment padding. format(has_bits_decl.c_str()); - format(cached_size_decl.c_str()); - need_to_emit_cached_size = false; + if (need_to_emit_cached_size) { + format(cached_size_decl.c_str()); + need_to_emit_cached_size = false; + } } // Field members: @@ -1927,7 +1909,24 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { for (auto field : optimized_order_) { const FieldGenerator& generator = field_generators_.get(field); generator.GenerateStaticMembers(printer); - generator.GeneratePrivateMembers(printer); + if (!ShouldSplit(field, options_)) { + generator.GeneratePrivateMembers(printer); + } + } + if (ShouldSplit(descriptor_, options_)) { + format("struct Split {\n"); + format.Indent(); + for (auto field : optimized_order_) { + if (!ShouldSplit(field, options_)) continue; + const FieldGenerator& generator = field_generators_.get(field); + generator.GeneratePrivateMembers(printer); + } + format.Outdent(); + format( + " typedef void InternalArenaConstructable_;\n" + " typedef void DestructorSkippable_;\n" + "};\n" + "Split* _split_;\n"); } // For each oneof generate a union @@ -1978,6 +1977,22 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format("::$proto_ns$::internal::AnyMetadata _any_metadata_;\n"); } + format.Outdent(); + format("};\n"); + + // Only create the _impl_ field if it contains data. + if (HasImplData(descriptor_, options_)) { + format("union { Impl_ _impl_; };\n"); + } + + if (ShouldSplit(descriptor_, options_)) { + format( + "static Impl_::Split* CreateSplitMessage(" + "::$proto_ns$::Arena* arena);\n"); + format("friend struct $1$;\n", + DefaultInstanceType(descriptor_, options_, /*split=*/true)); + } + // The TableStruct struct needs access to the private parts, in order to // construct the offsets of all members. format("friend struct ::$tablename$;\n"); @@ -2001,73 +2016,12 @@ void MessageGenerator::GenerateInlineMethods(io::Printer* printer) { "inline $classname$::$camel_oneof_name$Case $classname$::" "${1$$oneof_name$_case$}$() const {\n" " return $classname$::$camel_oneof_name$Case(" - "_oneof_case_[$oneof_index$]);\n" + "$oneof_case$[$oneof_index$]);\n" "}\n", oneof); } } -bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset, - size_t aux_offset) { - Formatter format(printer, variables_); - - if (!table_driven_) { - format("{ nullptr, nullptr, 0, -1, -1, -1, -1, nullptr, false },\n"); - return false; - } - - int max_field_number = 0; - for (auto field : FieldRange(descriptor_)) { - if (max_field_number < field->number()) { - max_field_number = field->number(); - } - } - - format("{\n"); - format.Indent(); - - format( - "$tablename$::entries + $1$,\n" - "$tablename$::aux + $2$,\n" - "$3$,\n", - offset, aux_offset, max_field_number); - - if (has_bit_indices_.empty()) { - // If no fields have hasbits, then _has_bits_ does not exist. - format("-1,\n"); - } else { - format("PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_),\n"); - } - - if (descriptor_->real_oneof_decl_count() > 0) { - format("PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_),\n"); - } else { - format("-1, // no _oneof_case_\n"); - } - - if (descriptor_->extension_range_count() > 0) { - format("PROTOBUF_FIELD_OFFSET($classtype$, _extensions_),\n"); - } else { - format("-1, // no _extensions_\n"); - } - - // TODO(ckennelly): Consolidate this with the calculation for - // AuxiliaryParseTableField. - format( - "PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_),\n" - "&$package_ns$::_$classname$_default_instance_,\n"); - - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - format("true,\n"); - } else { - format("false,\n"); - } - - format.Outdent(); - format("},\n"); - return true; -} - void MessageGenerator::GenerateSchema(io::Printer* printer, int offset, int has_offset) { Formatter format(printer, variables_); @@ -2087,218 +2041,6 @@ void MessageGenerator::GenerateSchema(io::Printer* printer, int offset, inlined_string_indices_offset); } -namespace { - -// We need to calculate for each field what function the table driven code -// should use to serialize it. This returns the index in a lookup table. -uint32_t CalcFieldNum(const FieldGenerator& generator, - const FieldDescriptor* field, const Options& options) { - bool is_a_map = IsMapEntryMessage(field->containing_type()); - int type = field->type(); - if (type == FieldDescriptor::TYPE_STRING || - type == FieldDescriptor::TYPE_BYTES) { - // string field - if (generator.IsInlined()) { - type = internal::FieldMetadata::kInlinedType; - } else if (IsCord(field, options)) { - type = internal::FieldMetadata::kCordType; - } else if (IsStringPiece(field, options)) { - type = internal::FieldMetadata::kStringPieceType; - } - } - - if (field->real_containing_oneof()) { - return internal::FieldMetadata::CalculateType( - type, internal::FieldMetadata::kOneOf); - } else if (field->is_packed()) { - return internal::FieldMetadata::CalculateType( - type, internal::FieldMetadata::kPacked); - } else if (field->is_repeated()) { - return internal::FieldMetadata::CalculateType( - type, internal::FieldMetadata::kRepeated); - } else if (HasHasbit(field) || field->real_containing_oneof() || is_a_map) { - return internal::FieldMetadata::CalculateType( - type, internal::FieldMetadata::kPresence); - } else { - return internal::FieldMetadata::CalculateType( - type, internal::FieldMetadata::kNoPresence); - } -} - -int FindMessageIndexInFile(const Descriptor* descriptor) { - std::vector<const Descriptor*> flatten = - FlattenMessagesInFile(descriptor->file()); - return std::find(flatten.begin(), flatten.end(), descriptor) - - flatten.begin(); -} - -} // namespace - -int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { - Formatter format(printer, variables_); - if (!options_.table_driven_serialization) { - return 0; - } - - std::vector<const FieldDescriptor*> sorted = SortFieldsByNumber(descriptor_); - if (IsMapEntryMessage(descriptor_)) { - for (int i = 0; i < 2; i++) { - const FieldDescriptor* field = sorted[i]; - const FieldGenerator& generator = field_generators_.get(field); - - uint32_t tag = internal::WireFormatLite::MakeTag( - field->number(), WireFormat::WireTypeForFieldType(field->type())); - - std::map<std::string, std::string> vars; - vars["classtype"] = QualifiedClassName(descriptor_, options_); - vars["field_name"] = FieldName(field); - vars["tag"] = StrCat(tag); - vars["hasbit"] = StrCat(i); - vars["type"] = StrCat(CalcFieldNum(generator, field, options_)); - vars["ptr"] = "nullptr"; - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - GOOGLE_CHECK(!IsMapEntryMessage(field->message_type())); - vars["ptr"] = - "::" + UniqueName("TableStruct", field->message_type(), options_) + - "::serialization_table + " + - StrCat(FindMessageIndexInFile(field->message_type())); - } - Formatter::SaveState saver(&format); - format.AddMap(vars); - format( - "{PROTOBUF_FIELD_OFFSET(" - "::$proto_ns$::internal::MapEntryHelper<$classtype$::" - "SuperType>, $field_name$_), $tag$," - "PROTOBUF_FIELD_OFFSET(" - "::$proto_ns$::internal::MapEntryHelper<$classtype$::" - "SuperType>, _has_bits_) * 8 + $hasbit$, $type$, " - "$ptr$},\n"); - } - return 2; - } - format( - "{PROTOBUF_FIELD_OFFSET($classtype$, _cached_size_)," - " 0, 0, 0, nullptr},\n"); - std::vector<const Descriptor::ExtensionRange*> sorted_extensions; - sorted_extensions.reserve(descriptor_->extension_range_count()); - for (int i = 0; i < descriptor_->extension_range_count(); ++i) { - sorted_extensions.push_back(descriptor_->extension_range(i)); - } - std::sort(sorted_extensions.begin(), sorted_extensions.end(), - ExtensionRangeSorter()); - for (int i = 0, extension_idx = 0; /* no range */; i++) { - for (; extension_idx < sorted_extensions.size() && - (i == sorted.size() || - sorted_extensions[extension_idx]->start < sorted[i]->number()); - extension_idx++) { - const Descriptor::ExtensionRange* range = - sorted_extensions[extension_idx]; - format( - "{PROTOBUF_FIELD_OFFSET($classtype$, _extensions_), " - "$1$, $2$, ::$proto_ns$::internal::FieldMetadata::kSpecial, " - "reinterpret_cast<const " - "void*>(::$proto_ns$::internal::ExtensionSerializer)},\n", - range->start, range->end); - } - if (i == sorted.size()) break; - const FieldDescriptor* field = sorted[i]; - - uint32_t tag = internal::WireFormatLite::MakeTag( - field->number(), WireFormat::WireTypeForFieldType(field->type())); - if (field->is_packed()) { - tag = internal::WireFormatLite::MakeTag( - field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - } - - std::string classfieldname = FieldName(field); - if (field->real_containing_oneof()) { - classfieldname = field->containing_oneof()->name(); - } - format.Set("field_name", classfieldname); - std::string ptr = "nullptr"; - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - if (IsMapEntryMessage(field->message_type())) { - format( - "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), $1$, $2$, " - "::$proto_ns$::internal::FieldMetadata::kSpecial, " - "reinterpret_cast<const void*>(static_cast< " - "::$proto_ns$::internal::SpecialSerializer>(" - "::$proto_ns$::internal::MapFieldSerializer< " - "::$proto_ns$::internal::MapEntryToMapField<" - "$3$>::MapFieldType, " - "$tablename$::serialization_table>))},\n", - tag, FindMessageIndexInFile(field->message_type()), - QualifiedClassName(field->message_type(), options_)); - continue; - } else if (!field->message_type()->options().message_set_wire_format()) { - // message_set doesn't have the usual table and we need to - // dispatch to generated serializer, hence ptr stays zero. - ptr = - "::" + UniqueName("TableStruct", field->message_type(), options_) + - "::serialization_table + " + - StrCat(FindMessageIndexInFile(field->message_type())); - } - } - - const FieldGenerator& generator = field_generators_.get(field); - int type = CalcFieldNum(generator, field, options_); - - if (IsLazy(field, options_, scc_analyzer_)) { - type = internal::FieldMetadata::kSpecial; - ptr = "reinterpret_cast<const void*>(::" + variables_["proto_ns"] + - "::internal::LazyFieldSerializer"; - if (field->real_containing_oneof()) { - ptr += "OneOf"; - } else if (!HasHasbit(field)) { - ptr += "NoPresence"; - } - ptr += ")"; - } - - if (field->options().weak()) { - // TODO(gerbens) merge weak fields into ranges - format( - "{PROTOBUF_FIELD_OFFSET(" - "$classtype$, _weak_field_map_), $1$, $1$, " - "::$proto_ns$::internal::FieldMetadata::kSpecial, " - "reinterpret_cast<const " - "void*>(::$proto_ns$::internal::WeakFieldSerializer)},\n", - tag); - } else if (field->real_containing_oneof()) { - format.Set("oneofoffset", - sizeof(uint32_t) * field->containing_oneof()->index()); - format( - "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), $1$," - " PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_) + " - "$oneofoffset$, $2$, $3$},\n", - tag, type, ptr); - } else if (HasHasbit(field)) { - format.Set("hasbitsoffset", has_bit_indices_[field->index()]); - format( - "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), " - "$1$, PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_) * 8 + " - "$hasbitsoffset$, $2$, $3$},\n", - tag, type, ptr); - } else { - format( - "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), " - "$1$, ~0u, $2$, $3$},\n", - tag, type, ptr); - } - } - int num_field_metadata = 1 + sorted.size() + sorted_extensions.size(); - num_field_metadata++; - std::string serializer = UseUnknownFieldSet(descriptor_->file(), options_) - ? "UnknownFieldSetSerializer" - : "UnknownFieldSerializerLite"; - format( - "{PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_), 0, ~0u, " - "::$proto_ns$::internal::FieldMetadata::kSpecial, reinterpret_cast<const " - "void*>(::$proto_ns$::internal::$1$)},\n", - serializer); - return num_field_metadata; -} - void MessageGenerator::GenerateClassMethods(io::Printer* printer) { Formatter format(printer, variables_); if (IsMapEntryMessage(descriptor_)) { @@ -2314,7 +2056,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { format( "::$proto_ns$::Metadata $classname$::GetMetadata() const {\n" "$annotate_reflection$" - " return ::$proto_ns$::internal::AssignDescriptors(\n" + " return ::_pbi::AssignDescriptors(\n" " &$desc_table$_getter, &$desc_table$_once,\n" " $file_level_metadata$[$1$]);\n" "}\n", @@ -2322,7 +2064,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { } else { format( "::$proto_ns$::Metadata $classname$::GetMetadata() const {\n" - " return ::$proto_ns$::internal::AssignDescriptors(\n" + " return ::_pbi::AssignDescriptors(\n" " &$desc_table$_getter, &$desc_table$_once,\n" " $file_level_metadata$[$1$]);\n" "}\n", @@ -2339,7 +2081,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { " const ::$proto_ns$::Message& message,\n" " const ::$proto_ns$::FieldDescriptor** type_url_field,\n" " const ::$proto_ns$::FieldDescriptor** value_field) {\n" - " return ::$proto_ns$::internal::GetAnyFieldDescriptors(\n" + " return ::_pbi::GetAnyFieldDescriptors(\n" " message, type_url_field, value_field);\n" "}\n"); } @@ -2347,8 +2089,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { "bool $classname$::ParseAnyTypeUrl(\n" " ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,\n" " std::string* full_type_name) {\n" - " return ::$proto_ns$::internal::ParseAnyTypeUrl(type_url,\n" - " full_type_name);\n" + " return ::_pbi::ParseAnyTypeUrl(type_url, full_type_name);\n" "}\n" "\n"); } @@ -2359,7 +2100,8 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { format.Indent(); if (!has_bit_indices_.empty()) { format( - "using HasBits = decltype(std::declval<$classname$>()._has_bits_);\n"); + "using HasBits = " + "decltype(std::declval<$classname$>().$has_bits$);\n"); } for (auto field : FieldRange(descriptor_)) { field_generators_.get(field).GenerateInternalAccessorDeclarations(printer); @@ -2390,7 +2132,8 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { format("};\n\n"); for (auto field : FieldRange(descriptor_)) { if (!IsFieldStripped(field, options_)) { - field_generators_.get(field).GenerateInternalAccessorDefinitions(printer); + field_generators_.get(field).GenerateInternalAccessorDefinitions( + printer); } } @@ -2440,7 +2183,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { GenerateMergeFrom(printer); format("\n"); - GenerateClassSpecificMergeFrom(printer); + GenerateClassSpecificMergeImpl(printer); format("\n"); GenerateCopyFrom(printer); @@ -2450,25 +2193,26 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { format("\n"); } + if (ShouldSplit(descriptor_, options_)) { + format( + "void $classname$::PrepareSplitMessageForWrite() {\n" + " if (IsSplitMessageDefault()) {\n" + " $split$ = CreateSplitMessage(GetArenaForAllocation());\n" + " }\n" + "}\n"); + } + GenerateVerify(printer); GenerateSwap(printer); format("\n"); - if (options_.table_driven_serialization) { - format( - "const void* $classname$::InternalGetTable() const {\n" - " return ::$tablename$::serialization_table + $1$;\n" - "}\n" - "\n", - index_in_file_messages_); - } if (HasDescriptorMethods(descriptor_->file(), options_)) { if (!descriptor_->options().map_entry()) { format( "::$proto_ns$::Metadata $classname$::GetMetadata() const {\n" "$annotate_reflection$" - " return ::$proto_ns$::internal::AssignDescriptors(\n" + " return ::_pbi::AssignDescriptors(\n" " &$desc_table$_getter, &$desc_table$_once,\n" " $file_level_metadata$[$1$]);\n" "}\n", @@ -2476,7 +2220,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { } else { format( "::$proto_ns$::Metadata $classname$::GetMetadata() const {\n" - " return ::$proto_ns$::internal::AssignDescriptors(\n" + " return ::_pbi::AssignDescriptors(\n" " &$desc_table$_getter, &$desc_table$_once,\n" " $file_level_metadata$[$1$]);\n" "}\n", @@ -2490,239 +2234,43 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { "\n"); } - if (options_.field_listener_options.inject_field_listener_events && - descriptor_->file()->options().optimize_for() != - google::protobuf::FileOptions::LITE_RUNTIME) { + if (HasTracker(descriptor_, options_)) { format( "::$proto_ns$::AccessListener<$classtype$> " - "$1$::_tracker_(&FullMessageName);\n", + "$1$::$tracker$(&FullMessageName);\n", ClassName(descriptor_)); } } -size_t MessageGenerator::GenerateParseOffsets(io::Printer* printer) { - Formatter format(printer, variables_); - - if (!table_driven_) { - return 0; - } - - // Field "0" is special: We use it in our switch statement of processing - // types to handle the successful end tag case. - format("{0, 0, 0, ::$proto_ns$::internal::kInvalidMask, 0, 0},\n"); - int last_field_number = 1; - - std::vector<const FieldDescriptor*> ordered_fields = - SortFieldsByNumber(descriptor_); - - for (auto field : ordered_fields) { - Formatter::SaveState saver(&format); - GOOGLE_CHECK_GE(field->number(), last_field_number); - - for (; last_field_number < field->number(); last_field_number++) { - format( - "{ 0, 0, ::$proto_ns$::internal::kInvalidMask,\n" - " ::$proto_ns$::internal::kInvalidMask, 0, 0 },\n"); - } - last_field_number++; - - unsigned char normal_wiretype, packed_wiretype, processing_type; - normal_wiretype = WireFormat::WireTypeForFieldType(field->type()); - - if (field->is_packable()) { - packed_wiretype = WireFormatLite::WIRETYPE_LENGTH_DELIMITED; - } else { - packed_wiretype = internal::kNotPackedMask; - } - - processing_type = static_cast<unsigned>(field->type()); - const FieldGenerator& generator = field_generators_.get(field); - if (field->type() == FieldDescriptor::TYPE_STRING) { - switch (EffectiveStringCType(field, options_)) { - case FieldOptions::STRING: - if (generator.IsInlined()) { - processing_type = internal::TYPE_STRING_INLINED; - } - break; - case FieldOptions::CORD: - processing_type = internal::TYPE_STRING_CORD; - break; - case FieldOptions::STRING_PIECE: - processing_type = internal::TYPE_STRING_STRING_PIECE; - break; - } - } else if (field->type() == FieldDescriptor::TYPE_BYTES) { - switch (EffectiveStringCType(field, options_)) { - case FieldOptions::STRING: - if (generator.IsInlined()) { - processing_type = internal::TYPE_BYTES_INLINED; - } - break; - case FieldOptions::CORD: - processing_type = internal::TYPE_BYTES_CORD; - break; - case FieldOptions::STRING_PIECE: - processing_type = internal::TYPE_BYTES_STRING_PIECE; - break; - } - } - - processing_type |= static_cast<unsigned>( - field->is_repeated() ? internal::kRepeatedMask : 0); - processing_type |= static_cast<unsigned>( - field->real_containing_oneof() ? internal::kOneofMask : 0); - - if (field->is_map()) { - processing_type = internal::TYPE_MAP; - } - - const unsigned char tag_size = - WireFormat::TagSize(field->number(), field->type()); - - std::map<std::string, std::string> vars; - if (field->real_containing_oneof()) { - vars["name"] = field->containing_oneof()->name(); - vars["presence"] = StrCat(field->containing_oneof()->index()); - } else { - vars["name"] = FieldName(field); - vars["presence"] = StrCat(has_bit_indices_[field->index()]); - } - vars["nwtype"] = StrCat(normal_wiretype); - vars["pwtype"] = StrCat(packed_wiretype); - vars["ptype"] = StrCat(processing_type); - vars["tag_size"] = StrCat(tag_size); - - format.AddMap(vars); - - format( - "{\n" - " PROTOBUF_FIELD_OFFSET($classtype$, $name$_),\n" - " static_cast<$uint32$>($presence$),\n" - " $nwtype$, $pwtype$, $ptype$, $tag_size$\n" - "},\n"); - } - - return last_field_number; -} - -size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) { - Formatter format(printer, variables_); - - if (!table_driven_) { - return 0; - } - - std::vector<const FieldDescriptor*> ordered_fields = - SortFieldsByNumber(descriptor_); - - format("::$proto_ns$::internal::AuxiliaryParseTableField(),\n"); - int last_field_number = 1; - for (auto field : ordered_fields) { - Formatter::SaveState saver(&format); - - GOOGLE_CHECK_GE(field->number(), last_field_number); - for (; last_field_number < field->number(); last_field_number++) { - format("::$proto_ns$::internal::AuxiliaryParseTableField(),\n"); - } - - std::map<std::string, std::string> vars; - SetCommonFieldVariables(field, &vars, options_); - format.AddMap(vars); - - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_ENUM: - if (HasPreservingUnknownEnumSemantics(field)) { - format( - "{::$proto_ns$::internal::AuxiliaryParseTableField::enum_aux{" - "nullptr}},\n"); - } else { - format( - "{::$proto_ns$::internal::AuxiliaryParseTableField::enum_aux{" - "$1$_IsValid}},\n", - ClassName(field->enum_type(), true)); - } - last_field_number++; - break; - case FieldDescriptor::CPPTYPE_MESSAGE: { - if (field->is_map()) { - format( - "{::$proto_ns$::internal::AuxiliaryParseTableField::map_" - "aux{&::$proto_ns$::internal::ParseMap<$1$>}},\n", - QualifiedClassName(field->message_type(), options_)); - last_field_number++; - break; - } - format.Set("field_classname", ClassName(field->message_type(), false)); - format.Set("default_instance", QualifiedDefaultInstanceName( - field->message_type(), options_)); - - format( - "{::$proto_ns$::internal::AuxiliaryParseTableField::message_aux{\n" - " &$default_instance$}},\n"); - last_field_number++; - break; - } - case FieldDescriptor::CPPTYPE_STRING: { - std::string default_val; - switch (EffectiveStringCType(field, options_)) { - case FieldOptions::STRING: - default_val = field->default_value_string().empty() - ? "&::" + variables_["proto_ns"] + - "::internal::fixed_address_empty_string" - : "&" + - QualifiedClassName(descriptor_, options_) + - "::" + MakeDefaultName(field); - break; - case FieldOptions::CORD: - case FieldOptions::STRING_PIECE: - default_val = - "\"" + CEscape(field->default_value_string()) + "\""; - break; - } - format( - "{::$proto_ns$::internal::AuxiliaryParseTableField::string_aux{\n" - " $1$,\n" - " \"$2$\"\n" - "}},\n", - default_val, field->full_name()); - last_field_number++; - break; - } - default: - break; - } - } - - return last_field_number; -} - std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( io::Printer* printer) { Formatter format(printer, variables_); if (!has_bit_indices_.empty() || IsMapEntryMessage(descriptor_)) { - format("PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_),\n"); + format("PROTOBUF_FIELD_OFFSET($classtype$, $has_bits$),\n"); } else { format("~0u, // no _has_bits_\n"); } format("PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_),\n"); if (descriptor_->extension_range_count() > 0) { - format("PROTOBUF_FIELD_OFFSET($classtype$, _extensions_),\n"); + format("PROTOBUF_FIELD_OFFSET($classtype$, $extensions$),\n"); } else { format("~0u, // no _extensions_\n"); } if (descriptor_->real_oneof_decl_count() > 0) { - format("PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_[0]),\n"); + format("PROTOBUF_FIELD_OFFSET($classtype$, $oneof_case$[0]),\n"); } else { format("~0u, // no _oneof_case_\n"); } if (num_weak_fields_ > 0) { - format("PROTOBUF_FIELD_OFFSET($classtype$, _weak_field_map_),\n"); + format("PROTOBUF_FIELD_OFFSET($classtype$, $weak_field_map$),\n"); } else { format("~0u, // no _weak_field_map_\n"); } if (!inlined_string_indices_.empty()) { - format("PROTOBUF_FIELD_OFFSET($classtype$, _inlined_string_donated_),\n"); + format( + "PROTOBUF_FIELD_OFFSET($classtype$, " + "$inlined_string_donated_array$),\n"); } else { format("~0u, // no _inlined_string_donated_\n"); } @@ -2740,9 +2288,13 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( if (field->options().weak() || field->real_containing_oneof()) { // Mark the field to prevent unintentional access through reflection. // Don't use the top bit because that is for unused fields. - format("::$proto_ns$::internal::kInvalidFieldOffsetTag"); + format("::_pbi::kInvalidFieldOffsetTag"); } else { - format("PROTOBUF_FIELD_OFFSET($classtype$, $1$_)", FieldName(field)); + format("PROTOBUF_FIELD_OFFSET($classtype$$1$, $2$)", + ShouldSplit(field, options_) ? "::Impl_::Split" : "", + ShouldSplit(field, options_) + ? FieldName(field) + "_" + : FieldMemberName(field, /*cold=*/false)); } // Some information about a field is in the pdproto profile. The profile is @@ -2750,11 +2302,6 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( // offset of the field, so that the information is available when // reflectively accessing the field at run time. // - // Embed whether the field is used to the MSB of the offset. - if (!IsFieldUsed(field, options_)) { - format(" | 0x80000000u // unused\n"); - } - // Embed whether the field is eagerly verified lazy or inlined string to the // LSB of the offset. if (IsEagerlyVerifiedLazy(field, options_, scc_analyzer_)) { @@ -2767,7 +2314,7 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( int count = 0; for (auto oneof : OneOfRange(descriptor_)) { - format("PROTOBUF_FIELD_OFFSET($classtype$, $1$_),\n", oneof->name()); + format("PROTOBUF_FIELD_OFFSET($classtype$, _impl_.$1$_),\n", oneof->name()); count++; } GOOGLE_CHECK_EQ(count, descriptor_->real_oneof_decl_count()); @@ -2787,11 +2334,12 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( } if (!inlined_string_indices_.empty()) { entries += inlined_string_indices_.size(); - for (int inlined_string_indice : inlined_string_indices_) { - const std::string index = inlined_string_indice >= 0 - ? StrCat(inlined_string_indice) - : "~0u"; - format("$1$,\n", index); + for (int inlined_string_index : inlined_string_indices_) { + const std::string index = + inlined_string_index >= 0 + ? StrCat(inlined_string_index, ", // inlined_string_index") + : "~0u,"; + format("$1$\n", index); } } @@ -2802,18 +2350,181 @@ void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) { if (HasSimpleBaseClass(descriptor_, options_)) return; Formatter format(printer, variables_); - format("inline void $classname$::SharedCtor() {\n"); + format( + "inline void $classname$::SharedCtor(\n" + " ::_pb::Arena* arena, bool is_message_owned) {\n" + " (void)arena;\n" + " (void)is_message_owned;\n"); - std::vector<bool> processed(optimized_order_.size(), false); - GenerateConstructorBody(printer, processed, false); + format.Indent(); + // Impl_ _impl_. + format("new (&_impl_) Impl_{"); + format.Indent(); + const char* field_sep = " "; + const auto put_sep = [&] { + format("\n$1$ ", field_sep); + field_sep = ","; + }; + + // Note: any fields without move/copy constructors can't be explicitly + // aggregate initialized pre-C++17. + if (descriptor_->extension_range_count() > 0) { + put_sep(); + format("/*decltype($extensions$)*/{::_pbi::ArenaInitialized(), arena}"); + } + if (!inlined_string_indices_.empty()) { + put_sep(); + format("decltype($inlined_string_donated_array$){}"); + } + bool need_to_emit_cached_size = !HasSimpleBaseClass(descriptor_, options_); + if (!has_bit_indices_.empty()) { + put_sep(); + format("decltype($has_bits$){}"); + if (need_to_emit_cached_size) { + put_sep(); + format("/*decltype($cached_size$)*/{}"); + need_to_emit_cached_size = false; + } + } + + // Initialize member variables with arena constructor. + for (auto field : optimized_order_) { + GOOGLE_DCHECK(!IsFieldStripped(field, options_)); + if (ShouldSplit(field, options_)) { + continue; + } + put_sep(); + field_generators_.get(field).GenerateAggregateInitializer(printer); + } + if (ShouldSplit(descriptor_, options_)) { + put_sep(); + format("decltype($split$){reinterpret_cast<Impl_::Split*>(&$1$)}", + DefaultInstanceName(descriptor_, options_, /*split=*/true)); + } + for (auto oneof : OneOfRange(descriptor_)) { + put_sep(); + format("decltype(_impl_.$1$_){}", oneof->name()); + } + + if (need_to_emit_cached_size) { + put_sep(); + format("/*decltype($cached_size$)*/{}"); + } + + if (descriptor_->real_oneof_decl_count() != 0) { + put_sep(); + format("/*decltype($oneof_case$)*/{}"); + } + if (num_weak_fields_ > 0) { + put_sep(); + format("decltype($weak_field_map$){arena}"); + } + if (IsAnyMessage(descriptor_, options_)) { + put_sep(); + // AnyMetadata has no move constructor. + format("/*decltype($any_metadata$)*/{&_impl_.type_url_, &_impl_.value_}"); + } + + format.Outdent(); + format("\n};\n"); + + if (!inlined_string_indices_.empty()) { + // Donate inline string fields. + format.Indent(); + // The last bit is the tracking bit for registering ArenaDtor. The bit is 1 + // means ArenaDtor is not registered on construction, and on demand register + // is needed. + format("if (arena != nullptr) {\n"); + if (NeedsArenaDestructor() == ArenaDtorNeeds::kOnDemand) { + format( + " if (!is_message_owned) {\n" + " $inlined_string_donated_array$[0] = ~0u;\n" + " } else {\n" + // We should not register ArenaDtor for MOA. + " $inlined_string_donated_array$[0] = 0xFFFFFFFEu;\n" + " }\n"); + } else { + format(" $inlined_string_donated_array$[0] = 0xFFFFFFFEu;\n"); + } + for (size_t i = 1; i < InlinedStringDonatedSize(); ++i) { + format(" $inlined_string_donated_array$[$1$] = ~0u;\n", i); + } + format("}\n"); + format.Outdent(); + } + + for (const FieldDescriptor* field : optimized_order_) { + if (ShouldSplit(field, options_)) { + continue; + } + field_generators_.get(field).GenerateConstructorCode(printer); + } for (auto oneof : OneOfRange(descriptor_)) { format("clear_has_$1$();\n", oneof->name()); } + format.Outdent(); format("}\n\n"); } +void MessageGenerator::GenerateCreateSplitMessage(io::Printer* printer) { + Formatter format(printer, variables_); + format( + "$classname$::Impl_::Split* " + "$classname$::CreateSplitMessage(::$proto_ns$::Arena* arena) {\n"); + format.Indent(); + const char* field_sep = " "; + const auto put_sep = [&] { + format("\n$1$ ", field_sep); + field_sep = ","; + }; + format( + "const size_t size = sizeof(Impl_::Split);\n" + "void* chunk = (arena == nullptr) ?\n" + " ::operator new(size) :\n" + " arena->AllocateAligned(size, alignof(Impl_::Split));\n" + "Impl_::Split* ptr = reinterpret_cast<Impl_::Split*>(chunk);\n" + "new (ptr) Impl_::Split{"); + format.Indent(); + for (const FieldDescriptor* field : optimized_order_) { + GOOGLE_DCHECK(!IsFieldStripped(field, options_)); + if (ShouldSplit(field, options_)) { + put_sep(); + field_generators_.get(field).GenerateAggregateInitializer(printer); + } + } + format.Outdent(); + format("};\n"); + for (const FieldDescriptor* field : optimized_order_) { + GOOGLE_DCHECK(!IsFieldStripped(field, options_)); + if (ShouldSplit(field, options_)) { + field_generators_.get(field).GenerateCreateSplitMessageCode(printer); + } + } + format("return ptr;\n"); + format.Outdent(); + format("}\n"); +} + +void MessageGenerator::GenerateInitDefaultSplitInstance(io::Printer* printer) { + if (!ShouldSplit(descriptor_, options_)) return; + + Formatter format(printer, variables_); + const char* field_sep = " "; + const auto put_sep = [&] { + format("\n$1$ ", field_sep); + field_sep = ","; + }; + for (const auto* field : optimized_order_) { + if (ShouldSplit(field, options_)) { + put_sep(); + field_generators_.get(field).GenerateConstexprAggregateInitializer( + printer); + } + } +} + void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) { if (HasSimpleBaseClass(descriptor_, options_)) return; Formatter format(printer, variables_); @@ -2821,11 +2532,32 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) { format("inline void $classname$::SharedDtor() {\n"); format.Indent(); format("$DCHK$(GetArenaForAllocation() == nullptr);\n"); + + if (descriptor_->extension_range_count() > 0) { + format("$extensions$.~ExtensionSet();\n"); + } + // Write the destructors for each field except oneof members. // optimized_order_ does not contain oneof fields. for (auto field : optimized_order_) { + if (ShouldSplit(field, options_)) { + continue; + } field_generators_.get(field).GenerateDestructorCode(printer); } + if (ShouldSplit(descriptor_, options_)) { + format("if (!IsSplitMessageDefault()) {\n"); + format.Indent(); + format("auto* $cached_split_ptr$ = $split$;\n"); + for (auto field : optimized_order_) { + if (ShouldSplit(field, options_)) { + field_generators_.get(field).GenerateDestructorCode(printer); + } + } + format("delete $cached_split_ptr$;\n"); + format.Outdent(); + format("}\n"); + } // Generate code to destruct oneofs. Clearing should do the work. for (auto oneof : OneOfRange(descriptor_)) { @@ -2837,16 +2569,33 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) { } if (num_weak_fields_) { - format("_weak_field_map_.ClearAll();\n"); + format("$weak_field_map$.ClearAll();\n"); } + + if (IsAnyMessage(descriptor_, options_)) { + format("$any_metadata$.~AnyMetadata();\n"); + } + format.Outdent(); format( "}\n" "\n"); } +ArenaDtorNeeds MessageGenerator::NeedsArenaDestructor() const { + if (HasSimpleBaseClass(descriptor_, options_)) return ArenaDtorNeeds::kNone; + ArenaDtorNeeds needs = ArenaDtorNeeds::kNone; + for (const auto* field : FieldRange(descriptor_)) { + if (IsFieldStripped(field, options_)) continue; + needs = + std::max(needs, field_generators_.get(field).NeedsArenaDestructor()); + } + return needs; +} + void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) { - if (HasSimpleBaseClass(descriptor_, options_)) return; + GOOGLE_CHECK(NeedsArenaDestructor() > ArenaDtorNeeds::kNone); + Formatter format(printer, variables_); // Generate the ArenaDtor() method. Track whether any fields actually produced @@ -2858,119 +2607,155 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) { // since that simplifies Arena's destructor list (ordinary function pointers // rather than member function pointers). _this is the object being // destructed. - format( - "$classname$* _this = reinterpret_cast< $classname$* >(object);\n" - // avoid an "unused variable" warning in case no fields have dtor code. - "(void)_this;\n"); + format("$classname$* _this = reinterpret_cast< $classname$* >(object);\n"); - bool need_registration = false; // Process non-oneof fields first. for (auto field : optimized_order_) { - if (field_generators_.get(field).GenerateArenaDestructorCode(printer)) { - need_registration = true; + if (IsFieldStripped(field, options_) || ShouldSplit(field, options_)) + continue; + const FieldGenerator& fg = field_generators_.get(field); + fg.GenerateArenaDestructorCode(printer); + } + if (ShouldSplit(descriptor_, options_)) { + format("if (!_this->IsSplitMessageDefault()) {\n"); + format.Indent(); + for (auto field : optimized_order_) { + if (IsFieldStripped(field, options_) || !ShouldSplit(field, options_)) + continue; + const FieldGenerator& fg = field_generators_.get(field); + fg.GenerateArenaDestructorCode(printer); } + format.Outdent(); + format("}\n"); } // Process oneof fields. - // - // Note: As of 10/5/2016, GenerateArenaDestructorCode does not emit anything - // and returns false for oneof fields. for (auto oneof : OneOfRange(descriptor_)) { for (auto field : FieldRange(oneof)) { - if (!IsFieldStripped(field, options_) && - field_generators_.get(field).GenerateArenaDestructorCode(printer)) { - need_registration = true; - } + if (IsFieldStripped(field, options_)) continue; + field_generators_.get(field).GenerateArenaDestructorCode(printer); } } format.Outdent(); format("}\n"); - - if (need_registration) { - format( - "inline void $classname$::RegisterArenaDtor(::$proto_ns$::Arena* " - "arena) {\n" - " if (arena != nullptr) {\n" - " arena->OwnCustomDestructor(this, &$classname$::ArenaDtor);\n" - " }\n" - "}\n"); - } else { - format( - "void $classname$::RegisterArenaDtor(::$proto_ns$::Arena*) {\n" - "}\n"); - } } void MessageGenerator::GenerateConstexprConstructor(io::Printer* printer) { Formatter format(printer, variables_); + if (IsMapEntryMessage(descriptor_) || !HasImplData(descriptor_, options_)) { + format( + "PROTOBUF_CONSTEXPR $classname$::$classname$(\n" + " ::_pbi::ConstantInitialized) {}\n"); + return; + } + format( - "constexpr $classname$::$classname$(\n" - " ::$proto_ns$::internal::ConstantInitialized)"); + "PROTOBUF_CONSTEXPR $classname$::$classname$(\n" + " ::_pbi::ConstantInitialized)"); + + bool need_to_emit_cached_size = !HasSimpleBaseClass(descriptor_, options_); + format(": _impl_{"); format.Indent(); - const char* field_sep = ":"; + const char* field_sep = " "; const auto put_sep = [&] { format("\n$1$ ", field_sep); field_sep = ","; }; - - if (!IsMapEntryMessage(descriptor_)) { - // Process non-oneof fields first. - for (auto field : optimized_order_) { - auto& gen = field_generators_.get(field); + if (descriptor_->extension_range_count() > 0) { + put_sep(); + format("/*decltype($extensions$)*/{}"); + } + if (!inlined_string_indices_.empty()) { + put_sep(); + format("/*decltype($inlined_string_donated_array$)*/{}"); + } + if (!has_bit_indices_.empty()) { + put_sep(); + format("/*decltype($has_bits$)*/{}"); + if (need_to_emit_cached_size) { put_sep(); - gen.GenerateConstinitInitializer(printer); + format("/*decltype($cached_size$)*/{}"); + need_to_emit_cached_size = false; } + } + for (auto field : optimized_order_) { + if (ShouldSplit(field, options_)) { + continue; + } + put_sep(); + field_generators_.get(field).GenerateConstexprAggregateInitializer( + printer); + } + if (ShouldSplit(descriptor_, options_)) { + put_sep(); + format("/*decltype($split$)*/&$1$._instance", + DefaultInstanceName(descriptor_, options_, /*split=*/true)); + } - if (IsAnyMessage(descriptor_, options_)) { - put_sep(); - format("_any_metadata_(&type_url_, &value_)"); - } + for (auto oneof : OneOfRange(descriptor_)) { + put_sep(); + format("/*decltype(_impl_.$1$_)*/{}", oneof->name()); + } - if (descriptor_->real_oneof_decl_count() != 0) { - put_sep(); - format("_oneof_case_{}"); - } + if (need_to_emit_cached_size) { + put_sep(); + format("/*decltype($cached_size$)*/{}"); + } + + if (descriptor_->real_oneof_decl_count() != 0) { + put_sep(); + format("/*decltype($oneof_case$)*/{}"); + } + + if (num_weak_fields_) { + put_sep(); + format("/*decltype($weak_field_map$)*/{}"); + } + + if (IsAnyMessage(descriptor_, options_)) { + put_sep(); + format( + "/*decltype($any_metadata$)*/{&_impl_.type_url_, " + "&_impl_.value_}"); } format.Outdent(); - format("{}\n"); + format("} {}\n"); } -void MessageGenerator::GenerateConstructorBody(io::Printer* printer, - std::vector<bool> processed, - bool copy_constructor) const { +void MessageGenerator::GenerateCopyConstructorBody(io::Printer* printer) const { Formatter format(printer, variables_); - const RunMap runs = FindRuns( - optimized_order_, [copy_constructor, this](const FieldDescriptor* field) { - return (copy_constructor && IsPOD(field)) || - (!copy_constructor && - CanBeManipulatedAsRawBytes(field, options_, scc_analyzer_)); + const RunMap runs = + FindRuns(optimized_order_, [this](const FieldDescriptor* field) { + return IsPOD(field) && !ShouldSplit(field, options_); }); - std::string pod_template; - if (copy_constructor) { - pod_template = - "::memcpy(&$first$_, &from.$first$_,\n" - " static_cast<size_t>(reinterpret_cast<char*>(&$last$_) -\n" - " reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n"; - } else { - pod_template = - "::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(\n" - " reinterpret_cast<char*>(&$first$_) - " - "reinterpret_cast<char*>(this)),\n" - " 0, static_cast<size_t>(reinterpret_cast<char*>(&$last$_) -\n" - " reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n"; + std::string pod_template = + "::memcpy(&$first$, &from.$first$,\n" + " static_cast<size_t>(reinterpret_cast<char*>(&$last$) -\n" + " reinterpret_cast<char*>(&$first$)) + sizeof($last$));\n"; + + if (ShouldSplit(descriptor_, options_)) { + format("if (!from.IsSplitMessageDefault()) {\n"); + format.Indent(); + format("_this->PrepareSplitMessageForWrite();\n"); + for (auto field : optimized_order_) { + if (ShouldSplit(field, options_)) { + field_generators_.get(field).GenerateCopyConstructorCode(printer); + } + } + format.Outdent(); + format("}\n"); } - for (int i = 0; i < optimized_order_.size(); ++i) { - if (processed[i]) { + for (size_t i = 0; i < optimized_order_.size(); ++i) { + const FieldDescriptor* field = optimized_order_[i]; + if (ShouldSplit(field, options_)) { continue; } - - const FieldDescriptor* field = optimized_order_[i]; const auto it = runs.find(field); // We only apply the memset technique to runs of more than one field, as @@ -2978,9 +2763,10 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer, if (it != runs.end() && it->second > 1) { // Use a memset, then skip run_length fields. const size_t run_length = it->second; - const std::string first_field_name = FieldName(field); + const std::string first_field_name = + FieldMemberName(field, /*cold=*/false); const std::string last_field_name = - FieldName(optimized_order_[i + run_length - 1]); + FieldMemberName(optimized_order_[i + run_length - 1], /*cold=*/false); format.Set("first", first_field_name); format.Set("last", last_field_name); @@ -2990,11 +2776,7 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer, i += run_length - 1; // ++i at the top of the loop. } else { - if (copy_constructor) { - field_generators_.get(field).GenerateCopyConstructorCode(printer); - } else { - field_generators_.get(field).GenerateConstructorCode(printer); - } + field_generators_.get(field).GenerateCopyConstructorCode(printer); } } } @@ -3002,66 +2784,20 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer, void MessageGenerator::GenerateStructors(io::Printer* printer) { Formatter format(printer, variables_); - std::string superclass; - superclass = SuperClassName(descriptor_, options_); - std::string initializer_with_arena = superclass + "(arena, is_message_owned)"; - - if (descriptor_->extension_range_count() > 0) { - initializer_with_arena += ",\n _extensions_(arena)"; - } - - // Initialize member variables with arena constructor. - for (auto field : optimized_order_) { - GOOGLE_DCHECK(!IsFieldStripped(field, options_)); - bool has_arena_constructor = field->is_repeated(); - if (!field->real_containing_oneof() && - (IsLazy(field, options_, scc_analyzer_) || - IsStringPiece(field, options_) || - (IsString(field, options_) && IsStringInlined(field, options_)))) { - has_arena_constructor = true; - } - if (has_arena_constructor) { - initializer_with_arena += - std::string(",\n ") + FieldName(field) + std::string("_(arena)"); - } - } - - if (IsAnyMessage(descriptor_, options_)) { - initializer_with_arena += ",\n _any_metadata_(&type_url_, &value_)"; - } - if (num_weak_fields_ > 0) { - initializer_with_arena += ", _weak_field_map_(arena)"; - } - - std::string initializer_null = superclass + "()"; - if (IsAnyMessage(descriptor_, options_)) { - initializer_null += ", _any_metadata_(&type_url_, &value_)"; - } - if (num_weak_fields_ > 0) { - initializer_null += ", _weak_field_map_(nullptr)"; - } - format( "$classname$::$classname$(::$proto_ns$::Arena* arena,\n" " bool is_message_owned)\n" - " : $1$ {\n", - initializer_with_arena); - - if (!inlined_string_indices_.empty()) { - // Donate inline string fields. - format(" if (arena != nullptr) {\n"); - for (size_t i = 0; i < InlinedStringDonatedSize(); ++i) { - format(" _inlined_string_donated_[$1$] = ~0u;\n", i); - } - format(" }\n"); - } + " : $1$(arena, is_message_owned) {\n", + SuperClassName(descriptor_, options_)); if (!HasSimpleBaseClass(descriptor_, options_)) { - format( - " SharedCtor();\n" - " if (!is_message_owned) {\n" - " RegisterArenaDtor(arena);\n" - " }\n"); + format(" SharedCtor(arena, is_message_owned);\n"); + if (NeedsArenaDestructor() == ArenaDtorNeeds::kRequired) { + format( + " if (arena != nullptr && !is_message_owned) {\n" + " arena->OwnCustomDestructor(this, &$classname$::ArenaDtor);\n" + " }\n"); + } } format( " // @@protoc_insertion_point(arena_constructor:$full_name$)\n" @@ -3085,40 +2821,81 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { } else { format( "$classname$::$classname$(const $classname$& from)\n" - " : $superclass$()"); - format.Indent(); - format.Indent(); + " : $superclass$() {\n"); format.Indent(); + format("$classname$* const _this = this; (void)_this;\n"); - // Do not copy inlined_string_donated_, because this is not an arena - // constructor. + if (HasImplData(descriptor_, options_)) { + const char* field_sep = " "; + const auto put_sep = [&] { + format("\n$1$ ", field_sep); + field_sep = ","; + }; - if (!has_bit_indices_.empty()) { - format(",\n_has_bits_(from._has_bits_)"); - } + format("new (&_impl_) Impl_{"); + format.Indent(); - std::vector<bool> processed(optimized_order_.size(), false); - for (int i = 0; i < optimized_order_.size(); i++) { - auto field = optimized_order_[i]; - if (!(field->is_repeated() && !(field->is_map())) && - !IsCord(field, options_)) { - continue; + if (descriptor_->extension_range_count() > 0) { + put_sep(); + format("/*decltype($extensions$)*/{}"); + } + if (!inlined_string_indices_.empty()) { + // Do not copy inlined_string_donated_, because this is not an arena + // constructor. + put_sep(); + format("decltype($inlined_string_donated_array$){}"); + } + bool need_to_emit_cached_size = + !HasSimpleBaseClass(descriptor_, options_); + if (!has_bit_indices_.empty()) { + put_sep(); + format("decltype($has_bits$){from.$has_bits$}"); + if (need_to_emit_cached_size) { + put_sep(); + format("/*decltype($cached_size$)*/{}"); + need_to_emit_cached_size = false; + } } - processed[i] = true; - format(",\n$1$_(from.$1$_)", FieldName(field)); - } + // Initialize member variables with arena constructor. + for (auto field : optimized_order_) { + if (ShouldSplit(field, options_)) { + continue; + } + put_sep(); + field_generators_.get(field).GenerateCopyAggregateInitializer(printer); + } + if (ShouldSplit(descriptor_, options_)) { + put_sep(); + format("decltype($split$){reinterpret_cast<Impl_::Split*>(&$1$)}", + DefaultInstanceName(descriptor_, options_, /*split=*/true)); + } + for (auto oneof : OneOfRange(descriptor_)) { + put_sep(); + format("decltype(_impl_.$1$_){}", oneof->name()); + } - if (IsAnyMessage(descriptor_, options_)) { - format(",\n_any_metadata_(&type_url_, &value_)"); - } - if (num_weak_fields_ > 0) { - format(",\n_weak_field_map_(from._weak_field_map_)"); - } + if (need_to_emit_cached_size) { + put_sep(); + format("/*decltype($cached_size$)*/{}"); + } - format.Outdent(); - format.Outdent(); - format(" {\n"); + if (descriptor_->real_oneof_decl_count() != 0) { + put_sep(); + format("/*decltype($oneof_case$)*/{}"); + } + if (num_weak_fields_ > 0) { + put_sep(); + format("decltype($weak_field_map$){from.$weak_field_map$}"); + } + if (IsAnyMessage(descriptor_, options_)) { + put_sep(); + format( + "/*decltype($any_metadata$)*/{&_impl_.type_url_, &_impl_.value_}"); + } + format.Outdent(); + format("};\n\n"); + } format( "_internal_metadata_.MergeFrom<$unknown_fields_type$>(from._internal_" @@ -3126,11 +2903,11 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { if (descriptor_->extension_range_count() > 0) { format( - "_extensions_.MergeFrom(internal_default_instance(), " - "from._extensions_);\n"); + "$extensions$.MergeFrom(internal_default_instance(), " + "from.$extensions$);\n"); } - GenerateConstructorBody(printer, processed, true); + GenerateCopyConstructorBody(printer); // Copy oneof fields. Oneof field requires oneof case check. for (auto oneof : OneOfRange(descriptor_)) { @@ -3168,14 +2945,27 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { // Generate the shared constructor code. GenerateSharedConstructorCode(printer); + if (ShouldSplit(descriptor_, options_)) { + GenerateCreateSplitMessage(printer); + } + // Generate the destructor. if (!HasSimpleBaseClass(descriptor_, options_)) { format( "$classname$::~$classname$() {\n" - " // @@protoc_insertion_point(destructor:$full_name$)\n" - " if (GetArenaForAllocation() != nullptr) return;\n" + " // @@protoc_insertion_point(destructor:$full_name$)\n"); + format( + " if (auto *arena = " + "_internal_metadata_.DeleteReturnArena<$unknown_fields_type$>()) {\n" + " (void)arena;\n"); + if (NeedsArenaDestructor() > ArenaDtorNeeds::kNone) { + format(" ArenaDtor(this);\n"); + } + format( + " return;\n" + " }\n"); + format( " SharedDtor();\n" - " _internal_metadata_.Delete<$unknown_fields_type$>();\n" "}\n" "\n"); } else { @@ -3190,13 +2980,15 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { GenerateSharedDestructorCode(printer); // Generate the arena-specific destructor code. - GenerateArenaDestructorCode(printer); + if (NeedsArenaDestructor() > ArenaDtorNeeds::kNone) { + GenerateArenaDestructorCode(printer); + } if (!HasSimpleBaseClass(descriptor_, options_)) { // Generate SetCachedSize. format( "void $classname$::SetCachedSize(int size) const {\n" - " _cached_size_.Set(size);\n" + " $cached_size$.Set(size);\n" "}\n"); } } @@ -3205,8 +2997,8 @@ void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) { Formatter format(printer, variables_); format( "template<> " - "PROTOBUF_NOINLINE " - "$classtype$* Arena::CreateMaybeMessage< $classtype$ >(Arena* arena) {\n" + "PROTOBUF_NOINLINE $classtype$*\n" + "Arena::CreateMaybeMessage< $classtype$ >(Arena* arena) {\n" " return Arena::CreateMessageInternal< $classtype$ >(arena);\n" "}\n"); } @@ -3232,7 +3024,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { "(void) cached_has_bits;\n\n"); if (descriptor_->extension_range_count() > 0) { - format("_extensions_.Clear();\n"); + format("$extensions$.Clear();\n"); } // Collect fields into chunks. Each chunk may have an if() condition that @@ -3254,6 +3046,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { // (memset) per chunk, and if present it will be at the beginning. bool same = HasByteIndex(a) == HasByteIndex(b) && a->is_repeated() == b->is_repeated() && + ShouldSplit(a, options_) == ShouldSplit(b, options_) && (CanInitializeByZeroing(a) == CanInitializeByZeroing(b) || (CanInitializeByZeroing(a) && (chunk_count == 1 || merge_zero_init))); @@ -3261,7 +3054,8 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { return same; }); - ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio); + ColdChunkSkipper cold_skipper(descriptor_, options_, chunks, has_bit_indices_, + kColdRatio); int cached_has_word_index = -1; for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) { @@ -3271,7 +3065,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { const FieldDescriptor* memset_start = nullptr; const FieldDescriptor* memset_end = nullptr; bool saw_non_zero_init = false; - + bool chunk_is_cold = !chunk.empty() && ShouldSplit(chunk.front(), options_); for (const auto& field : chunk) { if (CanInitializeByZeroing(field)) { GOOGLE_CHECK(!saw_non_zero_init); @@ -3305,23 +3099,31 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { if (cached_has_word_index != HasWordIndex(chunk.front())) { cached_has_word_index = HasWordIndex(chunk.front()); - format("cached_has_bits = _has_bits_[$1$];\n", cached_has_word_index); + format("cached_has_bits = $has_bits$[$1$];\n", cached_has_word_index); } format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str); format.Indent(); } + if (chunk_is_cold) { + format("if (!IsSplitMessageDefault()) {\n"); + format.Indent(); + } + if (memset_start) { if (memset_start == memset_end) { // For clarity, do not memset a single field. field_generators_.get(memset_start) .GenerateMessageClearingCode(printer); } else { + GOOGLE_CHECK_EQ(chunk_is_cold, ShouldSplit(memset_start, options_)); + GOOGLE_CHECK_EQ(chunk_is_cold, ShouldSplit(memset_end, options_)); format( - "::memset(&$1$_, 0, static_cast<size_t>(\n" - " reinterpret_cast<char*>(&$2$_) -\n" - " reinterpret_cast<char*>(&$1$_)) + sizeof($2$_));\n", - FieldName(memset_start), FieldName(memset_end)); + "::memset(&$1$, 0, static_cast<size_t>(\n" + " reinterpret_cast<char*>(&$2$) -\n" + " reinterpret_cast<char*>(&$1$)) + sizeof($2$));\n", + FieldMemberName(memset_start, chunk_is_cold), + FieldMemberName(memset_end, chunk_is_cold)); } } @@ -3350,6 +3152,11 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { } } + if (chunk_is_cold) { + format.Outdent(); + format("}\n"); + } + if (have_outer_if) { format.Outdent(); format("}\n"); @@ -3367,14 +3174,14 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { } if (num_weak_fields_) { - format("_weak_field_map_.ClearAll();\n"); + format("$weak_field_map$.ClearAll();\n"); } // We don't clear donated status. if (!has_bit_indices_.empty()) { // Step 5: Everything else. - format("_has_bits_.Clear();\n"); + format("$has_bits$.Clear();\n"); } std::map<std::string, std::string> vars; @@ -3420,7 +3227,7 @@ void MessageGenerator::GenerateOneofClear(io::Printer* printer) { format.Outdent(); format( "}\n" - "_oneof_case_[$1$] = $2$_NOT_SET;\n", + "$oneof_case$[$1$] = $2$_NOT_SET;\n", i, ToUpper(oneof->name())); format.Outdent(); format( @@ -3440,13 +3247,15 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) { if (HasGeneratedMethods(descriptor_->file(), options_)) { if (descriptor_->extension_range_count() > 0) { - format("_extensions_.InternalSwap(&other->_extensions_);\n"); + format( + "$extensions$.InternalSwap(&other->$extensions$);" + "\n"); } std::map<std::string, std::string> vars; SetUnknownFieldsVariable(descriptor_, options_, &vars); format.AddMap(vars); - if (HasSingularString(descriptor_, options_)) { + if (HasNonSplitOptionalString(descriptor_, options_)) { format( "auto* lhs_arena = GetArenaForAllocation();\n" "auto* rhs_arena = other->GetArenaForAllocation();\n"); @@ -3455,18 +3264,22 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) { if (!has_bit_indices_.empty()) { for (int i = 0; i < HasBitsSize(); ++i) { - format("swap(_has_bits_[$1$], other->_has_bits_[$1$]);\n", i); + format("swap($has_bits$[$1$], other->$has_bits$[$1$]);\n", i); } } // If possible, we swap several fields at once, including padding. const RunMap runs = FindRuns(optimized_order_, [this](const FieldDescriptor* field) { - return CanBeManipulatedAsRawBytes(field, options_, scc_analyzer_); + return !ShouldSplit(field, options_) && + CanBeManipulatedAsRawBytes(field, options_, scc_analyzer_); }); - for (int i = 0; i < optimized_order_.size(); ++i) { + for (size_t i = 0; i < optimized_order_.size(); ++i) { const FieldDescriptor* field = optimized_order_[i]; + if (ShouldSplit(field, options_)) { + continue; + } const auto it = runs.find(field); // We only apply the memswap technique to runs of more than one field, as @@ -3475,20 +3288,21 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) { if (it != runs.end() && it->second > 1) { // Use a memswap, then skip run_length fields. const size_t run_length = it->second; - const std::string first_field_name = FieldName(field); - const std::string last_field_name = - FieldName(optimized_order_[i + run_length - 1]); + const std::string first_field_name = + FieldMemberName(field, /*cold=*/false); + const std::string last_field_name = FieldMemberName( + optimized_order_[i + run_length - 1], /*cold=*/false); format.Set("first", first_field_name); format.Set("last", last_field_name); format( "::PROTOBUF_NAMESPACE_ID::internal::memswap<\n" - " PROTOBUF_FIELD_OFFSET($classname$, $last$_)\n" - " + sizeof($classname$::$last$_)\n" - " - PROTOBUF_FIELD_OFFSET($classname$, $first$_)>(\n" - " reinterpret_cast<char*>(&$first$_),\n" - " reinterpret_cast<char*>(&other->$first$_));\n"); + " PROTOBUF_FIELD_OFFSET($classname$, $last$)\n" + " + sizeof($classname$::$last$)\n" + " - PROTOBUF_FIELD_OFFSET($classname$, $first$)>(\n" + " reinterpret_cast<char*>(&$first$),\n" + " reinterpret_cast<char*>(&other->$first$));\n"); i += run_length - 1; // ++i at the top of the loop. @@ -3496,17 +3310,31 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) { field_generators_.get(field).GenerateSwappingCode(printer); } } + if (ShouldSplit(descriptor_, options_)) { + format("swap($split$, other->$split$);\n"); + } for (auto oneof : OneOfRange(descriptor_)) { - format("swap($1$_, other->$1$_);\n", oneof->name()); + format("swap(_impl_.$1$_, other->_impl_.$1$_);\n", oneof->name()); } for (int i = 0; i < descriptor_->real_oneof_decl_count(); i++) { - format("swap(_oneof_case_[$1$], other->_oneof_case_[$1$]);\n", i); + format("swap($oneof_case$[$1$], other->$oneof_case$[$1$]);\n", i); } if (num_weak_fields_) { - format("_weak_field_map_.UnsafeArenaSwap(&other->_weak_field_map_);\n"); + format( + "$weak_field_map$.UnsafeArenaSwap(&other->$weak_field_map$)" + ";\n"); + } + + if (!inlined_string_indices_.empty()) { + for (size_t i = 0; i < InlinedStringDonatedSize(); ++i) { + format( + "swap($inlined_string_donated_array$[$1$], " + "other->$inlined_string_donated_array$[$1$]);\n", + i); + } } } else { format("GetReflection()->Swap(this, other);"); @@ -3532,24 +3360,18 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) { format( "const ::$proto_ns$::Message::ClassData " "$classname$::_class_data_ = {\n" - " ::$proto_ns$::Message::CopyWithSizeCheck,\n" + " ::$proto_ns$::Message::CopyWithSourceCheck,\n" " $classname$::MergeImpl\n" "};\n" "const ::$proto_ns$::Message::ClassData*" "$classname$::GetClassData() const { return &_class_data_; }\n" - "\n" - "void $classname$::MergeImpl(::$proto_ns$::Message* to,\n" - " const ::$proto_ns$::Message& from) {\n" - " static_cast<$classname$ *>(to)->MergeFrom(\n" - " static_cast<const $classname$ &>(from));\n" - "}\n" "\n"); } else { // Generate CheckTypeAndMergeFrom(). format( "void $classname$::CheckTypeAndMergeFrom(\n" " const ::$proto_ns$::MessageLite& from) {\n" - " MergeFrom(*::$proto_ns$::internal::DownCast<const $classname$*>(\n" + " MergeFrom(*::_pbi::DownCast<const $classname$*>(\n" " &from));\n" "}\n"); } @@ -3569,29 +3391,50 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) { } } -void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) { +void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* printer) { if (HasSimpleBaseClass(descriptor_, options_)) return; // Generate the class-specific MergeFrom, which avoids the GOOGLE_CHECK and cast. Formatter format(printer, variables_); + if (!HasDescriptorMethods(descriptor_->file(), options_)) { + // For messages that don't inherit from Message, just implement MergeFrom + // directly. + format( + "void $classname$::MergeFrom(const $classname$& from) {\n" + " $classname$* const _this = this;\n"); + } else { + format( + "void $classname$::MergeImpl(::$proto_ns$::Message& to_msg, const " + "::$proto_ns$::Message& from_msg) {\n" + " auto* const _this = static_cast<$classname$*>(&to_msg);\n" + " auto& from = static_cast<const $classname$&>(from_msg);\n"); + } + format.Indent(); format( - "void $classname$::MergeFrom(const $classname$& from) {\n" "$annotate_mergefrom$" "// @@protoc_insertion_point(class_specific_merge_from_start:" - "$full_name$)\n" - " $DCHK$_NE(&from, this);\n"); - format.Indent(); + "$full_name$)\n"); + format("$DCHK$_NE(&from, _this);\n"); format( "$uint32$ cached_has_bits = 0;\n" "(void) cached_has_bits;\n\n"); + if (ShouldSplit(descriptor_, options_)) { + format( + "if (!from.IsSplitMessageDefault()) {\n" + " _this->PrepareSplitMessageForWrite();\n" + "}\n"); + } + std::vector<std::vector<const FieldDescriptor*>> chunks = CollectFields( optimized_order_, [&](const FieldDescriptor* a, const FieldDescriptor* b) -> bool { - return HasByteIndex(a) == HasByteIndex(b); + return HasByteIndex(a) == HasByteIndex(b) && + ShouldSplit(a, options_) == ShouldSplit(b, options_); }); - ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio); + ColdChunkSkipper cold_skipper(descriptor_, options_, chunks, has_bit_indices_, + kColdRatio); // cached_has_word_index maintains that: // cached_has_bits = from._has_bits_[cached_has_word_index] @@ -3619,7 +3462,7 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) { if (cached_has_word_index != HasWordIndex(chunk.front())) { cached_has_word_index = HasWordIndex(chunk.front()); - format("cached_has_bits = from._has_bits_[$1$];\n", + format("cached_has_bits = from.$has_bits$[$1$];\n", cached_has_word_index); } @@ -3680,7 +3523,8 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) { if (deferred_has_bit_changes) { // Flush the has bits for the primitives we deferred. GOOGLE_CHECK_LE(0, cached_has_word_index); - format("_has_bits_[$1$] |= cached_has_bits;\n", cached_has_word_index); + format("_this->$has_bits$[$1$] |= cached_has_bits;\n", + cached_has_word_index); } format.Outdent(); @@ -3716,19 +3560,22 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) { format("}\n"); } if (num_weak_fields_) { - format("_weak_field_map_.MergeFrom(from._weak_field_map_);\n"); + format( + "_this->$weak_field_map$.MergeFrom(from.$weak_field_map$);" + "\n"); } // Merging of extensions and unknown fields is done last, to maximize // the opportunity for tail calls. if (descriptor_->extension_range_count() > 0) { format( - "_extensions_.MergeFrom(internal_default_instance(), " - "from._extensions_);\n"); + "_this->$extensions$.MergeFrom(internal_default_instance(), " + "from.$extensions$);\n"); } format( - "_internal_metadata_.MergeFrom<$unknown_fields_type$>(from._internal_" + "_this->_internal_metadata_.MergeFrom<$unknown_fields_type$>(from._" + "internal_" "metadata_);\n"); format.Outdent(); @@ -3743,12 +3590,12 @@ void MessageGenerator::GenerateCopyFrom(io::Printer* printer) { // takes in the Message base class as a parameter); instead we just // let the base Message::CopyFrom take care of it. The base MergeFrom // knows how to quickly confirm the types exactly match, and if so, will - // use GetClassData() to get the address of Message::CopyWithSizeCheck, + // use GetClassData() to get the address of Message::CopyWithSourceCheck, // which calls Clear() and then MergeFrom(), as well as making sure that - // clearing the destination message doesn't alter the size of the source, - // when in debug builds. - // Most callers avoid this by passing a "from" message that is the same - // type as the message being merged into, rather than a generic Message. + // clearing the destination message doesn't alter the source, when in debug + // builds. Most callers avoid this by passing a "from" message that is the + // same type as the message being merged into, rather than a generic + // Message. } // Generate the class-specific CopyFrom. @@ -3760,20 +3607,33 @@ void MessageGenerator::GenerateCopyFrom(io::Printer* printer) { format("if (&from == this) return;\n"); - if (!options_.opensource_runtime) { + if (!options_.opensource_runtime && HasMessageFieldOrExtension(descriptor_)) { // This check is disabled in the opensource release because we're // concerned that many users do not define NDEBUG in their release builds. + // It is also disabled if a message has neither message fields nor + // extensions, as it's impossible to copy from its descendant. + // + // Note that FailIfCopyFromDescendant is implemented by reflection and not + // available for lite runtime. In that case, check if the size of the source + // has changed after Clear. + format("#ifndef NDEBUG\n"); + if (HasDescriptorMethods(descriptor_->file(), options_)) { + format("FailIfCopyFromDescendant(*this, from);\n"); + } else { + format("size_t from_size = from.ByteSizeLong();\n"); + } format( - "#ifndef NDEBUG\n" - "size_t from_size = from.ByteSizeLong();\n" "#endif\n" - "Clear();\n" - "#ifndef NDEBUG\n" - "$CHK$_EQ(from_size, from.ByteSizeLong())\n" - " << \"Source of CopyFrom changed when clearing target. Either \"\n" - " \"source is a nested message in target (not allowed), or \"\n" - " \"another thread is modifying the source.\";\n" - "#endif\n"); + "Clear();\n"); + if (!HasDescriptorMethods(descriptor_->file(), options_)) { + format( + "#ifndef NDEBUG\n" + "$CHK$_EQ(from_size, from.ByteSizeLong())\n" + " << \"Source of CopyFrom changed when clearing target. Either \"\n" + " \"source is a nested message in target (not allowed), or \"\n" + " \"another thread is modifying the source.\";\n" + "#endif\n"); + } } else { format("Clear();\n"); } @@ -3860,7 +3720,7 @@ void MessageGenerator::GenerateSerializeOneExtensionRange( Formatter format(printer, vars); format("// Extension range [$start$, $end$)\n"); format( - "target = _extensions_._InternalSerialize(\n" + "target = $extensions$._InternalSerialize(\n" "internal_default_instance(), $start$, $end$, target, stream);\n\n"); } @@ -3875,14 +3735,14 @@ void MessageGenerator::GenerateSerializeWithCachedSizesToArray( " $uint8$* target, ::$proto_ns$::io::EpsCopyOutputStream* stream) " "const {\n" "$annotate_serialize$" - " target = _extensions_." + " target = $extensions$." "InternalSerializeMessageSetWithCachedSizesToArray(\n" // "internal_default_instance(), target, stream);\n"); std::map<std::string, std::string> vars; SetUnknownFieldsVariable(descriptor_, options_, &vars); format.AddMap(vars); format( - " target = ::$proto_ns$::internal::" + " target = ::_pbi::" "InternalSerializeUnknownMessageSetItemsToArray(\n" " $unknown_fields$, target, stream);\n"); format( @@ -3965,7 +3825,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody( // Reload. int new_index = has_bit_index / 32; - format_("cached_has_bits = _has_bits_[$1$];\n", new_index); + format_("cached_has_bits = _impl_._has_bits_[$1$];\n", new_index); cached_has_bit_index_ = new_index; } @@ -4077,8 +3937,8 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody( ExtensionRangeSorter()); if (num_weak_fields_) { format( - "::$proto_ns$::internal::WeakFieldMap::FieldWriter field_writer(" - "_weak_field_map_);\n"); + "::_pbi::WeakFieldMap::FieldWriter field_writer(" + "$weak_field_map$);\n"); } format( @@ -4126,7 +3986,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody( if (UseUnknownFieldSet(descriptor_->file(), options_)) { format( "target = " - "::$proto_ns$::internal::WireFormat::" + "::_pbi::WireFormat::" "InternalSerializeUnknownFieldsToArray(\n" " $unknown_fields$, target, stream);\n"); } else { @@ -4167,8 +4027,8 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled( if (num_weak_fields_) { format( - "::$proto_ns$::internal::WeakFieldMap::FieldWriter field_writer(" - "_weak_field_map_);\n"); + "::_pbi::WeakFieldMap::FieldWriter field_writer(" + "$weak_field_map$);\n"); } format("for (int i = $1$; i >= 0; i-- ) {\n", num_fields - 1); @@ -4218,7 +4078,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled( if (UseUnknownFieldSet(descriptor_->file(), options_)) { format( "target = " - "::$proto_ns$::internal::WireFormat::" + "::_pbi::WireFormat::" "InternalSerializeUnknownFieldsToArray(\n" " $unknown_fields$, target, stream);\n"); } else { @@ -4259,13 +4119,13 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { "size_t $classname$::ByteSizeLong() const {\n" "$annotate_bytesize$" "// @@protoc_insertion_point(message_set_byte_size_start:$full_name$)\n" - " size_t total_size = _extensions_.MessageSetByteSize();\n" + " size_t total_size = $extensions$.MessageSetByteSize();\n" " if ($have_unknown_fields$) {\n" - " total_size += ::$proto_ns$::internal::\n" + " total_size += ::_pbi::\n" " ComputeUnknownMessageSetItemsSize($unknown_fields$);\n" " }\n" " int cached_size = " - "::$proto_ns$::internal::ToCachedSize(total_size);\n" + "::_pbi::ToCachedSize(total_size);\n" " SetCachedSize(cached_size);\n" " return total_size;\n" "}\n"); @@ -4312,7 +4172,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { if (descriptor_->extension_range_count() > 0) { format( - "total_size += _extensions_.ByteSize();\n" + "total_size += $extensions$.ByteSize();\n" "\n"); } @@ -4358,14 +4218,16 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { std::vector<std::vector<const FieldDescriptor*>> chunks = CollectFields( optimized_order_, [&](const FieldDescriptor* a, const FieldDescriptor* b) -> bool { - return a->label() == b->label() && HasByteIndex(a) == HasByteIndex(b); + return a->label() == b->label() && HasByteIndex(a) == HasByteIndex(b) && + ShouldSplit(a, options_) == ShouldSplit(b, options_); }); // Remove chunks with required fields. chunks.erase(std::remove_if(chunks.begin(), chunks.end(), IsRequired), chunks.end()); - ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio); + ColdChunkSkipper cold_skipper(descriptor_, options_, chunks, has_bit_indices_, + kColdRatio); int cached_has_word_index = -1; format( @@ -4393,7 +4255,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { if (cached_has_word_index != HasWordIndex(chunk.front())) { cached_has_word_index = HasWordIndex(chunk.front()); - format("cached_has_bits = _has_bits_[$1$];\n", cached_has_word_index); + format("cached_has_bits = $has_bits$[$1$];\n", cached_has_word_index); } format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str); format.Indent(); @@ -4473,7 +4335,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { if (num_weak_fields_) { // TagSize + MessageSize - format("total_size += _weak_field_map_.ByteSizeLong();\n"); + format("total_size += $weak_field_map$.ByteSizeLong();\n"); } if (UseUnknownFieldSet(descriptor_->file(), options_)) { @@ -4481,7 +4343,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { // unknown fields in tail position. This allows for better code generation // of this function for simple protos. format( - "return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_);\n"); + "return MaybeComputeUnknownFieldsSize(total_size, &$cached_size$);\n"); } else { format("if (PROTOBUF_PREDICT_FALSE($have_unknown_fields$)) {\n"); format(" total_size += $unknown_fields$.size();\n"); @@ -4496,7 +4358,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { // where even relaxed memory order might have perf impact to replace it with // ordinary loads and stores. format( - "int cached_size = ::$proto_ns$::internal::ToCachedSize(total_size);\n" + "int cached_size = ::_pbi::ToCachedSize(total_size);\n" "SetCachedSize(cached_size);\n" "return total_size;\n"); } @@ -4513,14 +4375,14 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) { if (descriptor_->extension_range_count() > 0) { format( - "if (!_extensions_.IsInitialized()) {\n" + "if (!$extensions$.IsInitialized()) {\n" " return false;\n" "}\n\n"); } if (num_required_fields_ > 0) { format( - "if (_Internal::MissingRequiredFields(_has_bits_))" + "if (_Internal::MissingRequiredFields($has_bits$))" " return false;\n"); } @@ -4530,7 +4392,7 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) { } if (num_weak_fields_) { // For Weak fields. - format("if (!_weak_field_map_.IsInitialized()) return false;\n"); + format("if (!$weak_field_map$.IsInitialized()) return false;\n"); } // Go through the oneof fields, emitting a switch if any might have required // fields. diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_message.h b/r5dev/thirdparty/protobuf/compiler/cpp/message.h similarity index 86% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_message.h rename to r5dev/thirdparty/protobuf/compiler/cpp/message.h index 61902e23..68a5e2d2 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_message.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/message.h @@ -40,11 +40,11 @@ #include <set> #include <string> -#include <thirdparty/protobuf/compiler/cpp/cpp_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_message_layout_helper.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_options.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_parse_function_generator.h> +#include <thirdparty/protobuf/compiler/cpp/field.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> +#include <thirdparty/protobuf/compiler/cpp/message_layout_helper.h> +#include <thirdparty/protobuf/compiler/cpp/options.h> +#include <thirdparty/protobuf/compiler/cpp/parse_function_generator.h> namespace google { namespace protobuf { @@ -96,22 +96,10 @@ class MessageGenerator { void GenerateFieldAccessorDeclarations(io::Printer* printer); void GenerateFieldAccessorDefinitions(io::Printer* printer); - // Generate the table-driven parsing array. Returns the number of entries - // generated. - size_t GenerateParseOffsets(io::Printer* printer); - size_t GenerateParseAuxTable(io::Printer* printer); - // Generates a ParseTable entry. Returns whether the proto uses - // table-driven parsing. - bool GenerateParseTable(io::Printer* printer, size_t offset, - size_t aux_offset); - // Generate the field offsets array. Returns the a pair of the total number // of entries generated and the index of the first has_bit entry. std::pair<size_t, size_t> GenerateOffsets(io::Printer* printer); void GenerateSchema(io::Printer* printer, int offset, int has_offset); - // For each field generates a table entry describing the field for the - // table driven serializer. - int GenerateFieldMetadata(io::Printer* printer); // Generate constructors and destructor. void GenerateStructors(io::Printer* printer); @@ -131,6 +119,9 @@ class MessageGenerator { // default instance. void GenerateConstexprConstructor(io::Printer* printer); + void GenerateCreateSplitMessage(io::Printer* printer); + void GenerateInitDefaultSplitInstance(io::Printer* printer); + // Generate standard Message methods. void GenerateClear(io::Printer* printer); void GenerateOneofClear(io::Printer* printer); @@ -141,7 +132,7 @@ class MessageGenerator { void GenerateSerializeWithCachedSizesBodyShuffled(io::Printer* printer); void GenerateByteSize(io::Printer* printer); void GenerateMergeFrom(io::Printer* printer); - void GenerateClassSpecificMergeFrom(io::Printer* printer); + void GenerateClassSpecificMergeImpl(io::Printer* printer); void GenerateCopyFrom(io::Printer* printer); void GenerateSwap(io::Printer* printer); void GenerateIsInitialized(io::Printer* printer); @@ -173,9 +164,20 @@ class MessageGenerator { void GenerateFieldClear(const FieldDescriptor* field, bool is_inline, Formatter format); - void GenerateConstructorBody(io::Printer* printer, - std::vector<bool> already_processed, - bool copy_constructor) const; + // Generates the body of the message's copy constructor. + void GenerateCopyConstructorBody(io::Printer* printer) const; + + // Returns the level that this message needs ArenaDtor. If the message has + // a field that is not arena-exclusive, it needs an ArenaDtor + // (go/proto-destructor). + // + // - Returning kNone means we don't need to generate ArenaDtor. + // - Returning kOnDemand means we need to generate ArenaDtor, but don't need + // to register ArenaDtor at construction. Such as when the message's + // ArenaDtor code is only for destructing inlined string. + // - Returning kRequired means we meed to generate ArenaDtor and register it + // at construction. + ArenaDtorNeeds NeedsArenaDestructor() const; size_t HasBitsSize() const; size_t InlinedStringDonatedSize() const; @@ -200,7 +202,8 @@ class MessageGenerator { int max_has_bit_index_; // A map from field index to inlined_string index. For non-inlined-string - // fields, the element is -1. + // fields, the element is -1. If there is no inlined string in the message, + // this is empty. std::vector<int> inlined_string_indices_; // The count of inlined_string fields in the message. int max_inlined_string_index_; @@ -209,8 +212,6 @@ class MessageGenerator { std::vector<const ExtensionGenerator*> extension_generators_; int num_required_fields_; int num_weak_fields_; - // table_driven_ indicates the generated message uses table-driven parsing. - bool table_driven_; std::unique_ptr<MessageLayoutHelper> message_layout_helper_; std::unique_ptr<ParseFunctionGenerator> parse_function_generator_; diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_message_field.cc b/r5dev/thirdparty/protobuf/compiler/cpp/message_field.cc similarity index 78% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_message_field.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/message_field.cc index 0fe67b91..332b21e1 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_message_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/message_field.cc @@ -32,9 +32,11 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/cpp/cpp_message_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> +#include <thirdparty/protobuf/compiler/cpp/message_field.h> + #include <thirdparty/protobuf/io/printer.h> +#include <thirdparty/protobuf/compiler/cpp/field.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> #include <thirdparty/protobuf/stubs/strutil.h> @@ -60,11 +62,16 @@ void SetMessageVariables(const FieldDescriptor* descriptor, SetCommonFieldVariables(descriptor, variables, options); (*variables)["type"] = FieldMessageTypeName(descriptor, options); (*variables)["casted_member"] = ReinterpretCast( - (*variables)["type"] + "*", (*variables)["name"] + "_", implicit_weak); + (*variables)["type"] + "*", (*variables)["field"], implicit_weak); + (*variables)["casted_member_const"] = + ReinterpretCast("const " + (*variables)["type"] + "&", + "*" + (*variables)["field"], implicit_weak); (*variables)["type_default_instance"] = QualifiedDefaultInstanceName(descriptor->message_type(), options); - (*variables)["type_default_instance_ptr"] = - QualifiedDefaultInstancePtr(descriptor->message_type(), options); + (*variables)["type_default_instance_ptr"] = ReinterpretCast( + "const ::PROTOBUF_NAMESPACE_ID::MessageLite*", + QualifiedDefaultInstancePtr(descriptor->message_type(), options), + implicit_weak); (*variables)["type_reference_function"] = implicit_weak ? (" ::" + (*variables)["proto_ns"] + "::internal::StrongReference(reinterpret_cast<const " + @@ -151,8 +158,7 @@ void MessageFieldGenerator::GenerateAccessorDeclarations( } void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions( - io::Printer* printer) const { -} + io::Printer* printer) const {} void MessageFieldGenerator::GenerateInlineAccessorDefinitions( io::Printer* printer) const { @@ -173,17 +179,17 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( format( "inline void $classname$::unsafe_arena_set_allocated_$name$(\n" " $type$* $name$) {\n" + "$maybe_prepare_split_message$" // If we're not on an arena, free whatever we were holding before. // (If we are on arena, we can just forget the earlier pointer.) " if (GetArenaForAllocation() == nullptr) {\n" - " delete reinterpret_cast<::$proto_ns$::MessageLite*>($name$_);\n" + " delete reinterpret_cast<::$proto_ns$::MessageLite*>($field$);\n" " }\n"); if (implicit_weak_field_) { format( - " $name$_ = " - "reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n"); + " $field$ = reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n"); } else { - format(" $name$_ = $name$;\n"); + format(" $field$ = $name$;\n"); } format( " if ($name$) {\n" @@ -199,9 +205,10 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( "inline $type$* $classname$::$release_name$() {\n" "$type_reference_function$" "$annotate_release$" + "$maybe_prepare_split_message$" " $clear_hasbit$\n" " $type$* temp = $casted_member$;\n" - " $name$_ = nullptr;\n" + " $field$ = nullptr;\n" "#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE\n" " auto* old = reinterpret_cast<::$proto_ns$::MessageLite*>(temp);\n" " temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n" @@ -217,9 +224,10 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( "$annotate_release$" " // @@protoc_insertion_point(field_release:$full_name$)\n" "$type_reference_function$" + "$maybe_prepare_split_message$" " $clear_hasbit$\n" " $type$* temp = $casted_member$;\n" - " $name$_ = nullptr;\n" + " $field$ = nullptr;\n" " return temp;\n" "}\n"); @@ -227,18 +235,21 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( "inline $type$* $classname$::_internal_mutable_$name$() {\n" "$type_reference_function$" " $set_hasbit$\n" - " if ($name$_ == nullptr) {\n" + " if ($field$ == nullptr) {\n" " auto* p = CreateMaybeMessage<$type$>(GetArenaForAllocation());\n"); if (implicit_weak_field_) { - format(" $name$_ = reinterpret_cast<::$proto_ns$::MessageLite*>(p);\n"); + format(" $field$ = reinterpret_cast<::$proto_ns$::MessageLite*>(p);\n"); } else { - format(" $name$_ = p;\n"); + format(" $field$ = p;\n"); } format( " }\n" " return $casted_member$;\n" "}\n" "inline $type$* $classname$::mutable_$name$() {\n" + // TODO(b/122856539): add tests to make sure all write accessors are able + // to prepare split message allocation. + "$maybe_prepare_split_message$" " $type$* _msg = _internal_mutable_$name$();\n" "$annotate_mutable$" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" @@ -250,12 +261,14 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( format( "inline void $classname$::set_allocated_$name$($type$* $name$) {\n" " ::$proto_ns$::Arena* message_arena = GetArenaForAllocation();\n"); - format(" if (message_arena == nullptr) {\n"); + format( + "$maybe_prepare_split_message$" + " if (message_arena == nullptr) {\n"); if (IsCrossFileMessage(descriptor_)) { format( - " delete reinterpret_cast< ::$proto_ns$::MessageLite*>($name$_);\n"); + " delete reinterpret_cast< ::$proto_ns$::MessageLite*>($field$);\n"); } else { - format(" delete $name$_;\n"); + format(" delete $field$;\n"); } format( " }\n" @@ -265,14 +278,13 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( // isn't defined in this file. format( " ::$proto_ns$::Arena* submessage_arena =\n" - " ::$proto_ns$::Arena::InternalHelper<\n" - " ::$proto_ns$::MessageLite>::GetOwningArena(\n" + " ::$proto_ns$::Arena::InternalGetOwningArena(\n" " reinterpret_cast<::$proto_ns$::MessageLite*>(" "$name$));\n"); } else { format( " ::$proto_ns$::Arena* submessage_arena =\n" - " ::$proto_ns$::Arena::InternalHelper<$type$>::GetOwningArena(" + " ::$proto_ns$::Arena::InternalGetOwningArena(" "$name$);\n"); } format( @@ -285,9 +297,9 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( " $clear_hasbit$\n" " }\n"); if (implicit_weak_field_) { - format(" $name$_ = reinterpret_cast<MessageLite*>($name$);\n"); + format(" $field$ = reinterpret_cast<MessageLite*>($name$);\n"); } else { - format(" $name$_ = $name$;\n"); + format(" $field$ = $name$;\n"); } format( "$annotate_set$" @@ -322,14 +334,10 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( format( "const ::$proto_ns$::MessageLite& $classname$::_Internal::$name$(\n" " const $classname$* msg) {\n" - " if (msg->$name$_ != nullptr) {\n" - " return *msg->$name$_;\n" - " } else if ($type_default_instance_ptr$ != nullptr) {\n" - " return *reinterpret_cast<const ::$proto_ns$::MessageLite*>(\n" - " $type_default_instance_ptr$);\n" + " if (msg->$field$ != nullptr) {\n" + " return *msg->$field$;\n" " } else {\n" - " return " - "*::$proto_ns$::internal::ImplicitWeakMessage::default_instance();\n" + " return *$type_default_instance_ptr$;\n" " }\n" "}\n"); format( @@ -338,20 +346,19 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( if (HasHasbit(descriptor_)) { format(" msg->$set_hasbit$\n"); } + if (descriptor_->real_containing_oneof() == nullptr) { + format(" if (msg->$field$ == nullptr) {\n"); + } else { + format( + " if (!msg->_internal_has_$name$()) {\n" + " msg->clear_$oneof_name$();\n" + " msg->set_has_$name$();\n"); + } format( - " if (msg->$name$_ == nullptr) {\n" - " if ($type_default_instance_ptr$ == nullptr) {\n" - " msg->$name$_ = ::$proto_ns$::Arena::CreateMessage<\n" - " ::$proto_ns$::internal::ImplicitWeakMessage>(\n" - " msg->GetArenaForAllocation());\n" - " } else {\n" - " msg->$name$_ = \n" - " reinterpret_cast<const ::$proto_ns$::MessageLite*>(\n" - " $type_default_instance_ptr$)->New(\n" - " msg->GetArenaForAllocation());\n" - " }\n" + " msg->$field$ = $type_default_instance_ptr$->New(\n" + " msg->GetArenaForAllocation());\n" " }\n" - " return msg->$name$_;\n" + " return msg->$field$;\n" "}\n"); } else { // This inline accessor directly returns member field and is used in @@ -360,7 +367,7 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( format( "const $type$&\n" "$classname$::_Internal::$name$(const $classname$* msg) {\n" - " return *msg->$field_member$;\n" + " return *msg->$field$;\n" "}\n"); } } @@ -371,14 +378,14 @@ void MessageFieldGenerator::GenerateClearingCode(io::Printer* printer) const { Formatter format(printer, variables_); if (!HasHasbit(descriptor_)) { // If we don't have has-bits, message presence is indicated only by ptr != - // NULL. Thus on clear, we need to delete the object. + // nullptr. Thus on clear, we need to delete the object. format( - "if (GetArenaForAllocation() == nullptr && $name$_ != nullptr) {\n" - " delete $name$_;\n" + "if (GetArenaForAllocation() == nullptr && $field$ != nullptr) {\n" + " delete $field$;\n" "}\n" - "$name$_ = nullptr;\n"); + "$field$ = nullptr;\n"); } else { - format("if ($name$_ != nullptr) $name$_->Clear();\n"); + format("if ($field$ != nullptr) $field$->Clear();\n"); } } @@ -389,16 +396,16 @@ void MessageFieldGenerator::GenerateMessageClearingCode( Formatter format(printer, variables_); if (!HasHasbit(descriptor_)) { // If we don't have has-bits, message presence is indicated only by ptr != - // NULL. Thus on clear, we need to delete the object. + // nullptr. Thus on clear, we need to delete the object. format( - "if (GetArenaForAllocation() == nullptr && $name$_ != nullptr) {\n" - " delete $name$_;\n" + "if (GetArenaForAllocation() == nullptr && $field$ != nullptr) {\n" + " delete $field$;\n" "}\n" - "$name$_ = nullptr;\n"); + "$field$ = nullptr;\n"); } else { format( - "$DCHK$($name$_ != nullptr);\n" - "$name$_->Clear();\n"); + "$DCHK$($field$ != nullptr);\n" + "$field$->Clear();\n"); } } @@ -408,12 +415,12 @@ void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const { Formatter format(printer, variables_); if (implicit_weak_field_) { format( - "_Internal::mutable_$name$(this)->CheckTypeAndMergeFrom(\n" + "_Internal::mutable_$name$(_this)->CheckTypeAndMergeFrom(\n" " _Internal::$name$(&from));\n"); } else { format( - "_internal_mutable_$name$()->$type$::MergeFrom(from._internal_$name$())" - ";\n"); + "_this->_internal_mutable_$name$()->$type$::MergeFrom(\n" + " from._internal_$name$());\n"); } } @@ -421,7 +428,7 @@ void MessageFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); Formatter format(printer, variables_); - format("swap($name$_, other->$name$_);\n"); + format("swap($field$, other->$field$);\n"); } void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { @@ -436,15 +443,11 @@ void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { // care when handling them. format("if (this != internal_default_instance()) "); } - format("delete $name$_;\n"); -} - -void MessageFieldGenerator::GenerateConstructorCode( - io::Printer* printer) const { - GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); - - Formatter format(printer, variables_); - format("$name$_ = nullptr;\n"); + if (ShouldSplit(descriptor_, options_)) { + format("delete $cached_split_ptr$->$name$_;\n"); + return; + } + format("delete $field$;\n"); } void MessageFieldGenerator::GenerateCopyConstructorCode( @@ -454,9 +457,7 @@ void MessageFieldGenerator::GenerateCopyConstructorCode( Formatter format(printer, variables_); format( "if (from._internal_has_$name$()) {\n" - " $name$_ = new $type$(*from.$name$_);\n" - "} else {\n" - " $name$_ = nullptr;\n" + " _this->$field$ = new $type$(*from.$field$);\n" "}\n"); } @@ -465,11 +466,18 @@ void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray( GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); Formatter format(printer, variables_); - format( - "target = stream->EnsureSpace(target);\n" - "target = ::$proto_ns$::internal::WireFormatLite::\n" - " InternalWrite$declared_type$(\n" - " $number$, _Internal::$name$(this), target, stream);\n"); + if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) { + format( + "target = ::$proto_ns$::internal::WireFormatLite::\n" + " InternalWrite$declared_type$($number$, _Internal::$name$(this),\n" + " _Internal::$name$(this).GetCachedSize(), target, stream);\n"); + } else { + format( + "target = stream->EnsureSpace(target);\n" + "target = ::$proto_ns$::internal::WireFormatLite::\n" + " InternalWrite$declared_type$(\n" + " $number$, _Internal::$name$(this), target, stream);\n"); + } } void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const { @@ -479,7 +487,7 @@ void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const { format( "total_size += $tag_size$ +\n" " ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n" - " *$field_member$);\n"); + " *$field$);\n"); } void MessageFieldGenerator::GenerateIsInitialized(io::Printer* printer) const { @@ -490,14 +498,30 @@ void MessageFieldGenerator::GenerateIsInitialized(io::Printer* printer) const { Formatter format(printer, variables_); format( "if (_internal_has_$name$()) {\n" - " if (!$name$_->IsInitialized()) return false;\n" + " if (!$field$->IsInitialized()) return false;\n" "}\n"); } -void MessageFieldGenerator::GenerateConstinitInitializer( +void MessageFieldGenerator::GenerateConstexprAggregateInitializer( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_(nullptr)"); + format("/*decltype($field$)*/nullptr"); +} + +void MessageFieldGenerator::GenerateCopyAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("decltype($field$){nullptr}"); +} + +void MessageFieldGenerator::GenerateAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + if (ShouldSplit(descriptor_, options_)) { + format("decltype(Impl_::Split::$name$_){nullptr}"); + return; + } + format("decltype($field$){nullptr}"); } // =================================================================== @@ -524,15 +548,13 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions( // isn't defined in this file. format( " ::$proto_ns$::Arena* submessage_arena =\n" - " ::$proto_ns$::Arena::InternalHelper<\n" - " ::$proto_ns$::MessageLite>::GetOwningArena(\n" + " ::$proto_ns$::Arena::InternalGetOwningArena(\n" " reinterpret_cast<::$proto_ns$::MessageLite*>(" "$name$));\n"); } else { format( " ::$proto_ns$::Arena* submessage_arena =\n" - " ::$proto_ns$::Arena::InternalHelper<" - "$type$>::GetOwningArena($name$);\n"); + " ::$proto_ns$::Arena::InternalGetOwningArena($name$);\n"); } format( " if (message_arena != submessage_arena) {\n" @@ -540,7 +562,7 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions( " message_arena, $name$, submessage_arena);\n" " }\n" " set_has_$name$();\n" - " $field_member$ = $name$;\n" + " $field$ = $name$;\n" " }\n" "$annotate_set$" " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" @@ -554,13 +576,14 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions( "inline $type$* $classname$::$release_name$() {\n" "$annotate_release$" " // @@protoc_insertion_point(field_release:$full_name$)\n" + "$type_reference_function$" " if (_internal_has_$name$()) {\n" " clear_has_$oneof_name$();\n" - " $type$* temp = $field_member$;\n" + " $type$* temp = $casted_member$;\n" " if (GetArenaForAllocation() != nullptr) {\n" " temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n" " }\n" - " $field_member$ = nullptr;\n" + " $field$ = nullptr;\n" " return temp;\n" " } else {\n" " return nullptr;\n" @@ -569,8 +592,9 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions( format( "inline const $type$& $classname$::_internal_$name$() const {\n" + "$type_reference_function$" " return _internal_has_$name$()\n" - " ? *$field_member$\n" + " ? $casted_member_const$\n" " : reinterpret_cast< $type$&>($type_default_instance$);\n" "}\n" "inline const $type$& $classname$::$name$() const {\n" @@ -582,10 +606,11 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions( "$annotate_release$" " // @@protoc_insertion_point(field_unsafe_arena_release" ":$full_name$)\n" + "$type_reference_function$" " if (_internal_has_$name$()) {\n" " clear_has_$oneof_name$();\n" - " $type$* temp = $field_member$;\n" - " $field_member$ = nullptr;\n" + " $type$* temp = $casted_member$;\n" + " $field$ = nullptr;\n" " return temp;\n" " } else {\n" " return nullptr;\n" @@ -598,21 +623,38 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions( // new value. " clear_$oneof_name$();\n" " if ($name$) {\n" - " set_has_$name$();\n" - " $field_member$ = $name$;\n" + " set_has_$name$();\n"); + if (implicit_weak_field_) { + format( + " $field$ = " + "reinterpret_cast<::$proto_ns$::MessageLite*>($name$);\n"); + } else { + format(" $field$ = $name$;\n"); + } + format( " }\n" "$annotate_set$" " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" "$full_name$)\n" "}\n" "inline $type$* $classname$::_internal_mutable_$name$() {\n" + "$type_reference_function$" " if (!_internal_has_$name$()) {\n" " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $field_member$ = CreateMaybeMessage< $type$ " - ">(GetArenaForAllocation());\n" + " set_has_$name$();\n"); + if (implicit_weak_field_) { + format( + " $field$ = " + "reinterpret_cast<::$proto_ns$::MessageLite*>(CreateMaybeMessage< " + "$type$ >(GetArenaForAllocation()));\n"); + } else { + format( + " $field$ = CreateMaybeMessage< $type$ " + ">(GetArenaForAllocation());\n"); + } + format( " }\n" - " return $field_member$;\n" + " return $casted_member$;\n" "}\n" "inline $type$* $classname$::mutable_$name$() {\n" " $type$* _msg = _internal_mutable_$name$();\n" @@ -629,7 +671,7 @@ void MessageOneofFieldGenerator::GenerateClearingCode( Formatter format(printer, variables_); format( "if (GetArenaForAllocation() == nullptr) {\n" - " delete $field_member$;\n" + " delete $field$;\n" "}\n"); } @@ -662,7 +704,7 @@ void MessageOneofFieldGenerator::GenerateIsInitialized( Formatter format(printer, variables_); format( "if (_internal_has_$name$()) {\n" - " if (!$field_member$->IsInitialized()) return false;\n" + " if (!$field$->IsInitialized()) return false;\n" "}\n"); } @@ -741,21 +783,21 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions( // TODO(dlj): move insertion points " // @@protoc_insertion_point(field_mutable:$full_name$)\n" "$type_reference_function$" - " return $name$_$weak$.Mutable(index);\n" + " return $field$$weak$.Mutable(index);\n" "}\n" "inline ::$proto_ns$::RepeatedPtrField< $type$ >*\n" "$classname$::mutable_$name$() {\n" "$annotate_mutable_list$" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" "$type_reference_function$" - " return &$name$_$weak$;\n" + " return &$field$$weak$;\n" "}\n"); if (options_.safe_boundary_check) { format( "inline const $type$& $classname$::_internal_$name$(int index) const " "{\n" - " return $name$_$weak$.InternalCheckedGet(index,\n" + " return $field$$weak$.InternalCheckedGet(index,\n" " reinterpret_cast<const $type$&>($type_default_instance$));\n" "}\n"); } else { @@ -763,7 +805,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions( "inline const $type$& $classname$::_internal_$name$(int index) const " "{\n" "$type_reference_function$" - " return $name$_$weak$.Get(index);\n" + " return $field$$weak$.Get(index);\n" "}\n"); } @@ -774,7 +816,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions( " return _internal_$name$(index);\n" "}\n" "inline $type$* $classname$::_internal_add_$name$() {\n" - " return $name$_$weak$.Add();\n" + " return $field$$weak$.Add();\n" "}\n" "inline $type$* $classname$::add_$name$() {\n" " $type$* _add = _internal_add_$name$();\n" @@ -789,7 +831,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions( "$annotate_list$" " // @@protoc_insertion_point(field_list:$full_name$)\n" "$type_reference_function$" - " return $name$_$weak$;\n" + " return $field$$weak$;\n" "}\n"); } @@ -798,7 +840,7 @@ void RepeatedMessageFieldGenerator::GenerateClearingCode( GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); Formatter format(printer, variables_); - format("$name$_.Clear();\n"); + format("$field$.Clear();\n"); } void RepeatedMessageFieldGenerator::GenerateMergingCode( @@ -806,7 +848,7 @@ void RepeatedMessageFieldGenerator::GenerateMergingCode( GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); Formatter format(printer, variables_); - format("$name$_.MergeFrom(from.$name$_);\n"); + format("_this->$field$.MergeFrom(from.$field$);\n"); } void RepeatedMessageFieldGenerator::GenerateSwappingCode( @@ -814,7 +856,7 @@ void RepeatedMessageFieldGenerator::GenerateSwappingCode( GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); Formatter format(printer, variables_); - format("$name$_.InternalSwap(&other->$name$_);\n"); + format("$field$.InternalSwap(&other->$field$);\n"); } void RepeatedMessageFieldGenerator::GenerateConstructorCode( @@ -822,6 +864,18 @@ void RepeatedMessageFieldGenerator::GenerateConstructorCode( // Not needed for repeated fields. } +void RepeatedMessageFieldGenerator::GenerateDestructorCode( + io::Printer* printer) const { + GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); + + Formatter format(printer, variables_); + if (implicit_weak_field_) { + format("$field$.~WeakRepeatedPtrField();\n"); + } else { + format("$field$.~RepeatedPtrField();\n"); + } +} + void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const { GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); @@ -829,23 +883,41 @@ void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray( Formatter format(printer, variables_); if (implicit_weak_field_) { format( - "for (auto it = this->$name$_.pointer_begin(),\n" - " end = this->$name$_.pointer_end(); it < end; ++it) {\n" - " target = stream->EnsureSpace(target);\n" - " target = ::$proto_ns$::internal::WireFormatLite::\n" - " InternalWrite$declared_type$($number$, **it, target, stream);\n" - "}\n"); + "for (auto it = this->$field$.pointer_begin(),\n" + " end = this->$field$.pointer_end(); it < end; ++it) {\n"); + if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) { + format( + " target = ::$proto_ns$::internal::WireFormatLite::\n" + " InternalWrite$declared_type$($number$, " + "**it, (**it).GetCachedSize(), target, stream);\n"); + } else { + format( + " target = stream->EnsureSpace(target);\n" + " target = ::$proto_ns$::internal::WireFormatLite::\n" + " InternalWrite$declared_type$($number$, **it, target, " + "stream);\n"); + } + format("}\n"); } else { format( - "for (unsigned int i = 0,\n" - " n = static_cast<unsigned int>(this->_internal_$name$_size()); i < " - "n; i++) " - "{\n" - " target = stream->EnsureSpace(target);\n" - " target = ::$proto_ns$::internal::WireFormatLite::\n" - " InternalWrite$declared_type$($number$, " - "this->_internal_$name$(i), target, stream);\n" - "}\n"); + "for (unsigned i = 0,\n" + " n = static_cast<unsigned>(this->_internal_$name$_size());" + " i < n; i++) {\n"); + if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) { + format( + " const auto& repfield = this->_internal_$name$(i);\n" + " target = ::$proto_ns$::internal::WireFormatLite::\n" + " InternalWrite$declared_type$($number$, " + "repfield, repfield.GetCachedSize(), target, stream);\n" + "}\n"); + } else { + format( + " target = stream->EnsureSpace(target);\n" + " target = ::$proto_ns$::internal::WireFormatLite::\n" + " InternalWrite$declared_type$($number$, " + "this->_internal_$name$(i), target, stream);\n" + "}\n"); + } } } @@ -856,7 +928,7 @@ void RepeatedMessageFieldGenerator::GenerateByteSize( Formatter format(printer, variables_); format( "total_size += $tag_size$UL * this->_internal_$name$_size();\n" - "for (const auto& msg : this->$name$_) {\n" + "for (const auto& msg : this->$field$) {\n" " total_size +=\n" " ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(msg);\n" "}\n"); @@ -871,21 +943,15 @@ void RepeatedMessageFieldGenerator::GenerateIsInitialized( Formatter format(printer, variables_); if (implicit_weak_field_) { format( - "if (!::$proto_ns$::internal::AllAreInitializedWeak($name$_.weak))\n" + "if (!::$proto_ns$::internal::AllAreInitializedWeak($field$.weak))\n" " return false;\n"); } else { format( - "if (!::$proto_ns$::internal::AllAreInitialized($name$_))\n" + "if (!::$proto_ns$::internal::AllAreInitialized($field$))\n" " return false;\n"); } } -void RepeatedMessageFieldGenerator::GenerateConstinitInitializer( - io::Printer* printer) const { - Formatter format(printer, variables_); - format("$name$_()"); -} - } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_message_field.h b/r5dev/thirdparty/protobuf/compiler/cpp/message_field.h similarity index 93% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_message_field.h rename to r5dev/thirdparty/protobuf/compiler/cpp/message_field.h index c9fa6fa9..65e5cf99 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_message_field.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/message_field.h @@ -37,8 +37,9 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/cpp/cpp_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> + +#include <thirdparty/protobuf/compiler/cpp/field.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> namespace google { namespace protobuf { @@ -66,13 +67,16 @@ class MessageFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const override; void GenerateSwappingCode(io::Printer* printer) const override; void GenerateDestructorCode(io::Printer* printer) const override; - void GenerateConstructorCode(io::Printer* printer) const override; + void GenerateConstructorCode(io::Printer* printer) const override {} void GenerateCopyConstructorCode(io::Printer* printer) const override; void GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; void GenerateIsInitialized(io::Printer* printer) const override; - void GenerateConstinitInitializer(io::Printer* printer) const override; + void GenerateConstexprAggregateInitializer( + io::Printer* printer) const override; + void GenerateAggregateInitializer(io::Printer* printer) const override; + void GenerateCopyAggregateInitializer(io::Printer* printer) const override; protected: const bool implicit_weak_field_; @@ -123,11 +127,11 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { void GenerateSwappingCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override; void GenerateCopyConstructorCode(io::Printer* printer) const override {} + void GenerateDestructorCode(io::Printer* printer) const override; void GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; void GenerateIsInitialized(io::Printer* printer) const override; - void GenerateConstinitInitializer(io::Printer* printer) const override; private: const bool implicit_weak_field_; diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_message_layout_helper.h b/r5dev/thirdparty/protobuf/compiler/cpp/message_layout_helper.h similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_message_layout_helper.h rename to r5dev/thirdparty/protobuf/compiler/cpp/message_layout_helper.h index 6d42d2a0..752c3db2 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_message_layout_helper.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/message_layout_helper.h @@ -35,8 +35,8 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_LAYOUT_HELPER_H__ #define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_LAYOUT_HELPER_H__ -#include <thirdparty/protobuf/compiler/cpp/cpp_options.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/compiler/cpp/options.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/message_size_unittest.cc b/r5dev/thirdparty/protobuf/compiler/cpp/message_size_unittest.cc new file mode 100644 index 00000000..f7359c9f --- /dev/null +++ b/r5dev/thirdparty/protobuf/compiler/cpp/message_size_unittest.cc @@ -0,0 +1,272 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <thirdparty/protobuf/unittest.pb.h> +#include <gmock/gmock.h> +#include <gtest/gtest.h> +#include <thirdparty/protobuf/descriptor.h> + +namespace google { +namespace protobuf { +namespace compiler { +namespace cpp { + +// Can't use an anonymous namespace here due to brokenness of Tru64 compiler. +namespace cpp_unittest { + + +#if !defined(GOOGLE_CHECK_MESSAGE_SIZE) +#define GOOGLE_CHECK_MESSAGE_SIZE(t, expected) +#endif + +// Mock structures to lock down the size of messages in a platform-independent +// way. The commented sizes only apply when build with clang x86_64. +struct MockMessageBase { + virtual ~MockMessageBase() = default; // 8 bytes vtable + void* internal_metadata; // 8 bytes +}; +GOOGLE_CHECK_MESSAGE_SIZE(MockMessageBase, 16); + +struct MockZeroFieldsBase : public MockMessageBase { + int cached_size; // 4 bytes + // + 4 bytes padding +}; +GOOGLE_CHECK_MESSAGE_SIZE(MockZeroFieldsBase, 24); + +struct MockExtensionSet { + void* arena; // 8 bytes + int16_t capacity; // 4 bytes + int16_t size; // 4 bytes + void* data; // 8 bytes +}; +GOOGLE_CHECK_MESSAGE_SIZE(MockExtensionSet, 24); + +struct MockRepeatedPtrField { + void* arena; // 8 bytes + int current_size; // 4 bytes + int total_size; // 4 bytes + void* data; // 8 bytes +}; +GOOGLE_CHECK_MESSAGE_SIZE(MockRepeatedPtrField, 24); + +struct MockRepeatedField { + int current_size; // 4 bytes + int total_size; // 4 bytes + void* data; // 8 bytes +}; +GOOGLE_CHECK_MESSAGE_SIZE(MockRepeatedField, 16); + +TEST(GeneratedMessageTest, MockSizes) { + // Consistency checks -- if these fail, the tests below will definitely fail. + GOOGLE_CHECK_EQ(sizeof(MessageLite), sizeof(MockMessageBase)); + GOOGLE_CHECK_EQ(sizeof(Message), sizeof(MockMessageBase)); + GOOGLE_CHECK_EQ(sizeof(internal::ZeroFieldsBase), sizeof(MockZeroFieldsBase)); + GOOGLE_CHECK_EQ(sizeof(internal::ExtensionSet), sizeof(MockExtensionSet)); + GOOGLE_CHECK_EQ(sizeof(RepeatedPtrField<std::string>), sizeof(MockRepeatedPtrField)); + GOOGLE_CHECK_EQ(sizeof(RepeatedField<int>), sizeof(MockRepeatedField)); +} + +TEST(GeneratedMessageTest, EmptyMessageSize) { + EXPECT_EQ(sizeof(protobuf_unittest::TestEmptyMessage), + sizeof(MockZeroFieldsBase)); +} + +TEST(GeneratedMessageTest, ReservedSize) { + EXPECT_EQ(sizeof(protobuf_unittest::TestReservedFields), + sizeof(MockZeroFieldsBase)); +} + +TEST(GeneratedMessageTest, EmptyMessageWithExtensionsSize) { + struct MockGenerated : public MockMessageBase { // 16 bytes + MockExtensionSet extensions; // 24 bytes + int cached_size; // 4 bytes + // + 4 bytes of padding + }; + GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 48); + EXPECT_EQ(sizeof(protobuf_unittest::TestEmptyMessageWithExtensions), + sizeof(MockGenerated)); +} + +TEST(GeneratedMessageTest, RecursiveMessageSize) { + struct MockGenerated : public MockMessageBase { // 16 bytes + int has_bits[1]; // 4 bytes + int cached_size; // 4 bytes + void* a; // 8 bytes + int32_t i; // 4 bytes + // + 4 bytes padding + }; + GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 40); + EXPECT_EQ(sizeof(protobuf_unittest::TestRecursiveMessage), + sizeof(MockGenerated)); +} + +TEST(GeneratedMessageTest, OneStringSize) { + struct MockGenerated : public MockMessageBase { // 16 bytes + int has_bits[1]; // 4 bytes + int cached_size; // 4 bytes + void* data; // 8 bytes + }; + GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 32); + EXPECT_EQ(sizeof(protobuf_unittest::OneString), sizeof(MockGenerated)); +} + +TEST(GeneratedMessageTest, MoreStringSize) { + struct MockGenerated : public MockMessageBase { // 16 bytes + int has_bits[1]; // 4 bytes + int cached_size; // 4 bytes + MockRepeatedPtrField data; // 24 bytes + }; + GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 48); + EXPECT_EQ(sizeof(protobuf_unittest::MoreString), sizeof(MockGenerated)); +} + +TEST(GeneratedMessageTest, Int32MessageSize) { + struct MockGenerated : public MockMessageBase { // 16 bytes + int has_bits[1]; // 4 bytes + int cached_size; // 4 bytes + int32_t data; // 4 bytes + // + 4 bytes padding + }; + GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 32); + EXPECT_EQ(sizeof(protobuf_unittest::Int32Message), sizeof(MockGenerated)); +} + +TEST(GeneratedMessageTest, Int64MessageSize) { + struct MockGenerated : public MockMessageBase { // 16 bytes + int has_bits[1]; // 4 bytes + int cached_size; // 4 bytes + int64_t data; // 8 bytes + }; + GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 32); + EXPECT_EQ(sizeof(protobuf_unittest::Int64Message), sizeof(MockGenerated)); +} + +TEST(GeneratedMessageTest, BoolMessageSize) { + struct MockGenerated : public MockMessageBase { // 16 bytes + int has_bits[1]; // 4 bytes + int cached_size; // 4 bytes + bool data; // 1 byte + // + 3 bytes padding + }; + GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 32); + EXPECT_EQ(sizeof(protobuf_unittest::BoolMessage), sizeof(MockGenerated)); +} + +TEST(GeneratedMessageTest, OneofSize) { + struct MockGenerated : public MockMessageBase { // 16 bytes + void* foo; // 8 bytes + int cached_size; // 4 bytes + uint32_t oneof_case[1]; // 4 bytes + }; + GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 32); + EXPECT_EQ(sizeof(protobuf_unittest::TestOneof), sizeof(MockGenerated)); +} + +TEST(GeneratedMessageTest, Oneof2Size) { + struct MockGenerated : public MockMessageBase { // 16 bytes + int has_bits[1]; // 4 bytes + int cached_size; // 4 bytes + void* baz_string; // 8 bytes + int32_t baz_int; // 4 bytes + // + 4 bytes padding + void* foo; // 8 bytes + void* bar; // 8 bytes + uint32_t oneof_case[2]; // 8 bytes + }; + GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 64); + EXPECT_EQ(sizeof(protobuf_unittest::TestOneof2), sizeof(MockGenerated)); +} + +TEST(GeneratedMessageTest, FieldOrderingsSize) { + struct MockGenerated : public MockMessageBase { // 16 bytes + int has_bits[1]; // 4 bytes + int cached_size; // 4 bytes + MockExtensionSet extensions; // 24 bytes + void* my_string; // 8 bytes + void* optional_nested_message; // 8 bytes + int64_t my_int; // 8 bytes + float my_float; // 4 bytes + // + 4 bytes of padding + }; + GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 80); + EXPECT_EQ(sizeof(protobuf_unittest::TestFieldOrderings), sizeof(MockGenerated)); +} + +TEST(GeneratedMessageTest, TestMessageSize) { + // We expect the message to contain (not in this order): + struct MockGenerated : public MockMessageBase { // 16 bytes + int has_bits[1]; // 4 bytes + int cached_size; // 4 bytes + void* m4; // 8 bytes + int64_t m2; // 8 bytes + bool m1; // 1 bytes + bool m3; // 1 bytes + // + 2 bytes padding + int m5; // 4 bytes + int64_t m6; // 8 bytes + }; + GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 56); + EXPECT_EQ(sizeof(protobuf_unittest::TestMessageSize), sizeof(MockGenerated)); +} + +TEST(GeneratedMessageTest, PackedTypesSize) { + struct MockGenerated : public MockMessageBase { // 16 bytes + MockRepeatedField packed_int32; // 16 bytes + int packed_int32_cached_byte_size; // 4 bytes + 4 bytes padding + MockRepeatedField packed_int64; // 16 bytes + int packed_int64_cached_byte_size; // 4 bytes + 4 bytes padding + MockRepeatedField packed_uint32; // 16 bytes + int packed_uint32_cached_byte_size; // 4 bytes + 4 bytes padding + MockRepeatedField packed_uint64; // 16 bytes + int packed_uint64_cached_byte_size; // 4 bytes + 4 bytes padding + MockRepeatedField packed_sint32; // 16 bytes + int packed_sint32_cached_byte_size; // 4 bytes + 4 bytes padding + MockRepeatedField packed_sint64; // 16 bytes + int packed_sint64_cached_byte_size; // 4 bytes + 4 bytes padding + MockRepeatedField packed_fixed32; // 16 bytes + MockRepeatedField packed_fixed64; // 16 bytes + MockRepeatedField packed_sfixed32; // 16 bytes + MockRepeatedField packed_sfixed64; // 16 bytes + MockRepeatedField packed_float; // 16 bytes + MockRepeatedField packed_double; // 16 bytes + MockRepeatedField packed_bool; // 16 bytes + MockRepeatedField packed_enum; // 16 bytes + int packed_enum_cached_byte_size; // 4 bytes + int cached_size; // 4 bytes + }; + GOOGLE_CHECK_MESSAGE_SIZE(MockGenerated, 16 * 15 + 8 * 6 + 8); + EXPECT_EQ(sizeof(protobuf_unittest::TestPackedTypes), sizeof(MockGenerated)); +} + +} // namespace cpp_unittest +} // namespace cpp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/metadata_test.cc b/r5dev/thirdparty/protobuf/compiler/cpp/metadata_test.cc index bc266409..2c6ce544 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/metadata_test.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/metadata_test.cc @@ -32,13 +32,13 @@ #include <thirdparty/protobuf/testing/file.h> #include <thirdparty/protobuf/testing/file.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_generator.h> -#include <thirdparty/protobuf/compiler/annotation_test_util.h> +#include <thirdparty/protobuf/compiler/cpp/generator.h> #include <thirdparty/protobuf/compiler/command_line_interface.h> #include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> +#include <thirdparty/protobuf/compiler/annotation_test_util.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> namespace google { namespace protobuf { @@ -76,12 +76,12 @@ class CppMetadataTest : public ::testing::Test { std::string output_base = TestTempDir() + "/" + StripProto(filename); - if (pb_cc != NULL) { + if (pb_cc != nullptr) { GOOGLE_CHECK_OK( File::GetContents(output_base + ".pb.cc", pb_cc, true)); } - if (pb_h != NULL && pb_h_info != NULL) { + if (pb_h != nullptr && pb_h_info != nullptr) { GOOGLE_CHECK_OK( File::GetContents(output_base + ".pb.h", pb_h, true)); if (!atu::DecodeMetadata(output_base + ".pb.h.meta", pb_h_info)) { @@ -89,7 +89,7 @@ class CppMetadataTest : public ::testing::Test { } } - if (proto_h != NULL && proto_h_info != NULL) { + if (proto_h != nullptr && proto_h_info != nullptr) { GOOGLE_CHECK_OK(File::GetContents(output_base + ".proto.h", proto_h, true)); if (!atu::DecodeMetadata(output_base + ".proto.h.meta", proto_h_info)) { @@ -112,15 +112,15 @@ TEST_F(CppMetadataTest, CapturesEnumNames) { GeneratedCodeInfo info; std::string pb_h; atu::AddFile("test.proto", kSmallTestFile); - EXPECT_TRUE( - CaptureMetadata("test.proto", &file, &pb_h, &info, NULL, NULL, NULL)); + EXPECT_TRUE(CaptureMetadata("test.proto", &file, &pb_h, &info, nullptr, + nullptr, nullptr)); EXPECT_EQ("Enum", file.enum_type(0).name()); std::vector<int> enum_path; enum_path.push_back(FileDescriptorProto::kEnumTypeFieldNumber); enum_path.push_back(0); const GeneratedCodeInfo::Annotation* enum_annotation = atu::FindAnnotationOnPath(info, "test.proto", enum_path); - EXPECT_TRUE(NULL != enum_annotation); + EXPECT_TRUE(nullptr != enum_annotation); EXPECT_TRUE(atu::AnnotationMatchesSubstring(pb_h, enum_annotation, "Enum")); } @@ -129,8 +129,8 @@ TEST_F(CppMetadataTest, AddsPragma) { GeneratedCodeInfo info; std::string pb_h; atu::AddFile("test.proto", kSmallTestFile); - EXPECT_TRUE( - CaptureMetadata("test.proto", &file, &pb_h, &info, NULL, NULL, NULL)); + EXPECT_TRUE(CaptureMetadata("test.proto", &file, &pb_h, &info, nullptr, + nullptr, nullptr)); EXPECT_TRUE(pb_h.find("#ifdef guard_name") != std::string::npos); EXPECT_TRUE(pb_h.find("#pragma pragma_name \"test.pb.h.meta\"") != std::string::npos); @@ -141,15 +141,15 @@ TEST_F(CppMetadataTest, CapturesMessageNames) { GeneratedCodeInfo info; std::string pb_h; atu::AddFile("test.proto", kSmallTestFile); - EXPECT_TRUE( - CaptureMetadata("test.proto", &file, &pb_h, &info, NULL, NULL, NULL)); + EXPECT_TRUE(CaptureMetadata("test.proto", &file, &pb_h, &info, nullptr, + nullptr, nullptr)); EXPECT_EQ("Message", file.message_type(0).name()); std::vector<int> message_path; message_path.push_back(FileDescriptorProto::kMessageTypeFieldNumber); message_path.push_back(0); const GeneratedCodeInfo::Annotation* message_annotation = atu::FindAnnotationOnPath(info, "test.proto", message_path); - EXPECT_TRUE(NULL != message_annotation); + EXPECT_TRUE(nullptr != message_annotation); EXPECT_TRUE( atu::AnnotationMatchesSubstring(pb_h, message_annotation, "Message")); } diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_move_unittest.cc b/r5dev/thirdparty/protobuf/compiler/cpp/move_unittest.cc similarity index 100% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_move_unittest.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/move_unittest.cc diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_names.h b/r5dev/thirdparty/protobuf/compiler/cpp/names.h similarity index 95% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_names.h rename to r5dev/thirdparty/protobuf/compiler/cpp/names.h index 2cd70bf7..4f9ab09d 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_names.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/names.h @@ -33,6 +33,7 @@ #include <string> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -50,9 +51,9 @@ namespace cpp { // // For example, if you had: // package foo.bar; -// message Baz { message Qux {} } +// message Baz { message Moo {} } // Then the non-qualified version would be: -// Baz_Qux +// Baz_Moo std::string ClassName(const Descriptor* descriptor); std::string ClassName(const EnumDescriptor* enum_descriptor); @@ -60,9 +61,9 @@ std::string ClassName(const EnumDescriptor* enum_descriptor); // // For example, if you had: // package foo.bar; -// message Baz { message Qux {} } -// Then the qualified ClassName for Qux would be: -// ::foo::bar::Baz_Qux +// message Baz { message Moo {} } +// Then the qualified ClassName for Moo would be: +// ::foo::bar::Baz_Moo std::string QualifiedClassName(const Descriptor* d); std::string QualifiedClassName(const EnumDescriptor* d); std::string QualifiedExtensionName(const FieldDescriptor* d); diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_options.h b/r5dev/thirdparty/protobuf/compiler/cpp/options.h similarity index 91% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_options.h rename to r5dev/thirdparty/protobuf/compiler/cpp/options.h index d0f16d03..5d935e9e 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_options.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/options.h @@ -57,34 +57,40 @@ struct FieldListenerOptions { // Generator options (see generator.cc for a description of each): struct Options { + const AccessInfoMap* access_info_map = nullptr; std::string dllexport_decl; - bool safe_boundary_check = false; - bool proto_h = false; - bool transitive_pb_h = true; - bool annotate_headers = false; - EnforceOptimizeMode enforce_mode = EnforceOptimizeMode::kNoEnforcement; - bool table_driven_parsing = false; - bool table_driven_serialization = false; - bool lite_implicit_weak_fields = false; - bool bootstrap = false; - bool opensource_runtime = false; - bool annotate_accessor = false; - bool unused_field_stripping = false; - bool profile_driven_inline_string = true; - bool force_inline_string = false; std::string runtime_include_base; - int num_cc_files = 0; std::string annotation_pragma_name; std::string annotation_guard_name; - const AccessInfoMap* access_info_map = nullptr; + FieldListenerOptions field_listener_options; + EnforceOptimizeMode enforce_mode = EnforceOptimizeMode::kNoEnforcement; enum { kTCTableNever, kTCTableGuarded, kTCTableAlways } tctable_mode = kTCTableNever; - FieldListenerOptions field_listener_options; - bool eagerly_verified_lazy = false; + int num_cc_files = 0; + bool safe_boundary_check = false; + bool proto_h = false; + bool transitive_pb_h = true; + bool annotate_headers = false; + bool lite_implicit_weak_fields = false; + bool bootstrap = false; + bool opensource_runtime = false; + bool annotate_accessor = false; + bool unused_field_stripping = false; + bool unverified_lazy_message_sets = false; + bool unverified_lazy = false; + bool profile_driven_inline_string = true; + bool message_owned_arena_trial = false; + bool force_split = false; +#ifdef PROTOBUF_STABLE_EXPERIMENTS + bool force_eagerly_verified_lazy = true; + bool force_inline_string = true; +#else // PROTOBUF_STABLE_EXPERIMENTS bool force_eagerly_verified_lazy = false; + bool force_inline_string = false; +#endif // !PROTOBUF_STABLE_EXPERIMENTS }; } // namespace cpp diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_padding_optimizer.cc b/r5dev/thirdparty/protobuf/compiler/cpp/padding_optimizer.cc similarity index 95% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_padding_optimizer.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/padding_optimizer.cc index 49b8ce72..94f5bf60 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_padding_optimizer.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/padding_optimizer.cc @@ -28,9 +28,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <thirdparty/protobuf/compiler/cpp/cpp_padding_optimizer.h> +#include <thirdparty/protobuf/compiler/cpp/padding_optimizer.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> namespace google { namespace protobuf { @@ -47,7 +47,7 @@ class FieldGroup { FieldGroup() : preferred_location_(0) {} // A group with a single field. - FieldGroup(float preferred_location, const FieldDescriptor* field) + FieldGroup(double preferred_location, const FieldDescriptor* field) : preferred_location_(preferred_location), fields_(1, field) {} // Append the fields in 'other' to this group. @@ -63,7 +63,7 @@ class FieldGroup { fields_.insert(fields_.end(), other.fields_.begin(), other.fields_.end()); } - void SetPreferredLocation(float location) { preferred_location_ = location; } + void SetPreferredLocation(double location) { preferred_location_ = location; } const std::vector<const FieldDescriptor*>& fields() const { return fields_; } // FieldGroup objects sort by their preferred location. @@ -77,7 +77,7 @@ class FieldGroup { // field in this group in the original ordering of fields. This is very // approximate, but should put this group close to where its member fields // originally went. - float preferred_location_; + double preferred_location_; std::vector<const FieldDescriptor*> fields_; // We rely on the default copy constructor and operator= so this type can be // used in a vector. @@ -203,7 +203,7 @@ void PaddingOptimizer::OptimizeLayout( field_group.SetPreferredLocation(-1); } else { // Move incomplete 4-byte block to the end. - field_group.SetPreferredLocation(fields->size() + 1); + field_group.SetPreferredLocation(double{FieldDescriptor::kMaxNumber}); } } aligned_to_8[f].push_back(field_group); diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_padding_optimizer.h b/r5dev/thirdparty/protobuf/compiler/cpp/padding_optimizer.h similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_padding_optimizer.h rename to r5dev/thirdparty/protobuf/compiler/cpp/padding_optimizer.h index 67f6588d..66f53860 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_padding_optimizer.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/padding_optimizer.h @@ -35,7 +35,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PADDING_OPTIMIZER_H__ #define GOOGLE_PROTOBUF_COMPILER_CPP_PADDING_OPTIMIZER_H__ -#include <thirdparty/protobuf/compiler/cpp/cpp_message_layout_helper.h> +#include <thirdparty/protobuf/compiler/cpp/message_layout_helper.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/parse_function_generator.cc b/r5dev/thirdparty/protobuf/compiler/cpp/parse_function_generator.cc new file mode 100644 index 00000000..2b7ecaf3 --- /dev/null +++ b/r5dev/thirdparty/protobuf/compiler/cpp/parse_function_generator.cc @@ -0,0 +1,1725 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <thirdparty/protobuf/compiler/cpp/parse_function_generator.h> + +#include <algorithm> +#include <limits> +#include <string> +#include <utility> + +#include <thirdparty/protobuf/wire_format.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> + +namespace google { +namespace protobuf { +namespace compiler { +namespace cpp { + +namespace { +using google::protobuf::internal::WireFormat; +using google::protobuf::internal::WireFormatLite; + +std::vector<const FieldDescriptor*> GetOrderedFields( + const Descriptor* descriptor, const Options& options) { + std::vector<const FieldDescriptor*> ordered_fields; + for (auto field : FieldRange(descriptor)) { + if (!IsFieldStripped(field, options)) { + ordered_fields.push_back(field); + } + } + std::sort(ordered_fields.begin(), ordered_fields.end(), + [](const FieldDescriptor* a, const FieldDescriptor* b) { + return a->number() < b->number(); + }); + return ordered_fields; +} + +bool HasInternalAccessors(const FieldOptions::CType ctype) { + return ctype == FieldOptions::STRING || ctype == FieldOptions::CORD; +} + +int TagSize(uint32_t field_number) { + if (field_number < 16) return 1; + GOOGLE_CHECK_LT(field_number, (1 << 14)) + << "coded tag for " << field_number << " too big for uint16_t"; + return 2; +} + +std::string FieldParseFunctionName( + const TailCallTableInfo::FieldEntryInfo& entry, const Options& options); + +bool IsFieldEligibleForFastParsing( + const TailCallTableInfo::FieldEntryInfo& entry, const Options& options, + MessageSCCAnalyzer* scc_analyzer) { + const auto* field = entry.field; + // Map, oneof, weak, and lazy fields are not handled on the fast path. + if (field->is_map() || field->real_containing_oneof() || + field->options().weak() || + IsImplicitWeakField(field, options, scc_analyzer) || + IsLazy(field, options, scc_analyzer)) { + return false; + } + + // We will check for a valid auxiliary index range later. However, we might + // want to change the value we check for inlined string fields. + int aux_idx = entry.aux_idx; + + switch (field->type()) { + case FieldDescriptor::TYPE_ENUM: + // If enum values are not validated at parse time, then this field can be + // handled on the fast path like an int32. + if (HasPreservingUnknownEnumSemantics(field)) { + break; + } + if (field->is_repeated() && field->is_packed()) { + return false; + } + break; + + // Some bytes fields can be handled on fast path. + case FieldDescriptor::TYPE_STRING: + case FieldDescriptor::TYPE_BYTES: + if (field->options().ctype() != FieldOptions::STRING) { + return false; + } + if (IsStringInlined(field, options)) { + GOOGLE_CHECK(!field->is_repeated()); + // For inlined strings, the donation state index is stored in the + // `aux_idx` field of the fast parsing info. We need to check the range + // of that value instead of the auxiliary index. + aux_idx = entry.inlined_string_idx; + } + break; + + default: + break; + } + + if (HasHasbit(field)) { + // The tailcall parser can only update the first 32 hasbits. Fields with + // has-bits beyond the first 32 are handled by mini parsing/fallback. + GOOGLE_CHECK_GE(entry.hasbit_idx, 0) << field->DebugString(); + if (entry.hasbit_idx >= 32) return false; + } + + // If the field needs auxiliary data, then the aux index is needed. This + // must fit in a uint8_t. + if (aux_idx > std::numeric_limits<uint8_t>::max()) { + return false; + } + + // The largest tag that can be read by the tailcall parser is two bytes + // when varint-coded. This allows 14 bits for the numeric tag value: + // byte 0 byte 1 + // 1nnnnttt 0nnnnnnn + // ^^^^^^^ ^^^^^^^ + if (field->number() >= 1 << 11) return false; + + return true; +} + +std::vector<TailCallTableInfo::FastFieldInfo> SplitFastFieldsForSize( + const std::vector<TailCallTableInfo::FieldEntryInfo>& field_entries, + int table_size_log2, const Options& options, + MessageSCCAnalyzer* scc_analyzer) { + std::vector<TailCallTableInfo::FastFieldInfo> result(1 << table_size_log2); + const uint32_t idx_mask = result.size() - 1; + + for (const auto& entry : field_entries) { + if (!IsFieldEligibleForFastParsing(entry, options, scc_analyzer)) { + continue; + } + + const auto* field = entry.field; + uint32_t tag = WireFormat::MakeTag(field); + + // Construct the varint-coded tag. If it is more than 7 bits, we need to + // shift the high bits and add a continue bit. + if (uint32_t hibits = tag & 0xFFFFFF80) { + tag = tag + hibits + 128; // tag = lobits + 2*hibits + 128 + } + + // The field index is determined by the low bits of the field number, where + // the table size determines the width of the mask. The largest table + // supported is 32 entries. The parse loop uses these bits directly, so that + // the dispatch does not require arithmetic: + // byte 0 byte 1 + // tag: 1nnnnttt 0nnnnnnn + // ^^^^^ + // idx (table_size_log2=5) + // This means that any field number that does not fit in the lower 4 bits + // will always have the top bit of its table index asserted. + const uint32_t fast_idx = (tag >> 3) & idx_mask; + + TailCallTableInfo::FastFieldInfo& info = result[fast_idx]; + if (info.field != nullptr) { + // This field entry is already filled. + continue; + } + + // Fill in this field's entry: + GOOGLE_CHECK(info.func_name.empty()) << info.func_name; + info.func_name = FieldParseFunctionName(entry, options); + info.field = field; + info.coded_tag = tag; + // If this field does not have presence, then it can set an out-of-bounds + // bit (tailcall parsing uses a uint64_t for hasbits, but only stores 32). + info.hasbit_idx = HasHasbit(field) ? entry.hasbit_idx : 63; + if (IsStringInlined(field, options)) { + GOOGLE_CHECK(!field->is_repeated()); + info.aux_idx = static_cast<uint8_t>(entry.inlined_string_idx); + } else { + info.aux_idx = static_cast<uint8_t>(entry.aux_idx); + } + } + return result; +} + +// Filter out fields that will be handled by mini parsing. +std::vector<const FieldDescriptor*> FilterMiniParsedFields( + const std::vector<const FieldDescriptor*>& fields, const Options& options, + MessageSCCAnalyzer* scc_analyzer) { + std::vector<const FieldDescriptor*> generated_fallback_fields; + + for (const auto* field : fields) { + bool handled = false; + switch (field->type()) { + case FieldDescriptor::TYPE_DOUBLE: + case FieldDescriptor::TYPE_FLOAT: + case FieldDescriptor::TYPE_FIXED32: + case FieldDescriptor::TYPE_SFIXED32: + case FieldDescriptor::TYPE_FIXED64: + case FieldDescriptor::TYPE_SFIXED64: + case FieldDescriptor::TYPE_BOOL: + case FieldDescriptor::TYPE_UINT32: + case FieldDescriptor::TYPE_SINT32: + case FieldDescriptor::TYPE_INT32: + case FieldDescriptor::TYPE_UINT64: + case FieldDescriptor::TYPE_SINT64: + case FieldDescriptor::TYPE_INT64: + // These are handled by MiniParse, so we don't need any generated + // fallback code. + handled = true; + break; + + case FieldDescriptor::TYPE_ENUM: + if (field->is_repeated() && !HasPreservingUnknownEnumSemantics(field)) { + // TODO(b/206890171): handle packed repeated closed enums + // Non-packed repeated can be handled using tables, but we still + // need to generate fallback code for all repeated enums in order to + // handle packed encoding. This is because of the lite/full split + // when handling invalid enum values in a packed field. + handled = false; + } else { + handled = true; + } + break; + + case FieldDescriptor::TYPE_BYTES: + case FieldDescriptor::TYPE_STRING: + if (IsStringInlined(field, options)) { + // TODO(b/198211897): support InilnedStringField. + handled = false; + } else { + handled = true; + } + break; + + case FieldDescriptor::TYPE_MESSAGE: + case FieldDescriptor::TYPE_GROUP: + // TODO(b/210762816): support remaining field types. + if (field->is_map() || IsWeak(field, options) || + IsImplicitWeakField(field, options, scc_analyzer) || + IsLazy(field, options, scc_analyzer)) { + handled = false; + } else { + handled = true; + } + break; + + default: + handled = false; + break; + } + if (!handled) generated_fallback_fields.push_back(field); + } + + return generated_fallback_fields; +} + +} // namespace + +TailCallTableInfo::TailCallTableInfo( + const Descriptor* descriptor, const Options& options, + const std::vector<const FieldDescriptor*>& ordered_fields, + const std::vector<int>& has_bit_indices, + const std::vector<int>& inlined_string_indices, + MessageSCCAnalyzer* scc_analyzer) { + int oneof_count = descriptor->real_oneof_decl_count(); + // If this message has any oneof fields, store the case offset in the first + // auxiliary entry. + if (oneof_count > 0) { + GOOGLE_LOG_IF(DFATAL, ordered_fields.empty()) + << "Invalid message: " << descriptor->full_name() << " has " + << oneof_count << " oneof declarations, but no fields"; + aux_entries.push_back(StrCat("_fl::Offset{offsetof(", + ClassName(descriptor), + ", _impl_._oneof_case_)}")); + } + + // If this message has any inlined string fields, store the donation state + // offset in the second auxiliary entry. + if (!inlined_string_indices.empty()) { + aux_entries.resize(2); // pad if necessary + aux_entries[1] = + StrCat("_fl::Offset{offsetof(", ClassName(descriptor), + ", _impl_._inlined_string_donated_)}"); + } + + // Fill in mini table entries. + for (const FieldDescriptor* field : ordered_fields) { + field_entries.push_back( + {field, (HasHasbit(field) ? has_bit_indices[field->index()] : -1)}); + auto& entry = field_entries.back(); + + if (field->type() == FieldDescriptor::TYPE_MESSAGE || + field->type() == FieldDescriptor::TYPE_GROUP) { + // Message-typed fields have a FieldAux with the default instance pointer. + if (field->is_map()) { + // TODO(b/205904770): generate aux entries for maps + } else if (IsWeak(field, options)) { + // Don't generate anything for weak fields. They are handled by the + // generated fallback. + } else if (IsImplicitWeakField(field, options, scc_analyzer)) { + // Implicit weak fields don't need to store a default instance pointer. + } else if (IsLazy(field, options, scc_analyzer)) { + // Lazy fields are handled by the generated fallback function. + } else { + field_entries.back().aux_idx = aux_entries.size(); + const Descriptor* field_type = field->message_type(); + aux_entries.push_back(StrCat( + "reinterpret_cast<const ", QualifiedClassName(field_type, options), + "*>(&", QualifiedDefaultInstanceName(field_type, options), ")")); + } + } else if (field->type() == FieldDescriptor::TYPE_ENUM && + !HasPreservingUnknownEnumSemantics(field)) { + // Enum fields which preserve unknown values (proto3 behavior) are + // effectively int32 fields with respect to parsing -- i.e., the value + // does not need to be validated at parse time. + // + // Enum fields which do not preserve unknown values (proto2 behavior) use + // a FieldAux to store validation information. If the enum values are + // sequential (and within a range we can represent), then the FieldAux + // entry represents the range using the minimum value (which must fit in + // an int16_t) and count (a uint16_t). Otherwise, the entry holds a + // pointer to the generated Name_IsValid function. + + entry.aux_idx = aux_entries.size(); + const EnumDescriptor* enum_type = field->enum_type(); + GOOGLE_CHECK_GT(enum_type->value_count(), 0) << enum_type->DebugString(); + + // Check if the enum values are a single, contiguous range. + std::vector<int> enum_values; + for (int i = 0, N = enum_type->value_count(); i < N; ++i) { + enum_values.push_back(enum_type->value(i)->number()); + } + auto values_begin = enum_values.begin(); + auto values_end = enum_values.end(); + std::sort(values_begin, values_end); + enum_values.erase(std::unique(values_begin, values_end), values_end); + + if (enum_values.back() - enum_values[0] == enum_values.size() - 1 && + enum_values[0] >= std::numeric_limits<int16_t>::min() && + enum_values[0] <= std::numeric_limits<int16_t>::max() && + enum_values.size() <= std::numeric_limits<uint16_t>::max()) { + entry.is_enum_range = true; + aux_entries.push_back( + StrCat(enum_values[0], ", ", enum_values.size())); + } else { + entry.is_enum_range = false; + aux_entries.push_back( + StrCat(QualifiedClassName(enum_type, options), "_IsValid")); + } + } else if ((field->type() == FieldDescriptor::TYPE_STRING || + field->type() == FieldDescriptor::TYPE_BYTES) && + IsStringInlined(field, options)) { + GOOGLE_CHECK(!field->is_repeated()); + // Inlined strings have an extra marker to represent their donation state. + int idx = inlined_string_indices[field->index()]; + // For mini parsing, the donation state index is stored as an `offset` + // auxiliary entry. + entry.aux_idx = aux_entries.size(); + aux_entries.push_back(StrCat("_fl::Offset{", idx, "}")); + // For fast table parsing, the donation state index is stored instead of + // the aux_idx (this will limit the range to 8 bits). + entry.inlined_string_idx = idx; + } + } + + // Choose the smallest fast table that covers the maximum number of fields. + table_size_log2 = 0; // fallback value + int num_fast_fields = -1; + for (int try_size_log2 : {0, 1, 2, 3, 4, 5}) { + size_t try_size = 1 << try_size_log2; + auto split_fields = SplitFastFieldsForSize(field_entries, try_size_log2, + options, scc_analyzer); + GOOGLE_CHECK_EQ(split_fields.size(), try_size); + int try_num_fast_fields = 0; + for (const auto& info : split_fields) { + if (info.field != nullptr) ++try_num_fast_fields; + } + // Use this size if (and only if) it covers more fields. + if (try_num_fast_fields > num_fast_fields) { + fast_path_fields = std::move(split_fields); + table_size_log2 = try_size_log2; + num_fast_fields = try_num_fast_fields; + } + // The largest table we allow has the same number of entries as the message + // has fields, rounded up to the next power of 2 (e.g., a message with 5 + // fields can have a fast table of size 8). A larger table *might* cover + // more fields in certain cases, but a larger table in that case would have + // mostly empty entries; so, we cap the size to avoid pathologically sparse + // tables. + if (try_size > ordered_fields.size()) { + break; + } + } + + // Filter out fields that are handled by MiniParse. We don't need to generate + // a fallback for these, which saves code size. + fallback_fields = FilterMiniParsedFields(ordered_fields, options, + scc_analyzer); + + // If there are no fallback fields, and at most one extension range, the + // parser can use a generic fallback function. Otherwise, a message-specific + // fallback routine is needed. + use_generated_fallback = + !fallback_fields.empty() || descriptor->extension_range_count() > 1; +} + +ParseFunctionGenerator::ParseFunctionGenerator( + const Descriptor* descriptor, int max_has_bit_index, + const std::vector<int>& has_bit_indices, + const std::vector<int>& inlined_string_indices, const Options& options, + MessageSCCAnalyzer* scc_analyzer, + const std::map<std::string, std::string>& vars) + : descriptor_(descriptor), + scc_analyzer_(scc_analyzer), + options_(options), + variables_(vars), + inlined_string_indices_(inlined_string_indices), + ordered_fields_(GetOrderedFields(descriptor_, options_)), + num_hasbits_(max_has_bit_index) { + if (should_generate_tctable()) { + tc_table_info_.reset(new TailCallTableInfo( + descriptor_, options_, ordered_fields_, has_bit_indices, + inlined_string_indices, scc_analyzer)); + } + SetCommonVars(options_, &variables_); + SetCommonMessageDataVariables(descriptor_, &variables_); + SetUnknownFieldsVariable(descriptor_, options_, &variables_); + variables_["classname"] = ClassName(descriptor, false); +} + +void ParseFunctionGenerator::GenerateMethodDecls(io::Printer* printer) { + Formatter format(printer, variables_); + if (should_generate_tctable()) { + format.Outdent(); + if (should_generate_guarded_tctable()) { + format("#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); + } + format( + " private:\n" + " static const char* Tct_ParseFallback(PROTOBUF_TC_PARAM_DECL);\n" + " public:\n"); + if (should_generate_guarded_tctable()) { + format("#endif\n"); + } + format.Indent(); + } + format( + "const char* _InternalParse(const char* ptr, " + "::$proto_ns$::internal::ParseContext* ctx) final;\n"); +} + +void ParseFunctionGenerator::GenerateMethodImpls(io::Printer* printer) { + Formatter format(printer, variables_); + bool need_parse_function = true; + if (descriptor_->options().message_set_wire_format()) { + // Special-case MessageSet. + need_parse_function = false; + format( + "const char* $classname$::_InternalParse(const char* ptr,\n" + " ::_pbi::ParseContext* ctx) {\n" + "$annotate_deserialize$"); + if (!options_.unverified_lazy_message_sets && + ShouldVerify(descriptor_, options_, scc_analyzer_)) { + format( + " ctx->set_lazy_eager_verify_func(&$classname$::InternalVerify);\n"); + } + format( + " return $extensions$.ParseMessageSet(ptr, \n" + " internal_default_instance(), &_internal_metadata_, ctx);\n" + "}\n"); + } + if (!should_generate_tctable()) { + if (need_parse_function) { + GenerateLoopingParseFunction(format); + } + return; + } + if (should_generate_guarded_tctable()) { + format("#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n\n"); + } + if (need_parse_function) { + GenerateTailcallParseFunction(format); + } + if (tc_table_info_->use_generated_fallback) { + GenerateTailcallFallbackFunction(format); + } + if (should_generate_guarded_tctable()) { + if (need_parse_function) { + format("\n#else // PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n\n"); + GenerateLoopingParseFunction(format); + } + format("\n#endif // PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); + } +} + +bool ParseFunctionGenerator::should_generate_tctable() const { + if (options_.tctable_mode == Options::kTCTableNever) { + return false; + } + return true; +} + +void ParseFunctionGenerator::GenerateTailcallParseFunction(Formatter& format) { + GOOGLE_CHECK(should_generate_tctable()); + + // Generate an `_InternalParse` that starts the tail-calling loop. + format( + "const char* $classname$::_InternalParse(\n" + " const char* ptr, ::_pbi::ParseContext* ctx) {\n" + "$annotate_deserialize$" + " ptr = ::_pbi::TcParser::ParseLoop(this, ptr, ctx, " + "&_table_.header);\n"); + format( + " return ptr;\n" + "}\n\n"); +} + +void ParseFunctionGenerator::GenerateTailcallFallbackFunction( + Formatter& format) { + GOOGLE_CHECK(should_generate_tctable()); + format( + "const char* $classname$::Tct_ParseFallback(PROTOBUF_TC_PARAM_DECL) {\n" + "#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) return nullptr\n"); + format.Indent(); + format("auto* typed_msg = static_cast<$classname$*>(msg);\n"); + + if (num_hasbits_ > 0) { + // Sync hasbits + format("typed_msg->_impl_._has_bits_[0] = hasbits;\n"); + } + format("uint32_t tag = data.tag();\n"); + + format.Set("msg", "typed_msg->"); + format.Set("this", "typed_msg"); + format.Set("has_bits", "typed_msg->_impl_._has_bits_"); + format.Set("next_tag", "goto next_tag"); + GenerateParseIterationBody(format, descriptor_, + tc_table_info_->fallback_fields); + + format.Outdent(); + format( + "next_tag:\n" + "message_done:\n" + " return ptr;\n" + "#undef CHK_\n" + "}\n"); +} + +struct SkipEntry16 { + uint16_t skipmap; + uint16_t field_entry_offset; +}; +struct SkipEntryBlock { + uint32_t first_fnum; + std::vector<SkipEntry16> entries; +}; +struct NumToEntryTable { + uint32_t skipmap32; // for fields #1 - #32 + std::vector<SkipEntryBlock> blocks; + // Compute the number of uint16_t required to represent this table. + int size16() const { + int size = 2; // for the termination field# + for (const auto& block : blocks) { + // 2 for the field#, 1 for a count of skip entries, 2 for each entry. + size += 3 + block.entries.size() * 2; + } + return size; + } +}; + +static NumToEntryTable MakeNumToEntryTable( + const std::vector<const FieldDescriptor*>& field_descriptors); + +void ParseFunctionGenerator::GenerateDataDecls(io::Printer* printer) { + if (!should_generate_tctable()) { + return; + } + Formatter format(printer, variables_); + if (should_generate_guarded_tctable()) { + format.Outdent(); + format("#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); + format.Indent(); + } + auto field_num_to_entry_table = MakeNumToEntryTable(ordered_fields_); + format( + "static const ::$proto_ns$::internal::" + "TcParseTable<$1$, $2$, $3$, $4$, $5$> _table_;\n", + tc_table_info_->table_size_log2, ordered_fields_.size(), + tc_table_info_->aux_entries.size(), CalculateFieldNamesSize(), + field_num_to_entry_table.size16()); + if (should_generate_guarded_tctable()) { + format.Outdent(); + format("#endif // PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); + format.Indent(); + } +} + +void ParseFunctionGenerator::GenerateDataDefinitions(io::Printer* printer) { + if (!should_generate_tctable()) { + return; + } + Formatter format(printer, variables_); + if (should_generate_guarded_tctable()) { + format("#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); + } + GenerateTailCallTable(format); + if (should_generate_guarded_tctable()) { + format("#endif // PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED\n"); + } +} + +void ParseFunctionGenerator::GenerateLoopingParseFunction(Formatter& format) { + format( + "const char* $classname$::_InternalParse(const char* ptr, " + "::_pbi::ParseContext* ctx) {\n" + "$annotate_deserialize$" + "#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure\n"); + format.Indent(); + format.Set("msg", ""); + format.Set("this", "this"); + int hasbits_size = 0; + if (num_hasbits_ > 0) { + hasbits_size = (num_hasbits_ + 31) / 32; + } + // For now only optimize small hasbits. + if (hasbits_size != 1) hasbits_size = 0; + if (hasbits_size) { + format("_Internal::HasBits has_bits{};\n"); + format.Set("has_bits", "has_bits"); + } else { + format.Set("has_bits", "_impl_._has_bits_"); + } + format.Set("next_tag", "continue"); + format("while (!ctx->Done(&ptr)) {\n"); + format.Indent(); + + format( + "uint32_t tag;\n" + "ptr = ::_pbi::ReadTag(ptr, &tag);\n"); + GenerateParseIterationBody(format, descriptor_, ordered_fields_); + + format.Outdent(); + format("} // while\n"); + + format.Outdent(); + format("message_done:\n"); + if (hasbits_size) format(" _impl_._has_bits_.Or(has_bits);\n"); + + format( + " return ptr;\n" + "failure:\n" + " ptr = nullptr;\n" + " goto message_done;\n" + "#undef CHK_\n" + "}\n"); +} + +static NumToEntryTable MakeNumToEntryTable( + const std::vector<const FieldDescriptor*>& field_descriptors) { + NumToEntryTable num_to_entry_table; + num_to_entry_table.skipmap32 = static_cast<uint32_t>(-1); + + // skip_entry_block is the current block of SkipEntries that we're + // appending to. cur_block_first_fnum is the number of the first + // field represented by the block. + uint16_t field_entry_index = 0; + uint16_t N = field_descriptors.size(); + // First, handle field numbers 1-32, which affect only the initial + // skipmap32 and don't generate additional skip-entry blocks. + for (; field_entry_index != N; ++field_entry_index) { + auto* field_descriptor = field_descriptors[field_entry_index]; + if (field_descriptor->number() > 32) break; + auto skipmap32_index = field_descriptor->number() - 1; + num_to_entry_table.skipmap32 -= 1 << skipmap32_index; + } + // If all the field numbers were less than or equal to 32, we will have + // no further entries to process, and we are already done. + if (field_entry_index == N) return num_to_entry_table; + + SkipEntryBlock* block = nullptr; + bool start_new_block = true; + // To determine sparseness, track the field number corresponding to + // the start of the most recent skip entry. + uint32_t last_skip_entry_start = 0; + for (; field_entry_index != N; ++field_entry_index) { + auto* field_descriptor = field_descriptors[field_entry_index]; + uint32_t fnum = field_descriptor->number(); + GOOGLE_CHECK_GT(fnum, last_skip_entry_start); + if (start_new_block == false) { + // If the next field number is within 15 of the last_skip_entry_start, we + // continue writing just to that entry. If it's between 16 and 31 more, + // then we just extend the current block by one. If it's more than 31 + // more, we have to add empty skip entries in order to continue using the + // existing block. Obviously it's just 32 more, it doesn't make sense to + // start a whole new block, since new blocks mean having to write out + // their starting field number, which is 32 bits, as well as the size of + // the additional block, which is 16... while an empty SkipEntry16 only + // costs 32 bits. So if it was 48 more, it's a slight space win; we save + // 16 bits, but probably at the cost of slower run time. We're choosing + // 96 for now. + if (fnum - last_skip_entry_start > 96) start_new_block = true; + } + if (start_new_block) { + num_to_entry_table.blocks.push_back(SkipEntryBlock{fnum}); + block = &num_to_entry_table.blocks.back(); + start_new_block = false; + } + + auto skip_entry_num = (fnum - block->first_fnum) / 16; + auto skip_entry_index = (fnum - block->first_fnum) % 16; + while (skip_entry_num >= block->entries.size()) + block->entries.push_back({0xFFFF, field_entry_index}); + block->entries[skip_entry_num].skipmap -= 1 << (skip_entry_index); + + last_skip_entry_start = fnum - skip_entry_index; + } + return num_to_entry_table; +} + +void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) { + GOOGLE_CHECK(should_generate_tctable()); + // All entries without a fast-path parsing function need a fallback. + std::string fallback; + if (tc_table_info_->use_generated_fallback) { + fallback = ClassName(descriptor_) + "::Tct_ParseFallback"; + } else { + fallback = "::_pbi::TcParser::GenericFallback"; + if (GetOptimizeFor(descriptor_->file(), options_) == + FileOptions::LITE_RUNTIME) { + fallback += "Lite"; + } + } + + // For simplicity and speed, the table is not covering all proto + // configurations. This model uses a fallback to cover all situations that + // the table can't accommodate, together with unknown fields or extensions. + // These are number of fields over 32, fields with 3 or more tag bytes, + // maps, weak fields, lazy, more than 1 extension range. In the cases + // the table is sufficient we can use a generic routine, that just handles + // unknown fields and potentially an extension range. + auto field_num_to_entry_table = MakeNumToEntryTable(ordered_fields_); + format( + "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1\n" + "const ::_pbi::TcParseTable<$1$, $2$, $3$, $4$, $5$> " + "$classname$::_table_ = " + "{\n", + tc_table_info_->table_size_log2, ordered_fields_.size(), + tc_table_info_->aux_entries.size(), CalculateFieldNamesSize(), + field_num_to_entry_table.size16()); + { + auto table_scope = format.ScopedIndent(); + format("{\n"); + { + auto header_scope = format.ScopedIndent(); + if (num_hasbits_ > 0 || IsMapEntryMessage(descriptor_)) { + format("PROTOBUF_FIELD_OFFSET($classname$, _impl_._has_bits_),\n"); + } else { + format("0, // no _has_bits_\n"); + } + if (descriptor_->extension_range_count() == 1) { + format( + "PROTOBUF_FIELD_OFFSET($classname$, $extensions$),\n" + "$1$, $2$, // extension_range_{low,high}\n", + descriptor_->extension_range(0)->start, + descriptor_->extension_range(0)->end); + } else { + format("0, 0, 0, // no _extensions_\n"); + } + format("$1$, $2$, // max_field_number, fast_idx_mask\n", + (ordered_fields_.empty() ? 0 : ordered_fields_.back()->number()), + (((1 << tc_table_info_->table_size_log2) - 1) << 3)); + format( + "offsetof(decltype(_table_), field_lookup_table),\n" + "$1$, // skipmap\n", + field_num_to_entry_table.skipmap32); + if (ordered_fields_.empty()) { + format( + "offsetof(decltype(_table_), field_names), // no field_entries\n"); + } else { + format("offsetof(decltype(_table_), field_entries),\n"); + } + + format( + "$1$, // num_field_entries\n" + "$2$, // num_aux_entries\n", + ordered_fields_.size(), tc_table_info_->aux_entries.size()); + if (tc_table_info_->aux_entries.empty()) { + format( + "offsetof(decltype(_table_), field_names), // no aux_entries\n"); + } else { + format("offsetof(decltype(_table_), aux_entries),\n"); + } + format( + "&$1$._instance,\n" + "$2$, // fallback\n" + "", + DefaultInstanceName(descriptor_, options_), fallback); + } + format("}, {{\n"); + { + // fast_entries[] + auto fast_scope = format.ScopedIndent(); + GenerateFastFieldEntries(format); + } + format("}}, {{\n"); + { + // field_lookup_table[] + auto field_lookup_scope = format.ScopedIndent(); + int line_entries = 0; + for (int i = 0, N = field_num_to_entry_table.blocks.size(); i < N; ++i) { + SkipEntryBlock& entry_block = field_num_to_entry_table.blocks[i]; + format("$1$, $2$, $3$,\n", entry_block.first_fnum & 65535, + entry_block.first_fnum / 65536, entry_block.entries.size()); + for (auto se16 : entry_block.entries) { + if (line_entries == 0) { + format("$1$, $2$,", se16.skipmap, se16.field_entry_offset); + ++line_entries; + } else if (line_entries < 5) { + format(" $1$, $2$,", se16.skipmap, se16.field_entry_offset); + ++line_entries; + } else { + format(" $1$, $2$,\n", se16.skipmap, se16.field_entry_offset); + line_entries = 0; + } + } + } + if (line_entries) format("\n"); + format("65535, 65535\n"); + } + if (ordered_fields_.empty()) { + GOOGLE_LOG_IF(DFATAL, !tc_table_info_->aux_entries.empty()) + << "Invalid message: " << descriptor_->full_name() << " has " + << tc_table_info_->aux_entries.size() + << " auxiliary field entries, but no fields"; + format( + "}},\n" + "// no field_entries, or aux_entries\n" + "{{\n"); + } else { + format("}}, {{\n"); + { + // field_entries[] + auto field_scope = format.ScopedIndent(); + GenerateFieldEntries(format); + } + if (tc_table_info_->aux_entries.empty()) { + format( + "}},\n" + "// no aux_entries\n" + "{{\n"); + } else { + format("}}, {{\n"); + { + // aux_entries[] + auto aux_scope = format.ScopedIndent(); + for (const std::string& aux_entry : tc_table_info_->aux_entries) { + format("{$1$},\n", aux_entry); + } + } + format("}}, {{\n"); + } + } // ordered_fields_.empty() + { + // field_names[] + auto field_name_scope = format.ScopedIndent(); + GenerateFieldNames(format); + } + format("}},\n"); + } + format("};\n\n"); // _table_ +} + +void ParseFunctionGenerator::GenerateFastFieldEntries(Formatter& format) { + for (const auto& info : tc_table_info_->fast_path_fields) { + if (info.field != nullptr) { + PrintFieldComment(format, info.field); + } + if (info.func_name.empty()) { + format("{::_pbi::TcParser::MiniParse, {}},\n"); + } else { + bool cold = ShouldSplit(info.field, options_); + format( + "{$1$,\n" + " {$2$, $3$, $4$, PROTOBUF_FIELD_OFFSET($classname$$5$, $6$)}},\n", + info.func_name, info.coded_tag, info.hasbit_idx, info.aux_idx, + cold ? "::Impl_::Split" : "", + cold ? FieldName(info.field) + "_" + : FieldMemberName(info.field, /*cold=*/false)); + } + } +} + +static void FormatFieldKind(Formatter& format, + const TailCallTableInfo::FieldEntryInfo& entry, + const Options& options, + MessageSCCAnalyzer* scc_analyzer) { + const FieldDescriptor* field = entry.field; + // Spell the field kind in proto language declaration order, starting with + // cardinality: + format("(::_fl::kFc"); + if (HasHasbit(field)) { + format("Optional"); + } else if (field->is_repeated()) { + format("Repeated"); + } else if (field->real_containing_oneof()) { + format("Oneof"); + } else { + format("Singular"); + } + + // The rest of the type uses convenience aliases: + format(" | ::_fl::k"); + if (field->is_repeated() && field->is_packed()) { + format("Packed"); + } + switch (field->type()) { + case FieldDescriptor::TYPE_DOUBLE: + format("Double"); + break; + case FieldDescriptor::TYPE_FLOAT: + format("Float"); + break; + case FieldDescriptor::TYPE_FIXED32: + format("Fixed32"); + break; + case FieldDescriptor::TYPE_SFIXED32: + format("SFixed32"); + break; + case FieldDescriptor::TYPE_FIXED64: + format("Fixed64"); + break; + case FieldDescriptor::TYPE_SFIXED64: + format("SFixed64"); + break; + case FieldDescriptor::TYPE_BOOL: + format("Bool"); + break; + case FieldDescriptor::TYPE_ENUM: + if (HasPreservingUnknownEnumSemantics(field)) { + // No validation is required. + format("OpenEnum"); + } else if (entry.is_enum_range) { + // Validation is done by range check (start/length in FieldAux). + format("EnumRange"); + } else { + // Validation uses the generated _IsValid function. + format("Enum"); + } + break; + case FieldDescriptor::TYPE_UINT32: + format("UInt32"); + break; + case FieldDescriptor::TYPE_SINT32: + format("SInt32"); + break; + case FieldDescriptor::TYPE_INT32: + format("Int32"); + break; + case FieldDescriptor::TYPE_UINT64: + format("UInt64"); + break; + case FieldDescriptor::TYPE_SINT64: + format("SInt64"); + break; + case FieldDescriptor::TYPE_INT64: + format("Int64"); + break; + + case FieldDescriptor::TYPE_BYTES: + format("Bytes"); + break; + case FieldDescriptor::TYPE_STRING: { + auto mode = GetUtf8CheckMode(field, options); + switch (mode) { + case Utf8CheckMode::kStrict: + format("Utf8String"); + break; + case Utf8CheckMode::kVerify: + format("RawString"); + break; + case Utf8CheckMode::kNone: + // Treat LITE_RUNTIME strings as bytes. + format("Bytes"); + break; + default: + GOOGLE_LOG(FATAL) << "Invalid Utf8CheckMode (" << static_cast<int>(mode) + << ") for " << field->DebugString(); + } + break; + } + + case FieldDescriptor::TYPE_GROUP: + format("Message | ::_fl::kRepGroup"); + break; + case FieldDescriptor::TYPE_MESSAGE: + if (field->is_map()) { + format("Map"); + } else { + format("Message"); + if (IsLazy(field, options, scc_analyzer)) { + format(" | ::_fl::kRepLazy"); + } else if (IsImplicitWeakField(field, options, scc_analyzer)) { + format(" | ::_fl::kRepIWeak"); + } + } + break; + } + + // Fill in extra information about string and bytes field representations. + if (field->type() == FieldDescriptor::TYPE_BYTES || + field->type() == FieldDescriptor::TYPE_STRING) { + if (field->is_repeated()) { + format(" | ::_fl::kRepSString"); + } else { + format(" | ::_fl::kRepAString"); + } + } + + format(")"); +} + +void ParseFunctionGenerator::GenerateFieldEntries(Formatter& format) { + for (const auto& entry : tc_table_info_->field_entries) { + const FieldDescriptor* field = entry.field; + PrintFieldComment(format, field); + format("{"); + if (IsWeak(field, options_)) { + // Weak fields are handled by the generated fallback function. + // (These are handled by legacy Google-internal logic.) + format("/* weak */ 0, 0, 0, 0"); + } else { + const OneofDescriptor* oneof = field->real_containing_oneof(); + bool cold = ShouldSplit(field, options_); + format("PROTOBUF_FIELD_OFFSET($classname$$1$, $2$), $3$, $4$,\n ", + cold ? "::Impl_::Split" : "", + cold ? FieldName(field) + "_" + : FieldMemberName(field, /*cold=*/false), + (oneof ? oneof->index() : entry.hasbit_idx), entry.aux_idx); + FormatFieldKind(format, entry, options_, scc_analyzer_); + } + format("},\n"); + } +} + +static constexpr int kMaxNameLength = 255; + +int ParseFunctionGenerator::CalculateFieldNamesSize() const { + // The full name of the message appears first. + int size = std::min(static_cast<int>(descriptor_->full_name().size()), + kMaxNameLength); + int lengths_size = 1; + for (const auto& entry : tc_table_info_->field_entries) { + const FieldDescriptor* field = entry.field; + GOOGLE_CHECK_LE(field->name().size(), kMaxNameLength); + size += field->name().size(); + lengths_size += 1; + } + // align to an 8-byte boundary + lengths_size = (lengths_size + 7) & -8; + return size + lengths_size + 1; +} + +static void FormatOctal(Formatter& format, int size) { + int octal_size = ((size >> 6) & 3) * 100 + // + ((size >> 3) & 7) * 10 + // + ((size >> 0) & 7); + format("\\$1$", octal_size); +} + +void ParseFunctionGenerator::GenerateFieldNames(Formatter& format) { + // First, we output the size of each string, as an unsigned byte. The first + // string is the message name. + int count = 1; + format("\""); + FormatOctal(format, + std::min(static_cast<int>(descriptor_->full_name().size()), 255)); + for (const auto& entry : tc_table_info_->field_entries) { + FormatOctal(format, entry.field->name().size()); + ++count; + } + while (count & 7) { // align to an 8-byte boundary + format("\\0"); + ++count; + } + format("\"\n"); + // The message name is stored at the beginning of the string + std::string message_name = descriptor_->full_name(); + if (message_name.size() > kMaxNameLength) { + static constexpr int kNameHalfLength = (kMaxNameLength - 3) / 2; + message_name = StrCat( + message_name.substr(0, kNameHalfLength), "...", + message_name.substr(message_name.size() - kNameHalfLength)); + } + format("\"$1$\"\n", message_name); + // Then we output the actual field names + for (const auto& entry : tc_table_info_->field_entries) { + const FieldDescriptor* field = entry.field; + format("\"$1$\"\n", field->name()); + } +} + +void ParseFunctionGenerator::GenerateArenaString(Formatter& format, + const FieldDescriptor* field) { + if (HasHasbit(field)) { + format("_Internal::set_has_$1$(&$has_bits$);\n", FieldName(field)); + } + format( + "if (arena != nullptr) {\n" + " ptr = ctx->ReadArenaString(ptr, &$msg$$field$, arena"); + if (IsStringInlined(field, options_)) { + GOOGLE_DCHECK(!inlined_string_indices_.empty()); + int inlined_string_index = inlined_string_indices_[field->index()]; + GOOGLE_DCHECK_GT(inlined_string_index, 0); + format(", &$msg$$inlined_string_donated_array$[0], $1$, $this$", + inlined_string_index); + } else { + GOOGLE_DCHECK(field->default_value_string().empty()); + } + format( + ");\n" + "} else {\n" + " ptr = ::_pbi::InlineGreedyStringParser(" + "$msg$$field$.MutableNoCopy(nullptr), ptr, ctx);\n" + "}\n" + "const std::string* str = &$msg$$field$.Get(); (void)str;\n"); +} + +void ParseFunctionGenerator::GenerateStrings(Formatter& format, + const FieldDescriptor* field, + bool check_utf8) { + FieldOptions::CType ctype = FieldOptions::STRING; + if (!options_.opensource_runtime) { + // Open source doesn't support other ctypes; + ctype = field->options().ctype(); + } + if (!field->is_repeated() && !options_.opensource_runtime && + GetOptimizeFor(field->file(), options_) != FileOptions::LITE_RUNTIME && + // For now only use arena string for strings with empty defaults. + field->default_value_string().empty() && + !field->real_containing_oneof() && ctype == FieldOptions::STRING) { + GenerateArenaString(format, field); + } else { + std::string parser_name; + switch (ctype) { + case FieldOptions::STRING: + parser_name = "GreedyStringParser"; + break; + case FieldOptions::CORD: + parser_name = "CordParser"; + break; + case FieldOptions::STRING_PIECE: + parser_name = "StringPieceParser"; + break; + } + format( + "auto str = $msg$$1$$2$_$name$();\n" + "ptr = ::_pbi::Inline$3$(str, ptr, ctx);\n", + HasInternalAccessors(ctype) ? "_internal_" : "", + field->is_repeated() && !field->is_packable() ? "add" : "mutable", + parser_name); + } + // It is intentionally placed before VerifyUTF8 because it doesn't make sense + // to verify UTF8 when we already know parsing failed. + format("CHK_(ptr);\n"); + if (!check_utf8) return; // return if this is a bytes field + auto level = GetUtf8CheckMode(field, options_); + switch (level) { + case Utf8CheckMode::kNone: + return; + case Utf8CheckMode::kVerify: + format("#ifndef NDEBUG\n"); + break; + case Utf8CheckMode::kStrict: + format("CHK_("); + break; + } + std::string field_name; + field_name = "nullptr"; + if (HasDescriptorMethods(field->file(), options_)) { + field_name = StrCat("\"", field->full_name(), "\""); + } + format("::_pbi::VerifyUTF8(str, $1$)", field_name); + switch (level) { + case Utf8CheckMode::kNone: + return; + case Utf8CheckMode::kVerify: + format( + ";\n" + "#endif // !NDEBUG\n"); + break; + case Utf8CheckMode::kStrict: + format(");\n"); + break; + } +} + +void ParseFunctionGenerator::GenerateLengthDelim(Formatter& format, + const FieldDescriptor* field) { + if (field->is_packable()) { + if (field->type() == FieldDescriptor::TYPE_ENUM && + !HasPreservingUnknownEnumSemantics(field)) { + std::string enum_type = QualifiedClassName(field->enum_type(), options_); + format( + "ptr = " + "::$proto_ns$::internal::Packed$1$Parser<$unknown_fields_type$>(" + "$msg$_internal_mutable_$name$(), ptr, ctx, $2$_IsValid, " + "&$msg$_internal_metadata_, $3$);\n", + DeclaredTypeMethodName(field->type()), enum_type, field->number()); + } else { + format( + "ptr = ::$proto_ns$::internal::Packed$1$Parser(" + "$msg$_internal_mutable_$name$(), ptr, ctx);\n", + DeclaredTypeMethodName(field->type())); + } + format("CHK_(ptr);\n"); + } else { + auto field_type = field->type(); + switch (field_type) { + case FieldDescriptor::TYPE_STRING: + GenerateStrings(format, field, true /* utf8 */); + break; + case FieldDescriptor::TYPE_BYTES: + GenerateStrings(format, field, false /* utf8 */); + break; + case FieldDescriptor::TYPE_MESSAGE: { + if (field->is_map()) { + const FieldDescriptor* val = field->message_type()->map_value(); + GOOGLE_CHECK(val); + if (val->type() == FieldDescriptor::TYPE_ENUM && + !HasPreservingUnknownEnumSemantics(field)) { + format( + "auto object = " + "::$proto_ns$::internal::InitEnumParseWrapper<" + "$unknown_fields_type$>(&$msg$$field$, $1$_IsValid, " + "$2$, &$msg$_internal_metadata_);\n" + "ptr = ctx->ParseMessage(&object, ptr);\n", + QualifiedClassName(val->enum_type(), options_), + field->number()); + } else { + format("ptr = ctx->ParseMessage(&$msg$$field$, ptr);\n"); + } + } else if (IsLazy(field, options_, scc_analyzer_)) { + bool eager_verify = + IsEagerlyVerifiedLazy(field, options_, scc_analyzer_); + if (ShouldVerify(descriptor_, options_, scc_analyzer_)) { + format( + "ctx->set_lazy_eager_verify_func($1$);\n", + eager_verify + ? StrCat("&", ClassName(field->message_type(), true), + "::InternalVerify") + : "nullptr"); + } + if (field->real_containing_oneof()) { + format( + "if (!$msg$_internal_has_$name$()) {\n" + " $msg$clear_$1$();\n" + " $msg$$field$ = ::$proto_ns$::Arena::CreateMessage<\n" + " ::$proto_ns$::internal::LazyField>(" + "$msg$GetArenaForAllocation());\n" + " $msg$set_has_$name$();\n" + "}\n" + "auto* lazy_field = $msg$$field$;\n", + field->containing_oneof()->name()); + } else if (HasHasbit(field)) { + format( + "_Internal::set_has_$name$(&$has_bits$);\n" + "auto* lazy_field = &$msg$$field$;\n"); + } else { + format("auto* lazy_field = &$msg$$field$;\n"); + } + format( + "::$proto_ns$::internal::LazyFieldParseHelper<\n" + " ::$proto_ns$::internal::LazyField> parse_helper(\n" + " $1$::default_instance(),\n" + " $msg$GetArenaForAllocation(),\n" + " ::google::protobuf::internal::LazyVerifyOption::$2$,\n" + " lazy_field);\n" + "ptr = ctx->ParseMessage(&parse_helper, ptr);\n", + FieldMessageTypeName(field, options_), + eager_verify ? "kEager" : "kLazy"); + if (ShouldVerify(descriptor_, options_, scc_analyzer_) && + eager_verify) { + format("ctx->set_lazy_eager_verify_func(nullptr);\n"); + } + } else if (IsImplicitWeakField(field, options_, scc_analyzer_)) { + if (!field->is_repeated()) { + format( + "ptr = ctx->ParseMessage(_Internal::mutable_$name$($this$), " + "ptr);\n"); + } else { + format( + "ptr = ctx->ParseMessage($msg$$field$.AddWeak(" + "reinterpret_cast<const ::$proto_ns$::MessageLite*>($1$ptr_)" + "), ptr);\n", + QualifiedDefaultInstanceName(field->message_type(), options_)); + } + } else if (IsWeak(field, options_)) { + format( + "{\n" + " auto* default_ = &reinterpret_cast<const Message&>($1$);\n" + " ptr = ctx->ParseMessage($msg$$weak_field_map$.MutableMessage(" + "$2$, default_), ptr);\n" + "}\n", + QualifiedDefaultInstanceName(field->message_type(), options_), + field->number()); + } else { + format( + "ptr = ctx->ParseMessage($msg$_internal_$mutable_field$(), " + "ptr);\n"); + } + format("CHK_(ptr);\n"); + break; + } + default: + GOOGLE_LOG(FATAL) << "Illegal combination for length delimited wiretype " + << " filed type is " << field->type(); + } + } +} + +static bool ShouldRepeat(const FieldDescriptor* descriptor, + WireFormatLite::WireType wiretype) { + constexpr int kMaxTwoByteFieldNumber = 16 * 128; + return descriptor->number() < kMaxTwoByteFieldNumber && + descriptor->is_repeated() && + (!descriptor->is_packable() || + wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED); +} + +void ParseFunctionGenerator::GenerateFieldBody( + Formatter& format, WireFormatLite::WireType wiretype, + const FieldDescriptor* field) { + Formatter::SaveState formatter_state(&format); + format.AddMap( + {{"name", FieldName(field)}, + {"primitive_type", PrimitiveTypeName(options_, field->cpp_type())}}); + if (field->is_repeated()) { + format.AddMap({{"put_field", StrCat("add_", FieldName(field))}, + {"mutable_field", StrCat("add_", FieldName(field))}}); + } else { + format.AddMap( + {{"put_field", StrCat("set_", FieldName(field))}, + {"mutable_field", StrCat("mutable_", FieldName(field))}}); + } + uint32_t tag = WireFormatLite::MakeTag(field->number(), wiretype); + switch (wiretype) { + case WireFormatLite::WIRETYPE_VARINT: { + std::string type = PrimitiveTypeName(options_, field->cpp_type()); + if (field->type() == FieldDescriptor::TYPE_ENUM) { + format.Set("enum_type", + QualifiedClassName(field->enum_type(), options_)); + format( + "$uint64$ val = ::$proto_ns$::internal::ReadVarint64(&ptr);\n" + "CHK_(ptr);\n"); + if (!HasPreservingUnknownEnumSemantics(field)) { + format("if (PROTOBUF_PREDICT_TRUE($enum_type$_IsValid(val))) {\n"); + format.Indent(); + } + format("$msg$_internal_$put_field$(static_cast<$enum_type$>(val));\n"); + if (!HasPreservingUnknownEnumSemantics(field)) { + format.Outdent(); + format( + "} else {\n" + " ::$proto_ns$::internal::WriteVarint(" + "$1$, val, $msg$mutable_unknown_fields());\n" + "}\n", + field->number()); + } + } else { + std::string size = (field->type() == FieldDescriptor::TYPE_INT32 || + field->type() == FieldDescriptor::TYPE_SINT32 || + field->type() == FieldDescriptor::TYPE_UINT32) + ? "32" + : "64"; + std::string zigzag; + if ((field->type() == FieldDescriptor::TYPE_SINT32 || + field->type() == FieldDescriptor::TYPE_SINT64)) { + zigzag = "ZigZag"; + } + if (field->is_repeated() || field->real_containing_oneof()) { + format( + "$msg$_internal_$put_field$(" + "::$proto_ns$::internal::ReadVarint$1$$2$(&ptr));\n" + "CHK_(ptr);\n", + zigzag, size); + } else { + if (HasHasbit(field)) { + format("_Internal::set_has_$name$(&$has_bits$);\n"); + } + format( + "$msg$$field$ = ::$proto_ns$::internal::ReadVarint$1$$2$(&ptr);\n" + "CHK_(ptr);\n", + zigzag, size); + } + } + break; + } + case WireFormatLite::WIRETYPE_FIXED32: + case WireFormatLite::WIRETYPE_FIXED64: { + if (field->is_repeated() || field->real_containing_oneof()) { + format( + "$msg$_internal_$put_field$(" + "::$proto_ns$::internal::UnalignedLoad<$primitive_type$>(ptr));\n" + "ptr += sizeof($primitive_type$);\n"); + } else { + if (HasHasbit(field)) { + format("_Internal::set_has_$name$(&$has_bits$);\n"); + } + format( + "$msg$$field$ = " + "::$proto_ns$::internal::UnalignedLoad<$primitive_type$>(ptr);\n" + "ptr += sizeof($primitive_type$);\n"); + } + break; + } + case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: { + GenerateLengthDelim(format, field); + break; + } + case WireFormatLite::WIRETYPE_START_GROUP: { + format( + "ptr = ctx->ParseGroup($msg$_internal_$mutable_field$(), ptr, $1$);\n" + "CHK_(ptr);\n", + tag); + break; + } + case WireFormatLite::WIRETYPE_END_GROUP: { + GOOGLE_LOG(FATAL) << "Can't have end group field\n"; + break; + } + } // switch (wire_type) +} + +// Returns the tag for this field and in case of repeated packable fields, +// sets a fallback tag in fallback_tag_ptr. +static uint32_t ExpectedTag(const FieldDescriptor* field, + uint32_t* fallback_tag_ptr) { + uint32_t expected_tag; + if (field->is_packable()) { + auto expected_wiretype = WireFormat::WireTypeForFieldType(field->type()); + expected_tag = WireFormatLite::MakeTag(field->number(), expected_wiretype); + GOOGLE_CHECK(expected_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED); + auto fallback_wiretype = WireFormatLite::WIRETYPE_LENGTH_DELIMITED; + uint32_t fallback_tag = + WireFormatLite::MakeTag(field->number(), fallback_wiretype); + + if (field->is_packed()) std::swap(expected_tag, fallback_tag); + *fallback_tag_ptr = fallback_tag; + } else { + auto expected_wiretype = WireFormat::WireTypeForField(field); + expected_tag = WireFormatLite::MakeTag(field->number(), expected_wiretype); + } + return expected_tag; +} + +// These variables are used by the generated parse iteration, and must already +// be defined in the generated code: +// - `const char* ptr`: the input buffer. +// - `ParseContext* ctx`: the associated context for `ptr`. +// - implicit `this`: i.e., we must be in a non-static member function. +// +// The macro `CHK_(x)` must be defined. It should return an error condition if +// the macro parameter is false. +// +// Whenever an END_GROUP tag was read, or tag 0 was read, the generated code +// branches to the label `message_done`. +// +// These formatter variables are used: +// - `next_tag`: a single statement to begin parsing the next tag. +// +// At the end of the generated code, the enclosing function should proceed to +// parse the next tag in the stream. +void ParseFunctionGenerator::GenerateParseIterationBody( + Formatter& format, const Descriptor* descriptor, + const std::vector<const FieldDescriptor*>& fields) { + if (!fields.empty()) { + GenerateFieldSwitch(format, fields); + // Each field `case` only considers field number. Field numbers that are + // not defined in the message, or tags with an incompatible wire type, are + // considered "unusual" cases. They will be handled by the logic below. + format.Outdent(); + format("handle_unusual:\n"); + format.Indent(); + } + + // Unusual/extension/unknown case: + format( + "if ((tag == 0) || ((tag & 7) == 4)) {\n" + " CHK_(ptr);\n" + " ctx->SetLastTag(tag);\n" + " goto message_done;\n" + "}\n"); + if (IsMapEntryMessage(descriptor)) { + format("$next_tag$;\n"); + } else { + if (descriptor->extension_range_count() > 0) { + format("if ("); + for (int i = 0; i < descriptor->extension_range_count(); i++) { + const Descriptor::ExtensionRange* range = + descriptor->extension_range(i); + if (i > 0) format(" ||\n "); + + uint32_t start_tag = WireFormatLite::MakeTag( + range->start, static_cast<WireFormatLite::WireType>(0)); + uint32_t end_tag = WireFormatLite::MakeTag( + range->end, static_cast<WireFormatLite::WireType>(0)); + + if (range->end > FieldDescriptor::kMaxNumber) { + format("($1$u <= tag)", start_tag); + } else { + format("($1$u <= tag && tag < $2$u)", start_tag, end_tag); + } + } + format( + ") {\n" + " ptr = $msg$$extensions$.ParseField(tag, ptr, " + "internal_default_instance(), &$msg$_internal_metadata_, ctx);\n" + " CHK_(ptr != nullptr);\n" + " $next_tag$;\n" + "}\n"); + } + format( + "ptr = UnknownFieldParse(\n" + " tag,\n" + " $msg$_internal_metadata_.mutable_unknown_fields<" + "$unknown_fields_type$>(),\n" + " ptr, ctx);\n" + "CHK_(ptr != nullptr);\n"); + } +} + +void ParseFunctionGenerator::GenerateFieldSwitch( + Formatter& format, const std::vector<const FieldDescriptor*>& fields) { + format("switch (tag >> 3) {\n"); + format.Indent(); + + for (const auto* field : fields) { + bool cold = ShouldSplit(field, options_); + format.Set("field", FieldMemberName(field, cold)); + PrintFieldComment(format, field); + format("case $1$:\n", field->number()); + format.Indent(); + uint32_t fallback_tag = 0; + uint32_t expected_tag = ExpectedTag(field, &fallback_tag); + format("if (PROTOBUF_PREDICT_TRUE(static_cast<$uint8$>(tag) == $1$)) {\n", + expected_tag & 0xFF); + format.Indent(); + if (cold) { + format("$msg$PrepareSplitMessageForWrite();\n"); + } + auto wiretype = WireFormatLite::GetTagWireType(expected_tag); + uint32_t tag = WireFormatLite::MakeTag(field->number(), wiretype); + int tag_size = io::CodedOutputStream::VarintSize32(tag); + bool is_repeat = ShouldRepeat(field, wiretype); + if (is_repeat) { + format( + "ptr -= $1$;\n" + "do {\n" + " ptr += $1$;\n", + tag_size); + format.Indent(); + } + GenerateFieldBody(format, wiretype, field); + if (is_repeat) { + format.Outdent(); + format( + " if (!ctx->DataAvailable(ptr)) break;\n" + "} while (::$proto_ns$::internal::ExpectTag<$1$>(ptr));\n", + tag); + } + format.Outdent(); + if (fallback_tag) { + format("} else if (static_cast<$uint8$>(tag) == $1$) {\n", + fallback_tag & 0xFF); + format.Indent(); + GenerateFieldBody(format, WireFormatLite::GetTagWireType(fallback_tag), + field); + format.Outdent(); + } + format( + "} else\n" + " goto handle_unusual;\n" + "$next_tag$;\n"); + format.Outdent(); + } // for loop over ordered fields + + format( + "default:\n" + " goto handle_unusual;\n"); + format.Outdent(); + format("} // switch\n"); +} + +namespace { + +std::string FieldParseFunctionName( + const TailCallTableInfo::FieldEntryInfo& entry, const Options& options) { + const FieldDescriptor* field = entry.field; + std::string name = "::_pbi::TcParser::Fast"; + + switch (field->type()) { + case FieldDescriptor::TYPE_FIXED32: + case FieldDescriptor::TYPE_SFIXED32: + case FieldDescriptor::TYPE_FLOAT: + name.append("F32"); + break; + + case FieldDescriptor::TYPE_FIXED64: + case FieldDescriptor::TYPE_SFIXED64: + case FieldDescriptor::TYPE_DOUBLE: + name.append("F64"); + break; + + case FieldDescriptor::TYPE_BOOL: + name.append("V8"); + break; + case FieldDescriptor::TYPE_INT32: + case FieldDescriptor::TYPE_UINT32: + name.append("V32"); + break; + case FieldDescriptor::TYPE_INT64: + case FieldDescriptor::TYPE_UINT64: + name.append("V64"); + break; + + case FieldDescriptor::TYPE_ENUM: + if (HasPreservingUnknownEnumSemantics(field)) { + name.append("V32"); + break; + } + if (field->is_repeated() && field->is_packed()) { + GOOGLE_LOG(DFATAL) << "Enum validation not handled: " << field->DebugString(); + return ""; + } + name.append(entry.is_enum_range ? "Er" : "Ev"); + break; + + case FieldDescriptor::TYPE_SINT32: + name.append("Z32"); + break; + case FieldDescriptor::TYPE_SINT64: + name.append("Z64"); + break; + + case FieldDescriptor::TYPE_BYTES: + name.append("B"); + if (IsStringInlined(field, options)) { + name.append("i"); + } + break; + case FieldDescriptor::TYPE_STRING: + switch (GetUtf8CheckMode(field, options)) { + case Utf8CheckMode::kNone: + name.append("B"); + break; + case Utf8CheckMode::kVerify: + name.append("S"); + break; + case Utf8CheckMode::kStrict: + name.append("U"); + break; + default: + GOOGLE_LOG(DFATAL) << "Mode not handled: " + << static_cast<int>(GetUtf8CheckMode(field, options)); + return ""; + } + if (IsStringInlined(field, options)) { + name.append("i"); + } + break; + + case FieldDescriptor::TYPE_MESSAGE: + name.append("M"); + break; + case FieldDescriptor::TYPE_GROUP: + name.append("G"); + break; + + default: + GOOGLE_LOG(DFATAL) << "Type not handled: " << field->DebugString(); + return ""; + } + + // The field implementation functions are prefixed by cardinality: + // `S` for optional or implicit fields. + // `R` for non-packed repeated. + // `P` for packed repeated. + name.append(field->is_packed() ? "P" + : field->is_repeated() ? "R" + : field->real_containing_oneof() ? "O" + : "S"); + + // Append the tag length. Fast parsing only handles 1- or 2-byte tags. + name.append(TagSize(field->number()) == 1 ? "1" : "2"); + + return name; +} + +} // namespace + +} // namespace cpp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_parse_function_generator.h b/r5dev/thirdparty/protobuf/compiler/cpp/parse_function_generator.h similarity index 75% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_parse_function_generator.h rename to r5dev/thirdparty/protobuf/compiler/cpp/parse_function_generator.h index ee5a66d5..cc0b0b6b 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_parse_function_generator.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/parse_function_generator.h @@ -35,12 +35,11 @@ #include <string> #include <vector> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_options.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/generated_message_tctable_decl.h> #include <thirdparty/protobuf/wire_format_lite.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> +#include <thirdparty/protobuf/compiler/cpp/options.h> namespace google { namespace protobuf { @@ -50,18 +49,36 @@ namespace cpp { // Helper class for generating tailcall parsing functions. struct TailCallTableInfo { TailCallTableInfo(const Descriptor* descriptor, const Options& options, + const std::vector<const FieldDescriptor*>& ordered_fields, const std::vector<int>& has_bit_indices, + const std::vector<int>& inlined_string_indices, MessageSCCAnalyzer* scc_analyzer); - // Information to generate field entries. - struct FieldInfo { - const FieldDescriptor* field; - google::protobuf::internal::TcFieldData bits; - std::string func_name; - }; + // Fields parsed by the table fast-path. - std::vector<FieldInfo> fast_path_fields; - // Fields parsed by slow-path fallback. + struct FastFieldInfo { + std::string func_name; + const FieldDescriptor* field; + uint16_t coded_tag; + uint8_t hasbit_idx; + uint8_t aux_idx; + }; + std::vector<FastFieldInfo> fast_path_fields; + + // Fields parsed by mini parsing routines. + struct FieldEntryInfo { + const FieldDescriptor* field; + int hasbit_idx; + int inlined_string_idx; + uint16_t aux_idx; + // True for enums entirely covered by the start/length fields of FieldAux: + bool is_enum_range; + }; + std::vector<FieldEntryInfo> field_entries; + std::vector<std::string> aux_entries; + + // Fields parsed by generated fallback function. std::vector<const FieldDescriptor*> fallback_fields; + // Table size. int table_size_log2; // Mask for has-bits of required fields. @@ -110,15 +127,15 @@ class ParseFunctionGenerator { // Generates a fallback function for tailcall table-based parsing. void GenerateTailcallFallbackFunction(Formatter& format); - // Generates functions for parsing this message as a field. - void GenerateTailcallFieldParseFunctions(Formatter& format); - // Generates a looping `_InternalParse` function. void GenerateLoopingParseFunction(Formatter& format); // Generates the tail-call table definition. void GenerateTailCallTable(Formatter& format); - void GenerateFastFieldEntries(Formatter& format, const std::string& fallback); + void GenerateFastFieldEntries(Formatter& format); + void GenerateFieldEntries(Formatter& format); + int CalculateFieldNamesSize() const; + void GenerateFieldNames(Formatter& format); // Generates parsing code for an `ArenaString` field. void GenerateArenaString(Formatter& format, const FieldDescriptor* field); @@ -139,12 +156,11 @@ class ParseFunctionGenerator { // Generates code to parse the next field from the input stream. void GenerateParseIterationBody( Formatter& format, const Descriptor* descriptor, - const std::vector<const FieldDescriptor*>& ordered_fields); + const std::vector<const FieldDescriptor*>& fields); - // Generates a `switch` statement to parse each of `ordered_fields`. - void GenerateFieldSwitch( - Formatter& format, - const std::vector<const FieldDescriptor*>& ordered_fields); + // Generates a `switch` statement to parse each of `fields`. + void GenerateFieldSwitch(Formatter& format, + const std::vector<const FieldDescriptor*>& fields); const Descriptor* descriptor_; MessageSCCAnalyzer* scc_analyzer_; @@ -152,45 +168,10 @@ class ParseFunctionGenerator { std::map<std::string, std::string> variables_; std::unique_ptr<TailCallTableInfo> tc_table_info_; std::vector<int> inlined_string_indices_; + const std::vector<const FieldDescriptor*> ordered_fields_; int num_hasbits_; }; -enum class ParseCardinality { - kSingular, - kOneof, - kRepeated, - kPacked, -}; - -// TypeFormat defines parsing types, which encapsulates the expected wire -// format, conversion or validation, and the in-memory layout. -enum class TypeFormat { - // Fixed types: - kFixed64, // fixed64, sfixed64, double - kFixed32, // fixed32, sfixed32, float - - // Varint types: - kVar64, // int64, uint64 - kVar32, // int32, uint32 - kSInt64, // sint64 - kSInt32, // sint32 - kBool, // bool - - // Length-delimited types: - kBytes, // bytes - kString, // string (proto3/UTF-8 strict) - kStringValidateOnly, // string (proto2/UTF-8 validate only) -}; - -// Returns the name of a field parser function. -// -// These are out-of-line functions generated by -// parse_function_inc_generator_main. -std::string GetTailCallFieldHandlerName(ParseCardinality card, - TypeFormat type_format, - int tag_length_bytes, - const Options& options); - } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_plugin_unittest.cc b/r5dev/thirdparty/protobuf/compiler/cpp/plugin_unittest.cc similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_plugin_unittest.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/plugin_unittest.cc index 7cdd6cf3..29690384 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_plugin_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/plugin_unittest.cc @@ -38,7 +38,7 @@ #include <thirdparty/protobuf/testing/file.h> #include <thirdparty/protobuf/testing/file.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_generator.h> +#include <thirdparty/protobuf/compiler/cpp/generator.h> #include <thirdparty/protobuf/compiler/command_line_interface.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> @@ -54,11 +54,10 @@ namespace { class TestGenerator : public CodeGenerator { public: TestGenerator() {} - ~TestGenerator() {} + ~TestGenerator() override {} - virtual bool Generate(const FileDescriptor* file, - const std::string& parameter, GeneratorContext* context, - std::string* error) const { + bool Generate(const FileDescriptor* file, const std::string& parameter, + GeneratorContext* context, std::string* error) const override { TryInsert("test.pb.h", "includes", context); TryInsert("test.pb.h", "namespace_scope", context); TryInsert("test.pb.h", "global_scope", context); @@ -199,7 +198,7 @@ TEST(CppPluginTest, PluginTest) { " ctype = CORD\n" " ];\n" "\n" - " oneof Qux {\n" + " oneof Moo {\n" " int64 oneOfInt = 20;\n" " string oneOfString = 21;\n" " Baz oneOfMessage = 22;\n" diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_primitive_field.cc b/r5dev/thirdparty/protobuf/compiler/cpp/primitive_field.cc similarity index 81% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_primitive_field.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/primitive_field.cc index 1e4eadf9..351ed7f9 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_primitive_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/primitive_field.cc @@ -32,12 +32,12 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/cpp/cpp_primitive_field.h> +#include <thirdparty/protobuf/compiler/cpp/primitive_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> namespace google { namespace protobuf { @@ -104,6 +104,10 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, SetCommonFieldVariables(descriptor, variables, options); (*variables)["type"] = PrimitiveTypeName(options, descriptor->cpp_type()); (*variables)["default"] = DefaultValue(options, descriptor); + (*variables)["cached_byte_size_name"] = MakeVarintCachedSizeName(descriptor); + bool cold = ShouldSplit(descriptor, options); + (*variables)["cached_byte_size_field"] = + MakeVarintCachedSizeFieldName(descriptor, cold); (*variables)["tag"] = StrCat(internal::WireFormat::MakeTag(descriptor)); int fixed_size = FixedSize(descriptor->type()); if (fixed_size != -1) { @@ -150,7 +154,7 @@ void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions( Formatter format(printer, variables_); format( "inline $type$ $classname$::_internal_$name$() const {\n" - " return $name$_;\n" + " return $field$;\n" "}\n" "inline $type$ $classname$::$name$() const {\n" "$annotate_get$" @@ -159,9 +163,10 @@ void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions( "}\n" "inline void $classname$::_internal_set_$name$($type$ value) {\n" " $set_hasbit$\n" - " $name$_ = value;\n" + " $field$ = value;\n" "}\n" "inline void $classname$::set_$name$($type$ value) {\n" + "$maybe_prepare_split_message$" " _internal_set_$name$(value);\n" "$annotate_set$" " // @@protoc_insertion_point(field_set:$full_name$)\n" @@ -170,29 +175,23 @@ void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions( void PrimitiveFieldGenerator::GenerateClearingCode(io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_ = $default$;\n"); + format("$field$ = $default$;\n"); } void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) const { Formatter format(printer, variables_); - format("_internal_set_$name$(from._internal_$name$());\n"); + format("_this->_internal_set_$name$(from._internal_$name$());\n"); } void PrimitiveFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { Formatter format(printer, variables_); - format("swap($name$_, other->$name$_);\n"); -} - -void PrimitiveFieldGenerator::GenerateConstructorCode( - io::Printer* printer) const { - Formatter format(printer, variables_); - format("$name$_ = $default$;\n"); + format("swap($field$, other->$field$);\n"); } void PrimitiveFieldGenerator::GenerateCopyConstructorCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_ = from.$name$_;\n"); + format("_this->$field$ = from.$field$;\n"); } void PrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray( @@ -201,7 +200,7 @@ void PrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray( format( "target = stream->EnsureSpace(target);\n" "target = " - "::$proto_ns$::internal::WireFormatLite::Write$declared_type$ToArray(" + "::_pbi::WireFormatLite::Write$declared_type$ToArray(" "$number$, this->_internal_$name$(), target);\n"); } @@ -214,12 +213,12 @@ void PrimitiveFieldGenerator::GenerateByteSize(io::Printer* printer) const { // Adding one is very common and it turns out it can be done for // free inside of WireFormatLite, so we can save an instruction here. format( - "total_size += ::$proto_ns$::internal::WireFormatLite::" + "total_size += ::_pbi::WireFormatLite::" "$declared_type$SizePlusOne(this->_internal_$name$());\n"); } else { format( "total_size += $tag_size$ +\n" - " ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n" + " ::_pbi::WireFormatLite::$declared_type$Size(\n" " this->_internal_$name$());\n"); } } else { @@ -227,10 +226,26 @@ void PrimitiveFieldGenerator::GenerateByteSize(io::Printer* printer) const { } } -void PrimitiveFieldGenerator::GenerateConstinitInitializer( +void PrimitiveFieldGenerator::GenerateConstexprAggregateInitializer( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_($default$)"); + format("/*decltype($field$)*/$default$"); +} + +void PrimitiveFieldGenerator::GenerateAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + if (ShouldSplit(descriptor_, options_)) { + format("decltype(Impl_::Split::$name$_){$default$}"); + return; + } + format("decltype($field$){$default$}"); +} + +void PrimitiveFieldGenerator::GenerateCopyAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("decltype($field$){}"); } // =================================================================== @@ -249,7 +264,7 @@ void PrimitiveOneofFieldGenerator::GenerateInlineAccessorDefinitions( format( "inline $type$ $classname$::_internal_$name$() const {\n" " if (_internal_has_$name$()) {\n" - " return $field_member$;\n" + " return $field$;\n" " }\n" " return $default$;\n" "}\n" @@ -258,7 +273,7 @@ void PrimitiveOneofFieldGenerator::GenerateInlineAccessorDefinitions( " clear_$oneof_name$();\n" " set_has_$name$();\n" " }\n" - " $field_member$ = value;\n" + " $field$ = value;\n" "}\n" "inline $type$ $classname$::$name$() const {\n" "$annotate_get$" @@ -275,7 +290,7 @@ void PrimitiveOneofFieldGenerator::GenerateInlineAccessorDefinitions( void PrimitiveOneofFieldGenerator::GenerateClearingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$field_member$ = $default$;\n"); + format("$field$ = $default$;\n"); } void PrimitiveOneofFieldGenerator::GenerateSwappingCode( @@ -286,7 +301,7 @@ void PrimitiveOneofFieldGenerator::GenerateSwappingCode( void PrimitiveOneofFieldGenerator::GenerateConstructorCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$ns$::_$classname$_default_instance_.$name$_ = $default$;\n"); + format("$ns$::_$classname$_default_instance_.$field$ = $default$;\n"); } // =================================================================== @@ -313,7 +328,7 @@ void RepeatedPrimitiveFieldGenerator::GeneratePrivateMembers( format("::$proto_ns$::RepeatedField< $type$ > $name$_;\n"); if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 && HasGeneratedMethods(descriptor_->file(), options_)) { - format("mutable std::atomic<int> _$name$_cached_byte_size_;\n"); + format("mutable std::atomic<int> $cached_byte_size_name$;\n"); } } @@ -344,7 +359,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions( Formatter format(printer, variables_); format( "inline $type$ $classname$::_internal_$name$(int index) const {\n" - " return $name$_.Get(index);\n" + " return $field$.Get(index);\n" "}\n" "inline $type$ $classname$::$name$(int index) const {\n" "$annotate_get$" @@ -353,11 +368,11 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions( "}\n" "inline void $classname$::set_$name$(int index, $type$ value) {\n" "$annotate_set$" - " $name$_.Set(index, value);\n" + " $field$.Set(index, value);\n" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" "inline void $classname$::_internal_add_$name$($type$ value) {\n" - " $name$_.Add(value);\n" + " $field$.Add(value);\n" "}\n" "inline void $classname$::add_$name$($type$ value) {\n" " _internal_add_$name$(value);\n" @@ -366,7 +381,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions( "}\n" "inline const ::$proto_ns$::RepeatedField< $type$ >&\n" "$classname$::_internal_$name$() const {\n" - " return $name$_;\n" + " return $field$;\n" "}\n" "inline const ::$proto_ns$::RepeatedField< $type$ >&\n" "$classname$::$name$() const {\n" @@ -376,7 +391,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions( "}\n" "inline ::$proto_ns$::RepeatedField< $type$ >*\n" "$classname$::_internal_mutable_$name$() {\n" - " return &$name$_;\n" + " return &$field$;\n" "}\n" "inline ::$proto_ns$::RepeatedField< $type$ >*\n" "$classname$::mutable_$name$() {\n" @@ -389,30 +404,25 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions( void RepeatedPrimitiveFieldGenerator::GenerateClearingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.Clear();\n"); + format("$field$.Clear();\n"); } void RepeatedPrimitiveFieldGenerator::GenerateMergingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.MergeFrom(from.$name$_);\n"); + format("_this->$field$.MergeFrom(from.$field$);\n"); } void RepeatedPrimitiveFieldGenerator::GenerateSwappingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.InternalSwap(&other->$name$_);\n"); + format("$field$.InternalSwap(&other->$field$);\n"); } -void RepeatedPrimitiveFieldGenerator::GenerateConstructorCode( - io::Printer* printer) const { - // Not needed for repeated fields. -} - -void RepeatedPrimitiveFieldGenerator::GenerateCopyConstructorCode( +void RepeatedPrimitiveFieldGenerator::GenerateDestructorCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.CopyFrom(from.$name$_);\n"); + format("$field$.~RepeatedField();\n"); } void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray( @@ -423,7 +433,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray( format( "{\n" " int byte_size = " - "_$name$_cached_byte_size_.load(std::memory_order_relaxed);\n" + "$cached_byte_size_field$.load(std::memory_order_relaxed);\n" " if (byte_size > 0) {\n" " target = stream->Write$declared_type$Packed(\n" " $number$, _internal_$name$(), byte_size, target);\n" @@ -440,7 +450,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray( format( "for (int i = 0, n = this->_internal_$name$_size(); i < n; i++) {\n" " target = stream->EnsureSpace(target);\n" - " target = ::$proto_ns$::internal::WireFormatLite::" + " target = ::_pbi::WireFormatLite::" "Write$declared_type$ToArray($number$, this->_internal_$name$(i), " "target);\n" "}\n"); @@ -455,8 +465,8 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize( int fixed_size = FixedSize(descriptor_->type()); if (fixed_size == -1) { format( - "size_t data_size = ::$proto_ns$::internal::WireFormatLite::\n" - " $declared_type$Size(this->$name$_);\n"); + "size_t data_size = ::_pbi::WireFormatLite::\n" + " $declared_type$Size(this->$field$);\n"); } else { format( "unsigned int count = static_cast<unsigned " @@ -468,13 +478,13 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize( format( "if (data_size > 0) {\n" " total_size += $tag_size$ +\n" - " ::$proto_ns$::internal::WireFormatLite::Int32Size(\n" - " static_cast<$int32$>(data_size));\n" + " " + "::_pbi::WireFormatLite::Int32Size(static_cast<$int32$>(data_size));\n" "}\n"); if (FixedSize(descriptor_->type()) == -1) { format( - "int cached_size = ::$proto_ns$::internal::ToCachedSize(data_size);\n" - "_$name$_cached_byte_size_.store(cached_size,\n" + "int cached_size = ::_pbi::ToCachedSize(data_size);\n" + "$cached_byte_size_field$.store(cached_size,\n" " std::memory_order_relaxed);\n"); } format("total_size += data_size;\n"); @@ -482,20 +492,44 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize( format( "total_size += $tag_size$ *\n" " " - "::$proto_ns$::internal::FromIntSize(this->_internal_$name$_size());\n" + "::_pbi::FromIntSize(this->_internal_$name$_size());\n" "total_size += data_size;\n"); } format.Outdent(); format("}\n"); } -void RepeatedPrimitiveFieldGenerator::GenerateConstinitInitializer( +void RepeatedPrimitiveFieldGenerator::GenerateConstexprAggregateInitializer( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_()"); + format("/*decltype($field$)*/{}"); if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 && HasGeneratedMethods(descriptor_->file(), options_)) { - format("\n, _$name$_cached_byte_size_(0)"); + format("\n, /*decltype($cached_byte_size_field$)*/{0}"); + } +} + +void RepeatedPrimitiveFieldGenerator::GenerateAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("decltype($field$){arena}"); + if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 && + HasGeneratedMethods(descriptor_->file(), options_)) { + // std::atomic has no move constructor, which prevents explicit aggregate + // initialization pre-C++17. + format("\n, /*decltype($cached_byte_size_field$)*/{0}"); + } +} + +void RepeatedPrimitiveFieldGenerator::GenerateCopyAggregateInitializer( + io::Printer* printer) const { + + Formatter format(printer, variables_); + format("decltype($field$){from.$field$}"); + if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 && + HasGeneratedMethods(descriptor_->file(), options_)) { + // std::atomic has no move constructor. + format("\n, /*decltype($cached_byte_size_field$)*/{0}"); } } diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_primitive_field.h b/r5dev/thirdparty/protobuf/compiler/cpp/primitive_field.h similarity index 84% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_primitive_field.h rename to r5dev/thirdparty/protobuf/compiler/cpp/primitive_field.h index 8bcc55dd..3cccbb6c 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_primitive_field.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/primitive_field.h @@ -37,7 +37,8 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/cpp/cpp_field.h> + +#include <thirdparty/protobuf/compiler/cpp/field.h> namespace google { namespace protobuf { @@ -48,7 +49,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { public: PrimitiveFieldGenerator(const FieldDescriptor* descriptor, const Options& options); - ~PrimitiveFieldGenerator(); + ~PrimitiveFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const override; @@ -57,12 +58,15 @@ class PrimitiveFieldGenerator : public FieldGenerator { void GenerateClearingCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateSwappingCode(io::Printer* printer) const override; - void GenerateConstructorCode(io::Printer* printer) const override; + void GenerateConstructorCode(io::Printer* printer) const override {} void GenerateCopyConstructorCode(io::Printer* printer) const override; void GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; - void GenerateConstinitInitializer(io::Printer* printer) const override; + void GenerateConstexprAggregateInitializer( + io::Printer* printer) const override; + void GenerateAggregateInitializer(io::Printer* printer) const override; + void GenerateCopyAggregateInitializer(io::Printer* printer) const override; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator); @@ -72,7 +76,7 @@ class PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator { public: PrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor, const Options& options); - ~PrimitiveOneofFieldGenerator(); + ~PrimitiveOneofFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override; @@ -88,7 +92,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { public: RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor, const Options& options); - ~RepeatedPrimitiveFieldGenerator(); + ~RepeatedPrimitiveFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const override; @@ -97,12 +101,18 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { void GenerateClearingCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateSwappingCode(io::Printer* printer) const override; - void GenerateConstructorCode(io::Printer* printer) const override; - void GenerateCopyConstructorCode(io::Printer* printer) const override; + void GenerateConstructorCode(io::Printer* printer) const override {} + void GenerateCopyConstructorCode(io::Printer* /*printer*/) const override { + GOOGLE_CHECK(!ShouldSplit(descriptor_, options_)); + } + void GenerateDestructorCode(io::Printer* printer) const override; void GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; - void GenerateConstinitInitializer(io::Printer* printer) const override; + void GenerateConstexprAggregateInitializer( + io::Printer* printer) const override; + void GenerateAggregateInitializer(io::Printer* printer) const override; + void GenerateCopyAggregateInitializer(io::Printer* printer) const override; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator); diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_service.cc b/r5dev/thirdparty/protobuf/compiler/cpp/service.cc similarity index 99% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_service.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/service.cc index a0f23c45..e8c95678 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_service.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/service.cc @@ -32,10 +32,11 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/cpp/cpp_service.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> +#include <thirdparty/protobuf/compiler/cpp/service.h> + #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_service.h b/r5dev/thirdparty/protobuf/compiler/cpp/service.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_service.h rename to r5dev/thirdparty/protobuf/compiler/cpp/service.h index 72cdce4d..b1501943 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_service.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/service.h @@ -37,8 +37,9 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/cpp/cpp_options.h> + #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/compiler/cpp/options.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_string_field.cc b/r5dev/thirdparty/protobuf/compiler/cpp/string_field.cc similarity index 77% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_string_field.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/string_field.cc index 5895ec3e..f01098f9 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_string_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/string_field.cc @@ -32,11 +32,12 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/cpp/cpp_string_field.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/descriptor.pb.h> +#include <thirdparty/protobuf/compiler/cpp/string_field.h> + #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> +#include <thirdparty/protobuf/descriptor.pb.h> namespace google { @@ -50,36 +51,30 @@ void SetStringVariables(const FieldDescriptor* descriptor, std::map<std::string, std::string>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); + + const std::string kNS = "::" + (*variables)["proto_ns"] + "::internal::"; + const std::string kArenaStringPtr = kNS + "ArenaStringPtr"; + (*variables)["default"] = DefaultValue(options, descriptor); (*variables)["default_length"] = StrCat(descriptor->default_value_string().length()); - std::string default_variable_string = MakeDefaultName(descriptor); - (*variables)["default_variable_name"] = default_variable_string; + (*variables)["default_variable_name"] = MakeDefaultName(descriptor); + (*variables)["default_variable_field"] = MakeDefaultFieldName(descriptor); - if (!descriptor->default_value_string().empty()) { + if (descriptor->default_value_string().empty()) { + (*variables)["default_string"] = kNS + "GetEmptyStringAlreadyInited()"; + (*variables)["default_value"] = "&" + (*variables)["default_string"]; + (*variables)["lazy_variable_args"] = ""; + } else { (*variables)["lazy_variable"] = - QualifiedClassName(descriptor->containing_type(), options) + - "::" + default_variable_string; + StrCat(QualifiedClassName(descriptor->containing_type(), options), + "::", MakeDefaultFieldName(descriptor)); + + (*variables)["default_string"] = (*variables)["lazy_variable"] + ".get()"; + (*variables)["default_value"] = "nullptr"; + (*variables)["lazy_variable_args"] = (*variables)["lazy_variable"] + ", "; } - (*variables)["default_string"] = - descriptor->default_value_string().empty() - ? "::" + (*variables)["proto_ns"] + - "::internal::GetEmptyStringAlreadyInited()" - : (*variables)["lazy_variable"] + ".get()"; - (*variables)["init_value"] = - descriptor->default_value_string().empty() - ? "&::" + (*variables)["proto_ns"] + - "::internal::GetEmptyStringAlreadyInited()" - : "nullptr"; - (*variables)["default_value_tag"] = - "::" + (*variables)["proto_ns"] + "::internal::ArenaStringPtr::" + - (descriptor->default_value_string().empty() ? "Empty" : "NonEmpty") + - "Default{}"; - (*variables)["default_variable_or_tag"] = - (*variables)[descriptor->default_value_string().empty() - ? "default_value_tag" - : "lazy_variable"]; (*variables)["pointer_type"] = descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char"; (*variables)["setter"] = @@ -116,10 +111,11 @@ void StringFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const { if (!inlined_) { format("::$proto_ns$::internal::ArenaStringPtr $name$_;\n"); } else { - // `_init_inline_xxx` is used for initializing default instances. - format( - "::$proto_ns$::internal::InlinedStringField $name$_;\n" - "static std::true_type _init_inline_$name$_;\n"); + // Skips the automatic destruction; rather calls it explicitly if + // allocating arena is null. This is required to support message-owned + // arena (go/path-to-arenas) where a root proto is destroyed but + // InlinedStringField may have arena-allocated memory. + format("::$proto_ns$::internal::InlinedStringField $name$_;\n"); } } @@ -130,6 +126,10 @@ void StringFieldGenerator::GenerateStaticMembers(io::Printer* printer) const { "static const ::$proto_ns$::internal::LazyString" " $default_variable_name$;\n"); } + if (inlined_) { + // `_init_inline_xxx` is used for initializing default instances. + format("static std::true_type _init_inline_$name$_;\n"); + } } void StringFieldGenerator::GenerateAccessorDeclarations( @@ -204,8 +204,8 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( " // @@protoc_insertion_point(field_get:$full_name$)\n"); if (!descriptor_->default_value_string().empty()) { format( - " if ($name$_.IsDefault(nullptr)) return " - "$default_variable_name$.get();\n"); + " if ($field$.IsDefault()) return " + "$default_variable_field$.get();\n"); } format( " return _internal_$name$();\n" @@ -215,8 +215,9 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( "template <typename ArgT0, typename... ArgT>\n" "inline PROTOBUF_ALWAYS_INLINE\n" "void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n" + "$maybe_prepare_split_message$" " $set_hasbit$\n" - " $name$_.$setter$($default_value_tag$, static_cast<ArgT0 &&>(arg0)," + " $field$.$setter$(static_cast<ArgT0 &&>(arg0)," " args..., GetArenaForAllocation());\n" "$annotate_set$" " // @@protoc_insertion_point(field_set:$full_name$)\n" @@ -226,10 +227,11 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( "template <typename ArgT0, typename... ArgT>\n" "inline PROTOBUF_ALWAYS_INLINE\n" "void $classname$::set_$name$(ArgT0&& arg0, ArgT... args) {\n" + "$maybe_prepare_split_message$" " $set_hasbit$\n" - " $name$_.$setter$(nullptr, static_cast<ArgT0 &&>(arg0)," + " $field$.$setter$(static_cast<ArgT0 &&>(arg0)," " args..., GetArenaForAllocation(), _internal_$name$_donated(), " - "&$donating_states_word$, $mask_for_undonate$);\n" + "&$donating_states_word$, $mask_for_undonate$, this);\n" "$annotate_set$" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" @@ -240,26 +242,27 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( } format( "inline std::string* $classname$::mutable_$name$() {\n" + "$maybe_prepare_split_message$" " std::string* _s = _internal_mutable_$name$();\n" "$annotate_mutable$" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" " return _s;\n" "}\n" "inline const std::string& $classname$::_internal_$name$() const {\n" - " return $name$_.Get();\n" + " return $field$.Get();\n" "}\n" "inline void $classname$::_internal_set_$name$(const std::string& " "value) {\n" " $set_hasbit$\n"); if (!inlined_) { format( - " $name$_.Set($default_value_tag$, value, GetArenaForAllocation());\n" + " $field$.Set(value, GetArenaForAllocation());\n" "}\n"); } else { format( - " $name$_.Set(nullptr, value, GetArenaForAllocation(),\n" + " $field$.Set(value, GetArenaForAllocation(),\n" " _internal_$name$_donated(), &$donating_states_word$, " - "$mask_for_undonate$);\n" + "$mask_for_undonate$, this);\n" "}\n"); } format( @@ -267,19 +270,20 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( " $set_hasbit$\n"); if (!inlined_) { format( - " return $name$_.Mutable($default_variable_or_tag$, " + " return $field$.Mutable($lazy_variable_args$" "GetArenaForAllocation());\n" "}\n"); } else { format( - " return $name$_.Mutable($default_variable_or_tag$, " + " return $field$.Mutable($lazy_variable_args$" "GetArenaForAllocation(), _internal_$name$_donated(), " - "&$donating_states_word$, $mask_for_undonate$);\n" + "&$donating_states_word$, $mask_for_undonate$, this);\n" "}\n"); } format( "inline std::string* $classname$::$release_name$() {\n" "$annotate_release$" + "$maybe_prepare_split_message$" " // @@protoc_insertion_point(field_release:$full_name$)\n"); if (HasHasbit(descriptor_)) { @@ -289,54 +293,50 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( " }\n" " $clear_hasbit$\n"); if (!inlined_) { - format( - " auto* p = $name$_.ReleaseNonDefault($init_value$, " - "GetArenaForAllocation());\n"); + format(" auto* p = $field$.Release();\n"); if (descriptor_->default_value_string().empty()) { format( "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n" - " if ($name$_.IsDefault($init_value$)) {\n" - " $name$_.Set($init_value$, \"\", GetArenaForAllocation());\n" + " if ($field$.IsDefault()) {\n" + " $field$.Set(\"\", GetArenaForAllocation());\n" " }\n" "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"); } format(" return p;\n"); } else { format( - " return $name$_.Release(nullptr, GetArenaForAllocation(), " + " return $field$.Release(GetArenaForAllocation(), " "_internal_$name$_donated());\n"); } } else { - format( - " return $name$_.Release($init_value$, GetArenaForAllocation());\n"); + format(" return $field$.Release();\n"); } format( "}\n" "inline void $classname$::set_allocated_$name$(std::string* $name$) {\n" + "$maybe_prepare_split_message$" " if ($name$ != nullptr) {\n" " $set_hasbit$\n" " } else {\n" " $clear_hasbit$\n" " }\n"); if (!inlined_) { - format( - " $name$_.SetAllocated($init_value$, $name$,\n" - " GetArenaForAllocation());\n"); + format(" $field$.SetAllocated($name$, GetArenaForAllocation());\n"); if (descriptor_->default_value_string().empty()) { format( "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n" - " if ($name$_.IsDefault($init_value$)) {\n" - " $name$_.Set($init_value$, \"\", GetArenaForAllocation());\n" + " if ($field$.IsDefault()) {\n" + " $field$.Set(\"\", GetArenaForAllocation());\n" " }\n" "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"); } } else { // Currently, string fields with default value can't be inlined. format( - " $name$_.SetAllocated(nullptr, $name$, GetArenaForAllocation(), " + " $field$.SetAllocated(nullptr, $name$, GetArenaForAllocation(), " "_internal_$name$_donated(), &$donating_states_word$, " - "$mask_for_undonate$);\n"); + "$mask_for_undonate$, this);\n"); } format( "$annotate_set$" @@ -350,7 +350,7 @@ void StringFieldGenerator::GenerateNonInlineAccessorDefinitions( if (!descriptor_->default_value_string().empty()) { format( "const ::$proto_ns$::internal::LazyString " - "$classname$::$default_variable_name$" + "$classname$::$default_variable_field$" "{{{$default$, $default_length$}}, {nullptr}};\n"); } } @@ -358,11 +358,11 @@ void StringFieldGenerator::GenerateNonInlineAccessorDefinitions( void StringFieldGenerator::GenerateClearingCode(io::Printer* printer) const { Formatter format(printer, variables_); if (descriptor_->default_value_string().empty()) { - format("$name$_.ClearToEmpty();\n"); + format("$field$.ClearToEmpty();\n"); } else { GOOGLE_DCHECK(!inlined_); format( - "$name$_.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n"); + "$field$.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n"); } } @@ -388,27 +388,27 @@ void StringFieldGenerator::GenerateMessageClearingCode( // // For non-inlined strings, we distinguish from non-default by comparing // instances, rather than contents. - format("$DCHK$(!$name$_.IsDefault(nullptr));\n"); + format("$DCHK$(!$field$.IsDefault());\n"); } if (descriptor_->default_value_string().empty()) { if (must_be_present) { - format("$name$_.ClearNonDefaultToEmpty();\n"); + format("$field$.ClearNonDefaultToEmpty();\n"); } else { - format("$name$_.ClearToEmpty();\n"); + format("$field$.ClearToEmpty();\n"); } } else { // Clear to a non-empty default is more involved, as we try to use the // Arena if one is present and may need to reallocate the string. format( - "$name$_.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n "); + "$field$.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n "); } } void StringFieldGenerator::GenerateMergingCode(io::Printer* printer) const { Formatter format(printer, variables_); // TODO(gpike): improve this - format("_internal_set_$name$(from._internal_$name$());\n"); + format("_this->_internal_set_$name$(from._internal_$name$());\n"); } void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { @@ -416,34 +416,46 @@ void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { if (!inlined_) { format( "::$proto_ns$::internal::ArenaStringPtr::InternalSwap(\n" - " $init_value$,\n" - " &$name$_, lhs_arena,\n" - " &other->$name$_, rhs_arena\n" + " &$field$, lhs_arena,\n" + " &other->$field$, rhs_arena\n" ");\n"); } else { - // At this point, it's guaranteed that the two fields being swapped are on - // the same arena. format( - "$name$_.Swap(&other->$name$_, nullptr, GetArenaForAllocation(), " - "_internal_$name$_donated(), other->_internal_$name$_donated(), " - "&$donating_states_word$, &(other->$donating_states_word$), " - "$mask_for_undonate$);\n"); + "::$proto_ns$::internal::InlinedStringField::InternalSwap(\n" + " &$field$, lhs_arena, " + "($inlined_string_donated_array$[0] & 0x1u) == 0, this,\n" + " &other->$field$, rhs_arena, " + "(other->$inlined_string_donated_array$[0] & 0x1u) == 0, other);\n"); } } void StringFieldGenerator::GenerateConstructorCode(io::Printer* printer) const { Formatter format(printer, variables_); if (inlined_ && descriptor_->default_value_string().empty()) { - // Automatic initialization will construct the string. return; } GOOGLE_DCHECK(!inlined_); - format("$name$_.UnsafeSetDefault($init_value$);\n"); + format("$field$.InitDefault();\n"); if (IsString(descriptor_, options_) && descriptor_->default_value_string().empty()) { format( "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n" - " $name$_.Set($init_value$, \"\", GetArenaForAllocation());\n" + " $field$.Set(\"\", GetArenaForAllocation());\n" + "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"); + } +} + +void StringFieldGenerator::GenerateCreateSplitMessageCode( + io::Printer* printer) const { + GOOGLE_CHECK(ShouldSplit(descriptor_, options_)); + GOOGLE_CHECK(!inlined_); + Formatter format(printer, variables_); + format("ptr->$name$_.InitDefault();\n"); + if (IsString(descriptor_, options_) && + descriptor_->default_value_string().empty()) { + format( + "#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING\n" + " ptr->$name$_.Set(\"\", GetArenaForAllocation());\n" "#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING\n"); } } @@ -452,6 +464,9 @@ void StringFieldGenerator::GenerateCopyConstructorCode( io::Printer* printer) const { Formatter format(printer, variables_); GenerateConstructorCode(printer); + if (inlined_) { + format("new (&_this->$field$) ::_pbi::InlinedStringField();\n"); + } if (HasHasbit(descriptor_)) { format("if (from._internal_has_$name$()) {\n"); @@ -463,13 +478,13 @@ void StringFieldGenerator::GenerateCopyConstructorCode( if (!inlined_) { format( - "$name$_.Set($default_value_tag$, from._internal_$name$(), \n" - " GetArenaForAllocation());\n"); + "_this->$field$.Set(from._internal_$name$(), \n" + " _this->GetArenaForAllocation());\n"); } else { format( - "$name$_.Set(nullptr, from._internal_$name$(),\n" - " GetArenaForAllocation(), _internal_$name$_donated(), " - "&$donating_states_word$, $mask_for_undonate$);\n"); + "_this->$field$.Set(from._internal_$name$(),\n" + " _this->GetArenaForAllocation(), _this->_internal_$name$_donated(), " + "&_this->$donating_states_word$, $mask_for_undonate$, _this);\n"); } format.Outdent(); @@ -478,12 +493,35 @@ void StringFieldGenerator::GenerateCopyConstructorCode( void StringFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { Formatter format(printer, variables_); - if (inlined_) { - // The destructor is automatically invoked. + if (!inlined_) { + if (ShouldSplit(descriptor_, options_)) { + format("$cached_split_ptr$->$name$_.Destroy();\n"); + return; + } + format("$field$.Destroy();\n"); return; } + // Explicitly calls ~InlinedStringField as its automatic call is disabled. + // Destructor has been implicitly skipped as a union, and even the + // message-owned arena is enabled, arena could still be missing for + // Arena::CreateMessage(nullptr). + GOOGLE_DCHECK(!ShouldSplit(descriptor_, options_)); + format("$field$.~InlinedStringField();\n"); +} - format("$name$_.DestroyNoArena($init_value$);\n"); +ArenaDtorNeeds StringFieldGenerator::NeedsArenaDestructor() const { + return inlined_ ? ArenaDtorNeeds::kOnDemand : ArenaDtorNeeds::kNone; +} + +void StringFieldGenerator::GenerateArenaDestructorCode( + io::Printer* printer) const { + if (!inlined_) return; + Formatter format(printer, variables_); + // _this is the object being destructed (we are inside a static method here). + format( + "if (!_this->_internal_$name$_donated()) {\n" + " _this->$field$.~InlinedStringField();\n" + "}\n"); } void StringFieldGenerator::GenerateSerializeWithCachedSizesToArray( @@ -509,20 +547,43 @@ void StringFieldGenerator::GenerateByteSize(io::Printer* printer) const { " this->_internal_$name$());\n"); } -void StringFieldGenerator::GenerateConstinitInitializer( +void StringFieldGenerator::GenerateConstexprAggregateInitializer( io::Printer* printer) const { Formatter format(printer, variables_); if (inlined_) { - format("$name$_(nullptr, false)"); + format("/*decltype($field$)*/{nullptr, false}"); return; } if (descriptor_->default_value_string().empty()) { - format("$name$_(&::$proto_ns$::internal::fixed_address_empty_string)"); + format( + "/*decltype($field$)*/{&::_pbi::fixed_address_empty_string, " + "::_pbi::ConstantInitialized{}}"); } else { - format("$name$_(nullptr)"); + format("/*decltype($field$)*/{nullptr, ::_pbi::ConstantInitialized{}}"); } } +void StringFieldGenerator::GenerateAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + if (ShouldSplit(descriptor_, options_)) { + GOOGLE_CHECK(!inlined_); + format("decltype(Impl_::Split::$name$_){}"); + return; + } + if (!inlined_) { + format("decltype($field$){}"); + } else { + format("decltype($field$)(arena)"); + } +} + +void StringFieldGenerator::GenerateCopyAggregateInitializer( + io::Printer* printer) const { + Formatter format(printer, variables_); + format("decltype($field$){}"); +} + // =================================================================== StringOneofFieldGenerator::StringOneofFieldGenerator( @@ -550,9 +611,9 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " if (!_internal_has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" - " $field_member$.UnsafeSetDefault($init_value$);\n" + " $field$.InitDefault();\n" " }\n" - " $field_member$.$setter$($default_value_tag$," + " $field$.$setter$(" " static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());\n" "$annotate_set$" " // @@protoc_insertion_point(field_set:$full_name$)\n" @@ -565,7 +626,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( "}\n" "inline const std::string& $classname$::_internal_$name$() const {\n" " if (_internal_has_$name$()) {\n" - " return $field_member$.Get();\n" + " return $field$.Get();\n" " }\n" " return $default_string$;\n" "}\n" @@ -574,28 +635,26 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " if (!_internal_has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" - " $field_member$.UnsafeSetDefault($init_value$);\n" + " $field$.InitDefault();\n" " }\n" - " $field_member$.Set($default_value_tag$, value, " - "GetArenaForAllocation());\n" + " $field$.Set(value, GetArenaForAllocation());\n" "}\n"); format( "inline std::string* $classname$::_internal_mutable_$name$() {\n" " if (!_internal_has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" - " $field_member$.UnsafeSetDefault($init_value$);\n" + " $field$.InitDefault();\n" " }\n" - " return $field_member$.Mutable(\n" - " $default_variable_or_tag$, GetArenaForAllocation());\n" + " return $field$.Mutable($lazy_variable_args$" + " GetArenaForAllocation());\n" "}\n" "inline std::string* $classname$::$release_name$() {\n" "$annotate_release$" " // @@protoc_insertion_point(field_release:$full_name$)\n" " if (_internal_has_$name$()) {\n" " clear_has_$oneof_name$();\n" - " return $field_member$.ReleaseNonDefault($init_value$, " - "GetArenaForAllocation());\n" + " return $field$.Release();\n" " } else {\n" " return nullptr;\n" " }\n" @@ -606,11 +665,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " }\n" " if ($name$ != nullptr) {\n" " set_has_$name$();\n" - " $field_member$.UnsafeSetDefault($name$);\n" - " ::$proto_ns$::Arena* arena = GetArenaForAllocation();\n" - " if (arena != nullptr) {\n" - " arena->Own($name$);\n" - " }\n" + " $field$.InitAllocated($name$, GetArenaForAllocation());\n" " }\n" "$annotate_set$" " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" @@ -620,9 +675,7 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( void StringOneofFieldGenerator::GenerateClearingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format( - "$field_member$.Destroy($default_value_tag$, " - "GetArenaForAllocation());\n"); + format("$field$.Destroy();\n"); } void StringOneofFieldGenerator::GenerateMessageClearingCode( @@ -737,14 +790,14 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions( format( "inline const std::string& $classname$::_internal_$name$(int index) " "const {\n" - " return $name$_.InternalCheckedGet(\n" + " return $field$.InternalCheckedGet(\n" " index, ::$proto_ns$::internal::GetEmptyStringAlreadyInited());\n" "}\n"); } else { format( "inline const std::string& $classname$::_internal_$name$(int index) " "const {\n" - " return $name$_.Get(index);\n" + " return $field$.Get(index);\n" "}\n"); } format( @@ -756,23 +809,23 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions( "inline std::string* $classname$::mutable_$name$(int index) {\n" "$annotate_mutable$" " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $name$_.Mutable(index);\n" + " return $field$.Mutable(index);\n" "}\n" "inline void $classname$::set_$name$(int index, const std::string& " "value) " "{\n" - " $name$_.Mutable(index)->assign(value);\n" + " $field$.Mutable(index)->assign(value);\n" "$annotate_set$" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" "inline void $classname$::set_$name$(int index, std::string&& value) {\n" - " $name$_.Mutable(index)->assign(std::move(value));\n" + " $field$.Mutable(index)->assign(std::move(value));\n" "$annotate_set$" " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" "inline void $classname$::set_$name$(int index, const char* value) {\n" " $null_check$" - " $name$_.Mutable(index)->assign(value);\n" + " $field$.Mutable(index)->assign(value);\n" "$annotate_set$" " // @@protoc_insertion_point(field_set_char:$full_name$)\n" "}\n"); @@ -780,7 +833,7 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions( format( "inline void " "$classname$::set_$name$(int index, StringPiece value) {\n" - " $name$_.Mutable(index)->assign(value.data(), value.size());\n" + " $field$.Mutable(index)->assign(value.data(), value.size());\n" "$annotate_set$" " // @@protoc_insertion_point(field_set_string_piece:$full_name$)\n" "}\n"); @@ -789,34 +842,34 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions( "inline void " "$classname$::set_$name$" "(int index, const $pointer_type$* value, size_t size) {\n" - " $name$_.Mutable(index)->assign(\n" + " $field$.Mutable(index)->assign(\n" " reinterpret_cast<const char*>(value), size);\n" "$annotate_set$" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" "inline std::string* $classname$::_internal_add_$name$() {\n" - " return $name$_.Add();\n" + " return $field$.Add();\n" "}\n" "inline void $classname$::add_$name$(const std::string& value) {\n" - " $name$_.Add()->assign(value);\n" + " $field$.Add()->assign(value);\n" "$annotate_add$" " // @@protoc_insertion_point(field_add:$full_name$)\n" "}\n" "inline void $classname$::add_$name$(std::string&& value) {\n" - " $name$_.Add(std::move(value));\n" + " $field$.Add(std::move(value));\n" "$annotate_add$" " // @@protoc_insertion_point(field_add:$full_name$)\n" "}\n" "inline void $classname$::add_$name$(const char* value) {\n" " $null_check$" - " $name$_.Add()->assign(value);\n" + " $field$.Add()->assign(value);\n" "$annotate_add$" " // @@protoc_insertion_point(field_add_char:$full_name$)\n" "}\n"); if (!options_.opensource_runtime) { format( "inline void $classname$::add_$name$(StringPiece value) {\n" - " $name$_.Add()->assign(value.data(), value.size());\n" + " $field$.Add()->assign(value.data(), value.size());\n" "$annotate_add$" " // @@protoc_insertion_point(field_add_string_piece:$full_name$)\n" "}\n"); @@ -824,7 +877,7 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions( format( "inline void " "$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n" - " $name$_.Add()->assign(reinterpret_cast<const char*>(value), size);\n" + " $field$.Add()->assign(reinterpret_cast<const char*>(value), size);\n" "$annotate_add$" " // @@protoc_insertion_point(field_add_pointer:$full_name$)\n" "}\n" @@ -832,43 +885,38 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions( "$classname$::$name$() const {\n" "$annotate_list$" " // @@protoc_insertion_point(field_list:$full_name$)\n" - " return $name$_;\n" + " return $field$;\n" "}\n" "inline ::$proto_ns$::RepeatedPtrField<std::string>*\n" "$classname$::mutable_$name$() {\n" "$annotate_mutable_list$" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" - " return &$name$_;\n" + " return &$field$;\n" "}\n"); } void RepeatedStringFieldGenerator::GenerateClearingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.Clear();\n"); + format("$field$.Clear();\n"); } void RepeatedStringFieldGenerator::GenerateMergingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.MergeFrom(from.$name$_);\n"); + format("_this->$field$.MergeFrom(from.$field$);\n"); } void RepeatedStringFieldGenerator::GenerateSwappingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.InternalSwap(&other->$name$_);\n"); + format("$field$.InternalSwap(&other->$field$);\n"); } -void RepeatedStringFieldGenerator::GenerateConstructorCode( - io::Printer* printer) const { - // Not needed for repeated fields. -} - -void RepeatedStringFieldGenerator::GenerateCopyConstructorCode( +void RepeatedStringFieldGenerator::GenerateDestructorCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.CopyFrom(from.$name$_);"); + format("$field$.~RepeatedPtrField();\n"); } void RepeatedStringFieldGenerator::GenerateSerializeWithCachedSizesToArray( @@ -895,20 +943,14 @@ void RepeatedStringFieldGenerator::GenerateByteSize( Formatter format(printer, variables_); format( "total_size += $tag_size$ *\n" - " ::$proto_ns$::internal::FromIntSize($name$_.size());\n" - "for (int i = 0, n = $name$_.size(); i < n; i++) {\n" + " ::$proto_ns$::internal::FromIntSize($field$.size());\n" + "for (int i = 0, n = $field$.size(); i < n; i++) {\n" " total_size += " "::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n" - " $name$_.Get(i));\n" + " $field$.Get(i));\n" "}\n"); } -void RepeatedStringFieldGenerator::GenerateConstinitInitializer( - io::Printer* printer) const { - Formatter format(printer, variables_); - format("$name$_()"); -} - } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_string_field.h b/r5dev/thirdparty/protobuf/compiler/cpp/string_field.h similarity index 86% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_string_field.h rename to r5dev/thirdparty/protobuf/compiler/cpp/string_field.h index 571451de..a9e75ed6 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_string_field.h +++ b/r5dev/thirdparty/protobuf/compiler/cpp/string_field.h @@ -37,7 +37,8 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/cpp/cpp_field.h> + +#include <thirdparty/protobuf/compiler/cpp/field.h> namespace google { namespace protobuf { @@ -48,7 +49,7 @@ class StringFieldGenerator : public FieldGenerator { public: StringFieldGenerator(const FieldDescriptor* descriptor, const Options& options); - ~StringFieldGenerator(); + ~StringFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const override; @@ -62,13 +63,19 @@ class StringFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const override; void GenerateSwappingCode(io::Printer* printer) const override; void GenerateConstructorCode(io::Printer* printer) const override; + void GenerateCreateSplitMessageCode(io::Printer* printer) const override; void GenerateCopyConstructorCode(io::Printer* printer) const override; void GenerateDestructorCode(io::Printer* printer) const override; + void GenerateArenaDestructorCode(io::Printer* printer) const override; void GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; - void GenerateConstinitInitializer(io::Printer* printer) const override; + void GenerateConstexprAggregateInitializer( + io::Printer* printer) const override; + void GenerateAggregateInitializer(io::Printer* printer) const override; + void GenerateCopyAggregateInitializer(io::Printer* printer) const override; bool IsInlined() const override { return inlined_; } + ArenaDtorNeeds NeedsArenaDestructor() const override; private: bool inlined_; @@ -79,7 +86,7 @@ class StringOneofFieldGenerator : public StringFieldGenerator { public: StringOneofFieldGenerator(const FieldDescriptor* descriptor, const Options& options); - ~StringOneofFieldGenerator(); + ~StringOneofFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GenerateInlineAccessorDefinitions(io::Printer* printer) const override; @@ -99,7 +106,7 @@ class RepeatedStringFieldGenerator : public FieldGenerator { public: RepeatedStringFieldGenerator(const FieldDescriptor* descriptor, const Options& options); - ~RepeatedStringFieldGenerator(); + ~RepeatedStringFieldGenerator() override; // implements FieldGenerator --------------------------------------- void GeneratePrivateMembers(io::Printer* printer) const override; @@ -108,12 +115,14 @@ class RepeatedStringFieldGenerator : public FieldGenerator { void GenerateClearingCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateSwappingCode(io::Printer* printer) const override; - void GenerateConstructorCode(io::Printer* printer) const override; - void GenerateCopyConstructorCode(io::Printer* printer) const override; + void GenerateConstructorCode(io::Printer* printer) const override {} + void GenerateCopyConstructorCode(io::Printer* /*printer*/) const override { + GOOGLE_CHECK(!ShouldSplit(descriptor_, options_)); + } + void GenerateDestructorCode(io::Printer* printer) const override; void GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const override; void GenerateByteSize(io::Printer* printer) const override; - void GenerateConstinitInitializer(io::Printer* printer) const override; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator); diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto b/r5dev/thirdparty/protobuf/compiler/cpp/test_bad_identifiers.proto similarity index 100% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto rename to r5dev/thirdparty/protobuf/compiler/cpp/test_bad_identifiers.proto diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_test_large_enum_value.proto b/r5dev/thirdparty/protobuf/compiler/cpp/test_large_enum_value.proto similarity index 100% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_test_large_enum_value.proto rename to r5dev/thirdparty/protobuf/compiler/cpp/test_large_enum_value.proto diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_unittest.cc b/r5dev/thirdparty/protobuf/compiler/cpp/unittest.cc similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_unittest.cc rename to r5dev/thirdparty/protobuf/compiler/cpp/unittest.cc index 35e268bb..f5a43da0 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/unittest.cc @@ -44,12 +44,11 @@ // correctly and produces the interfaces we expect, which is why this test // is written this way. -#include <thirdparty/protobuf/compiler/cpp/cpp_unittest.h> +#include <thirdparty/protobuf/compiler/cpp/unittest.h> #include <thirdparty/protobuf/unittest.pb.h> #include <thirdparty/protobuf/unittest_embed_optimize_for.pb.h> #include <thirdparty/protobuf/unittest_optimize_for.pb.h> - #include <thirdparty/protobuf/test_util.h> #define MESSAGE_TEST_NAME MessageTest @@ -65,7 +64,7 @@ #define UNITTEST_IMPORT ::protobuf_unittest_import // Must include after the above macros. -#include <thirdparty/protobuf/compiler/cpp/cpp_unittest.inc> +#include <thirdparty/protobuf/compiler/cpp/unittest.inc> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_unittest.h b/r5dev/thirdparty/protobuf/compiler/cpp/unittest.h similarity index 100% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_unittest.h rename to r5dev/thirdparty/protobuf/compiler/cpp/unittest.h diff --git a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_unittest.inc b/r5dev/thirdparty/protobuf/compiler/cpp/unittest.inc similarity index 91% rename from r5dev/thirdparty/protobuf/compiler/cpp/cpp_unittest.inc rename to r5dev/thirdparty/protobuf/compiler/cpp/unittest.inc index cf58be22..06df3b41 100644 --- a/r5dev/thirdparty/protobuf/compiler/cpp/cpp_unittest.inc +++ b/r5dev/thirdparty/protobuf/compiler/cpp/unittest.inc @@ -49,25 +49,25 @@ #include <memory> #include <vector> -#include <thirdparty/protobuf/compiler/cpp/cpp_unittest.h> +#include <thirdparty/protobuf/compiler/cpp/unittest.h> #include <thirdparty/protobuf/stubs/strutil.h> -#if !defined(GOOGLE_PROTOBUF_CMAKE_BUILD) && !defined(_MSC_VER) -// We exclude this large proto from cmake build because it's too large for +#ifndef _MSC_VER +// We exclude this large proto because it's too large for // visual studio to compile (report internal errors). #include <thirdparty/protobuf/unittest_enormous_descriptor.pb.h> #endif -#include <thirdparty/protobuf/compiler/cpp/cpp_helpers.h> -#include <thirdparty/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h> -#include <thirdparty/protobuf/compiler/scc.h> -#include <thirdparty/protobuf/compiler/importer.h> -#include <thirdparty/protobuf/test_util2.h> +#include <thirdparty/protobuf/compiler/cpp/helpers.h> +#include <thirdparty/protobuf/compiler/cpp/test_bad_identifiers.pb.h> #include <thirdparty/protobuf/unittest_no_generic_services.pb.h> -#include <thirdparty/protobuf/io/coded_stream.h> -#include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/dynamic_message.h> +#include <thirdparty/protobuf/compiler/scc.h> +#include <thirdparty/protobuf/compiler/importer.h> +#include <thirdparty/protobuf/io/coded_stream.h> +#include <thirdparty/protobuf/io/zero_copy_stream_impl.h> +#include <thirdparty/protobuf/test_util2.h> #include <thirdparty/protobuf/stubs/callback.h> #include <thirdparty/protobuf/stubs/common.h> @@ -95,7 +95,7 @@ void DoNothing() {} class MockErrorCollector : public MultiFileErrorCollector { public: MockErrorCollector() {} - ~MockErrorCollector() {} + ~MockErrorCollector() override {} std::string text_; @@ -126,7 +126,7 @@ TEST(GENERATED_DESCRIPTOR_TEST_NAME, IdenticalDescriptors) { const FileDescriptor* parsed_descriptor = importer.Import(TestUtil::MaybeTranslatePath(UNITTEST_PROTO_PATH)); EXPECT_EQ("", error_collector.text_); - ASSERT_TRUE(parsed_descriptor != NULL); + ASSERT_TRUE(parsed_descriptor != nullptr); // Test that descriptors are generated correctly by converting them to // FileDescriptorProtos and comparing. @@ -138,7 +138,7 @@ TEST(GENERATED_DESCRIPTOR_TEST_NAME, IdenticalDescriptors) { generated_descriptor_proto.DebugString()); } -#if !defined(GOOGLE_PROTOBUF_CMAKE_BUILD) && !defined(_MSC_VER) +#ifndef _MSC_VER // Test that generated code has proper descriptors: // Touch a descriptor generated from an enormous message to validate special // handling for descriptors exceeding the C++ standard's recommended minimum @@ -147,7 +147,7 @@ TEST(GENERATED_DESCRIPTOR_TEST_NAME, EnormousDescriptor) { const Descriptor* generated_descriptor = ::protobuf_unittest::TestEnormousDescriptor::descriptor(); - EXPECT_TRUE(generated_descriptor != NULL); + EXPECT_TRUE(generated_descriptor != nullptr); } #endif @@ -249,11 +249,11 @@ TEST(GENERATED_MESSAGE_TEST_NAME, StringDefaults) { } TEST(GENERATED_MESSAGE_TEST_NAME, ReleaseString) { - // Check that release_foo() starts out NULL, and gives us a value + // Check that release_foo() starts out nullptr, and gives us a value // that we can delete after it's been set. UNITTEST::TestAllTypes message; - EXPECT_EQ(NULL, message.release_default_string()); + EXPECT_EQ(nullptr, message.release_default_string()); EXPECT_FALSE(message.has_default_string()); EXPECT_EQ("hello", message.default_string()); @@ -261,30 +261,30 @@ TEST(GENERATED_MESSAGE_TEST_NAME, ReleaseString) { EXPECT_TRUE(message.has_default_string()); std::unique_ptr<std::string> str(message.release_default_string()); EXPECT_FALSE(message.has_default_string()); - ASSERT_TRUE(str != NULL); + ASSERT_TRUE(str != nullptr); EXPECT_EQ("blah", *str); - EXPECT_EQ(NULL, message.release_default_string()); + EXPECT_EQ(nullptr, message.release_default_string()); EXPECT_FALSE(message.has_default_string()); EXPECT_EQ("hello", message.default_string()); } TEST(GENERATED_MESSAGE_TEST_NAME, ReleaseMessage) { - // Check that release_foo() starts out NULL, and gives us a value + // Check that release_foo() starts out nullptr, and gives us a value // that we can delete after it's been set. UNITTEST::TestAllTypes message; - EXPECT_EQ(NULL, message.release_optional_nested_message()); + EXPECT_EQ(nullptr, message.release_optional_nested_message()); EXPECT_FALSE(message.has_optional_nested_message()); message.mutable_optional_nested_message()->set_bb(1); std::unique_ptr<UNITTEST::TestAllTypes::NestedMessage> nest( message.release_optional_nested_message()); EXPECT_FALSE(message.has_optional_nested_message()); - ASSERT_TRUE(nest != NULL); + ASSERT_TRUE(nest != nullptr); EXPECT_EQ(1, nest->bb()); - EXPECT_EQ(NULL, message.release_optional_nested_message()); + EXPECT_EQ(nullptr, message.release_optional_nested_message()); EXPECT_FALSE(message.has_optional_nested_message()); } @@ -297,7 +297,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, SetAllocatedString) { message.set_optional_string(kHello); EXPECT_TRUE(message.has_optional_string()); - message.set_allocated_optional_string(NULL); + message.set_allocated_optional_string(nullptr); EXPECT_FALSE(message.has_optional_string()); EXPECT_EQ("", message.optional_string()); @@ -315,7 +315,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, SetAllocatedMessage) { message.mutable_optional_nested_message()->set_bb(1); EXPECT_TRUE(message.has_optional_nested_message()); - message.set_allocated_optional_nested_message(NULL); + message.set_allocated_optional_nested_message(nullptr); EXPECT_FALSE(message.has_optional_nested_message()); EXPECT_EQ(&UNITTEST::TestAllTypes::NestedMessage::default_instance(), &message.optional_nested_message()); @@ -323,7 +323,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, SetAllocatedMessage) { message.mutable_optional_nested_message()->set_bb(1); UNITTEST::TestAllTypes::NestedMessage* nest = message.release_optional_nested_message(); - ASSERT_TRUE(nest != NULL); + ASSERT_TRUE(nest != nullptr); EXPECT_FALSE(message.has_optional_nested_message()); message.set_allocated_optional_nested_message(nest); @@ -339,19 +339,6 @@ TEST(GENERATED_MESSAGE_TEST_NAME, Clear) { TestUtil::SetAllFields(&message); message.Clear(); TestUtil::ExpectClear(message); - - // Unlike with the defaults test, we do NOT expect that requesting embedded - // messages will return a pointer to the default instance. Instead, they - // should return the objects that were created when mutable_blah() was - // called. - EXPECT_NE(&UNITTEST::TestAllTypes::OptionalGroup::default_instance(), - &message.optionalgroup()); - EXPECT_NE(&UNITTEST::TestAllTypes::NestedMessage::default_instance(), - &message.optional_nested_message()); - EXPECT_NE(&UNITTEST::ForeignMessage::default_instance(), - &message.optional_foreign_message()); - EXPECT_NE(&UNITTEST_IMPORT::ImportMessage::default_instance(), - &message.optional_import_message()); } TEST(GENERATED_MESSAGE_TEST_NAME, EmbeddedNullsInBytesCharStar) { @@ -406,6 +393,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, StringCharStarLength) { } +#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || defined(NDEBUG) TEST(GENERATED_MESSAGE_TEST_NAME, CopyFrom) { UNITTEST::TestAllTypes message1, message2; @@ -418,6 +406,20 @@ TEST(GENERATED_MESSAGE_TEST_NAME, CopyFrom) { TestUtil::ExpectAllFieldsSet(message2); } +TEST(GENERATED_MESSAGE_TEST_NAME, CopyAssignmentOperator) { + UNITTEST::TestAllTypes message1; + TestUtil::SetAllFields(&message1); + + UNITTEST::TestAllTypes message2; + message2 = message1; + TestUtil::ExpectAllFieldsSet(message2); + + // Make sure that self-assignment does something sane. + message2.operator=(message2); + TestUtil::ExpectAllFieldsSet(message2); +} +#endif // !PROTOBUF_TEST_NO_DESCRIPTORS || NDEBUG + TEST(GENERATED_MESSAGE_TEST_NAME, SwapWithEmpty) { UNITTEST::TestAllTypes message1, message2; @@ -503,6 +505,9 @@ TEST(GENERATED_MESSAGE_TEST_NAME, ADLSwap) { // Note the address of one of the repeated fields, to verify it was swapped // rather than copied. const int32_t* addr = &message1.repeated_int32().Get(0); +#ifdef PROTOBUF_FORCE_COPY_IN_SWAP + const int32_t value = *addr; +#endif using std::swap; swap(message1, message2); @@ -512,7 +517,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, ADLSwap) { #ifdef PROTOBUF_FORCE_COPY_IN_SWAP EXPECT_NE(addr, &message2.repeated_int32().Get(0)); - EXPECT_EQ(*addr, message2.repeated_int32().Get(0)); + EXPECT_EQ(value, message2.repeated_int32().Get(0)); #else EXPECT_EQ(addr, &message2.repeated_int32().Get(0)); #endif @@ -531,6 +536,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, CopyConstructor) { // None set. { UNITTEST::TestAllTypes message1; + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) UNITTEST::TestAllTypes message2(message1); EXPECT_FALSE(message1.has_optional_string()); @@ -588,20 +594,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, CopyConstructorWithArenas) { TestUtil::ExpectAllFieldsSet(*message2_heap); } -TEST(GENERATED_MESSAGE_TEST_NAME, CopyAssignmentOperator) { - UNITTEST::TestAllTypes message1; - TestUtil::SetAllFields(&message1); - - UNITTEST::TestAllTypes message2; - message2 = message1; - TestUtil::ExpectAllFieldsSet(message2); - - // Make sure that self-assignment does something sane. - message2.operator=(message2); - TestUtil::ExpectAllFieldsSet(message2); -} - -#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || PROTOBUF_RTTI +#ifndef PROTOBUF_TEST_NO_DESCRIPTORS TEST(GENERATED_MESSAGE_TEST_NAME, UpcastCopyFrom) { // Test the CopyFrom method that takes in the generic const Message& // parameter. @@ -614,9 +607,6 @@ TEST(GENERATED_MESSAGE_TEST_NAME, UpcastCopyFrom) { TestUtil::ExpectAllFieldsSet(message2); } -#endif - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS TEST(GENERATED_MESSAGE_TEST_NAME, DynamicMessageCopyFrom) { // Test copying from a DynamicMessage, which must fall back to using @@ -833,7 +823,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, CamelCaseFieldNames) { message.mutable_messagefield()->set_c(6); message.add_repeatedprimitivefield(8); - message.add_repeatedstringfield("qux"); + message.add_repeatedstringfield("moo"); message.add_repeatedenumfield(UNITTEST::FOREIGN_BAR); message.add_repeatedmessagefield()->set_c(15); @@ -843,7 +833,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, CamelCaseFieldNames) { EXPECT_EQ(6, message.messagefield().c()); EXPECT_EQ(8, message.repeatedprimitivefield(0)); - EXPECT_EQ("qux", message.repeatedstringfield(0)); + EXPECT_EQ("moo", message.repeatedstringfield(0)); EXPECT_EQ(UNITTEST::FOREIGN_BAR, message.repeatedenumfield(0)); EXPECT_EQ(15, message.repeatedmessagefield(0).c()); } @@ -879,82 +869,85 @@ TEST(GENERATED_MESSAGE_TEST_NAME, TestEmbedOptimizedForSize) { } TEST(GENERATED_MESSAGE_TEST_NAME, TestSpaceUsed) { - UNITTEST::TestAllTypes message1; + // Allocate explicitly on the heap to prevent arena creation. + std::unique_ptr<UNITTEST::TestAllTypes> message1( + Arena::CreateMessage<UNITTEST::TestAllTypes>(nullptr)); // sizeof provides a lower bound on SpaceUsedLong(). - EXPECT_LE(sizeof(UNITTEST::TestAllTypes), message1.SpaceUsedLong()); - const size_t empty_message_size = message1.SpaceUsedLong(); + EXPECT_LE(sizeof(UNITTEST::TestAllTypes), message1->SpaceUsedLong()); + const size_t empty_message_size = message1->SpaceUsedLong(); // Setting primitive types shouldn't affect the space used. - message1.set_optional_int32(123); - message1.set_optional_int64(12345); - message1.set_optional_uint32(123); - message1.set_optional_uint64(12345); - EXPECT_EQ(empty_message_size, message1.SpaceUsedLong()); + message1->set_optional_int32(123); + message1->set_optional_int64(12345); + message1->set_optional_uint32(123); + message1->set_optional_uint64(12345); + EXPECT_EQ(empty_message_size, message1->SpaceUsedLong()); // On some STL implementations, setting the string to a small value should // only increase SpaceUsedLong() by the size of a string object, though this // is not true everywhere. - message1.set_optional_string("abc"); - EXPECT_LE(empty_message_size + message1.optional_string().size(), - message1.SpaceUsedLong()); + message1->set_optional_string("abc"); + EXPECT_LE(empty_message_size + message1->optional_string().size(), + message1->SpaceUsedLong()); // Setting a string to a value larger than the string object itself should // increase SpaceUsedLong(), because it cannot store the value internally. - message1.set_optional_string(std::string(sizeof(std::string) + 1, 'x')); - int min_expected_increase = message1.optional_string().capacity(); + message1->set_optional_string(std::string(sizeof(std::string) + 1, 'x')); + int min_expected_increase = message1->optional_string().capacity(); EXPECT_LE(empty_message_size + min_expected_increase, - message1.SpaceUsedLong()); + message1->SpaceUsedLong()); - size_t previous_size = message1.SpaceUsedLong(); + size_t previous_size = message1->SpaceUsedLong(); // Adding an optional message should increase the size by the size of the // nested message type. NestedMessage is simple enough (1 int field) that it // is equal to sizeof(NestedMessage) - message1.mutable_optional_nested_message(); + message1->mutable_optional_nested_message(); ASSERT_EQ(sizeof(UNITTEST::TestAllTypes::NestedMessage), - message1.optional_nested_message().SpaceUsedLong()); + message1->optional_nested_message().SpaceUsedLong()); EXPECT_EQ(previous_size + sizeof(UNITTEST::TestAllTypes::NestedMessage), - message1.SpaceUsedLong()); + message1->SpaceUsedLong()); } TEST(GENERATED_MESSAGE_TEST_NAME, TestOneofSpaceUsed) { - UNITTEST::TestOneof2 message1; - EXPECT_LE(sizeof(UNITTEST::TestOneof2), message1.SpaceUsedLong()); + // Allocate explicitly on the heap to prevent arena creation. + std::unique_ptr<UNITTEST::TestOneof2> message1( + Arena::CreateMessage<UNITTEST::TestOneof2>(nullptr)); + EXPECT_LE(sizeof(UNITTEST::TestOneof2), message1->SpaceUsedLong()); - const size_t empty_message_size = message1.SpaceUsedLong(); + const size_t empty_message_size = message1->SpaceUsedLong(); // Setting primitive types shouldn't affect the space used. - message1.set_foo_int(123); - message1.set_bar_int(12345); - EXPECT_EQ(empty_message_size, message1.SpaceUsedLong()); + message1->set_foo_int(123); + message1->set_bar_int(12345); + EXPECT_EQ(empty_message_size, message1->SpaceUsedLong()); // Setting a string in oneof to a small value should only increase // SpaceUsedLong() by the size of a string object. - message1.set_foo_string("abc"); - EXPECT_LE(empty_message_size + sizeof(std::string), message1.SpaceUsedLong()); + message1->set_foo_string("abc"); + EXPECT_LE(empty_message_size + sizeof(std::string), message1->SpaceUsedLong()); // Setting a string in oneof to a value larger than the string object itself // should increase SpaceUsedLong(), because it cannot store the value // internally. - message1.set_foo_string(std::string(sizeof(std::string) + 1, 'x')); + message1->set_foo_string(std::string(sizeof(std::string) + 1, 'x')); int min_expected_increase = - message1.foo_string().capacity() + sizeof(std::string); + message1->foo_string().capacity() + sizeof(std::string); EXPECT_LE(empty_message_size + min_expected_increase, - message1.SpaceUsedLong()); + message1->SpaceUsedLong()); // Setting a message in oneof should delete the other fields and increase the // size by the size of the nested message type. NestedMessage is simple enough // that it is equal to sizeof(NestedMessage). It may be backed by LazyField, // increasing space used by LazyField and backing Cord. - message1.mutable_foo_message(); + message1->mutable_foo_message(); ASSERT_EQ(sizeof(UNITTEST::TestOneof2::NestedMessage), - message1.foo_message().SpaceUsedLong()); + message1->foo_message().SpaceUsedLong()); EXPECT_LE(empty_message_size + sizeof(UNITTEST::TestOneof2::NestedMessage), - message1.SpaceUsedLong()); + message1->SpaceUsedLong()); } #endif // !PROTOBUF_TEST_NO_DESCRIPTORS - TEST(GENERATED_MESSAGE_TEST_NAME, FieldConstantValues) { UNITTEST::TestRequired message; EXPECT_EQ(UNITTEST::TestAllTypes_NestedMessage::kBbFieldNumber, 1); @@ -1065,14 +1058,13 @@ TEST(GENERATED_ENUM_TEST_NAME, MinAndMax) { EXPECT_EQ(12589235, UNITTEST::TestSparseEnum_ARRAYSIZE); // Make sure we can take the address of _MIN, _MAX and _ARRAYSIZE. - void* null_pointer = 0; // NULL may be integer-type, not pointer-type. - EXPECT_NE(null_pointer, &UNITTEST::TestAllTypes::NestedEnum_MIN); - EXPECT_NE(null_pointer, &UNITTEST::TestAllTypes::NestedEnum_MAX); - EXPECT_NE(null_pointer, &UNITTEST::TestAllTypes::NestedEnum_ARRAYSIZE); + EXPECT_NE(nullptr, &UNITTEST::TestAllTypes::NestedEnum_MIN); + EXPECT_NE(nullptr, &UNITTEST::TestAllTypes::NestedEnum_MAX); + EXPECT_NE(nullptr, &UNITTEST::TestAllTypes::NestedEnum_ARRAYSIZE); - EXPECT_NE(null_pointer, &UNITTEST::ForeignEnum_MIN); - EXPECT_NE(null_pointer, &UNITTEST::ForeignEnum_MAX); - EXPECT_NE(null_pointer, &UNITTEST::ForeignEnum_ARRAYSIZE); + EXPECT_NE(nullptr, &UNITTEST::ForeignEnum_MIN); + EXPECT_NE(nullptr, &UNITTEST::ForeignEnum_MAX); + EXPECT_NE(nullptr, &UNITTEST::ForeignEnum_ARRAYSIZE); // Make sure we can use _MIN and _MAX as switch cases. switch (UNITTEST::SPARSE_A) { @@ -1146,14 +1138,14 @@ class GENERATED_SERVICE_TEST_NAME : public testing::Test { class MockTestService : public UNITTEST::TestService { public: MockTestService() - : called_(false), - method_(""), - controller_(NULL), - request_(NULL), - response_(NULL), - done_(NULL) {} + : called_(false), + method_(""), + controller_(nullptr), + request_(nullptr), + response_(nullptr), + done_(nullptr) {} - ~MockTestService() {} + ~MockTestService() override {} void Reset() { called_ = false; } @@ -1194,16 +1186,16 @@ class GENERATED_SERVICE_TEST_NAME : public testing::Test { class MockRpcChannel : public RpcChannel { public: MockRpcChannel() - : called_(false), - method_(NULL), - controller_(NULL), - request_(NULL), - response_(NULL), - done_(NULL), - destroyed_(NULL) {} + : called_(false), + method_(nullptr), + controller_(nullptr), + request_(nullptr), + response_(nullptr), + done_(nullptr), + destroyed_(nullptr) {} - ~MockRpcChannel() { - if (destroyed_ != NULL) *destroyed_ = true; + ~MockRpcChannel() override { + if (destroyed_ != nullptr) *destroyed_ = true; } void Reset() { called_ = false; } @@ -1269,8 +1261,8 @@ class GENERATED_SERVICE_TEST_NAME : public testing::Test { done_(::google::protobuf::NewPermanentCallback(&DoNothing)) {} void SetUp() override { - ASSERT_TRUE(foo_ != NULL); - ASSERT_TRUE(bar_ != NULL); + ASSERT_TRUE(foo_ != nullptr); + ASSERT_TRUE(bar_ != nullptr); } const ServiceDescriptor* descriptor_; @@ -1480,7 +1472,7 @@ TEST_F(OneofTest, SettingOneFieldClearsOthers) { TestUtil::ExpectAtMostOneFieldSetInOneof(message); - message.set_foo_bytes("qux"); + message.set_foo_bytes("moo"); EXPECT_TRUE(message.has_foo_bytes()); TestUtil::ExpectAtMostOneFieldSetInOneof(message); @@ -1488,7 +1480,7 @@ TEST_F(OneofTest, SettingOneFieldClearsOthers) { EXPECT_TRUE(message.has_foo_enum()); TestUtil::ExpectAtMostOneFieldSetInOneof(message); - message.mutable_foo_message()->set_qux_int(234); + message.mutable_foo_message()->set_moo_int(234); EXPECT_TRUE(message.has_foo_message()); TestUtil::ExpectAtMostOneFieldSetInOneof(message); @@ -1511,11 +1503,11 @@ TEST_F(OneofTest, EnumCases) { ExpectEnumCasesWork(message); message.set_foo_string("foo"); ExpectEnumCasesWork(message); - message.set_foo_bytes("qux"); + message.set_foo_bytes("moo"); ExpectEnumCasesWork(message); message.set_foo_enum(UNITTEST::TestOneof2::FOO); ExpectEnumCasesWork(message); - message.mutable_foo_message()->set_qux_int(234); + message.mutable_foo_message()->set_moo_int(234); ExpectEnumCasesWork(message); message.mutable_foogroup()->set_a(345); ExpectEnumCasesWork(message); @@ -1565,15 +1557,15 @@ TEST_F(OneofTest, SetString) { EXPECT_FALSE(message.has_foo_string()); - message.set_foo_string("qux", 3); + message.set_foo_string("moo", 3); EXPECT_TRUE(message.has_foo_string()); - EXPECT_EQ(message.foo_string(), "qux"); + EXPECT_EQ(message.foo_string(), "moo"); message.clear_foo_string(); EXPECT_FALSE(message.has_foo_string()); - message.mutable_foo_string()->assign("quux"); + message.mutable_foo_string()->assign("mooo"); EXPECT_TRUE(message.has_foo_string()); - EXPECT_EQ(message.foo_string(), "quux"); + EXPECT_EQ(message.foo_string(), "mooo"); message.clear_foo_string(); EXPECT_FALSE(message.has_foo_string()); @@ -1585,21 +1577,21 @@ TEST_F(OneofTest, SetString) { } TEST_F(OneofTest, ReleaseString) { - // Check that release_foo() starts out NULL, and gives us a value + // Check that release_foo() starts out nullptr, and gives us a value // that we can delete after it's been set. UNITTEST::TestOneof2 message; - EXPECT_EQ(NULL, message.release_foo_string()); + EXPECT_EQ(nullptr, message.release_foo_string()); EXPECT_FALSE(message.has_foo_string()); message.set_foo_string("blah"); EXPECT_TRUE(message.has_foo_string()); std::unique_ptr<std::string> str(message.release_foo_string()); EXPECT_FALSE(message.has_foo_string()); - ASSERT_TRUE(str != NULL); + ASSERT_TRUE(str != nullptr); EXPECT_EQ("blah", *str); - EXPECT_EQ(NULL, message.release_foo_string()); + EXPECT_EQ(nullptr, message.release_foo_string()); EXPECT_FALSE(message.has_foo_string()); } @@ -1612,7 +1604,7 @@ TEST_F(OneofTest, SetAllocatedString) { message.set_foo_string(kHello); EXPECT_TRUE(message.has_foo_string()); - message.set_allocated_foo_string(NULL); + message.set_allocated_foo_string(nullptr); EXPECT_FALSE(message.has_foo_string()); EXPECT_EQ("", message.foo_string()); @@ -1632,7 +1624,7 @@ TEST_F(OneofTest, ArenaSetAllocatedString) { message->set_foo_string(kHello); EXPECT_TRUE(message->has_foo_string()); - message->set_allocated_foo_string(NULL); + message->set_allocated_foo_string(nullptr); EXPECT_FALSE(message->has_foo_string()); EXPECT_EQ("", message->foo_string()); @@ -1649,32 +1641,32 @@ TEST_F(OneofTest, SetMessage) { // Unset field returns default instance EXPECT_EQ(&message.foo_message(), &UNITTEST::TestOneof2_NestedMessage::default_instance()); - EXPECT_EQ(message.foo_message().qux_int(), 0); + EXPECT_EQ(message.foo_message().moo_int(), 0); - message.mutable_foo_message()->set_qux_int(234); + message.mutable_foo_message()->set_moo_int(234); EXPECT_TRUE(message.has_foo_message()); - EXPECT_EQ(message.foo_message().qux_int(), 234); + EXPECT_EQ(message.foo_message().moo_int(), 234); message.clear_foo_message(); EXPECT_FALSE(message.has_foo_message()); } TEST_F(OneofTest, ReleaseMessage) { - // Check that release_foo() starts out NULL, and gives us a value + // Check that release_foo() starts out nullptr, and gives us a value // that we can delete after it's been set. UNITTEST::TestOneof2 message; - EXPECT_EQ(NULL, message.release_foo_message()); + EXPECT_EQ(nullptr, message.release_foo_message()); EXPECT_FALSE(message.has_foo_message()); - message.mutable_foo_message()->set_qux_int(1); + message.mutable_foo_message()->set_moo_int(1); EXPECT_TRUE(message.has_foo_message()); std::unique_ptr<UNITTEST::TestOneof2_NestedMessage> mes( message.release_foo_message()); EXPECT_FALSE(message.has_foo_message()); - ASSERT_TRUE(mes != NULL); - EXPECT_EQ(1, mes->qux_int()); + ASSERT_TRUE(mes != nullptr); + EXPECT_EQ(1, mes->moo_int()); - EXPECT_EQ(NULL, message.release_foo_message()); + EXPECT_EQ(nullptr, message.release_foo_message()); EXPECT_FALSE(message.has_foo_message()); } @@ -1684,22 +1676,22 @@ TEST_F(OneofTest, SetAllocatedMessage) { EXPECT_FALSE(message.has_foo_message()); - message.mutable_foo_message()->set_qux_int(1); + message.mutable_foo_message()->set_moo_int(1); EXPECT_TRUE(message.has_foo_message()); - message.set_allocated_foo_message(NULL); + message.set_allocated_foo_message(nullptr); EXPECT_FALSE(message.has_foo_message()); EXPECT_EQ(&message.foo_message(), &UNITTEST::TestOneof2_NestedMessage::default_instance()); - message.mutable_foo_message()->set_qux_int(1); + message.mutable_foo_message()->set_moo_int(1); UNITTEST::TestOneof2_NestedMessage* mes = message.release_foo_message(); - ASSERT_TRUE(mes != NULL); + ASSERT_TRUE(mes != nullptr); EXPECT_FALSE(message.has_foo_message()); message.set_allocated_foo_message(mes); EXPECT_TRUE(message.has_foo_message()); - EXPECT_EQ(1, message.foo_message().qux_int()); + EXPECT_EQ(1, message.foo_message().moo_int()); } @@ -1729,7 +1721,7 @@ TEST_F(OneofTest, Defaults) { EXPECT_EQ(message.foo_enum(), 1); EXPECT_FALSE(message.has_foo_message()); - EXPECT_EQ(message.foo_message().qux_int(), 0); + EXPECT_EQ(message.foo_message().moo_int(), 0); EXPECT_FALSE(message.has_foogroup()); EXPECT_EQ(message.foogroup().a(), 0); @@ -1773,14 +1765,14 @@ TEST_F(OneofTest, SwapBothHasFields) { message1.set_foo_string("FOO"); EXPECT_TRUE(message1.has_foo_string()); - message2.mutable_foo_message()->set_qux_int(1); + message2.mutable_foo_message()->set_moo_int(1); EXPECT_TRUE(message2.has_foo_message()); message1.Swap(&message2); EXPECT_FALSE(message1.has_foo_string()); EXPECT_FALSE(message2.has_foo_message()); EXPECT_TRUE(message1.has_foo_message()); - EXPECT_EQ(message1.foo_message().qux_int(), 1); + EXPECT_EQ(message1.foo_message().moo_int(), 1); EXPECT_TRUE(message2.has_foo_string()); EXPECT_EQ(message2.foo_string(), "FOO"); } @@ -1811,16 +1803,16 @@ TEST_F(OneofTest, CopyFrom) { TEST_F(OneofTest, CopyAssignmentOperator) { UNITTEST::TestOneof2 message1; - message1.mutable_foo_message()->set_qux_int(123); + message1.mutable_foo_message()->set_moo_int(123); EXPECT_TRUE(message1.has_foo_message()); UNITTEST::TestOneof2 message2; message2 = message1; - EXPECT_EQ(message2.foo_message().qux_int(), 123); + EXPECT_EQ(message2.foo_message().moo_int(), 123); // Make sure that self-assignment does something sane. message2 = *&message2; // Avoid -Wself-assign. - EXPECT_EQ(message2.foo_message().qux_int(), 123); + EXPECT_EQ(message2.foo_message().moo_int(), 123); } TEST_F(OneofTest, UpcastCopyFrom) { @@ -1875,14 +1867,14 @@ EXPECT_EQ(message2.foo_int(), 123); { UNITTEST::TestOneof2 message1, message2; std::string data; - message1.set_foo_bytes("qux"); + message1.set_foo_bytes("moo"); int size = message1.ByteSizeLong(); data.resize(size); uint8_t* start = reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&data)); uint8_t* end = message1.SerializeWithCachedSizesToArray(start); EXPECT_EQ(size, end - start); EXPECT_TRUE(message2.ParseFromString(data)); - EXPECT_EQ(message2.foo_bytes(), "qux"); + EXPECT_EQ(message2.foo_bytes(), "moo"); } // Enum @@ -1903,14 +1895,14 @@ EXPECT_EQ(message2.foo_int(), 123); { UNITTEST::TestOneof2 message1, message2; std::string data; - message1.mutable_foo_message()->set_qux_int(234); + message1.mutable_foo_message()->set_moo_int(234); int size = message1.ByteSizeLong(); data.resize(size); uint8_t* start = reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&data)); uint8_t* end = message1.SerializeWithCachedSizesToArray(start); EXPECT_EQ(size, end - start); EXPECT_TRUE(message2.ParseFromString(data)); - EXPECT_EQ(message2.foo_message().qux_int(), 234); + EXPECT_EQ(message2.foo_message().moo_int(), 234); } // Group @@ -1982,7 +1974,7 @@ data.resize(size); { UNITTEST::TestOneof2 message1, message2; std::string data; - message1.set_foo_bytes("qux"); + message1.set_foo_bytes("moo"); int size = message1.ByteSizeLong(); data.resize(size); @@ -1996,7 +1988,7 @@ data.resize(size); } EXPECT_TRUE(message2.ParseFromString(data)); - EXPECT_EQ(message2.foo_bytes(), "qux"); + EXPECT_EQ(message2.foo_bytes(), "moo"); } // Enum @@ -2024,7 +2016,7 @@ data.resize(size); { UNITTEST::TestOneof2 message1, message2; std::string data; - message1.mutable_foo_message()->set_qux_int(234); + message1.mutable_foo_message()->set_moo_int(234); int size = message1.ByteSizeLong(); data.resize(size); @@ -2038,7 +2030,7 @@ data.resize(size); } EXPECT_TRUE(message2.ParseFromString(data)); - EXPECT_EQ(message2.foo_message().qux_int(), 234); + EXPECT_EQ(message2.foo_message().moo_int(), 234); } // Group @@ -2080,11 +2072,11 @@ TEST_F(OneofTest, MergeFrom) { EXPECT_EQ(message2.foo_string(), "foo"); - message1.set_foo_bytes("qux"); + message1.set_foo_bytes("moo"); message2.MergeFrom(message1); TestUtil::ExpectAtMostOneFieldSetInOneof(message2); EXPECT_TRUE(message2.has_foo_bytes()); - EXPECT_EQ(message2.foo_bytes(), "qux"); + EXPECT_EQ(message2.foo_bytes(), "moo"); message1.set_foo_enum(UNITTEST::TestOneof2::FOO); message2.MergeFrom(message1); @@ -2092,11 +2084,11 @@ TEST_F(OneofTest, MergeFrom) { EXPECT_TRUE(message2.has_foo_enum()); EXPECT_EQ(message2.foo_enum(), UNITTEST::TestOneof2::FOO); - message1.mutable_foo_message()->set_qux_int(234); + message1.mutable_foo_message()->set_moo_int(234); message2.MergeFrom(message1); TestUtil::ExpectAtMostOneFieldSetInOneof(message2); EXPECT_TRUE(message2.has_foo_message()); - EXPECT_EQ(message2.foo_message().qux_int(), 234); + EXPECT_EQ(message2.foo_message().moo_int(), 234); message1.mutable_foogroup()->set_a(345); message2.MergeFrom(message1); diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc index 2ad5f41b..731a33d9 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc @@ -110,13 +110,14 @@ class MockGeneratorContext : public GeneratorContext { class GenerateAndTest { public: GenerateAndTest() {} - void Run(const FileDescriptor* proto_file, std::string file1, std::string file2) { + void Run(const FileDescriptor* proto_file, std::string file1, + std::string file2) { ASSERT_TRUE(proto_file != NULL) << TestSourceDir(); ASSERT_TRUE(generator_.Generate(proto_file, parameter_, &context_, &error_)); context_.ExpectFileMatches(file1, file2); } - void SetParameter(string parameter) { + void SetParameter(std::string parameter) { parameter_ = parameter; } diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_enum_field.cc b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_enum_field.cc index c2e17162..9859d664 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_enum_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_enum_field.cc @@ -109,7 +109,7 @@ void EnumOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, "$oneof_name$_ = input.ReadEnum();\n" - "$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n"); + "$oneof_name$Case_ = $oneof_property_name$OneofCase.$oneof_case_name$;\n"); } void EnumOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) { diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_enum_field.h b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_enum_field.h index b0e83a5d..30794dde 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_enum_field.h +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_enum_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__ -#include <string> - #include <thirdparty/protobuf/compiler/code_generator.h> #include <thirdparty/protobuf/compiler/csharp/csharp_primitive_field.h> diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_field_base.cc b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_field_base.cc index 8904aec1..4961b694 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_field_base.cc +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_field_base.cc @@ -61,7 +61,7 @@ void FieldGeneratorBase::SetCommonFieldVariables( part_tag_size /= 2; } uint tag = internal::WireFormat::MakeTag(descriptor_); - uint8 tag_array[5]; + uint8_t tag_array[5]; io::CodedOutputStream::WriteTagToArray(tag, tag_array); std::string tag_bytes = StrCat(tag_array[0]); for (int i = 1; i < part_tag_size; i++) { @@ -130,8 +130,9 @@ void FieldGeneratorBase::SetCommonOneofFieldVariables( } else { (*variables)["has_property_check"] = oneof_name() + "Case_ == " + oneof_property_name() + - "OneofCase." + property_name(); + "OneofCase." + oneof_case_name(); } + (*variables)["oneof_case_name"] = oneof_case_name(); (*variables)["oneof_property_name"] = oneof_property_name(); } @@ -187,6 +188,10 @@ void FieldGeneratorBase::AddPublicMemberAttributes(io::Printer* printer) { WriteGeneratedCodeAttributes(printer); } +std::string FieldGeneratorBase::oneof_case_name() { + return GetOneofCaseName(descriptor_); +} + std::string FieldGeneratorBase::oneof_property_name() { return UnderscoresToCamelCase(descriptor_->containing_oneof()->name(), true); } diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_field_base.h b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_field_base.h index 6a36f11a..acecb13e 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_field_base.h +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_field_base.h @@ -85,6 +85,7 @@ class FieldGeneratorBase : public SourceGeneratorBase { std::map<std::string, std::string>* variables); std::string oneof_property_name(); + std::string oneof_case_name(); std::string oneof_name(); std::string property_name(); std::string name(); diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_generator_unittest.cc b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_generator_unittest.cc index 13897987..321c4b16 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_generator_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_generator_unittest.cc @@ -30,14 +30,14 @@ #include <memory> +#include <thirdparty/protobuf/any.pb.h> #include <thirdparty/protobuf/compiler/command_line_interface.h> #include <thirdparty/protobuf/compiler/csharp/csharp_helpers.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> -#include <thirdparty/protobuf/testing/file.h> namespace google { namespace protobuf { @@ -63,6 +63,17 @@ TEST(CSharpEnumValue, PascalCasedPrefixStripping) { EXPECT_EQ("_2", GetEnumValueName("Foo", "FOO___2")); } +TEST(DescriptorProtoHelpers, IsDescriptorProto) { + EXPECT_TRUE(IsDescriptorProto(DescriptorProto::descriptor()->file())); + EXPECT_FALSE(IsDescriptorProto(google::protobuf::Any::descriptor()->file())); +} + +TEST(DescriptorProtoHelpers, IsDescriptorOptionMessage) { + EXPECT_TRUE(IsDescriptorOptionMessage(FileOptions::descriptor())); + EXPECT_FALSE(IsDescriptorOptionMessage(google::protobuf::Any::descriptor())); + EXPECT_FALSE(IsDescriptorOptionMessage(DescriptorProto::descriptor())); +} + } // namespace } // namespace csharp } // namespace compiler diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_helpers.cc b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_helpers.cc index b6633157..a4eafe6c 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_helpers.cc +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_helpers.cc @@ -393,6 +393,13 @@ std::string GetPropertyName(const FieldDescriptor* descriptor) { return property_name; } +std::string GetOneofCaseName(const FieldDescriptor* descriptor) { + // The name in a oneof case enum is the same as for the property, but as we always have a "None" + // value as well, we need to reserve that by appending an underscore. + std::string property_name = GetPropertyName(descriptor); + return property_name == "None" ? "None_" : property_name; +} + std::string GetOutputFile(const FileDescriptor* descriptor, const std::string file_extension, const bool generate_directories, diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_helpers.h b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_helpers.h index 359688ef..36410313 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_helpers.h +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_helpers.h @@ -87,6 +87,8 @@ std::string GetFieldConstantName(const FieldDescriptor* field); std::string GetPropertyName(const FieldDescriptor* descriptor); +std::string GetOneofCaseName(const FieldDescriptor* descriptor); + int GetFixedSize(FieldDescriptor::Type type); std::string UnderscoresToCamelCase(const std::string& input, @@ -130,7 +132,8 @@ uint GetGroupEndTag(const Descriptor* descriptor); // descriptors etc, for use in the runtime. This is the only type which is // allowed to use proto2 syntax, and it generates internal classes. inline bool IsDescriptorProto(const FileDescriptor* descriptor) { - return descriptor->name() == "google/protobuf/descriptor.proto"; + return descriptor->name() == "google/protobuf/descriptor.proto" || + descriptor->name() == "net/proto2/proto/descriptor.proto"; } // Determines whether the given message is an options message within descriptor.proto. @@ -138,15 +141,15 @@ inline bool IsDescriptorOptionMessage(const Descriptor* descriptor) { if (!IsDescriptorProto(descriptor->file())) { return false; } - const std::string name = descriptor->full_name(); - return name == "google.protobuf.FileOptions" || - name == "google.protobuf.MessageOptions" || - name == "google.protobuf.FieldOptions" || - name == "google.protobuf.OneofOptions" || - name == "google.protobuf.EnumOptions" || - name == "google.protobuf.EnumValueOptions" || - name == "google.protobuf.ServiceOptions" || - name == "google.protobuf.MethodOptions"; + const std::string name = descriptor->name(); + return name == "FileOptions" || + name == "MessageOptions" || + name == "FieldOptions" || + name == "OneofOptions" || + name == "EnumOptions" || + name == "EnumValueOptions" || + name == "ServiceOptions" || + name == "MethodOptions"; } inline bool IsWrapperType(const FieldDescriptor* descriptor) { diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_map_field.cc b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_map_field.cc index 47934450..c496edd0 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_map_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_map_field.cc @@ -57,9 +57,9 @@ MapFieldGenerator::~MapFieldGenerator() { void MapFieldGenerator::GenerateMembers(io::Printer* printer) { const FieldDescriptor* key_descriptor = - descriptor_->message_type()->FindFieldByName("key"); + descriptor_->message_type()->map_key(); const FieldDescriptor* value_descriptor = - descriptor_->message_type()->FindFieldByName("value"); + descriptor_->message_type()->map_value(); variables_["key_type_name"] = type_name(key_descriptor); variables_["value_type_name"] = type_name(value_descriptor); std::unique_ptr<FieldGeneratorBase> key_generator( diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_map_field.h b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_map_field.h index 6d826ae5..e0e837dc 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_map_field.h +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_map_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__ -#include <string> - #include <thirdparty/protobuf/compiler/code_generator.h> #include <thirdparty/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_message.cc b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_message.cc index e478cf6a..b4797062 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_message.cc +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_message.cc @@ -238,8 +238,8 @@ void MessageGenerator::Generate(io::Printer* printer) { printer->Print("None = 0,\n"); for (int j = 0; j < oneof->field_count(); j++) { const FieldDescriptor* field = oneof->field(j); - printer->Print("$field_property_name$ = $index$,\n", - "field_property_name", GetPropertyName(field), + printer->Print("$oneof_case_name$ = $index$,\n", + "oneof_case_name", GetOneofCaseName(field), "index", StrCat(field->number())); } printer->Outdent(); @@ -403,10 +403,10 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) { for (int j = 0; j < oneof->field_count(); j++) { const FieldDescriptor* field = oneof->field(j); std::unique_ptr<FieldGeneratorBase> generator(CreateFieldGeneratorInternal(field)); - vars["field_property_name"] = GetPropertyName(field); + vars["oneof_case_name"] = GetOneofCaseName(field); printer->Print( vars, - "case $property_name$OneofCase.$field_property_name$:\n"); + "case $property_name$OneofCase.$oneof_case_name$:\n"); printer->Indent(); generator->GenerateCloningCode(printer); printer->Print("break;\n"); @@ -635,10 +635,10 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { printer->Indent(); for (int j = 0; j < oneof->field_count(); j++) { const FieldDescriptor* field = oneof->field(j); - vars["field_property_name"] = GetPropertyName(field); + vars["oneof_case_name"] = GetOneofCaseName(field); printer->Print( vars, - "case $property_name$OneofCase.$field_property_name$:\n"); + "case $property_name$OneofCase.$oneof_case_name$:\n"); printer->Indent(); std::unique_ptr<FieldGeneratorBase> generator(CreateFieldGeneratorInternal(field)); generator->GenerateMergingCode(printer); @@ -717,7 +717,7 @@ void MessageGenerator::GenerateMainParseLoop(io::Printer* printer, bool use_pars const FieldDescriptor* field = fields_by_number()[i]; internal::WireFormatLite::WireType wt = internal::WireFormat::WireTypeForFieldType(field->type()); - uint32 tag = internal::WireFormatLite::MakeTag(field->number(), wt); + uint32_t tag = internal::WireFormatLite::MakeTag(field->number(), wt); // Handle both packed and unpacked repeated fields with the same Read*Array call; // the two generated cases are the packed and unpacked tags. // TODO(jonskeet): Check that is_packable is equivalent to diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_message_field.cc b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_message_field.cc index 44e88085..0c7c5b68 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_message_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_message_field.cc @@ -225,7 +225,7 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : null; }\n" " set {\n" " $oneof_name$_ = value;\n" - " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n" + " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$oneof_case_name$;\n" " }\n" "}\n"); if (SupportsPresenceApi(descriptor_)) { @@ -236,7 +236,7 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { printer->Print( variables_, "$access_level$ bool Has$property_name$ {\n" - " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$property_name$; }\n" + " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$oneof_case_name$; }\n" "}\n"); printer->Print( variables_, diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_message_field.h b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_message_field.h index 4b5d9f10..cef99361 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_message_field.h +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_message_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__ -#include <string> - #include <thirdparty/protobuf/compiler/code_generator.h> #include <thirdparty/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_primitive_field.cc b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_primitive_field.cc index ce2ee004..931f1eae 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -296,7 +296,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { } printer->Print( variables_, - " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" + " $oneof_name$Case_ = $oneof_property_name$OneofCase.$oneof_case_name$;\n" " }\n" "}\n"); if (SupportsPresenceApi(descriptor_)) { @@ -307,7 +307,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { printer->Print( variables_, "$access_level$ bool Has$property_name$ {\n" - " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$property_name$; }\n" + " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$oneof_case_name$; }\n" "}\n"); printer->Print( variables_, diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_primitive_field.h b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_primitive_field.h index dac69fd7..6a2d3f5c 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_primitive_field.h +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_primitive_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__ -#include <string> - #include <thirdparty/protobuf/compiler/code_generator.h> #include <thirdparty/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_reflection_class.cc b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_reflection_class.cc index 04bc9c87..044a6f03 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_reflection_class.cc +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_reflection_class.cc @@ -128,7 +128,7 @@ void ReflectionClassGenerator::WriteIntroduction(io::Printer* printer) { "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" "// source: $file_name$\n" "// </auto-generated>\n" - "#pragma warning disable 1591, 0612, 3021\n" + "#pragma warning disable 1591, 0612, 3021, 8981\n" "#region Designer generated code\n" "\n" "using pb = global::Google.Protobuf;\n" diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_repeated_enum_field.h b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_repeated_enum_field.h index 97c7f388..b0213237 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_repeated_enum_field.h +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_repeated_enum_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__ -#include <string> - #include <thirdparty/protobuf/compiler/code_generator.h> #include <thirdparty/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_repeated_message_field.h b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_repeated_message_field.h index 2dee22b7..844fa0dc 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_repeated_message_field.h +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_repeated_message_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__ -#include <string> - #include <thirdparty/protobuf/compiler/code_generator.h> #include <thirdparty/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_repeated_primitive_field.h b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_repeated_primitive_field.h index 2ac4afca..fcc4ed56 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_repeated_primitive_field.h +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_repeated_primitive_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__ -#include <string> - #include <thirdparty/protobuf/compiler/code_generator.h> #include <thirdparty/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_wrapper_field.cc b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_wrapper_field.cc index 477eaa8b..210e34a8 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_wrapper_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_wrapper_field.cc @@ -233,7 +233,7 @@ void WrapperOneofFieldGenerator::GenerateMembers(io::Printer* printer) { " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : ($type_name$) null; }\n" " set {\n" " $oneof_name$_ = value;\n" - " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n" + " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$oneof_case_name$;\n" " }\n" "}\n"); if (SupportsPresenceApi(descriptor_)) { @@ -244,7 +244,7 @@ void WrapperOneofFieldGenerator::GenerateMembers(io::Printer* printer) { printer->Print( variables_, "$access_level$ bool Has$property_name$ {\n" - " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$property_name$; }\n" + " get { return $oneof_name$Case_ == $oneof_property_name$OneofCase.$oneof_case_name$; }\n" "}\n"); printer->Print( variables_, diff --git a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_wrapper_field.h b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_wrapper_field.h index 47e9c63c..0dbe84c9 100644 --- a/r5dev/thirdparty/protobuf/compiler/csharp/csharp_wrapper_field.h +++ b/r5dev/thirdparty/protobuf/compiler/csharp/csharp_wrapper_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_WRAPPER_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_WRAPPER_FIELD_H__ -#include <string> - #include <thirdparty/protobuf/compiler/code_generator.h> #include <thirdparty/protobuf/compiler/csharp/csharp_field_base.h> diff --git a/r5dev/thirdparty/protobuf/compiler/importer.cc b/r5dev/thirdparty/protobuf/compiler/importer.cc index 18cf5fe1..098829da 100644 --- a/r5dev/thirdparty/protobuf/compiler/importer.cc +++ b/r5dev/thirdparty/protobuf/compiler/importer.cc @@ -93,13 +93,13 @@ class SourceTreeDescriptorDatabase::SingleFileErrorCollector : filename_(filename), multi_file_error_collector_(multi_file_error_collector), had_errors_(false) {} - ~SingleFileErrorCollector() {} + ~SingleFileErrorCollector() override {} bool had_errors() { return had_errors_; } // implements ErrorCollector --------------------------------------- void AddError(int line, int column, const std::string& message) override { - if (multi_file_error_collector_ != NULL) { + if (multi_file_error_collector_ != nullptr) { multi_file_error_collector_->AddError(filename_, line, column, message); } had_errors_ = true; @@ -134,12 +134,12 @@ SourceTreeDescriptorDatabase::~SourceTreeDescriptorDatabase() {} bool SourceTreeDescriptorDatabase::FindFileByName(const std::string& filename, FileDescriptorProto* output) { std::unique_ptr<io::ZeroCopyInputStream> input(source_tree_->Open(filename)); - if (input == NULL) { + if (input == nullptr) { if (fallback_database_ != nullptr && fallback_database_->FindFileByName(filename, output)) { return true; } - if (error_collector_ != NULL) { + if (error_collector_ != nullptr) { error_collector_->AddError(filename, -1, 0, source_tree_->GetLastErrorMessage()); } @@ -151,7 +151,7 @@ bool SourceTreeDescriptorDatabase::FindFileByName(const std::string& filename, io::Tokenizer tokenizer(input.get(), &file_error_collector); Parser parser; - if (error_collector_ != NULL) { + if (error_collector_ != nullptr) { parser.RecordErrorsTo(&file_error_collector); } if (using_validation_error_collector_) { @@ -187,7 +187,7 @@ void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddError( const std::string& filename, const std::string& element_name, const Message* descriptor, ErrorLocation location, const std::string& message) { - if (owner_->error_collector_ == NULL) return; + if (owner_->error_collector_ == nullptr) return; int line, column; if (location == DescriptorPool::ErrorCollector::IMPORT) { @@ -203,7 +203,7 @@ void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddWarning( const std::string& filename, const std::string& element_name, const Message* descriptor, ErrorLocation location, const std::string& message) { - if (owner_->error_collector_ == NULL) return; + if (owner_->error_collector_ == nullptr) return; int line, column; if (location == DescriptorPool::ErrorCollector::IMPORT) { @@ -429,7 +429,7 @@ DiskSourceTree::DiskFileToVirtualFile(const std::string& disk_file, // of verifying that we are not canonicalizing away any non-existent // directories. std::unique_ptr<io::ZeroCopyInputStream> stream(OpenDiskFile(disk_file)); - if (stream == NULL) { + if (stream == nullptr) { return CANNOT_OPEN; } @@ -440,11 +440,11 @@ bool DiskSourceTree::VirtualFileToDiskFile(const std::string& virtual_file, std::string* disk_file) { std::unique_ptr<io::ZeroCopyInputStream> stream( OpenVirtualFile(virtual_file, disk_file)); - return stream != NULL; + return stream != nullptr; } io::ZeroCopyInputStream* DiskSourceTree::Open(const std::string& filename) { - return OpenVirtualFile(filename, NULL); + return OpenVirtualFile(filename, nullptr); } std::string DiskSourceTree::GetLastErrorMessage() { @@ -461,7 +461,7 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile( last_error_message_ = "Backslashes, consecutive slashes, \".\", or \"..\" " "are not allowed in the virtual path"; - return NULL; + return nullptr; } for (const auto& mapping : mappings_) { @@ -469,8 +469,8 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile( if (ApplyMapping(virtual_file, mapping.virtual_path, mapping.disk_path, &temp_disk_file)) { io::ZeroCopyInputStream* stream = OpenDiskFile(temp_disk_file); - if (stream != NULL) { - if (disk_file != NULL) { + if (stream != nullptr) { + if (disk_file != nullptr) { *disk_file = temp_disk_file; } return stream; @@ -480,12 +480,12 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile( // The file exists but is not readable. last_error_message_ = "Read access is denied for file: " + temp_disk_file; - return NULL; + return nullptr; } } } last_error_message_ = "File not found."; - return NULL; + return nullptr; } io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile( @@ -498,12 +498,12 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile( #if defined(_WIN32) if (ret == 0 && sb.st_mode & S_IFDIR) { last_error_message_ = "Input file is a directory."; - return NULL; + return nullptr; } #else if (ret == 0 && S_ISDIR(sb.st_mode)) { last_error_message_ = "Input file is a directory."; - return NULL; + return nullptr; } #endif int file_descriptor; @@ -515,7 +515,7 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile( result->SetCloseOnDelete(true); return result; } else { - return NULL; + return nullptr; } } diff --git a/r5dev/thirdparty/protobuf/compiler/importer.h b/r5dev/thirdparty/protobuf/compiler/importer.h index df46cbf1..d5ad15bf 100644 --- a/r5dev/thirdparty/protobuf/compiler/importer.h +++ b/r5dev/thirdparty/protobuf/compiler/importer.h @@ -41,10 +41,12 @@ #include <string> #include <utility> #include <vector> + #include <thirdparty/protobuf/compiler/parser.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/descriptor_database.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -85,7 +87,7 @@ class PROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabase { // the specified source_tree. SourceTreeDescriptorDatabase(SourceTree* source_tree, DescriptorDatabase* fallback_database); - ~SourceTreeDescriptorDatabase(); + ~SourceTreeDescriptorDatabase() override; // Instructs the SourceTreeDescriptorDatabase to report any parse errors // to the given MultiFileErrorCollector. This should be called before @@ -124,7 +126,7 @@ class PROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabase { : public DescriptorPool::ErrorCollector { public: ValidationErrorCollector(SourceTreeDescriptorDatabase* owner); - ~ValidationErrorCollector(); + ~ValidationErrorCollector() override; // implements ErrorCollector --------------------------------------- void AddError(const std::string& filename, const std::string& element_name, @@ -241,7 +243,7 @@ class PROTOBUF_EXPORT SourceTree { class PROTOBUF_EXPORT DiskSourceTree : public SourceTree { public: DiskSourceTree(); - ~DiskSourceTree(); + ~DiskSourceTree() override; // Map a path on disk to a location in the SourceTree. The path may be // either a file or a directory. If it is a directory, the entire tree diff --git a/r5dev/thirdparty/protobuf/compiler/importer_unittest.cc b/r5dev/thirdparty/protobuf/compiler/importer_unittest.cc index e9d6ac66..109dee65 100644 --- a/r5dev/thirdparty/protobuf/compiler/importer_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/importer_unittest.cc @@ -66,20 +66,20 @@ bool FileExists(const std::string& path) { class MockErrorCollector : public MultiFileErrorCollector { public: MockErrorCollector() {} - ~MockErrorCollector() {} + ~MockErrorCollector() override {} std::string text_; std::string warning_text_; // implements ErrorCollector --------------------------------------- void AddError(const std::string& filename, int line, int column, - const std::string& message) { + const std::string& message) override { strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n", filename, line, column, message); } void AddWarning(const std::string& filename, int line, int column, - const std::string& message) { + const std::string& message) override { strings::SubstituteAndAppend(&warning_text_, "$0:$1:$2: $3\n", filename, line, column, message); } @@ -91,23 +91,23 @@ class MockErrorCollector : public MultiFileErrorCollector { class MockSourceTree : public SourceTree { public: MockSourceTree() {} - ~MockSourceTree() {} + ~MockSourceTree() override {} void AddFile(const std::string& name, const char* contents) { files_[name] = contents; } // implements SourceTree ------------------------------------------- - io::ZeroCopyInputStream* Open(const std::string& filename) { + io::ZeroCopyInputStream* Open(const std::string& filename) override { const char* contents = FindPtrOrNull(files_, filename); - if (contents == NULL) { - return NULL; + if (contents == nullptr) { + return nullptr; } else { return new io::ArrayInputStream(contents, strlen(contents)); } } - std::string GetLastErrorMessage() { return "File not found."; } + std::string GetLastErrorMessage() override { return "File not found."; } private: std::unordered_map<std::string, const char*> files_; @@ -139,7 +139,7 @@ TEST_F(ImporterTest, Import) { const FileDescriptor* file = importer_.Import("foo.proto"); EXPECT_EQ("", error_collector_.text_); - ASSERT_TRUE(file != NULL); + ASSERT_TRUE(file != nullptr); ASSERT_EQ(1, file->message_type_count()); EXPECT_EQ("Foo", file->message_type(0)->name()); @@ -168,8 +168,8 @@ TEST_F(ImporterTest, ImportNested) { const FileDescriptor* foo = importer_.Import("foo.proto"); const FileDescriptor* bar = importer_.Import("bar.proto"); EXPECT_EQ("", error_collector_.text_); - ASSERT_TRUE(foo != NULL); - ASSERT_TRUE(bar != NULL); + ASSERT_TRUE(foo != nullptr); + ASSERT_TRUE(bar != nullptr); // Check that foo's dependency is the same object as bar. ASSERT_EQ(1, foo->dependency_count()); @@ -187,7 +187,7 @@ TEST_F(ImporterTest, ImportNested) { TEST_F(ImporterTest, FileNotFound) { // Error: Parsing a file that doesn't exist. - EXPECT_TRUE(importer_.Import("foo.proto") == NULL); + EXPECT_TRUE(importer_.Import("foo.proto") == nullptr); EXPECT_EQ("foo.proto:-1:0: File not found.\n", error_collector_.text_); } @@ -197,7 +197,7 @@ TEST_F(ImporterTest, ImportNotFound) { "syntax = \"proto2\";\n" "import \"bar.proto\";\n"); - EXPECT_TRUE(importer_.Import("foo.proto") == NULL); + EXPECT_TRUE(importer_.Import("foo.proto") == nullptr); EXPECT_EQ( "bar.proto:-1:0: File not found.\n" "foo.proto:1:0: Import \"bar.proto\" was not found or had errors.\n", @@ -214,7 +214,7 @@ TEST_F(ImporterTest, RecursiveImport) { "syntax = \"proto2\";\n" "import \"recursive1.proto\";\n"); - EXPECT_TRUE(importer_.Import("recursive1.proto") == NULL); + EXPECT_TRUE(importer_.Import("recursive1.proto") == nullptr); EXPECT_EQ( "recursive1.proto:2:0: File recursively imports itself: " "recursive1.proto " @@ -262,7 +262,7 @@ TEST_F(ImporterTest, LiteRuntimeImport) { class DiskSourceTreeTest : public testing::Test { protected: - virtual void SetUp() { + void SetUp() override { dirnames_.push_back(TestTempDir() + "/test_proto2_import_path_1"); dirnames_.push_back(TestTempDir() + "/test_proto2_import_path_2"); @@ -274,7 +274,7 @@ class DiskSourceTreeTest : public testing::Test { } } - virtual void TearDown() { + void TearDown() override { for (int i = 0; i < dirnames_.size(); i++) { if (FileExists(dirnames_[i])) { File::DeleteRecursively(dirnames_[i], NULL, NULL); @@ -294,7 +294,7 @@ class DiskSourceTreeTest : public testing::Test { const char* expected_contents) { std::unique_ptr<io::ZeroCopyInputStream> input(source_tree_.Open(filename)); - ASSERT_FALSE(input == NULL); + ASSERT_FALSE(input == nullptr); // Read all the data from the file. std::string file_contents; @@ -310,7 +310,7 @@ class DiskSourceTreeTest : public testing::Test { void ExpectCannotOpenFile(const std::string& filename, const std::string& error_message) { std::unique_ptr<io::ZeroCopyInputStream> input(source_tree_.Open(filename)); - EXPECT_TRUE(input == NULL); + EXPECT_TRUE(input == nullptr); EXPECT_EQ(error_message, source_tree_.GetLastErrorMessage()); } @@ -537,8 +537,8 @@ TEST_F(DiskSourceTreeTest, VirtualFileToDiskFile) { EXPECT_EQ("not touched", not_touched); // Accept NULL as output parameter. - EXPECT_TRUE(source_tree_.VirtualFileToDiskFile("bar/foo", NULL)); - EXPECT_FALSE(source_tree_.VirtualFileToDiskFile("baz/foo", NULL)); + EXPECT_TRUE(source_tree_.VirtualFileToDiskFile("bar/foo", nullptr)); + EXPECT_FALSE(source_tree_.VirtualFileToDiskFile("baz/foo", nullptr)); } } // namespace diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_context.cc b/r5dev/thirdparty/protobuf/compiler/java/context.cc similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/java/java_context.cc rename to r5dev/thirdparty/protobuf/compiler/java/context.cc index e42cedaa..6bebe835 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_context.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/context.cc @@ -28,13 +28,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <thirdparty/protobuf/compiler/java/java_context.h> +#include <thirdparty/protobuf/compiler/java/context.h> -#include <thirdparty/protobuf/compiler/java/java_field.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/java/field.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> #include <thirdparty/protobuf/stubs/map_util.h> namespace google { diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_context.h b/r5dev/thirdparty/protobuf/compiler/java/context.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_context.h rename to r5dev/thirdparty/protobuf/compiler/java/context.h index 568fb37a..40a368f6 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_context.h +++ b/r5dev/thirdparty/protobuf/compiler/java/context.h @@ -36,7 +36,7 @@ #include <vector> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/java/java_options.h> +#include <thirdparty/protobuf/compiler/java/options.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_doc_comment.cc b/r5dev/thirdparty/protobuf/compiler/java/doc_comment.cc similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/java/java_doc_comment.cc rename to r5dev/thirdparty/protobuf/compiler/java/doc_comment.cc index 37fca66f..14a766e0 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_doc_comment.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/doc_comment.cc @@ -32,13 +32,13 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> #include <vector> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/descriptor.pb.h> namespace google { namespace protobuf { @@ -199,7 +199,16 @@ void WriteDeprecatedJavadoc(io::Printer* printer, const FieldDescriptor* field, return; } - printer->Print(" * @deprecated\n"); + std::string startLine = "0"; + SourceLocation location; + if (field->GetSourceLocation(&location)) { + startLine = std::to_string(location.start_line); + } + + printer->Print(" * @deprecated $name$ is deprecated.\n", "name", + field->full_name()); + printer->Print(" * See $file$;l=$line$\n", "file", field->file()->name(), + "line", startLine); } void WriteFieldAccessorDocComment(io::Printer* printer, diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_doc_comment.h b/r5dev/thirdparty/protobuf/compiler/java/doc_comment.h similarity index 99% rename from r5dev/thirdparty/protobuf/compiler/java/java_doc_comment.h rename to r5dev/thirdparty/protobuf/compiler/java/doc_comment.h index eba65f9e..0e412ff9 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_doc_comment.h +++ b/r5dev/thirdparty/protobuf/compiler/java/doc_comment.h @@ -37,6 +37,7 @@ #include <thirdparty/protobuf/descriptor.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_doc_comment_unittest.cc b/r5dev/thirdparty/protobuf/compiler/java/doc_comment_unittest.cc similarity index 75% rename from r5dev/thirdparty/protobuf/compiler/java/java_doc_comment_unittest.cc rename to r5dev/thirdparty/protobuf/compiler/java/doc_comment_unittest.cc index 45240a4e..e85b3ac0 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_doc_comment_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/doc_comment_unittest.cc @@ -30,7 +30,7 @@ // Author: kenton@google.com (Kenton Varda) -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> #include <gtest/gtest.h> @@ -49,17 +49,6 @@ TEST(JavaDocCommentTest, Escaping) { EXPECT_EQ("@deprecated", EscapeJavadoc("@deprecated")); } -// TODO(kenton): It's hard to write a robust test of the doc comments -- we -// can only really compare the output against a golden value, which is a -// fairly tedious and fragile testing strategy. If we want to go that route, -// it probably makes sense to bite the bullet and write a test that compares -// the whole generated output for unittest.proto against a golden value, with -// a very simple script that can be run to regenerate it with the latest code. -// This would mean that updates to the golden file would have to be included -// in any change to the code generator, which would actually be fairly useful -// as it allows the reviewer to see clearly how the generated code is -// changing. - } // namespace } // namespace java } // namespace compiler diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_enum.cc b/r5dev/thirdparty/protobuf/compiler/java/enum.cc similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/java/java_enum.cc rename to r5dev/thirdparty/protobuf/compiler/java/enum.cc index 41c07eb5..c71576e0 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_enum.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/enum.cc @@ -32,17 +32,21 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include <thirdparty/protobuf/compiler/java/enum.h> + #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_enum.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> +#include <thirdparty/protobuf/descriptor.pb.h> + +// Must be last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -389,3 +393,5 @@ bool EnumGenerator::CanUseEnumValues() { } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_enum.h b/r5dev/thirdparty/protobuf/compiler/java/enum.h similarity index 100% rename from r5dev/thirdparty/protobuf/compiler/java/java_enum.h rename to r5dev/thirdparty/protobuf/compiler/java/enum.h diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_enum_field.cc b/r5dev/thirdparty/protobuf/compiler/java/enum_field.cc similarity index 85% rename from r5dev/thirdparty/protobuf/compiler/java/java_enum_field.cc rename to r5dev/thirdparty/protobuf/compiler/java/enum_field.cc index b9f6e119..e64ee5bc 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_enum_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/enum_field.cc @@ -32,21 +32,24 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_enum_field.h> +#include "google/protobuf/compiler/java/enum_field.h" #include <cstdint> #include <map> #include <string> -#include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/stubs/strutil.h> +#include "google/protobuf/stubs/logging.h" +#include "google/protobuf/stubs/common.h" +#include "google/protobuf/io/printer.h" +#include "google/protobuf/wire_format.h" +#include "google/protobuf/stubs/strutil.h" +#include "google/protobuf/compiler/java/context.h" +#include "google/protobuf/compiler/java/doc_comment.h" +#include "google/protobuf/compiler/java/helpers.h" +#include "google/protobuf/compiler/java/name_resolver.h" + +// Must be last. +#include "google/protobuf/port_def.inc" namespace google { namespace protobuf { @@ -55,10 +58,11 @@ namespace java { namespace { -void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex, - int builderBitIndex, const FieldGeneratorInfo* info, - ClassNameResolver* name_resolver, - std::map<std::string, std::string>* variables) { +void SetEnumVariables( + const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, + const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, + std::map<std::string, std::string>* variables, + Context* context) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["type"] = @@ -77,40 +81,27 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex, // by the proto compiler (*variables)["deprecation"] = descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; - (*variables)["kt_deprecation"] = - descriptor->options().deprecated() - ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] + - " is deprecated\") " - : ""; - (*variables)["on_changed"] = "onChanged();"; - // Use deprecated valueOf() method to be compatible with old generated code - // for v2.5.0/v2.6.1. - // TODO(xiaofeng): Use "forNumber" when we no longer support compatibility - // with v2.5.0/v2.6.1, and remove the @SuppressWarnings annotations. - (*variables)["for_number"] = "valueOf"; - + variables->insert( + {"kt_deprecation", + descriptor->options().deprecated() + ? StrCat("@kotlin.Deprecated(message = \"Field ", + (*variables)["name"], " is deprecated\") ") + : ""}); if (HasHasbit(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); - (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); - // Note that these have a trailing ";". (*variables)["set_has_field_bit_message"] = GenerateSetBit(messageBitIndex) + ";"; - (*variables)["set_has_field_bit_builder"] = - GenerateSetBit(builderBitIndex) + ";"; - (*variables)["clear_has_field_bit_builder"] = - GenerateClearBit(builderBitIndex) + ";"; - + (*variables)["set_has_field_bit_to_local"] = + GenerateSetBitToLocal(messageBitIndex); (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex); } else { (*variables)["set_has_field_bit_message"] = ""; - (*variables)["set_has_field_bit_builder"] = ""; - (*variables)["clear_has_field_bit_builder"] = ""; - - (*variables)["is_field_present_message"] = - (*variables)["name"] + "_ != " + (*variables)["default"] + - ".getNumber()"; + (*variables)["set_has_field_bit_to_local"] = ""; + variables->insert({"is_field_present_message", + StrCat((*variables)["name"], "_ != ", + (*variables)["default"], ".getNumber()")}); } // For repeated builders, one bit is used for whether the array is immutable. @@ -118,22 +109,21 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex, (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex); (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex); - // For repeated fields, one bit is used for whether the array is immutable - // in the parsing constructor. - (*variables)["get_mutable_bit_parser"] = - GenerateGetBitMutableLocal(builderBitIndex); - (*variables)["set_mutable_bit_parser"] = - GenerateSetBitMutableLocal(builderBitIndex); + (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); + // Note that these have a trailing ";". + (*variables)["set_has_field_bit_builder"] = + GenerateSetBit(builderBitIndex) + ";"; + (*variables)["clear_has_field_bit_builder"] = + GenerateClearBit(builderBitIndex) + ";"; (*variables)["get_has_field_bit_from_local"] = GenerateGetBitFromLocal(builderBitIndex); - (*variables)["set_has_field_bit_to_local"] = - GenerateSetBitToLocal(messageBitIndex); if (SupportUnknownEnumValue(descriptor->file())) { - (*variables)["unknown"] = (*variables)["type"] + ".UNRECOGNIZED"; + variables->insert( + {"unknown", StrCat((*variables)["type"], ".UNRECOGNIZED")}); } else { - (*variables)["unknown"] = (*variables)["default"]; + variables->insert({"unknown", (*variables)["default"]}); } } @@ -144,21 +134,30 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex, ImmutableEnumFieldGenerator::ImmutableEnumFieldGenerator( const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context) - : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) { + : descriptor_(descriptor), + message_bit_index_(messageBitIndex), + builder_bit_index_(builderBitIndex), + name_resolver_(context->GetNameResolver()) { SetEnumVariables(descriptor, messageBitIndex, builderBitIndex, context->GetFieldGeneratorInfo(descriptor), name_resolver_, - &variables_); + &variables_, context); } ImmutableEnumFieldGenerator::~ImmutableEnumFieldGenerator() {} +int ImmutableEnumFieldGenerator::GetMessageBitIndex() const { + return message_bit_index_; +} + +int ImmutableEnumFieldGenerator::GetBuilderBitIndex() const { + return builder_bit_index_; +} + int ImmutableEnumFieldGenerator::GetNumBitsForMessage() const { return HasHasbit(descriptor_) ? 1 : 0; } -int ImmutableEnumFieldGenerator::GetNumBitsForBuilder() const { - return GetNumBitsForMessage(); -} +int ImmutableEnumFieldGenerator::GetNumBitsForBuilder() const { return 1; } void ImmutableEnumFieldGenerator::GenerateInterfaceMembers( io::Printer* printer) const { @@ -177,7 +176,7 @@ void ImmutableEnumFieldGenerator::GenerateInterfaceMembers( } void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const { - printer->Print(variables_, "private int $name$_;\n"); + printer->Print(variables_, "private int $name$_ = $default_number$;\n"); PrintExtraFieldInfo(variables_, printer); if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); @@ -201,8 +200,7 @@ void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const { printer->Print(variables_, "@java.lang.Override $deprecation$public $type$ " "${$get$capitalized_name$$}$() {\n" - " @SuppressWarnings(\"deprecation\")\n" - " $type$ result = $type$.$for_number$($name$_);\n" + " $type$ result = $type$.forNumber($name$_);\n" " return result == null ? $unknown$ : result;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -233,9 +231,9 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers( printer->Print(variables_, "$deprecation$public Builder " "${$set$capitalized_name$Value$}$(int value) {\n" - " $set_has_field_bit_builder$\n" " $name$_ = value;\n" - " $on_changed$\n" + " $set_has_field_bit_builder$\n" + " onChanged();\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -244,8 +242,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers( printer->Print(variables_, "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" - " @SuppressWarnings(\"deprecation\")\n" - " $type$ result = $type$.$for_number$($name$_);\n" + " $type$ result = $type$.forNumber($name$_);\n" " return result == null ? $unknown$ : result;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -259,7 +256,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers( " }\n" " $set_has_field_bit_builder$\n" " $name$_ = value.getNumber();\n" - " $on_changed$\n" + " onChanged();\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -270,7 +267,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers( "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " $clear_has_field_bit_builder$\n" " $name$_ = $default_number$;\n" - " $on_changed$\n" + " onChanged();\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -317,9 +314,7 @@ void ImmutableEnumFieldGenerator::GenerateInitializationCode( void ImmutableEnumFieldGenerator::GenerateBuilderClearCode( io::Printer* printer) const { - printer->Print(variables_, - "$name$_ = $default_number$;\n" - "$clear_has_field_bit_builder$\n"); + printer->Print(variables_, "$name$_ = $default_number$;\n"); } void ImmutableEnumFieldGenerator::GenerateMergingCode( @@ -342,41 +337,35 @@ void ImmutableEnumFieldGenerator::GenerateMergingCode( void ImmutableEnumFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - if (HasHazzer(descriptor_)) { - printer->Print(variables_, - "if ($get_has_field_bit_from_local$) {\n" - " $set_has_field_bit_to_local$;\n" - "}\n"); + printer->Print(variables_, + "if ($get_has_field_bit_from_local$) {\n" + " result.$name$_ = $name$_;\n"); + if (GetNumBitsForMessage() > 0) { + printer->Print(variables_, " $set_has_field_bit_to_local$;\n"); } - printer->Print(variables_, "result.$name$_ = $name$_;\n"); + printer->Print("}\n"); } -void ImmutableEnumFieldGenerator::GenerateParsingCode( +void ImmutableEnumFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print(variables_, - "int rawValue = input.readEnum();\n" - "$set_has_field_bit_message$\n" - "$name$_ = rawValue;\n"); + "$name$_ = input.readEnum();\n" + "$set_has_field_bit_builder$\n"); } else { printer->Print(variables_, - "int rawValue = input.readEnum();\n" - " @SuppressWarnings(\"deprecation\")\n" - "$type$ value = $type$.$for_number$(rawValue);\n" - "if (value == null) {\n" - " unknownFields.mergeVarintField($number$, rawValue);\n" + "int tmpRaw = input.readEnum();\n" + "$type$ tmpValue =\n" + " $type$.forNumber(tmpRaw);\n" + "if (tmpValue == null) {\n" + " mergeUnknownVarintField($number$, tmpRaw);\n" "} else {\n" - " $set_has_field_bit_message$\n" - " $name$_ = rawValue;\n" + " $name$_ = tmpRaw;\n" + " $set_has_field_bit_builder$\n" "}\n"); } } -void ImmutableEnumFieldGenerator::GenerateParsingDoneCode( - io::Printer* printer) const { - // noop for enums -} - void ImmutableEnumFieldGenerator::GenerateSerializationCode( io::Printer* printer) const { printer->Print(variables_, @@ -450,8 +439,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateMembers( printer->Print(variables_, "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" - " @SuppressWarnings(\"deprecation\")\n" - " $type$ result = $type$.$for_number$(\n" + " $type$ result = $type$.forNumber(\n" " (java.lang.Integer) $oneof_name$_);\n" " return result == null ? $unknown$ : result;\n" " }\n" @@ -490,7 +478,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( "${$set$capitalized_name$Value$}$(int value) {\n" " $set_oneof_case_message$;\n" " $oneof_name$_ = value;\n" - " $on_changed$\n" + " onChanged();\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -500,14 +488,14 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" - " @SuppressWarnings(\"deprecation\")\n" - " $type$ result = $type$.$for_number$(\n" + " $type$ result = $type$.forNumber(\n" " (java.lang.Integer) $oneof_name$_);\n" " return result == null ? $unknown$ : result;\n" " }\n" " return $default$;\n" "}\n"); printer->Annotate("{", "}", descriptor_); + WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); printer->Print(variables_, @@ -518,10 +506,11 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( " }\n" " $set_oneof_case_message$;\n" " $oneof_name$_ = value.getNumber();\n" - " $on_changed$\n" + " onChanged();\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); + WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -530,19 +519,21 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( " if ($has_oneof_case_message$) {\n" " $clear_oneof_case_message$;\n" " $oneof_name$_ = null;\n" - " $on_changed$\n" + " onChanged();\n" " }\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); } +void ImmutableEnumOneofFieldGenerator::GenerateBuilderClearCode( + io::Printer* printer) const { + // No-op: Enum fields in oneofs are correctly cleared by clearing the oneof +} + void ImmutableEnumOneofFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - printer->Print(variables_, - "if ($has_oneof_case_message$) {\n" - " result.$oneof_name$_ = $oneof_name$_;\n" - "}\n"); + // No-Op: Handled by single statement for the oneof } void ImmutableEnumOneofFieldGenerator::GenerateMergingCode( @@ -557,7 +548,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateMergingCode( } } -void ImmutableEnumOneofFieldGenerator::GenerateParsingCode( +void ImmutableEnumOneofFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print(variables_, @@ -567,10 +558,10 @@ void ImmutableEnumOneofFieldGenerator::GenerateParsingCode( } else { printer->Print(variables_, "int rawValue = input.readEnum();\n" - "@SuppressWarnings(\"deprecation\")\n" - "$type$ value = $type$.$for_number$(rawValue);\n" + "$type$ value =\n" + " $type$.forNumber(rawValue);\n" "if (value == null) {\n" - " unknownFields.mergeVarintField($number$, rawValue);\n" + " mergeUnknownVarintField($number$, rawValue);\n" "} else {\n" " $set_oneof_case_message$;\n" " $oneof_name$_ = rawValue;\n" @@ -631,11 +622,8 @@ void ImmutableEnumOneofFieldGenerator::GenerateHashCode( RepeatedImmutableEnumFieldGenerator::RepeatedImmutableEnumFieldGenerator( const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context) - : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) { - SetEnumVariables(descriptor, messageBitIndex, builderBitIndex, - context->GetFieldGeneratorInfo(descriptor), name_resolver_, - &variables_); -} + : ImmutableEnumFieldGenerator(descriptor, messageBitIndex, builderBitIndex, + context) {} RepeatedImmutableEnumFieldGenerator::~RepeatedImmutableEnumFieldGenerator() {} @@ -675,6 +663,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers( io::Printer* printer) const { printer->Print( variables_, + "@SuppressWarnings(\"serial\")\n" "private java.util.List<java.lang.Integer> $name$_;\n" "private static final " "com.google.protobuf.Internal.ListAdapter.Converter<\n" @@ -682,8 +671,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers( " new com.google.protobuf.Internal.ListAdapter.Converter<\n" " java.lang.Integer, $type$>() {\n" " public $type$ convert(java.lang.Integer from) {\n" - " @SuppressWarnings(\"deprecation\")\n" - " $type$ result = $type$.$for_number$(from);\n" + " $type$ result = $type$.forNumber(from);\n" " return result == null ? $unknown$ : result;\n" " }\n" " };\n"); @@ -799,7 +787,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " }\n" " ensure$capitalized_name$IsMutable();\n" " $name$_.set(index, value.getNumber());\n" - " $on_changed$\n" + " onChanged();\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -813,7 +801,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " }\n" " ensure$capitalized_name$IsMutable();\n" " $name$_.add(value.getNumber());\n" - " $on_changed$\n" + " onChanged();\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -826,7 +814,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " for ($type$ value : values) {\n" " $name$_.add(value.getNumber());\n" " }\n" - " $on_changed$\n" + " onChanged();\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -837,7 +825,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " $name$_ = java.util.Collections.emptyList();\n" " $clear_mutable_bit_builder$;\n" - " $on_changed$\n" + " onChanged();\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -859,7 +847,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( "}\n"); printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, - LIST_INDEXED_GETTER, + LIST_INDEXED_SETTER, /* builder */ true); printer->Print( variables_, @@ -867,7 +855,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " int index, int value) {\n" " ensure$capitalized_name$IsMutable();\n" " $name$_.set(index, value);\n" - " $on_changed$\n" + " onChanged();\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -878,7 +866,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( "${$add$capitalized_name$Value$}$(int value) {\n" " ensure$capitalized_name$IsMutable();\n" " $name$_.add(value);\n" - " $on_changed$\n" + " onChanged();\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -892,7 +880,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " for (int value : values) {\n" " $name$_.add(value);\n" " }\n" - " $on_changed$\n" + " onChanged();\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -932,7 +920,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMergingCode( " ensure$capitalized_name$IsMutable();\n" " $name$_.addAll(other.$name$_);\n" " }\n" - " $on_changed$\n" + " onChanged();\n" "}\n"); } @@ -949,36 +937,29 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuildingCode( "result.$name$_ = $name$_;\n"); } -void RepeatedImmutableEnumFieldGenerator::GenerateParsingCode( +void RepeatedImmutableEnumFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { // Read and store the enum if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print(variables_, - "int rawValue = input.readEnum();\n" - "if (!$get_mutable_bit_parser$) {\n" - " $name$_ = new java.util.ArrayList<java.lang.Integer>();\n" - " $set_mutable_bit_parser$;\n" - "}\n" - "$name$_.add(rawValue);\n"); + "int tmpRaw = input.readEnum();\n" + "ensure$capitalized_name$IsMutable();\n" + "$name$_.add(tmpRaw);\n"); } else { - printer->Print( - variables_, - "int rawValue = input.readEnum();\n" - "@SuppressWarnings(\"deprecation\")\n" - "$type$ value = $type$.$for_number$(rawValue);\n" - "if (value == null) {\n" - " unknownFields.mergeVarintField($number$, rawValue);\n" - "} else {\n" - " if (!$get_mutable_bit_parser$) {\n" - " $name$_ = new java.util.ArrayList<java.lang.Integer>();\n" - " $set_mutable_bit_parser$;\n" - " }\n" - " $name$_.add(rawValue);\n" - "}\n"); + printer->Print(variables_, + "int tmpRaw = input.readEnum();\n" + "$type$ tmpValue =\n" + " $type$.forNumber(tmpRaw);\n" + "if (tmpValue == null) {\n" + " mergeUnknownVarintField($number$, tmpRaw);\n" + "} else {\n" + " ensure$capitalized_name$IsMutable();\n" + " $name$_.add(tmpRaw);\n" + "}\n"); } } -void RepeatedImmutableEnumFieldGenerator::GenerateParsingCodeFromPacked( +void RepeatedImmutableEnumFieldGenerator::GenerateBuilderParsingCodeFromPacked( io::Printer* printer) const { // Wrap GenerateParsingCode's contents with a while loop. @@ -988,7 +969,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateParsingCodeFromPacked( "while(input.getBytesUntilLimit() > 0) {\n"); printer->Indent(); - GenerateParsingCode(printer); + GenerateBuilderParsingCode(printer); printer->Outdent(); printer->Print(variables_, @@ -996,15 +977,6 @@ void RepeatedImmutableEnumFieldGenerator::GenerateParsingCodeFromPacked( "input.popLimit(oldLimit);\n"); } -void RepeatedImmutableEnumFieldGenerator::GenerateParsingDoneCode( - io::Printer* printer) const { - printer->Print( - variables_, - "if ($get_mutable_bit_parser$) {\n" - " $name$_ = java.util.Collections.unmodifiableList($name$_);\n" - "}\n"); -} - void RepeatedImmutableEnumFieldGenerator::GenerateSerializationCode( io::Printer* printer) const { if (descriptor_->is_packed()) { @@ -1087,7 +1059,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers( WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$kt_deprecation$ public val $kt_name$: " + "$kt_deprecation$public val $kt_name$: " "com.google.protobuf.kotlin.DslList" "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" @@ -1174,3 +1146,5 @@ std::string RepeatedImmutableEnumFieldGenerator::GetBoxedType() const { } // namespace compiler } // namespace protobuf } // namespace google + +#include "google/protobuf/port_undef.inc" diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_enum_field.h b/r5dev/thirdparty/protobuf/compiler/java/enum_field.h similarity index 83% rename from r5dev/thirdparty/protobuf/compiler/java/java_enum_field.h rename to r5dev/thirdparty/protobuf/compiler/java/enum_field.h index 62259c72..8f0a5c3e 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_enum_field.h +++ b/r5dev/thirdparty/protobuf/compiler/java/enum_field.h @@ -37,7 +37,8 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_field.h> + +#include "google/protobuf/compiler/java/field.h" namespace google { namespace protobuf { @@ -60,10 +61,15 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator { explicit ImmutableEnumFieldGenerator(const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context); + ImmutableEnumFieldGenerator(const ImmutableEnumFieldGenerator&) = delete; + ImmutableEnumFieldGenerator& operator=(const ImmutableEnumFieldGenerator&) = + delete; ~ImmutableEnumFieldGenerator() override; // implements ImmutableFieldGenerator // --------------------------------------- + int GetMessageBitIndex() const override; + int GetBuilderBitIndex() const override; int GetNumBitsForMessage() const override; int GetNumBitsForBuilder() const override; void GenerateInterfaceMembers(io::Printer* printer) const override; @@ -71,10 +77,9 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator { void GenerateBuilderMembers(io::Printer* printer) const override; void GenerateInitializationCode(io::Printer* printer) const override; void GenerateBuilderClearCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; - void GenerateParsingDoneCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; void GenerateFieldBuilderInitializationCode( @@ -87,11 +92,10 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; + int message_bit_index_; + int builder_bit_index_; std::map<std::string, std::string> variables_; ClassNameResolver* name_resolver_; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumFieldGenerator); }; class ImmutableEnumOneofFieldGenerator : public ImmutableEnumFieldGenerator { @@ -99,27 +103,33 @@ class ImmutableEnumOneofFieldGenerator : public ImmutableEnumFieldGenerator { ImmutableEnumOneofFieldGenerator(const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context); - ~ImmutableEnumOneofFieldGenerator(); + ImmutableEnumOneofFieldGenerator(const ImmutableEnumOneofFieldGenerator&) = + delete; + ImmutableEnumOneofFieldGenerator& operator=( + const ImmutableEnumOneofFieldGenerator&) = delete; + ~ImmutableEnumOneofFieldGenerator() override; void GenerateMembers(io::Printer* printer) const override; void GenerateBuilderMembers(io::Printer* printer) const override; + void GenerateBuilderClearCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; void GenerateEqualsCode(io::Printer* printer) const override; void GenerateHashCode(io::Printer* printer) const override; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumOneofFieldGenerator); }; -class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator { +class RepeatedImmutableEnumFieldGenerator : public ImmutableEnumFieldGenerator { public: explicit RepeatedImmutableEnumFieldGenerator( const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context); + RepeatedImmutableEnumFieldGenerator( + const RepeatedImmutableEnumFieldGenerator&) = delete; + RepeatedImmutableEnumFieldGenerator& operator=( + const RepeatedImmutableEnumFieldGenerator&) = delete; ~RepeatedImmutableEnumFieldGenerator() override; // implements ImmutableFieldGenerator --------------------------------------- @@ -132,9 +142,9 @@ class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator { void GenerateBuilderClearCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; - void GenerateParsingCodeFromPacked(io::Printer* printer) const override; - void GenerateParsingDoneCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; + void GenerateBuilderParsingCodeFromPacked( + io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; void GenerateFieldBuilderInitializationCode( @@ -144,13 +154,6 @@ class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator { void GenerateKotlinDslMembers(io::Printer* printer) const override; std::string GetBoxedType() const override; - - private: - const FieldDescriptor* descriptor_; - std::map<std::string, std::string> variables_; - ClassNameResolver* name_resolver_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableEnumFieldGenerator); }; } // namespace java diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_enum_field_lite.cc b/r5dev/thirdparty/protobuf/compiler/java/enum_field_lite.cc similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_enum_field_lite.cc rename to r5dev/thirdparty/protobuf/compiler/java/enum_field_lite.cc index 97da5897..986ca6c3 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_enum_field_lite.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/enum_field_lite.cc @@ -32,7 +32,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_enum_field_lite.h> +#include <thirdparty/protobuf/compiler/java/enum_field_lite.h> #include <cstdint> #include <map> @@ -40,13 +40,16 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> + +// Must be last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -916,3 +919,5 @@ std::string RepeatedImmutableEnumFieldLiteGenerator::GetBoxedType() const { } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_enum_field_lite.h b/r5dev/thirdparty/protobuf/compiler/java/enum_field_lite.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_enum_field_lite.h rename to r5dev/thirdparty/protobuf/compiler/java/enum_field_lite.h index e4965057..c3bb00c1 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_enum_field_lite.h +++ b/r5dev/thirdparty/protobuf/compiler/java/enum_field_lite.h @@ -39,7 +39,7 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_field.h> +#include <thirdparty/protobuf/compiler/java/field.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_enum_lite.cc b/r5dev/thirdparty/protobuf/compiler/java/enum_lite.cc similarity index 96% rename from r5dev/thirdparty/protobuf/compiler/java/java_enum_lite.cc rename to r5dev/thirdparty/protobuf/compiler/java/enum_lite.cc index cb07c146..da84559f 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_enum_lite.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/enum_lite.cc @@ -32,17 +32,18 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include <thirdparty/protobuf/compiler/java/enum_lite.h> + #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_enum_lite.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/stubs/map_util.h> namespace google { diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_enum_lite.h b/r5dev/thirdparty/protobuf/compiler/java/enum_lite.h similarity index 100% rename from r5dev/thirdparty/protobuf/compiler/java/java_enum_lite.h rename to r5dev/thirdparty/protobuf/compiler/java/enum_lite.h diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_extension.cc b/r5dev/thirdparty/protobuf/compiler/java/extension.cc similarity index 94% rename from r5dev/thirdparty/protobuf/compiler/java/java_extension.cc rename to r5dev/thirdparty/protobuf/compiler/java/extension.cc index b654f6d3..b1fd9277 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_extension.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/extension.cc @@ -32,14 +32,17 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_extension.h> +#include <thirdparty/protobuf/compiler/java/extension.h> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> + +// Must be last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -170,3 +173,5 @@ int ImmutableExtensionGenerator::GenerateRegistrationCode( } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_extension.h b/r5dev/thirdparty/protobuf/compiler/java/extension.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_extension.h rename to r5dev/thirdparty/protobuf/compiler/java/extension.h index 6f83ca3c..fd790bc5 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_extension.h +++ b/r5dev/thirdparty/protobuf/compiler/java/extension.h @@ -92,7 +92,7 @@ class ImmutableExtensionGenerator : public ExtensionGenerator { public: explicit ImmutableExtensionGenerator(const FieldDescriptor* descriptor, Context* context); - virtual ~ImmutableExtensionGenerator(); + ~ImmutableExtensionGenerator() override; void Generate(io::Printer* printer) override; int GenerateNonNestedInitializationCode(io::Printer* printer) override; diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_extension_lite.cc b/r5dev/thirdparty/protobuf/compiler/java/extension_lite.cc similarity index 91% rename from r5dev/thirdparty/protobuf/compiler/java/java_extension_lite.cc rename to r5dev/thirdparty/protobuf/compiler/java/extension_lite.cc index 5075a890..060357fc 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_extension_lite.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/extension_lite.cc @@ -28,14 +28,17 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <thirdparty/protobuf/compiler/java/java_extension_lite.h> +#include <thirdparty/protobuf/compiler/java/extension_lite.h> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> + +// Must be last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -113,3 +116,5 @@ int ImmutableExtensionLiteGenerator::GenerateRegistrationCode( } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_extension_lite.h b/r5dev/thirdparty/protobuf/compiler/java/extension_lite.h similarity index 96% rename from r5dev/thirdparty/protobuf/compiler/java/java_extension_lite.h rename to r5dev/thirdparty/protobuf/compiler/java/extension_lite.h index 6f16fc69..8e585b17 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_extension_lite.h +++ b/r5dev/thirdparty/protobuf/compiler/java/extension_lite.h @@ -35,7 +35,7 @@ #include <string> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/java/java_extension.h> +#include <thirdparty/protobuf/compiler/java/extension.h> namespace google { namespace protobuf { @@ -49,7 +49,7 @@ class ImmutableExtensionLiteGenerator : public ExtensionGenerator { public: explicit ImmutableExtensionLiteGenerator(const FieldDescriptor* descriptor, Context* context); - virtual ~ImmutableExtensionLiteGenerator(); + ~ImmutableExtensionLiteGenerator() override; void Generate(io::Printer* printer) override; diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_field.cc b/r5dev/thirdparty/protobuf/compiler/java/field.cc similarity index 92% rename from r5dev/thirdparty/protobuf/compiler/java/java_field.cc rename to r5dev/thirdparty/protobuf/compiler/java/field.cc index 7faf0956..10c7fc91 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/field.cc @@ -32,27 +32,27 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_field.h> +#include <thirdparty/protobuf/compiler/java/field.h> #include <memory> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_enum_field.h> -#include <thirdparty/protobuf/compiler/java/java_enum_field_lite.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_map_field.h> -#include <thirdparty/protobuf/compiler/java/java_map_field_lite.h> -#include <thirdparty/protobuf/compiler/java/java_message_field.h> -#include <thirdparty/protobuf/compiler/java/java_message_field_lite.h> -#include <thirdparty/protobuf/compiler/java/java_primitive_field.h> -#include <thirdparty/protobuf/compiler/java/java_primitive_field_lite.h> -#include <thirdparty/protobuf/compiler/java/java_string_field.h> -#include <thirdparty/protobuf/compiler/java/java_string_field_lite.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/enum_field.h> +#include <thirdparty/protobuf/compiler/java/enum_field_lite.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/map_field.h> +#include <thirdparty/protobuf/compiler/java/map_field_lite.h> +#include <thirdparty/protobuf/compiler/java/message_field.h> +#include <thirdparty/protobuf/compiler/java/message_field_lite.h> +#include <thirdparty/protobuf/compiler/java/primitive_field.h> +#include <thirdparty/protobuf/compiler/java/primitive_field_lite.h> +#include <thirdparty/protobuf/compiler/java/string_field.h> +#include <thirdparty/protobuf/compiler/java/string_field_lite.h> namespace google { @@ -185,7 +185,7 @@ static inline void ReportUnexpectedPackedFieldsCall(io::Printer* printer) { // but this method should be overridden. // - This FieldGenerator doesn't support packing, and this method // should never have been called. - GOOGLE_LOG(FATAL) << "GenerateParsingCodeFromPacked() " + GOOGLE_LOG(FATAL) << "GenerateBuilderParsingCodeFromPacked() " << "called on field generator that does not support packing."; } @@ -193,7 +193,7 @@ static inline void ReportUnexpectedPackedFieldsCall(io::Printer* printer) { ImmutableFieldGenerator::~ImmutableFieldGenerator() {} -void ImmutableFieldGenerator::GenerateParsingCodeFromPacked( +void ImmutableFieldGenerator::GenerateBuilderParsingCodeFromPacked( io::Printer* printer) const { ReportUnexpectedPackedFieldsCall(printer); } diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_field.h b/r5dev/thirdparty/protobuf/compiler/java/field.h similarity index 95% rename from r5dev/thirdparty/protobuf/compiler/java/java_field.h rename to r5dev/thirdparty/protobuf/compiler/java/field.h index c3f79dee..6ffc3c70 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_field.h +++ b/r5dev/thirdparty/protobuf/compiler/java/field.h @@ -68,6 +68,8 @@ class ImmutableFieldGenerator { ImmutableFieldGenerator() {} virtual ~ImmutableFieldGenerator(); + virtual int GetMessageBitIndex() const = 0; + virtual int GetBuilderBitIndex() const = 0; virtual int GetNumBitsForMessage() const = 0; virtual int GetNumBitsForBuilder() const = 0; virtual void GenerateInterfaceMembers(io::Printer* printer) const = 0; @@ -77,9 +79,8 @@ class ImmutableFieldGenerator { virtual void GenerateBuilderClearCode(io::Printer* printer) const = 0; virtual void GenerateMergingCode(io::Printer* printer) const = 0; virtual void GenerateBuildingCode(io::Printer* printer) const = 0; - virtual void GenerateParsingCode(io::Printer* printer) const = 0; - virtual void GenerateParsingCodeFromPacked(io::Printer* printer) const; - virtual void GenerateParsingDoneCode(io::Printer* printer) const = 0; + virtual void GenerateBuilderParsingCode(io::Printer* printer) const = 0; + virtual void GenerateBuilderParsingCodeFromPacked(io::Printer* printer) const; virtual void GenerateSerializationCode(io::Printer* printer) const = 0; virtual void GenerateSerializedSizeCode(io::Printer* printer) const = 0; virtual void GenerateFieldBuilderInitializationCode( @@ -156,7 +157,7 @@ template <> FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap(); -// Field information used in FieldGeneartors. +// Field information used in FieldGenerators. struct FieldGeneratorInfo { std::string name; std::string capitalized_name; diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_file.cc b/r5dev/thirdparty/protobuf/compiler/java/file.cc similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/java/java_file.cc rename to r5dev/thirdparty/protobuf/compiler/java/file.cc index aba05815..162c29cb 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_file.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/file.cc @@ -32,27 +32,30 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_file.h> +#include <thirdparty/protobuf/compiler/java/file.h> #include <memory> #include <set> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_enum.h> -#include <thirdparty/protobuf/compiler/java/java_enum_lite.h> -#include <thirdparty/protobuf/compiler/java/java_extension.h> -#include <thirdparty/protobuf/compiler/java/java_generator_factory.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_message.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/compiler/java/java_service.h> -#include <thirdparty/protobuf/compiler/java/java_shared_code_generator.h> #include <thirdparty/protobuf/compiler/code_generator.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/dynamic_message.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/enum.h> +#include <thirdparty/protobuf/compiler/java/enum_lite.h> +#include <thirdparty/protobuf/compiler/java/extension.h> +#include <thirdparty/protobuf/compiler/java/generator_factory.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/message.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> +#include <thirdparty/protobuf/compiler/java/service.h> +#include <thirdparty/protobuf/compiler/java/shared_code_generator.h> +#include <thirdparty/protobuf/descriptor.pb.h> + +// Must be last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -247,7 +250,7 @@ bool FileGenerator::Validate(std::string* error) { << "generate full runtime code for Java. To use Java Lite runtime, " << "users should use the Java Lite plugin instead. See:\n" << " " - "https://github.com/protocolbuffers/protobuf/blob/master/java/" + "https://github.com/protocolbuffers/protobuf/blob/main/java/" "lite.md"; } return true; @@ -732,3 +735,5 @@ bool FileGenerator::ShouldIncludeDependency(const FileDescriptor* descriptor, } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_file.h b/r5dev/thirdparty/protobuf/compiler/java/file.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_file.h rename to r5dev/thirdparty/protobuf/compiler/java/file.h index b64b315a..f9389535 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_file.h +++ b/r5dev/thirdparty/protobuf/compiler/java/file.h @@ -38,8 +38,9 @@ #include <memory> #include <string> #include <vector> + #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/java/java_options.h> +#include <thirdparty/protobuf/compiler/java/options.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_generator.cc b/r5dev/thirdparty/protobuf/compiler/java/generator.cc similarity index 94% rename from r5dev/thirdparty/protobuf/compiler/java/java_generator.cc rename to r5dev/thirdparty/protobuf/compiler/java/generator.cc index bedbebd5..0fa7fcee 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_generator.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/generator.cc @@ -32,20 +32,21 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_generator.h> +#include <thirdparty/protobuf/compiler/java/generator.h> #include <memory> -#include <thirdparty/protobuf/compiler/java/java_file.h> -#include <thirdparty/protobuf/compiler/java/java_generator_factory.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/compiler/java/java_options.h> -#include <thirdparty/protobuf/compiler/java/java_shared_code_generator.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> +#include <thirdparty/protobuf/stubs/stringprintf.h> +#include <thirdparty/protobuf/compiler/java/file.h> +#include <thirdparty/protobuf/compiler/java/generator_factory.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> +#include <thirdparty/protobuf/compiler/java/options.h> +#include <thirdparty/protobuf/compiler/java/shared_code_generator.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/stubs/strutil.h> diff --git a/r5dev/thirdparty/protobuf/compiler/java/generator.h b/r5dev/thirdparty/protobuf/compiler/java/generator.h new file mode 100644 index 00000000..6d691c72 --- /dev/null +++ b/r5dev/thirdparty/protobuf/compiler/java/generator.h @@ -0,0 +1,77 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Author: kenton@google.com (Kenton Varda) +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. +// +// Generates Java code for a given .proto file. + +#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ +#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ + +#include <string> +#include <thirdparty/protobuf/compiler/code_generator.h> + +// Must be included last. +#include <thirdparty/protobuf/port_def.inc> + +namespace google { +namespace protobuf { +namespace compiler { +namespace java { + +// CodeGenerator implementation which generates Java code. If you create your +// own protocol compiler binary and you want it to support Java output, you +// can do so by registering an instance of this CodeGenerator with the +// CommandLineInterface in your main() function. +class PROTOC_EXPORT JavaGenerator : public CodeGenerator { + public: + JavaGenerator(); + ~JavaGenerator() override; + + // implements CodeGenerator ---------------------------------------- + bool Generate(const FileDescriptor* file, const std::string& parameter, + GeneratorContext* context, std::string* error) const override; + + uint64_t GetSupportedFeatures() const override; + + private: + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator); +}; + +} // namespace java +} // namespace compiler +} // namespace protobuf +} // namespace google + +#include <thirdparty/protobuf/port_undef.inc> + +#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_generator_factory.cc b/r5dev/thirdparty/protobuf/compiler/java/generator_factory.cc similarity index 82% rename from r5dev/thirdparty/protobuf/compiler/java/java_generator_factory.cc rename to r5dev/thirdparty/protobuf/compiler/java/generator_factory.cc index 5e80b174..903237f2 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_generator_factory.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/generator_factory.cc @@ -30,17 +30,17 @@ // Author: liujisi@google.com (Pherl Liu) -#include <thirdparty/protobuf/compiler/java/java_generator_factory.h> +#include <thirdparty/protobuf/compiler/java/generator_factory.h> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_enum_field.h> -#include <thirdparty/protobuf/compiler/java/java_extension.h> -#include <thirdparty/protobuf/compiler/java/java_extension_lite.h> -#include <thirdparty/protobuf/compiler/java/java_field.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_message.h> -#include <thirdparty/protobuf/compiler/java/java_message_lite.h> -#include <thirdparty/protobuf/compiler/java/java_service.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/enum_field.h> +#include <thirdparty/protobuf/compiler/java/extension.h> +#include <thirdparty/protobuf/compiler/java/extension_lite.h> +#include <thirdparty/protobuf/compiler/java/field.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/message.h> +#include <thirdparty/protobuf/compiler/java/message_lite.h> +#include <thirdparty/protobuf/compiler/java/service.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_generator_factory.h b/r5dev/thirdparty/protobuf/compiler/java/generator_factory.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_generator_factory.h rename to r5dev/thirdparty/protobuf/compiler/java/generator_factory.h index 6403d73a..3c2c68a4 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_generator_factory.h +++ b/r5dev/thirdparty/protobuf/compiler/java/generator_factory.h @@ -78,7 +78,7 @@ class GeneratorFactory { class ImmutableGeneratorFactory : public GeneratorFactory { public: ImmutableGeneratorFactory(Context* context); - virtual ~ImmutableGeneratorFactory(); + ~ImmutableGeneratorFactory() override; MessageGenerator* NewMessageGenerator( const Descriptor* descriptor) const override; diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_helpers.cc b/r5dev/thirdparty/protobuf/compiler/java/helpers.cc similarity index 95% rename from r5dev/thirdparty/protobuf/compiler/java/java_helpers.cc rename to r5dev/thirdparty/protobuf/compiler/java/helpers.cc index 910d9abf..a925964e 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_helpers.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/helpers.cc @@ -32,7 +32,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_helpers.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> #include <algorithm> #include <cstdint> @@ -40,15 +40,18 @@ #include <unordered_set> #include <vector> -#include <thirdparty/protobuf/stubs/stringprintf.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/compiler/java/java_names.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> +#include <thirdparty/protobuf/compiler/java/names.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/stubs/hash.h> // for hash<T *> +// Must be last. +#include <thirdparty/protobuf/port_def.inc> + namespace google { namespace protobuf { namespace compiler { @@ -66,15 +69,26 @@ namespace { const char* kDefaultPackage = ""; -// Names that should be avoided as field names. -// Using them will cause the compiler to generate accessors whose names are -// colliding with methods defined in base classes. +// Names that should be avoided (in UpperCamelCase format). +// Using them will cause the compiler to generate accessors whose names +// collide with methods defined in base classes. +// Keep this list in sync with specialFieldNames in +// java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java const char* kForbiddenWordList[] = { - // message base class: - "cached_size", - "serialized_size", // java.lang.Object: - "class", + "Class", + // com.google.protobuf.MessageLiteOrBuilder: + "DefaultInstanceForType", + // com.google.protobuf.MessageLite: + "ParserForType", + "SerializedSize", + // com.google.protobuf.MessageOrBuilder: + "AllFields", + "DescriptorForType", + "InitializationErrorString", + "UnknownFields", + // obsolete. kept for backwards compatibility of generated code + "CachedSize", }; const std::unordered_set<std::string>* kReservedNames = @@ -93,7 +107,7 @@ const std::unordered_set<std::string>* kReservedNames = bool IsForbidden(const std::string& field_name) { for (int i = 0; i < GOOGLE_ARRAYSIZE(kForbiddenWordList); ++i) { - if (field_name == kForbiddenWordList[i]) { + if (UnderscoresToCamelCase(field_name, true) == kForbiddenWordList[i]) { return true; } } @@ -249,18 +263,18 @@ std::string UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field) { return name; } +// Names that should be avoided as field names in Kotlin. +// All Kotlin hard keywords are in this list. +const std::unordered_set<std::string>* kKotlinForbiddenNames = + new std::unordered_set<std::string>({ + "as", "as?", "break", "class", "continue", "do", "else", + "false", "for", "fun", "if", "in", "!in", "interface", + "is", "!is", "null", "object", "package", "return", "super", + "this", "throw", "true", "try", "typealias", "typeof", "val", + "var", "when", "while", + }); + bool IsForbiddenKotlin(const std::string& field_name) { - // Names that should be avoided as field names in Kotlin. - // All Kotlin hard keywords are in this list. - const std::unordered_set<std::string>* kKotlinForbiddenNames = - new std::unordered_set<std::string>({ - "as", "as?", "break", "class", "continue", "do", - "else", "false", "for", "fun", "if", "in", - "!in", "interface", "is", "!is", "null", "object", - "package", "return", "super", "this", "throw", "true", - "try", "typealias", "typeof", "val", "var", "when", - "while", - }); return kKotlinForbiddenNames->find(field_name) != kKotlinForbiddenNames->end(); } @@ -1049,8 +1063,7 @@ int GetExperimentalJavaFieldType(const FieldDescriptor* field) { if (field->is_map()) { if (!SupportUnknownEnumValue(field)) { - const FieldDescriptor* value = - field->message_type()->FindFieldByName("value"); + const FieldDescriptor* value = field->message_type()->map_value(); if (GetJavaType(value) == JAVATYPE_ENUM) { extra_bits |= kMapWithProto2EnumValue; } @@ -1098,3 +1111,5 @@ void EscapeUtf16ToString(uint16_t code, std::string* output) { } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_helpers.h b/r5dev/thirdparty/protobuf/compiler/java/helpers.h similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/java/java_helpers.h rename to r5dev/thirdparty/protobuf/compiler/java/helpers.h index f0944f61..66db271d 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_helpers.h +++ b/r5dev/thirdparty/protobuf/compiler/java/helpers.h @@ -38,10 +38,10 @@ #include <cstdint> #include <string> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/descriptor.pb.h> namespace google { namespace protobuf { @@ -151,6 +151,21 @@ inline bool IsDescriptorProto(const Descriptor* descriptor) { // fields. std::string GetOneofStoredType(const FieldDescriptor* field); +// We use either the proto1 enums if the enum is generated, otherwise fall back +// to use integers. +enum class Proto1EnumRepresentation { + kEnum, + kInteger, +}; + +// Returns which representation we should use. +inline Proto1EnumRepresentation GetProto1EnumRepresentation( + const EnumDescriptor* descriptor) { + if (descriptor->containing_type() != nullptr) { + return Proto1EnumRepresentation::kEnum; + } + return Proto1EnumRepresentation::kInteger; +} // Whether we should generate multiple java files for messages. inline bool MultipleJavaFiles(const FileDescriptor* descriptor, diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_generator.h b/r5dev/thirdparty/protobuf/compiler/java/java_generator.h index c521bbfc..c5073a56 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_generator.h +++ b/r5dev/thirdparty/protobuf/compiler/java/java_generator.h @@ -1,76 +1,6 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_JAVA_GENERATOR_H_ +#define GOOGLE_PROTOBUF_COMPILER_JAVA_JAVA_GENERATOR_H_ -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Generates Java code for a given .proto file. +#include <thirdparty/protobuf/compiler/java/generator.h> -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ - -#include <string> -#include <thirdparty/protobuf/compiler/code_generator.h> - -#include <thirdparty/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -// CodeGenerator implementation which generates Java code. If you create your -// own protocol compiler binary and you want it to support Java output, you -// can do so by registering an instance of this CodeGenerator with the -// CommandLineInterface in your main() function. -class PROTOC_EXPORT JavaGenerator : public CodeGenerator { - public: - JavaGenerator(); - ~JavaGenerator(); - - // implements CodeGenerator ---------------------------------------- - bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* context, std::string* error) const override; - - uint64_t GetSupportedFeatures() const override; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <thirdparty/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ +#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_JAVA_GENERATOR_H_ diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_kotlin_generator.cc b/r5dev/thirdparty/protobuf/compiler/java/kotlin_generator.cc similarity index 88% rename from r5dev/thirdparty/protobuf/compiler/java/java_kotlin_generator.cc rename to r5dev/thirdparty/protobuf/compiler/java/kotlin_generator.cc index af38ba06..13610f48 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_kotlin_generator.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/kotlin_generator.cc @@ -28,13 +28,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <thirdparty/protobuf/compiler/java/java_kotlin_generator.h> +#include <thirdparty/protobuf/compiler/java/kotlin_generator.h> -#include <thirdparty/protobuf/compiler/java/java_file.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_options.h> -#include <thirdparty/protobuf/compiler/java/java_generator.h> #include <thirdparty/protobuf/compiler/code_generator.h> +#include <thirdparty/protobuf/compiler/java/file.h> +#include <thirdparty/protobuf/compiler/java/generator.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/options.h> namespace google { namespace protobuf { @@ -63,11 +63,13 @@ bool KotlinGenerator::Generate(const FileDescriptor* file, if (option.first == "output_list_file") { file_options.output_list_file = option.second; } else if (option.first == "immutable") { + // Note: the option is considered always set regardless of the input. file_options.generate_immutable_code = true; } else if (option.first == "mutable") { *error = "Mutable not supported by Kotlin generator"; return false; } else if (option.first == "shared") { + // Note: the option is considered always set regardless of the input. file_options.generate_shared_code = true; } else if (option.first == "lite") { file_options.enforce_lite = true; @@ -81,23 +83,17 @@ bool KotlinGenerator::Generate(const FileDescriptor* file, } } - // By default we generate immutable code and shared code for immutable API. - if (!file_options.generate_immutable_code && - !file_options.generate_shared_code) { - file_options.generate_immutable_code = true; - file_options.generate_shared_code = true; - } + // We only support generation of immutable code so we do it. + file_options.generate_immutable_code = true; + file_options.generate_shared_code = true; std::vector<std::string> all_files; std::vector<std::string> all_annotations; - std::unique_ptr<FileGenerator> file_generator; - if (file_options.generate_immutable_code) { - file_generator.reset( + std::unique_ptr<FileGenerator> file_generator( new FileGenerator(file, file_options, /* immutable_api = */ true)); - } - if (!file_generator->Validate(error)) { + if (!file_generator || !file_generator->Validate(error)) { return false; } diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_kotlin_generator.h b/r5dev/thirdparty/protobuf/compiler/java/kotlin_generator.h similarity index 99% rename from r5dev/thirdparty/protobuf/compiler/java/java_kotlin_generator.h rename to r5dev/thirdparty/protobuf/compiler/java/kotlin_generator.h index 0a559f6b..43779486 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_kotlin_generator.h +++ b/r5dev/thirdparty/protobuf/compiler/java/kotlin_generator.h @@ -36,6 +36,8 @@ #include <string> #include <thirdparty/protobuf/compiler/code_generator.h> + +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_map_field.cc b/r5dev/thirdparty/protobuf/compiler/java/map_field.cc similarity index 77% rename from r5dev/thirdparty/protobuf/compiler/java/java_map_field.cc rename to r5dev/thirdparty/protobuf/compiler/java/map_field.cc index 69c65b8c..777f107d 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_map_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/map_field.cc @@ -28,13 +28,16 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <thirdparty/protobuf/compiler/java/java_map_field.h> +#include "google/protobuf/compiler/java/map_field.h" -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/io/printer.h> +#include "google/protobuf/io/printer.h" +#include "google/protobuf/compiler/java/context.h" +#include "google/protobuf/compiler/java/doc_comment.h" +#include "google/protobuf/compiler/java/helpers.h" +#include "google/protobuf/compiler/java/name_resolver.h" + +// Must be last. +#include "google/protobuf/port_def.inc" namespace google { namespace protobuf { @@ -47,14 +50,14 @@ const FieldDescriptor* KeyField(const FieldDescriptor* descriptor) { GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type()); const Descriptor* message = descriptor->message_type(); GOOGLE_CHECK(message->options().map_entry()); - return message->FindFieldByName("key"); + return message->map_key(); } const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) { GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type()); const Descriptor* message = descriptor->message_type(); GOOGLE_CHECK(message->options().map_entry()); - return message->FindFieldByName("value"); + return message->map_value(); } std::string TypeName(const FieldDescriptor* field, @@ -85,10 +88,10 @@ std::string WireType(const FieldDescriptor* field) { std::string(FieldTypeName(field->type())); } -void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, - int builderBitIndex, const FieldGeneratorInfo* info, - Context* context, - std::map<std::string, std::string>* variables) { +void SetMessageVariables( + const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, + const FieldGeneratorInfo* info, Context* context, + std::map<std::string, std::string>* variables) { SetCommonFieldVariables(descriptor, info, variables); ClassNameResolver* name_resolver = context->GetNameResolver(); @@ -99,6 +102,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, const JavaType keyJavaType = GetJavaType(key); const JavaType valueJavaType = GetJavaType(value); + std::string pass_through_nullness = "/* nullable */\n"; + (*variables)["key_type"] = TypeName(key, name_resolver, false); std::string boxed_key_type = TypeName(key, name_resolver, true); (*variables)["boxed_key_type"] = boxed_key_type; @@ -115,13 +120,14 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, : ""; (*variables)["value_null_check"] = valueJavaType != JAVATYPE_ENUM && IsReferenceType(valueJavaType) - ? "if (value == null) {\n" - " throw new NullPointerException(\"map value\");\n" - "}\n" + ? "if (value == null) { " + "throw new NullPointerException(\"map value\"); }" : ""; if (valueJavaType == JAVATYPE_ENUM) { // We store enums as Integers internally. (*variables)["value_type"] = "int"; + variables->insert( + {"value_type_pass_through_nullness", (*variables)["value_type"]}); (*variables)["boxed_value_type"] = "java.lang.Integer"; (*variables)["value_wire_type"] = WireType(value); (*variables)["value_default_value"] = @@ -129,10 +135,15 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, (*variables)["value_enum_type"] = TypeName(value, name_resolver, false); + variables->insert( + {"value_enum_type_pass_through_nullness", + StrCat(pass_through_nullness, (*variables)["value_enum_type"])}); + if (SupportUnknownEnumValue(descriptor->file())) { // Map unknown values to a special UNRECOGNIZED value if supported. - (*variables)["unrecognized_value"] = - (*variables)["value_enum_type"] + ".UNRECOGNIZED"; + variables->insert( + {"unrecognized_value", + StrCat((*variables)["value_enum_type"], ".UNRECOGNIZED")}); } else { // Map unknown values to the default value if we don't have UNRECOGNIZED. (*variables)["unrecognized_value"] = @@ -140,38 +151,49 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, } } else { (*variables)["value_type"] = TypeName(value, name_resolver, false); + + variables->insert( + {"value_type_pass_through_nullness", + StrCat( + (IsReferenceType(valueJavaType) ? pass_through_nullness : ""), + (*variables)["value_type"])}); + (*variables)["boxed_value_type"] = TypeName(value, name_resolver, true); (*variables)["value_wire_type"] = WireType(value); (*variables)["value_default_value"] = DefaultValue(value, true, name_resolver); } - (*variables)["type_parameters"] = - (*variables)["boxed_key_type"] + ", " + (*variables)["boxed_value_type"]; + variables->insert( + {"type_parameters", StrCat((*variables)["boxed_key_type"], ", ", + (*variables)["boxed_value_type"])}); // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported // by the proto compiler (*variables)["deprecation"] = descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; - (*variables)["kt_deprecation"] = - descriptor->options().deprecated() - ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] + - " is deprecated\") " - : ""; + variables->insert( + {"kt_deprecation", + descriptor->options().deprecated() + ? StrCat("@kotlin.Deprecated(message = \"Field ", + (*variables)["name"], " is deprecated\") ") + : ""}); (*variables)["on_changed"] = "onChanged();"; - // For repeated fields, one bit is used for whether the array is immutable - // in the parsing constructor. - (*variables)["get_mutable_bit_parser"] = - GenerateGetBitMutableLocal(builderBitIndex); - (*variables)["set_mutable_bit_parser"] = - GenerateSetBitMutableLocal(builderBitIndex); - - (*variables)["default_entry"] = - (*variables)["capitalized_name"] + "DefaultEntryHolder.defaultEntry"; - (*variables)["map_field_parameter"] = (*variables)["default_entry"]; + variables->insert( + {"default_entry", StrCat((*variables)["capitalized_name"], + "DefaultEntryHolder.defaultEntry")}); + variables->insert({"map_field_parameter", (*variables)["default_entry"]}); (*variables)["descriptor"] = name_resolver->GetImmutableClassName(descriptor->file()) + ".internal_" + UniqueFileScopeIdentifier(descriptor->message_type()) + "_descriptor, "; (*variables)["ver"] = GeneratedCodeVersionSuffix(); + + (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); + (*variables)["get_has_field_bit_from_local"] = + GenerateGetBitFromLocal(builderBitIndex); + (*variables)["set_has_field_bit_builder"] = + GenerateSetBit(builderBitIndex) + ";"; + (*variables)["clear_has_field_bit_builder"] = + GenerateClearBit(builderBitIndex) + ";"; } } // namespace @@ -179,7 +201,11 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, ImmutableMapFieldGenerator::ImmutableMapFieldGenerator( const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context) - : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) { + : descriptor_(descriptor), + message_bit_index_(messageBitIndex), + builder_bit_index_(builderBitIndex), + name_resolver_(context->GetNameResolver()), + context_(context) { SetMessageVariables(descriptor, messageBitIndex, builderBitIndex, context->GetFieldGeneratorInfo(descriptor), context, &variables_); @@ -187,6 +213,14 @@ ImmutableMapFieldGenerator::ImmutableMapFieldGenerator( ImmutableMapFieldGenerator::~ImmutableMapFieldGenerator() {} +int ImmutableMapFieldGenerator::GetMessageBitIndex() const { + return message_bit_index_; +} + +int ImmutableMapFieldGenerator::GetBuilderBitIndex() const { + return builder_bit_index_; +} + int ImmutableMapFieldGenerator::GetNumBitsForMessage() const { return 0; } int ImmutableMapFieldGenerator::GetNumBitsForBuilder() const { return 1; } @@ -218,11 +252,12 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers( "${$get$capitalized_name$Map$}$();\n"); printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" - " $key_type$ key,\n" - " $value_enum_type$ defaultValue);\n"); + printer->Print(variables_, + "$deprecation$$value_enum_type_pass_through_nullness$ " + "${$get$capitalized_name$OrDefault$}$(\n" + " $key_type$ key,\n" + " $value_enum_type_pass_through_nullness$ " + " defaultValue);\n"); printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( @@ -247,16 +282,16 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers( printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$\n" - "$value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" + "$deprecation$$value_type_pass_through_nullness$ " + "${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" - " $value_type$ defaultValue);\n"); + " $value_type_pass_through_nullness$ defaultValue);\n"); printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$\n" - "$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" - " $key_type$ key);\n"); + printer->Print( + variables_, + "$deprecation$$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" + " $key_type$ key);\n"); printer->Annotate("{", "}", descriptor_); } } else { @@ -275,16 +310,16 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers( printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$\n" - "$value_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "$deprecation$$value_type_pass_through_nullness$ " + "${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" - " $value_type$ defaultValue);\n"); + " $value_type_pass_through_nullness$ defaultValue);\n"); printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$\n" - "$value_type$ ${$get$capitalized_name$OrThrow$}$(\n" - " $key_type$ key);\n"); + printer->Print( + variables_, + "$deprecation$$value_type$ ${$get$capitalized_name$OrThrow$}$(\n" + " $key_type$ key);\n"); printer->Annotate("{", "}", descriptor_); } } @@ -304,6 +339,7 @@ void ImmutableMapFieldGenerator::GenerateMembers(io::Printer* printer) const { " $value_default_value$);\n" "}\n"); printer->Print(variables_, + "@SuppressWarnings(\"serial\")\n" "private com.google.protobuf.MapField<\n" " $type_parameters$> $name$_;\n" "private com.google.protobuf.MapField<$type_parameters$>\n" @@ -339,42 +375,45 @@ void ImmutableMapFieldGenerator::GenerateMembers(io::Printer* printer) const { void ImmutableMapFieldGenerator::GenerateBuilderMembers( io::Printer* printer) const { - printer->Print(variables_, - "private com.google.protobuf.MapField<\n" - " $type_parameters$> $name$_;\n" - "private com.google.protobuf.MapField<$type_parameters$>\n" - "internalGet$capitalized_name$() {\n" - " if ($name$_ == null) {\n" - " return com.google.protobuf.MapField.emptyMapField(\n" - " $map_field_parameter$);\n" - " }\n" - " return $name$_;\n" - "}\n" - "private com.google.protobuf.MapField<$type_parameters$>\n" - "internalGetMutable$capitalized_name$() {\n" - " $on_changed$;\n" - " if ($name$_ == null) {\n" - " $name$_ = com.google.protobuf.MapField.newMapField(\n" - " $map_field_parameter$);\n" - " }\n" - " if (!$name$_.isMutable()) {\n" - " $name$_ = $name$_.copy();\n" - " }\n" - " return $name$_;\n" - "}\n"); + printer->Print( + variables_, + "private com.google.protobuf.MapField<\n" + " $type_parameters$> $name$_;\n" + "$deprecation$private com.google.protobuf.MapField<$type_parameters$>\n" + " internalGet$capitalized_name$() {\n" + " if ($name$_ == null) {\n" + " return com.google.protobuf.MapField.emptyMapField(\n" + " $map_field_parameter$);\n" + " }\n" + " return $name$_;\n" + "}\n" + "$deprecation$private com.google.protobuf.MapField<$type_parameters$>\n" + " internalGetMutable$capitalized_name$() {\n" + " if ($name$_ == null) {\n" + " $name$_ = com.google.protobuf.MapField.newMapField(\n" + " $map_field_parameter$);\n" + " }\n" + " if (!$name$_.isMutable()) {\n" + " $name$_ = $name$_.copy();\n" + " }\n" + " $set_has_field_bit_builder$\n" + " $on_changed$\n" + " return $name$_;\n" + "}\n"); GenerateMapGetters(printer); - printer->Print(variables_, - "$deprecation$\n" - "public Builder ${$clear$capitalized_name$$}$() {\n" - " internalGetMutable$capitalized_name$().getMutableMap()\n" - " .clear();\n" - " return this;\n" - "}\n"); + printer->Print( + variables_, + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" + " $clear_has_field_bit_builder$\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .clear();\n" + " return this;\n" + "}\n"); printer->Annotate("{", "}", descriptor_); + WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$\n" - "public Builder ${$remove$capitalized_name$$}$(\n" + "$deprecation$public Builder ${$remove$capitalized_name$$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " internalGetMutable$capitalized_name$().getMutableMap()\n" @@ -382,6 +421,7 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); + if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print( variables_, @@ -390,7 +430,8 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "${$getMutable$capitalized_name$$}$() {\n" + " ${$getMutable$capitalized_name$$}$() {\n" + " $set_has_field_bit_builder$\n" " return internalGetAdapted$capitalized_name$Map(\n" " internalGetMutable$capitalized_name$().getMutableMap());\n" "}\n"); @@ -404,9 +445,11 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " $value_null_check$\n" " internalGetMutable$capitalized_name$().getMutableMap()\n" " .put(key, $name$ValueConverter.doBackward(value));\n" + " $set_has_field_bit_builder$\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); + WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -415,9 +458,11 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " internalGetAdapted$capitalized_name$Map(\n" " internalGetMutable$capitalized_name$().getMutableMap())\n" " .putAll(values);\n" + " $set_has_field_bit_builder$\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); + if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -427,6 +472,7 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" "${$getMutable$capitalized_name$Value$}$() {\n" + " $set_has_field_bit_builder$\n" " return internalGetMutable$capitalized_name$().getMutableMap();\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -440,9 +486,11 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " $value_null_check$\n" " internalGetMutable$capitalized_name$().getMutableMap()\n" " .put(key, value);\n" + " $set_has_field_bit_builder$\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); + WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -450,6 +498,7 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n" " internalGetMutable$capitalized_name$().getMutableMap()\n" " .putAll(values);\n" + " $set_has_field_bit_builder$\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); @@ -462,55 +511,59 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$type_parameters$>\n" - "${$getMutable$capitalized_name$$}$() {\n" + " ${$getMutable$capitalized_name$$}$() {\n" + " $set_has_field_bit_builder$\n" " return internalGetMutable$capitalized_name$().getMutableMap();\n" "}\n"); printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, - "$deprecation$" - "public Builder ${$put$capitalized_name$$}$(\n" + "$deprecation$public Builder ${$put$capitalized_name$$}$(\n" " $key_type$ key,\n" " $value_type$ value) {\n" " $key_null_check$\n" " $value_null_check$\n" " internalGetMutable$capitalized_name$().getMutableMap()\n" " .put(key, value);\n" + " $set_has_field_bit_builder$\n" " return this;\n" "}\n"); printer->Annotate("{", "}", descriptor_); + WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$\n" - "public Builder ${$putAll$capitalized_name$$}$(\n" - " java.util.Map<$type_parameters$> values) {\n" - " internalGetMutable$capitalized_name$().getMutableMap()\n" - " .putAll(values);\n" - " return this;\n" - "}\n"); + printer->Print( + variables_, + "$deprecation$public Builder ${$putAll$capitalized_name$$}$(\n" + " java.util.Map<$type_parameters$> values) {\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .putAll(values);\n" + " $set_has_field_bit_builder$\n" + " return this;\n" + "}\n"); printer->Annotate("{", "}", descriptor_); } } void ImmutableMapFieldGenerator::GenerateMapGetters( io::Printer* printer) const { - printer->Print(variables_, - "$deprecation$\n" - "public int ${$get$capitalized_name$Count$}$() {\n" - " return internalGet$capitalized_name$().getMap().size();\n" - "}\n"); + printer->Print( + variables_, + "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" + " return internalGet$capitalized_name$().getMap().size();\n" + "}\n"); printer->Annotate("{", "}", descriptor_); + WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$\n" "@java.lang.Override\n" - "public boolean ${$contains$capitalized_name$$}$(\n" + "$deprecation$public boolean ${$contains$capitalized_name$$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " return internalGet$capitalized_name$().getMap().containsKey(key);\n" "}\n"); printer->Annotate("{", "}", descriptor_); + if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print(variables_, "/**\n" @@ -526,21 +579,22 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" - "$deprecation$\n" - "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" + "$deprecation$public java.util.Map<$boxed_key_type$, " + "$value_enum_type$>\n" "${$get$capitalized_name$Map$}$() {\n" " return internalGetAdapted$capitalized_name$Map(\n" " internalGet$capitalized_name$().getMap());" "}\n"); printer->Annotate("{", "}", descriptor_); + WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" - "$deprecation$\n" - "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "$deprecation$public $value_enum_type_pass_through_nullness$ " + "${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" - " $value_enum_type$ defaultValue) {\n" + " $value_enum_type_pass_through_nullness$ defaultValue) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" " internalGet$capitalized_name$().getMap();\n" @@ -549,12 +603,12 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( " : defaultValue;\n" "}\n"); printer->Annotate("{", "}", descriptor_); + WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" - "$deprecation$\n" - "public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" + "$deprecation$public $value_enum_type$ get$capitalized_name$OrThrow(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" @@ -565,6 +619,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( " return $name$ValueConverter.doForward(map.get(key));\n" "}\n"); printer->Annotate("{", "}", descriptor_); + if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -579,23 +634,22 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( "}\n"); printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$\n" - "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "${$get$capitalized_name$ValueMap$}$() {\n" - " return internalGet$capitalized_name$().getMap();\n" - "}\n"); + printer->Print(variables_, + "@java.lang.Override\n" + "$deprecation$public java.util.Map<$boxed_key_type$, " + "$boxed_value_type$>\n" + "${$get$capitalized_name$ValueMap$}$() {\n" + " return internalGet$capitalized_name$().getMap();\n" + "}\n"); printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" - "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" + "$deprecation$public $value_type_pass_through_nullness$ " + "${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" - " $value_type$ defaultValue) {\n" + " $value_type_pass_through_nullness$ defaultValue) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" " internalGet$capitalized_name$().getMap();\n" @@ -606,8 +660,8 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( printer->Print( variables_, "@java.lang.Override\n" - "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" + "$deprecation$public $value_type$ " + "${$get$capitalized_name$ValueOrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" @@ -634,8 +688,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" - "$deprecation$\n" - "public java.util.Map<$type_parameters$> " + "$deprecation$public java.util.Map<$type_parameters$> " "${$get$capitalized_name$Map$}$() {\n" " return internalGet$capitalized_name$().getMap();\n" "}\n"); @@ -644,10 +697,10 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( printer->Print( variables_, "@java.lang.Override\n" - "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "$deprecation$public $value_type_pass_through_nullness$ " + "${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" - " $value_type$ defaultValue) {\n" + " $value_type_pass_through_nullness$ defaultValue) {\n" " $key_null_check$\n" " java.util.Map<$type_parameters$> map =\n" " internalGet$capitalized_name$().getMap();\n" @@ -655,19 +708,19 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( "}\n"); printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "@java.lang.Override\n" - "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n" - " $key_type$ key) {\n" - " $key_null_check$\n" - " java.util.Map<$type_parameters$> map =\n" - " internalGet$capitalized_name$().getMap();\n" - " if (!map.containsKey(key)) {\n" - " throw new java.lang.IllegalArgumentException();\n" - " }\n" - " return map.get(key);\n" - "}\n"); + printer->Print( + variables_, + "@java.lang.Override\n" + "$deprecation$public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n" + " $key_type$ key) {\n" + " $key_null_check$\n" + " java.util.Map<$type_parameters$> map =\n" + " internalGet$capitalized_name$().getMap();\n" + " if (!map.containsKey(key)) {\n" + " throw new java.lang.IllegalArgumentException();\n" + " }\n" + " return map.get(key);\n" + "}\n"); printer->Annotate("{", "}", descriptor_); } } @@ -766,6 +819,7 @@ void ImmutableMapFieldGenerator::GenerateInitializationCode( void ImmutableMapFieldGenerator::GenerateBuilderClearCode( io::Printer* printer) const { + // No need to clear the has-bit since we clear the bitField ints all at once. printer->Print(variables_, "internalGetMutable$capitalized_name$().clear();\n"); } @@ -774,38 +828,34 @@ void ImmutableMapFieldGenerator::GenerateMergingCode( io::Printer* printer) const { printer->Print(variables_, "internalGetMutable$capitalized_name$().mergeFrom(\n" - " other.internalGet$capitalized_name$());\n"); + " other.internalGet$capitalized_name$());\n" + "$set_has_field_bit_builder$\n"); } void ImmutableMapFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { printer->Print(variables_, - "result.$name$_ = internalGet$capitalized_name$();\n" - "result.$name$_.makeImmutable();\n"); + "if ($get_has_field_bit_from_local$) {\n" + " result.$name$_ = internalGet$capitalized_name$();\n" + " result.$name$_.makeImmutable();\n" + "}\n"); } -void ImmutableMapFieldGenerator::GenerateParsingCode( +void ImmutableMapFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { - printer->Print(variables_, - "if (!$get_mutable_bit_parser$) {\n" - " $name$_ = com.google.protobuf.MapField.newMapField(\n" - " $map_field_parameter$);\n" - " $set_mutable_bit_parser$;\n" - "}\n"); if (!SupportUnknownEnumValue(descriptor_->file()) && GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print( variables_, "com.google.protobuf.ByteString bytes = input.readBytes();\n" "com.google.protobuf.MapEntry<$type_parameters$>\n" - "$name$__ = $default_entry$.getParserForType().parseFrom(bytes);\n"); - printer->Print( - variables_, + "$name$__ = $default_entry$.getParserForType().parseFrom(bytes);\n" "if ($value_enum_type$.forNumber($name$__.getValue()) == null) {\n" - " unknownFields.mergeLengthDelimitedField($number$, bytes);\n" + " mergeUnknownLengthDelimitedField($number$, bytes);\n" "} else {\n" - " $name$_.getMutableMap().put(\n" + " internalGetMutable$capitalized_name$().getMutableMap().put(\n" " $name$__.getKey(), $name$__.getValue());\n" + " $set_has_field_bit_builder$\n" "}\n"); } else { printer->Print( @@ -813,16 +863,11 @@ void ImmutableMapFieldGenerator::GenerateParsingCode( "com.google.protobuf.MapEntry<$type_parameters$>\n" "$name$__ = input.readMessage(\n" " $default_entry$.getParserForType(), extensionRegistry);\n" - "$name$_.getMutableMap().put(\n" - " $name$__.getKey(), $name$__.getValue());\n"); + "internalGetMutable$capitalized_name$().getMutableMap().put(\n" + " $name$__.getKey(), $name$__.getValue());\n" + "$set_has_field_bit_builder$\n"); } } - -void ImmutableMapFieldGenerator::GenerateParsingDoneCode( - io::Printer* printer) const { - // Nothing to do here. -} - void ImmutableMapFieldGenerator::GenerateSerializationCode( io::Printer* printer) const { printer->Print(variables_, @@ -874,3 +919,5 @@ std::string ImmutableMapFieldGenerator::GetBoxedType() const { } // namespace compiler } // namespace protobuf } // namespace google + +#include "google/protobuf/port_undef.inc" diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_map_field.h b/r5dev/thirdparty/protobuf/compiler/java/map_field.h similarity index 92% rename from r5dev/thirdparty/protobuf/compiler/java/java_map_field.h rename to r5dev/thirdparty/protobuf/compiler/java/map_field.h index 3c6db9f9..d54a28bd 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_map_field.h +++ b/r5dev/thirdparty/protobuf/compiler/java/map_field.h @@ -31,7 +31,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__ -#include <thirdparty/protobuf/compiler/java/java_field.h> +#include "google/protobuf/compiler/java/field.h" namespace google { namespace protobuf { @@ -46,6 +46,8 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator { ~ImmutableMapFieldGenerator() override; // implements ImmutableFieldGenerator --------------------------------------- + int GetMessageBitIndex() const override; + int GetBuilderBitIndex() const override; int GetNumBitsForMessage() const override; int GetNumBitsForBuilder() const override; void GenerateInterfaceMembers(io::Printer* printer) const override; @@ -55,8 +57,7 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator { void GenerateBuilderClearCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; - void GenerateParsingDoneCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; void GenerateFieldBuilderInitializationCode( @@ -69,8 +70,11 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator { private: const FieldDescriptor* descriptor_; + int message_bit_index_; + int builder_bit_index_; std::map<std::string, std::string> variables_; ClassNameResolver* name_resolver_; + Context* context_; void GenerateMapGetters(io::Printer* printer) const; }; diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_map_field_lite.cc b/r5dev/thirdparty/protobuf/compiler/java/map_field_lite.cc similarity index 96% rename from r5dev/thirdparty/protobuf/compiler/java/java_map_field_lite.cc rename to r5dev/thirdparty/protobuf/compiler/java/map_field_lite.cc index ace59cf8..abb63ce4 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_map_field_lite.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/map_field_lite.cc @@ -28,15 +28,18 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <thirdparty/protobuf/compiler/java/java_map_field_lite.h> +#include <thirdparty/protobuf/compiler/java/map_field_lite.h> #include <cstdint> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> #include <thirdparty/protobuf/io/printer.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> + +// Must be last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -49,14 +52,14 @@ const FieldDescriptor* KeyField(const FieldDescriptor* descriptor) { GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type()); const Descriptor* message = descriptor->message_type(); GOOGLE_CHECK(message->options().map_entry()); - return message->FindFieldByName("key"); + return message->map_key(); } const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) { GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type()); const Descriptor* message = descriptor->message_type(); GOOGLE_CHECK(message->options().map_entry()); - return message->FindFieldByName("value"); + return message->map_value(); } std::string TypeName(const FieldDescriptor* field, @@ -101,6 +104,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, const JavaType keyJavaType = GetJavaType(key); const JavaType valueJavaType = GetJavaType(value); + std::string pass_through_nullness = "/* nullable */\n"; + (*variables)["key_type"] = TypeName(key, name_resolver, false); (*variables)["boxed_key_type"] = TypeName(key, name_resolver, true); (*variables)["kt_key_type"] = KotlinTypeName(key, name_resolver); @@ -128,6 +133,9 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, (*variables)["value_enum_type"] = TypeName(value, name_resolver, false); + (*variables)["value_enum_type_pass_through_nullness"] = + pass_through_nullness + (*variables)["value_enum_type"]; + if (SupportUnknownEnumValue(descriptor->file())) { // Map unknown values to a special UNRECOGNIZED value if supported. (*variables)["unrecognized_value"] = @@ -139,6 +147,11 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, } } else { (*variables)["value_type"] = TypeName(value, name_resolver, false); + + (*variables)["value_type_pass_through_nullness"] = + (IsReferenceType(valueJavaType) ? pass_through_nullness : "") + + (*variables)["value_type"]; + (*variables)["boxed_value_type"] = TypeName(value, name_resolver, true); (*variables)["value_wire_type"] = WireType(value); (*variables)["value_default_value"] = @@ -203,11 +216,12 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers( "${$get$capitalized_name$Map$}$();\n"); printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" - " $key_type$ key,\n" - " $value_enum_type$ defaultValue);\n"); + printer->Print(variables_, + "$deprecation$$value_enum_type_pass_through_nullness$ " + "${$get$capitalized_name$OrDefault$}$(\n" + " $key_type$ key,\n" + " $value_enum_type_pass_through_nullness$ " + " defaultValue);\n"); printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( @@ -261,9 +275,10 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers( WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$\n" - "$value_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "$value_type_pass_through_nullness$ " + "${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" - " $value_type$ defaultValue);\n"); + " $value_type_pass_through_nullness$ defaultValue);\n"); printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, @@ -606,9 +621,10 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "public $value_enum_type_pass_through_nullness$ " + "${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" - " $value_enum_type$ defaultValue) {\n" + " $value_enum_type_pass_through_nullness$ defaultValue) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $value_enum_type$> map =\n" " instance.get$capitalized_name$Map();\n" @@ -907,3 +923,5 @@ std::string ImmutableMapFieldLiteGenerator::GetBoxedType() const { } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_map_field_lite.h b/r5dev/thirdparty/protobuf/compiler/java/map_field_lite.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_map_field_lite.h rename to r5dev/thirdparty/protobuf/compiler/java/map_field_lite.h index b990fd2d..8ff6c935 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_map_field_lite.h +++ b/r5dev/thirdparty/protobuf/compiler/java/map_field_lite.h @@ -33,7 +33,7 @@ #include <cstdint> -#include <thirdparty/protobuf/compiler/java/java_field.h> +#include <thirdparty/protobuf/compiler/java/field.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_message.cc b/r5dev/thirdparty/protobuf/compiler/java/message.cc similarity index 88% rename from r5dev/thirdparty/protobuf/compiler/java/java_message.cc rename to r5dev/thirdparty/protobuf/compiler/java/message.cc index 24136ad0..3aa3655b 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_message.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/message.cc @@ -32,7 +32,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_message.h> +#include <thirdparty/protobuf/compiler/java/message.h> #include <algorithm> #include <cstdint> @@ -40,21 +40,25 @@ #include <memory> #include <vector> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_enum.h> -#include <thirdparty/protobuf/compiler/java/java_extension.h> -#include <thirdparty/protobuf/compiler/java/java_generator_factory.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_message_builder.h> -#include <thirdparty/protobuf/compiler/java/java_message_builder_lite.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/printer.h> +#include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/enum.h> +#include <thirdparty/protobuf/compiler/java/extension.h> +#include <thirdparty/protobuf/compiler/java/generator_factory.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/message_builder.h> +#include <thirdparty/protobuf/compiler/java/message_builder_lite.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> +#include <thirdparty/protobuf/descriptor.pb.h> + +// Must be last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -67,7 +71,7 @@ using internal::WireFormatLite; namespace { std::string MapValueImmutableClassdName(const Descriptor* descriptor, ClassNameResolver* name_resolver) { - const FieldDescriptor* value_field = descriptor->FindFieldByName("value"); + const FieldDescriptor* value_field = descriptor->map_value(); GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type()); return name_resolver->GetImmutableClassName(value_field->message_type()); } @@ -376,6 +380,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { "}\n" "\n"); + // TODO(b/248149118): Remove this superfluous override. printer->Print( "@java.lang.Override\n" "public final com.google.protobuf.UnknownFieldSet\n" @@ -383,10 +388,6 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { " return this.unknownFields;\n" "}\n"); - if (context_->HasGeneratedMethods(descriptor_)) { - GenerateParsingConstructor(printer); - } - GenerateDescriptorMethods(printer); // Nested types @@ -635,9 +636,9 @@ void ImmutableMessageGenerator::GenerateMessageSerializationMethods( } if (descriptor_->options().message_set_wire_format()) { - printer->Print("unknownFields.writeAsMessageSetTo(output);\n"); + printer->Print("getUnknownFields().writeAsMessageSetTo(output);\n"); } else { - printer->Print("unknownFields.writeTo(output);\n"); + printer->Print("getUnknownFields().writeTo(output);\n"); } printer->Outdent(); @@ -666,9 +667,10 @@ void ImmutableMessageGenerator::GenerateMessageSerializationMethods( } if (descriptor_->options().message_set_wire_format()) { - printer->Print("size += unknownFields.getSerializedSizeAsMessageSet();\n"); + printer->Print( + "size += getUnknownFields().getSerializedSizeAsMessageSet();\n"); } else { - printer->Print("size += unknownFields.getSerializedSize();\n"); + printer->Print("size += getUnknownFields().getSerializedSize();\n"); } printer->Print( @@ -1065,7 +1067,8 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode( // false for non-canonical ordering when running in LITE_RUNTIME but it's // the best we can do. printer->Print( - "if (!unknownFields.equals(other.unknownFields)) return false;\n"); + "if (!getUnknownFields().equals(other.getUnknownFields())) return " + "false;\n"); if (descriptor_->extension_range_count() > 0) { printer->Print( "if (!getExtensionFields().equals(other.getExtensionFields()))\n" @@ -1139,7 +1142,7 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode( printer->Print("hash = hashFields(hash, getExtensionFields());\n"); } - printer->Print("hash = (29 * hash) + unknownFields.hashCode();\n"); + printer->Print("hash = (29 * hash) + getUnknownFields().hashCode();\n"); printer->Print( "memoizedHashCode = hash;\n" "return hash;\n"); @@ -1164,186 +1167,33 @@ void ImmutableMessageGenerator::GenerateExtensionRegistrationCode( } } -// =================================================================== -void ImmutableMessageGenerator::GenerateParsingConstructor( - io::Printer* printer) { - std::unique_ptr<const FieldDescriptor*[]> sorted_fields( - SortFieldsByNumber(descriptor_)); - - printer->Print( - "private $classname$(\n" - " com.google.protobuf.CodedInputStream input,\n" - " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" - " throws com.google.protobuf.InvalidProtocolBufferException {\n", - "classname", descriptor_->name()); - printer->Indent(); - - // Initialize all fields to default. - printer->Print( - "this();\n" - "if (extensionRegistry == null) {\n" - " throw new java.lang.NullPointerException();\n" - "}\n"); - - // Use builder bits to track mutable repeated fields. - int totalBuilderBits = 0; - for (int i = 0; i < descriptor_->field_count(); i++) { - const ImmutableFieldGenerator& field = - field_generators_.get(descriptor_->field(i)); - totalBuilderBits += field.GetNumBitsForBuilder(); - } - int totalBuilderInts = (totalBuilderBits + 31) / 32; - for (int i = 0; i < totalBuilderInts; i++) { - printer->Print("int mutable_$bit_field_name$ = 0;\n", "bit_field_name", - GetBitFieldName(i)); - } - - printer->Print( - "com.google.protobuf.UnknownFieldSet.Builder unknownFields =\n" - " com.google.protobuf.UnknownFieldSet.newBuilder();\n"); - - printer->Print("try {\n"); - printer->Indent(); - - printer->Print( - "boolean done = false;\n" - "while (!done) {\n"); - printer->Indent(); - - printer->Print( - "int tag = input.readTag();\n" - "switch (tag) {\n"); - printer->Indent(); - - printer->Print( - "case 0:\n" // zero signals EOF / limit reached - " done = true;\n" - " break;\n"); - - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = sorted_fields[i]; - uint32_t tag = WireFormatLite::MakeTag( - field->number(), WireFormat::WireTypeForFieldType(field->type())); - - printer->Print("case $tag$: {\n", "tag", - StrCat(static_cast<int32_t>(tag))); - printer->Indent(); - - field_generators_.get(field).GenerateParsingCode(printer); - - printer->Outdent(); - printer->Print( - " break;\n" - "}\n"); - - if (field->is_packable()) { - // To make packed = true wire compatible, we generate parsing code from a - // packed version of this field regardless of field->options().packed(). - uint32_t packed_tag = WireFormatLite::MakeTag( - field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - printer->Print("case $tag$: {\n", "tag", - StrCat(static_cast<int32_t>(packed_tag))); - printer->Indent(); - - field_generators_.get(field).GenerateParsingCodeFromPacked(printer); - - printer->Outdent(); - printer->Print( - " break;\n" - "}\n"); - } - } - - printer->Print( - "default: {\n" - " if (!parseUnknownField(\n" - " input, unknownFields, extensionRegistry, tag)) {\n" - " done = true;\n" // it's an endgroup tag - " }\n" - " break;\n" - "}\n"); - - printer->Outdent(); - printer->Outdent(); - printer->Print( - " }\n" // switch (tag) - "}\n"); // while (!done) - - printer->Outdent(); - printer->Print( - "} catch (com.google.protobuf.InvalidProtocolBufferException e) {\n" - " throw e.setUnfinishedMessage(this);\n" - "} catch (java.io.IOException e) {\n" - " throw new com.google.protobuf.InvalidProtocolBufferException(\n" - " e).setUnfinishedMessage(this);\n" - "} finally {\n"); - printer->Indent(); - - // Make repeated field list immutable. - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = sorted_fields[i]; - field_generators_.get(field).GenerateParsingDoneCode(printer); - } - - // Make unknown fields immutable. - printer->Print("this.unknownFields = unknownFields.build();\n"); - - // Make extensions immutable. - printer->Print("makeExtensionsImmutable();\n"); - - printer->Outdent(); - printer->Outdent(); - printer->Print( - " }\n" // finally - "}\n"); -} - // =================================================================== void ImmutableMessageGenerator::GenerateParser(io::Printer* printer) { printer->Print( "$visibility$ static final com.google.protobuf.Parser<$classname$>\n" - " PARSER = new com.google.protobuf.AbstractParser<$classname$>() {\n", - "visibility", - ExposePublicParser(descriptor_->file()) ? "@java.lang.Deprecated public" - : "private", - "classname", descriptor_->name()); - printer->Indent(); - printer->Print( - "@java.lang.Override\n" - "public $classname$ parsePartialFrom(\n" - " com.google.protobuf.CodedInputStream input,\n" - " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" - " throws com.google.protobuf.InvalidProtocolBufferException {\n", - "classname", descriptor_->name()); - if (context_->HasGeneratedMethods(descriptor_)) { - printer->Print(" return new $classname$(input, extensionRegistry);\n", - "classname", descriptor_->name()); - } else { - // When parsing constructor isn't generated, use builder to parse - // messages. Note, will fallback to use reflection based mergeFieldFrom() - // in AbstractMessage.Builder. - printer->Indent(); - printer->Print( - "Builder builder = newBuilder();\n" - "try {\n" - " builder.mergeFrom(input, extensionRegistry);\n" - "} catch (com.google.protobuf.InvalidProtocolBufferException e) {\n" - " throw e.setUnfinishedMessage(builder.buildPartial());\n" - "} catch (java.io.IOException e) {\n" - " throw new com.google.protobuf.InvalidProtocolBufferException(\n" - " e.getMessage()).setUnfinishedMessage(\n" - " builder.buildPartial());\n" - "}\n" - "return builder.buildPartial();\n"); - printer->Outdent(); - } - printer->Print("}\n"); - printer->Outdent(); - printer->Print( + " PARSER = new com.google.protobuf.AbstractParser<$classname$>() {\n" + " @java.lang.Override\n" + " public $classname$ parsePartialFrom(\n" + " com.google.protobuf.CodedInputStream input,\n" + " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" + " throws com.google.protobuf.InvalidProtocolBufferException {\n" + " Builder builder = newBuilder();\n" + " try {\n" + " builder.mergeFrom(input, extensionRegistry);\n" + " } catch (com.google.protobuf.InvalidProtocolBufferException e) {\n" + " throw e.setUnfinishedMessage(builder.buildPartial());\n" + " } catch (com.google.protobuf.UninitializedMessageException e) {\n" + " throw " + "e.asInvalidProtocolBufferException().setUnfinishedMessage(builder." + "buildPartial());\n" + " } catch (java.io.IOException e) {\n" + " throw new com.google.protobuf.InvalidProtocolBufferException(e)\n" + " .setUnfinishedMessage(builder.buildPartial());\n" + " }\n" + " return builder.buildPartial();\n" + " }\n" "};\n" - "\n"); - - printer->Print( + "\n" "public static com.google.protobuf.Parser<$classname$> parser() {\n" " return PARSER;\n" "}\n" @@ -1353,6 +1203,9 @@ void ImmutableMessageGenerator::GenerateParser(io::Printer* printer) { " return PARSER;\n" "}\n" "\n", + "visibility", + ExposePublicParser(descriptor_->file()) ? "@java.lang.Deprecated public" + : "private", "classname", descriptor_->name()); } @@ -1455,7 +1308,7 @@ void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const { void ImmutableMessageGenerator::GenerateKotlinMembers( io::Printer* printer) const { printer->Print( - "@kotlin.jvm.JvmSynthetic\n" + "@kotlin.jvm.JvmName(\"-initialize$camelcase_name$\")\n" "public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> " "kotlin.Unit): " "$message$ " @@ -1486,7 +1339,7 @@ void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers( "kotlin.Unit): " "$message$ =\n" " $message_kt$.Dsl._create(this.toBuilder()).apply { block() " - "}._build()\n", + "}._build()\n\n", "message", name_resolver_->GetClassName(descriptor_, true), "message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_)); @@ -1495,6 +1348,24 @@ void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers( ImmutableMessageGenerator(descriptor_->nested_type(i), context_) .GenerateTopLevelKotlinMembers(printer); } + + GenerateKotlinOrNull(printer); +} + +void ImmutableMessageGenerator::GenerateKotlinOrNull(io::Printer* printer) const { + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* field = descriptor_->field(i); + if (field->has_presence() && GetJavaType(field) == JAVATYPE_MESSAGE) { + printer->Print( + "public val $full_classname$OrBuilder.$camelcase_name$OrNull: $full_name$?\n" + " get() = if (has$name$()) get$name$() else null\n\n", + "full_classname", name_resolver_->GetClassName(descriptor_, true), + "camelcase_name", context_->GetFieldGeneratorInfo(field)->name, + "full_name", + name_resolver_->GetImmutableClassName(field->message_type()), "name", + context_->GetFieldGeneratorInfo(field)->capitalized_name); + } + } } void ImmutableMessageGenerator::GenerateKotlinExtensions( @@ -1504,7 +1375,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@Suppress(\"UNCHECKED_CAST\")\n" "@kotlin.jvm.JvmSynthetic\n" - "public operator fun <T> get(extension: " + "public operator fun <T : kotlin.Any> get(extension: " "com.google.protobuf.ExtensionLite<$message$, T>): T {\n" " return if (extension.isRepeated) {\n" " get(extension as com.google.protobuf.ExtensionLite<$message$, " @@ -1520,7 +1391,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" "@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n" - "public operator fun <E> get(\n" + "public operator fun <E : kotlin.Any> get(\n" " extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n" "): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n" " return com.google.protobuf.kotlin.ExtensionList(extension, " @@ -1549,7 +1420,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" "@kotlin.PublishedApi\n" - "internal fun <T> setExtension(extension: " + "internal fun <T : kotlin.Any> setExtension(extension: " "com.google.protobuf.ExtensionLite<$message$, T>, " "value: T) {\n" " _builder.setExtension(extension, value)\n" @@ -1582,7 +1453,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" "@Suppress(\"NOTHING_TO_INLINE\")\n" - "public inline operator fun <T : com.google.protobuf.MessageLite> set(\n" + "inline operator fun <T : com.google.protobuf.MessageLite> set(\n" " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n" " value: T\n" ") {\n" @@ -1592,7 +1463,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "public fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "public fun <E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.add(value: E) {\n" " _builder.addExtension(this.extension, value)\n" "}\n\n", @@ -1601,7 +1472,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" "@Suppress(\"NOTHING_TO_INLINE\")\n" - "public inline operator fun <E> " + "public inline operator fun <E : kotlin.Any> " "com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.plusAssign" "(value: E) {\n" @@ -1611,7 +1482,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "public fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "public fun <E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.addAll(values: Iterable<E>) {\n" " for (value in values) {\n" " add(value)\n" @@ -1622,7 +1493,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" "@Suppress(\"NOTHING_TO_INLINE\")\n" - "public inline operator fun <E> " + "public inline operator fun <E : kotlin.Any> " "com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.plusAssign(values: " "Iterable<E>) {\n" @@ -1632,7 +1503,8 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "public operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "public operator fun <E : kotlin.Any> " + "com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.set(index: Int, value: " "E) {\n" " _builder.setExtension(this.extension, index, value)\n" @@ -1727,3 +1599,5 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) { } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_message.h b/r5dev/thirdparty/protobuf/compiler/java/message.h similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/java/java_message.h rename to r5dev/thirdparty/protobuf/compiler/java/message.h index d481932e..30b4abe7 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_message.h +++ b/r5dev/thirdparty/protobuf/compiler/java/message.h @@ -37,7 +37,8 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_field.h> + +#include <thirdparty/protobuf/compiler/java/field.h> namespace google { namespace protobuf { @@ -100,7 +101,7 @@ class MessageGenerator { class ImmutableMessageGenerator : public MessageGenerator { public: ImmutableMessageGenerator(const Descriptor* descriptor, Context* context); - virtual ~ImmutableMessageGenerator(); + ~ImmutableMessageGenerator() override; void Generate(io::Printer* printer) override; void GenerateInterface(io::Printer* printer) override; @@ -136,6 +137,7 @@ class ImmutableMessageGenerator : public MessageGenerator { void GenerateParsingConstructor(io::Printer* printer); void GenerateMutableCopy(io::Printer* printer); void GenerateKotlinExtensions(io::Printer* printer) const; + void GenerateKotlinOrNull(io::Printer* printer) const; void GenerateAnyMethods(io::Printer* printer); Context* context_; diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_message_builder.cc b/r5dev/thirdparty/protobuf/compiler/java/message_builder.cc similarity index 69% rename from r5dev/thirdparty/protobuf/compiler/java/java_message_builder.cc rename to r5dev/thirdparty/protobuf/compiler/java/message_builder.cc index 17aae152..32ad668d 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_message_builder.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/message_builder.cc @@ -32,36 +32,43 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_message_builder.h> +#include "google/protobuf/compiler/java/message_builder.h" #include <algorithm> #include <map> #include <memory> +#include <set> #include <vector> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_enum.h> -#include <thirdparty/protobuf/compiler/java/java_extension.h> -#include <thirdparty/protobuf/compiler/java/java_generator_factory.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/descriptor.pb.h> -#include <thirdparty/protobuf/io/coded_stream.h> -#include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/stubs/strutil.h> -#include <thirdparty/protobuf/stubs/substitute.h> +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/io/printer.h" +#include "google/protobuf/wire_format.h" +#include "google/protobuf/stubs/strutil.h" +#include "google/protobuf/stubs/substitute.h" +#include "google/protobuf/compiler/java/context.h" +#include "google/protobuf/compiler/java/doc_comment.h" +#include "google/protobuf/compiler/java/enum.h" +#include "google/protobuf/compiler/java/extension.h" +#include "google/protobuf/compiler/java/generator_factory.h" +#include "google/protobuf/compiler/java/helpers.h" +#include "google/protobuf/compiler/java/name_resolver.h" +#include "google/protobuf/descriptor.pb.h" + +// Must be last. +#include "google/protobuf/port_def.inc" namespace google { namespace protobuf { namespace compiler { namespace java { +using internal::WireFormat; +using internal::WireFormatLite; + namespace { std::string MapValueImmutableClassdName(const Descriptor* descriptor, ClassNameResolver* name_resolver) { - const FieldDescriptor* value_field = descriptor->FindFieldByName("value"); + const FieldDescriptor* value_field = descriptor->map_value(); GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type()); return name_resolver->GetImmutableClassName(value_field->message_type()); } @@ -139,12 +146,11 @@ void MessageBuilderGenerator::Generate(io::Printer* printer) { "\n" "public Builder clear$oneof_capitalized_name$() {\n" " $oneof_name$Case_ = 0;\n" - " $oneof_name$_ = null;\n"); - printer->Print(" onChanged();\n"); - printer->Print( - " return this;\n" - "}\n" - "\n"); + " $oneof_name$_ = null;\n" + " onChanged();\n" + " return this;\n" + "}\n" + "\n"); } // Integers for bit fields. @@ -285,43 +291,63 @@ void MessageBuilderGenerator::GenerateDescriptorMethods(io::Printer* printer) { void MessageBuilderGenerator::GenerateCommonBuilderMethods( io::Printer* printer) { + // Decide if we really need to have the "maybeForceBuilderInitialization()" + // method. + // TODO(b/249158148): Remove the need for this entirely + bool need_maybe_force_builder_init = false; + for (int i = 0; i < descriptor_->field_count(); i++) { + if (descriptor_->field(i)->message_type() != nullptr && + !IsRealOneof(descriptor_->field(i)) && + HasHasbit(descriptor_->field(i))) { + need_maybe_force_builder_init = true; + break; + } + } + + const char* force_builder_init = need_maybe_force_builder_init + ? " maybeForceBuilderInitialization();" + : ""; + printer->Print( "// Construct using $classname$.newBuilder()\n" "private Builder() {\n" - " maybeForceBuilderInitialization();\n" + "$force_builder_init$\n" "}\n" "\n", - "classname", name_resolver_->GetImmutableClassName(descriptor_)); + "classname", name_resolver_->GetImmutableClassName(descriptor_), + "force_builder_init", force_builder_init); printer->Print( "private Builder(\n" " com.google.protobuf.GeneratedMessage$ver$.BuilderParent parent) {\n" " super(parent);\n" - " maybeForceBuilderInitialization();\n" + "$force_builder_init$\n" "}\n", "classname", name_resolver_->GetImmutableClassName(descriptor_), "ver", - GeneratedCodeVersionSuffix()); + GeneratedCodeVersionSuffix(), "force_builder_init", force_builder_init); - printer->Print( - "private void maybeForceBuilderInitialization() {\n" - " if (com.google.protobuf.GeneratedMessage$ver$\n" - " .alwaysUseFieldBuilders) {\n", - "ver", GeneratedCodeVersionSuffix()); + if (need_maybe_force_builder_init) { + printer->Print( + "private void maybeForceBuilderInitialization() {\n" + " if (com.google.protobuf.GeneratedMessage$ver$\n" + " .alwaysUseFieldBuilders) {\n", + "ver", GeneratedCodeVersionSuffix()); - printer->Indent(); - printer->Indent(); - for (int i = 0; i < descriptor_->field_count(); i++) { - if (!IsRealOneof(descriptor_->field(i))) { - field_generators_.get(descriptor_->field(i)) - .GenerateFieldBuilderInitializationCode(printer); + printer->Indent(); + printer->Indent(); + for (int i = 0; i < descriptor_->field_count(); i++) { + if (!IsRealOneof(descriptor_->field(i))) { + field_generators_.get(descriptor_->field(i)) + .GenerateFieldBuilderInitializationCode(printer); + } } - } - printer->Outdent(); - printer->Outdent(); + printer->Outdent(); + printer->Outdent(); - printer->Print( - " }\n" - "}\n"); + printer->Print( + " }\n" + "}\n"); + } printer->Print( "@java.lang.Override\n" @@ -329,12 +355,15 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods( " super.clear();\n"); printer->Indent(); + int totalBuilderInts = (descriptor_->field_count() + 31) / 32; + for (int i = 0; i < totalBuilderInts; i++) { + printer->Print("$bit_field_name$ = 0;\n", "bit_field_name", + GetBitFieldName(i)); + } for (int i = 0; i < descriptor_->field_count(); i++) { - if (!IsRealOneof(descriptor_->field(i))) { - field_generators_.get(descriptor_->field(i)) - .GenerateBuilderClearCode(printer); - } + field_generators_.get(descriptor_->field(i)) + .GenerateBuilderClearCode(printer); } for (auto oneof : oneofs_) { @@ -382,63 +411,7 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods( "\n", "classname", name_resolver_->GetImmutableClassName(descriptor_)); - printer->Print( - "@java.lang.Override\n" - "public $classname$ buildPartial() {\n" - " $classname$ result = new $classname$(this);\n", - "classname", name_resolver_->GetImmutableClassName(descriptor_)); - - printer->Indent(); - - int totalBuilderBits = 0; - int totalMessageBits = 0; - for (int i = 0; i < descriptor_->field_count(); i++) { - const ImmutableFieldGenerator& field = - field_generators_.get(descriptor_->field(i)); - totalBuilderBits += field.GetNumBitsForBuilder(); - totalMessageBits += field.GetNumBitsForMessage(); - } - int totalBuilderInts = (totalBuilderBits + 31) / 32; - int totalMessageInts = (totalMessageBits + 31) / 32; - - // Local vars for from and to bit fields to avoid accessing the builder and - // message over and over for these fields. Seems to provide a slight - // perforamance improvement in micro benchmark and this is also what proto1 - // code does. - for (int i = 0; i < totalBuilderInts; i++) { - printer->Print("int from_$bit_field_name$ = $bit_field_name$;\n", - "bit_field_name", GetBitFieldName(i)); - } - for (int i = 0; i < totalMessageInts; i++) { - printer->Print("int to_$bit_field_name$ = 0;\n", "bit_field_name", - GetBitFieldName(i)); - } - - // Output generation code for each field. - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)).GenerateBuildingCode(printer); - } - - // Copy the bit field results to the generated message - for (int i = 0; i < totalMessageInts; i++) { - printer->Print("result.$bit_field_name$ = to_$bit_field_name$;\n", - "bit_field_name", GetBitFieldName(i)); - } - - for (auto oneof : oneofs_) { - printer->Print("result.$oneof_name$Case_ = $oneof_name$Case_;\n", - "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name); - } - - printer->Outdent(); - - printer->Print(" onBuilt();\n"); - - printer->Print( - " return result;\n" - "}\n" - "\n", - "classname", name_resolver_->GetImmutableClassName(descriptor_)); + GenerateBuildPartial(printer); // Override methods declared in GeneratedMessage to return the concrete // generated type so callsites won't depend on GeneratedMessage. This @@ -575,7 +548,7 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods( printer->Print(" this.mergeExtensionFields(other);\n"); } - printer->Print(" this.mergeUnknownFields(other.unknownFields);\n"); + printer->Print(" this.mergeUnknownFields(other.getUnknownFields());\n"); printer->Print(" onChanged();\n"); @@ -586,6 +559,156 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods( } } +void MessageBuilderGenerator::GenerateBuildPartial(io::Printer* printer) { + printer->Print( + "@java.lang.Override\n" + "public $classname$ buildPartial() {\n" + " $classname$ result = new $classname$(this);\n", + "classname", name_resolver_->GetImmutableClassName(descriptor_)); + + printer->Indent(); + + // Handle the repeated fields first so that the "mutable bits" are cleared. + bool has_repeated_fields = false; + for (int i = 0; i < descriptor_->field_count(); ++i) { + if (descriptor_->field(i)->is_repeated() && + !IsMapField(descriptor_->field(i))) { + has_repeated_fields = true; + printer->Print("buildPartialRepeatedFields(result);\n"); + break; + } + } + + // One buildPartial#() per from_bit_field + int totalBuilderInts = (descriptor_->field_count() + 31) / 32; + if (totalBuilderInts > 0) { + for (int i = 0; i < totalBuilderInts; ++i) { + printer->Print( + "if ($bit_field_name$ != 0) { buildPartial$piece$(result); }\n", + "bit_field_name", GetBitFieldName(i), "piece", StrCat(i)); + } + } + + if (!oneofs_.empty()) { + printer->Print("buildPartialOneofs(result);\n"); + } + + printer->Outdent(); + printer->Print( + " onBuilt();\n" + " return result;\n" + "}\n" + "\n", + "classname", name_resolver_->GetImmutableClassName(descriptor_)); + + // Build Repeated Fields + if (has_repeated_fields) { + printer->Print( + "private void buildPartialRepeatedFields($classname$ result) {\n", + "classname", name_resolver_->GetImmutableClassName(descriptor_)); + printer->Indent(); + for (int i = 0; i < descriptor_->field_count(); ++i) { + if (descriptor_->field(i)->is_repeated() && + !IsMapField(descriptor_->field(i))) { + const ImmutableFieldGenerator& field = + field_generators_.get(descriptor_->field(i)); + field.GenerateBuildingCode(printer); + } + } + printer->Outdent(); + printer->Print("}\n\n"); + } + + // Build non-oneof fields + int start_field = 0; + for (int i = 0; i < totalBuilderInts; i++) { + start_field = GenerateBuildPartialPiece(printer, i, start_field); + } + + // Build Oneofs + if (!oneofs_.empty()) { + printer->Print("private void buildPartialOneofs($classname$ result) {\n", + "classname", + name_resolver_->GetImmutableClassName(descriptor_)); + printer->Indent(); + for (auto oneof : oneofs_) { + printer->Print( + "result.$oneof_name$Case_ = $oneof_name$Case_;\n" + "result.$oneof_name$_ = this.$oneof_name$_;\n", + "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name); + for (int i = 0; i < oneof->field_count(); ++i) { + if (oneof->field(i)->message_type() != nullptr) { + const ImmutableFieldGenerator& field = + field_generators_.get(oneof->field(i)); + field.GenerateBuildingCode(printer); + } + } + } + printer->Outdent(); + printer->Print("}\n\n"); + } +} + +int MessageBuilderGenerator::GenerateBuildPartialPiece(io::Printer* printer, + int piece, + int first_field) { + printer->Print( + "private void buildPartial$piece$($classname$ result) {\n" + " int from_$bit_field_name$ = $bit_field_name$;\n", + "classname", name_resolver_->GetImmutableClassName(descriptor_), "piece", + StrCat(piece), "bit_field_name", GetBitFieldName(piece)); + printer->Indent(); + std::set<int> declared_to_bitfields; + + int bit = 0; + int next = first_field; + for (; bit < 32 && next < descriptor_->field_count(); ++next) { + const ImmutableFieldGenerator& field = + field_generators_.get(descriptor_->field(next)); + bit += field.GetNumBitsForBuilder(); + + // Skip oneof fields that are handled separately + if (IsRealOneof(descriptor_->field(next))) { + continue; + } + + // Skip repeated fields because they are currently handled + // in separate buildPartial sub-methods. + if (descriptor_->field(next)->is_repeated() && + !IsMapField(descriptor_->field(next))) { + continue; + } + // Skip fields without presence bits in the builder + if (field.GetNumBitsForBuilder() == 0) { + continue; + } + + // Track message bits if necessary + if (field.GetNumBitsForMessage() > 0) { + int to_bitfield = field.GetMessageBitIndex() / 32; + if (declared_to_bitfields.count(to_bitfield) == 0) { + printer->Print("int to_$bit_field_name$ = 0;\n", "bit_field_name", + GetBitFieldName(to_bitfield)); + declared_to_bitfields.insert(to_bitfield); + } + } + + // Copy the field from the builder to the message + field.GenerateBuildingCode(printer); + } + + // Copy the bit field results to the generated message + for (int to_bitfield : declared_to_bitfields) { + printer->Print("result.$bit_field_name$ |= to_$bit_field_name$;\n", + "bit_field_name", GetBitFieldName(to_bitfield)); + } + + printer->Outdent(); + printer->Print("}\n\n"); + + return next; +} + // =================================================================== void MessageBuilderGenerator::GenerateBuilderParsingMethods( @@ -596,20 +719,92 @@ void MessageBuilderGenerator::GenerateBuilderParsingMethods( " com.google.protobuf.CodedInputStream input,\n" " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" " throws java.io.IOException {\n" - " $classname$ parsedMessage = null;\n" + " if (extensionRegistry == null) {\n" + " throw new java.lang.NullPointerException();\n" + " }\n" " try {\n" - " parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);\n" + " boolean done = false;\n" + " while (!done) {\n" + " int tag = input.readTag();\n" + " switch (tag) {\n" + " case 0:\n" // zero signals EOF / limit reached + " done = true;\n" + " break;\n"); + printer->Indent(); // method + printer->Indent(); // try + printer->Indent(); // while + printer->Indent(); // switch + GenerateBuilderFieldParsingCases(printer); + printer->Outdent(); // switch + printer->Outdent(); // while + printer->Outdent(); // try + printer->Outdent(); // method + printer->Print( + " default: {\n" + " if (!super.parseUnknownField(input, extensionRegistry, tag)) " + "{\n" + " done = true; // was an endgroup tag\n" + " }\n" + " break;\n" + " } // default:\n" + " } // switch (tag)\n" + " } // while (!done)\n" " } catch (com.google.protobuf.InvalidProtocolBufferException e) {\n" - " parsedMessage = ($classname$) e.getUnfinishedMessage();\n" " throw e.unwrapIOException();\n" " } finally {\n" - " if (parsedMessage != null) {\n" - " mergeFrom(parsedMessage);\n" - " }\n" - " }\n" + " onChanged();\n" + " } // finally\n" " return this;\n" - "}\n", - "classname", name_resolver_->GetImmutableClassName(descriptor_)); + "}\n"); +} + +void MessageBuilderGenerator::GenerateBuilderFieldParsingCases( + io::Printer* printer) { + std::unique_ptr<const FieldDescriptor*[]> sorted_fields( + SortFieldsByNumber(descriptor_)); + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* field = sorted_fields[i]; + GenerateBuilderFieldParsingCase(printer, field); + if (field->is_packable()) { + GenerateBuilderPackedFieldParsingCase(printer, field); + } + } +} + +void MessageBuilderGenerator::GenerateBuilderFieldParsingCase( + io::Printer* printer, const FieldDescriptor* field) { + uint32_t tag = WireFormatLite::MakeTag( + field->number(), WireFormat::WireTypeForFieldType(field->type())); + std::string tagString = StrCat(static_cast<int32_t>(tag)); + printer->Print("case $tag$: {\n", "tag", tagString); + printer->Indent(); + + field_generators_.get(field).GenerateBuilderParsingCode(printer); + + printer->Outdent(); + printer->Print( + " break;\n" + "} // case $tag$\n", + "tag", tagString); +} + +void MessageBuilderGenerator::GenerateBuilderPackedFieldParsingCase( + io::Printer* printer, const FieldDescriptor* field) { + // To make packed = true wire compatible, we generate parsing code from a + // packed version of this field regardless of field->options().packed(). + uint32_t tag = WireFormatLite::MakeTag( + field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED); + std::string tagString = StrCat(static_cast<int32_t>(tag)); + printer->Print("case $tag$: {\n", "tag", tagString); + printer->Indent(); + + field_generators_.get(field).GenerateBuilderParsingCodeFromPacked(printer); + + printer->Outdent(); + printer->Print( + " break;\n" + "} // case $tag$\n", + "tag", tagString); } // =================================================================== @@ -710,3 +905,5 @@ void MessageBuilderGenerator::GenerateIsInitialized(io::Printer* printer) { } // namespace compiler } // namespace protobuf } // namespace google + +#include "google/protobuf/port_undef.inc" diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_message_builder.h b/r5dev/thirdparty/protobuf/compiler/java/message_builder.h similarity index 82% rename from r5dev/thirdparty/protobuf/compiler/java/java_message_builder.h rename to r5dev/thirdparty/protobuf/compiler/java/message_builder.h index 259a4904..7ada222a 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_message_builder.h +++ b/r5dev/thirdparty/protobuf/compiler/java/message_builder.h @@ -37,7 +37,8 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_field.h> + +#include <thirdparty/protobuf/compiler/java/field.h> namespace google { namespace protobuf { @@ -68,8 +69,18 @@ class MessageBuilderGenerator { private: void GenerateCommonBuilderMethods(io::Printer* printer); + void GenerateBuildPartial(io::Printer* printer); + int GenerateBuildPartialPiece(io::Printer* printer, int piece, + int first_field); + int GenerateBuildPartialPieceWithoutPresence(io::Printer* printer, int piece, + int first_field); void GenerateDescriptorMethods(io::Printer* printer); void GenerateBuilderParsingMethods(io::Printer* printer); + void GenerateBuilderFieldParsingCases(io::Printer* printer); + void GenerateBuilderFieldParsingCase(io::Printer* printer, + const FieldDescriptor* field); + void GenerateBuilderPackedFieldParsingCase(io::Printer* printer, + const FieldDescriptor* field); void GenerateIsInitialized(io::Printer* printer); const Descriptor* descriptor_; diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_message_builder_lite.cc b/r5dev/thirdparty/protobuf/compiler/java/message_builder_lite.cc similarity index 90% rename from r5dev/thirdparty/protobuf/compiler/java/java_message_builder_lite.cc rename to r5dev/thirdparty/protobuf/compiler/java/message_builder_lite.cc index 5b74b464..d422499d 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_message_builder_lite.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/message_builder_lite.cc @@ -32,26 +32,29 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_message_builder_lite.h> +#include <thirdparty/protobuf/compiler/java/message_builder_lite.h> #include <algorithm> #include <map> #include <memory> #include <vector> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_enum.h> -#include <thirdparty/protobuf/compiler/java/java_extension.h> -#include <thirdparty/protobuf/compiler/java/java_generator_factory.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/enum.h> +#include <thirdparty/protobuf/compiler/java/extension.h> +#include <thirdparty/protobuf/compiler/java/generator_factory.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> +#include <thirdparty/protobuf/descriptor.pb.h> + +// Must be last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -149,3 +152,5 @@ void MessageBuilderLiteGenerator::GenerateCommonBuilderMethods( } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_message_builder_lite.h b/r5dev/thirdparty/protobuf/compiler/java/message_builder_lite.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_message_builder_lite.h rename to r5dev/thirdparty/protobuf/compiler/java/message_builder_lite.h index 70368f50..a144e8a3 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_message_builder_lite.h +++ b/r5dev/thirdparty/protobuf/compiler/java/message_builder_lite.h @@ -37,7 +37,8 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_field.h> + +#include <thirdparty/protobuf/compiler/java/field.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_message_field.cc b/r5dev/thirdparty/protobuf/compiler/java/message_field.cc similarity index 82% rename from r5dev/thirdparty/protobuf/compiler/java/java_message_field.cc rename to r5dev/thirdparty/protobuf/compiler/java/message_field.cc index de8555de..5093be4b 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_message_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/message_field.cc @@ -32,17 +32,21 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include "google/protobuf/compiler/java/message_field.h" + #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_message_field.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/stubs/strutil.h> +#include "google/protobuf/io/printer.h" +#include "google/protobuf/wire_format.h" +#include "google/protobuf/stubs/strutil.h" +#include "google/protobuf/compiler/java/context.h" +#include "google/protobuf/compiler/java/doc_comment.h" +#include "google/protobuf/compiler/java/helpers.h" +#include "google/protobuf/compiler/java/name_resolver.h" + +// Must be last. +#include "google/protobuf/port_def.inc" namespace google { namespace protobuf { @@ -52,10 +56,11 @@ namespace java { namespace { -void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, - int builderBitIndex, const FieldGeneratorInfo* info, - ClassNameResolver* name_resolver, - std::map<std::string, std::string>* variables) { +void SetMessageVariables( + const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, + const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, + std::map<std::string, std::string>* variables, + Context* context) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["type"] = @@ -70,11 +75,12 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, // by the proto compiler (*variables)["deprecation"] = descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; - (*variables)["kt_deprecation"] = - descriptor->options().deprecated() - ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] + - " is deprecated\") " - : ""; + variables->insert( + {"kt_deprecation", + descriptor->options().deprecated() + ? StrCat("@kotlin.Deprecated(message = \"Field ", + (*variables)["name"], " is deprecated\") ") + : ""}); (*variables)["on_changed"] = "onChanged();"; (*variables)["ver"] = GeneratedCodeVersionSuffix(); (*variables)["get_parser"] = @@ -84,24 +90,16 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, if (HasHasbit(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); - (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); // Note that these have a trailing ";". - (*variables)["set_has_field_bit_message"] = - GenerateSetBit(messageBitIndex) + ";"; - (*variables)["set_has_field_bit_builder"] = - GenerateSetBit(builderBitIndex) + ";"; - (*variables)["clear_has_field_bit_builder"] = - GenerateClearBit(builderBitIndex) + ";"; + (*variables)["set_has_field_bit_to_local"] = + GenerateSetBitToLocal(messageBitIndex); (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex); } else { - (*variables)["set_has_field_bit_message"] = ""; - (*variables)["set_has_field_bit_builder"] = ""; - (*variables)["clear_has_field_bit_builder"] = ""; - - (*variables)["is_field_present_message"] = - (*variables)["name"] + "_ != null"; + (*variables)["set_has_field_bit_to_local"] = ""; + variables->insert({"is_field_present_message", + StrCat((*variables)["name"], "_ != null")}); } // For repeated builders, one bit is used for whether the array is immutable. @@ -109,17 +107,13 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex); (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex); - // For repeated fields, one bit is used for whether the array is immutable - // in the parsing constructor. - (*variables)["get_mutable_bit_parser"] = - GenerateGetBitMutableLocal(builderBitIndex); - (*variables)["set_mutable_bit_parser"] = - GenerateSetBitMutableLocal(builderBitIndex); - + (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); + (*variables)["set_has_field_bit_builder"] = + GenerateSetBit(builderBitIndex) + ";"; + (*variables)["clear_has_field_bit_builder"] = + GenerateClearBit(builderBitIndex) + ";"; (*variables)["get_has_field_bit_from_local"] = GenerateGetBitFromLocal(builderBitIndex); - (*variables)["set_has_field_bit_to_local"] = - GenerateSetBitToLocal(messageBitIndex); } } // namespace @@ -129,21 +123,31 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, ImmutableMessageFieldGenerator::ImmutableMessageFieldGenerator( const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context) - : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) { + : descriptor_(descriptor), + message_bit_index_(messageBitIndex), + builder_bit_index_(builderBitIndex), + name_resolver_(context->GetNameResolver()), + context_(context) { SetMessageVariables(descriptor, messageBitIndex, builderBitIndex, context->GetFieldGeneratorInfo(descriptor), - name_resolver_, &variables_); + name_resolver_, &variables_, context); } ImmutableMessageFieldGenerator::~ImmutableMessageFieldGenerator() {} +int ImmutableMessageFieldGenerator::GetMessageBitIndex() const { + return message_bit_index_; +} + +int ImmutableMessageFieldGenerator::GetBuilderBitIndex() const { + return builder_bit_index_; +} + int ImmutableMessageFieldGenerator::GetNumBitsForMessage() const { return HasHasbit(descriptor_) ? 1 : 0; } -int ImmutableMessageFieldGenerator::GetNumBitsForBuilder() const { - return GetNumBitsForMessage(); -} +int ImmutableMessageFieldGenerator::GetNumBitsForBuilder() const { return 1; } void ImmutableMessageFieldGenerator::GenerateInterfaceMembers( io::Printer* printer) const { @@ -176,24 +180,6 @@ void ImmutableMessageFieldGenerator::GenerateMembers( " return $get_has_field_bit_message$;\n" "}\n"); printer->Annotate("{", "}", descriptor_); - WriteFieldAccessorDocComment(printer, descriptor_, GETTER); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" - " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - - WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$public $type$OrBuilder " - "${$get$capitalized_name$OrBuilder$}$() {\n" - " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); } else { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( @@ -203,24 +189,25 @@ void ImmutableMessageFieldGenerator::GenerateMembers( " return $name$_ != null;\n" "}\n"); printer->Annotate("{", "}", descriptor_); - WriteFieldAccessorDocComment(printer, descriptor_, GETTER); - printer->Print( - variables_, - "@java.lang.Override\n" - "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" - " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "@java.lang.Override\n" - "$deprecation$public $type$OrBuilder " - "${$get$capitalized_name$OrBuilder$}$() {\n" - " return get$capitalized_name$();\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); } + WriteFieldAccessorDocComment(printer, descriptor_, GETTER); + printer->Print( + variables_, + "@java.lang.Override\n" + "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" + " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); + + WriteFieldDocComment(printer, descriptor_); + printer->Print( + variables_, + "@java.lang.Override\n" + "$deprecation$public $type$OrBuilder " + "${$get$capitalized_name$OrBuilder$}$() {\n" + " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); } void ImmutableMessageFieldGenerator::PrintNestedBuilderCondition( @@ -258,9 +245,6 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( // When using nested-builders, the code initially works just like the // non-nested builder case. It only creates a nested builder lazily on // demand and then forever delegates to it after creation. - - bool has_hasbit = HasHasbit(descriptor_); - printer->Print(variables_, "private $type$ $name$_;\n"); printer->Print(variables_, @@ -275,21 +259,11 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( // boolean hasField() WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - if (has_hasbit) { - printer->Print( - variables_, - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $get_has_field_bit_builder$;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } else { - printer->Print( - variables_, - "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" - " return $name$Builder_ != null || $name$_ != null;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); - } + printer->Print(variables_, + "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" + " return $get_has_field_bit_builder$;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); // Field getField() WriteFieldAccessorDocComment(printer, descriptor_, GETTER); @@ -307,12 +281,12 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( "if (value == null) {\n" " throw new NullPointerException();\n" "}\n" - "$name$_ = value;\n" - "$on_changed$\n", + "$name$_ = value;\n", "$name$Builder_.setMessage(value);\n", "$set_has_field_bit_builder$\n" + "$on_changed$\n" "return this;\n"); // Field.Builder setField(Field.Builder builderForValue) @@ -322,58 +296,48 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " $type$.Builder builderForValue)", - "$name$_ = builderForValue.build();\n" - "$on_changed$\n", + "$name$_ = builderForValue.build();\n", "$name$Builder_.setMessage(builderForValue.build());\n", "$set_has_field_bit_builder$\n" + "$on_changed$\n" "return this;\n"); - // Field.Builder mergeField(Field value) + // Message.Builder mergeField(Field value) WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction( printer, "$deprecation$public Builder ${$merge$capitalized_name$$}$($type$ value)", - - has_hasbit - ? "if ($get_has_field_bit_builder$ &&\n" - " $name$_ != null &&\n" - " $name$_ != $type$.getDefaultInstance()) {\n" - " $name$_ =\n" - " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n" - "} else {\n" - " $name$_ = value;\n" - "}\n" - "$on_changed$\n" - : "if ($name$_ != null) {\n" - " $name$_ =\n" - " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n" - "} else {\n" - " $name$_ = value;\n" - "}\n" - "$on_changed$\n", + "if ($get_has_field_bit_builder$ &&\n" + " $name$_ != null &&\n" + " $name$_ != $type$.getDefaultInstance()) {\n" + " get$capitalized_name$Builder().mergeFrom(value);\n" + "} else {\n" + " $name$_ = value;\n" + "}\n", "$name$Builder_.mergeFrom(value);\n", "$set_has_field_bit_builder$\n" + "$on_changed$\n" "return this;\n"); - // Field.Builder clearField() + // Message.Builder clearField() WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction( - printer, "$deprecation$public Builder ${$clear$capitalized_name$$}$()", - - "$name$_ = null;\n" - "$on_changed$\n", - - has_hasbit ? "$name$Builder_.clear();\n" - : "$name$_ = null;\n" - "$name$Builder_ = null;\n", - - "$clear_has_field_bit_builder$\n" - "return this;\n"); + printer->Print(variables_, + "$deprecation$public Builder clear$capitalized_name$() {\n" + " $clear_has_field_bit_builder$\n" + " $name$_ = null;\n" + " if ($name$Builder_ != null) {\n" + " $name$Builder_.dispose();\n" + " $name$Builder_ = null;\n" + " }\n" + " $on_changed$\n" + " return this;\n" + "}\n"); + // Field.Builder getFieldBuilder() WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public $type$.Builder " @@ -383,6 +347,8 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( " return get$capitalized_name$FieldBuilder().getBuilder();\n" "}\n"); printer->Annotate("{", "}", descriptor_); + + // FieldOrBuilder getFieldOrBuilder() WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public $type$OrBuilder " @@ -395,6 +361,8 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( " }\n" "}\n"); printer->Annotate("{", "}", descriptor_); + + // SingleFieldBuilder getFieldFieldBuilder WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -438,13 +406,21 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers( "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" "}\n"); + + GenerateKotlinOrNull(printer); +} + +void ImmutableMessageFieldGenerator::GenerateKotlinOrNull(io::Printer* printer) const { + if (descriptor_->has_optional_keyword()) { + printer->Print(variables_, + "public val $classname$Kt.Dsl.$name$OrNull: $kt_type$?\n" + " get() = $kt_dsl_builder$.$name$OrNull\n"); + } } void ImmutableMessageFieldGenerator::GenerateFieldBuilderInitializationCode( io::Printer* printer) const { - if (HasHasbit(descriptor_)) { - printer->Print(variables_, "get$capitalized_name$FieldBuilder();\n"); - } + printer->Print(variables_, "get$capitalized_name$FieldBuilder();\n"); } void ImmutableMessageFieldGenerator::GenerateInitializationCode( @@ -452,17 +428,13 @@ void ImmutableMessageFieldGenerator::GenerateInitializationCode( void ImmutableMessageFieldGenerator::GenerateBuilderClearCode( io::Printer* printer) const { - if (HasHasbit(descriptor_)) { - PrintNestedBuilderCondition(printer, "$name$_ = null;\n", - - "$name$Builder_.clear();\n"); - printer->Print(variables_, "$clear_has_field_bit_builder$\n"); - } else { - PrintNestedBuilderCondition(printer, "$name$_ = null;\n", - - "$name$_ = null;\n" - "$name$Builder_ = null;\n"); - } + // No need to clear the has-bit since we clear the bitField ints all at once. + printer->Print(variables_, + "$name$_ = null;\n" + "if ($name$Builder_ != null) {\n" + " $name$Builder_.dispose();\n" + " $name$Builder_ = null;\n" + "}\n"); } void ImmutableMessageFieldGenerator::GenerateMergingCode( @@ -475,50 +447,32 @@ void ImmutableMessageFieldGenerator::GenerateMergingCode( void ImmutableMessageFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - if (HasHasbit(descriptor_)) { - printer->Print(variables_, "if ($get_has_field_bit_from_local$) {\n"); - printer->Indent(); - PrintNestedBuilderCondition(printer, "result.$name$_ = $name$_;\n", - "result.$name$_ = $name$Builder_.build();\n"); - printer->Outdent(); - printer->Print(variables_, - " $set_has_field_bit_to_local$;\n" - "}\n"); - } else { - PrintNestedBuilderCondition(printer, "result.$name$_ = $name$_;\n", - "result.$name$_ = $name$Builder_.build();\n"); + printer->Print(variables_, + "if ($get_has_field_bit_from_local$) {\n" + " result.$name$_ = $name$Builder_ == null\n" + " ? $name$_\n" + " : $name$Builder_.build();\n"); + if (GetNumBitsForMessage() > 0) { + printer->Print(variables_, " $set_has_field_bit_to_local$;\n"); } + printer->Print("}\n"); } -void ImmutableMessageFieldGenerator::GenerateParsingCode( +void ImmutableMessageFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { - printer->Print(variables_, - "$type$.Builder subBuilder = null;\n" - "if ($is_field_present_message$) {\n" - " subBuilder = $name$_.toBuilder();\n" - "}\n"); - if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) { printer->Print(variables_, - "$name$_ = input.readGroup($number$, $type$.$get_parser$,\n" - " extensionRegistry);\n"); + "input.readGroup($number$,\n" + " get$capitalized_name$FieldBuilder().getBuilder(),\n" + " extensionRegistry);\n" + "$set_has_field_bit_builder$\n"); } else { printer->Print(variables_, - "$name$_ = input.readMessage($type$.$get_parser$, " - "extensionRegistry);\n"); + "input.readMessage(\n" + " get$capitalized_name$FieldBuilder().getBuilder(),\n" + " extensionRegistry);\n" + "$set_has_field_bit_builder$\n"); } - - printer->Print(variables_, - "if (subBuilder != null) {\n" - " subBuilder.mergeFrom($name$_);\n" - " $name$_ = subBuilder.buildPartial();\n" - "}\n" - "$set_has_field_bit_message$\n"); -} - -void ImmutableMessageFieldGenerator::GenerateParsingDoneCode( - io::Printer* printer) const { - // noop for messages. } void ImmutableMessageFieldGenerator::GenerateSerializationCode( @@ -582,6 +536,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateMembers( " return $has_oneof_case_message$;\n" "}\n"); printer->Annotate("{", "}", descriptor_); + WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, "@java.lang.Override\n" @@ -698,8 +653,9 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers( "if ($has_oneof_case_message$) {\n" " $name$Builder_.mergeFrom(value);\n" - "}\n" - "$name$Builder_.setMessage(value);\n", + "} else {\n" + " $name$Builder_.setMessage(value);\n" + "}\n", "$set_oneof_case_message$;\n" "return this;\n"); @@ -764,24 +720,28 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers( " $oneof_name$_ = null;\n" " }\n" " $set_oneof_case_message$;\n" - " $on_changed$;\n" + " $on_changed$\n" " return $name$Builder_;\n" "}\n"); printer->Annotate("{", "}", descriptor_); } +void ImmutableMessageOneofFieldGenerator::GenerateBuilderClearCode( + io::Printer* printer) const { + // Make sure the builder gets cleared. + printer->Print(variables_, + "if ($name$Builder_ != null) {\n" + " $name$Builder_.clear();\n" + "}\n"); +} + void ImmutableMessageOneofFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - printer->Print(variables_, "if ($has_oneof_case_message$) {\n"); - printer->Indent(); - - PrintNestedBuilderCondition( - printer, "result.$oneof_name$_ = $oneof_name$_;\n", - - "result.$oneof_name$_ = $name$Builder_.build();\n"); - - printer->Outdent(); - printer->Print("}\n"); + printer->Print(variables_, + "if ($has_oneof_case_message$ &&\n" + " $name$Builder_ != null) {\n" + " result.$oneof_name$_ = $name$Builder_.build();\n" + "}\n"); } void ImmutableMessageOneofFieldGenerator::GenerateMergingCode( @@ -790,32 +750,21 @@ void ImmutableMessageOneofFieldGenerator::GenerateMergingCode( "merge$capitalized_name$(other.get$capitalized_name$());\n"); } -void ImmutableMessageOneofFieldGenerator::GenerateParsingCode( +void ImmutableMessageOneofFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { - printer->Print(variables_, - "$type$.Builder subBuilder = null;\n" - "if ($has_oneof_case_message$) {\n" - " subBuilder = (($type$) $oneof_name$_).toBuilder();\n" - "}\n"); - if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) { - printer->Print( - variables_, - "$oneof_name$_ = input.readGroup($number$, $type$.$get_parser$,\n" - " extensionRegistry);\n"); + printer->Print(variables_, + "input.readGroup($number$,\n" + " get$capitalized_name$FieldBuilder().getBuilder(),\n" + " extensionRegistry);\n" + "$set_oneof_case_message$;\n"); } else { - printer->Print( - variables_, - "$oneof_name$_ =\n" - " input.readMessage($type$.$get_parser$, extensionRegistry);\n"); + printer->Print(variables_, + "input.readMessage(\n" + " get$capitalized_name$FieldBuilder().getBuilder(),\n" + " extensionRegistry);\n" + "$set_oneof_case_message$;\n"); } - - printer->Print(variables_, - "if (subBuilder != null) {\n" - " subBuilder.mergeFrom(($type$) $oneof_name$_);\n" - " $oneof_name$_ = subBuilder.buildPartial();\n" - "}\n"); - printer->Print(variables_, "$set_oneof_case_message$;\n"); } void ImmutableMessageOneofFieldGenerator::GenerateSerializationCode( @@ -842,11 +791,8 @@ void ImmutableMessageOneofFieldGenerator::GenerateSerializedSizeCode( RepeatedImmutableMessageFieldGenerator::RepeatedImmutableMessageFieldGenerator( const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context) - : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) { - SetMessageVariables(descriptor, messageBitIndex, builderBitIndex, - context->GetFieldGeneratorInfo(descriptor), - name_resolver_, &variables_); -} + : ImmutableMessageFieldGenerator(descriptor, messageBitIndex, + builderBitIndex, context) {} RepeatedImmutableMessageFieldGenerator:: ~RepeatedImmutableMessageFieldGenerator() {} @@ -889,7 +835,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateInterfaceMembers( void RepeatedImmutableMessageFieldGenerator::GenerateMembers( io::Printer* printer) const { - printer->Print(variables_, "private java.util.List<$type$> $name$_;\n"); + printer->Print(variables_, "@SuppressWarnings(\"serial\")\n" + "private java.util.List<$type$> $name$_;\n"); PrintExtraFieldInfo(variables_, printer); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, @@ -899,6 +846,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( " return $name$_;\n" // note: unmodifiable list "}\n"); printer->Annotate("{", "}", descriptor_); + + // List<FieldOrBuilder> getFieldOrBuilderList() WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -908,6 +857,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( " return $name$_;\n" "}\n"); printer->Annotate("{", "}", descriptor_); + + // int getFieldCount() WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -916,6 +867,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( " return $name$_.size();\n" "}\n"); printer->Annotate("{", "}", descriptor_); + + // Field getField(int index) WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -924,6 +877,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( " return $name$_.get(index);\n" "}\n"); printer->Annotate("{", "}", descriptor_); + + // FieldOrBuilder getFieldOrBuilder(int index) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" @@ -1149,7 +1104,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( "return this;\n"); - // Builder clearAllRepeatedField() + // Builder clearRepeatedField() WriteFieldDocComment(printer, descriptor_); PrintNestedBuilderFunction( printer, "$deprecation$public Builder ${$clear$capitalized_name$$}$()", @@ -1176,6 +1131,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( "return this;\n"); + // Field.Builder getRepeatedFieldBuilder(int index) WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -1185,6 +1141,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( "}\n"); printer->Annotate("{", "}", descriptor_); + // FieldOrBuilder getRepeatedFieldOrBuilder(int index) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public $type$OrBuilder " @@ -1198,6 +1155,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( "}\n"); printer->Annotate("{", "}", descriptor_); + // List<FieldOrBuilder> getRepeatedFieldOrBuilderList() WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -1211,6 +1169,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( "}\n"); printer->Annotate("{", "}", descriptor_); + // Field.Builder addRepeatedField() WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public $type$.Builder " @@ -1219,6 +1178,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( " $type$.getDefaultInstance());\n" "}\n"); printer->Annotate("{", "}", descriptor_); + + // Field.Builder addRepeatedFieldBuilder(int index) WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -1228,6 +1189,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( " index, $type$.getDefaultInstance());\n" "}\n"); printer->Annotate("{", "}", descriptor_); + + // List<Field.Builder> getRepeatedFieldBuilderList() WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -1266,10 +1229,12 @@ void RepeatedImmutableMessageFieldGenerator::GenerateInitializationCode( void RepeatedImmutableMessageFieldGenerator::GenerateBuilderClearCode( io::Printer* printer) const { PrintNestedBuilderCondition(printer, - "$name$_ = java.util.Collections.emptyList();\n" - "$clear_mutable_bit_builder$;\n", + "$name$_ = java.util.Collections.emptyList();\n", + "$name$_ = null;\n" "$name$Builder_.clear();\n"); + + printer->Print(variables_, "$clear_mutable_bit_builder$;\n"); } void RepeatedImmutableMessageFieldGenerator::GenerateMergingCode( @@ -1324,34 +1289,25 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuildingCode( "result.$name$_ = $name$Builder_.build();\n"); } -void RepeatedImmutableMessageFieldGenerator::GenerateParsingCode( +void RepeatedImmutableMessageFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { - printer->Print(variables_, - "if (!$get_mutable_bit_parser$) {\n" - " $name$_ = new java.util.ArrayList<$type$>();\n" - " $set_mutable_bit_parser$;\n" - "}\n"); - if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) { - printer->Print( - variables_, - "$name$_.add(input.readGroup($number$, $type$.$get_parser$,\n" - " extensionRegistry));\n"); + printer->Print(variables_, + "$type$ m =\n" + " input.readGroup($number$,\n" + " $type$.$get_parser$,\n" + " extensionRegistry);\n"); } else { - printer->Print( - variables_, - "$name$_.add(\n" - " input.readMessage($type$.$get_parser$, extensionRegistry));\n"); + printer->Print(variables_, + "$type$ m =\n" + " input.readMessage(\n" + " $type$.$get_parser$,\n" + " extensionRegistry);\n"); } -} - -void RepeatedImmutableMessageFieldGenerator::GenerateParsingDoneCode( - io::Printer* printer) const { - printer->Print( - variables_, - "if ($get_mutable_bit_parser$) {\n" - " $name$_ = java.util.Collections.unmodifiableList($name$_);\n" - "}\n"); + PrintNestedBuilderCondition(printer, + "ensure$capitalized_name$IsMutable();\n" + "$name$_.add(m);\n", + "$name$Builder_.addMessage(m);\n"); } void RepeatedImmutableMessageFieldGenerator::GenerateSerializationCode( @@ -1426,7 +1382,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "add(value: $kt_type$) {\n" " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n" - "}"); + "}\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ false); @@ -1438,7 +1394,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(value: $kt_type$) {\n" " add(value)\n" - "}"); + "}\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER, /* builder */ false); @@ -1449,7 +1405,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n" " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n" - "}"); + "}\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER, /* builder */ false); @@ -1462,7 +1418,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n" " addAll(values)\n" - "}"); + "}\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER, /* builder */ false); @@ -1474,7 +1430,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "set(index: kotlin.Int, value: $kt_type$) {\n" " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n" - "}"); + "}\n"); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ false); @@ -1485,10 +1441,12 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "clear() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" - "}"); + "}\n\n"); } } // namespace java } // namespace compiler } // namespace protobuf } // namespace google + +#include "google/protobuf/port_undef.inc" diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_message_field.h b/r5dev/thirdparty/protobuf/compiler/java/message_field.h similarity index 76% rename from r5dev/thirdparty/protobuf/compiler/java/java_message_field.h rename to r5dev/thirdparty/protobuf/compiler/java/message_field.h index 93035291..f16062f0 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_message_field.h +++ b/r5dev/thirdparty/protobuf/compiler/java/message_field.h @@ -37,7 +37,8 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_field.h> + +#include "google/protobuf/compiler/java/field.h" namespace google { namespace protobuf { @@ -61,10 +62,16 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator { int messageBitIndex, int builderBitIndex, Context* context); - ~ImmutableMessageFieldGenerator(); + ImmutableMessageFieldGenerator(const ImmutableMessageFieldGenerator&) = + delete; + ImmutableMessageFieldGenerator& operator=( + const ImmutableMessageFieldGenerator&) = delete; + ~ImmutableMessageFieldGenerator() override; // implements ImmutableFieldGenerator // --------------------------------------- + int GetMessageBitIndex() const override; + int GetBuilderBitIndex() const override; int GetNumBitsForMessage() const override; int GetNumBitsForBuilder() const override; void GenerateInterfaceMembers(io::Printer* printer) const override; @@ -74,8 +81,7 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator { void GenerateBuilderClearCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; - void GenerateParsingDoneCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; void GenerateFieldBuilderInitializationCode( @@ -88,20 +94,23 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; + int message_bit_index_; + int builder_bit_index_; std::map<std::string, std::string> variables_; ClassNameResolver* name_resolver_; + Context* context_; - void PrintNestedBuilderCondition(io::Printer* printer, - const char* regular_case, - const char* nested_builder_case) const; - void PrintNestedBuilderFunction(io::Printer* printer, - const char* method_prototype, - const char* regular_case, - const char* nested_builder_case, - const char* trailing_code) const; + virtual void PrintNestedBuilderCondition( + io::Printer* printer, const char* regular_case, + const char* nested_builder_case) const; + virtual void PrintNestedBuilderFunction(io::Printer* printer, + const char* method_prototype, + const char* regular_case, + const char* nested_builder_case, + const char* trailing_code) const; private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldGenerator); + void GenerateKotlinOrNull(io::Printer* printer) const; }; class ImmutableMessageOneofFieldGenerator @@ -110,25 +119,32 @@ class ImmutableMessageOneofFieldGenerator ImmutableMessageOneofFieldGenerator(const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context); - ~ImmutableMessageOneofFieldGenerator(); + ImmutableMessageOneofFieldGenerator( + const ImmutableMessageOneofFieldGenerator&) = delete; + ImmutableMessageOneofFieldGenerator& operator=( + const ImmutableMessageOneofFieldGenerator&) = delete; + ~ImmutableMessageOneofFieldGenerator() override; void GenerateMembers(io::Printer* printer) const override; void GenerateBuilderMembers(io::Printer* printer) const override; + void GenerateBuilderClearCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageOneofFieldGenerator); }; -class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator { +class RepeatedImmutableMessageFieldGenerator + : public ImmutableMessageFieldGenerator { public: explicit RepeatedImmutableMessageFieldGenerator( const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context); + RepeatedImmutableMessageFieldGenerator( + const RepeatedImmutableMessageFieldGenerator&) = delete; + RepeatedImmutableMessageFieldGenerator& operator=( + const RepeatedImmutableMessageFieldGenerator&) = delete; ~RepeatedImmutableMessageFieldGenerator() override; // implements ImmutableFieldGenerator --------------------------------------- @@ -141,8 +157,7 @@ class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator { void GenerateBuilderClearCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; - void GenerateParsingDoneCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; void GenerateFieldBuilderInitializationCode( @@ -154,21 +169,14 @@ class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator { std::string GetBoxedType() const override; protected: - const FieldDescriptor* descriptor_; - std::map<std::string, std::string> variables_; - ClassNameResolver* name_resolver_; - - void PrintNestedBuilderCondition(io::Printer* printer, - const char* regular_case, - const char* nested_builder_case) const; + void PrintNestedBuilderCondition( + io::Printer* printer, const char* regular_case, + const char* nested_builder_case) const override; void PrintNestedBuilderFunction(io::Printer* printer, const char* method_prototype, const char* regular_case, const char* nested_builder_case, - const char* trailing_code) const; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableMessageFieldGenerator); + const char* trailing_code) const override; }; } // namespace java diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_message_field_lite.cc b/r5dev/thirdparty/protobuf/compiler/java/message_field_lite.cc similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/java/java_message_field_lite.cc rename to r5dev/thirdparty/protobuf/compiler/java/message_field_lite.cc index 4061f562..d226d54c 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_message_field_lite.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/message_field_lite.cc @@ -32,19 +32,22 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_message_field_lite.h> +#include <thirdparty/protobuf/compiler/java/message_field_lite.h> #include <cstdint> #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> + +// Must be last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -308,6 +311,15 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n" " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n" "}\n"); + GenerateKotlinOrNull(printer); +} + +void ImmutableMessageFieldLiteGenerator::GenerateKotlinOrNull(io::Printer* printer) const { + if (descriptor_->has_optional_keyword()) { + printer->Print(variables_, + "public val $classname$Kt.Dsl.$name$OrNull: $kt_type$?\n" + " get() = $kt_dsl_builder$.$name$OrNull\n"); + } } void ImmutableMessageFieldLiteGenerator::GenerateFieldInfo( @@ -816,7 +828,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "add(value: $kt_type$) {\n" " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n" - "}"); + "}\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ false); @@ -828,7 +840,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(value: $kt_type$) {\n" " add(value)\n" - "}"); + "}\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER, /* builder */ false); @@ -839,7 +851,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n" " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n" - "}"); + "}\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER, /* builder */ false); @@ -852,7 +864,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n" " addAll(values)\n" - "}"); + "}\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER, /* builder */ false); @@ -864,7 +876,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "set(index: kotlin.Int, value: $kt_type$) {\n" " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n" - "}"); + "}\n"); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ false); @@ -875,10 +887,12 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>." "clear() {\n" " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n" - "}"); + "}\n"); } } // namespace java } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_message_field_lite.h b/r5dev/thirdparty/protobuf/compiler/java/message_field_lite.h similarity index 96% rename from r5dev/thirdparty/protobuf/compiler/java/java_message_field_lite.h rename to r5dev/thirdparty/protobuf/compiler/java/message_field_lite.h index ffb5a308..e7fdb28b 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_message_field_lite.h +++ b/r5dev/thirdparty/protobuf/compiler/java/message_field_lite.h @@ -39,7 +39,7 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_field.h> +#include <thirdparty/protobuf/compiler/java/field.h> namespace google { namespace protobuf { @@ -62,7 +62,7 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator { explicit ImmutableMessageFieldLiteGenerator(const FieldDescriptor* descriptor, int messageBitIndex, Context* context); - ~ImmutableMessageFieldLiteGenerator(); + ~ImmutableMessageFieldLiteGenerator() override; // implements ImmutableFieldLiteGenerator // ------------------------------------ @@ -85,6 +85,7 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator { private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldLiteGenerator); + void GenerateKotlinOrNull(io::Printer* printer) const; }; class ImmutableMessageOneofFieldLiteGenerator @@ -93,7 +94,7 @@ class ImmutableMessageOneofFieldLiteGenerator ImmutableMessageOneofFieldLiteGenerator(const FieldDescriptor* descriptor, int messageBitIndex, Context* context); - ~ImmutableMessageOneofFieldLiteGenerator(); + ~ImmutableMessageOneofFieldLiteGenerator() override; void GenerateMembers(io::Printer* printer) const override; void GenerateBuilderMembers(io::Printer* printer) const override; diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_message_lite.cc b/r5dev/thirdparty/protobuf/compiler/java/message_lite.cc similarity index 94% rename from r5dev/thirdparty/protobuf/compiler/java/java_message_lite.cc rename to r5dev/thirdparty/protobuf/compiler/java/message_lite.cc index a44f59be..c02d74fa 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_message_lite.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/message_lite.cc @@ -32,7 +32,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_message_lite.h> +#include <thirdparty/protobuf/compiler/java/message_lite.h> #include <algorithm> #include <cstdint> @@ -40,21 +40,24 @@ #include <memory> #include <vector> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_enum_lite.h> -#include <thirdparty/protobuf/compiler/java/java_extension_lite.h> -#include <thirdparty/protobuf/compiler/java/java_generator_factory.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_message_builder.h> -#include <thirdparty/protobuf/compiler/java/java_message_builder_lite.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/enum_lite.h> +#include <thirdparty/protobuf/compiler/java/extension_lite.h> +#include <thirdparty/protobuf/compiler/java/generator_factory.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/message_builder.h> +#include <thirdparty/protobuf/compiler/java/message_builder_lite.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> +#include <thirdparty/protobuf/descriptor.pb.h> + +// Must be last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -779,7 +782,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl( void ImmutableMessageLiteGenerator::GenerateKotlinMembers( io::Printer* printer) const { printer->Print( - "@kotlin.jvm.JvmSynthetic\n" + "@kotlin.jvm.JvmName(\"-initialize$camelcase_name$\")\n" "public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> " "kotlin.Unit): " "$message$ =\n" @@ -808,7 +811,7 @@ void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers( "kotlin.Unit): " "$message$ =\n" " $message_kt$.Dsl._create(this.toBuilder()).apply { block() " - "}._build()\n", + "}._build()\n\n", "message", name_resolver_->GetClassName(descriptor_, true), "message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_)); @@ -817,6 +820,26 @@ void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers( ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_) .GenerateTopLevelKotlinMembers(printer); } + + GenerateKotlinOrNull(printer); +} + +void ImmutableMessageLiteGenerator::GenerateKotlinOrNull(io::Printer* printer) const { + // Generate getFieldOrNull getters for all optional message fields. + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* field = descriptor_->field(i); + if (field->has_presence() && GetJavaType(field) == JAVATYPE_MESSAGE) { + printer->Print( + "public val $full_classname$OrBuilder.$camelcase_name$OrNull: " + "$full_name$?\n" + " get() = if (has$name$()) get$name$() else null\n\n", + "full_classname", name_resolver_->GetClassName(descriptor_, true), + "camelcase_name", context_->GetFieldGeneratorInfo(field)->name, + "full_name", + name_resolver_->GetImmutableClassName(field->message_type()), "name", + context_->GetFieldGeneratorInfo(field)->capitalized_name); + } + } } void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( @@ -826,7 +849,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@Suppress(\"UNCHECKED_CAST\")\n" "@kotlin.jvm.JvmSynthetic\n" - "public operator fun <T> get(extension: " + "public operator fun <T : kotlin.Any> get(extension: " "com.google.protobuf.ExtensionLite<$message$, T>): T {\n" " return if (extension.isRepeated) {\n" " get(extension as com.google.protobuf.ExtensionLite<$message$, " @@ -842,7 +865,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" "@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n" - "public operator fun <E> get(\n" + "public operator fun <E : kotlin.Any> get(\n" " extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n" "): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n" " return com.google.protobuf.kotlin.ExtensionList(extension, " @@ -871,7 +894,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" "@kotlin.PublishedApi\n" - "internal fun <T> setExtension(extension: " + "internal fun <T : kotlin.Any> setExtension(extension: " "com.google.protobuf.ExtensionLite<$message$, T>, " "value: T) {\n" " _builder.setExtension(extension, value)\n" @@ -914,7 +937,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "public fun<E> com.google.protobuf.kotlin.ExtensionList<E, " + "public fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.add(value: E) {\n" " _builder.addExtension(this.extension, value)\n" "}\n\n", @@ -923,7 +946,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" "@Suppress(\"NOTHING_TO_INLINE\")\n" - "public inline operator fun <E> " + "public inline operator fun <E : kotlin.Any> " "com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.plusAssign" "(value: E) {\n" @@ -933,7 +956,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "public fun<E> com.google.protobuf.kotlin.ExtensionList<E, " + "public fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.addAll(values: Iterable<E>) {\n" " for (value in values) {\n" " add(value)\n" @@ -944,7 +967,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" "@Suppress(\"NOTHING_TO_INLINE\")\n" - "public inline operator fun <E> " + "public inline operator fun <E : kotlin.Any> " "com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.plusAssign(values: " "Iterable<E>) {\n" @@ -954,7 +977,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( printer->Print( "@kotlin.jvm.JvmSynthetic\n" - "public operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, " + "public operator fun <E : kotlin.Any> " + "com.google.protobuf.kotlin.ExtensionList<E, " "$message$>.set(index: Int, value: " "E) {\n" " _builder.setExtension(this.extension, index, value)\n" @@ -975,3 +999,5 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_message_lite.h b/r5dev/thirdparty/protobuf/compiler/java/message_lite.h similarity index 94% rename from r5dev/thirdparty/protobuf/compiler/java/java_message_lite.h rename to r5dev/thirdparty/protobuf/compiler/java/message_lite.h index b81fdd1f..01efe28d 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_message_lite.h +++ b/r5dev/thirdparty/protobuf/compiler/java/message_lite.h @@ -35,10 +35,8 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__ #define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__ -#include <map> -#include <string> -#include <thirdparty/protobuf/compiler/java/java_field.h> -#include <thirdparty/protobuf/compiler/java/java_message.h> +#include <thirdparty/protobuf/compiler/java/field.h> +#include <thirdparty/protobuf/compiler/java/message.h> namespace google { namespace protobuf { @@ -48,7 +46,7 @@ namespace java { class ImmutableMessageLiteGenerator : public MessageGenerator { public: ImmutableMessageLiteGenerator(const Descriptor* descriptor, Context* context); - virtual ~ImmutableMessageLiteGenerator(); + ~ImmutableMessageLiteGenerator() override; void Generate(io::Printer* printer) override; void GenerateInterface(io::Printer* printer) override; @@ -70,6 +68,7 @@ class ImmutableMessageLiteGenerator : public MessageGenerator { void GenerateConstructor(io::Printer* printer); void GenerateDynamicMethodNewBuildMessageInfo(io::Printer* printer); void GenerateKotlinExtensions(io::Printer* printer) const; + void GenerateKotlinOrNull(io::Printer* printer) const; Context* context_; ClassNameResolver* name_resolver_; diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_name_resolver.cc b/r5dev/thirdparty/protobuf/compiler/java/name_resolver.cc similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_name_resolver.cc rename to r5dev/thirdparty/protobuf/compiler/java/name_resolver.cc index 708491db..73dbf58a 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_name_resolver.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/name_resolver.cc @@ -28,15 +28,18 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_names.h> #include <thirdparty/protobuf/compiler/code_generator.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/names.h> + +// Must be last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -378,3 +381,5 @@ std::string ClassNameResolver::GetDowngradedClassName( } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_name_resolver.h b/r5dev/thirdparty/protobuf/compiler/java/name_resolver.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_name_resolver.h rename to r5dev/thirdparty/protobuf/compiler/java/name_resolver.h index 1df64ecb..adf650cb 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_name_resolver.h +++ b/r5dev/thirdparty/protobuf/compiler/java/name_resolver.h @@ -36,6 +36,9 @@ #include <thirdparty/protobuf/stubs/common.h> +// Must be last. +#include <thirdparty/protobuf/port_def.inc> + namespace google { namespace protobuf { class Descriptor; @@ -123,7 +126,6 @@ class ClassNameResolver { std::string GetDowngradedFileClassName(const FileDescriptor* file); std::string GetDowngradedClassName(const Descriptor* descriptor); - private: // Get the full name of a Java class by prepending the Java package name // or outer class name. std::string GetClassFullName(const std::string& name_without_package, @@ -132,6 +134,8 @@ class ClassNameResolver { std::string GetClassFullName(const std::string& name_without_package, const FileDescriptor* file, bool immutable, bool is_own_file, bool kotlin); + + private: // Get the Java Class style full name of a message. std::string GetJavaClassFullName(const std::string& name_without_package, const FileDescriptor* file, bool immutable); @@ -150,4 +154,6 @@ class ClassNameResolver { } // namespace protobuf } // namespace google +#include <thirdparty/protobuf/port_undef.inc> + #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__ diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_names.h b/r5dev/thirdparty/protobuf/compiler/java/names.h similarity index 100% rename from r5dev/thirdparty/protobuf/compiler/java/java_names.h rename to r5dev/thirdparty/protobuf/compiler/java/names.h diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_options.h b/r5dev/thirdparty/protobuf/compiler/java/options.h similarity index 100% rename from r5dev/thirdparty/protobuf/compiler/java/java_options.h rename to r5dev/thirdparty/protobuf/compiler/java/options.h diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_plugin_unittest.cc b/r5dev/thirdparty/protobuf/compiler/java/plugin_unittest.cc similarity index 81% rename from r5dev/thirdparty/protobuf/compiler/java/java_plugin_unittest.cc rename to r5dev/thirdparty/protobuf/compiler/java/plugin_unittest.cc index b9b42b36..8eeb992d 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_plugin_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/plugin_unittest.cc @@ -29,19 +29,17 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Author: kenton@google.com (Kenton Varda) -// -// TODO(kenton): Share code with the versions of this test in other languages? -// It seemed like parameterizing it would add more complexity than it is -// worth. #include <memory> +#include <string> #include <thirdparty/protobuf/testing/file.h> #include <thirdparty/protobuf/testing/file.h> -#include <thirdparty/protobuf/compiler/java/java_generator.h> +#include <thirdparty/protobuf/compiler/java/generator.h> #include <thirdparty/protobuf/compiler/command_line_interface.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> +#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> @@ -54,11 +52,10 @@ namespace { class TestGenerator : public CodeGenerator { public: TestGenerator() {} - ~TestGenerator() {} + ~TestGenerator() override {} - virtual bool Generate(const FileDescriptor* file, - const std::string& parameter, GeneratorContext* context, - std::string* error) const { + bool Generate(const FileDescriptor* file, const std::string& parameter, + GeneratorContext* context, std::string* error) const override { std::string filename = "Test.java"; TryInsert(filename, "outer_class_scope", context); TryInsert(filename, "class_scope:foo.Bar", context); @@ -110,6 +107,26 @@ TEST(JavaPluginTest, PluginTest) { test_out.c_str(), "test.proto"}; EXPECT_EQ(0, cli.Run(5, argv)); + + // Loop over the lines of the generated code and verify that we find what we + // expect + + std::string output; + GOOGLE_CHECK_OK(File::GetContents(TestTempDir() + "/Test.java", &output, + true)); + std::vector<std::string> lines = Split(output, "\n"); + bool found_generated_annotation = false; + bool found_do_not_edit = false; + for (const auto& line : lines) { + if (line.find(" DO NOT EDIT!") != std::string::npos) { + found_do_not_edit = true; + } + if (line.find("@com.google.protobuf.Generated") != std::string::npos) { + found_generated_annotation = true; + } + } + EXPECT_TRUE(found_do_not_edit); + (void)found_generated_annotation; } } // namespace diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_primitive_field.cc b/r5dev/thirdparty/protobuf/compiler/java/primitive_field.cc similarity index 84% rename from r5dev/thirdparty/protobuf/compiler/java/java_primitive_field.cc rename to r5dev/thirdparty/protobuf/compiler/java/primitive_field.cc index d1702cec..2e3b8eaa 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_primitive_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/primitive_field.cc @@ -32,21 +32,21 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_primitive_field.h> +#include "google/protobuf/compiler/java/primitive_field.h" #include <cstdint> #include <map> #include <string> -#include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/stubs/strutil.h> +#include "google/protobuf/stubs/logging.h" +#include "google/protobuf/stubs/common.h" +#include "google/protobuf/io/printer.h" +#include "google/protobuf/wire_format.h" +#include "google/protobuf/stubs/strutil.h" +#include "google/protobuf/compiler/java/context.h" +#include "google/protobuf/compiler/java/doc_comment.h" +#include "google/protobuf/compiler/java/helpers.h" +#include "google/protobuf/compiler/java/name_resolver.h" namespace google { namespace protobuf { @@ -57,53 +57,55 @@ using internal::WireFormat; namespace { -void SetPrimitiveVariables(const FieldDescriptor* descriptor, - int messageBitIndex, int builderBitIndex, - const FieldGeneratorInfo* info, - ClassNameResolver* name_resolver, - std::map<std::string, std::string>* variables) { +void SetPrimitiveVariables( + const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, + const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, + std::map<std::string, std::string>* variables, + Context* context) { SetCommonFieldVariables(descriptor, info, variables); JavaType javaType = GetJavaType(descriptor); (*variables)["type"] = PrimitiveTypeName(javaType); (*variables)["boxed_type"] = BoxedPrimitiveTypeName(javaType); (*variables)["kt_type"] = KotlinTypeName(javaType); - (*variables)["field_type"] = (*variables)["type"]; + variables->insert({"field_type", (*variables)["type"]}); + std::string name = (*variables)["name"]; if (javaType == JAVATYPE_BOOLEAN || javaType == JAVATYPE_DOUBLE || javaType == JAVATYPE_FLOAT || javaType == JAVATYPE_INT || javaType == JAVATYPE_LONG) { std::string capitalized_type = UnderscoresToCamelCase( PrimitiveTypeName(javaType), /*cap_first_letter=*/true); (*variables)["field_list_type"] = - "com.google.protobuf.Internal." + capitalized_type + "List"; - (*variables)["empty_list"] = "empty" + capitalized_type + "List()"; - (*variables)["create_list"] = "new" + capitalized_type + "List()"; - (*variables)["mutable_copy_list"] = - "mutableCopy(" + (*variables)["name"] + "_)"; - (*variables)["name_make_immutable"] = - (*variables)["name"] + "_.makeImmutable()"; - (*variables)["repeated_get"] = - (*variables)["name"] + "_.get" + capitalized_type; - (*variables)["repeated_add"] = - (*variables)["name"] + "_.add" + capitalized_type; - (*variables)["repeated_set"] = - (*variables)["name"] + "_.set" + capitalized_type; - } else { - (*variables)["field_list_type"] = - "java.util.List<" + (*variables)["boxed_type"] + ">"; + StrCat("com.google.protobuf.Internal.", capitalized_type, "List"); + (*variables)["empty_list"] = + StrCat("empty", capitalized_type, "List()"); (*variables)["create_list"] = - "new java.util.ArrayList<" + (*variables)["boxed_type"] + ">()"; - (*variables)["mutable_copy_list"] = "new java.util.ArrayList<" + - (*variables)["boxed_type"] + ">(" + - (*variables)["name"] + "_)"; - (*variables)["empty_list"] = "java.util.Collections.emptyList()"; + StrCat("new", capitalized_type, "List()"); + (*variables)["mutable_copy_list"] = + StrCat("mutableCopy(", name, "_)"); (*variables)["name_make_immutable"] = - (*variables)["name"] + "_ = java.util.Collections.unmodifiableList(" + - (*variables)["name"] + "_)"; - (*variables)["repeated_get"] = (*variables)["name"] + "_.get"; - (*variables)["repeated_add"] = (*variables)["name"] + "_.add"; - (*variables)["repeated_set"] = (*variables)["name"] + "_.set"; + StrCat(name, "_.makeImmutable()"); + (*variables)["repeated_get"] = + StrCat(name, "_.get", capitalized_type); + (*variables)["repeated_add"] = + StrCat(name, "_.add", capitalized_type); + (*variables)["repeated_set"] = + StrCat(name, "_.set", capitalized_type); + } else { + std::string boxed_type = (*variables)["boxed_type"]; + (*variables)["field_list_type"] = + StrCat("java.util.List<", boxed_type, ">"); + (*variables)["create_list"] = + StrCat("new java.util.ArrayList<", boxed_type, ">()"); + (*variables)["mutable_copy_list"] = + StrCat("new java.util.ArrayList<", boxed_type, ">(", name, "_)"); + (*variables)["empty_list"] = "java.util.Collections.emptyList()"; + (*variables)["name_make_immutable"] = StrCat( + name, "_ = java.util.Collections.unmodifiableList(", name, "_)"); + (*variables)["repeated_get"] = StrCat(name, "_.get"); + (*variables)["repeated_add"] = StrCat(name, "_.add"); + (*variables)["repeated_set"] = StrCat(name, "_.set"); } (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver); @@ -119,9 +121,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, WireFormat::TagSize(descriptor->number(), GetType(descriptor))); if (IsReferenceType(GetJavaType(descriptor))) { (*variables)["null_check"] = - " if (value == null) {\n" - " throw new NullPointerException();\n" - " }\n"; + "if (value == null) { throw new NullPointerException(); }"; } else { (*variables)["null_check"] = ""; } @@ -131,8 +131,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; (*variables)["kt_deprecation"] = descriptor->options().deprecated() - ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] + - " is deprecated\") " + ? StrCat("@kotlin.Deprecated(message = \"Field ", name, + " is deprecated\") ") : ""; int fixed_size = FixedSize(GetType(descriptor)); if (fixed_size != -1) { @@ -143,40 +143,29 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, if (HasHasbit(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); - (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); - // Note that these have a trailing ";". - (*variables)["set_has_field_bit_message"] = - GenerateSetBit(messageBitIndex) + ";"; - (*variables)["set_has_field_bit_builder"] = - GenerateSetBit(builderBitIndex) + ";"; - (*variables)["clear_has_field_bit_builder"] = - GenerateClearBit(builderBitIndex) + ";"; - + (*variables)["set_has_field_bit_to_local"] = + GenerateSetBitToLocal(messageBitIndex) + ";"; (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex); } else { - (*variables)["set_has_field_bit_message"] = ""; - (*variables)["set_has_field_bit_builder"] = ""; - (*variables)["clear_has_field_bit_builder"] = ""; - + (*variables)["set_has_field_bit_to_local"] = ""; switch (descriptor->type()) { case FieldDescriptor::TYPE_BYTES: (*variables)["is_field_present_message"] = - "!" + (*variables)["name"] + "_.isEmpty()"; + StrCat("!", name, "_.isEmpty()"); break; case FieldDescriptor::TYPE_FLOAT: (*variables)["is_field_present_message"] = - "java.lang.Float.floatToRawIntBits(" + (*variables)["name"] + - "_) != 0"; + StrCat("java.lang.Float.floatToRawIntBits(", name, "_) != 0"); break; case FieldDescriptor::TYPE_DOUBLE: - (*variables)["is_field_present_message"] = - "java.lang.Double.doubleToRawLongBits(" + (*variables)["name"] + - "_) != 0"; + (*variables)["is_field_present_message"] = StrCat( + "java.lang.Double.doubleToRawLongBits(", name, "_) != 0"); break; default: - (*variables)["is_field_present_message"] = - (*variables)["name"] + "_ != " + (*variables)["default"]; + variables->insert( + {"is_field_present_message", + StrCat(name, "_ != ", (*variables)["default"])}); break; } } @@ -186,17 +175,15 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex); (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex); - // For repeated fields, one bit is used for whether the array is immutable - // in the parsing constructor. - (*variables)["get_mutable_bit_parser"] = - GenerateGetBitMutableLocal(builderBitIndex); - (*variables)["set_mutable_bit_parser"] = - GenerateSetBitMutableLocal(builderBitIndex); - + // Always track the presence of a field explicitly in the builder, regardless + // of syntax. + (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); (*variables)["get_has_field_bit_from_local"] = GenerateGetBitFromLocal(builderBitIndex); - (*variables)["set_has_field_bit_to_local"] = - GenerateSetBitToLocal(messageBitIndex); + (*variables)["set_has_field_bit_builder"] = + GenerateSetBit(builderBitIndex) + ";"; + (*variables)["clear_has_field_bit_builder"] = + GenerateClearBit(builderBitIndex) + ";"; } } // namespace @@ -206,21 +193,30 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, ImmutablePrimitiveFieldGenerator::ImmutablePrimitiveFieldGenerator( const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context) - : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) { + : descriptor_(descriptor), + message_bit_index_(messageBitIndex), + builder_bit_index_(builderBitIndex), + name_resolver_(context->GetNameResolver()) { SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex, context->GetFieldGeneratorInfo(descriptor), - name_resolver_, &variables_); + name_resolver_, &variables_, context); } ImmutablePrimitiveFieldGenerator::~ImmutablePrimitiveFieldGenerator() {} +int ImmutablePrimitiveFieldGenerator::GetMessageBitIndex() const { + return message_bit_index_; +} + +int ImmutablePrimitiveFieldGenerator::GetBuilderBitIndex() const { + return builder_bit_index_; +} + int ImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const { return HasHasbit(descriptor_) ? 1 : 0; } -int ImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const { - return GetNumBitsForMessage(); -} +int ImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const { return 1; } void ImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers( io::Printer* printer) const { @@ -235,7 +231,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers( void ImmutablePrimitiveFieldGenerator::GenerateMembers( io::Printer* printer) const { - printer->Print(variables_, "private $field_type$ $name$_;\n"); + printer->Print(variables_, "private $field_type$ $name$_ = $default$;\n"); PrintExtraFieldInfo(variables_, printer); if (HasHazzer(descriptor_)) { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); @@ -285,9 +281,9 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( printer->Print(variables_, "$deprecation$public Builder " "${$set$capitalized_name$$}$($type$ value) {\n" - "$null_check$" - " $set_has_field_bit_builder$\n" + " $null_check$\n" " $name$_ = value;\n" + " $set_has_field_bit_builder$\n" " $on_changed$\n" " return this;\n" "}\n"); @@ -359,9 +355,8 @@ void ImmutablePrimitiveFieldGenerator::GenerateInitializationCode( void ImmutablePrimitiveFieldGenerator::GenerateBuilderClearCode( io::Printer* printer) const { - printer->Print(variables_, - "$name$_ = $default$;\n" - "$clear_has_field_bit_builder$\n"); + // No need to clear the has-bit since we clear the bitField ints all at once. + printer->Print(variables_, "$name$_ = $default$;\n"); } void ImmutablePrimitiveFieldGenerator::GenerateMergingCode( @@ -381,35 +376,20 @@ void ImmutablePrimitiveFieldGenerator::GenerateMergingCode( void ImmutablePrimitiveFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - if (HasHazzer(descriptor_)) { - if (IsDefaultValueJavaDefault(descriptor_)) { - printer->Print(variables_, - "if ($get_has_field_bit_from_local$) {\n" - " result.$name$_ = $name$_;\n" - " $set_has_field_bit_to_local$;\n" - "}\n"); - } else { - printer->Print(variables_, - "if ($get_has_field_bit_from_local$) {\n" - " $set_has_field_bit_to_local$;\n" - "}\n" - "result.$name$_ = $name$_;\n"); - } - } else { - printer->Print(variables_, "result.$name$_ = $name$_;\n"); + printer->Print(variables_, + "if ($get_has_field_bit_from_local$) {\n" + " result.$name$_ = $name$_;\n"); + if (GetNumBitsForMessage() > 0) { + printer->Print(variables_, " $set_has_field_bit_to_local$\n"); } + printer->Print("}\n"); } -void ImmutablePrimitiveFieldGenerator::GenerateParsingCode( +void ImmutablePrimitiveFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { printer->Print(variables_, - "$set_has_field_bit_message$\n" - "$name$_ = input.read$capitalized_type$();\n"); -} - -void ImmutablePrimitiveFieldGenerator::GenerateParsingDoneCode( - io::Printer* printer) const { - // noop for primitives. + "$name$_ = input.read$capitalized_type$();\n" + "$set_has_field_bit_builder$\n"); } void ImmutablePrimitiveFieldGenerator::GenerateSerializationCode( @@ -591,7 +571,7 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers( printer->Print(variables_, "$deprecation$public Builder " "${$set$capitalized_name$$}$($type$ value) {\n" - "$null_check$" + " $null_check$\n" " $set_oneof_case_message$;\n" " $oneof_name$_ = value;\n" " $on_changed$\n" @@ -614,12 +594,15 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers( printer->Annotate("{", "}", descriptor_); } +void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderClearCode( + io::Printer* printer) const { + // No-Op: When a primitive field is in a oneof, clearing the oneof clears that + // field. +} + void ImmutablePrimitiveOneofFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - printer->Print(variables_, - "if ($has_oneof_case_message$) {\n" - " result.$oneof_name$_ = $oneof_name$_;\n" - "}\n"); + // no-op } void ImmutablePrimitiveOneofFieldGenerator::GenerateMergingCode( @@ -628,7 +611,7 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateMergingCode( "set$capitalized_name$(other.get$capitalized_name$());\n"); } -void ImmutablePrimitiveOneofFieldGenerator::GenerateParsingCode( +void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { printer->Print(variables_, "$oneof_name$_ = input.read$capitalized_type$();\n" @@ -677,11 +660,8 @@ RepeatedImmutablePrimitiveFieldGenerator:: int messageBitIndex, int builderBitIndex, Context* context) - : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) { - SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex, - context->GetFieldGeneratorInfo(descriptor), - name_resolver_, &variables_); -} + : ImmutablePrimitiveFieldGenerator(descriptor, messageBitIndex, + builderBitIndex, context) {} RepeatedImmutablePrimitiveFieldGenerator:: ~RepeatedImmutablePrimitiveFieldGenerator() {} @@ -710,7 +690,8 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers( void RepeatedImmutablePrimitiveFieldGenerator::GenerateMembers( io::Printer* printer) const { - printer->Print(variables_, "private $field_list_type$ $name$_;\n"); + printer->Print(variables_, "@SuppressWarnings(\"serial\")\n" + "private $field_list_type$ $name$_;\n"); PrintExtraFieldInfo(variables_, printer); WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER); printer->Print(variables_, @@ -760,7 +741,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( " if (!$get_mutable_bit_builder$) {\n" " $name$_ = $mutable_copy_list$;\n" " $set_mutable_bit_builder$;\n" - " }\n" + " }\n" "}\n"); // Note: We return an unmodifiable list because otherwise the caller @@ -795,7 +776,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( printer->Print(variables_, "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " int index, $type$ value) {\n" - "$null_check$" + " $null_check$\n" " ensure$capitalized_name$IsMutable();\n" " $repeated_set$(index, value);\n" " $on_changed$\n" @@ -807,7 +788,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( printer->Print(variables_, "$deprecation$public Builder " "${$add$capitalized_name$$}$($type$ value) {\n" - "$null_check$" + " $null_check$\n" " ensure$capitalized_name$IsMutable();\n" " $repeated_add$(value);\n" " $on_changed$\n" @@ -945,9 +926,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateInitializationCode( void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderClearCode( io::Printer* printer) const { - printer->Print(variables_, - "$name$_ = $empty_list$;\n" - "$clear_mutable_bit_builder$;\n"); + printer->Print(variables_, "$name$_ = $empty_list$;\n"); } void RepeatedImmutablePrimitiveFieldGenerator::GenerateMergingCode( @@ -982,38 +961,24 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuildingCode( "result.$name$_ = $name$_;\n"); } -void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingCode( +void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { printer->Print(variables_, - "if (!$get_mutable_bit_parser$) {\n" - " $name$_ = $create_list$;\n" - " $set_mutable_bit_parser$;\n" + "$type$ v = input.read$capitalized_type$();\n" + "ensure$capitalized_name$IsMutable();\n" + "$repeated_add$(v);\n"); +} + +void RepeatedImmutablePrimitiveFieldGenerator:: + GenerateBuilderParsingCodeFromPacked(io::Printer* printer) const { + printer->Print(variables_, + "int length = input.readRawVarint32();\n" + "int limit = input.pushLimit(length);\n" + "ensure$capitalized_name$IsMutable();\n" + "while (input.getBytesUntilLimit() > 0) {\n" + " $repeated_add$(input.read$capitalized_type$());\n" "}\n" - "$repeated_add$(input.read$capitalized_type$());\n"); -} - -void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingCodeFromPacked( - io::Printer* printer) const { - printer->Print( - variables_, - "int length = input.readRawVarint32();\n" - "int limit = input.pushLimit(length);\n" - "if (!$get_mutable_bit_parser$ && input.getBytesUntilLimit() > 0) {\n" - " $name$_ = $create_list$;\n" - " $set_mutable_bit_parser$;\n" - "}\n" - "while (input.getBytesUntilLimit() > 0) {\n" - " $repeated_add$(input.read$capitalized_type$());\n" - "}\n" - "input.popLimit(limit);\n"); -} - -void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingDoneCode( - io::Printer* printer) const { - printer->Print(variables_, - "if ($get_mutable_bit_parser$) {\n" - " $name_make_immutable$; // C\n" - "}\n"); + "input.popLimit(limit);\n"); } void RepeatedImmutablePrimitiveFieldGenerator::GenerateSerializationCode( diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_primitive_field.h b/r5dev/thirdparty/protobuf/compiler/java/primitive_field.h similarity index 82% rename from r5dev/thirdparty/protobuf/compiler/java/java_primitive_field.h rename to r5dev/thirdparty/protobuf/compiler/java/primitive_field.h index f65c0ce0..9d956559 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_primitive_field.h +++ b/r5dev/thirdparty/protobuf/compiler/java/primitive_field.h @@ -37,7 +37,8 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_field.h> + +#include "google/protobuf/compiler/java/field.h" namespace google { namespace protobuf { @@ -61,10 +62,16 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator { int messageBitIndex, int builderBitIndex, Context* context); + ImmutablePrimitiveFieldGenerator(const ImmutablePrimitiveFieldGenerator&) = + delete; + ImmutablePrimitiveFieldGenerator& operator=( + const ImmutablePrimitiveFieldGenerator&) = delete; ~ImmutablePrimitiveFieldGenerator() override; // implements ImmutableFieldGenerator // --------------------------------------- + int GetMessageBitIndex() const override; + int GetBuilderBitIndex() const override; int GetNumBitsForMessage() const override; int GetNumBitsForBuilder() const override; void GenerateInterfaceMembers(io::Printer* printer) const override; @@ -74,8 +81,7 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator { void GenerateBuilderClearCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; - void GenerateParsingDoneCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; void GenerateFieldBuilderInitializationCode( @@ -88,11 +94,10 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; + int message_bit_index_; + int builder_bit_index_; std::map<std::string, std::string> variables_; ClassNameResolver* name_resolver_; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveFieldGenerator); }; class ImmutablePrimitiveOneofFieldGenerator @@ -101,26 +106,32 @@ class ImmutablePrimitiveOneofFieldGenerator ImmutablePrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context); - ~ImmutablePrimitiveOneofFieldGenerator(); + ImmutablePrimitiveOneofFieldGenerator( + const ImmutablePrimitiveOneofFieldGenerator&) = delete; + ImmutablePrimitiveOneofFieldGenerator& operator=( + const ImmutablePrimitiveOneofFieldGenerator&) = delete; + ~ImmutablePrimitiveOneofFieldGenerator() override; void GenerateMembers(io::Printer* printer) const override; void GenerateBuilderMembers(io::Printer* printer) const override; + void GenerateBuilderClearCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveOneofFieldGenerator); }; class RepeatedImmutablePrimitiveFieldGenerator - : public ImmutableFieldGenerator { + : public ImmutablePrimitiveFieldGenerator { public: explicit RepeatedImmutablePrimitiveFieldGenerator( const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context); + RepeatedImmutablePrimitiveFieldGenerator( + const RepeatedImmutablePrimitiveFieldGenerator&) = delete; + RepeatedImmutablePrimitiveFieldGenerator& operator=( + const RepeatedImmutablePrimitiveFieldGenerator&) = delete; ~RepeatedImmutablePrimitiveFieldGenerator() override; // implements ImmutableFieldGenerator --------------------------------------- @@ -133,9 +144,9 @@ class RepeatedImmutablePrimitiveFieldGenerator void GenerateBuilderClearCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; - void GenerateParsingCodeFromPacked(io::Printer* printer) const override; - void GenerateParsingDoneCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; + void GenerateBuilderParsingCodeFromPacked( + io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; void GenerateFieldBuilderInitializationCode( @@ -145,13 +156,6 @@ class RepeatedImmutablePrimitiveFieldGenerator void GenerateKotlinDslMembers(io::Printer* printer) const override; std::string GetBoxedType() const override; - - private: - const FieldDescriptor* descriptor_; - std::map<std::string, std::string> variables_; - ClassNameResolver* name_resolver_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutablePrimitiveFieldGenerator); }; } // namespace java diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_primitive_field_lite.cc b/r5dev/thirdparty/protobuf/compiler/java/primitive_field_lite.cc similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_primitive_field_lite.cc rename to r5dev/thirdparty/protobuf/compiler/java/primitive_field_lite.cc index 1292d7d9..7f99a3c9 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_primitive_field_lite.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/primitive_field_lite.cc @@ -32,7 +32,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_primitive_field_lite.h> +#include <thirdparty/protobuf/compiler/java/primitive_field_lite.h> #include <cstdint> #include <map> @@ -40,13 +40,13 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> namespace google { namespace protobuf { @@ -160,7 +160,6 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex); } else { - (*variables)["set_has_field_bit_message"] = ""; (*variables)["set_has_field_bit_message"] = ""; (*variables)["clear_has_field_bit_message"] = ""; diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_primitive_field_lite.h b/r5dev/thirdparty/protobuf/compiler/java/primitive_field_lite.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_primitive_field_lite.h rename to r5dev/thirdparty/protobuf/compiler/java/primitive_field_lite.h index 54860a9c..8553780a 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_primitive_field_lite.h +++ b/r5dev/thirdparty/protobuf/compiler/java/primitive_field_lite.h @@ -39,7 +39,7 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_field.h> +#include <thirdparty/protobuf/compiler/java/field.h> namespace google { namespace protobuf { @@ -93,7 +93,7 @@ class ImmutablePrimitiveOneofFieldLiteGenerator ImmutablePrimitiveOneofFieldLiteGenerator(const FieldDescriptor* descriptor, int messageBitIndex, Context* context); - ~ImmutablePrimitiveOneofFieldLiteGenerator(); + ~ImmutablePrimitiveOneofFieldLiteGenerator() override; void GenerateMembers(io::Printer* printer) const override; void GenerateBuilderMembers(io::Printer* printer) const override; diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_service.cc b/r5dev/thirdparty/protobuf/compiler/java/service.cc similarity index 97% rename from r5dev/thirdparty/protobuf/compiler/java/java_service.cc rename to r5dev/thirdparty/protobuf/compiler/java/service.cc index 174e6bf8..c5add108 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_service.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/service.cc @@ -32,14 +32,17 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_service.h> +#include <thirdparty/protobuf/compiler/java/service.h> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> + +// Must be last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -472,3 +475,5 @@ void ImmutableServiceGenerator::GenerateBlockingMethodSignature( } // namespace compiler } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_service.h b/r5dev/thirdparty/protobuf/compiler/java/service.h similarity index 99% rename from r5dev/thirdparty/protobuf/compiler/java/java_service.h rename to r5dev/thirdparty/protobuf/compiler/java/service.h index bfd562d3..4d7f3371 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_service.h +++ b/r5dev/thirdparty/protobuf/compiler/java/service.h @@ -78,7 +78,7 @@ class ImmutableServiceGenerator : public ServiceGenerator { public: ImmutableServiceGenerator(const ServiceDescriptor* descriptor, Context* context); - virtual ~ImmutableServiceGenerator(); + ~ImmutableServiceGenerator() override; void Generate(io::Printer* printer) override; diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_shared_code_generator.cc b/r5dev/thirdparty/protobuf/compiler/java/shared_code_generator.cc similarity index 96% rename from r5dev/thirdparty/protobuf/compiler/java/java_shared_code_generator.cc rename to r5dev/thirdparty/protobuf/compiler/java/shared_code_generator.cc index 90de1665..f86c0e3b 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_shared_code_generator.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/shared_code_generator.cc @@ -30,19 +30,19 @@ // Author: xiaofeng@google.com (Feng Xiao) -#include <thirdparty/protobuf/compiler/java/java_shared_code_generator.h> +#include <thirdparty/protobuf/compiler/java/shared_code_generator.h> #include <memory> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/compiler/java/java_names.h> #include <thirdparty/protobuf/compiler/code_generator.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> +#include <thirdparty/protobuf/compiler/java/names.h> +#include <thirdparty/protobuf/descriptor.pb.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_shared_code_generator.h b/r5dev/thirdparty/protobuf/compiler/java/shared_code_generator.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_shared_code_generator.h rename to r5dev/thirdparty/protobuf/compiler/java/shared_code_generator.h index 395fc20c..f3d50ec2 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_shared_code_generator.h +++ b/r5dev/thirdparty/protobuf/compiler/java/shared_code_generator.h @@ -40,7 +40,7 @@ #include <vector> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/java/java_options.h> +#include <thirdparty/protobuf/compiler/java/options.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_string_field.cc b/r5dev/thirdparty/protobuf/compiler/java/string_field.cc similarity index 90% rename from r5dev/thirdparty/protobuf/compiler/java/java_string_field.cc rename to r5dev/thirdparty/protobuf/compiler/java/string_field.cc index 9dc5db27..5f207924 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_string_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/string_field.cc @@ -33,21 +33,21 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_string_field.h> +#include "google/protobuf/compiler/java/string_field.h" #include <cstdint> #include <map> #include <string> -#include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> -#include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/stubs/strutil.h> +#include "google/protobuf/stubs/logging.h" +#include "google/protobuf/stubs/common.h" +#include "google/protobuf/io/printer.h" +#include "google/protobuf/wire_format.h" +#include "google/protobuf/stubs/strutil.h" +#include "google/protobuf/compiler/java/context.h" +#include "google/protobuf/compiler/java/doc_comment.h" +#include "google/protobuf/compiler/java/helpers.h" +#include "google/protobuf/compiler/java/name_resolver.h" namespace google { namespace protobuf { @@ -59,11 +59,11 @@ using internal::WireFormatLite; namespace { -void SetPrimitiveVariables(const FieldDescriptor* descriptor, - int messageBitIndex, int builderBitIndex, - const FieldGeneratorInfo* info, - ClassNameResolver* name_resolver, - std::map<std::string, std::string>* variables) { +void SetPrimitiveVariables( + const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, + const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, + std::map<std::string, std::string>* variables, + Context* context) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["empty_list"] = "com.google.protobuf.LazyStringArrayList.EMPTY"; @@ -77,9 +77,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["tag_size"] = StrCat( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); (*variables)["null_check"] = - " if (value == null) {\n" - " throw new NullPointerException();\n" - " }\n"; + "if (value == null) { throw new NullPointerException(); }"; (*variables)["isStringEmpty"] = "com.google.protobuf.GeneratedMessage" + GeneratedCodeVersionSuffix() + ".isStringEmpty"; @@ -93,34 +91,33 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, // by the proto compiler (*variables)["deprecation"] = descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; - (*variables)["kt_deprecation"] = - descriptor->options().deprecated() - ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] + - " is deprecated\") " - : ""; + variables->insert( + {"kt_deprecation", + descriptor->options().deprecated() + ? StrCat("@kotlin.Deprecated(message = \"Field ", + (*variables)["name"], " is deprecated\") ") + : ""}); (*variables)["on_changed"] = "onChanged();"; if (HasHasbit(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); - (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); + (*variables)["set_has_field_bit_to_local"] = + GenerateSetBitToLocal(messageBitIndex); // Note that these have a trailing ";". (*variables)["set_has_field_bit_message"] = GenerateSetBit(messageBitIndex) + ";"; - (*variables)["set_has_field_bit_builder"] = - GenerateSetBit(builderBitIndex) + ";"; - (*variables)["clear_has_field_bit_builder"] = - GenerateClearBit(builderBitIndex) + ";"; (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex); } else { + (*variables)["get_has_field_bit_message"] = ""; + (*variables)["set_has_field_bit_to_local"] = ""; (*variables)["set_has_field_bit_message"] = ""; - (*variables)["set_has_field_bit_builder"] = ""; - (*variables)["clear_has_field_bit_builder"] = ""; - (*variables)["is_field_present_message"] = - "!" + (*variables)["isStringEmpty"] + "(" + (*variables)["name"] + "_)"; + variables->insert({"is_field_present_message", + StrCat("!", (*variables)["isStringEmpty"], "(", + (*variables)["name"], "_)")}); } // For repeated builders, one bit is used for whether the array is immutable. @@ -128,17 +125,13 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex); (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex); - // For repeated fields, one bit is used for whether the array is immutable - // in the parsing constructor. - (*variables)["get_mutable_bit_parser"] = - GenerateGetBitMutableLocal(builderBitIndex); - (*variables)["set_mutable_bit_parser"] = - GenerateSetBitMutableLocal(builderBitIndex); - + (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); (*variables)["get_has_field_bit_from_local"] = GenerateGetBitFromLocal(builderBitIndex); - (*variables)["set_has_field_bit_to_local"] = - GenerateSetBitToLocal(messageBitIndex); + (*variables)["set_has_field_bit_builder"] = + GenerateSetBit(builderBitIndex) + ";"; + (*variables)["clear_has_field_bit_builder"] = + GenerateClearBit(builderBitIndex) + ";"; } } // namespace @@ -148,21 +141,30 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, ImmutableStringFieldGenerator::ImmutableStringFieldGenerator( const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context) - : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) { + : descriptor_(descriptor), + message_bit_index_(messageBitIndex), + builder_bit_index_(builderBitIndex), + name_resolver_(context->GetNameResolver()) { SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex, context->GetFieldGeneratorInfo(descriptor), - name_resolver_, &variables_); + name_resolver_, &variables_, context); } ImmutableStringFieldGenerator::~ImmutableStringFieldGenerator() {} +int ImmutableStringFieldGenerator::GetMessageBitIndex() const { + return message_bit_index_; +} + +int ImmutableStringFieldGenerator::GetBuilderBitIndex() const { + return builder_bit_index_; +} + int ImmutableStringFieldGenerator::GetNumBitsForMessage() const { return HasHasbit(descriptor_) ? 1 : 0; } -int ImmutableStringFieldGenerator::GetNumBitsForBuilder() const { - return GetNumBitsForMessage(); -} +int ImmutableStringFieldGenerator::GetNumBitsForBuilder() const { return 1; } // A note about how strings are handled. This code used to just store a String // in the Message. This had two issues: @@ -214,7 +216,9 @@ void ImmutableStringFieldGenerator::GenerateInterfaceMembers( void ImmutableStringFieldGenerator::GenerateMembers( io::Printer* printer) const { - printer->Print(variables_, "private volatile java.lang.Object $name$_;\n"); + printer->Print(variables_, + "@SuppressWarnings(\"serial\")\n" + "private volatile java.lang.Object $name$_ = $default$;\n"); PrintExtraFieldInfo(variables_, printer); if (HasHazzer(descriptor_)) { @@ -333,9 +337,9 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers( printer->Print(variables_, "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " java.lang.String value) {\n" - "$null_check$" - " $set_has_field_bit_builder$\n" + " $null_check$\n" " $name$_ = value;\n" + " $set_has_field_bit_builder$\n" " $on_changed$\n" " return this;\n" "}\n"); @@ -344,14 +348,14 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers( /* builder */ true); printer->Print( variables_, - "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" - " $clear_has_field_bit_builder$\n"); + "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"); printer->Annotate("{", "}", descriptor_); // The default value is not a simple literal so we want to avoid executing // it multiple times. Instead, get the default out of the default instance. printer->Print(variables_, " $name$_ = getDefaultInstance().get$capitalized_name$();\n"); printer->Print(variables_, + " $clear_has_field_bit_builder$\n" " $on_changed$\n" " return this;\n" "}\n"); @@ -362,14 +366,14 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers( variables_, "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" - "$null_check$"); + " $null_check$\n"); printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " checkByteStringIsUtf8(value);\n"); } printer->Print(variables_, - " $set_has_field_bit_builder$\n" " $name$_ = value;\n" + " $set_has_field_bit_builder$\n" " $on_changed$\n" " return this;\n" "}\n"); @@ -416,9 +420,7 @@ void ImmutableStringFieldGenerator::GenerateInitializationCode( void ImmutableStringFieldGenerator::GenerateBuilderClearCode( io::Printer* printer) const { - printer->Print(variables_, - "$name$_ = $default$;\n" - "$clear_has_field_bit_builder$\n"); + printer->Print(variables_, "$name$_ = $default$;\n"); } void ImmutableStringFieldGenerator::GenerateMergingCode( @@ -428,14 +430,15 @@ void ImmutableStringFieldGenerator::GenerateMergingCode( // all string fields to Strings when copying fields from a Message. printer->Print(variables_, "if (other.has$capitalized_name$()) {\n" - " $set_has_field_bit_builder$\n" " $name$_ = other.$name$_;\n" + " $set_has_field_bit_builder$\n" " $on_changed$\n" "}\n"); } else { printer->Print(variables_, "if (!other.get$capitalized_name$().isEmpty()) {\n" " $name$_ = other.$name$_;\n" + " $set_has_field_bit_builder$\n" " $on_changed$\n" "}\n"); } @@ -443,35 +446,28 @@ void ImmutableStringFieldGenerator::GenerateMergingCode( void ImmutableStringFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - if (HasHazzer(descriptor_)) { - printer->Print(variables_, - "if ($get_has_field_bit_from_local$) {\n" - " $set_has_field_bit_to_local$;\n" - "}\n"); + printer->Print(variables_, + "if ($get_has_field_bit_from_local$) {\n" + " result.$name$_ = $name$_;\n"); + if (GetNumBitsForMessage() > 0) { + printer->Print(variables_, " $set_has_field_bit_to_local$;\n"); } - printer->Print(variables_, "result.$name$_ = $name$_;\n"); + printer->Print("}\n"); } -void ImmutableStringFieldGenerator::GenerateParsingCode( +void ImmutableStringFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { if (CheckUtf8(descriptor_)) { printer->Print(variables_, - "java.lang.String s = input.readStringRequireUtf8();\n" - "$set_has_field_bit_message$\n" - "$name$_ = s;\n"); + "$name$_ = input.readStringRequireUtf8();\n" + "$set_has_field_bit_builder$\n"); } else { printer->Print(variables_, - "com.google.protobuf.ByteString bs = input.readBytes();\n" - "$set_has_field_bit_message$\n" - "$name$_ = bs;\n"); + "$name$_ = input.readBytes();\n" + "$set_has_field_bit_builder$\n"); } } -void ImmutableStringFieldGenerator::GenerateParsingDoneCode( - io::Printer* printer) const { - // noop for strings. -} - void ImmutableStringFieldGenerator::GenerateSerializationCode( io::Printer* printer) const { printer->Print(variables_, @@ -655,7 +651,7 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( printer->Print(variables_, "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " java.lang.String value) {\n" - "$null_check$" + " $null_check$\n" " $set_oneof_case_message$;\n" " $oneof_name$_ = value;\n" " $on_changed$\n" @@ -682,7 +678,7 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( variables_, "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" - "$null_check$"); + " $null_check$\n"); printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " checkByteStringIsUtf8(value);\n"); @@ -695,6 +691,11 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( "}\n"); } +void ImmutableStringOneofFieldGenerator::GenerateBuilderClearCode( + io::Printer* printer) const { + // No-Op: String fields in oneofs are correctly cleared by clearing the oneof +} + void ImmutableStringOneofFieldGenerator::GenerateMergingCode( io::Printer* printer) const { // Allow a slight breach of abstraction here in order to avoid forcing @@ -707,13 +708,10 @@ void ImmutableStringOneofFieldGenerator::GenerateMergingCode( void ImmutableStringOneofFieldGenerator::GenerateBuildingCode( io::Printer* printer) const { - printer->Print(variables_, - "if ($has_oneof_case_message$) {\n" - " result.$oneof_name$_ = $oneof_name$_;\n" - "}\n"); + // No-Op: oneof fields are built by a single statement } -void ImmutableStringOneofFieldGenerator::GenerateParsingCode( +void ImmutableStringOneofFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { if (CheckUtf8(descriptor_)) { printer->Print(variables_, @@ -749,11 +747,8 @@ void ImmutableStringOneofFieldGenerator::GenerateSerializedSizeCode( RepeatedImmutableStringFieldGenerator::RepeatedImmutableStringFieldGenerator( const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context) - : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) { - SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex, - context->GetFieldGeneratorInfo(descriptor), - name_resolver_, &variables_); -} + : ImmutableStringFieldGenerator(descriptor, messageBitIndex, + builderBitIndex, context) {} RepeatedImmutableStringFieldGenerator:: ~RepeatedImmutableStringFieldGenerator() {} @@ -796,6 +791,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateInterfaceMembers( void RepeatedImmutableStringFieldGenerator::GenerateMembers( io::Printer* printer) const { printer->Print(variables_, + "@SuppressWarnings(\"serial\")\n" "private com.google.protobuf.LazyStringList $name$_;\n"); PrintExtraFieldInfo(variables_, printer); WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER); @@ -891,7 +887,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers( printer->Print(variables_, "$deprecation$public Builder ${$set$capitalized_name$$}$(\n" " int index, java.lang.String value) {\n" - "$null_check$" + " $null_check$\n" " ensure$capitalized_name$IsMutable();\n" " $name$_.set(index, value);\n" " $on_changed$\n" @@ -903,7 +899,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers( printer->Print(variables_, "$deprecation$public Builder ${$add$capitalized_name$$}$(\n" " java.lang.String value) {\n" - "$null_check$" + " $null_check$\n" " ensure$capitalized_name$IsMutable();\n" " $name$_.add(value);\n" " $on_changed$\n" @@ -940,7 +936,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers( variables_, "$deprecation$public Builder ${$add$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" - "$null_check$"); + " $null_check$\n"); printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " checkByteStringIsUtf8(value);\n"); @@ -992,7 +988,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers( // List<String> += String WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ false); - printer->Print(variables_, + printer->Print(variables_, "@kotlin.jvm.JvmSynthetic\n" "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n" "@Suppress(\"NOTHING_TO_INLINE\")\n" @@ -1104,33 +1100,19 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuildingCode( "result.$name$_ = $name$_;\n"); } -void RepeatedImmutableStringFieldGenerator::GenerateParsingCode( +void RepeatedImmutableStringFieldGenerator::GenerateBuilderParsingCode( io::Printer* printer) const { if (CheckUtf8(descriptor_)) { printer->Print(variables_, - "java.lang.String s = input.readStringRequireUtf8();\n"); + "java.lang.String s = input.readStringRequireUtf8();\n" + "ensure$capitalized_name$IsMutable();\n" + "$name$_.add(s);\n"); } else { printer->Print(variables_, - "com.google.protobuf.ByteString bs = input.readBytes();\n"); + "com.google.protobuf.ByteString bs = input.readBytes();\n" + "ensure$capitalized_name$IsMutable();\n" + "$name$_.add(bs);\n"); } - printer->Print(variables_, - "if (!$get_mutable_bit_parser$) {\n" - " $name$_ = new com.google.protobuf.LazyStringArrayList();\n" - " $set_mutable_bit_parser$;\n" - "}\n"); - if (CheckUtf8(descriptor_)) { - printer->Print(variables_, "$name$_.add(s);\n"); - } else { - printer->Print(variables_, "$name$_.add(bs);\n"); - } -} - -void RepeatedImmutableStringFieldGenerator::GenerateParsingDoneCode( - io::Printer* printer) const { - printer->Print(variables_, - "if ($get_mutable_bit_parser$) {\n" - " $name$_ = $name$_.getUnmodifiableView();\n" - "}\n"); } void RepeatedImmutableStringFieldGenerator::GenerateSerializationCode( diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_string_field.h b/r5dev/thirdparty/protobuf/compiler/java/string_field.h similarity index 82% rename from r5dev/thirdparty/protobuf/compiler/java/java_string_field.h rename to r5dev/thirdparty/protobuf/compiler/java/string_field.h index 451445fc..814ebf21 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_string_field.h +++ b/r5dev/thirdparty/protobuf/compiler/java/string_field.h @@ -38,7 +38,8 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_field.h> + +#include "google/protobuf/compiler/java/field.h" namespace google { namespace protobuf { @@ -61,10 +62,15 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator { explicit ImmutableStringFieldGenerator(const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context); - ~ImmutableStringFieldGenerator(); + ImmutableStringFieldGenerator(const ImmutableStringFieldGenerator&) = delete; + ImmutableStringFieldGenerator& operator=( + const ImmutableStringFieldGenerator&) = delete; + ~ImmutableStringFieldGenerator() override; // implements ImmutableFieldGenerator // --------------------------------------- + int GetMessageBitIndex() const override; + int GetBuilderBitIndex() const override; int GetNumBitsForMessage() const override; int GetNumBitsForBuilder() const override; void GenerateInterfaceMembers(io::Printer* printer) const override; @@ -74,8 +80,7 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator { void GenerateBuilderClearCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; - void GenerateParsingDoneCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; void GenerateFieldBuilderInitializationCode( @@ -88,11 +93,10 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; + int message_bit_index_; + int builder_bit_index_; std::map<std::string, std::string> variables_; ClassNameResolver* name_resolver_; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringFieldGenerator); }; class ImmutableStringOneofFieldGenerator @@ -101,25 +105,33 @@ class ImmutableStringOneofFieldGenerator ImmutableStringOneofFieldGenerator(const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context); - ~ImmutableStringOneofFieldGenerator(); + ImmutableStringOneofFieldGenerator( + const ImmutableStringOneofFieldGenerator&) = delete; + ImmutableStringOneofFieldGenerator& operator=( + const ImmutableStringOneofFieldGenerator&) = delete; + ~ImmutableStringOneofFieldGenerator() override; private: void GenerateMembers(io::Printer* printer) const override; void GenerateBuilderMembers(io::Printer* printer) const override; + void GenerateBuilderClearCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringOneofFieldGenerator); }; -class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator { +class RepeatedImmutableStringFieldGenerator + : public ImmutableStringFieldGenerator { public: explicit RepeatedImmutableStringFieldGenerator( const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex, Context* context); + RepeatedImmutableStringFieldGenerator( + const RepeatedImmutableStringFieldGenerator&) = delete; + RepeatedImmutableStringFieldGenerator& operator=( + const RepeatedImmutableStringFieldGenerator&) = delete; ~RepeatedImmutableStringFieldGenerator() override; // implements ImmutableFieldGenerator --------------------------------------- @@ -132,8 +144,7 @@ class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator { void GenerateBuilderClearCode(io::Printer* printer) const override; void GenerateMergingCode(io::Printer* printer) const override; void GenerateBuildingCode(io::Printer* printer) const override; - void GenerateParsingCode(io::Printer* printer) const override; - void GenerateParsingDoneCode(io::Printer* printer) const override; + void GenerateBuilderParsingCode(io::Printer* printer) const override; void GenerateSerializationCode(io::Printer* printer) const override; void GenerateSerializedSizeCode(io::Printer* printer) const override; void GenerateFieldBuilderInitializationCode( @@ -143,13 +154,6 @@ class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator { void GenerateKotlinDslMembers(io::Printer* printer) const override; std::string GetBoxedType() const override; - - private: - const FieldDescriptor* descriptor_; - std::map<std::string, std::string> variables_; - ClassNameResolver* name_resolver_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableStringFieldGenerator); }; } // namespace java diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_string_field_lite.cc b/r5dev/thirdparty/protobuf/compiler/java/string_field_lite.cc similarity index 99% rename from r5dev/thirdparty/protobuf/compiler/java/java_string_field_lite.cc rename to r5dev/thirdparty/protobuf/compiler/java/string_field_lite.cc index c798dc65..66c5c5e3 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_string_field_lite.cc +++ b/r5dev/thirdparty/protobuf/compiler/java/string_field_lite.cc @@ -33,7 +33,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/compiler/java/java_string_field_lite.h> +#include <thirdparty/protobuf/compiler/java/string_field_lite.h> #include <cstdint> #include <map> @@ -41,13 +41,13 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/java/java_context.h> -#include <thirdparty/protobuf/compiler/java/java_doc_comment.h> -#include <thirdparty/protobuf/compiler/java/java_helpers.h> -#include <thirdparty/protobuf/compiler/java/java_name_resolver.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/java/context.h> +#include <thirdparty/protobuf/compiler/java/doc_comment.h> +#include <thirdparty/protobuf/compiler/java/helpers.h> +#include <thirdparty/protobuf/compiler/java/name_resolver.h> namespace google { namespace protobuf { @@ -758,7 +758,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( "$kt_deprecation$public val $kt_name$: " "com.google.protobuf.kotlin.DslList" "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n" - " @kotlin.OptIn" + "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" " get() = com.google.protobuf.kotlin.DslList(\n" " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n" diff --git a/r5dev/thirdparty/protobuf/compiler/java/java_string_field_lite.h b/r5dev/thirdparty/protobuf/compiler/java/string_field_lite.h similarity index 98% rename from r5dev/thirdparty/protobuf/compiler/java/java_string_field_lite.h rename to r5dev/thirdparty/protobuf/compiler/java/string_field_lite.h index fe6abe53..1fbeb7cf 100644 --- a/r5dev/thirdparty/protobuf/compiler/java/java_string_field_lite.h +++ b/r5dev/thirdparty/protobuf/compiler/java/string_field_lite.h @@ -40,7 +40,7 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/java/java_field.h> +#include <thirdparty/protobuf/compiler/java/field.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/compiler/js/js_generator.cc b/r5dev/thirdparty/protobuf/compiler/js/js_generator.cc deleted file mode 100644 index 4b47ecf5..00000000 --- a/r5dev/thirdparty/protobuf/compiler/js/js_generator.cc +++ /dev/null @@ -1,3941 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include <assert.h> -#include <thirdparty/protobuf/compiler/js/js_generator.h> -#include <thirdparty/protobuf/compiler/js/well_known_types_embed.h> -#include <thirdparty/protobuf/compiler/scc.h> -#include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/descriptor.pb.h> -#include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/io/zero_copy_stream.h> -#include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/stubs/stringprintf.h> -#include <thirdparty/protobuf/stubs/strutil.h> - -#include <algorithm> -#include <limits> -#include <map> -#include <memory> -#include <string> -#include <utility> -#include <vector> - -namespace google { -namespace protobuf { -namespace compiler { -namespace js { - -// Sorted list of JavaScript keywords. These cannot be used as names. If they -// appear, we prefix them with "pb_". -const char* kKeyword[] = { - "abstract", "boolean", "break", "byte", "case", - "catch", "char", "class", "const", "continue", - "debugger", "default", "delete", "do", "double", - "else", "enum", "export", "extends", "false", - "final", "finally", "float", "for", "function", - "goto", "if", "implements", "import", "in", - "instanceof", "int", "interface", "long", "native", - "new", "null", "package", "private", "protected", - "public", "return", "short", "static", "super", - "switch", "synchronized", "this", "throw", "throws", - "transient", "try", "typeof", "var", "void", - "volatile", "while", "with", -}; - -static const int kNumKeyword = sizeof(kKeyword) / sizeof(char*); - -namespace { - -// The mode of operation for bytes fields. Historically JSPB always carried -// bytes as JS {string}, containing base64 content by convention. With binary -// and proto3 serialization the new convention is to represent it as binary -// data in Uint8Array. See b/26173701 for background on the migration. -enum BytesMode { - BYTES_DEFAULT, // Default type for getBytesField to return. - BYTES_B64, // Explicitly coerce to base64 string where needed. - BYTES_U8, // Explicitly coerce to Uint8Array where needed. -}; - -bool IsReserved(const std::string& ident) { - for (int i = 0; i < kNumKeyword; i++) { - if (ident == kKeyword[i]) { - return true; - } - } - return false; -} - -std::string GetSnakeFilename(const std::string& filename) { - std::string snake_name = filename; - ReplaceCharacters(&snake_name, "/", '_'); - return snake_name; -} - -// Given a filename like foo/bar/baz.proto, returns the corresponding JavaScript -// file foo/bar/baz.js. -std::string GetJSFilename(const GeneratorOptions& options, - const std::string& filename) { - return StripProto(filename) + options.GetFileNameExtension(); -} - -// Given a filename like foo/bar/baz.proto, returns the root directory -// path ../../ -std::string GetRootPath(const std::string& from_filename, - const std::string& to_filename) { - if (to_filename.find("google/protobuf") == 0) { - // Well-known types (.proto files in the google/protobuf directory) are - // assumed to come from the 'google-protobuf' npm package. We may want to - // generalize this exception later by letting others put generated code in - // their own npm packages. - return "google-protobuf/"; - } - - size_t slashes = std::count(from_filename.begin(), from_filename.end(), '/'); - if (slashes == 0) { - return "./"; - } - std::string result = ""; - for (size_t i = 0; i < slashes; i++) { - result += "../"; - } - return result; -} - -// Returns the alias we assign to the module of the given .proto filename -// when importing. -std::string ModuleAlias(const std::string& filename) { - // This scheme could technically cause problems if a file includes any 2 of: - // foo/bar_baz.proto - // foo_bar_baz.proto - // foo_bar/baz.proto - // - // We'll worry about this problem if/when we actually see it. This name isn't - // exposed to users so we can change it later if we need to. - std::string basename = StripProto(filename); - ReplaceCharacters(&basename, "-", '$'); - ReplaceCharacters(&basename, "/", '_'); - ReplaceCharacters(&basename, ".", '_'); - return basename + "_pb"; -} - -// Returns the fully normalized JavaScript namespace for the given -// file descriptor's package. -std::string GetNamespace(const GeneratorOptions& options, - const FileDescriptor* file) { - if (!options.namespace_prefix.empty()) { - return options.namespace_prefix; - } else if (!file->package().empty()) { - return "proto." + file->package(); - } else { - return "proto"; - } -} - -// Returns the name of the message with a leading dot and taking into account -// nesting, for example ".OuterMessage.InnerMessage", or returns empty if -// descriptor is null. This function does not handle namespacing, only message -// nesting. -std::string GetNestedMessageName(const Descriptor* descriptor) { - if (descriptor == NULL) { - return ""; - } - std::string result = - StripPrefixString(descriptor->full_name(), descriptor->file()->package()); - // Add a leading dot if one is not already present. - if (!result.empty() && result[0] != '.') { - result = "." + result; - } - return result; -} - -// Returns the path prefix for a message or enumeration that -// lives under the given file and containing type. -std::string GetPrefix(const GeneratorOptions& options, - const FileDescriptor* file_descriptor, - const Descriptor* containing_type) { - std::string prefix = GetNamespace(options, file_descriptor) + - GetNestedMessageName(containing_type); - if (!prefix.empty()) { - prefix += "."; - } - return prefix; -} - -// Returns the fully normalized JavaScript path prefix for the given -// message descriptor. -std::string GetMessagePathPrefix(const GeneratorOptions& options, - const Descriptor* descriptor) { - return GetPrefix(options, descriptor->file(), descriptor->containing_type()); -} - -// Returns the fully normalized JavaScript path for the given -// message descriptor. -std::string GetMessagePath(const GeneratorOptions& options, - const Descriptor* descriptor) { - return GetMessagePathPrefix(options, descriptor) + descriptor->name(); -} - -// Returns the fully normalized JavaScript path prefix for the given -// enumeration descriptor. -std::string GetEnumPathPrefix(const GeneratorOptions& options, - const EnumDescriptor* enum_descriptor) { - return GetPrefix(options, enum_descriptor->file(), - enum_descriptor->containing_type()); -} - -// Returns the fully normalized JavaScript path for the given -// enumeration descriptor. -std::string GetEnumPath(const GeneratorOptions& options, - const EnumDescriptor* enum_descriptor) { - return GetEnumPathPrefix(options, enum_descriptor) + enum_descriptor->name(); -} - -std::string MaybeCrossFileRef(const GeneratorOptions& options, - const FileDescriptor* from_file, - const Descriptor* to_message) { - if ((options.import_style == GeneratorOptions::kImportCommonJs || - options.import_style == GeneratorOptions::kImportCommonJsStrict) && - from_file != to_message->file()) { - // Cross-file ref in CommonJS needs to use the module alias instead of - // the global name. - return ModuleAlias(to_message->file()->name()) + - GetNestedMessageName(to_message->containing_type()) + "." + - to_message->name(); - } else { - // Within a single file we use a full name. - return GetMessagePath(options, to_message); - } -} - -std::string SubmessageTypeRef(const GeneratorOptions& options, - const FieldDescriptor* field) { - GOOGLE_CHECK(field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE); - return MaybeCrossFileRef(options, field->file(), field->message_type()); -} - -// - Object field name: LOWER_UNDERSCORE -> LOWER_CAMEL, except for group fields -// (UPPER_CAMEL -> LOWER_CAMEL), with "List" (or "Map") appended if appropriate, -// and with reserved words triggering a "pb_" prefix. -// - Getters/setters: LOWER_UNDERSCORE -> UPPER_CAMEL, except for group fields -// (use the name directly), then append "List" if appropriate, then append "$" -// if resulting name is equal to a reserved word. -// - Enums: just uppercase. - -// Locale-independent version of ToLower that deals only with ASCII A-Z. -char ToLowerASCII(char c) { - if (c >= 'A' && c <= 'Z') { - return (c - 'A') + 'a'; - } else { - return c; - } -} - -std::vector<std::string> ParseLowerUnderscore(const std::string& input) { - std::vector<std::string> words; - std::string running = ""; - for (int i = 0; i < input.size(); i++) { - if (input[i] == '_') { - if (!running.empty()) { - words.push_back(running); - running.clear(); - } - } else { - running += ToLowerASCII(input[i]); - } - } - if (!running.empty()) { - words.push_back(running); - } - return words; -} - -std::vector<std::string> ParseUpperCamel(const std::string& input) { - std::vector<std::string> words; - std::string running = ""; - for (int i = 0; i < input.size(); i++) { - if (input[i] >= 'A' && input[i] <= 'Z' && !running.empty()) { - words.push_back(running); - running.clear(); - } - running += ToLowerASCII(input[i]); - } - if (!running.empty()) { - words.push_back(running); - } - return words; -} - -std::string ToLowerCamel(const std::vector<std::string>& words) { - std::string result; - for (int i = 0; i < words.size(); i++) { - std::string word = words[i]; - if (i == 0 && (word[0] >= 'A' && word[0] <= 'Z')) { - word[0] = (word[0] - 'A') + 'a'; - } else if (i != 0 && (word[0] >= 'a' && word[0] <= 'z')) { - word[0] = (word[0] - 'a') + 'A'; - } - result += word; - } - return result; -} - -std::string ToUpperCamel(const std::vector<std::string>& words) { - std::string result; - for (int i = 0; i < words.size(); i++) { - std::string word = words[i]; - if (word[0] >= 'a' && word[0] <= 'z') { - word[0] = (word[0] - 'a') + 'A'; - } - result += word; - } - return result; -} - -// Based on code from descriptor.cc (Thanks Kenton!) -// Uppercases the entire string, turning ValueName into -// VALUENAME. -std::string ToEnumCase(const std::string& input) { - std::string result; - result.reserve(input.size()); - - for (int i = 0; i < input.size(); i++) { - if ('a' <= input[i] && input[i] <= 'z') { - result.push_back(input[i] - 'a' + 'A'); - } else { - result.push_back(input[i]); - } - } - - return result; -} - -std::string ToLower(const std::string& input) { - std::string result; - result.reserve(input.size()); - - for (int i = 0; i < input.size(); i++) { - if ('A' <= input[i] && input[i] <= 'Z') { - result.push_back(input[i] - 'A' + 'a'); - } else { - result.push_back(input[i]); - } - } - - return result; -} - -// When we're generating one output file per SCC, this is the filename -// that top-level extensions should go in. -// e.g. one proto file (test.proto): -// package a; -// extends Foo { -// ... -// } -// If "with_filename" equals true, the extension filename will be -// "proto.a_test_extensions.js", otherwise will be "proto.a.js" -std::string GetExtensionFileName(const GeneratorOptions& options, - const FileDescriptor* file, - bool with_filename) { - std::string snake_name = StripProto(GetSnakeFilename(file->name())); - return options.output_dir + "/" + ToLower(GetNamespace(options, file)) + - (with_filename ? ("_" + snake_name + "_extensions") : "") + - options.GetFileNameExtension(); -} -// When we're generating one output file per SCC, this is the filename -// that all messages in the SCC should go in. -// If with_package equals true, filename will have package prefix, -// If the filename length is longer than 200, the filename will be the -// SCC's proto filename with suffix "_long_sccs_(index)" (if with_package equals -// true it still has package prefix) -std::string GetMessagesFileName(const GeneratorOptions& options, const SCC* scc, - bool with_package) { - static std::map<const Descriptor*, std::string>* long_name_dict = - new std::map<const Descriptor*, std::string>(); - std::string package_base = - with_package - ? ToLower(GetNamespace(options, scc->GetRepresentative()->file()) + - "_") - : ""; - std::string filename_base = ""; - std::vector<std::string> all_message_names; - for (auto one_desc : scc->descriptors) { - if (one_desc->containing_type() == nullptr) { - all_message_names.push_back(ToLower(one_desc->name())); - } - } - sort(all_message_names.begin(), all_message_names.end()); - for (auto one_message : all_message_names) { - if (!filename_base.empty()) { - filename_base += "_"; - } - filename_base += one_message; - } - if (filename_base.size() + package_base.size() > 200) { - if ((*long_name_dict).find(scc->GetRepresentative()) == - (*long_name_dict).end()) { - std::string snake_name = StripProto( - GetSnakeFilename(scc->GetRepresentative()->file()->name())); - (*long_name_dict)[scc->GetRepresentative()] = - StrCat(snake_name, "_long_sccs_", - static_cast<uint64>((*long_name_dict).size())); - } - filename_base = (*long_name_dict)[scc->GetRepresentative()]; - } - return options.output_dir + "/" + package_base + filename_base + - options.GetFileNameExtension(); -} - -// When we're generating one output file per type name, this is the filename -// that a top-level enum should go in. -// If with_package equals true, filename will have package prefix. -std::string GetEnumFileName(const GeneratorOptions& options, - const EnumDescriptor* desc, bool with_package) { - return options.output_dir + "/" + - (with_package ? ToLower(GetNamespace(options, desc->file()) + "_") - : "") + - ToLower(desc->name()) + options.GetFileNameExtension(); -} - -// Returns the message/response ID, if set. -std::string GetMessageId(const Descriptor* desc) { return std::string(); } - -bool IgnoreExtensionField(const FieldDescriptor* field) { - // Exclude descriptor extensions from output "to avoid clutter" (from original - // codegen). - if (!field->is_extension()) return false; - const FileDescriptor* file = field->containing_type()->file(); - return file->name() == "net/proto2/proto/descriptor.proto" || - file->name() == "google/protobuf/descriptor.proto"; -} - -// Used inside Google only -- do not remove. -bool IsResponse(const Descriptor* desc) { return false; } - -bool IgnoreField(const FieldDescriptor* field) { - return IgnoreExtensionField(field); -} - -// Do we ignore this message type? -bool IgnoreMessage(const Descriptor* d) { return d->options().map_entry(); } - -// Does JSPB ignore this entire oneof? True only if all fields are ignored. -bool IgnoreOneof(const OneofDescriptor* oneof) { - if (oneof->is_synthetic()) return true; - for (int i = 0; i < oneof->field_count(); i++) { - if (!IgnoreField(oneof->field(i))) { - return false; - } - } - return true; -} - -std::string JSIdent(const GeneratorOptions& options, - const FieldDescriptor* field, bool is_upper_camel, - bool is_map, bool drop_list) { - std::string result; - if (field->type() == FieldDescriptor::TYPE_GROUP) { - result = is_upper_camel - ? ToUpperCamel(ParseUpperCamel(field->message_type()->name())) - : ToLowerCamel(ParseUpperCamel(field->message_type()->name())); - } else { - result = is_upper_camel ? ToUpperCamel(ParseLowerUnderscore(field->name())) - : ToLowerCamel(ParseLowerUnderscore(field->name())); - } - if (is_map || field->is_map()) { - // JSPB-style or proto3-style map. - result += "Map"; - } else if (!drop_list && field->is_repeated()) { - // Repeated field. - result += "List"; - } - return result; -} - -std::string JSObjectFieldName(const GeneratorOptions& options, - const FieldDescriptor* field) { - std::string name = JSIdent(options, field, - /* is_upper_camel = */ false, - /* is_map = */ false, - /* drop_list = */ false); - if (IsReserved(name)) { - name = "pb_" + name; - } - return name; -} - -std::string JSByteGetterSuffix(BytesMode bytes_mode) { - switch (bytes_mode) { - case BYTES_DEFAULT: - return ""; - case BYTES_B64: - return "B64"; - case BYTES_U8: - return "U8"; - default: - assert(false); - } - return ""; -} - -// Returns the field name as a capitalized portion of a getter/setter method -// name, e.g. MyField for .getMyField(). -std::string JSGetterName(const GeneratorOptions& options, - const FieldDescriptor* field, - BytesMode bytes_mode = BYTES_DEFAULT, - bool drop_list = false) { - std::string name = JSIdent(options, field, - /* is_upper_camel = */ true, - /* is_map = */ false, drop_list); - if (field->type() == FieldDescriptor::TYPE_BYTES) { - std::string suffix = JSByteGetterSuffix(bytes_mode); - if (!suffix.empty()) { - name += "_as" + suffix; - } - } - if (name == "Extension" || name == "JsPbMessageId") { - // Avoid conflicts with base-class names. - name += "$"; - } - return name; -} - -std::string JSOneofName(const OneofDescriptor* oneof) { - return ToUpperCamel(ParseLowerUnderscore(oneof->name())); -} - -// Returns the index corresponding to this field in the JSPB array (underlying -// data storage array). -std::string JSFieldIndex(const FieldDescriptor* field) { - // Determine whether this field is a member of a group. Group fields are a bit - // wonky: their "containing type" is a message type created just for the - // group, and that type's parent type has a field with the group-message type - // as its message type and TYPE_GROUP as its field type. For such fields, the - // index we use is relative to the field number of the group submessage field. - // For all other fields, we just use the field number. - const Descriptor* containing_type = field->containing_type(); - const Descriptor* parent_type = containing_type->containing_type(); - if (parent_type != NULL) { - for (int i = 0; i < parent_type->field_count(); i++) { - if (parent_type->field(i)->type() == FieldDescriptor::TYPE_GROUP && - parent_type->field(i)->message_type() == containing_type) { - return StrCat(field->number() - parent_type->field(i)->number()); - } - } - } - return StrCat(field->number()); -} - -std::string JSOneofIndex(const OneofDescriptor* oneof) { - int index = -1; - for (int i = 0; i < oneof->containing_type()->oneof_decl_count(); i++) { - const OneofDescriptor* o = oneof->containing_type()->oneof_decl(i); - if (o->is_synthetic()) continue; - // If at least one field in this oneof is not JSPB-ignored, count the oneof. - for (int j = 0; j < o->field_count(); j++) { - const FieldDescriptor* f = o->field(j); - if (!IgnoreField(f)) { - index++; - break; // inner loop - } - } - if (o == oneof) { - break; - } - } - return StrCat(index); -} - -// Decodes a codepoint in \x0000 -- \xFFFF. -uint16 DecodeUTF8Codepoint(uint8* bytes, size_t* length) { - if (*length == 0) { - return 0; - } - size_t expected = 0; - if ((*bytes & 0x80) == 0) { - expected = 1; - } else if ((*bytes & 0xe0) == 0xc0) { - expected = 2; - } else if ((*bytes & 0xf0) == 0xe0) { - expected = 3; - } else { - // Too long -- don't accept. - *length = 0; - return 0; - } - - if (*length < expected) { - // Not enough bytes -- don't accept. - *length = 0; - return 0; - } - - *length = expected; - switch (expected) { - case 1: - return bytes[0]; - case 2: - return ((bytes[0] & 0x1F) << 6) | ((bytes[1] & 0x3F) << 0); - case 3: - return ((bytes[0] & 0x0F) << 12) | ((bytes[1] & 0x3F) << 6) | - ((bytes[2] & 0x3F) << 0); - default: - return 0; - } -} - -// Escapes the contents of a string to be included within double-quotes ("") in -// JavaScript. The input data should be a UTF-8 encoded C++ string of chars. -// Returns false if |out| was truncated because |in| contained invalid UTF-8 or -// codepoints outside the BMP. -// TODO(b/115551870): Support codepoints outside the BMP. -bool EscapeJSString(const std::string& in, std::string* out) { - size_t decoded = 0; - for (size_t i = 0; i < in.size(); i += decoded) { - uint16 codepoint = 0; - // Decode the next UTF-8 codepoint. - size_t have_bytes = in.size() - i; - uint8 bytes[3] = { - static_cast<uint8>(in[i]), - static_cast<uint8>(((i + 1) < in.size()) ? in[i + 1] : 0), - static_cast<uint8>(((i + 2) < in.size()) ? in[i + 2] : 0), - }; - codepoint = DecodeUTF8Codepoint(bytes, &have_bytes); - if (have_bytes == 0) { - return false; - } - decoded = have_bytes; - - switch (codepoint) { - case '\'': - *out += "\\x27"; - break; - case '"': - *out += "\\x22"; - break; - case '<': - *out += "\\x3c"; - break; - case '=': - *out += "\\x3d"; - break; - case '>': - *out += "\\x3e"; - break; - case '&': - *out += "\\x26"; - break; - case '\b': - *out += "\\b"; - break; - case '\t': - *out += "\\t"; - break; - case '\n': - *out += "\\n"; - break; - case '\f': - *out += "\\f"; - break; - case '\r': - *out += "\\r"; - break; - case '\\': - *out += "\\\\"; - break; - default: - // TODO(b/115551870): Once we're supporting codepoints outside the BMP, - // use a single Unicode codepoint escape if the output language is - // ECMAScript 2015 or above. Otherwise, use a surrogate pair. - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#String_literals - if (codepoint >= 0x20 && codepoint <= 0x7e) { - *out += static_cast<char>(codepoint); - } else if (codepoint >= 0x100) { - *out += StringPrintf("\\u%04x", codepoint); - } else { - *out += StringPrintf("\\x%02x", codepoint); - } - break; - } - } - return true; -} - -std::string EscapeBase64(const std::string& in) { - static const char* kAlphabet = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - std::string result; - - for (size_t i = 0; i < in.size(); i += 3) { - int value = (in[i] << 16) | (((i + 1) < in.size()) ? (in[i + 1] << 8) : 0) | - (((i + 2) < in.size()) ? (in[i + 2] << 0) : 0); - result += kAlphabet[(value >> 18) & 0x3f]; - result += kAlphabet[(value >> 12) & 0x3f]; - if ((i + 1) < in.size()) { - result += kAlphabet[(value >> 6) & 0x3f]; - } else { - result += '='; - } - if ((i + 2) < in.size()) { - result += kAlphabet[(value >> 0) & 0x3f]; - } else { - result += '='; - } - } - - return result; -} - -// Post-process the result of SimpleFtoa/SimpleDtoa to *exactly* match the -// original codegen's formatting (which is just .toString() on java.lang.Double -// or java.lang.Float). -std::string PostProcessFloat(std::string result) { - // If inf, -inf or nan, replace with +Infinity, -Infinity or NaN. - if (result == "inf") { - return "Infinity"; - } else if (result == "-inf") { - return "-Infinity"; - } else if (result == "nan") { - return "NaN"; - } - - // If scientific notation (e.g., "1e10"), (i) capitalize the "e", (ii) - // ensure that the mantissa (portion prior to the "e") has at least one - // fractional digit (after the decimal point), and (iii) strip any unnecessary - // leading zeroes and/or '+' signs from the exponent. - std::string::size_type exp_pos = result.find('e'); - if (exp_pos != std::string::npos) { - std::string mantissa = result.substr(0, exp_pos); - std::string exponent = result.substr(exp_pos + 1); - - // Add ".0" to mantissa if no fractional part exists. - if (mantissa.find('.') == std::string::npos) { - mantissa += ".0"; - } - - // Strip the sign off the exponent and store as |exp_neg|. - bool exp_neg = false; - if (!exponent.empty() && exponent[0] == '+') { - exponent = exponent.substr(1); - } else if (!exponent.empty() && exponent[0] == '-') { - exp_neg = true; - exponent = exponent.substr(1); - } - - // Strip any leading zeroes off the exponent. - while (exponent.size() > 1 && exponent[0] == '0') { - exponent = exponent.substr(1); - } - - return mantissa + "E" + std::string(exp_neg ? "-" : "") + exponent; - } - - // Otherwise, this is an ordinary decimal number. Append ".0" if result has no - // decimal/fractional part in order to match output of original codegen. - if (result.find('.') == std::string::npos) { - result += ".0"; - } - - return result; -} - -std::string FloatToString(float value) { - std::string result = SimpleFtoa(value); - return PostProcessFloat(result); -} - -std::string DoubleToString(double value) { - std::string result = SimpleDtoa(value); - return PostProcessFloat(result); -} - -bool InRealOneof(const FieldDescriptor* field) { - return field->containing_oneof() && - !field->containing_oneof()->is_synthetic(); -} - -// Return true if this is an integral field that should be represented as string -// in JS. -bool IsIntegralFieldWithStringJSType(const FieldDescriptor* field) { - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT64: - case FieldDescriptor::CPPTYPE_UINT64: - // The default value of JSType is JS_NORMAL, which behaves the same as - // JS_NUMBER. - return field->options().jstype() == FieldOptions::JS_STRING; - default: - return false; - } -} - -std::string MaybeNumberString(const FieldDescriptor* field, - const std::string& orig) { - return IsIntegralFieldWithStringJSType(field) ? ("\"" + orig + "\"") : orig; -} - -std::string JSFieldDefault(const FieldDescriptor* field) { - if (field->is_repeated()) { - return "[]"; - } - - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32: - return MaybeNumberString(field, StrCat(field->default_value_int32())); - case FieldDescriptor::CPPTYPE_UINT32: - // The original codegen is in Java, and Java protobufs store unsigned - // integer values as signed integer values. In order to exactly match the - // output, we need to reinterpret as base-2 signed. Ugh. - return MaybeNumberString( - field, StrCat(static_cast<int32>(field->default_value_uint32()))); - case FieldDescriptor::CPPTYPE_INT64: - return MaybeNumberString(field, StrCat(field->default_value_int64())); - case FieldDescriptor::CPPTYPE_UINT64: - // See above note for uint32 -- reinterpreting as signed. - return MaybeNumberString( - field, StrCat(static_cast<int64>(field->default_value_uint64()))); - case FieldDescriptor::CPPTYPE_ENUM: - return StrCat(field->default_value_enum()->number()); - case FieldDescriptor::CPPTYPE_BOOL: - return field->default_value_bool() ? "true" : "false"; - case FieldDescriptor::CPPTYPE_FLOAT: - return FloatToString(field->default_value_float()); - case FieldDescriptor::CPPTYPE_DOUBLE: - return DoubleToString(field->default_value_double()); - case FieldDescriptor::CPPTYPE_STRING: - if (field->type() == FieldDescriptor::TYPE_STRING) { - std::string out; - bool is_valid = EscapeJSString(field->default_value_string(), &out); - if (!is_valid) { - // TODO(b/115551870): Decide whether this should be a hard error. - GOOGLE_LOG(WARNING) - << "The default value for field " << field->full_name() - << " was truncated since it contained invalid UTF-8 or" - " codepoints outside the basic multilingual plane."; - } - return "\"" + out + "\""; - } else { // Bytes - return "\"" + EscapeBase64(field->default_value_string()) + "\""; - } - case FieldDescriptor::CPPTYPE_MESSAGE: - return "null"; - } - GOOGLE_LOG(FATAL) << "Shouldn't reach here."; - return ""; -} - -std::string ProtoTypeName(const GeneratorOptions& options, - const FieldDescriptor* field) { - switch (field->type()) { - case FieldDescriptor::TYPE_BOOL: - return "bool"; - case FieldDescriptor::TYPE_INT32: - return "int32"; - case FieldDescriptor::TYPE_UINT32: - return "uint32"; - case FieldDescriptor::TYPE_SINT32: - return "sint32"; - case FieldDescriptor::TYPE_FIXED32: - return "fixed32"; - case FieldDescriptor::TYPE_SFIXED32: - return "sfixed32"; - case FieldDescriptor::TYPE_INT64: - return "int64"; - case FieldDescriptor::TYPE_UINT64: - return "uint64"; - case FieldDescriptor::TYPE_SINT64: - return "sint64"; - case FieldDescriptor::TYPE_FIXED64: - return "fixed64"; - case FieldDescriptor::TYPE_SFIXED64: - return "sfixed64"; - case FieldDescriptor::TYPE_FLOAT: - return "float"; - case FieldDescriptor::TYPE_DOUBLE: - return "double"; - case FieldDescriptor::TYPE_STRING: - return "string"; - case FieldDescriptor::TYPE_BYTES: - return "bytes"; - case FieldDescriptor::TYPE_GROUP: - return GetMessagePath(options, field->message_type()); - case FieldDescriptor::TYPE_ENUM: - return GetEnumPath(options, field->enum_type()); - case FieldDescriptor::TYPE_MESSAGE: - return GetMessagePath(options, field->message_type()); - default: - return ""; - } -} - -std::string JSIntegerTypeName(const FieldDescriptor* field) { - return IsIntegralFieldWithStringJSType(field) ? "string" : "number"; -} - -std::string JSStringTypeName(const GeneratorOptions& options, - const FieldDescriptor* field, - BytesMode bytes_mode) { - if (field->type() == FieldDescriptor::TYPE_BYTES) { - switch (bytes_mode) { - case BYTES_DEFAULT: - return "(string|Uint8Array)"; - case BYTES_B64: - return "string"; - case BYTES_U8: - return "Uint8Array"; - default: - assert(false); - } - } - return "string"; -} - -std::string JSTypeName(const GeneratorOptions& options, - const FieldDescriptor* field, BytesMode bytes_mode) { - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_BOOL: - return "boolean"; - case FieldDescriptor::CPPTYPE_INT32: - return JSIntegerTypeName(field); - case FieldDescriptor::CPPTYPE_INT64: - return JSIntegerTypeName(field); - case FieldDescriptor::CPPTYPE_UINT32: - return JSIntegerTypeName(field); - case FieldDescriptor::CPPTYPE_UINT64: - return JSIntegerTypeName(field); - case FieldDescriptor::CPPTYPE_FLOAT: - return "number"; - case FieldDescriptor::CPPTYPE_DOUBLE: - return "number"; - case FieldDescriptor::CPPTYPE_STRING: - return JSStringTypeName(options, field, bytes_mode); - case FieldDescriptor::CPPTYPE_ENUM: - return GetEnumPath(options, field->enum_type()); - case FieldDescriptor::CPPTYPE_MESSAGE: - return GetMessagePath(options, field->message_type()); - default: - return ""; - } -} - -// Used inside Google only -- do not remove. -bool UseBrokenPresenceSemantics(const GeneratorOptions& options, - const FieldDescriptor* field) { - return false; -} - -// Returns true for fields that return "null" from accessors when they are -// unset. This should normally only be true for non-repeated submessages, but we -// have legacy users who relied on old behavior where accessors behaved this -// way. -bool ReturnsNullWhenUnset(const GeneratorOptions& options, - const FieldDescriptor* field) { - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - field->is_optional()) { - return true; - } - - // TODO(haberman): remove this case and unconditionally return false. - return UseBrokenPresenceSemantics(options, field) && !field->is_repeated() && - !field->has_default_value(); -} - -// In a sane world, this would be the same as ReturnsNullWhenUnset(). But in -// the status quo, some fields declare that they never return null/undefined -// even though they actually do: -// * required fields -// * optional enum fields -// * proto3 primitive fields. -bool DeclaredReturnTypeIsNullable(const GeneratorOptions& options, - const FieldDescriptor* field) { - if (field->is_required() || field->type() == FieldDescriptor::TYPE_ENUM) { - return false; - } - - if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 && - field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { - return false; - } - - return ReturnsNullWhenUnset(options, field); -} - -bool SetterAcceptsUndefined(const GeneratorOptions& options, - const FieldDescriptor* field) { - if (ReturnsNullWhenUnset(options, field)) { - return true; - } - - // Broken presence semantics always accepts undefined for setters. - return UseBrokenPresenceSemantics(options, field); -} - -bool SetterAcceptsNull(const GeneratorOptions& options, - const FieldDescriptor* field) { - if (ReturnsNullWhenUnset(options, field)) { - return true; - } - - // With broken presence semantics, fields with defaults accept "null" for - // setters, but other fields do not. This is a strange quirk of the old - // codegen. - return UseBrokenPresenceSemantics(options, field) && - field->has_default_value(); -} - -// Returns types which are known to by non-nullable by default. -// The style guide requires that we omit "!" in this case. -bool IsPrimitive(const std::string& type) { - return type == "undefined" || type == "string" || type == "number" || - type == "boolean"; -} - -std::string JSFieldTypeAnnotation(const GeneratorOptions& options, - const FieldDescriptor* field, - bool is_setter_argument, bool force_present, - bool singular_if_not_packed, - BytesMode bytes_mode = BYTES_DEFAULT, - bool force_singular = false) { - std::string jstype = JSTypeName(options, field, bytes_mode); - - if (!force_singular && field->is_repeated() && - (field->is_packed() || !singular_if_not_packed)) { - if (field->type() == FieldDescriptor::TYPE_BYTES && - bytes_mode == BYTES_DEFAULT) { - jstype = "(Array<!Uint8Array>|Array<string>)"; - } else { - if (!IsPrimitive(jstype)) { - jstype = "!" + jstype; - } - jstype = "Array<" + jstype + ">"; - } - } - - bool is_null_or_undefined = false; - - if (is_setter_argument) { - if (SetterAcceptsNull(options, field)) { - jstype = "?" + jstype; - is_null_or_undefined = true; - } - - if (SetterAcceptsUndefined(options, field)) { - jstype += "|undefined"; - is_null_or_undefined = true; - } - } else if (force_present) { - // Don't add null or undefined. - } else { - if (DeclaredReturnTypeIsNullable(options, field)) { - jstype = "?" + jstype; - is_null_or_undefined = true; - } - } - - if (!is_null_or_undefined && !IsPrimitive(jstype)) { - jstype = "!" + jstype; - } - - return jstype; -} - -std::string JSBinaryReaderMethodType(const FieldDescriptor* field) { - std::string name = field->type_name(); - if (name[0] >= 'a' && name[0] <= 'z') { - name[0] = (name[0] - 'a') + 'A'; - } - return IsIntegralFieldWithStringJSType(field) ? (name + "String") : name; -} - -std::string JSBinaryReadWriteMethodName(const FieldDescriptor* field, - bool is_writer) { - std::string name = JSBinaryReaderMethodType(field); - if (field->is_packed()) { - name = "Packed" + name; - } else if (is_writer && field->is_repeated()) { - name = "Repeated" + name; - } - return name; -} - -std::string JSBinaryReaderMethodName(const GeneratorOptions& options, - const FieldDescriptor* field) { - return "jspb.BinaryReader.prototype.read" + - JSBinaryReadWriteMethodName(field, /* is_writer = */ false); -} - -std::string JSBinaryWriterMethodName(const GeneratorOptions& options, - const FieldDescriptor* field) { - if (field->containing_type() && - field->containing_type()->options().message_set_wire_format()) { - return "jspb.BinaryWriter.prototype.writeMessageSet"; - } - return "jspb.BinaryWriter.prototype.write" + - JSBinaryReadWriteMethodName(field, /* is_writer = */ true); -} - -std::string JSTypeTag(const FieldDescriptor* desc) { - switch (desc->type()) { - case FieldDescriptor::TYPE_DOUBLE: - case FieldDescriptor::TYPE_FLOAT: - return "Float"; - case FieldDescriptor::TYPE_INT32: - case FieldDescriptor::TYPE_UINT32: - case FieldDescriptor::TYPE_INT64: - case FieldDescriptor::TYPE_UINT64: - case FieldDescriptor::TYPE_FIXED32: - case FieldDescriptor::TYPE_FIXED64: - case FieldDescriptor::TYPE_SINT32: - case FieldDescriptor::TYPE_SINT64: - case FieldDescriptor::TYPE_SFIXED32: - case FieldDescriptor::TYPE_SFIXED64: - if (IsIntegralFieldWithStringJSType(desc)) { - return "StringInt"; - } else { - return "Int"; - } - case FieldDescriptor::TYPE_BOOL: - return "Boolean"; - case FieldDescriptor::TYPE_STRING: - return "String"; - case FieldDescriptor::TYPE_BYTES: - return "Bytes"; - case FieldDescriptor::TYPE_ENUM: - return "Enum"; - default: - assert(false); - } - return ""; -} - -bool HasRepeatedFields(const GeneratorOptions& options, - const Descriptor* desc) { - for (int i = 0; i < desc->field_count(); i++) { - if (desc->field(i)->is_repeated() && !desc->field(i)->is_map()) { - return true; - } - } - return false; -} - -static const char* kRepeatedFieldArrayName = ".repeatedFields_"; - -std::string RepeatedFieldsArrayName(const GeneratorOptions& options, - const Descriptor* desc) { - return HasRepeatedFields(options, desc) - ? (GetMessagePath(options, desc) + kRepeatedFieldArrayName) - : "null"; -} - -bool HasOneofFields(const Descriptor* desc) { - for (int i = 0; i < desc->field_count(); i++) { - if (InRealOneof(desc->field(i))) { - return true; - } - } - return false; -} - -static const char* kOneofGroupArrayName = ".oneofGroups_"; - -std::string OneofFieldsArrayName(const GeneratorOptions& options, - const Descriptor* desc) { - return HasOneofFields(desc) - ? (GetMessagePath(options, desc) + kOneofGroupArrayName) - : "null"; -} - -std::string RepeatedFieldNumberList(const GeneratorOptions& options, - const Descriptor* desc) { - std::vector<std::string> numbers; - for (int i = 0; i < desc->field_count(); i++) { - if (desc->field(i)->is_repeated() && !desc->field(i)->is_map()) { - numbers.push_back(JSFieldIndex(desc->field(i))); - } - } - return "[" + Join(numbers, ",") + "]"; -} - -std::string OneofGroupList(const Descriptor* desc) { - // List of arrays (one per oneof), each of which is a list of field indices - std::vector<std::string> oneof_entries; - for (int i = 0; i < desc->oneof_decl_count(); i++) { - const OneofDescriptor* oneof = desc->oneof_decl(i); - if (IgnoreOneof(oneof)) { - continue; - } - - std::vector<std::string> oneof_fields; - for (int j = 0; j < oneof->field_count(); j++) { - if (IgnoreField(oneof->field(j))) { - continue; - } - oneof_fields.push_back(JSFieldIndex(oneof->field(j))); - } - oneof_entries.push_back("[" + Join(oneof_fields, ",") + "]"); - } - return "[" + Join(oneof_entries, ",") + "]"; -} - -std::string JSOneofArray(const GeneratorOptions& options, - const FieldDescriptor* field) { - return OneofFieldsArrayName(options, field->containing_type()) + "[" + - JSOneofIndex(field->containing_oneof()) + "]"; -} - -std::string RelativeTypeName(const FieldDescriptor* field) { - assert(field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM || - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE); - // For a field with an enum or message type, compute a name relative to the - // path name of the message type containing this field. - std::string package = field->file()->package(); - std::string containing_type = field->containing_type()->full_name() + "."; - std::string type = (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) - ? field->enum_type()->full_name() - : field->message_type()->full_name(); - - // |prefix| is advanced as we find separators '.' past the common package - // prefix that yield common prefixes in the containing type's name and this - // type's name. - int prefix = 0; - for (int i = 0; i < type.size() && i < containing_type.size(); i++) { - if (type[i] != containing_type[i]) { - break; - } - if (type[i] == '.' && i >= package.size()) { - prefix = i + 1; - } - } - - return type.substr(prefix); -} - -std::string JSExtensionsObjectName(const GeneratorOptions& options, - const FileDescriptor* from_file, - const Descriptor* desc) { - if (desc->full_name() == "google.protobuf.bridge.MessageSet") { - // TODO(haberman): fix this for the kImportCommonJs case. - return "jspb.Message.messageSetExtensions"; - } else { - return MaybeCrossFileRef(options, from_file, desc) + ".extensions"; - } -} - -static const int kMapKeyField = 1; -static const int kMapValueField = 2; - -const FieldDescriptor* MapFieldKey(const FieldDescriptor* field) { - assert(field->is_map()); - return field->message_type()->FindFieldByNumber(kMapKeyField); -} - -const FieldDescriptor* MapFieldValue(const FieldDescriptor* field) { - assert(field->is_map()); - return field->message_type()->FindFieldByNumber(kMapValueField); -} - -std::string FieldDefinition(const GeneratorOptions& options, - const FieldDescriptor* field) { - if (field->is_map()) { - const FieldDescriptor* key_field = MapFieldKey(field); - const FieldDescriptor* value_field = MapFieldValue(field); - std::string key_type = ProtoTypeName(options, key_field); - std::string value_type; - if (value_field->type() == FieldDescriptor::TYPE_ENUM || - value_field->type() == FieldDescriptor::TYPE_MESSAGE) { - value_type = RelativeTypeName(value_field); - } else { - value_type = ProtoTypeName(options, value_field); - } - return StringPrintf("map<%s, %s> %s = %d;", key_type.c_str(), - value_type.c_str(), field->name().c_str(), - field->number()); - } else { - std::string qualifier = - field->is_repeated() ? "repeated" - : (field->is_optional() ? "optional" : "required"); - std::string type, name; - if (field->type() == FieldDescriptor::TYPE_ENUM || - field->type() == FieldDescriptor::TYPE_MESSAGE) { - type = RelativeTypeName(field); - name = field->name(); - } else if (field->type() == FieldDescriptor::TYPE_GROUP) { - type = "group"; - name = field->message_type()->name(); - } else { - type = ProtoTypeName(options, field); - name = field->name(); - } - return StringPrintf("%s %s %s = %d;", qualifier.c_str(), type.c_str(), - name.c_str(), field->number()); - } -} - -std::string FieldComments(const FieldDescriptor* field, BytesMode bytes_mode) { - std::string comments; - if (field->type() == FieldDescriptor::TYPE_BYTES && bytes_mode == BYTES_U8) { - comments += - " * Note that Uint8Array is not supported on all browsers.\n" - " * @see http://caniuse.com/Uint8Array\n"; - } - return comments; -} - -bool ShouldGenerateExtension(const FieldDescriptor* field) { - return field->is_extension() && !IgnoreField(field); -} - -bool HasExtensions(const Descriptor* desc) { - for (int i = 0; i < desc->extension_count(); i++) { - if (ShouldGenerateExtension(desc->extension(i))) { - return true; - } - } - for (int i = 0; i < desc->nested_type_count(); i++) { - if (HasExtensions(desc->nested_type(i))) { - return true; - } - } - return false; -} - -bool HasExtensions(const FileDescriptor* file) { - for (int i = 0; i < file->extension_count(); i++) { - if (ShouldGenerateExtension(file->extension(i))) { - return true; - } - } - for (int i = 0; i < file->message_type_count(); i++) { - if (HasExtensions(file->message_type(i))) { - return true; - } - } - return false; -} - -bool HasMap(const GeneratorOptions& options, const Descriptor* desc) { - for (int i = 0; i < desc->field_count(); i++) { - if (desc->field(i)->is_map()) { - return true; - } - } - for (int i = 0; i < desc->nested_type_count(); i++) { - if (HasMap(options, desc->nested_type(i))) { - return true; - } - } - return false; -} - -bool FileHasMap(const GeneratorOptions& options, const FileDescriptor* desc) { - for (int i = 0; i < desc->message_type_count(); i++) { - if (HasMap(options, desc->message_type(i))) { - return true; - } - } - return false; -} - -bool IsExtendable(const Descriptor* desc) { - return desc->extension_range_count() > 0; -} - -// Returns the max index in the underlying data storage array beyond which the -// extension object is used. -std::string GetPivot(const Descriptor* desc) { - static const int kDefaultPivot = 500; - - // Find the max field number - int max_field_number = 0; - for (int i = 0; i < desc->field_count(); i++) { - if (!IgnoreField(desc->field(i)) && - desc->field(i)->number() > max_field_number) { - max_field_number = desc->field(i)->number(); - } - } - - int pivot = -1; - if (IsExtendable(desc) || (max_field_number >= kDefaultPivot)) { - pivot = ((max_field_number + 1) < kDefaultPivot) ? (max_field_number + 1) - : kDefaultPivot; - } - - return StrCat(pivot); -} - -// Whether this field represents presence. For fields with presence, we -// generate extra methods (clearFoo() and hasFoo()) for this field. -bool HasFieldPresence(const GeneratorOptions& options, - const FieldDescriptor* field) { - // This returns false for repeated fields and maps, but we still do - // generate clearFoo() methods for these through a special case elsewhere. - return field->has_presence(); -} - -// We use this to implement the semantics that same file can be generated -// multiple times, but only the last one keep the short name. Others all use -// long name with extra information to distinguish (For message and enum, the -// extra information is package name, for file level extension, the extra -// information is proto's filename). -// We never actually write the files, but we keep a set of which descriptors -// were the final one for a given filename. -class FileDeduplicator { - public: - explicit FileDeduplicator(const GeneratorOptions& options) {} - - // params: - // filenames: a pair of {short filename, full filename} - // (short filename don't have extra information, full filename - // contains extra information) - // desc: The Descriptor or SCC pointer or EnumDescriptor. - bool AddFile(const std::pair<std::string, std::string> filenames, - const void* desc) { - if (descs_by_shortname_.find(filenames.first) != - descs_by_shortname_.end()) { - // Change old pointer's actual name to full name. - auto short_name_desc = descs_by_shortname_[filenames.first]; - allowed_descs_actual_name_[short_name_desc] = - allowed_descs_full_name_[short_name_desc]; - } - descs_by_shortname_[filenames.first] = desc; - allowed_descs_actual_name_[desc] = filenames.first; - allowed_descs_full_name_[desc] = filenames.second; - - return true; - } - - void GetAllowedMap(std::map<const void*, std::string>* allowed_set) { - *allowed_set = allowed_descs_actual_name_; - } - - private: - // The map that restores all the descs that are using short name as filename. - std::map<std::string, const void*> descs_by_shortname_; - // The final actual filename map. - std::map<const void*, std::string> allowed_descs_actual_name_; - // The full name map. - std::map<const void*, std::string> allowed_descs_full_name_; -}; - -void DepthFirstSearch(const FileDescriptor* file, - std::vector<const FileDescriptor*>* list, - std::set<const FileDescriptor*>* seen) { - if (!seen->insert(file).second) { - return; - } - - // Add all dependencies. - for (int i = 0; i < file->dependency_count(); i++) { - DepthFirstSearch(file->dependency(i), list, seen); - } - - // Add this file. - list->push_back(file); -} - -// A functor for the predicate to remove_if() below. Returns true if a given -// FileDescriptor is not in the given set. -class NotInSet { - public: - explicit NotInSet(const std::set<const FileDescriptor*>& file_set) - : file_set_(file_set) {} - - bool operator()(const FileDescriptor* file) { - return file_set_.count(file) == 0; - } - - private: - const std::set<const FileDescriptor*>& file_set_; -}; - -// This function generates an ordering of the input FileDescriptors that matches -// the logic of the old code generator. The order is significant because two -// different input files can generate the same output file, and the last one -// needs to win. -void GenerateJspbFileOrder(const std::vector<const FileDescriptor*>& input, - std::vector<const FileDescriptor*>* ordered) { - // First generate an ordering of all reachable files (including dependencies) - // with depth-first search. This mimics the behavior of --include_imports, - // which is what the old codegen used. - ordered->clear(); - std::set<const FileDescriptor*> seen; - std::set<const FileDescriptor*> input_set; - for (int i = 0; i < input.size(); i++) { - DepthFirstSearch(input[i], ordered, &seen); - input_set.insert(input[i]); - } - - // Now remove the entries that are not actually in our input list. - ordered->erase( - std::remove_if(ordered->begin(), ordered->end(), NotInSet(input_set)), - ordered->end()); -} - -// If we're generating code in file-per-type mode, avoid overwriting files -// by choosing the last descriptor that writes each filename and permitting -// only those to generate code. - -struct DepsGenerator { - std::vector<const Descriptor*> operator()(const Descriptor* desc) const { - std::vector<const Descriptor*> deps; - auto maybe_add = [&](const Descriptor* d) { - if (d) deps.push_back(d); - }; - for (int i = 0; i < desc->field_count(); i++) { - if (!IgnoreField(desc->field(i))) { - maybe_add(desc->field(i)->message_type()); - } - } - for (int i = 0; i < desc->extension_count(); i++) { - maybe_add(desc->extension(i)->message_type()); - maybe_add(desc->extension(i)->containing_type()); - } - for (int i = 0; i < desc->nested_type_count(); i++) { - maybe_add(desc->nested_type(i)); - } - maybe_add(desc->containing_type()); - - return deps; - } -}; - -bool GenerateJspbAllowedMap(const GeneratorOptions& options, - const std::vector<const FileDescriptor*>& files, - std::map<const void*, std::string>* allowed_set, - SCCAnalyzer<DepsGenerator>* analyzer) { - std::vector<const FileDescriptor*> files_ordered; - GenerateJspbFileOrder(files, &files_ordered); - - // Choose the last descriptor for each filename. - FileDeduplicator dedup(options); - std::set<const SCC*> added; - for (int i = 0; i < files_ordered.size(); i++) { - for (int j = 0; j < files_ordered[i]->message_type_count(); j++) { - const Descriptor* desc = files_ordered[i]->message_type(j); - if (added.insert(analyzer->GetSCC(desc)).second && - !dedup.AddFile( - std::make_pair( - GetMessagesFileName(options, analyzer->GetSCC(desc), false), - GetMessagesFileName(options, analyzer->GetSCC(desc), true)), - analyzer->GetSCC(desc))) { - return false; - } - } - for (int j = 0; j < files_ordered[i]->enum_type_count(); j++) { - const EnumDescriptor* desc = files_ordered[i]->enum_type(j); - if (!dedup.AddFile(std::make_pair(GetEnumFileName(options, desc, false), - GetEnumFileName(options, desc, true)), - desc)) { - return false; - } - } - - // Pull out all free-floating extensions and generate files for those too. - bool has_extension = false; - - for (int j = 0; j < files_ordered[i]->extension_count(); j++) { - if (ShouldGenerateExtension(files_ordered[i]->extension(j))) { - has_extension = true; - } - } - - if (has_extension) { - if (!dedup.AddFile( - std::make_pair( - GetExtensionFileName(options, files_ordered[i], false), - GetExtensionFileName(options, files_ordered[i], true)), - files_ordered[i])) { - return false; - } - } - } - - dedup.GetAllowedMap(allowed_set); - - return true; -} - -// Embeds base64 encoded GeneratedCodeInfo proto in a comment at the end of -// file. -void EmbedCodeAnnotations(const GeneratedCodeInfo& annotations, - io::Printer* printer) { - // Serialize annotations proto into base64 string. - std::string meta_content; - annotations.SerializeToString(&meta_content); - std::string meta_64; - Base64Escape(meta_content, &meta_64); - - // Print base64 encoded annotations at the end of output file in - // a comment. - printer->Print("\n// Below is base64 encoded GeneratedCodeInfo proto"); - printer->Print("\n// $encoded_proto$\n", "encoded_proto", meta_64); -} - -bool IsWellKnownTypeFile(const FileDescriptor* file) { - return HasPrefixString(file->name(), "google/protobuf/"); -} - -} // anonymous namespace - -void Generator::GenerateHeader(const GeneratorOptions& options, - const FileDescriptor* file, - io::Printer* printer) const { - if (file != nullptr) { - printer->Print("// source: $filename$\n", "filename", file->name()); - } - printer->Print( - "/**\n" - " * @fileoverview\n" - " * @enhanceable\n" - // TODO(b/152440355): requireType/requires diverged from internal version. - " * @suppress {missingRequire} reports error on implicit type usages.\n" - " * @suppress {messageConventions} JS Compiler reports an " - "error if a variable or\n" - " * field starts with 'MSG_' and isn't a translatable " - "message.\n" - " * @public\n" - " */\n" - "// GENERATED CODE -- DO NOT EDIT!\n" - "/* eslint-disable */\n" - "// @ts-nocheck\n" - "\n"); -} - -void Generator::FindProvidesForFile(const GeneratorOptions& options, - io::Printer* printer, - const FileDescriptor* file, - std::set<std::string>* provided) const { - for (int i = 0; i < file->message_type_count(); i++) { - FindProvidesForMessage(options, printer, file->message_type(i), provided); - } - for (int i = 0; i < file->enum_type_count(); i++) { - FindProvidesForEnum(options, printer, file->enum_type(i), provided); - } -} - -void Generator::FindProvides(const GeneratorOptions& options, - io::Printer* printer, - const std::vector<const FileDescriptor*>& files, - std::set<std::string>* provided) const { - for (int i = 0; i < files.size(); i++) { - FindProvidesForFile(options, printer, files[i], provided); - } - - printer->Print("\n"); -} - -void FindProvidesForOneOfEnum(const GeneratorOptions& options, - const OneofDescriptor* oneof, - std::set<std::string>* provided) { - std::string name = GetMessagePath(options, oneof->containing_type()) + "." + - JSOneofName(oneof) + "Case"; - provided->insert(name); -} - -void FindProvidesForOneOfEnums(const GeneratorOptions& options, - io::Printer* printer, const Descriptor* desc, - std::set<std::string>* provided) { - if (HasOneofFields(desc)) { - for (int i = 0; i < desc->oneof_decl_count(); i++) { - if (IgnoreOneof(desc->oneof_decl(i))) { - continue; - } - FindProvidesForOneOfEnum(options, desc->oneof_decl(i), provided); - } - } -} - -void Generator::FindProvidesForMessage(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc, - std::set<std::string>* provided) const { - if (IgnoreMessage(desc)) { - return; - } - - std::string name = GetMessagePath(options, desc); - provided->insert(name); - - for (int i = 0; i < desc->enum_type_count(); i++) { - FindProvidesForEnum(options, printer, desc->enum_type(i), provided); - } - - FindProvidesForOneOfEnums(options, printer, desc, provided); - - for (int i = 0; i < desc->nested_type_count(); i++) { - FindProvidesForMessage(options, printer, desc->nested_type(i), provided); - } -} -void Generator::FindProvidesForEnum(const GeneratorOptions& options, - io::Printer* printer, - const EnumDescriptor* enumdesc, - std::set<std::string>* provided) const { - std::string name = GetEnumPath(options, enumdesc); - provided->insert(name); -} - -void Generator::FindProvidesForFields( - const GeneratorOptions& options, io::Printer* printer, - const std::vector<const FieldDescriptor*>& fields, - std::set<std::string>* provided) const { - for (int i = 0; i < fields.size(); i++) { - const FieldDescriptor* field = fields[i]; - - if (IgnoreField(field)) { - continue; - } - - std::string name = GetNamespace(options, field->file()) + "." + - JSObjectFieldName(options, field); - provided->insert(name); - } -} - -void Generator::GenerateProvides(const GeneratorOptions& options, - io::Printer* printer, - std::set<std::string>* provided) const { - for (std::set<std::string>::iterator it = provided->begin(); - it != provided->end(); ++it) { - if (options.import_style == GeneratorOptions::kImportClosure) { - printer->Print("goog.provide('$name$');\n", "name", *it); - } else { - // We aren't using Closure's import system, but we use goog.exportSymbol() - // to construct the expected tree of objects, eg. - // - // goog.exportSymbol('foo.bar.Baz', null, this); - // - // // Later generated code expects foo.bar = {} to exist: - // foo.bar.Baz = function() { /* ... */ } - - // Do not use global scope in strict mode - if (options.import_style == GeneratorOptions::kImportCommonJsStrict) { - std::string namespaceObject = *it; - // Remove "proto." from the namespace object - GOOGLE_CHECK_EQ(0, namespaceObject.compare(0, 6, "proto.")); - namespaceObject.erase(0, 6); - printer->Print("goog.exportSymbol('$name$', null, proto);\n", "name", - namespaceObject); - } else { - printer->Print("goog.exportSymbol('$name$', null, global);\n", "name", - *it); - } - } - } -} - -void Generator::GenerateRequiresForSCC(const GeneratorOptions& options, - io::Printer* printer, const SCC* scc, - std::set<std::string>* provided) const { - std::set<std::string> required; - std::set<std::string> forwards; - bool have_message = false; - bool has_extension = false; - bool has_map = false; - for (auto desc : scc->descriptors) { - if (desc->containing_type() == nullptr) { - FindRequiresForMessage(options, desc, &required, &forwards, - &have_message); - has_extension = (has_extension || HasExtensions(desc)); - has_map = (has_map || HasMap(options, desc)); - } - } - - GenerateRequiresImpl(options, printer, &required, &forwards, provided, - /* require_jspb = */ have_message, - /* require_extension = */ has_extension, - /* require_map = */ has_map); -} - -void Generator::GenerateRequiresForLibrary( - const GeneratorOptions& options, io::Printer* printer, - const std::vector<const FileDescriptor*>& files, - std::set<std::string>* provided) const { - GOOGLE_CHECK_EQ(options.import_style, GeneratorOptions::kImportClosure); - // For Closure imports we need to import every message type individually. - std::set<std::string> required; - std::set<std::string> forwards; - bool have_extensions = false; - bool have_map = false; - bool have_message = false; - - for (int i = 0; i < files.size(); i++) { - for (int j = 0; j < files[i]->message_type_count(); j++) { - const Descriptor* desc = files[i]->message_type(j); - if (!IgnoreMessage(desc)) { - FindRequiresForMessage(options, desc, &required, &forwards, - &have_message); - } - } - - if (!have_extensions && HasExtensions(files[i])) { - have_extensions = true; - } - - if (!have_map && FileHasMap(options, files[i])) { - have_map = true; - } - - for (int j = 0; j < files[i]->extension_count(); j++) { - const FieldDescriptor* extension = files[i]->extension(j); - if (IgnoreField(extension)) { - continue; - } - if (extension->containing_type()->full_name() != - "google.protobuf.bridge.MessageSet") { - required.insert(GetMessagePath(options, extension->containing_type())); - } - FindRequiresForField(options, extension, &required, &forwards); - have_extensions = true; - } - } - - GenerateRequiresImpl(options, printer, &required, &forwards, provided, - /* require_jspb = */ have_message, - /* require_extension = */ have_extensions, - /* require_map = */ have_map); -} - -void Generator::GenerateRequiresForExtensions( - const GeneratorOptions& options, io::Printer* printer, - const std::vector<const FieldDescriptor*>& fields, - std::set<std::string>* provided) const { - std::set<std::string> required; - std::set<std::string> forwards; - for (int i = 0; i < fields.size(); i++) { - const FieldDescriptor* field = fields[i]; - if (IgnoreField(field)) { - continue; - } - FindRequiresForExtension(options, field, &required, &forwards); - } - - GenerateRequiresImpl(options, printer, &required, &forwards, provided, - /* require_jspb = */ false, - /* require_extension = */ fields.size() > 0, - /* require_map = */ false); -} - -void Generator::GenerateRequiresImpl(const GeneratorOptions& options, - io::Printer* printer, - std::set<std::string>* required, - std::set<std::string>* forwards, - std::set<std::string>* provided, - bool require_jspb, bool require_extension, - bool require_map) const { - if (require_jspb) { - required->insert("jspb.Message"); - required->insert("jspb.BinaryReader"); - required->insert("jspb.BinaryWriter"); - } - if (require_extension) { - required->insert("jspb.ExtensionFieldBinaryInfo"); - required->insert("jspb.ExtensionFieldInfo"); - } - if (require_map) { - required->insert("jspb.Map"); - } - - std::set<std::string>::iterator it; - for (it = required->begin(); it != required->end(); ++it) { - if (provided->find(*it) != provided->end()) { - continue; - } - printer->Print("goog.require('$name$');\n", "name", *it); - } - - printer->Print("\n"); - - for (it = forwards->begin(); it != forwards->end(); ++it) { - if (provided->find(*it) != provided->end()) { - continue; - } - printer->Print("goog.forwardDeclare('$name$');\n", "name", *it); - } -} - -bool NamespaceOnly(const Descriptor* desc) { return false; } - -void Generator::FindRequiresForMessage(const GeneratorOptions& options, - const Descriptor* desc, - std::set<std::string>* required, - std::set<std::string>* forwards, - bool* have_message) const { - if (!NamespaceOnly(desc)) { - *have_message = true; - for (int i = 0; i < desc->field_count(); i++) { - const FieldDescriptor* field = desc->field(i); - if (IgnoreField(field)) { - continue; - } - FindRequiresForField(options, field, required, forwards); - } - } - - for (int i = 0; i < desc->extension_count(); i++) { - const FieldDescriptor* field = desc->extension(i); - if (IgnoreField(field)) { - continue; - } - FindRequiresForExtension(options, field, required, forwards); - } - - for (int i = 0; i < desc->nested_type_count(); i++) { - FindRequiresForMessage(options, desc->nested_type(i), required, forwards, - have_message); - } -} - -void Generator::FindRequiresForField(const GeneratorOptions& options, - const FieldDescriptor* field, - std::set<std::string>* required, - std::set<std::string>* forwards) const { - if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM && - // N.B.: file-level extensions with enum type do *not* create - // dependencies, as per original codegen. - !(field->is_extension() && field->extension_scope() == nullptr)) { - if (options.add_require_for_enums) { - required->insert(GetEnumPath(options, field->enum_type())); - } else { - forwards->insert(GetEnumPath(options, field->enum_type())); - } - } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - if (!IgnoreMessage(field->message_type())) { - required->insert(GetMessagePath(options, field->message_type())); - } - } -} - -void Generator::FindRequiresForExtension( - const GeneratorOptions& options, const FieldDescriptor* field, - std::set<std::string>* required, std::set<std::string>* forwards) const { - if (field->containing_type()->full_name() != - "google.protobuf.bridge.MessageSet") { - required->insert(GetMessagePath(options, field->containing_type())); - } - FindRequiresForField(options, field, required, forwards); -} - -void Generator::GenerateTestOnly(const GeneratorOptions& options, - io::Printer* printer) const { - if (options.testonly) { - printer->Print("goog.setTestOnly();\n\n"); - } - printer->Print("\n"); -} - -void Generator::GenerateClassesAndEnums(const GeneratorOptions& options, - io::Printer* printer, - const FileDescriptor* file) const { - for (int i = 0; i < file->message_type_count(); i++) { - GenerateClassConstructorAndDeclareExtensionFieldInfo(options, printer, - file->message_type(i)); - } - for (int i = 0; i < file->message_type_count(); i++) { - GenerateClass(options, printer, file->message_type(i)); - } - for (int i = 0; i < file->enum_type_count(); i++) { - GenerateEnum(options, printer, file->enum_type(i)); - } -} - -void Generator::GenerateClass(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - if (IgnoreMessage(desc)) { - return; - } - - if (!NamespaceOnly(desc)) { - printer->Print("\n"); - GenerateClassFieldInfo(options, printer, desc); - - GenerateClassToObject(options, printer, desc); - // These must come *before* the extension-field info generation in - // GenerateClassRegistration so that references to the binary - // serialization/deserialization functions may be placed in the extension - // objects. - GenerateClassDeserializeBinary(options, printer, desc); - GenerateClassSerializeBinary(options, printer, desc); - } - - // Recurse on nested types. These must come *before* the extension-field - // info generation in GenerateClassRegistration so that extensions that - // reference nested types proceed the definitions of the nested types. - for (int i = 0; i < desc->enum_type_count(); i++) { - GenerateEnum(options, printer, desc->enum_type(i)); - } - for (int i = 0; i < desc->nested_type_count(); i++) { - GenerateClass(options, printer, desc->nested_type(i)); - } - - if (!NamespaceOnly(desc)) { - GenerateClassRegistration(options, printer, desc); - GenerateClassFields(options, printer, desc); - - if (options.import_style != GeneratorOptions::kImportClosure) { - for (int i = 0; i < desc->extension_count(); i++) { - GenerateExtension(options, printer, desc->extension(i)); - } - } - } -} - -void Generator::GenerateClassConstructor(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - printer->Print( - "/**\n" - " * Generated by JsPbCodeGenerator.\n" - " * @param {Array=} opt_data Optional initial data array, typically " - "from a\n" - " * server response, or constructed directly in Javascript. The array " - "is used\n" - " * in place and becomes part of the constructed object. It is not " - "cloned.\n" - " * If no data is provided, the constructed object will be empty, but " - "still\n" - " * valid.\n" - " * @extends {jspb.Message}\n" - " * @constructor\n" - " */\n" - "$classprefix$$classname$ = function(opt_data) {\n", - "classprefix", GetMessagePathPrefix(options, desc), "classname", - desc->name()); - printer->Annotate("classname", desc); - std::string message_id = GetMessageId(desc); - printer->Print( - " jspb.Message.initialize(this, opt_data, $messageId$, $pivot$, " - "$rptfields$, $oneoffields$);\n", - "messageId", - !message_id.empty() ? ("'" + message_id + "'") - : (IsResponse(desc) ? "''" : "0"), - "pivot", GetPivot(desc), "rptfields", - RepeatedFieldsArrayName(options, desc), "oneoffields", - OneofFieldsArrayName(options, desc)); - printer->Print( - "};\n" - "goog.inherits($classname$, jspb.Message);\n" - "if (goog.DEBUG && !COMPILED) {\n" - // displayName overrides Function.prototype.displayName - // http://google3/javascript/externs/es3.js?l=511 - " /**\n" - " * @public\n" - " * @override\n" - " */\n" - " $classname$.displayName = '$classname$';\n" - "}\n", - "classname", GetMessagePath(options, desc)); -} - -void Generator::GenerateClassConstructorAndDeclareExtensionFieldInfo( - const GeneratorOptions& options, io::Printer* printer, - const Descriptor* desc) const { - if (!NamespaceOnly(desc)) { - GenerateClassConstructor(options, printer, desc); - if (IsExtendable(desc) && - desc->full_name() != "google.protobuf.bridge.MessageSet") { - GenerateClassExtensionFieldInfo(options, printer, desc); - } - } - for (int i = 0; i < desc->nested_type_count(); i++) { - if (!IgnoreMessage(desc->nested_type(i))) { - GenerateClassConstructorAndDeclareExtensionFieldInfo( - options, printer, desc->nested_type(i)); - } - } -} - -void Generator::GenerateClassFieldInfo(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - if (HasRepeatedFields(options, desc)) { - printer->Print( - "/**\n" - " * List of repeated fields within this message type.\n" - " * @private {!Array<number>}\n" - " * @const\n" - " */\n" - "$classname$$rptfieldarray$ = $rptfields$;\n" - "\n", - "classname", GetMessagePath(options, desc), "rptfieldarray", - kRepeatedFieldArrayName, "rptfields", - RepeatedFieldNumberList(options, desc)); - } - - if (HasOneofFields(desc)) { - printer->Print( - "/**\n" - " * Oneof group definitions for this message. Each group defines the " - "field\n" - " * numbers belonging to that group. When of these fields' value is " - "set, all\n" - " * other fields in the group are cleared. During deserialization, if " - "multiple\n" - " * fields are encountered for a group, only the last value seen will " - "be kept.\n" - " * @private {!Array<!Array<number>>}\n" - " * @const\n" - " */\n" - "$classname$$oneofgrouparray$ = $oneofgroups$;\n" - "\n", - "classname", GetMessagePath(options, desc), "oneofgrouparray", - kOneofGroupArrayName, "oneofgroups", OneofGroupList(desc)); - - for (int i = 0; i < desc->oneof_decl_count(); i++) { - if (IgnoreOneof(desc->oneof_decl(i))) { - continue; - } - GenerateOneofCaseDefinition(options, printer, desc->oneof_decl(i)); - } - } -} - -void Generator::GenerateClassXid(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - printer->Print( - "\n" - "\n" - "$class$.prototype.messageXid = xid('$class$');\n", - "class", GetMessagePath(options, desc)); -} - -void Generator::GenerateOneofCaseDefinition( - const GeneratorOptions& options, io::Printer* printer, - const OneofDescriptor* oneof) const { - printer->Print( - "/**\n" - " * @enum {number}\n" - " */\n" - "$classname$.$oneof$Case = {\n" - " $upcase$_NOT_SET: 0", - "classname", GetMessagePath(options, oneof->containing_type()), "oneof", - JSOneofName(oneof), "upcase", ToEnumCase(oneof->name())); - - for (int i = 0; i < oneof->field_count(); i++) { - if (IgnoreField(oneof->field(i))) { - continue; - } - - printer->Print( - ",\n" - " $upcase$: $number$", - "upcase", ToEnumCase(oneof->field(i)->name()), "number", - JSFieldIndex(oneof->field(i))); - printer->Annotate("upcase", oneof->field(i)); - } - - printer->Print( - "\n" - "};\n" - "\n" - "/**\n" - " * @return {$class$.$oneof$Case}\n" - " */\n" - "$class$.prototype.get$oneof$Case = function() {\n" - " return /** @type {$class$.$oneof$Case} */(jspb.Message." - "computeOneofCase(this, $class$.oneofGroups_[$oneofindex$]));\n" - "};\n" - "\n", - "class", GetMessagePath(options, oneof->containing_type()), "oneof", - JSOneofName(oneof), "oneofindex", JSOneofIndex(oneof)); -} - -void Generator::GenerateClassToObject(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - printer->Print( - "\n" - "\n" - "if (jspb.Message.GENERATE_TO_OBJECT) {\n" - "/**\n" - " * Creates an object representation of this proto.\n" - " * Field names that are reserved in JavaScript and will be renamed to " - "pb_name.\n" - " * Optional fields that are not set will be set to undefined.\n" - " * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.\n" - " * For the list of reserved names please see:\n" - " * net/proto2/compiler/js/internal/generator.cc#kKeyword.\n" - " * @param {boolean=} opt_includeInstance Deprecated. whether to include " - "the\n" - " * JSPB instance for transitional soy proto support:\n" - " * http://goto/soy-param-migration\n" - " * @return {!Object}\n" - " */\n" - "$classname$.prototype.toObject = function(opt_includeInstance) {\n" - " return $classname$.toObject(opt_includeInstance, this);\n" - "};\n" - "\n" - "\n" - "/**\n" - " * Static version of the {@see toObject} method.\n" - " * @param {boolean|undefined} includeInstance Deprecated. Whether to " - "include\n" - " * the JSPB instance for transitional soy proto support:\n" - " * http://goto/soy-param-migration\n" - " * @param {!$classname$} msg The msg instance to transform.\n" - " * @return {!Object}\n" - " * @suppress {unusedLocalVariables} f is only used for nested messages\n" - " */\n" - "$classname$.toObject = function(includeInstance, msg) {\n" - " var f, obj = {", - "classname", GetMessagePath(options, desc)); - - bool first = true; - for (int i = 0; i < desc->field_count(); i++) { - const FieldDescriptor* field = desc->field(i); - if (IgnoreField(field)) { - continue; - } - - if (!first) { - printer->Print(",\n "); - } else { - printer->Print("\n "); - first = false; - } - - GenerateClassFieldToObject(options, printer, field); - } - - if (!first) { - printer->Print("\n };\n\n"); - } else { - printer->Print("\n\n };\n\n"); - } - - if (IsExtendable(desc)) { - printer->Print( - " jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), " - "obj,\n" - " $extObject$, $class$.prototype.getExtension,\n" - " includeInstance);\n", - "extObject", JSExtensionsObjectName(options, desc->file(), desc), - "class", GetMessagePath(options, desc)); - } - - printer->Print( - " if (includeInstance) {\n" - " obj.$$jspbMessageInstance = msg;\n" - " }\n" - " return obj;\n" - "};\n" - "}\n" - "\n" - "\n", - "classname", GetMessagePath(options, desc)); -} - -void Generator::GenerateFieldValueExpression(io::Printer* printer, - const char* obj_reference, - const FieldDescriptor* field, - bool use_default) const { - const bool is_float_or_double = - field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT || - field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE; - const bool is_boolean = field->cpp_type() == FieldDescriptor::CPPTYPE_BOOL; - - const std::string with_default = use_default ? "WithDefault" : ""; - const std::string default_arg = - use_default ? StrCat(", ", JSFieldDefault(field)) : ""; - const std::string cardinality = field->is_repeated() ? "Repeated" : ""; - std::string type = ""; - if (is_float_or_double) { - type = "FloatingPoint"; - } - if (is_boolean) { - type = "Boolean"; - } - - // Prints the appropriate function, among: - // - getField - // - getBooleanField - // - getFloatingPointField => Replaced by getOptionalFloatingPointField to - // preserve backward compatibility. - // - getFieldWithDefault - // - getBooleanFieldWithDefault - // - getFloatingPointFieldWithDefault - // - getRepeatedField - // - getRepeatedBooleanField - // - getRepeatedFloatingPointField - if (is_float_or_double && !field->is_repeated() && !use_default) { - printer->Print( - "jspb.Message.getOptionalFloatingPointField($obj$, " - "$index$$default$)", - "obj", obj_reference, "index", JSFieldIndex(field), "default", - default_arg); - } else { - printer->Print( - "jspb.Message.get$cardinality$$type$Field$with_default$($obj$, " - "$index$$default$)", - "cardinality", cardinality, "type", type, "with_default", with_default, - "obj", obj_reference, "index", JSFieldIndex(field), "default", - default_arg); - } -} - -void Generator::GenerateClassFieldToObject(const GeneratorOptions& options, - io::Printer* printer, - const FieldDescriptor* field) const { - printer->Print("$fieldname$: ", "fieldname", - JSObjectFieldName(options, field)); - - if (field->is_map()) { - const FieldDescriptor* value_field = MapFieldValue(field); - // If the map values are of a message type, we must provide their static - // toObject() method; otherwise we pass undefined for that argument. - std::string value_to_object; - if (value_field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - value_to_object = - GetMessagePath(options, value_field->message_type()) + ".toObject"; - } else { - value_to_object = "undefined"; - } - printer->Print( - "(f = msg.get$name$()) ? f.toObject(includeInstance, $valuetoobject$) " - ": []", - "name", JSGetterName(options, field), "valuetoobject", value_to_object); - } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - // Message field. - if (field->is_repeated()) { - { - printer->Print( - "jspb.Message.toObjectList(msg.get$getter$(),\n" - " $type$.toObject, includeInstance)", - "getter", JSGetterName(options, field), "type", - SubmessageTypeRef(options, field)); - } - } else { - printer->Print( - "(f = msg.get$getter$()) && " - "$type$.toObject(includeInstance, f)", - "getter", JSGetterName(options, field), "type", - SubmessageTypeRef(options, field)); - } - } else if (field->type() == FieldDescriptor::TYPE_BYTES) { - // For bytes fields we want to always return the B64 data. - printer->Print("msg.get$getter$()", "getter", - JSGetterName(options, field, BYTES_B64)); - } else { - bool use_default = field->has_default_value(); - - if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 && - // Repeated fields get initialized to their default in the constructor - // (why?), so we emit a plain getField() call for them. - !field->is_repeated()) { - // Proto3 puts all defaults (including implicit defaults) in toObject(). - // But for proto2 we leave the existing semantics unchanged: unset fields - // without default are unset. - use_default = true; - } - - // We don't implement this by calling the accessors, because the semantics - // of the accessors are changing independently of the toObject() semantics. - // We are migrating the accessors to return defaults instead of null, but - // it may take longer to migrate toObject (or we might not want to do it at - // all). So we want to generate independent code. - // The accessor for unset optional values without default should return - // null. Those are converted to undefined in the generated object. - if (!use_default) { - printer->Print("(f = "); - } - GenerateFieldValueExpression(printer, "msg", field, use_default); - if (!use_default) { - printer->Print(") == null ? undefined : f"); - } - } -} - -void Generator::GenerateObjectTypedef(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - // TODO(b/122687752): Consider renaming nested messages called ObjectFormat - // to prevent collisions. - const std::string type_name = GetMessagePath(options, desc) + ".ObjectFormat"; - - printer->Print( - "/**\n" - " * The raw object form of $messageName$ as accepted by the `fromObject` " - "method.\n" - " * @record\n" - " */\n" - "$typeName$ = function() {\n", - "messageName", desc->name(), "typeName", type_name); - - for (int i = 0; i < desc->field_count(); i++) { - if (i > 0) { - printer->Print("\n"); - } - printer->Print( - " /** @type {$fieldType$|undefined} */\n" - " this.$fieldName$;\n", - "fieldName", JSObjectFieldName(options, desc->field(i)), - // TODO(b/121097361): Add type checking for field values. - "fieldType", "?"); - } - - printer->Print("};\n\n"); -} - -void Generator::GenerateClassFromObject(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - printer->Print("if (jspb.Message.GENERATE_FROM_OBJECT) {\n\n"); - - GenerateObjectTypedef(options, printer, desc); - - printer->Print( - "/**\n" - " * Loads data from an object into a new instance of this proto.\n" - " * @param {!$classname$.ObjectFormat} obj\n" - " * The object representation of this proto to load the data from.\n" - " * @return {!$classname$}\n" - " */\n" - "$classname$.fromObject = function(obj) {\n" - " var msg = new $classname$();\n", - "classname", GetMessagePath(options, desc)); - - for (int i = 0; i < desc->field_count(); i++) { - const FieldDescriptor* field = desc->field(i); - if (!IgnoreField(field)) { - GenerateClassFieldFromObject(options, printer, field); - } - } - - printer->Print( - " return msg;\n" - "};\n" - "}\n\n"); -} - -void Generator::GenerateClassFieldFromObject( - const GeneratorOptions& options, io::Printer* printer, - const FieldDescriptor* field) const { - if (field->is_map()) { - const FieldDescriptor* value_field = MapFieldValue(field); - if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) { - // Since the map values are of message type, we have to do some extra work - // to recursively call fromObject() on them before setting the map field. - printer->Print( - " obj.$name$ && jspb.Message.setWrapperField(\n" - " msg, $index$, jspb.Map.fromObject(obj.$name$, $fieldclass$, " - "$fieldclass$.fromObject));\n", - "name", JSObjectFieldName(options, field), "index", - JSFieldIndex(field), "fieldclass", - GetMessagePath(options, value_field->message_type())); - } else { - // `msg` is a newly-constructed message object that has not yet built any - // map containers wrapping underlying arrays, so we can simply directly - // set the array here without fear of a stale wrapper. - printer->Print( - " obj.$name$ && " - "jspb.Message.setField(msg, $index$, obj.$name$);\n", - "name", JSObjectFieldName(options, field), "index", - JSFieldIndex(field)); - } - } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - // Message field (singular or repeated) - if (field->is_repeated()) { - { - printer->Print( - " obj.$name$ && " - "jspb.Message.setRepeatedWrapperField(\n" - " msg, $index$, obj.$name$.map(\n" - " $fieldclass$.fromObject));\n", - "name", JSObjectFieldName(options, field), "index", - JSFieldIndex(field), "fieldclass", - SubmessageTypeRef(options, field)); - } - } else { - printer->Print( - " obj.$name$ && jspb.Message.setWrapperField(\n" - " msg, $index$, $fieldclass$.fromObject(obj.$name$));\n", - "name", JSObjectFieldName(options, field), "index", - JSFieldIndex(field), "fieldclass", SubmessageTypeRef(options, field)); - } - } else { - // Simple (primitive) field. - printer->Print( - " obj.$name$ != null && jspb.Message.setField(msg, $index$, " - "obj.$name$);\n", - "name", JSObjectFieldName(options, field), "index", - JSFieldIndex(field)); - } -} - -void Generator::GenerateClassRegistration(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - // Register any extensions defined inside this message type. - for (int i = 0; i < desc->extension_count(); i++) { - const FieldDescriptor* extension = desc->extension(i); - if (ShouldGenerateExtension(extension)) { - GenerateExtension(options, printer, extension); - } - } -} - -void Generator::GenerateClassFields(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - for (int i = 0; i < desc->field_count(); i++) { - if (!IgnoreField(desc->field(i))) { - GenerateClassField(options, printer, desc->field(i)); - } - } -} - -void GenerateBytesWrapper(const GeneratorOptions& options, io::Printer* printer, - const FieldDescriptor* field, BytesMode bytes_mode) { - std::string type = - JSFieldTypeAnnotation(options, field, - /* is_setter_argument = */ false, - /* force_present = */ false, - /* singular_if_not_packed = */ false, bytes_mode); - printer->Print( - "/**\n" - " * $fielddef$\n" - "$comment$" - " * This is a type-conversion wrapper around `get$defname$()`\n" - " * @return {$type$}\n" - " */\n" - "$class$.prototype.get$name$ = function() {\n" - " return /** @type {$type$} */ (jspb.Message.bytes$list$As$suffix$(\n" - " this.get$defname$()));\n" - "};\n" - "\n" - "\n", - "fielddef", FieldDefinition(options, field), "comment", - FieldComments(field, bytes_mode), "type", type, "class", - GetMessagePath(options, field->containing_type()), "name", - JSGetterName(options, field, bytes_mode), "list", - field->is_repeated() ? "List" : "", "suffix", - JSByteGetterSuffix(bytes_mode), "defname", - JSGetterName(options, field, BYTES_DEFAULT)); -} - -void Generator::GenerateClassField(const GeneratorOptions& options, - io::Printer* printer, - const FieldDescriptor* field) const { - if (field->is_map()) { - const FieldDescriptor* key_field = MapFieldKey(field); - const FieldDescriptor* value_field = MapFieldValue(field); - // Map field: special handling to instantiate the map object on demand. - std::string key_type = - JSFieldTypeAnnotation(options, key_field, - /* is_setter_argument = */ false, - /* force_present = */ true, - /* singular_if_not_packed = */ false); - std::string value_type = - JSFieldTypeAnnotation(options, value_field, - /* is_setter_argument = */ false, - /* force_present = */ true, - /* singular_if_not_packed = */ false); - - printer->Print( - "/**\n" - " * $fielddef$\n" - " * @param {boolean=} opt_noLazyCreate Do not create the map if\n" - " * empty, instead returning `undefined`\n" - " * @return {!jspb.Map<$keytype$,$valuetype$>}\n" - " */\n", - "fielddef", FieldDefinition(options, field), "keytype", key_type, - "valuetype", value_type); - printer->Print( - "$class$.prototype.$gettername$ = function(opt_noLazyCreate) {\n" - " return /** @type {!jspb.Map<$keytype$,$valuetype$>} */ (\n", - "class", GetMessagePath(options, field->containing_type()), - "gettername", "get" + JSGetterName(options, field), "keytype", key_type, - "valuetype", value_type); - printer->Annotate("gettername", field); - printer->Print( - " jspb.Message.getMapField(this, $index$, opt_noLazyCreate", - "index", JSFieldIndex(field)); - - if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) { - printer->Print( - ",\n" - " $messageType$", - "messageType", GetMessagePath(options, value_field->message_type())); - } else { - printer->Print( - ",\n" - " null"); - } - - printer->Print("));\n"); - - printer->Print( - "};\n" - "\n" - "\n"); - } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - // Message field: special handling in order to wrap the underlying data - // array with a message object. - - printer->Print( - "/**\n" - " * $fielddef$\n" - "$comment$" - " * @return {$type$}\n" - " */\n", - "fielddef", FieldDefinition(options, field), "comment", - FieldComments(field, BYTES_DEFAULT), "type", - JSFieldTypeAnnotation(options, field, - /* is_setter_argument = */ false, - /* force_present = */ false, - /* singular_if_not_packed = */ false)); - printer->Print( - "$class$.prototype.$gettername$ = function() {\n" - " return /** @type{$type$} */ (\n" - " jspb.Message.get$rpt$WrapperField(this, $wrapperclass$, " - "$index$$required$));\n" - "};\n" - "\n" - "\n", - "class", GetMessagePath(options, field->containing_type()), - "gettername", "get" + JSGetterName(options, field), "type", - JSFieldTypeAnnotation(options, field, - /* is_setter_argument = */ false, - /* force_present = */ false, - /* singular_if_not_packed = */ false), - "rpt", (field->is_repeated() ? "Repeated" : ""), "index", - JSFieldIndex(field), "wrapperclass", SubmessageTypeRef(options, field), - "required", - (field->label() == FieldDescriptor::LABEL_REQUIRED ? ", 1" : "")); - printer->Annotate("gettername", field); - printer->Print( - "/**\n" - " * @param {$optionaltype$} value\n" - " * @return {!$class$} returns this\n" - "*/\n" - "$class$.prototype.$settername$ = function(value) {\n" - " return jspb.Message.set$oneoftag$$repeatedtag$WrapperField(", - "optionaltype", - JSFieldTypeAnnotation(options, field, - /* is_setter_argument = */ true, - /* force_present = */ false, - /* singular_if_not_packed = */ false), - "class", GetMessagePath(options, field->containing_type()), - "settername", "set" + JSGetterName(options, field), "oneoftag", - (InRealOneof(field) ? "Oneof" : ""), "repeatedtag", - (field->is_repeated() ? "Repeated" : "")); - printer->Annotate("settername", field); - - printer->Print( - "this, $index$$oneofgroup$, value);\n" - "};\n" - "\n" - "\n", - "index", JSFieldIndex(field), "oneofgroup", - (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : "")); - - if (field->is_repeated()) { - GenerateRepeatedMessageHelperMethods(options, printer, field); - } - - } else { - bool untyped = false; - - // Simple (primitive) field, either singular or repeated. - - // TODO(b/26173701): Always use BYTES_DEFAULT for the getter return type; - // at this point we "lie" to non-binary users and tell the return - // type is always base64 string, pending a LSC to migrate to typed getters. - BytesMode bytes_mode = - field->type() == FieldDescriptor::TYPE_BYTES && !options.binary - ? BYTES_B64 - : BYTES_DEFAULT; - std::string typed_annotation = - JSFieldTypeAnnotation(options, field, - /* is_setter_argument = */ false, - /* force_present = */ false, - /* singular_if_not_packed = */ false, - /* bytes_mode = */ bytes_mode); - if (untyped) { - printer->Print( - "/**\n" - " * @return {?} Raw field, untyped.\n" - " */\n"); - } else { - printer->Print( - "/**\n" - " * $fielddef$\n" - "$comment$" - " * @return {$type$}\n" - " */\n", - "fielddef", FieldDefinition(options, field), "comment", - FieldComments(field, bytes_mode), "type", typed_annotation); - } - - printer->Print("$class$.prototype.$gettername$ = function() {\n", "class", - GetMessagePath(options, field->containing_type()), - "gettername", "get" + JSGetterName(options, field)); - printer->Annotate("gettername", field); - - if (untyped) { - printer->Print(" return "); - } else { - printer->Print(" return /** @type {$type$} */ (", "type", - typed_annotation); - } - - bool use_default = !ReturnsNullWhenUnset(options, field); - - // Raw fields with no default set should just return undefined. - if (untyped && !field->has_default_value()) { - use_default = false; - } - - // Repeated fields get initialized to their default in the constructor - // (why?), so we emit a plain getField() call for them. - if (field->is_repeated()) { - use_default = false; - } - - GenerateFieldValueExpression(printer, "this", field, use_default); - - if (untyped) { - printer->Print( - ";\n" - "};\n" - "\n" - "\n"); - } else { - printer->Print( - ");\n" - "};\n" - "\n" - "\n"); - } - - if (field->type() == FieldDescriptor::TYPE_BYTES && !untyped) { - GenerateBytesWrapper(options, printer, field, BYTES_B64); - GenerateBytesWrapper(options, printer, field, BYTES_U8); - } - - printer->Print( - "/**\n" - " * @param {$optionaltype$} value\n" - " * @return {!$class$} returns this\n" - " */\n", - "class", GetMessagePath(options, field->containing_type()), - "optionaltype", - untyped ? "*" - : JSFieldTypeAnnotation(options, field, - /* is_setter_argument = */ true, - /* force_present = */ false, - /* singular_if_not_packed = */ false)); - - if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 && - !field->is_repeated() && !field->is_map() && - !HasFieldPresence(options, field)) { - // Proto3 non-repeated and non-map fields without presence use the - // setProto3*Field function. - printer->Print( - "$class$.prototype.$settername$ = function(value) {\n" - " return jspb.Message.setProto3$typetag$Field(this, $index$, " - "value);" - "\n" - "};\n" - "\n" - "\n", - "class", GetMessagePath(options, field->containing_type()), - "settername", "set" + JSGetterName(options, field), "typetag", - JSTypeTag(field), "index", JSFieldIndex(field)); - printer->Annotate("settername", field); - } else { - // Otherwise, use the regular setField function. - printer->Print( - "$class$.prototype.$settername$ = function(value) {\n" - " return jspb.Message.set$oneoftag$Field(this, $index$", - "class", GetMessagePath(options, field->containing_type()), - "settername", "set" + JSGetterName(options, field), "oneoftag", - (InRealOneof(field) ? "Oneof" : ""), "index", JSFieldIndex(field)); - printer->Annotate("settername", field); - printer->Print( - "$oneofgroup$, $type$value$rptvalueinit$$typeclose$);\n" - "};\n" - "\n" - "\n", - "type", - untyped ? "/** @type{string|number|boolean|Array|undefined} */(" : "", - "typeclose", untyped ? ")" : "", "oneofgroup", - (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), - "rptvalueinit", (field->is_repeated() ? " || []" : "")); - } - - if (untyped) { - printer->Print( - "/**\n" - " * Clears the value.\n" - " * @return {!$class$} returns this\n" - " */\n", - "class", GetMessagePath(options, field->containing_type())); - } - - if (field->is_repeated()) { - GenerateRepeatedPrimitiveHelperMethods(options, printer, field, untyped); - } - } - - // Generate clearFoo() method for map fields, repeated fields, and other - // fields with presence. - if (field->is_map()) { - // clang-format off - printer->Print( - "/**\n" - " * Clears values from the map. The map will be non-null.\n" - " * @return {!$class$} returns this\n" - " */\n" - "$class$.prototype.$clearername$ = function() {\n" - " this.$gettername$().clear();\n" - " return this;" - "};\n" - "\n" - "\n", - "class", GetMessagePath(options, field->containing_type()), - "clearername", "clear" + JSGetterName(options, field), - "gettername", "get" + JSGetterName(options, field)); - // clang-format on - printer->Annotate("clearername", field); - } else if (field->is_repeated() || - (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !field->is_required())) { - // Fields where we can delegate to the regular setter. - // clang-format off - printer->Print( - "/**\n" - " * $jsdoc$\n" - " * @return {!$class$} returns this\n" - " */\n" - "$class$.prototype.$clearername$ = function() {\n" - " return this.$settername$($clearedvalue$);\n" - "};\n" - "\n" - "\n", - "jsdoc", field->is_repeated() - ? "Clears the list making it empty but non-null." - : "Clears the message field making it undefined.", - "class", GetMessagePath(options, field->containing_type()), - "clearername", "clear" + JSGetterName(options, field), - "settername", "set" + JSGetterName(options, field), - "clearedvalue", (field->is_repeated() ? "[]" : "undefined")); - // clang-format on - printer->Annotate("clearername", field); - } else if (HasFieldPresence(options, field)) { - // Fields where we can't delegate to the regular setter because it doesn't - // accept "undefined" as an argument. - // clang-format off - printer->Print( - "/**\n" - " * Clears the field making it undefined.\n" - " * @return {!$class$} returns this\n" - " */\n" - "$class$.prototype.$clearername$ = function() {\n" - " return jspb.Message.set$maybeoneof$Field(this, " - "$index$$maybeoneofgroup$, ", - "class", GetMessagePath(options, field->containing_type()), - "clearername", "clear" + JSGetterName(options, field), - "maybeoneof", (InRealOneof(field) ? "Oneof" : ""), - "maybeoneofgroup", (InRealOneof(field) - ? (", " + JSOneofArray(options, field)) - : ""), - "index", JSFieldIndex(field)); - // clang-format on - printer->Annotate("clearername", field); - printer->Print( - "$clearedvalue$);\n" - "};\n" - "\n" - "\n", - "clearedvalue", (field->is_repeated() ? "[]" : "undefined")); - } - - if (HasFieldPresence(options, field)) { - printer->Print( - "/**\n" - " * Returns whether this field is set.\n" - " * @return {boolean}\n" - " */\n" - "$class$.prototype.$hasername$ = function() {\n" - " return jspb.Message.getField(this, $index$) != null;\n" - "};\n" - "\n" - "\n", - "class", GetMessagePath(options, field->containing_type()), "hasername", - "has" + JSGetterName(options, field), "index", JSFieldIndex(field)); - printer->Annotate("hasername", field); - } -} - -void Generator::GenerateRepeatedPrimitiveHelperMethods( - const GeneratorOptions& options, io::Printer* printer, - const FieldDescriptor* field, bool untyped) const { - // clang-format off - printer->Print( - "/**\n" - " * @param {$optionaltype$} value\n" - " * @param {number=} opt_index\n" - " * @return {!$class$} returns this\n" - " */\n" - "$class$.prototype.$addername$ = function(value, opt_index) {\n" - " return jspb.Message.addToRepeatedField(this, " - "$index$", - "class", GetMessagePath(options, field->containing_type()), "addername", - "add" + JSGetterName(options, field, BYTES_DEFAULT, - /* drop_list = */ true), - "optionaltype", - JSFieldTypeAnnotation( - options, field, - /* is_setter_argument = */ false, - /* force_present = */ true, - /* singular_if_not_packed = */ false, - BYTES_DEFAULT, - /* force_singular = */ true), - "index", JSFieldIndex(field)); - printer->Annotate("addername", field); - printer->Print( - "$oneofgroup$, $type$value$rptvalueinit$$typeclose$, " - "opt_index);\n" - "};\n" - "\n" - "\n", - "type", untyped ? "/** @type{string|number|boolean|!Uint8Array} */(" : "", - "typeclose", untyped ? ")" : "", "oneofgroup", - (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), - "rptvalueinit", ""); - // clang-format on -} - -void Generator::GenerateRepeatedMessageHelperMethods( - const GeneratorOptions& options, io::Printer* printer, - const FieldDescriptor* field) const { - printer->Print( - "/**\n" - " * @param {!$optionaltype$=} opt_value\n" - " * @param {number=} opt_index\n" - " * @return {!$optionaltype$}\n" - " */\n" - "$class$.prototype.$addername$ = function(opt_value, opt_index) {\n" - " return jspb.Message.addTo$repeatedtag$WrapperField(", - "optionaltype", JSTypeName(options, field, BYTES_DEFAULT), "class", - GetMessagePath(options, field->containing_type()), "addername", - "add" + JSGetterName(options, field, BYTES_DEFAULT, - /* drop_list = */ true), - "repeatedtag", (field->is_repeated() ? "Repeated" : "")); - - printer->Annotate("addername", field); - printer->Print( - "this, $index$$oneofgroup$, opt_value, $ctor$, opt_index);\n" - "};\n" - "\n" - "\n", - "index", JSFieldIndex(field), "oneofgroup", - (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), "ctor", - GetMessagePath(options, field->message_type())); -} - -void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - if (IsExtendable(desc)) { - printer->Print( - "\n" - "/**\n" - " * The extensions registered with this message class. This is a " - "map of\n" - " * extension field number to fieldInfo object.\n" - " *\n" - " * For example:\n" - " * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, " - "ctor: proto.example.MyMessage} }\n" - " *\n" - " * fieldName contains the JsCompiler renamed field name property " - "so that it\n" - " * works in OPTIMIZED mode.\n" - " *\n" - " * @type {!Object<number, jspb.ExtensionFieldInfo>}\n" - " */\n" - "$class$.extensions = {};\n" - "\n", - "class", GetMessagePath(options, desc)); - - printer->Print( - "\n" - "/**\n" - " * The extensions registered with this message class. This is a " - "map of\n" - " * extension field number to fieldInfo object.\n" - " *\n" - " * For example:\n" - " * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, " - "ctor: proto.example.MyMessage} }\n" - " *\n" - " * fieldName contains the JsCompiler renamed field name property " - "so that it\n" - " * works in OPTIMIZED mode.\n" - " *\n" - " * @type {!Object<number, jspb.ExtensionFieldBinaryInfo>}\n" - " */\n" - "$class$.extensionsBinary = {};\n" - "\n", - "class", GetMessagePath(options, desc)); - } -} - -void Generator::GenerateClassDeserializeBinary(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - // TODO(cfallin): Handle lazy decoding when requested by field option and/or - // by default for 'bytes' fields and packed repeated fields. - - printer->Print( - "/**\n" - " * Deserializes binary data (in protobuf wire format).\n" - " * @param {jspb.ByteSource} bytes The bytes to deserialize.\n" - " * @return {!$class$}\n" - " */\n" - "$class$.deserializeBinary = function(bytes) {\n" - " var reader = new jspb.BinaryReader(bytes);\n" - " var msg = new $class$;\n" - " return $class$.deserializeBinaryFromReader(msg, reader);\n" - "};\n" - "\n" - "\n" - "/**\n" - " * Deserializes binary data (in protobuf wire format) from the\n" - " * given reader into the given message object.\n" - " * @param {!$class$} msg The message object to deserialize into.\n" - " * @param {!jspb.BinaryReader} reader The BinaryReader to use.\n" - " * @return {!$class$}\n" - " */\n" - "$class$.deserializeBinaryFromReader = function(msg, reader) {\n" - " while (reader.nextField()) {\n", - "class", GetMessagePath(options, desc)); - printer->Print( - " if (reader.isEndGroup()) {\n" - " break;\n" - " }\n" - " var field = reader.getFieldNumber();\n" - " switch (field) {\n"); - - for (int i = 0; i < desc->field_count(); i++) { - if (!IgnoreField(desc->field(i))) { - GenerateClassDeserializeBinaryField(options, printer, desc->field(i)); - } - } - - printer->Print(" default:\n"); - if (IsExtendable(desc)) { - printer->Print( - " jspb.Message.readBinaryExtension(msg, reader,\n" - " $extobj$Binary,\n" - " $class$.prototype.getExtension,\n" - " $class$.prototype.setExtension);\n" - " break;\n" - " }\n", - "extobj", JSExtensionsObjectName(options, desc->file(), desc), "class", - GetMessagePath(options, desc)); - } else { - printer->Print( - " reader.skipField();\n" - " break;\n" - " }\n"); - } - - printer->Print( - " }\n" - " return msg;\n" - "};\n" - "\n" - "\n"); -} - -void Generator::GenerateClassDeserializeBinaryField( - const GeneratorOptions& options, io::Printer* printer, - const FieldDescriptor* field) const { - printer->Print(" case $num$:\n", "num", StrCat(field->number())); - - if (field->is_map()) { - const FieldDescriptor* key_field = MapFieldKey(field); - const FieldDescriptor* value_field = MapFieldValue(field); - printer->Print( - " var value = msg.get$name$();\n" - " reader.readMessage(value, function(message, reader) {\n", - "name", JSGetterName(options, field)); - - printer->Print( - " jspb.Map.deserializeBinary(message, reader, " - "$keyReaderFn$, $valueReaderFn$", - "keyReaderFn", JSBinaryReaderMethodName(options, key_field), - "valueReaderFn", JSBinaryReaderMethodName(options, value_field)); - - if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) { - printer->Print(", $messageType$.deserializeBinaryFromReader", - "messageType", - GetMessagePath(options, value_field->message_type())); - } else { - printer->Print(", null"); - } - printer->Print(", $defaultKey$", "defaultKey", JSFieldDefault(key_field)); - if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) { - printer->Print(", new $messageType$()", "messageType", - GetMessagePath(options, value_field->message_type())); - } else { - printer->Print(", $defaultValue$", "defaultValue", - JSFieldDefault(value_field)); - } - printer->Print(");\n"); - printer->Print(" });\n"); - } else { - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - printer->Print( - " var value = new $fieldclass$;\n" - " reader.read$msgOrGroup$($grpfield$value," - "$fieldclass$.deserializeBinaryFromReader);\n", - "fieldclass", SubmessageTypeRef(options, field), "msgOrGroup", - (field->type() == FieldDescriptor::TYPE_GROUP) ? "Group" : "Message", - "grpfield", - (field->type() == FieldDescriptor::TYPE_GROUP) - ? (StrCat(field->number()) + ", ") - : ""); - } else if (field->is_packable()) { - printer->Print( - " var values = /** @type {$fieldtype$} */ " - "(reader.isDelimited() " - "? reader.readPacked$reader$() : [reader.read$reader$()]);\n", - "fieldtype", - JSFieldTypeAnnotation(options, field, false, true, - /* singular_if_not_packed */ false, BYTES_U8), - "reader", JSBinaryReaderMethodType(field)); - } else { - printer->Print( - " var value = /** @type {$fieldtype$} */ " - "(reader.read$reader$());\n", - "fieldtype", - JSFieldTypeAnnotation(options, field, false, true, - /* singular_if_not_packed */ true, BYTES_U8), - "reader", - JSBinaryReadWriteMethodName(field, /* is_writer = */ false)); - } - - if (field->is_packable()) { - printer->Print( - " for (var i = 0; i < values.length; i++) {\n" - " msg.add$name$(values[i]);\n" - " }\n", - "name", - JSGetterName(options, field, BYTES_DEFAULT, /* drop_list = */ true)); - } else if (field->is_repeated()) { - printer->Print( - " msg.add$name$(value);\n", "name", - JSGetterName(options, field, BYTES_DEFAULT, /* drop_list = */ true)); - } else { - // Singular fields, and packed repeated fields, receive a |value| either - // as the field's value or as the array of all the field's values; set - // this as the field's value directly. - printer->Print(" msg.set$name$(value);\n", "name", - JSGetterName(options, field)); - } - } - - printer->Print(" break;\n"); -} - -void Generator::GenerateClassSerializeBinary(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const { - printer->Print( - "/**\n" - " * Serializes the message to binary data (in protobuf wire format).\n" - " * @return {!Uint8Array}\n" - " */\n" - "$class$.prototype.serializeBinary = function() {\n" - " var writer = new jspb.BinaryWriter();\n" - " $class$.serializeBinaryToWriter(this, writer);\n" - " return writer.getResultBuffer();\n" - "};\n" - "\n" - "\n" - "/**\n" - " * Serializes the given message to binary data (in protobuf wire\n" - " * format), writing to the given BinaryWriter.\n" - " * @param {!$class$} message\n" - " * @param {!jspb.BinaryWriter} writer\n" - " * @suppress {unusedLocalVariables} f is only used for nested messages\n" - " */\n" - "$class$.serializeBinaryToWriter = function(message, " - "writer) {\n" - " var f = undefined;\n", - "class", GetMessagePath(options, desc)); - - for (int i = 0; i < desc->field_count(); i++) { - if (!IgnoreField(desc->field(i))) { - GenerateClassSerializeBinaryField(options, printer, desc->field(i)); - } - } - - if (IsExtendable(desc)) { - printer->Print( - " jspb.Message.serializeBinaryExtensions(message, writer,\n" - " $extobj$Binary, $class$.prototype.getExtension);\n", - "extobj", JSExtensionsObjectName(options, desc->file(), desc), "class", - GetMessagePath(options, desc)); - } - - printer->Print( - "};\n" - "\n" - "\n"); -} - -void Generator::GenerateClassSerializeBinaryField( - const GeneratorOptions& options, io::Printer* printer, - const FieldDescriptor* field) const { - if (HasFieldPresence(options, field) && - field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { - std::string typed_annotation = - JSFieldTypeAnnotation(options, field, - /* is_setter_argument = */ false, - /* force_present = */ false, - /* singular_if_not_packed = */ false, - /* bytes_mode = */ BYTES_DEFAULT); - printer->Print( - " f = /** @type {$type$} */ " - "(jspb.Message.getField(message, $index$));\n", - "index", JSFieldIndex(field), "type", typed_annotation); - } else { - printer->Print( - " f = message.get$name$($nolazy$);\n", "name", - JSGetterName(options, field, BYTES_U8), - // No lazy creation for maps containers -- fastpath the empty case. - "nolazy", field->is_map() ? "true" : ""); - } - - // Print an `if (condition)` statement that evaluates to true if the field - // goes on the wire. - if (field->is_map()) { - printer->Print(" if (f && f.getLength() > 0) {\n"); - } else if (field->is_repeated()) { - printer->Print(" if (f.length > 0) {\n"); - } else { - if (HasFieldPresence(options, field)) { - printer->Print(" if (f != null) {\n"); - } else { - // No field presence: serialize onto the wire only if value is - // non-default. Defaults are documented here: - // https://goto.google.com/lhdfm - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32: - case FieldDescriptor::CPPTYPE_INT64: - case FieldDescriptor::CPPTYPE_UINT32: - case FieldDescriptor::CPPTYPE_UINT64: { - if (IsIntegralFieldWithStringJSType(field)) { - // We can use `parseInt` here even though it will not be precise for - // 64-bit quantities because we are only testing for zero/nonzero, - // and JS numbers (64-bit floating point values, i.e., doubles) are - // integer-precise in the range that includes zero. - printer->Print(" if (parseInt(f, 10) !== 0) {\n"); - } else { - printer->Print(" if (f !== 0) {\n"); - } - break; - } - - case FieldDescriptor::CPPTYPE_ENUM: - case FieldDescriptor::CPPTYPE_FLOAT: - case FieldDescriptor::CPPTYPE_DOUBLE: - printer->Print(" if (f !== 0.0) {\n"); - break; - case FieldDescriptor::CPPTYPE_BOOL: - printer->Print(" if (f) {\n"); - break; - case FieldDescriptor::CPPTYPE_STRING: - printer->Print(" if (f.length > 0) {\n"); - break; - default: - assert(false); - break; - } - } - } - - // Write the field on the wire. - if (field->is_map()) { - const FieldDescriptor* key_field = MapFieldKey(field); - const FieldDescriptor* value_field = MapFieldValue(field); - printer->Print( - " f.serializeBinary($index$, writer, " - "$keyWriterFn$, $valueWriterFn$", - "index", StrCat(field->number()), "keyWriterFn", - JSBinaryWriterMethodName(options, key_field), "valueWriterFn", - JSBinaryWriterMethodName(options, value_field)); - - if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) { - printer->Print(", $messageType$.serializeBinaryToWriter", "messageType", - GetMessagePath(options, value_field->message_type())); - } - - printer->Print(");\n"); - } else { - printer->Print( - " writer.write$method$(\n" - " $index$,\n" - " f", - "method", JSBinaryReadWriteMethodName(field, /* is_writer = */ true), - "index", StrCat(field->number())); - - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !field->is_map()) { - printer->Print( - ",\n" - " $submsg$.serializeBinaryToWriter\n", - "submsg", SubmessageTypeRef(options, field)); - } else { - printer->Print("\n"); - } - - printer->Print(" );\n"); - } - - // Close the `if`. - printer->Print(" }\n"); -} - -void Generator::GenerateEnum(const GeneratorOptions& options, - io::Printer* printer, - const EnumDescriptor* enumdesc) const { - printer->Print( - "/**\n" - " * @enum {number}\n" - " */\n" - "$enumprefix$$name$ = {\n", - "enumprefix", GetEnumPathPrefix(options, enumdesc), "name", - enumdesc->name()); - printer->Annotate("name", enumdesc); - - std::set<std::string> used_name; - std::vector<int> valid_index; - for (int i = 0; i < enumdesc->value_count(); i++) { - if (enumdesc->options().allow_alias() && - !used_name.insert(ToEnumCase(enumdesc->value(i)->name())).second) { - continue; - } - valid_index.push_back(i); - } - for (auto i : valid_index) { - const EnumValueDescriptor* value = enumdesc->value(i); - printer->Print(" $name$: $value$$comma$\n", "name", - ToEnumCase(value->name()), "value", StrCat(value->number()), - "comma", (i == valid_index.back()) ? "" : ","); - printer->Annotate("name", value); - } - - printer->Print( - "};\n" - "\n"); -} - -void Generator::GenerateExtension(const GeneratorOptions& options, - io::Printer* printer, - const FieldDescriptor* field) const { - std::string extension_scope = - (field->extension_scope() - ? GetMessagePath(options, field->extension_scope()) - : GetNamespace(options, field->file())); - - const std::string extension_object_name = JSObjectFieldName(options, field); - printer->Print( - "\n" - "/**\n" - " * A tuple of {field number, class constructor} for the extension\n" - " * field named `$nameInComment$`.\n" - " * @type {!jspb.ExtensionFieldInfo<$extensionType$>}\n" - " */\n" - "$class$.$name$ = new jspb.ExtensionFieldInfo(\n", - "nameInComment", extension_object_name, "name", extension_object_name, - "class", extension_scope, "extensionType", - JSFieldTypeAnnotation(options, field, - /* is_setter_argument = */ false, - /* force_present = */ true, - /* singular_if_not_packed = */ false)); - printer->Annotate("name", field); - printer->Print( - " $index$,\n" - " {$name$: 0},\n" - " $ctor$,\n" - " /** @type {?function((boolean|undefined),!jspb.Message=): " - "!Object} */ (\n" - " $toObject$),\n" - " $repeated$);\n", - "index", StrCat(field->number()), "name", extension_object_name, "ctor", - (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE - ? SubmessageTypeRef(options, field) - : std::string("null")), - "toObject", - (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE - ? (SubmessageTypeRef(options, field) + ".toObject") - : std::string("null")), - "repeated", (field->is_repeated() ? "1" : "0")); - - printer->Print( - "\n" - "$extendName$Binary[$index$] = new jspb.ExtensionFieldBinaryInfo(\n" - " $class$.$name$,\n" - " $binaryReaderFn$,\n" - " $binaryWriterFn$,\n" - " $binaryMessageSerializeFn$,\n" - " $binaryMessageDeserializeFn$,\n", - "extendName", - JSExtensionsObjectName(options, field->file(), field->containing_type()), - "index", StrCat(field->number()), "class", extension_scope, "name", - extension_object_name, "binaryReaderFn", - JSBinaryReaderMethodName(options, field), "binaryWriterFn", - JSBinaryWriterMethodName(options, field), "binaryMessageSerializeFn", - (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) - ? (SubmessageTypeRef(options, field) + ".serializeBinaryToWriter") - : "undefined", - "binaryMessageDeserializeFn", - (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) - ? (SubmessageTypeRef(options, field) + ".deserializeBinaryFromReader") - : "undefined"); - - printer->Print(" $isPacked$);\n", "isPacked", - (field->is_packed() ? "true" : "false")); - - printer->Print( - "// This registers the extension field with the extended class, so that\n" - "// toObject() will function correctly.\n" - "$extendName$[$index$] = $class$.$name$;\n" - "\n", - "extendName", - JSExtensionsObjectName(options, field->file(), field->containing_type()), - "index", StrCat(field->number()), "class", extension_scope, "name", - extension_object_name); -} - -bool GeneratorOptions::ParseFromOptions( - const std::vector<std::pair<std::string, std::string> >& options, - std::string* error) { - for (int i = 0; i < options.size(); i++) { - if (options[i].first == "add_require_for_enums") { - if (options[i].second != "") { - *error = "Unexpected option value for add_require_for_enums"; - return false; - } - add_require_for_enums = true; - } else if (options[i].first == "binary") { - if (options[i].second != "") { - *error = "Unexpected option value for binary"; - return false; - } - binary = true; - } else if (options[i].first == "testonly") { - if (options[i].second != "") { - *error = "Unexpected option value for testonly"; - return false; - } - testonly = true; - - } else if (options[i].first == "error_on_name_conflict") { - GOOGLE_LOG(WARNING) << "Ignoring error_on_name_conflict option, this " - "will be removed in a future release"; - } else if (options[i].first == "output_dir") { - output_dir = options[i].second; - } else if (options[i].first == "namespace_prefix") { - namespace_prefix = options[i].second; - } else if (options[i].first == "library") { - library = options[i].second; - } else if (options[i].first == "import_style") { - if (options[i].second == "closure") { - import_style = kImportClosure; - } else if (options[i].second == "commonjs") { - import_style = kImportCommonJs; - } else if (options[i].second == "commonjs_strict") { - import_style = kImportCommonJsStrict; - } else if (options[i].second == "browser") { - import_style = kImportBrowser; - } else if (options[i].second == "es6") { - import_style = kImportEs6; - } else { - *error = "Unknown import style " + options[i].second + ", expected " + - "one of: closure, commonjs, browser, es6."; - } - } else if (options[i].first == "extension") { - extension = options[i].second; - } else if (options[i].first == "one_output_file_per_input_file") { - if (!options[i].second.empty()) { - *error = "Unexpected option value for one_output_file_per_input_file"; - return false; - } - one_output_file_per_input_file = true; - } else if (options[i].first == "annotate_code") { - if (!options[i].second.empty()) { - *error = "Unexpected option value for annotate_code"; - return false; - } - annotate_code = true; - } else { - // Assume any other option is an output directory, as long as it is a bare - // `key` rather than a `key=value` option. - if (options[i].second != "") { - *error = "Unknown option: " + options[i].first; - return false; - } - output_dir = options[i].first; - } - } - - if (import_style != kImportClosure && - (add_require_for_enums || testonly || !library.empty() || - extension != ".js" || one_output_file_per_input_file)) { - *error = - "The add_require_for_enums, testonly, library, extension, and " - "one_output_file_per_input_file options should only be " - "used for import_style=closure"; - return false; - } - - return true; -} - -GeneratorOptions::OutputMode GeneratorOptions::output_mode() const { - // We use one output file per input file if we are not using Closure or if - // this is explicitly requested. - if (import_style != kImportClosure || one_output_file_per_input_file) { - return kOneOutputFilePerInputFile; - } - - // If a library name is provided, we put everything in that one file. - if (!library.empty()) { - return kEverythingInOneFile; - } - - // Otherwise, we create one output file per SCC. - return kOneOutputFilePerSCC; -} - -void Generator::GenerateFilesInDepOrder( - const GeneratorOptions& options, io::Printer* printer, - const std::vector<const FileDescriptor*>& files) const { - // Build a std::set over all files so that the DFS can detect when it recurses - // into a dep not specified in the user's command line. - std::set<const FileDescriptor*> all_files(files.begin(), files.end()); - // Track the in-progress set of files that have been generated already. - std::set<const FileDescriptor*> generated; - for (int i = 0; i < files.size(); i++) { - GenerateFileAndDeps(options, printer, files[i], &all_files, &generated); - } -} - -void Generator::GenerateFileAndDeps( - const GeneratorOptions& options, io::Printer* printer, - const FileDescriptor* root, std::set<const FileDescriptor*>* all_files, - std::set<const FileDescriptor*>* generated) const { - // Skip if already generated. - if (generated->find(root) != generated->end()) { - return; - } - generated->insert(root); - - // Generate all dependencies before this file's content. - for (int i = 0; i < root->dependency_count(); i++) { - const FileDescriptor* dep = root->dependency(i); - GenerateFileAndDeps(options, printer, dep, all_files, generated); - } - - // Generate this file's content. Only generate if the file is part of the - // original set requested to be generated; i.e., don't take all transitive - // deps down to the roots. - if (all_files->find(root) != all_files->end()) { - GenerateClassesAndEnums(options, printer, root); - } -} - -bool Generator::GenerateFile(const FileDescriptor* file, - const GeneratorOptions& options, - GeneratorContext* context, - bool use_short_name) const { - std::string filename = - options.output_dir + "/" + - GetJSFilename(options, use_short_name - ? file->name().substr(file->name().rfind('/')) - : file->name()); - std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename)); - GOOGLE_CHECK(output); - GeneratedCodeInfo annotations; - io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector( - &annotations); - io::Printer printer(output.get(), '$', - options.annotate_code ? &annotation_collector : nullptr); - - GenerateFile(options, &printer, file); - - if (printer.failed()) { - return false; - } - - if (options.annotate_code) { - EmbedCodeAnnotations(annotations, &printer); - } - - return true; -} - -void Generator::GenerateFile(const GeneratorOptions& options, - io::Printer* printer, - const FileDescriptor* file) const { - GenerateHeader(options, file, printer); - - // Generate "require" statements. - if ((options.import_style == GeneratorOptions::kImportCommonJs || - options.import_style == GeneratorOptions::kImportCommonJsStrict)) { - printer->Print("var jspb = require('google-protobuf');\n"); - printer->Print("var goog = jspb;\n"); - - // Do not use global scope in strict mode - if (options.import_style == GeneratorOptions::kImportCommonJsStrict) { - printer->Print("var proto = {};\n\n"); - } else { - // To get the global object we call a function with .call(null), this will set "this" inside the - // function to the global object. - // This does not work if we are running in strict mode ("use strict"), - // so we fallback to the following things (in order from first to last): - // - window: defined in browsers - // - global: defined in most server side environments like NodeJS - // - self: defined inside Web Workers (WorkerGlobalScope) - // - Function('return this')(): this will work on most platforms, but it may be blocked by things like CSP. - // Function('') is almost the same as eval('') - printer->Print( - "var global = (function() {\n" - " if (this) { return this; }\n" - " if (typeof window !== 'undefined') { return window; }\n" - " if (typeof global !== 'undefined') { return global; }\n" - " if (typeof self !== 'undefined') { return self; }\n" - " return Function('return this')();\n" - "}.call(null));\n\n"); - } - - for (int i = 0; i < file->dependency_count(); i++) { - const std::string& name = file->dependency(i)->name(); - printer->Print( - "var $alias$ = require('$file$');\n" - "goog.object.extend(proto, $alias$);\n", - "alias", ModuleAlias(name), "file", - GetRootPath(file->name(), name) + GetJSFilename(options, name)); - } - } - - std::set<std::string> provided; - std::set<const FieldDescriptor*> extensions; - for (int i = 0; i < file->extension_count(); i++) { - // We honor the jspb::ignore option here only when working with - // Closure-style imports. Use of this option is discouraged and so we want - // to avoid adding new support for it. - if (options.import_style == GeneratorOptions::kImportClosure && - IgnoreField(file->extension(i))) { - continue; - } - provided.insert(GetNamespace(options, file) + "." + - JSObjectFieldName(options, file->extension(i))); - extensions.insert(file->extension(i)); - } - - FindProvidesForFile(options, printer, file, &provided); - GenerateProvides(options, printer, &provided); - std::vector<const FileDescriptor*> files; - files.push_back(file); - if (options.import_style == GeneratorOptions::kImportClosure) { - GenerateRequiresForLibrary(options, printer, files, &provided); - } - - GenerateClassesAndEnums(options, printer, file); - - // Generate code for top-level extensions. Extensions nested inside messages - // are emitted inside GenerateClassesAndEnums(). - for (std::set<const FieldDescriptor*>::const_iterator it = extensions.begin(); - it != extensions.end(); ++it) { - GenerateExtension(options, printer, *it); - } - - // if provided is empty, do not export anything - if (options.import_style == GeneratorOptions::kImportCommonJs && - !provided.empty()) { - printer->Print("goog.object.extend(exports, $package$);\n", "package", - GetNamespace(options, file)); - } else if (options.import_style == GeneratorOptions::kImportCommonJsStrict) { - printer->Print("goog.object.extend(exports, proto);\n", "package", - GetNamespace(options, file)); - } - - // Emit well-known type methods. - for (FileToc* toc = well_known_types_js; toc->name != NULL; toc++) { - std::string name = std::string("google/protobuf/") + toc->name; - if (name == StripProto(file->name()) + ".js") { - printer->Print(toc->data); - } - } -} - -bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files, - const std::string& parameter, - GeneratorContext* context, - std::string* error) const { - std::vector<std::pair<std::string, std::string> > option_pairs; - ParseGeneratorParameter(parameter, &option_pairs); - GeneratorOptions options; - if (!options.ParseFromOptions(option_pairs, error)) { - return false; - } - - if (options.output_mode() == GeneratorOptions::kEverythingInOneFile) { - // All output should go in a single file. - std::string filename = options.output_dir + "/" + options.library + - options.GetFileNameExtension(); - std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename)); - GOOGLE_CHECK(output.get()); - GeneratedCodeInfo annotations; - io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector( - &annotations); - io::Printer printer( - output.get(), '$', - options.annotate_code ? &annotation_collector : nullptr); - - // Pull out all extensions -- we need these to generate all - // provides/requires. - std::vector<const FieldDescriptor*> extensions; - for (int i = 0; i < files.size(); i++) { - for (int j = 0; j < files[i]->extension_count(); j++) { - const FieldDescriptor* extension = files[i]->extension(j); - extensions.push_back(extension); - } - } - - if (files.size() == 1) { - GenerateHeader(options, files[0], &printer); - } else { - GenerateHeader(options, nullptr, &printer); - } - - std::set<std::string> provided; - FindProvides(options, &printer, files, &provided); - FindProvidesForFields(options, &printer, extensions, &provided); - GenerateProvides(options, &printer, &provided); - GenerateTestOnly(options, &printer); - GenerateRequiresForLibrary(options, &printer, files, &provided); - - GenerateFilesInDepOrder(options, &printer, files); - - for (int i = 0; i < extensions.size(); i++) { - if (ShouldGenerateExtension(extensions[i])) { - GenerateExtension(options, &printer, extensions[i]); - } - } - - if (printer.failed()) { - return false; - } - if (options.annotate_code) { - EmbedCodeAnnotations(annotations, &printer); - } - } else if (options.output_mode() == GeneratorOptions::kOneOutputFilePerSCC) { - std::set<const Descriptor*> have_printed; - SCCAnalyzer<DepsGenerator> analyzer; - std::map<const void*, std::string> allowed_map; - if (!GenerateJspbAllowedMap(options, files, &allowed_map, &analyzer)) { - return false; - } - - bool generated = false; - for (int i = 0; i < files.size(); i++) { - const FileDescriptor* file = files[i]; - // Force well known type to generate in a whole file. - if (IsWellKnownTypeFile(file)) { - if (!GenerateFile(file, options, context, true)) { - return false; - } - generated = true; - continue; - } - for (int j = 0; j < file->message_type_count(); j++) { - const Descriptor* desc = file->message_type(j); - if (have_printed.count(desc) || - allowed_map.count(analyzer.GetSCC(desc)) == 0) { - continue; - } - - generated = true; - const SCC* scc = analyzer.GetSCC(desc); - const std::string& filename = allowed_map[scc]; - std::unique_ptr<io::ZeroCopyOutputStream> output( - context->Open(filename)); - GOOGLE_CHECK(output.get()); - GeneratedCodeInfo annotations; - io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector( - &annotations); - io::Printer printer( - output.get(), '$', - options.annotate_code ? &annotation_collector : nullptr); - - GenerateHeader(options, file, &printer); - - std::set<std::string> provided; - for (auto one_desc : scc->descriptors) { - if (one_desc->containing_type() == nullptr) { - FindProvidesForMessage(options, &printer, one_desc, &provided); - } - } - GenerateProvides(options, &printer, &provided); - GenerateTestOnly(options, &printer); - GenerateRequiresForSCC(options, &printer, scc, &provided); - - for (auto one_desc : scc->descriptors) { - if (one_desc->containing_type() == nullptr) { - GenerateClassConstructorAndDeclareExtensionFieldInfo( - options, &printer, one_desc); - } - } - for (auto one_desc : scc->descriptors) { - if (one_desc->containing_type() == nullptr) { - GenerateClass(options, &printer, one_desc); - } - } - - for (auto one_desc : scc->descriptors) { - have_printed.insert(one_desc); - } - - if (printer.failed()) { - return false; - } - if (options.annotate_code) { - EmbedCodeAnnotations(annotations, &printer); - } - } - for (int j = 0; j < file->enum_type_count(); j++) { - const EnumDescriptor* enumdesc = file->enum_type(j); - if (allowed_map.count(enumdesc) == 0) { - continue; - } - - generated = true; - const std::string& filename = allowed_map[enumdesc]; - std::unique_ptr<io::ZeroCopyOutputStream> output( - context->Open(filename)); - GOOGLE_CHECK(output.get()); - GeneratedCodeInfo annotations; - io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector( - &annotations); - io::Printer printer( - output.get(), '$', - options.annotate_code ? &annotation_collector : nullptr); - - GenerateHeader(options, file, &printer); - - std::set<std::string> provided; - FindProvidesForEnum(options, &printer, enumdesc, &provided); - GenerateProvides(options, &printer, &provided); - GenerateTestOnly(options, &printer); - - GenerateEnum(options, &printer, enumdesc); - - if (printer.failed()) { - return false; - } - if (options.annotate_code) { - EmbedCodeAnnotations(annotations, &printer); - } - } - // File-level extensions (message-level extensions are generated under - // the enclosing message). - if (allowed_map.count(file) == 1) { - generated = true; - const std::string& filename = allowed_map[file]; - - std::unique_ptr<io::ZeroCopyOutputStream> output( - context->Open(filename)); - GOOGLE_CHECK(output.get()); - GeneratedCodeInfo annotations; - io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector( - &annotations); - io::Printer printer( - output.get(), '$', - options.annotate_code ? &annotation_collector : nullptr); - - GenerateHeader(options, file, &printer); - - std::set<std::string> provided; - std::vector<const FieldDescriptor*> fields; - - for (int j = 0; j < files[i]->extension_count(); j++) { - if (ShouldGenerateExtension(files[i]->extension(j))) { - fields.push_back(files[i]->extension(j)); - } - } - - FindProvidesForFields(options, &printer, fields, &provided); - GenerateProvides(options, &printer, &provided); - GenerateTestOnly(options, &printer); - GenerateRequiresForExtensions(options, &printer, fields, &provided); - - for (int j = 0; j < files[i]->extension_count(); j++) { - if (ShouldGenerateExtension(files[i]->extension(j))) { - GenerateExtension(options, &printer, files[i]->extension(j)); - } - } - if (options.annotate_code) { - EmbedCodeAnnotations(annotations, &printer); - } - } - } - if (!generated) { - std::string filename = options.output_dir + "/" + - "empty_no_content_void_file" + - options.GetFileNameExtension(); - std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename)); - } - } else /* options.output_mode() == kOneOutputFilePerInputFile */ { - // Generate one output file per input (.proto) file. - - for (int i = 0; i < files.size(); i++) { - const FileDescriptor* file = files[i]; - if (!GenerateFile(file, options, context, false)) { - return false; - } - } - } - return true; -} - -} // namespace js -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/r5dev/thirdparty/protobuf/compiler/js/js_generator.h b/r5dev/thirdparty/protobuf/compiler/js/js_generator.h deleted file mode 100644 index 29b8398b..00000000 --- a/r5dev/thirdparty/protobuf/compiler/js/js_generator.h +++ /dev/null @@ -1,336 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Generates JavaScript code for a given .proto file. -// -#ifndef GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__ - -#include <set> -#include <string> - -#include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/compiler/scc.h> -#include <thirdparty/protobuf/compiler/code_generator.h> - -#include <thirdparty/protobuf/port_def.inc> - -namespace google { -namespace protobuf { - -class Descriptor; -class EnumDescriptor; -class FieldDescriptor; -class OneofDescriptor; -class FileDescriptor; - -namespace io { -class Printer; -} - -namespace compiler { -namespace js { - -struct GeneratorOptions { - // Output path. - std::string output_dir; - // Namespace prefix. - std::string namespace_prefix; - // Enable binary-format support? - bool binary; - // What style of imports should be used. - enum ImportStyle { - kImportClosure, // goog.require() - kImportCommonJs, // require() - kImportCommonJsStrict, // require() with no global export - kImportBrowser, // no import statements - kImportEs6, // import { member } from '' - } import_style; - - GeneratorOptions() - : output_dir("."), - namespace_prefix(""), - binary(false), - import_style(kImportClosure), - add_require_for_enums(false), - testonly(false), - library(""), - extension(".js"), - one_output_file_per_input_file(false), - annotate_code(false) {} - - bool ParseFromOptions( - const std::vector<std::pair<std::string, std::string> >& options, - std::string* error); - - // Returns the file name extension to use for generated code. - std::string GetFileNameExtension() const { - return import_style == kImportClosure ? extension : "_pb.js"; - } - - enum OutputMode { - // Create an output file for each input .proto file. - kOneOutputFilePerInputFile, - // Create an output file for each type. - kOneOutputFilePerSCC, - // Put everything in a single file named by the library option. - kEverythingInOneFile, - }; - - // Indicates how to output the generated code based on the provided options. - OutputMode output_mode() const; - - // The remaining options are only relevant when we are using kImportClosure. - - // Add a `goog.requires()` call for each enum type used. If not set, a - // forward declaration with `goog.forwardDeclare` is produced instead. - bool add_require_for_enums; - // Set this as a test-only module via `goog.setTestOnly();`. - bool testonly; - // Create a library with name <name>_lib.js rather than a separate .js file - // per type? - std::string library; - // The extension to use for output file names. - std::string extension; - // Create a separate output file for each input file? - bool one_output_file_per_input_file; - // If true, we should append annotations as comments on the last line for - // generated .js file. Annotations used by tools like https://kythe.io - // to provide cross-references between .js and .proto files. Annotations - // are encoded as base64 proto of GeneratedCodeInfo message (see - // descriptor.proto). - bool annotate_code; -}; - -// CodeGenerator implementation which generates a JavaScript source file and -// header. If you create your own protocol compiler binary and you want it to -// support JavaScript output, you can do so by registering an instance of this -// CodeGenerator with the CommandLineInterface in your main() function. -class PROTOC_EXPORT Generator : public CodeGenerator { - public: - Generator() {} - virtual ~Generator() {} - - bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* context, std::string* error) const override { - *error = "Unimplemented Generate() method. Call GenerateAll() instead."; - return false; - } - - bool HasGenerateAll() const override { return true; } - - bool GenerateAll(const std::vector<const FileDescriptor*>& files, - const std::string& parameter, GeneratorContext* context, - std::string* error) const override; - - uint64 GetSupportedFeatures() const override { - return FEATURE_PROTO3_OPTIONAL; - } - - private: - void GenerateHeader(const GeneratorOptions& options, - const FileDescriptor* file, io::Printer* printer) const; - - // Generate goog.provides() calls. - void FindProvides(const GeneratorOptions& options, io::Printer* printer, - const std::vector<const FileDescriptor*>& file, - std::set<std::string>* provided) const; - void FindProvidesForFile(const GeneratorOptions& options, - io::Printer* printer, const FileDescriptor* file, - std::set<std::string>* provided) const; - void FindProvidesForMessage(const GeneratorOptions& options, - io::Printer* printer, const Descriptor* desc, - std::set<std::string>* provided) const; - void FindProvidesForEnum(const GeneratorOptions& options, - io::Printer* printer, const EnumDescriptor* enumdesc, - std::set<std::string>* provided) const; - // For extension fields at file scope. - void FindProvidesForFields(const GeneratorOptions& options, - io::Printer* printer, - const std::vector<const FieldDescriptor*>& fields, - std::set<std::string>* provided) const; - // Print the goog.provides() found by the methods above. - void GenerateProvides(const GeneratorOptions& options, io::Printer* printer, - std::set<std::string>* provided) const; - - // Generate goog.setTestOnly() if indicated. - void GenerateTestOnly(const GeneratorOptions& options, - io::Printer* printer) const; - - // Generate goog.requires() calls. - void GenerateRequiresForLibrary( - const GeneratorOptions& options, io::Printer* printer, - const std::vector<const FileDescriptor*>& files, - std::set<std::string>* provided) const; - void GenerateRequiresForSCC(const GeneratorOptions& options, - io::Printer* printer, const SCC* scc, - std::set<std::string>* provided) const; - // For extension fields at file scope. - void GenerateRequiresForExtensions( - const GeneratorOptions& options, io::Printer* printer, - const std::vector<const FieldDescriptor*>& fields, - std::set<std::string>* provided) const; - void GenerateRequiresImpl(const GeneratorOptions& options, - io::Printer* printer, - std::set<std::string>* required, - std::set<std::string>* forwards, - std::set<std::string>* provided, bool require_jspb, - bool require_extension, bool require_map) const; - void FindRequiresForMessage(const GeneratorOptions& options, - const Descriptor* desc, - std::set<std::string>* required, - std::set<std::string>* forwards, - bool* have_message) const; - void FindRequiresForField(const GeneratorOptions& options, - const FieldDescriptor* field, - std::set<std::string>* required, - std::set<std::string>* forwards) const; - void FindRequiresForExtension(const GeneratorOptions& options, - const FieldDescriptor* field, - std::set<std::string>* required, - std::set<std::string>* forwards) const; - // Generate all things in a proto file into one file. - // If use_short_name is true, the generated file's name will only be short - // name that without directory, otherwise filename equals file->name() - bool GenerateFile(const FileDescriptor* file, const GeneratorOptions& options, - GeneratorContext* context, bool use_short_name) const; - void GenerateFile(const GeneratorOptions& options, io::Printer* printer, - const FileDescriptor* file) const; - - // Generate definitions for all message classes and enums in all files, - // processing the files in dependence order. - void GenerateFilesInDepOrder( - const GeneratorOptions& options, io::Printer* printer, - const std::vector<const FileDescriptor*>& file) const; - // Helper for above. - void GenerateFileAndDeps(const GeneratorOptions& options, - io::Printer* printer, const FileDescriptor* root, - std::set<const FileDescriptor*>* all_files, - std::set<const FileDescriptor*>* generated) const; - - // Generate definitions for all message classes and enums. - void GenerateClassesAndEnums(const GeneratorOptions& options, - io::Printer* printer, - const FileDescriptor* file) const; - - void GenerateFieldValueExpression(io::Printer* printer, - const char* obj_reference, - const FieldDescriptor* field, - bool use_default) const; - - // Generate definition for one class. - void GenerateClass(const GeneratorOptions& options, io::Printer* printer, - const Descriptor* desc) const; - void GenerateClassConstructor(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const; - void GenerateClassFieldInfo(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const; - void GenerateClassConstructorAndDeclareExtensionFieldInfo( - const GeneratorOptions& options, io::Printer* printer, - const Descriptor* desc) const; - void GenerateClassXid(const GeneratorOptions& options, io::Printer* printer, - const Descriptor* desc) const; - void GenerateOneofCaseDefinition(const GeneratorOptions& options, - io::Printer* printer, - const OneofDescriptor* oneof) const; - void GenerateObjectTypedef(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const; - void GenerateClassToObject(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const; - void GenerateClassFieldToObject(const GeneratorOptions& options, - io::Printer* printer, - const FieldDescriptor* field) const; - void GenerateClassFromObject(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const; - void GenerateClassFieldFromObject(const GeneratorOptions& options, - io::Printer* printer, - const FieldDescriptor* field) const; - void GenerateClassRegistration(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const; - void GenerateClassFields(const GeneratorOptions& options, - io::Printer* printer, const Descriptor* desc) const; - void GenerateClassField(const GeneratorOptions& options, io::Printer* printer, - const FieldDescriptor* desc) const; - void GenerateClassExtensionFieldInfo(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const; - void GenerateClassDeserialize(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const; - void GenerateClassDeserializeBinary(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const; - void GenerateClassDeserializeBinaryField(const GeneratorOptions& options, - io::Printer* printer, - const FieldDescriptor* field) const; - void GenerateClassSerializeBinary(const GeneratorOptions& options, - io::Printer* printer, - const Descriptor* desc) const; - void GenerateClassSerializeBinaryField(const GeneratorOptions& options, - io::Printer* printer, - const FieldDescriptor* field) const; - - // Generate definition for one enum. - void GenerateEnum(const GeneratorOptions& options, io::Printer* printer, - const EnumDescriptor* enumdesc) const; - - // Generate an extension definition. - void GenerateExtension(const GeneratorOptions& options, io::Printer* printer, - const FieldDescriptor* field) const; - - // Generate addFoo() method for repeated primitive fields. - void GenerateRepeatedPrimitiveHelperMethods(const GeneratorOptions& options, - io::Printer* printer, - const FieldDescriptor* field, - bool untyped) const; - - // Generate addFoo() method for repeated message fields. - void GenerateRepeatedMessageHelperMethods(const GeneratorOptions& options, - io::Printer* printer, - const FieldDescriptor* field) const; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator); -}; - -} // namespace js -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <thirdparty/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__ diff --git a/r5dev/thirdparty/protobuf/compiler/js/well_known_types_embed.cc b/r5dev/thirdparty/protobuf/compiler/js/well_known_types_embed.cc deleted file mode 100644 index ae1687c6..00000000 --- a/r5dev/thirdparty/protobuf/compiler/js/well_known_types_embed.cc +++ /dev/null @@ -1,270 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include <thirdparty/protobuf/compiler/js/well_known_types_embed.h> - -struct FileToc well_known_types_js[] = { - {"any.js", - "/* This code will be inserted into generated code for\n" - " * google/protobuf/any.proto. */\n" - "\n" - "/**\n" - " * Returns the type name contained in this instance, if any.\n" - " * @return {string|undefined}\n" - " */\n" - "proto.google.protobuf.Any.prototype.getTypeName = function() {\n" - " return this.getTypeUrl().split('/').pop();\n" - "};\n" - "\n" - "\n" - "/**\n" - " * Packs the given message instance into this Any.\n" - " * For binary format usage only.\n" - " * @param {!Uint8Array} serialized The serialized data to pack.\n" - " * @param {string} name The type name of this message object.\n" - " * @param {string=} opt_typeUrlPrefix the type URL prefix.\n" - " */\n" - "proto.google.protobuf.Any.prototype.pack = function(serialized, name,\n" - " opt_typeUrlPrefix) " - "{\n" - " if (!opt_typeUrlPrefix) {\n" - " opt_typeUrlPrefix = 'type.googleapis.com/';\n" - " }\n" - "\n" - " if (opt_typeUrlPrefix.substr(-1) != '/') {\n" - " this.setTypeUrl(opt_typeUrlPrefix + '/' + name);\n" - " } else {\n" - " this.setTypeUrl(opt_typeUrlPrefix + name);\n" - " }\n" - "\n" - " this.setValue(serialized);\n" - "};\n" - "\n" - "\n" - "/**\n" - " * @template T\n" - " * Unpacks this Any into the given message object.\n" - " * @param {function(Uint8Array):T} deserialize Function that will " - "deserialize\n" - " * the binary data properly.\n" - " * @param {string} name The expected type name of this message object.\n" - " * @return {?T} If the name matched the expected name, returns the " - "deserialized\n" - " * object, otherwise returns null.\n" - " */\n" - "proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) " - "{\n" - " if (this.getTypeName() == name) {\n" - " return deserialize(this.getValue_asU8());\n" - " } else {\n" - " return null;\n" - " }\n" - "};\n" - }, - {"timestamp.js", - "/* This code will be inserted into generated code for\n" - " * google/protobuf/timestamp.proto. */\n" - "\n" - "/**\n" - " * Returns a JavaScript 'Date' object corresponding to this Timestamp.\n" - " * @return {!Date}\n" - " */\n" - "proto.google.protobuf.Timestamp.prototype.toDate = function() {\n" - " var seconds = this.getSeconds();\n" - " var nanos = this.getNanos();\n" - "\n" - " return new Date((seconds * 1000) + (nanos / 1000000));\n" - "};\n" - "\n" - "\n" - "/**\n" - " * Sets the value of this Timestamp object to be the given Date.\n" - " * @param {!Date} value The value to set.\n" - " */\n" - "proto.google.protobuf.Timestamp.prototype.fromDate = function(value) {\n" - " this.setSeconds(Math.floor(value.getTime() / 1000));\n" - " this.setNanos(value.getMilliseconds() * 1000000);\n" - "};\n" - "\n" - "\n" - "/**\n" - " * Factory method that returns a Timestamp object with value equal to\n" - " * the given Date.\n" - " * @param {!Date} value The value to set.\n" - " * @return {!proto.google.protobuf.Timestamp}\n" - " */\n" - "proto.google.protobuf.Timestamp.fromDate = function(value) {\n" - " var timestamp = new proto.google.protobuf.Timestamp();\n" - " timestamp.fromDate(value);\n" - " return timestamp;\n" - "};\n"}, - {"struct.js", - "/* This code will be inserted into generated code for\n" - " * google/protobuf/struct.proto. */\n" - "\n" - "/**\n" - " * Typedef representing plain JavaScript values that can go into a\n" - " * Struct.\n" - " * @typedef {null|number|string|boolean|Array|Object}\n" - " */\n" - "proto.google.protobuf.JavaScriptValue;\n" - "\n" - "\n" - "/**\n" - " * Converts this Value object to a plain JavaScript value.\n" - " * @return {?proto.google.protobuf.JavaScriptValue} a plain JavaScript\n" - " * value representing this Struct.\n" - " */\n" - "proto.google.protobuf.Value.prototype.toJavaScript = function() {\n" - " var kindCase = proto.google.protobuf.Value.KindCase;\n" - " switch (this.getKindCase()) {\n" - " case kindCase.NULL_VALUE:\n" - " return null;\n" - " case kindCase.NUMBER_VALUE:\n" - " return this.getNumberValue();\n" - " case kindCase.STRING_VALUE:\n" - " return this.getStringValue();\n" - " case kindCase.BOOL_VALUE:\n" - " return this.getBoolValue();\n" - " case kindCase.STRUCT_VALUE:\n" - " return this.getStructValue().toJavaScript();\n" - " case kindCase.LIST_VALUE:\n" - " return this.getListValue().toJavaScript();\n" - " default:\n" - " throw new Error('Unexpected struct type');\n" - " }\n" - "};\n" - "\n" - "\n" - "/**\n" - " * Converts this JavaScript value to a new Value proto.\n" - " * @param {!proto.google.protobuf.JavaScriptValue} value The value to\n" - " * convert.\n" - " * @return {!proto.google.protobuf.Value} The newly constructed value.\n" - " */\n" - "proto.google.protobuf.Value.fromJavaScript = function(value) {\n" - " var ret = new proto.google.protobuf.Value();\n" - " switch (goog.typeOf(value)) {\n" - " case 'string':\n" - " ret.setStringValue(/** @type {string} */ (value));\n" - " break;\n" - " case 'number':\n" - " ret.setNumberValue(/** @type {number} */ (value));\n" - " break;\n" - " case 'boolean':\n" - " ret.setBoolValue(/** @type {boolean} */ (value));\n" - " break;\n" - " case 'null':\n" - " ret.setNullValue(proto.google.protobuf.NullValue.NULL_VALUE);\n" - " break;\n" - " case 'array':\n" - " ret.setListValue(proto.google.protobuf.ListValue.fromJavaScript(\n" - " /** @type{!Array} */ (value)));\n" - " break;\n" - " case 'object':\n" - " ret.setStructValue(proto.google.protobuf.Struct.fromJavaScript(\n" - " /** @type{!Object} */ (value)));\n" - " break;\n" - " default:\n" - " throw new Error('Unexpected struct type.');\n" - " }\n" - "\n" - " return ret;\n" - "};\n" - "\n" - "\n" - "/**\n" - " * Converts this ListValue object to a plain JavaScript array.\n" - " * @return {!Array} a plain JavaScript array representing this List.\n" - " */\n" - "proto.google.protobuf.ListValue.prototype.toJavaScript = function() {\n" - " var ret = [];\n" - " var values = this.getValuesList();\n" - "\n" - " for (var i = 0; i < values.length; i++) {\n" - " ret[i] = values[i].toJavaScript();\n" - " }\n" - "\n" - " return ret;\n" - "};\n" - "\n" - "\n" - "/**\n" - " * Constructs a ListValue protobuf from this plain JavaScript array.\n" - " * @param {!Array} array a plain JavaScript array\n" - " * @return {proto.google.protobuf.ListValue} a new ListValue object\n" - " */\n" - "proto.google.protobuf.ListValue.fromJavaScript = function(array) {\n" - " var ret = new proto.google.protobuf.ListValue();\n" - "\n" - " for (var i = 0; i < array.length; i++) {\n" - " " - "ret.addValues(proto.google.protobuf.Value.fromJavaScript(array[i]));\n" - " }\n" - "\n" - " return ret;\n" - "};\n" - "\n" - "\n" - "/**\n" - " * Converts this Struct object to a plain JavaScript object.\n" - " * @return {!Object<string, !proto.google.protobuf.JavaScriptValue>} a " - "plain\n" - " * JavaScript object representing this Struct.\n" - " */\n" - "proto.google.protobuf.Struct.prototype.toJavaScript = function() {\n" - " var ret = {};\n" - "\n" - " this.getFieldsMap().forEach(function(value, key) {\n" - " ret[key] = value.toJavaScript();\n" - " });\n" - "\n" - " return ret;\n" - "};\n" - "\n" - "\n" - "/**\n" - " * Constructs a Struct protobuf from this plain JavaScript object.\n" - " * @param {!Object} obj a plain JavaScript object\n" - " * @return {proto.google.protobuf.Struct} a new Struct object\n" - " */\n" - "proto.google.protobuf.Struct.fromJavaScript = function(obj) {\n" - " var ret = new proto.google.protobuf.Struct();\n" - " var map = ret.getFieldsMap();\n" - "\n" - " for (var property in obj) {\n" - " var val = obj[property];\n" - " map.set(property, proto.google.protobuf.Value.fromJavaScript(val));\n" - " }\n" - "\n" - " return ret;\n" - "};\n"}, - {NULL, NULL} // Terminate the list. -}; diff --git a/r5dev/thirdparty/protobuf/compiler/main.cc b/r5dev/thirdparty/protobuf/compiler/main.cc index a9ea0169..138a3cb1 100644 --- a/r5dev/thirdparty/protobuf/compiler/main.cc +++ b/r5dev/thirdparty/protobuf/compiler/main.cc @@ -28,17 +28,18 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <thirdparty/protobuf/compiler/cpp/cpp_generator.h> -#include <thirdparty/protobuf/compiler/java/java_generator.h> -#include <thirdparty/protobuf/compiler/java/java_kotlin_generator.h> -#include <thirdparty/protobuf/compiler/js/js_generator.h> +#include <thirdparty/protobuf/compiler/cpp/generator.h> +#include <thirdparty/protobuf/compiler/java/generator.h> +#include <thirdparty/protobuf/compiler/java/kotlin_generator.h> #include <thirdparty/protobuf/compiler/command_line_interface.h> -#include <thirdparty/protobuf/compiler/python/python_generator.h> #include <thirdparty/protobuf/compiler/csharp/csharp_generator.h> #include <thirdparty/protobuf/compiler/objectivec/objectivec_generator.h> #include <thirdparty/protobuf/compiler/php/php_generator.h> +#include <thirdparty/protobuf/compiler/python/generator.h> +#include <thirdparty/protobuf/compiler/python/pyi_generator.h> #include <thirdparty/protobuf/compiler/ruby/ruby_generator.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -75,6 +76,10 @@ int ProtobufMain(int argc, char* argv[]) { python::Generator py_generator; cli.RegisterGenerator("--python_out", "--python_opt", &py_generator, "Generate Python source file."); + // Python pyi + python::PyiGenerator pyi_generator; + cli.RegisterGenerator("--pyi_out", &pyi_generator, + "Generate python pyi stub."); // PHP php::Generator php_generator; @@ -96,11 +101,6 @@ int ProtobufMain(int argc, char* argv[]) { cli.RegisterGenerator("--objc_out", "--objc_opt", &objc_generator, "Generate Objective-C header and source."); - // JavaScript - js::Generator js_generator; - cli.RegisterGenerator("--js_out", "--js_opt", &js_generator, - "Generate JavaScript source."); - return cli.Run(argc, argv); } diff --git a/r5dev/thirdparty/protobuf/compiler/mock_code_generator.cc b/r5dev/thirdparty/protobuf/compiler/mock_code_generator.cc index 2b910d3b..6183907e 100644 --- a/r5dev/thirdparty/protobuf/compiler/mock_code_generator.cc +++ b/r5dev/thirdparty/protobuf/compiler/mock_code_generator.cc @@ -47,13 +47,13 @@ #include <thirdparty/protobuf/testing/file.h> #include <thirdparty/protobuf/testing/file.h> #include <thirdparty/protobuf/compiler/plugin.pb.h> -#include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/descriptor.pb.h> -#include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/text_format.h> #include <gtest/gtest.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/io/printer.h> +#include <thirdparty/protobuf/io/zero_copy_stream.h> +#include <thirdparty/protobuf/text_format.h> #ifdef major #undef major @@ -315,7 +315,7 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file, io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector( &annotations); io::Printer printer(output.get(), '$', - annotate ? &annotation_collector : NULL); + annotate ? &annotation_collector : nullptr); printer.PrintRaw(GetOutputFileContent(name_, parameter, file, context)); std::string annotate_suffix = "_annotation"; if (annotate) { diff --git a/r5dev/thirdparty/protobuf/compiler/mock_code_generator.h b/r5dev/thirdparty/protobuf/compiler/mock_code_generator.h index a6423d46..94e34f4b 100644 --- a/r5dev/thirdparty/protobuf/compiler/mock_code_generator.h +++ b/r5dev/thirdparty/protobuf/compiler/mock_code_generator.h @@ -78,7 +78,7 @@ namespace compiler { class MockCodeGenerator : public CodeGenerator { public: MockCodeGenerator(const std::string& name); - virtual ~MockCodeGenerator(); + ~MockCodeGenerator() override; // Expect (via gTest) that a MockCodeGenerator with the given name was called // with the given parameters by inspecting the output location. diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_enum_field.cc b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_enum_field.cc index fa186aeb..50823ea8 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_enum_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_enum_field.cc @@ -34,7 +34,6 @@ #include <thirdparty/protobuf/compiler/objectivec/objectivec_enum_field.h> #include <thirdparty/protobuf/compiler/objectivec/objectivec_helpers.h> #include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/wire_format.h> namespace google { namespace protobuf { @@ -65,9 +64,8 @@ void SetEnumVariables(const FieldDescriptor* descriptor, } } // namespace -EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : SingleFieldGenerator(descriptor, options) { +EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor) + : SingleFieldGenerator(descriptor) { SetEnumVariables(descriptor, &variables_); } @@ -116,12 +114,16 @@ void EnumFieldGenerator::GenerateCFunctionImplementations( } void EnumFieldGenerator::DetermineForwardDeclarations( - std::set<std::string>* fwd_decls) const { - SingleFieldGenerator::DetermineForwardDeclarations(fwd_decls); - // If it is an enum defined in a different file, then we'll need a forward - // declaration for it. When it is in our file, all the enums are output - // before the message, so it will be declared before it is needed. - if (descriptor_->file() != descriptor_->enum_type()->file()) { + std::set<std::string>* fwd_decls, + bool include_external_types) const { + SingleFieldGenerator::DetermineForwardDeclarations( + fwd_decls, include_external_types); + // If it is an enum defined in a different file (and not a WKT), then we'll + // need a forward declaration for it. When it is in our file, all the enums + // are output before the message, so it will be declared before it is needed. + if (include_external_types && + descriptor_->file() != descriptor_->enum_type()->file() && + !IsProtobufLibraryBundledProtoFile(descriptor_->enum_type()->file())) { // Enum name is already in "storage_type". const std::string& name = variable("storage_type"); fwd_decls->insert("GPB_ENUM_FWD_DECLARE(" + name + ")"); @@ -129,8 +131,8 @@ void EnumFieldGenerator::DetermineForwardDeclarations( } RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator( - const FieldDescriptor* descriptor, const Options& options) - : RepeatedFieldGenerator(descriptor, options) { + const FieldDescriptor* descriptor) + : RepeatedFieldGenerator(descriptor) { SetEnumVariables(descriptor, &variables_); variables_["array_storage_type"] = "GPBEnumArray"; } diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_enum_field.h b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_enum_field.h index f6ac1ff1..2218b399 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_enum_field.h +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_enum_field.h @@ -41,8 +41,7 @@ namespace compiler { namespace objectivec { class EnumFieldGenerator : public SingleFieldGenerator { - friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field, - const Options& options); + friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); EnumFieldGenerator(const EnumFieldGenerator&) = delete; EnumFieldGenerator& operator=(const EnumFieldGenerator&) = delete; @@ -53,23 +52,22 @@ class EnumFieldGenerator : public SingleFieldGenerator { virtual void GenerateCFunctionImplementations( io::Printer* printer) const override; virtual void DetermineForwardDeclarations( - std::set<std::string>* fwd_decls) const override; + std::set<std::string>* fwd_decls, + bool include_external_types) const override; protected: - EnumFieldGenerator(const FieldDescriptor* descriptor, const Options& options); + explicit EnumFieldGenerator(const FieldDescriptor* descriptor); virtual ~EnumFieldGenerator(); }; class RepeatedEnumFieldGenerator : public RepeatedFieldGenerator { - friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field, - const Options& options); + friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); public: virtual void FinishInitialization() override; protected: - RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); + explicit RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor); virtual ~RepeatedEnumFieldGenerator(); }; diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_field.cc b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_field.cc index 4f7534cf..0cb675ab 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_field.cc @@ -37,7 +37,6 @@ #include <thirdparty/protobuf/compiler/objectivec/objectivec_message_field.h> #include <thirdparty/protobuf/compiler/objectivec/objectivec_primitive_field.h> #include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/stubs/strutil.h> namespace google { @@ -118,40 +117,39 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, } // namespace -FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field, - const Options& options) { +FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field) { FieldGenerator* result = NULL; if (field->is_repeated()) { switch (GetObjectiveCType(field)) { case OBJECTIVECTYPE_MESSAGE: { if (field->is_map()) { - result = new MapFieldGenerator(field, options); + result = new MapFieldGenerator(field); } else { - result = new RepeatedMessageFieldGenerator(field, options); + result = new RepeatedMessageFieldGenerator(field); } break; } case OBJECTIVECTYPE_ENUM: - result = new RepeatedEnumFieldGenerator(field, options); + result = new RepeatedEnumFieldGenerator(field); break; default: - result = new RepeatedPrimitiveFieldGenerator(field, options); + result = new RepeatedPrimitiveFieldGenerator(field); break; } } else { switch (GetObjectiveCType(field)) { case OBJECTIVECTYPE_MESSAGE: { - result = new MessageFieldGenerator(field, options); + result = new MessageFieldGenerator(field); break; } case OBJECTIVECTYPE_ENUM: - result = new EnumFieldGenerator(field, options); + result = new EnumFieldGenerator(field); break; default: if (IsReferenceType(field)) { - result = new PrimitiveObjFieldGenerator(field, options); + result = new PrimitiveObjFieldGenerator(field); } else { - result = new PrimitiveFieldGenerator(field, options); + result = new PrimitiveFieldGenerator(field); } break; } @@ -160,8 +158,7 @@ FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field, return result; } -FieldGenerator::FieldGenerator(const FieldDescriptor* descriptor, - const Options& options) +FieldGenerator::FieldGenerator(const FieldDescriptor* descriptor) : descriptor_(descriptor) { SetCommonFieldVariables(descriptor, &variables_); } @@ -185,7 +182,8 @@ void FieldGenerator::GenerateCFunctionImplementations( } void FieldGenerator::DetermineForwardDeclarations( - std::set<std::string>* fwd_decls) const { + std::set<std::string>* fwd_decls, + bool include_external_types) const { // Nothing } @@ -266,9 +264,8 @@ void FieldGenerator::FinishInitialization(void) { } } -SingleFieldGenerator::SingleFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : FieldGenerator(descriptor, options) { +SingleFieldGenerator::SingleFieldGenerator(const FieldDescriptor* descriptor) + : FieldGenerator(descriptor) { // Nothing } @@ -310,9 +307,8 @@ bool SingleFieldGenerator::RuntimeUsesHasBit(void) const { return true; } -ObjCObjFieldGenerator::ObjCObjFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : SingleFieldGenerator(descriptor, options) { +ObjCObjFieldGenerator::ObjCObjFieldGenerator(const FieldDescriptor* descriptor) + : SingleFieldGenerator(descriptor) { variables_["property_storage_attribute"] = "strong"; if (IsRetainedName(variables_["name"])) { variables_["storage_attribute"] = " NS_RETURNS_NOT_RETAINED"; @@ -353,8 +349,8 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration( } RepeatedFieldGenerator::RepeatedFieldGenerator( - const FieldDescriptor* descriptor, const Options& options) - : ObjCObjFieldGenerator(descriptor, options) { + const FieldDescriptor* descriptor) + : ObjCObjFieldGenerator(descriptor) { // Default to no comment and let the cases needing it fill it in. variables_["array_comment"] = ""; } @@ -407,19 +403,18 @@ bool RepeatedFieldGenerator::RuntimeUsesHasBit(void) const { return false; // The array (or map/dict) having anything is what is used. } -FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor, - const Options& options) +FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor) : descriptor_(descriptor), field_generators_(descriptor->field_count()), extension_generators_(descriptor->extension_count()) { // Construct all the FieldGenerators. for (int i = 0; i < descriptor->field_count(); i++) { field_generators_[i].reset( - FieldGenerator::Make(descriptor->field(i), options)); + FieldGenerator::Make(descriptor->field(i))); } for (int i = 0; i < descriptor->extension_count(); i++) { extension_generators_[i].reset( - FieldGenerator::Make(descriptor->extension(i), options)); + FieldGenerator::Make(descriptor->extension(i))); } } diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_field.h b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_field.h index a436ba45..328ad09c 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_field.h +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_field.h @@ -33,7 +33,6 @@ #include <map> #include <string> -#include <thirdparty/protobuf/compiler/objectivec/objectivec_helpers.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/io/printer.h> @@ -44,8 +43,7 @@ namespace objectivec { class FieldGenerator { public: - static FieldGenerator* Make(const FieldDescriptor* field, - const Options& options); + static FieldGenerator* Make(const FieldDescriptor* field); virtual ~FieldGenerator(); @@ -66,7 +64,8 @@ class FieldGenerator { // Exposed for subclasses, should always call it on the parent class also. virtual void DetermineForwardDeclarations( - std::set<std::string>* fwd_decls) const; + std::set<std::string>* fwd_decls, + bool include_external_types) const; virtual void DetermineObjectiveCClassDefinitions( std::set<std::string>* fwd_decls) const; @@ -96,7 +95,7 @@ class FieldGenerator { std::string raw_field_name() const { return variable("raw_field_name"); } protected: - FieldGenerator(const FieldDescriptor* descriptor, const Options& options); + explicit FieldGenerator(const FieldDescriptor* descriptor); virtual void FinishInitialization(void); bool WantsHasProperty(void) const; @@ -120,8 +119,7 @@ class SingleFieldGenerator : public FieldGenerator { virtual bool RuntimeUsesHasBit(void) const override; protected: - SingleFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); + explicit SingleFieldGenerator(const FieldDescriptor* descriptor); }; // Subclass with common support for when the field ends up as an ObjC Object. @@ -136,8 +134,7 @@ class ObjCObjFieldGenerator : public SingleFieldGenerator { virtual void GeneratePropertyDeclaration(io::Printer* printer) const override; protected: - ObjCObjFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); + explicit ObjCObjFieldGenerator(const FieldDescriptor* descriptor); }; class RepeatedFieldGenerator : public ObjCObjFieldGenerator { @@ -155,15 +152,14 @@ class RepeatedFieldGenerator : public ObjCObjFieldGenerator { virtual bool RuntimeUsesHasBit(void) const override; protected: - RepeatedFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); + explicit RepeatedFieldGenerator(const FieldDescriptor* descriptor); virtual void FinishInitialization(void) override; }; // Convenience class which constructs FieldGenerators for a Descriptor. class FieldGeneratorMap { public: - FieldGeneratorMap(const Descriptor* descriptor, const Options& options); + explicit FieldGeneratorMap(const Descriptor* descriptor); ~FieldGeneratorMap(); FieldGeneratorMap(const FieldGeneratorMap&) = delete; diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_file.cc b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_file.cc index b6bafbe8..40f3e5f5 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_file.cc +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_file.cc @@ -31,6 +31,7 @@ #include <thirdparty/protobuf/compiler/objectivec/objectivec_file.h> #include <thirdparty/protobuf/compiler/objectivec/objectivec_enum.h> #include <thirdparty/protobuf/compiler/objectivec/objectivec_extension.h> +#include <thirdparty/protobuf/compiler/objectivec/objectivec_helpers.h> #include <thirdparty/protobuf/compiler/objectivec/objectivec_message.h> #include <thirdparty/protobuf/compiler/code_generator.h> #include <thirdparty/protobuf/io/printer.h> @@ -56,6 +57,10 @@ const int32_t GOOGLE_PROTOBUF_OBJC_VERSION = 30004; const char* kHeaderExtension = ".pbobjc.h"; +std::string BundledFileName(const FileDescriptor* file) { + return "GPB" + FilePathBasename(file) + kHeaderExtension; +} + // Checks if a message contains any enums definitions (on the message or // a nested message under it). bool MessageContainsEnums(const Descriptor* message) { @@ -112,46 +117,77 @@ bool FileContainsExtensions(const FileDescriptor* file) { return false; } -// Helper for CollectMinimalFileDepsContainingExtensionsWorker that marks all -// deps as visited and prunes them from the needed files list. -void PruneFileAndDepsMarkingAsVisited( - const FileDescriptor* file, - std::vector<const FileDescriptor*>* files, - std::set<const FileDescriptor*>* files_visited) { - std::vector<const FileDescriptor*>::iterator iter = - std::find(files->begin(), files->end(), file); - if (iter != files->end()) { - files->erase(iter); - } - files_visited->insert(file); +bool IsDirectDependency(const FileDescriptor* dep, const FileDescriptor* file) { for (int i = 0; i < file->dependency_count(); i++) { - PruneFileAndDepsMarkingAsVisited(file->dependency(i), files, files_visited); + if (dep == file->dependency(i)) { + return true; + } } + return false; } -// Helper for CollectMinimalFileDepsContainingExtensions. -void CollectMinimalFileDepsContainingExtensionsWorker( - const FileDescriptor* file, - std::vector<const FileDescriptor*>* files, - std::set<const FileDescriptor*>* files_visited) { - if (files_visited->find(file) != files_visited->end()) { - return; +struct FileDescriptorsOrderedByName { + inline bool operator()(const FileDescriptor* a, + const FileDescriptor* b) const { + return a->name() < b->name(); } - files_visited->insert(file); +}; - if (FileContainsExtensions(file)) { - files->push_back(file); - for (int i = 0; i < file->dependency_count(); i++) { - const FileDescriptor* dep = file->dependency(i); - PruneFileAndDepsMarkingAsVisited(dep, files, files_visited); - } - } else { - for (int i = 0; i < file->dependency_count(); i++) { - const FileDescriptor* dep = file->dependency(i); - CollectMinimalFileDepsContainingExtensionsWorker(dep, files, - files_visited); +} // namespace + +FileGenerator::CommonState::CommonState() { } + +const FileGenerator::CommonState::MinDepsEntry& +FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensionsInternal( + const FileDescriptor* file) { + auto it = deps_info_cache_.find(file); + if (it != deps_info_cache_.end()) { + return it->second; + } + + std::set<const FileDescriptor*> min_deps_collector; + std::set<const FileDescriptor*> covered_deps_collector; + std::set<const FileDescriptor*> to_prune; + for (int i = 0; i < file->dependency_count(); i++) { + const FileDescriptor* dep = file->dependency(i); + MinDepsEntry dep_info = + CollectMinimalFileDepsContainingExtensionsInternal(dep); + + // Everything the dep covered, this file will also cover. + covered_deps_collector.insert(dep_info.covered_deps.begin(), dep_info.covered_deps.end()); + // Prune everything from the dep's covered list in case another dep lists it + // as a min dep. + to_prune.insert(dep_info.covered_deps.begin(), dep_info.covered_deps.end()); + + // Does the dep have any extensions... + if (dep_info.has_extensions) { + // Yes -> Add this file, prune its min_deps and add them to the covered deps. + min_deps_collector.insert(dep); + to_prune.insert(dep_info.min_deps.begin(), dep_info.min_deps.end()); + covered_deps_collector.insert(dep_info.min_deps.begin(), dep_info.min_deps.end()); + } else { + // No -> Just use its min_deps. + min_deps_collector.insert(dep_info.min_deps.begin(), dep_info.min_deps.end()); } } + + const bool file_has_exts = FileContainsExtensions(file); + + // Fast path: if nothing to prune or there was only one dep, the prune work is + // a waste, skip it. + if (to_prune.empty() || file->dependency_count() == 1) { + return deps_info_cache_.insert( + {file, {file_has_exts, min_deps_collector, covered_deps_collector}}).first->second; + } + + std::set<const FileDescriptor*> min_deps; + std::copy_if(min_deps_collector.begin(), min_deps_collector.end(), + std::inserter(min_deps, min_deps.end()), + [&](const FileDescriptor* value){ + return to_prune.find(value) == to_prune.end(); + }); + return deps_info_cache_.insert( + {file, {file_has_exts, min_deps, covered_deps_collector}}).first->second; } // Collect the deps of the given file that contain extensions. This can be used to @@ -163,40 +199,32 @@ void CollectMinimalFileDepsContainingExtensionsWorker( // There are comments about what the expected code should be line and limited // testing objectivec/Tests/GPBUnittestProtos2.m around compilation (#imports // specifically). -void CollectMinimalFileDepsContainingExtensions( - const FileDescriptor* file, - std::vector<const FileDescriptor*>* files) { - std::set<const FileDescriptor*> files_visited; - for (int i = 0; i < file->dependency_count(); i++) { - const FileDescriptor* dep = file->dependency(i); - CollectMinimalFileDepsContainingExtensionsWorker(dep, files, - &files_visited); - } +const std::vector<const FileDescriptor*> +FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensions( + const FileDescriptor* file) { + std::set<const FileDescriptor*> min_deps = + CollectMinimalFileDepsContainingExtensionsInternal(file).min_deps; + // Sort the list since pointer order isn't stable across runs. + std::vector<const FileDescriptor*> result(min_deps.begin(), min_deps.end()); + std::sort(result.begin(), result.end(), FileDescriptorsOrderedByName()); + return result; } -bool IsDirectDependency(const FileDescriptor* dep, const FileDescriptor* file) { - for (int i = 0; i < file->dependency_count(); i++) { - if (dep == file->dependency(i)) { - return true; - } - } - return false; -} - -} // namespace - -FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) +FileGenerator::FileGenerator(const FileDescriptor* file, + const GenerationOptions& generation_options, + CommonState& common_state) : file_(file), + generation_options_(generation_options), + common_state_(common_state), root_class_name_(FileClassName(file)), - is_bundled_proto_(IsProtobufLibraryBundledProtoFile(file)), - options_(options) { + is_bundled_proto_(IsProtobufLibraryBundledProtoFile(file)) { for (int i = 0; i < file_->enum_type_count(); i++) { EnumGenerator* generator = new EnumGenerator(file_->enum_type(i)); enum_generators_.emplace_back(generator); } for (int i = 0; i < file_->message_type_count(); i++) { MessageGenerator* generator = - new MessageGenerator(root_class_name_, file_->message_type(i), options_); + new MessageGenerator(root_class_name_, file_->message_type(i)); message_generators_.emplace_back(generator); } for (int i = 0; i < file_->extension_count(); i++) { @@ -216,6 +244,10 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { headers.push_back("GPBDescriptor.h"); headers.push_back("GPBMessage.h"); headers.push_back("GPBRootObject.h"); + for (int i = 0; i < file_->dependency_count(); i++) { + const std::string header_name = BundledFileName(file_->dependency(i)); + headers.push_back(header_name); + } } else { headers.push_back("GPBProtocolBuffers.h"); } @@ -237,16 +269,26 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { "\n", "google_protobuf_objc_version", StrCat(GOOGLE_PROTOBUF_OBJC_VERSION)); - // #import any headers for "public imports" in the proto file. + // The bundled protos (WKTs) don't use of forward declarations. + bool headers_use_forward_declarations = + generation_options_.headers_use_forward_declarations && !is_bundled_proto_; + { ImportWriter import_writer( - options_.generate_for_named_framework, - options_.named_framework_to_proto_path_mappings_path, - options_.runtime_import_prefix, - is_bundled_proto_); + generation_options_.generate_for_named_framework, + generation_options_.named_framework_to_proto_path_mappings_path, + generation_options_.runtime_import_prefix, + /* include_wkt_imports = */ false); const std::string header_extension(kHeaderExtension); - for (int i = 0; i < file_->public_dependency_count(); i++) { - import_writer.AddFile(file_->public_dependency(i), header_extension); + if (headers_use_forward_declarations) { + // #import any headers for "public imports" in the proto file. + for (int i = 0; i < file_->public_dependency_count(); i++) { + import_writer.AddFile(file_->public_dependency(i), header_extension); + } + } else { + for (int i = 0; i < file_->dependency_count(); i++) { + import_writer.AddFile(file_->dependency(i), header_extension); + } } import_writer.Print(printer); } @@ -266,7 +308,9 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { std::set<std::string> fwd_decls; for (const auto& generator : message_generators_) { - generator->DetermineForwardDeclarations(&fwd_decls); + generator->DetermineForwardDeclarations( + &fwd_decls, + /* include_external_types = */ headers_use_forward_declarations); } for (std::set<std::string>::const_iterator i(fwd_decls.begin()); i != fwd_decls.end(); ++i) { @@ -340,6 +384,9 @@ void FileGenerator::GenerateSource(io::Printer* printer) { // #import the runtime support. std::vector<std::string> headers; headers.push_back("GPBProtocolBuffers_RuntimeSupport.h"); + if (is_bundled_proto_) { + headers.push_back(BundledFileName(file_)); + } PrintFileRuntimePreamble(printer, headers); // Enums use atomic in the generated code, so add the system import as needed. @@ -349,31 +396,37 @@ void FileGenerator::GenerateSource(io::Printer* printer) { "\n"); } - std::vector<const FileDescriptor*> deps_with_extensions; - CollectMinimalFileDepsContainingExtensions(file_, &deps_with_extensions); + std::vector<const FileDescriptor*> deps_with_extensions = + common_state_.CollectMinimalFileDepsContainingExtensions(file_); + + // The bundled protos (WKTs) don't use of forward declarations. + bool headers_use_forward_declarations = + generation_options_.headers_use_forward_declarations && !is_bundled_proto_; { ImportWriter import_writer( - options_.generate_for_named_framework, - options_.named_framework_to_proto_path_mappings_path, - options_.runtime_import_prefix, - is_bundled_proto_); + generation_options_.generate_for_named_framework, + generation_options_.named_framework_to_proto_path_mappings_path, + generation_options_.runtime_import_prefix, + /* include_wkt_imports = */ false); const std::string header_extension(kHeaderExtension); // #import the header for this proto file. import_writer.AddFile(file_, header_extension); - // #import the headers for anything that a plain dependency of this proto - // file (that means they were just an include, not a "public" include). - std::set<std::string> public_import_names; - for (int i = 0; i < file_->public_dependency_count(); i++) { - public_import_names.insert(file_->public_dependency(i)->name()); - } - for (int i = 0; i < file_->dependency_count(); i++) { - const FileDescriptor *dep = file_->dependency(i); - bool public_import = (public_import_names.count(dep->name()) != 0); - if (!public_import) { - import_writer.AddFile(dep, header_extension); + if (headers_use_forward_declarations) { + // #import the headers for anything that a plain dependency of this proto + // file (that means they were just an include, not a "public" include). + std::set<std::string> public_import_names; + for (int i = 0; i < file_->public_dependency_count(); i++) { + public_import_names.insert(file_->public_dependency(i)->name()); + } + for (int i = 0; i < file_->dependency_count(); i++) { + const FileDescriptor *dep = file_->dependency(i); + bool public_import = (public_import_names.count(dep->name()) != 0); + if (!public_import) { + import_writer.AddFile(dep, header_extension); + } } } @@ -599,8 +652,26 @@ void FileGenerator::PrintFileRuntimePreamble( "// source: $filename$\n" "\n", "filename", file_->name()); - ImportWriter::PrintRuntimeImports( - printer, headers_to_import, options_.runtime_import_prefix, true); + + if (is_bundled_proto_) { + // This is basically a clone of ImportWriter::PrintRuntimeImports() but + // without the CPP symbol gate, since within the bundled files, that isn't + // needed. + std::string import_prefix = generation_options_.runtime_import_prefix; + if (!import_prefix.empty()) { + import_prefix += "/"; + } + for (const auto& header : headers_to_import) { + printer->Print( + "#import \"$import_prefix$$header$\"\n", + "import_prefix", import_prefix, + "header", header); + } + } else { + ImportWriter::PrintRuntimeImports( + printer, headers_to_import, generation_options_.runtime_import_prefix, true); + } + printer->Print("\n"); } diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_file.h b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_file.h index af89c922..7bac5cc2 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_file.h +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_file.h @@ -31,10 +31,10 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FILE_H__ #define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FILE_H__ -#include <string> +#include <map> #include <set> +#include <string> #include <vector> -#include <thirdparty/protobuf/compiler/objectivec/objectivec_helpers.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/io/printer.h> @@ -49,7 +49,40 @@ class MessageGenerator; class FileGenerator { public: - FileGenerator(const FileDescriptor* file, const Options& options); + struct GenerationOptions { + GenerationOptions() + // TODO(thomasvl): Eventually flip this default to false for better + // interop with Swift if proto usages span modules made from ObjC sources. + : headers_use_forward_declarations(true) {} + std::string generate_for_named_framework; + std::string named_framework_to_proto_path_mappings_path; + std::string runtime_import_prefix; + bool headers_use_forward_declarations; + }; + + // Wrapper for some common state that is shared between file generations to + // improve performance when more than one file is generated at a time. + struct CommonState { + CommonState(); + + const std::vector<const FileDescriptor*> + CollectMinimalFileDepsContainingExtensions(const FileDescriptor* file); + + private: + struct MinDepsEntry { + bool has_extensions; + std::set<const FileDescriptor*> min_deps; + // `covered_deps` are the transtive deps of `min_deps_w_exts` that also + // have extensions. + std::set<const FileDescriptor*> covered_deps; + }; + const MinDepsEntry& CollectMinimalFileDepsContainingExtensionsInternal(const FileDescriptor* file); + std::map<const FileDescriptor*, MinDepsEntry> deps_info_cache_; + }; + + FileGenerator(const FileDescriptor* file, + const GenerationOptions& generation_options, + CommonState& common_state); ~FileGenerator(); FileGenerator(const FileGenerator&) = delete; @@ -60,6 +93,8 @@ class FileGenerator { private: const FileDescriptor* file_; + const GenerationOptions& generation_options_; + CommonState& common_state_; std::string root_class_name_; bool is_bundled_proto_; @@ -67,8 +102,6 @@ class FileGenerator { std::vector<std::unique_ptr<MessageGenerator>> message_generators_; std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_; - const Options options_; - void PrintFileRuntimePreamble( io::Printer* printer, const std::vector<std::string>& headers_to_import) const; diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_generator.cc b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_generator.cc index 190e0fe0..bbe9b91b 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_generator.cc +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_generator.cc @@ -94,7 +94,8 @@ bool ObjectiveCGenerator::GenerateAll( // // e.g. protoc ... --objc_opt=expected_prefixes=file.txt,generate_for_named_framework=MyFramework - Options generation_options; + Options validation_options; + FileGenerator::GenerationOptions generation_options; std::vector<std::pair<std::string, std::string> > options; ParseGeneratorParameter(parameter, &options); @@ -110,17 +111,20 @@ bool ObjectiveCGenerator::GenerateAll( // - Comments start with "#". // - A comment can go on a line after a expected package/prefix pair. // (i.e. - "package=prefix # comment") + // - For files that do NOT have a proto package (not recommended), an + // entry can be made as "no_package:PATH=prefix", where PATH is the + // path for the .proto file. // // There is no validation that the prefixes are good prefixes, it is // assumed that they are when you create the file. - generation_options.expected_prefixes_path = options[i].second; + validation_options.expected_prefixes_path = options[i].second; } else if (options[i].first == "expected_prefixes_suppressions") { // A semicolon delimited string that lists the paths of .proto files to // exclude from the package prefix validations (expected_prefixes_path). // This is provided as an "out", to skip some files being checked. for (StringPiece split_piece : Split( options[i].second, ";", true)) { - generation_options.expected_prefixes_suppressions.push_back( + validation_options.expected_prefixes_suppressions.push_back( std::string(split_piece)); } } else if (options[i].first == "prefixes_must_be_registered") { @@ -132,7 +136,7 @@ bool ObjectiveCGenerator::GenerateAll( // tried to use a prefix that isn't registered. // Default is "no". if (!StringToBool(options[i].second, - &generation_options.prefixes_must_be_registered)) { + &validation_options.prefixes_must_be_registered)) { *error = "error: Unknown value for prefixes_must_be_registered: " + options[i].second; return false; } @@ -144,7 +148,7 @@ bool ObjectiveCGenerator::GenerateAll( // raised if a files doesn't have one. // Default is "no". if (!StringToBool(options[i].second, - &generation_options.require_prefixes)) { + &validation_options.require_prefixes)) { *error = "error: Unknown value for require_prefixes: " + options[i].second; return false; } @@ -185,8 +189,22 @@ bool ObjectiveCGenerator::GenerateAll( // generated files. When integrating ObjC protos into a build system, // this can be used to avoid having to add the runtime directory to the // header search path since the generate #import will be more complete. - generation_options.runtime_import_prefix = - StripSuffixString(options[i].second, "/"); + generation_options.runtime_import_prefix = StripSuffixString(options[i].second, "/"); + } else if (options[i].first == "package_to_prefix_mappings_path") { + // Path to use for when loading the objc class prefix mappings to use. + // The `objc_class_prefix` file option is always honored first if one is present. + // This option also has precedent over the use_package_as_prefix option. + // + // The format of the file is: + // - An entry is a line of "package=prefix". + // - Comments start with "#". + // - A comment can go on a line after a expected package/prefix pair. + // (i.e. - "package=prefix # comment") + // - For files that do NOT have a proto package (not recommended), an + // entry can be made as "no_package:PATH=prefix", where PATH is the + // path for the .proto file. + // + SetPackageToPrefixMappingsPath(options[i].second); } else if (options[i].first == "use_package_as_prefix") { // Controls how the symbols should be prefixed to avoid symbols // collisions. The objc_class_prefix file option is always honored, this @@ -212,6 +230,12 @@ bool ObjectiveCGenerator::GenerateAll( // - A comment can go on a line after a expected package/prefix pair. // (i.e. - "some.proto.package # comment") SetProtoPackagePrefixExceptionList(options[i].second); + } else if (options[i].first == "headers_use_forward_declarations") { + if (!StringToBool(options[i].second, + &generation_options.headers_use_forward_declarations)) { + *error = "error: Unknown value for headers_use_forward_declarations: " + options[i].second; + return false; + } } else { *error = "error: Unknown generator option: " + options[i].first; return false; @@ -240,14 +264,15 @@ bool ObjectiveCGenerator::GenerateAll( // ----------------------------------------------------------------- // Validate the objc prefix/package pairings. - if (!ValidateObjCClassPrefixes(files, generation_options, error)) { + if (!ValidateObjCClassPrefixes(files, validation_options, error)) { // *error will have been filled in. return false; } + FileGenerator::CommonState state; for (int i = 0; i < files.size(); i++) { const FileDescriptor* file = files[i]; - FileGenerator file_generator(file, generation_options); + FileGenerator file_generator(file, generation_options, state); std::string filepath = FilePath(file); // Generate header. diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_helpers.cc b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_helpers.cc index 8b61e9ea..6657a322 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_helpers.cc @@ -73,6 +73,14 @@ using ::open; namespace { +bool BoolFromEnvVar(const char* env_var, bool default_value) { + const char* value = getenv(env_var); + if (value) { + return std::string("YES") == ToUpper(value); + } + return default_value; +} + class SimpleLineCollector : public LineConsumer { public: SimpleLineCollector(std::unordered_set<std::string>* inout_set) @@ -87,10 +95,31 @@ class SimpleLineCollector : public LineConsumer { std::unordered_set<std::string>* set_; }; +class PackageToPrefixesCollector : public LineConsumer { + public: + PackageToPrefixesCollector(const std::string &usage, + std::map<std::string, std::string>* inout_package_to_prefix_map) + : usage_(usage), prefix_map_(inout_package_to_prefix_map) {} + + virtual bool ConsumeLine(const StringPiece& line, std::string* out_error) override; + + private: + const std::string usage_; + std::map<std::string, std::string>* prefix_map_; +}; + class PrefixModeStorage { public: PrefixModeStorage(); + const std::string package_to_prefix_mappings_path() const { return package_to_prefix_mappings_path_; } + void set_package_to_prefix_mappings_path(const std::string& path) { + package_to_prefix_mappings_path_ = path; + package_to_prefix_map_.clear(); + } + + std::string prefix_from_proto_package_mappings(const FileDescriptor* file); + bool use_package_name() const { return use_package_name_; } void set_use_package_name(bool on_or_off) { use_package_name_ = on_or_off; } @@ -102,9 +131,16 @@ class PrefixModeStorage { bool is_package_exempted(const std::string& package); + // When using a proto package as the prefix, this should be added as the + // prefix in front of it. + const std::string& forced_package_prefix() const { return forced_prefix_; } + private: bool use_package_name_; + std::map<std::string, std::string> package_to_prefix_map_; + std::string package_to_prefix_mappings_path_; std::string exception_path_; + std::string forced_prefix_; std::unordered_set<std::string> exceptions_; }; @@ -112,14 +148,57 @@ PrefixModeStorage::PrefixModeStorage() { // Even thought there are generation options, have an env back door since some // of these helpers could be used in other plugins. - const char* use_package_cstr = getenv("GPB_OBJC_USE_PACKAGE_AS_PREFIX"); - use_package_name_ = - (use_package_cstr && (std::string("YES") == ToUpper(use_package_cstr))); + use_package_name_ = BoolFromEnvVar("GPB_OBJC_USE_PACKAGE_AS_PREFIX", false); const char* exception_path = getenv("GPB_OBJC_PACKAGE_PREFIX_EXCEPTIONS_PATH"); if (exception_path) { exception_path_ = exception_path; } + + // This one is a not expected to be common, so it doesn't get a generation + // option, just the env var. + const char* prefix = getenv("GPB_OBJC_USE_PACKAGE_AS_PREFIX_PREFIX"); + if (prefix) { + forced_prefix_ = prefix; + } +} + +std::string PrefixModeStorage::prefix_from_proto_package_mappings(const FileDescriptor* file) { + if (!file) { + return ""; + } + + if (package_to_prefix_map_.empty() && !package_to_prefix_mappings_path_.empty()) { + std::string error_str; + // Re use the same collector as we use for expected_prefixes_path since the file + // format is the same. + PackageToPrefixesCollector collector("Package to prefixes", &package_to_prefix_map_); + if (!ParseSimpleFile(package_to_prefix_mappings_path_, &collector, &error_str)) { + if (error_str.empty()) { + error_str = std::string("protoc:0: warning: Failed to parse") + + std::string(" prefix to proto package mappings file: ") + + package_to_prefix_mappings_path_; + } + std::cerr << error_str << std::endl; + std::cerr.flush(); + package_to_prefix_map_.clear(); + } + } + + const std::string package = file->package(); + // For files without packages, the can be registered as "no_package:PATH", + // allowing the expected prefixes file. + static const std::string no_package_prefix("no_package:"); + const std::string lookup_key = package.empty() ? no_package_prefix + file->name() : package; + + std::map<std::string, std::string>::const_iterator prefix_lookup = + package_to_prefix_map_.find(lookup_key); + + if (prefix_lookup != package_to_prefix_map_.end()) { + return prefix_lookup->second; + } + + return ""; } bool PrefixModeStorage::is_package_exempted(const std::string& package) { @@ -151,6 +230,14 @@ PrefixModeStorage g_prefix_mode; } // namespace +std::string GetPackageToPrefixMappingsPath() { + return g_prefix_mode.package_to_prefix_mappings_path(); +} + +void SetPackageToPrefixMappingsPath(const std::string& file_path) { + g_prefix_mode.set_package_to_prefix_mappings_path(file_path); +} + bool UseProtoPackageAsDefaultPrefix() { return g_prefix_mode.use_package_name(); } @@ -168,7 +255,9 @@ void SetProtoPackagePrefixExceptionList(const std::string& file_path) { } Options::Options() { - // Default is the value of the env for the package prefixes. + // While there are generator options, also support env variables to help with + // build systems where it isn't as easy to hook in for add the generation + // options when invoking protoc. const char* file_path = getenv("GPB_OBJC_EXPECTED_PACKAGE_PREFIXES"); if (file_path) { expected_prefixes_path = file_path; @@ -178,8 +267,9 @@ Options::Options() { expected_prefixes_suppressions = Split(suppressions, ";", true); } - prefixes_must_be_registered = false; - require_prefixes = false; + prefixes_must_be_registered = + BoolFromEnvVar("GPB_OBJC_PREFIXES_MUST_BE_REGISTERED", false); + require_prefixes = BoolFromEnvVar("GPB_OBJC_REQUIRE_PREFIXES", false); } namespace { @@ -352,9 +442,9 @@ bool IsReservedCIdentifier(const std::string& input) { } std::string SanitizeNameForObjC(const std::string& prefix, - const std::string& input, - const std::string& extension, - std::string* out_suffix_added) { + const std::string& input, + const std::string& extension, + std::string* out_suffix_added) { static const std::unordered_set<std::string> kReservedWords = MakeWordsMap(kReservedWordList, GOOGLE_ARRAYSIZE(kReservedWordList)); static const std::unordered_set<std::string> kNSObjectMethods = @@ -510,8 +600,14 @@ std::string FileClassPrefix(const FileDescriptor* file) { return file->options().objc_class_prefix(); } - // If package prefix isn't enabled or no package, done. - if (!g_prefix_mode.use_package_name() || file->package().empty()) { + // If package prefix is specified in an prefix to proto mappings file then use that. + std::string objc_class_prefix = g_prefix_mode.prefix_from_proto_package_mappings(file); + if (!objc_class_prefix.empty()) { + return objc_class_prefix; + } + + // If package prefix isn't enabled, done. + if (!g_prefix_mode.use_package_name()) { return ""; } @@ -538,7 +634,7 @@ std::string FileClassPrefix(const FileDescriptor* file) { if (!result.empty()) { result.append("_"); } - return result; + return g_prefix_mode.forced_package_prefix() + result; } std::string FilePath(const FileDescriptor* file) { @@ -1184,23 +1280,11 @@ void RemoveComment(StringPiece* input) { namespace { -class ExpectedPrefixesCollector : public LineConsumer { - public: - ExpectedPrefixesCollector(std::map<std::string, std::string>* inout_package_to_prefix_map) - : prefix_map_(inout_package_to_prefix_map) {} - - virtual bool ConsumeLine(const StringPiece& line, std::string* out_error) override; - - private: - std::map<std::string, std::string>* prefix_map_; -}; - -bool ExpectedPrefixesCollector::ConsumeLine( +bool PackageToPrefixesCollector::ConsumeLine( const StringPiece& line, std::string* out_error) { int offset = line.find('='); if (offset == StringPiece::npos) { - *out_error = std::string("Expected prefixes file line without equal sign: '") + - std::string(line) + "'."; + *out_error = usage_ + " file line without equal sign: '" + StrCat(line) + "'."; return false; } StringPiece package = line.substr(0, offset); @@ -1214,16 +1298,16 @@ bool ExpectedPrefixesCollector::ConsumeLine( return true; } -bool LoadExpectedPackagePrefixes(const Options& generation_options, +bool LoadExpectedPackagePrefixes(const std::string& expected_prefixes_path, std::map<std::string, std::string>* prefix_map, std::string* out_error) { - if (generation_options.expected_prefixes_path.empty()) { + if (expected_prefixes_path.empty()) { return true; } - ExpectedPrefixesCollector collector(prefix_map); + PackageToPrefixesCollector collector("Expected prefixes", prefix_map); return ParseSimpleFile( - generation_options.expected_prefixes_path, &collector, out_error); + expected_prefixes_path, &collector, out_error); } bool ValidateObjCClassPrefix( @@ -1240,6 +1324,11 @@ bool ValidateObjCClassPrefix( const std::string prefix = file->options().objc_class_prefix(); const std::string package = file->package(); + // For files without packages, the can be registered as "no_package:PATH", + // allowing the expected prefixes file. + static const std::string no_package_prefix("no_package:"); + const std::string lookup_key = + package.empty() ? no_package_prefix + file->name() : package; // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some // error cases, so it seems to be ok to use as a back door for warnings. @@ -1247,7 +1336,7 @@ bool ValidateObjCClassPrefix( // Check: Error - See if there was an expected prefix for the package and // report if it doesn't match (wrong or missing). std::map<std::string, std::string>::const_iterator package_match = - expected_package_prefixes.find(package); + expected_package_prefixes.find(lookup_key); if (package_match != expected_package_prefixes.end()) { // There was an entry, and... if (has_prefix && package_match->second == prefix) { @@ -1256,8 +1345,11 @@ bool ValidateObjCClassPrefix( } else { // ...it didn't match! *out_error = "error: Expected 'option objc_class_prefix = \"" + - package_match->second + "\";' for package '" + package + - "' in '" + file->name() + "'"; + package_match->second + "\";'"; + if (!package.empty()) { + *out_error += " for package '" + package + "'"; + } + *out_error += " in '" + file->name() + "'"; if (has_prefix) { *out_error += "; but found '" + prefix + "' instead"; } @@ -1286,51 +1378,34 @@ bool ValidateObjCClassPrefix( i != expected_package_prefixes.end(); ++i) { if (i->second == prefix) { other_package_for_prefix = i->first; - break; + // Stop on the first real package listing, if it was a no_package file + // specific entry, keep looking to try and find a package one. + if (!HasPrefixString(other_package_for_prefix, no_package_prefix)) { + break; + } } } - // Check: Warning - If the file does not have a package, check whether the - // prefix was declared is being used by another package or not. This is - // a special case for empty packages. - if (package.empty()) { - // The file does not have a package and ... - if (other_package_for_prefix.empty()) { - // ... no other package has declared that prefix. - std::cerr - << "protoc:0: warning: File '" << file->name() << "' has no " - << "package. Consider adding a new package to the proto and adding '" - << "new.package = " << prefix << "' to the expected prefixes file (" - << expected_prefixes_path << ")." << std::endl; - std::cerr.flush(); - } else { - // ... another package has declared the same prefix. - std::cerr - << "protoc:0: warning: File '" << file->name() << "' has no package " - << "and package '" << other_package_for_prefix << "' already uses '" - << prefix << "' as its prefix. Consider either adding a new package " - << "to the proto, or reusing one of the packages already using this " - << "prefix in the expected prefixes file (" - << expected_prefixes_path << ")." << std::endl; - std::cerr.flush(); - } - return true; - } - // Check: Error - Make sure the prefix wasn't expected for a different // package (overlap is allowed, but it has to be listed as an expected // overlap). if (!other_package_for_prefix.empty()) { *out_error = "error: Found 'option objc_class_prefix = \"" + prefix + - "\";' in '" + file->name() + - "'; that prefix is already used for 'package " + - other_package_for_prefix + ";'. It can only be reused by listing " + - "it in the expected file (" + - expected_prefixes_path + ")."; + "\";' in '" + file->name() + "'; that prefix is already used for "; + if (HasPrefixString(other_package_for_prefix, no_package_prefix)) { + *out_error += "file '" + + StripPrefixString(other_package_for_prefix, no_package_prefix) + + "'."; + } else { + *out_error += "'package " + other_package_for_prefix + ";'."; + } + *out_error += + " It can only be reused by adding '" + lookup_key + " = " + prefix + + "' to the expected prefixes file (" + expected_prefixes_path + ")."; return false; // Only report first usage of the prefix. } - } // !prefix.empty() + } // !prefix.empty() && have_expected_prefix_file // Check: Warning - Make sure the prefix is is a reasonable value according // to Apple's rules (the checks above implicitly whitelist anything that @@ -1359,17 +1434,18 @@ bool ValidateObjCClassPrefix( if (prefixes_must_be_registered) { *out_error = "error: '" + file->name() + "' has 'option objc_class_prefix = \"" + - prefix + "\";', but it is not registered; add it to the expected " + - "prefixes file (" + expected_prefixes_path + ") for the package '" + - package + "'."; + prefix + "\";', but it is not registered. Add '" + lookup_key + " = " + + (prefix.empty() ? "\"\"" : prefix) + + "' to the expected prefixes file (" + expected_prefixes_path + ")."; return false; } std::cerr << "protoc:0: warning: Found unexpected 'option objc_class_prefix = \"" - << prefix << "\";' in '" << file->name() << "';" - << " consider adding it to the expected prefixes file (" - << expected_prefixes_path << ")." << std::endl; + << prefix << "\";' in '" << file->name() << "'; consider adding '" + << lookup_key << " = " << (prefix.empty() ? "\"\"" : prefix) + << "' to the expected prefixes file (" << expected_prefixes_path + << ")." << std::endl; std::cerr.flush(); } @@ -1378,6 +1454,13 @@ bool ValidateObjCClassPrefix( } // namespace +bool ValidateObjCClassPrefixes(const std::vector<const FileDescriptor*>& files, + std::string* out_error) { + // Options's ctor load from the environment. + Options options; + return ValidateObjCClassPrefixes(files, options, out_error); +} + bool ValidateObjCClassPrefixes(const std::vector<const FileDescriptor*>& files, const Options& generation_options, std::string* out_error) { @@ -1389,7 +1472,7 @@ bool ValidateObjCClassPrefixes(const std::vector<const FileDescriptor*>& files, // Load the expected package prefixes, if available, to validate against. std::map<std::string, std::string> expected_package_prefixes; - if (!LoadExpectedPackagePrefixes(generation_options, + if (!LoadExpectedPackagePrefixes(generation_options.expected_prefixes_path, &expected_package_prefixes, out_error)) { return false; diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_helpers.h b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_helpers.h index afe93869..f1e56b8c 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_helpers.h +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_helpers.h @@ -47,6 +47,10 @@ namespace protobuf { namespace compiler { namespace objectivec { +// Get/Set the path to a file to load for objc class prefix lookups. +std::string PROTOC_EXPORT GetPackageToPrefixMappingsPath(); +void PROTOC_EXPORT SetPackageToPrefixMappingsPath( + const std::string& file_path); // Get/Set if the proto package should be used to make the default prefix for // symbols. This will then impact most of the type naming apis below. It is done // as a global to not break any other generator reusing the methods since they @@ -54,20 +58,18 @@ namespace objectivec { bool PROTOC_EXPORT UseProtoPackageAsDefaultPrefix(); void PROTOC_EXPORT SetUseProtoPackageAsDefaultPrefix(bool on_or_off); // Get/Set the path to a file to load as exceptions when -// `UseProtoPackageAsDefaultPrefixUseProtoPackageAsDefaultPrefix()` is `true`. -// And empty string means there should be no exceptions loaded. +// `UseProtoPackageAsDefaultPrefix()` is `true`. An empty string means there +// should be no exceptions. std::string PROTOC_EXPORT GetProtoPackagePrefixExceptionList(); void PROTOC_EXPORT SetProtoPackagePrefixExceptionList( const std::string& file_path); -// Generator options (see objectivec_generator.cc for a description of each): +// Generator Prefix Validation Options (see objectivec_generator.cc for a +// description of each): struct Options { Options(); std::string expected_prefixes_path; std::vector<std::string> expected_prefixes_suppressions; - std::string generate_for_named_framework; - std::string named_framework_to_proto_path_mappings_path; - std::string runtime_import_prefix; bool prefixes_must_be_registered; bool require_prefixes; }; @@ -251,7 +253,11 @@ IsProtobufLibraryBundledProtoFile(const FileDescriptor* file); // and the result is false. bool PROTOC_EXPORT ValidateObjCClassPrefixes( const std::vector<const FileDescriptor*>& files, - const Options& generation_options, std::string* out_error); + const Options& validation_options, std::string* out_error); +// Same was the other ValidateObjCClassPrefixes() calls, but the options all +// come from the environment variables. +bool PROTOC_EXPORT ValidateObjCClassPrefixes( + const std::vector<const FileDescriptor*>& files, std::string* out_error); // Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform // the input into the expected output. diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc index f2aa776f..8e3bb515 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc @@ -30,7 +30,6 @@ #include <thirdparty/protobuf/compiler/objectivec/objectivec_helpers.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> -#include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> namespace google { @@ -154,7 +153,7 @@ TEST(ObjCHelper, TextFormatDecodeData_RawStrings) { EXPECT_EQ(4, decode_data.num_entries()); - uint8 expected_data[] = { + uint8_t expected_data[] = { 0x4, 0x1, 0x0, 'z', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'I', 'J', 0x0, 0x3, 0x0, 'a', 'b', 'c', 'd', 'e', 'z', 'g', 'h', 'I', 'J', 0x0, @@ -179,7 +178,7 @@ TEST(ObjCHelper, TextFormatDecodeData_ByteCodes) { EXPECT_EQ(5, decode_data.num_entries()); - uint8 expected_data[] = { + uint8_t expected_data[] = { 0x5, // All as is (00 op) 0x1, 0x0A, 0x0, diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_map_field.cc b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_map_field.cc index 2c246c24..9fd28755 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_map_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_map_field.cc @@ -81,14 +81,13 @@ const char* MapEntryTypeName(const FieldDescriptor* descriptor, bool isKey) { } // namespace -MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : RepeatedFieldGenerator(descriptor, options) { +MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor) + : RepeatedFieldGenerator(descriptor) { const FieldDescriptor* key_descriptor = descriptor->message_type()->map_key(); const FieldDescriptor* value_descriptor = descriptor->message_type()->map_value(); - value_field_generator_.reset(FieldGenerator::Make(value_descriptor, options)); + value_field_generator_.reset(FieldGenerator::Make(value_descriptor)); // Pull over some variables_ from the value. variables_["field_type"] = value_field_generator_->variable("field_type"); @@ -153,7 +152,7 @@ void MapFieldGenerator::FinishInitialization(void) { // Use the array_comment support in RepeatedFieldGenerator to output what the // values in the map are. const FieldDescriptor* value_descriptor = - descriptor_->message_type()->FindFieldByName("value"); + descriptor_->message_type()->map_value(); if (GetObjectiveCType(value_descriptor) == OBJECTIVECTYPE_ENUM) { variables_["array_comment"] = "// |" + variables_["name"] + "| values are |" + value_field_generator_->variable("storage_type") + "|\n"; @@ -161,11 +160,19 @@ void MapFieldGenerator::FinishInitialization(void) { } void MapFieldGenerator::DetermineForwardDeclarations( - std::set<std::string>* fwd_decls) const { - RepeatedFieldGenerator::DetermineForwardDeclarations(fwd_decls); + std::set<std::string>* fwd_decls, + bool include_external_types) const { + RepeatedFieldGenerator::DetermineForwardDeclarations( + fwd_decls, include_external_types); const FieldDescriptor* value_descriptor = - descriptor_->message_type()->FindFieldByName("value"); - if (GetObjectiveCType(value_descriptor) == OBJECTIVECTYPE_MESSAGE) { + descriptor_->message_type()->map_value(); + // Within a file there is no requirement on the order of the messages, so + // local references need a forward declaration. External files (not WKTs), + // need one when requested. + if (GetObjectiveCType(value_descriptor) == OBJECTIVECTYPE_MESSAGE && + ((include_external_types && + !IsProtobufLibraryBundledProtoFile(value_descriptor->file())) || + descriptor_->file() == value_descriptor->file())) { const std::string& value_storage_type = value_field_generator_->variable("storage_type"); fwd_decls->insert("@class " + value_storage_type); @@ -176,7 +183,7 @@ void MapFieldGenerator::DetermineObjectiveCClassDefinitions( std::set<std::string>* fwd_decls) const { // Class name is already in "storage_type". const FieldDescriptor* value_descriptor = - descriptor_->message_type()->FindFieldByName("value"); + descriptor_->message_type()->map_value(); if (GetObjectiveCType(value_descriptor) == OBJECTIVECTYPE_MESSAGE) { fwd_decls->insert(ObjCClassDeclaration( value_field_generator_->variable("storage_type"))); diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_map_field.h b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_map_field.h index 8aea14c0..73b6225a 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_map_field.h +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_map_field.h @@ -41,8 +41,7 @@ namespace compiler { namespace objectivec { class MapFieldGenerator : public RepeatedFieldGenerator { - friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field, - const Options& options); + friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); public: virtual void FinishInitialization(void) override; @@ -51,13 +50,14 @@ class MapFieldGenerator : public RepeatedFieldGenerator { MapFieldGenerator& operator=(const MapFieldGenerator&) = delete; protected: - MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options); + explicit MapFieldGenerator(const FieldDescriptor* descriptor); virtual ~MapFieldGenerator(); virtual void DetermineObjectiveCClassDefinitions( std::set<std::string>* fwd_decls) const override; virtual void DetermineForwardDeclarations( - std::set<std::string>* fwd_decls) const override; + std::set<std::string>* fwd_decls, + bool include_external_types) const override; private: std::unique_ptr<FieldGenerator> value_field_generator_; diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message.cc b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message.cc index e69700e8..ee4134e6 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message.cc +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message.cc @@ -41,8 +41,6 @@ #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> -#include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/wire_format_lite.h> #include <thirdparty/protobuf/descriptor.pb.h> namespace google { @@ -171,11 +169,10 @@ const FieldDescriptor** SortFieldsByStorageSize(const Descriptor* descriptor) { } // namespace MessageGenerator::MessageGenerator(const std::string& root_classname, - const Descriptor* descriptor, - const Options& options) + const Descriptor* descriptor) : root_classname_(root_classname), descriptor_(descriptor), - field_generators_(descriptor, options), + field_generators_(descriptor), class_name_(ClassName(descriptor_)), deprecated_attribute_(GetOptionalDeprecatedAttribute( descriptor, descriptor->file(), false, true)) { @@ -197,8 +194,7 @@ MessageGenerator::MessageGenerator(const std::string& root_classname, for (int i = 0; i < descriptor_->nested_type_count(); i++) { MessageGenerator* generator = new MessageGenerator(root_classname_, - descriptor_->nested_type(i), - options); + descriptor_->nested_type(i)); nested_message_generators_.emplace_back(generator); } } @@ -217,17 +213,18 @@ void MessageGenerator::GenerateStaticVariablesInitialization( } void MessageGenerator::DetermineForwardDeclarations( - std::set<std::string>* fwd_decls) { + std::set<std::string>* fwd_decls, + bool include_external_types) { if (!IsMapEntryMessage(descriptor_)) { for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* fieldDescriptor = descriptor_->field(i); field_generators_.get(fieldDescriptor) - .DetermineForwardDeclarations(fwd_decls); + .DetermineForwardDeclarations(fwd_decls, include_external_types); } } for (const auto& generator : nested_message_generators_) { - generator->DetermineForwardDeclarations(fwd_decls); + generator->DetermineForwardDeclarations(fwd_decls, include_external_types); } } diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message.h b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message.h index a53c0f61..61cd505b 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message.h +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message.h @@ -35,7 +35,6 @@ #include <set> #include <vector> #include <thirdparty/protobuf/compiler/objectivec/objectivec_field.h> -#include <thirdparty/protobuf/compiler/objectivec/objectivec_helpers.h> #include <thirdparty/protobuf/compiler/objectivec/objectivec_oneof.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/io/printer.h> @@ -51,7 +50,7 @@ class EnumGenerator; class MessageGenerator { public: MessageGenerator(const std::string& root_classname, - const Descriptor* descriptor, const Options& options); + const Descriptor* descriptor); ~MessageGenerator(); MessageGenerator(const MessageGenerator&) = delete; @@ -63,7 +62,8 @@ class MessageGenerator { void GenerateSource(io::Printer* printer); void GenerateExtensionRegistrationSource(io::Printer* printer); void DetermineObjectiveCClassDefinitions(std::set<std::string>* fwd_decls); - void DetermineForwardDeclarations(std::set<std::string>* fwd_decls); + void DetermineForwardDeclarations(std::set<std::string>* fwd_decls, + bool include_external_types); // Checks if the message or a nested message includes a oneof definition. bool IncludesOneOfDefinition() const; diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message_field.cc b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message_field.cc index ac9ac25c..a3b8ac4c 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message_field.cc @@ -34,7 +34,6 @@ #include <thirdparty/protobuf/compiler/objectivec/objectivec_message_field.h> #include <thirdparty/protobuf/compiler/objectivec/objectivec_helpers.h> #include <thirdparty/protobuf/io/printer.h> -#include <thirdparty/protobuf/wire_format.h> namespace google { namespace protobuf { @@ -58,19 +57,27 @@ void SetMessageVariables(const FieldDescriptor* descriptor, } // namespace -MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : ObjCObjFieldGenerator(descriptor, options) { +MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor) + : ObjCObjFieldGenerator(descriptor) { SetMessageVariables(descriptor, &variables_); } MessageFieldGenerator::~MessageFieldGenerator() {} void MessageFieldGenerator::DetermineForwardDeclarations( - std::set<std::string>* fwd_decls) const { - ObjCObjFieldGenerator::DetermineForwardDeclarations(fwd_decls); - // Class name is already in "storage_type". - fwd_decls->insert("@class " + variable("storage_type")); + std::set<std::string>* fwd_decls, + bool include_external_types) const { + ObjCObjFieldGenerator::DetermineForwardDeclarations( + fwd_decls, include_external_types); + // Within a file there is no requirement on the order of the messages, so + // local references need a forward declaration. External files (not WKTs), + // need one when requested. + if ((include_external_types && + !IsProtobufLibraryBundledProtoFile(descriptor_->message_type()->file())) || + descriptor_->file() == descriptor_->message_type()->file()) { + // Class name is already in "storage_type". + fwd_decls->insert("@class " + variable("storage_type")); + } } void MessageFieldGenerator::DetermineObjectiveCClassDefinitions( @@ -79,8 +86,8 @@ void MessageFieldGenerator::DetermineObjectiveCClassDefinitions( } RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator( - const FieldDescriptor* descriptor, const Options& options) - : RepeatedFieldGenerator(descriptor, options) { + const FieldDescriptor* descriptor) + : RepeatedFieldGenerator(descriptor) { SetMessageVariables(descriptor, &variables_); variables_["array_storage_type"] = "NSMutableArray"; variables_["array_property_type"] = @@ -90,10 +97,19 @@ RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator( RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {} void RepeatedMessageFieldGenerator::DetermineForwardDeclarations( - std::set<std::string>* fwd_decls) const { - RepeatedFieldGenerator::DetermineForwardDeclarations(fwd_decls); - // Class name is already in "storage_type". - fwd_decls->insert("@class " + variable("storage_type")); + std::set<std::string>* fwd_decls, + bool include_external_types) const { + RepeatedFieldGenerator::DetermineForwardDeclarations( + fwd_decls, include_external_types); + // Within a file there is no requirement on the order of the messages, so + // local references need a forward declaration. External files (not WKTs), + // need one when requested. + if ((include_external_types && + !IsProtobufLibraryBundledProtoFile(descriptor_->message_type()->file())) || + descriptor_->file() == descriptor_->message_type()->file()) { + // Class name is already in "storage_type". + fwd_decls->insert("@class " + variable("storage_type")); + } } void RepeatedMessageFieldGenerator::DetermineObjectiveCClassDefinitions( diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message_field.h b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message_field.h index 8e848276..cc4868e5 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message_field.h +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_message_field.h @@ -41,12 +41,10 @@ namespace compiler { namespace objectivec { class MessageFieldGenerator : public ObjCObjFieldGenerator { - friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field, - const Options& options); + friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); protected: - MessageFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); + explicit MessageFieldGenerator(const FieldDescriptor* descriptor); MessageFieldGenerator(const MessageFieldGenerator&) = delete; MessageFieldGenerator& operator=(const MessageFieldGenerator&) = delete; @@ -55,18 +53,17 @@ class MessageFieldGenerator : public ObjCObjFieldGenerator { public: virtual void DetermineForwardDeclarations( - std::set<std::string>* fwd_decls) const override; + std::set<std::string>* fwd_decls, + bool include_external_types) const override; virtual void DetermineObjectiveCClassDefinitions( std::set<std::string>* fwd_decls) const override; }; class RepeatedMessageFieldGenerator : public RepeatedFieldGenerator { - friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field, - const Options& options); + friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); protected: - RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); + explicit RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor); virtual ~RepeatedMessageFieldGenerator(); RepeatedMessageFieldGenerator(const RepeatedMessageFieldGenerator&) = delete; @@ -74,7 +71,8 @@ class RepeatedMessageFieldGenerator : public RepeatedFieldGenerator { public: virtual void DetermineForwardDeclarations( - std::set<std::string>* fwd_decls) const override; + std::set<std::string>* fwd_decls, + bool include_external_types) const override; virtual void DetermineObjectiveCClassDefinitions( std::set<std::string>* fwd_decls) const override; }; diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_primitive_field.cc b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_primitive_field.cc index 35a6bde7..9d5b3abd 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_primitive_field.cc +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_primitive_field.cc @@ -35,8 +35,6 @@ #include <thirdparty/protobuf/compiler/objectivec/objectivec_primitive_field.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/stubs/strutil.h> -#include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/wire_format_lite.h> namespace google { namespace protobuf { @@ -125,8 +123,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, } // namespace PrimitiveFieldGenerator::PrimitiveFieldGenerator( - const FieldDescriptor* descriptor, const Options& options) - : SingleFieldGenerator(descriptor, options) { + const FieldDescriptor* descriptor) + : SingleFieldGenerator(descriptor) { SetPrimitiveVariables(descriptor, &variables_); } @@ -159,8 +157,8 @@ void PrimitiveFieldGenerator::SetExtraRuntimeHasBitsBase(int has_base) { } PrimitiveObjFieldGenerator::PrimitiveObjFieldGenerator( - const FieldDescriptor* descriptor, const Options& options) - : ObjCObjFieldGenerator(descriptor, options) { + const FieldDescriptor* descriptor) + : ObjCObjFieldGenerator(descriptor) { SetPrimitiveVariables(descriptor, &variables_); variables_["property_storage_attribute"] = "copy"; } @@ -168,8 +166,8 @@ PrimitiveObjFieldGenerator::PrimitiveObjFieldGenerator( PrimitiveObjFieldGenerator::~PrimitiveObjFieldGenerator() {} RepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator( - const FieldDescriptor* descriptor, const Options& options) - : RepeatedFieldGenerator(descriptor, options) { + const FieldDescriptor* descriptor) + : RepeatedFieldGenerator(descriptor) { SetPrimitiveVariables(descriptor, &variables_); std::string base_name = PrimitiveArrayTypeName(descriptor); diff --git a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_primitive_field.h b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_primitive_field.h index 54bb4317..621f433c 100644 --- a/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_primitive_field.h +++ b/r5dev/thirdparty/protobuf/compiler/objectivec/objectivec_primitive_field.h @@ -31,8 +31,6 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_PRIMITIVE_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_PRIMITIVE_FIELD_H__ -#include <map> -#include <string> #include <thirdparty/protobuf/compiler/objectivec/objectivec_field.h> namespace google { @@ -41,12 +39,10 @@ namespace compiler { namespace objectivec { class PrimitiveFieldGenerator : public SingleFieldGenerator { - friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field, - const Options& options); + friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); protected: - PrimitiveFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); + explicit PrimitiveFieldGenerator(const FieldDescriptor* descriptor); virtual ~PrimitiveFieldGenerator(); PrimitiveFieldGenerator(const PrimitiveFieldGenerator&) = delete; @@ -59,12 +55,10 @@ class PrimitiveFieldGenerator : public SingleFieldGenerator { }; class PrimitiveObjFieldGenerator : public ObjCObjFieldGenerator { - friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field, - const Options& options); + friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); protected: - PrimitiveObjFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); + explicit PrimitiveObjFieldGenerator(const FieldDescriptor* descriptor); virtual ~PrimitiveObjFieldGenerator(); PrimitiveObjFieldGenerator(const PrimitiveObjFieldGenerator&) = delete; @@ -73,12 +67,10 @@ class PrimitiveObjFieldGenerator : public ObjCObjFieldGenerator { }; class RepeatedPrimitiveFieldGenerator : public RepeatedFieldGenerator { - friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field, - const Options& options); + friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); protected: - RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); + explicit RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor); virtual ~RepeatedPrimitiveFieldGenerator(); RepeatedPrimitiveFieldGenerator(const RepeatedPrimitiveFieldGenerator&) = diff --git a/r5dev/thirdparty/protobuf/compiler/parser.cc b/r5dev/thirdparty/protobuf/compiler/parser.cc index b5b9cab3..bf5c5831 100644 --- a/r5dev/thirdparty/protobuf/compiler/parser.cc +++ b/r5dev/thirdparty/protobuf/compiler/parser.cc @@ -46,11 +46,11 @@ #include <thirdparty/protobuf/stubs/casts.h> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> +#include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/tokenizer.h> -#include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/map_util.h> #include <thirdparty/protobuf/stubs/hash.h> @@ -64,32 +64,33 @@ namespace { typedef std::unordered_map<std::string, FieldDescriptorProto::Type> TypeNameMap; -TypeNameMap MakeTypeNameTable() { - TypeNameMap result; +const TypeNameMap& GetTypeNameTable() { + static auto* table = new auto([]() { + TypeNameMap result; - result["double"] = FieldDescriptorProto::TYPE_DOUBLE; - result["float"] = FieldDescriptorProto::TYPE_FLOAT; - result["uint64"] = FieldDescriptorProto::TYPE_UINT64; - result["fixed64"] = FieldDescriptorProto::TYPE_FIXED64; - result["fixed32"] = FieldDescriptorProto::TYPE_FIXED32; - result["bool"] = FieldDescriptorProto::TYPE_BOOL; - result["string"] = FieldDescriptorProto::TYPE_STRING; - result["group"] = FieldDescriptorProto::TYPE_GROUP; + result["double"] = FieldDescriptorProto::TYPE_DOUBLE; + result["float"] = FieldDescriptorProto::TYPE_FLOAT; + result["uint64"] = FieldDescriptorProto::TYPE_UINT64; + result["fixed64"] = FieldDescriptorProto::TYPE_FIXED64; + result["fixed32"] = FieldDescriptorProto::TYPE_FIXED32; + result["bool"] = FieldDescriptorProto::TYPE_BOOL; + result["string"] = FieldDescriptorProto::TYPE_STRING; + result["group"] = FieldDescriptorProto::TYPE_GROUP; - result["bytes"] = FieldDescriptorProto::TYPE_BYTES; - result["uint32"] = FieldDescriptorProto::TYPE_UINT32; - result["sfixed32"] = FieldDescriptorProto::TYPE_SFIXED32; - result["sfixed64"] = FieldDescriptorProto::TYPE_SFIXED64; - result["int32"] = FieldDescriptorProto::TYPE_INT32; - result["int64"] = FieldDescriptorProto::TYPE_INT64; - result["sint32"] = FieldDescriptorProto::TYPE_SINT32; - result["sint64"] = FieldDescriptorProto::TYPE_SINT64; + result["bytes"] = FieldDescriptorProto::TYPE_BYTES; + result["uint32"] = FieldDescriptorProto::TYPE_UINT32; + result["sfixed32"] = FieldDescriptorProto::TYPE_SFIXED32; + result["sfixed64"] = FieldDescriptorProto::TYPE_SFIXED64; + result["int32"] = FieldDescriptorProto::TYPE_INT32; + result["int64"] = FieldDescriptorProto::TYPE_INT64; + result["sint32"] = FieldDescriptorProto::TYPE_SINT32; + result["sint64"] = FieldDescriptorProto::TYPE_SINT64; - return result; + return result; + }()); + return *table; } -const TypeNameMap kTypeNames = MakeTypeNameTable(); - // Camel-case the field name and append "Entry" for generated map entry name. // e.g. map<KeyType, ValueType> foo_map => FooMapEntry std::string MapEntryName(const std::string& field_name) { @@ -180,9 +181,9 @@ bool IsNumberFollowUnderscore(const std::string& name) { // =================================================================== Parser::Parser() - : input_(NULL), - error_collector_(NULL), - source_location_table_(NULL), + : input_(nullptr), + error_collector_(nullptr), + source_location_table_(nullptr), had_errors_(false), require_syntax_identifier_(false), stop_after_syntax_identifier_(false) { @@ -221,12 +222,8 @@ bool Parser::Consume(const char* text, const char* error) { } bool Parser::Consume(const char* text) { - if (TryConsume(text)) { - return true; - } else { - AddError("Expected \"" + std::string(text) + "\"."); - return false; - } + std::string error = "Expected \"" + std::string(text) + "\"."; + return Consume(text, error.c_str()); } bool Parser::ConsumeIdentifier(std::string* output, const char* error) { @@ -347,7 +344,7 @@ bool Parser::TryConsumeEndOfDeclaration(const char* text, // from last time. leading.swap(upcoming_doc_comments_); - if (location != NULL) { + if (location != nullptr) { upcoming_detached_comments_.swap(detached); location->AttachComments(&leading, &trailing, &detached); } else if (strcmp(text, "}") == 0) { @@ -380,7 +377,7 @@ bool Parser::ConsumeEndOfDeclaration(const char* text, // ------------------------------------------------------------------- void Parser::AddError(int line, int column, const std::string& error) { - if (error_collector_ != NULL) { + if (error_collector_ != nullptr) { error_collector_->AddError(line, column, error); } had_errors_ = true; @@ -473,7 +470,7 @@ void Parser::LocationRecorder::EndAt(const io::Tokenizer::Token& token) { void Parser::LocationRecorder::RecordLegacyLocation( const Message* descriptor, DescriptorPool::ErrorCollector::ErrorLocation location) { - if (parser_->source_location_table_ != NULL) { + if (parser_->source_location_table_ != nullptr) { parser_->source_location_table_->Add( descriptor, location, location_->span(0), location_->span(1)); } @@ -516,7 +513,7 @@ void Parser::SkipStatement() { if (AtEnd()) { return; } else if (LookingAtType(io::Tokenizer::TYPE_SYMBOL)) { - if (TryConsumeEndOfDeclaration(";", NULL)) { + if (TryConsumeEndOfDeclaration(";", nullptr)) { return; } else if (TryConsume("{")) { SkipRestOfBlock(); @@ -534,7 +531,7 @@ void Parser::SkipRestOfBlock() { if (AtEnd()) { return; } else if (LookingAtType(io::Tokenizer::TYPE_SYMBOL)) { - if (TryConsumeEndOfDeclaration("}", NULL)) { + if (TryConsumeEndOfDeclaration("}", nullptr)) { return; } else if (TryConsume("{")) { SkipRestOfBlock(); @@ -628,7 +625,7 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) { if (LookingAtType(io::Tokenizer::TYPE_START)) { // Advance to first token. - input_->NextWithComments(NULL, &upcoming_detached_comments_, + input_->NextWithComments(nullptr, &upcoming_detached_comments_, &upcoming_doc_comments_); } @@ -644,7 +641,7 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) { return false; } // Store the syntax into the file. - if (file != NULL) file->set_syntax(syntax_identifier_); + if (file != nullptr) file->set_syntax(syntax_identifier_); } else if (!stop_after_syntax_identifier_) { GOOGLE_LOG(WARNING) << "No syntax specified for the proto file: " << file->name() << ". Please use 'syntax = \"proto2\";' " @@ -664,16 +661,16 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) { if (LookingAt("}")) { AddError("Unmatched \"}\"."); - input_->NextWithComments(NULL, &upcoming_detached_comments_, + input_->NextWithComments(nullptr, &upcoming_detached_comments_, &upcoming_doc_comments_); } } } } - input_ = NULL; - source_code_info_ = NULL; - assert(file != NULL); + input_ = nullptr; + source_code_info_ = nullptr; + assert(file != nullptr); source_code_info.Swap(file->mutable_source_code_info()); return !had_errors_; } @@ -706,7 +703,7 @@ bool Parser::ParseSyntaxIdentifier(const LocationRecorder& parent) { bool Parser::ParseTopLevelStatement(FileDescriptorProto* file, const LocationRecorder& root_location) { - if (TryConsumeEndOfDeclaration(";", NULL)) { + if (TryConsumeEndOfDeclaration(";", nullptr)) { // empty statement; ignore return true; } else if (LookingAt("message")) { @@ -862,7 +859,7 @@ bool Parser::ParseMessageBlock(DescriptorProto* message, const FileDescriptorProto* containing_file) { DO(ConsumeEndOfDeclaration("{", &message_location)); - while (!TryConsumeEndOfDeclaration("}", NULL)) { + while (!TryConsumeEndOfDeclaration("}", nullptr)) { if (AtEnd()) { AddError("Reached end of input in message definition (missing '}')."); return false; @@ -887,7 +884,7 @@ bool Parser::ParseMessageBlock(DescriptorProto* message, bool Parser::ParseMessageStatement(DescriptorProto* message, const LocationRecorder& message_location, const FileDescriptorProto* containing_file) { - if (TryConsumeEndOfDeclaration(";", NULL)) { + if (TryConsumeEndOfDeclaration(";", nullptr)) { // empty statement; ignore return true; } else if (LookingAt("message")) { @@ -945,7 +942,7 @@ bool Parser::ParseMessageField(FieldDescriptorProto* field, const FileDescriptorProto* containing_file) { { FieldDescriptorProto::Label label; - if (ParseLabel(&label, field_location, containing_file)) { + if (ParseLabel(&label, field_location)) { field->set_label(label); if (label == FieldDescriptorProto::LABEL_OPTIONAL && syntax_identifier_ == "proto3") { @@ -980,37 +977,14 @@ bool Parser::ParseMessageFieldNoLabel( if (TryConsume("map")) { if (LookingAt("<")) { map_field.is_map_field = true; + DO(ParseMapType(&map_field, field, location)); } else { // False positive type_parsed = true; type_name = "map"; } } - if (map_field.is_map_field) { - if (field->has_oneof_index()) { - AddError("Map fields are not allowed in oneofs."); - return false; - } - if (field->has_label()) { - AddError( - "Field labels (required/optional/repeated) are not allowed on " - "map fields."); - return false; - } - if (field->has_extendee()) { - AddError("Map fields are not allowed to be extensions."); - return false; - } - field->set_label(FieldDescriptorProto::LABEL_REPEATED); - DO(Consume("<")); - DO(ParseType(&map_field.key_type, &map_field.key_type_name)); - DO(Consume(",")); - DO(ParseType(&map_field.value_type, &map_field.value_type_name)); - DO(Consume(">")); - // Defer setting of the type name of the map field until the - // field name is parsed. Add the source location though. - location.AddPath(FieldDescriptorProto::kTypeNameFieldNumber); - } else { + if (!map_field.is_map_field) { // Handle the case where no explicit label is given for a non-map field. if (!field->has_label() && DefaultToOptionalFields()) { field->set_label(FieldDescriptorProto::LABEL_OPTIONAL); @@ -1022,8 +996,8 @@ bool Parser::ParseMessageFieldNoLabel( field->set_label(FieldDescriptorProto::LABEL_OPTIONAL); } - // Handle the case where the actual type is a message or enum named "map", - // which we already consumed in the code above. + // Handle the case where the actual type is a message or enum named + // "map", which we already consumed in the code above. if (!type_parsed) { DO(ParseType(&type, &type_name)); } @@ -1131,6 +1105,34 @@ bool Parser::ParseMessageFieldNoLabel( return true; } +bool Parser::ParseMapType(MapField* map_field, FieldDescriptorProto* field, + LocationRecorder& type_name_location) { + if (field->has_oneof_index()) { + AddError("Map fields are not allowed in oneofs."); + return false; + } + if (field->has_label()) { + AddError( + "Field labels (required/optional/repeated) are not allowed on " + "map fields."); + return false; + } + if (field->has_extendee()) { + AddError("Map fields are not allowed to be extensions."); + return false; + } + field->set_label(FieldDescriptorProto::LABEL_REPEATED); + DO(Consume("<")); + DO(ParseType(&map_field->key_type, &map_field->key_type_name)); + DO(Consume(",")); + DO(ParseType(&map_field->value_type, &map_field->value_type_name)); + DO(Consume(">")); + // Defer setting of the type name of the map field until the + // field name is parsed. Add the source location though. + type_name_location.AddPath(FieldDescriptorProto::kTypeNameFieldNumber); + return true; +} + void Parser::GenerateMapEntry(const MapField& map_field, FieldDescriptorProto* field, RepeatedPtrField<DescriptorProto>* messages) { @@ -1458,7 +1460,7 @@ bool Parser::ParseOption(Message* options, // Create an entry in the uninterpreted_option field. const FieldDescriptor* uninterpreted_option_field = options->GetDescriptor()->FindFieldByName("uninterpreted_option"); - GOOGLE_CHECK(uninterpreted_option_field != NULL) + GOOGLE_CHECK(uninterpreted_option_field != nullptr) << "No field named \"uninterpreted_option\" in the Options proto."; const Reflection* reflection = options->GetReflection(); @@ -1906,7 +1908,7 @@ bool Parser::ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions, // other statements. SkipStatement(); } - } while (!TryConsumeEndOfDeclaration("}", NULL)); + } while (!TryConsumeEndOfDeclaration("}", nullptr)); return true; } @@ -1970,7 +1972,7 @@ bool Parser::ParseOneof(OneofDescriptorProto* oneof_decl, // other statements. SkipStatement(); } - } while (!TryConsumeEndOfDeclaration("}", NULL)); + } while (!TryConsumeEndOfDeclaration("}", nullptr)); return true; } @@ -2003,7 +2005,7 @@ bool Parser::ParseEnumBlock(EnumDescriptorProto* enum_type, const FileDescriptorProto* containing_file) { DO(ConsumeEndOfDeclaration("{", &enum_location)); - while (!TryConsumeEndOfDeclaration("}", NULL)) { + while (!TryConsumeEndOfDeclaration("}", nullptr)) { if (AtEnd()) { AddError("Reached end of input in enum definition (missing '}')."); return false; @@ -2022,7 +2024,7 @@ bool Parser::ParseEnumBlock(EnumDescriptorProto* enum_type, bool Parser::ParseEnumStatement(EnumDescriptorProto* enum_type, const LocationRecorder& enum_location, const FileDescriptorProto* containing_file) { - if (TryConsumeEndOfDeclaration(";", NULL)) { + if (TryConsumeEndOfDeclaration(";", nullptr)) { // empty statement; ignore return true; } else if (LookingAt("option")) { @@ -2120,7 +2122,7 @@ bool Parser::ParseServiceBlock(ServiceDescriptorProto* service, const FileDescriptorProto* containing_file) { DO(ConsumeEndOfDeclaration("{", &service_location)); - while (!TryConsumeEndOfDeclaration("}", NULL)) { + while (!TryConsumeEndOfDeclaration("}", nullptr)) { if (AtEnd()) { AddError("Reached end of input in service definition (missing '}')."); return false; @@ -2139,7 +2141,7 @@ bool Parser::ParseServiceBlock(ServiceDescriptorProto* service, bool Parser::ParseServiceStatement(ServiceDescriptorProto* service, const LocationRecorder& service_location, const FileDescriptorProto* containing_file) { - if (TryConsumeEndOfDeclaration(";", NULL)) { + if (TryConsumeEndOfDeclaration(";", nullptr)) { // empty statement; ignore return true; } else if (LookingAt("option")) { @@ -2177,7 +2179,6 @@ bool Parser::ParseServiceMethod(MethodDescriptorProto* method, DescriptorPool::ErrorCollector::OTHER); method->set_client_streaming(true); DO(Consume("stream")); - } LocationRecorder location(method_location, MethodDescriptorProto::kInputTypeFieldNumber); @@ -2198,7 +2199,6 @@ bool Parser::ParseServiceMethod(MethodDescriptorProto* method, DescriptorPool::ErrorCollector::OTHER); DO(Consume("stream")); method->set_server_streaming(true); - } LocationRecorder location(method_location, MethodDescriptorProto::kOutputTypeFieldNumber); @@ -2226,13 +2226,13 @@ bool Parser::ParseMethodOptions(const LocationRecorder& parent_location, Message* mutable_options) { // Options! ConsumeEndOfDeclaration("{", &parent_location); - while (!TryConsumeEndOfDeclaration("}", NULL)) { + while (!TryConsumeEndOfDeclaration("}", nullptr)) { if (AtEnd()) { AddError("Reached end of input in method options (missing '}')."); return false; } - if (TryConsumeEndOfDeclaration(";", NULL)) { + if (TryConsumeEndOfDeclaration(";", nullptr)) { // empty statement; ignore } else { LocationRecorder location(parent_location, optionsFieldNumber); @@ -2251,8 +2251,7 @@ bool Parser::ParseMethodOptions(const LocationRecorder& parent_location, // ------------------------------------------------------------------- bool Parser::ParseLabel(FieldDescriptorProto::Label* label, - const LocationRecorder& field_location, - const FileDescriptorProto* containing_file) { + const LocationRecorder& field_location) { if (!LookingAt("optional") && !LookingAt("repeated") && !LookingAt("required")) { return false; @@ -2272,8 +2271,9 @@ bool Parser::ParseLabel(FieldDescriptorProto::Label* label, bool Parser::ParseType(FieldDescriptorProto::Type* type, std::string* type_name) { - TypeNameMap::const_iterator iter = kTypeNames.find(input_->current().text); - if (iter != kTypeNames.end()) { + const auto& type_names_table = GetTypeNameTable(); + auto iter = type_names_table.find(input_->current().text); + if (iter != type_names_table.end()) { *type = iter->second; input_->Next(); } else { @@ -2285,8 +2285,9 @@ bool Parser::ParseType(FieldDescriptorProto::Type* type, bool Parser::ParseUserDefinedType(std::string* type_name) { type_name->clear(); - TypeNameMap::const_iterator iter = kTypeNames.find(input_->current().text); - if (iter != kTypeNames.end()) { + const auto& type_names_table = GetTypeNameTable(); + auto iter = type_names_table.find(input_->current().text); + if (iter != type_names_table.end()) { // Note: The only place enum types are allowed is for field types, but // if we are parsing a field type then we would not get here because // primitives are allowed there as well. So this error message doesn't @@ -2396,7 +2397,7 @@ bool SourceLocationTable::Find( int* column) const { const std::pair<int, int>* result = FindOrNull(location_map_, std::make_pair(descriptor, location)); - if (result == NULL) { + if (result == nullptr) { *line = -1; *column = 0; return false; diff --git a/r5dev/thirdparty/protobuf/compiler/parser.h b/r5dev/thirdparty/protobuf/compiler/parser.h index af1f507a..79c890a5 100644 --- a/r5dev/thirdparty/protobuf/compiler/parser.h +++ b/r5dev/thirdparty/protobuf/compiler/parser.h @@ -42,9 +42,9 @@ #include <string> #include <utility> +#include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/tokenizer.h> -#include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/repeated_field.h> // Must be included last. @@ -122,6 +122,7 @@ class PROTOBUF_EXPORT Parser { private: class LocationRecorder; + struct MapField; // ================================================================= // Error recovery helpers @@ -281,9 +282,6 @@ class PROTOBUF_EXPORT Parser { std::vector<std::string>* detached_comments) const; private: - // Indexes of parent and current location in the parent - // SourceCodeInfo.location repeated field. For top-level elements, - // parent_index_ is -1. Parser* parser_; SourceCodeInfo* source_code_info_; SourceCodeInfo::Location* location_; @@ -381,6 +379,9 @@ class PROTOBUF_EXPORT Parser { const LocationRecorder& field_location, const FileDescriptorProto* containing_file); + bool ParseMapType(MapField* map_field, FieldDescriptorProto* field, + LocationRecorder& type_name_location); + // Parse an "extensions" declaration. bool ParseExtensions(DescriptorProto* message, const LocationRecorder& extensions_location, @@ -434,7 +435,6 @@ class PROTOBUF_EXPORT Parser { const LocationRecorder& method_location, const FileDescriptorProto* containing_file); - // Parse options of a single method or stream. bool ParseMethodOptions(const LocationRecorder& parent_location, const FileDescriptorProto* containing_file, @@ -444,8 +444,7 @@ class PROTOBUF_EXPORT Parser { // Parse "required", "optional", or "repeated" and fill in "label" // with the value. Returns true if such a label is consumed. bool ParseLabel(FieldDescriptorProto::Label* label, - const LocationRecorder& field_location, - const FileDescriptorProto* containing_file); + const LocationRecorder& field_location); // Parse a type name and fill in "type" (if it is a primitive) or // "type_name" (if it is not) with the type parsed. @@ -485,7 +484,7 @@ class PROTOBUF_EXPORT Parser { // Parses a single part of a multipart option name. A multipart name consists // of names separated by dots. Each name is either an identifier or a series // of identifiers separated by dots and enclosed in parentheses. E.g., - // "foo.(bar.baz).qux". + // "foo.(bar.baz).moo". bool ParseOptionNamePart(UninterpretedOption* uninterpreted_option, const LocationRecorder& part_location, const FileDescriptorProto* containing_file); diff --git a/r5dev/thirdparty/protobuf/compiler/parser_unittest.cc b/r5dev/thirdparty/protobuf/compiler/parser_unittest.cc index fadd6ee1..d1dd8ba0 100644 --- a/r5dev/thirdparty/protobuf/compiler/parser_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/parser_unittest.cc @@ -83,7 +83,7 @@ class MockValidationErrorCollector : public DescriptorPool::ErrorCollector { io::ErrorCollector* wrapped_collector) : source_locations_(source_locations), wrapped_collector_(wrapped_collector) {} - ~MockValidationErrorCollector() {} + ~MockValidationErrorCollector() override {} // implements ErrorCollector --------------------------------------- void AddError(const std::string& filename, const std::string& element_name, @@ -173,7 +173,7 @@ class ParserTest : public testing::Test { MockValidationErrorCollector validation_error_collector(source_locations, &error_collector_); EXPECT_TRUE(pool_.BuildFileCollectingErrors( - file, &validation_error_collector) == NULL); + file, &validation_error_collector) == nullptr); EXPECT_EQ(expected_errors, error_collector_.text_); } @@ -194,7 +194,7 @@ TEST_F(ParserTest, StopAfterSyntaxIdentifier) { "syntax = \"foobar\";\n" "this line will not be parsed\n"); parser_->SetStopAfterSyntaxIdentifier(true); - EXPECT_TRUE(parser_->Parse(input_.get(), NULL)); + EXPECT_TRUE(parser_->Parse(input_.get(), nullptr)); EXPECT_EQ("", error_collector_.text_); EXPECT_EQ("foobar", parser_->GetSyntaxIdentifier()); } @@ -204,7 +204,7 @@ TEST_F(ParserTest, StopAfterOmittedSyntaxIdentifier) { "// blah\n" "this line will not be parsed\n"); parser_->SetStopAfterSyntaxIdentifier(true); - EXPECT_TRUE(parser_->Parse(input_.get(), NULL)); + EXPECT_TRUE(parser_->Parse(input_.get(), nullptr)); EXPECT_EQ("", error_collector_.text_); EXPECT_EQ("", parser_->GetSyntaxIdentifier()); } @@ -214,7 +214,7 @@ TEST_F(ParserTest, StopAfterSyntaxIdentifierWithErrors) { "// blah\n" "syntax = error;\n"); parser_->SetStopAfterSyntaxIdentifier(true); - EXPECT_FALSE(parser_->Parse(input_.get(), NULL)); + EXPECT_FALSE(parser_->Parse(input_.get(), nullptr)); EXPECT_EQ("1:9: Expected syntax identifier.\n", error_collector_.text_); } @@ -1792,7 +1792,7 @@ TEST_F(ParserValidationErrorTest, PackageNameError) { FileDescriptorProto other_file; other_file.set_name("bar.proto"); other_file.add_message_type()->set_name("foo"); - EXPECT_TRUE(pool_.BuildFile(other_file) != NULL); + EXPECT_TRUE(pool_.BuildFile(other_file) != nullptr); // Now try to define it as a package. ExpectHasValidationErrors( @@ -1861,7 +1861,8 @@ TEST_F(ParserValidationErrorTest, FieldNumberError) { "message Foo {\n" " optional int32 bar = 0;\n" "}\n", - "1:23: Field numbers must be positive integers.\n"); + "1:23: Field numbers must be positive integers.\n" + "1:23: Suggested field numbers for Foo: 1\n"); } TEST_F(ParserValidationErrorTest, FieldExtendeeError) { @@ -1926,7 +1927,8 @@ TEST_F(ParserValidationErrorTest, ExtensionRangeNumberError) { "message Foo {\n" " extensions 0;\n" "}\n", - "1:13: Extension numbers must be positive integers.\n"); + "1:13: Extension numbers must be positive integers.\n" + "1:13: Suggested field numbers for Foo: 1\n"); } TEST_F(ParserValidationErrorTest, Proto3ExtensionError) { @@ -2071,7 +2073,7 @@ TEST_F(ParserValidationErrorTest, ResolvedUndefinedError) { other_file.set_name("base.proto"); other_file.set_package("base"); other_file.add_message_type()->set_name("bar"); - EXPECT_TRUE(pool_.BuildFile(other_file) != NULL); + EXPECT_TRUE(pool_.BuildFile(other_file) != nullptr); // Define "foo.base" and try "base.bar". // "base.bar" is resolved to "foo.base.bar" which is not defined. @@ -2092,7 +2094,7 @@ TEST_F(ParserValidationErrorTest, ResovledUndefinedOptionError) { // Build descriptor message in test pool FileDescriptorProto descriptor_proto; DescriptorProto::descriptor()->file()->CopyTo(&descriptor_proto); - ASSERT_TRUE(pool_.BuildFile(descriptor_proto) != NULL); + ASSERT_TRUE(pool_.BuildFile(descriptor_proto) != nullptr); // base2.proto: // package baz @@ -2121,7 +2123,7 @@ TEST_F(ParserValidationErrorTest, ResovledUndefinedOptionError) { extension->set_type_name("Bar"); extension->set_extendee("google.protobuf.FileOptions"); - EXPECT_TRUE(pool_.BuildFile(other_file) != NULL); + EXPECT_TRUE(pool_.BuildFile(other_file) != nullptr); // qux.proto: // package qux.baz @@ -2228,17 +2230,17 @@ TEST_F(ParseDescriptorDebugTest, TestAllDescriptorTypes) { protobuf_unittest_import::PublicImportMessage::descriptor()->file(); FileDescriptorProto public_import_proto; public_import->CopyTo(&public_import_proto); - ASSERT_TRUE(pool_.BuildFile(public_import_proto) != NULL); + ASSERT_TRUE(pool_.BuildFile(public_import_proto) != nullptr); const FileDescriptor* import = protobuf_unittest_import::ImportMessage::descriptor()->file(); FileDescriptorProto import_proto; import->CopyTo(&import_proto); - ASSERT_TRUE(pool_.BuildFile(import_proto) != NULL); + ASSERT_TRUE(pool_.BuildFile(import_proto) != nullptr); const FileDescriptor* actual = pool_.BuildFile(parsed); parsed.Clear(); - ASSERT_TRUE(actual != NULL) << "Failed to validate:\n" << debug_string; + ASSERT_TRUE(actual != nullptr) << "Failed to validate:\n" << debug_string; actual->CopyTo(&parsed); - ASSERT_TRUE(actual != NULL); + ASSERT_TRUE(actual != nullptr); // The messages might be in different orders, making them hard to compare. // So, sort the messages in the descriptor protos (including nested messages, @@ -2276,14 +2278,14 @@ TEST_F(ParseDescriptorDebugTest, TestCustomOptions) { const FileDescriptor* import = FileDescriptorProto::descriptor()->file(); FileDescriptorProto import_proto; import->CopyTo(&import_proto); - ASSERT_TRUE(pool_.BuildFile(import_proto) != NULL); + ASSERT_TRUE(pool_.BuildFile(import_proto) != nullptr); FileDescriptorProto any_import; google::protobuf::Any::descriptor()->file()->CopyTo(&any_import); ASSERT_TRUE(pool_.BuildFile(any_import) != nullptr); const FileDescriptor* actual = pool_.BuildFile(parsed); - ASSERT_TRUE(actual != NULL); + ASSERT_TRUE(actual != nullptr); parsed.Clear(); actual->CopyTo(&parsed); @@ -2365,7 +2367,7 @@ TEST_F(ParseDescriptorDebugTest, TestCommentsInDebugString) { MockValidationErrorCollector collector(source_locations, &error_collector_); const FileDescriptor* descriptor = pool_.BuildFileCollectingErrors(parsed_desc, &collector); - ASSERT_TRUE(descriptor != NULL); + ASSERT_TRUE(descriptor != nullptr); // Ensure that each of the comments appears somewhere in the DebugString(). // We don't test the exact comment placement or formatting, because we do not @@ -2429,7 +2431,7 @@ TEST_F(ParseDescriptorDebugTest, TestMaps) { EXPECT_TRUE(parser_->Parse(input_.get(), &original)); original.set_name("foo.proto"); const FileDescriptor* file = pool_.BuildFile(original); - ASSERT_TRUE(file != NULL); + ASSERT_TRUE(file != nullptr); // Make sure the debug string uses map syntax and does not have the auto // generated entry. @@ -2466,13 +2468,15 @@ TEST_F(ParseDescriptorDebugTest, TestMaps) { // *output_field to the descriptor of the field, and *output_index to -1. // Returns true if the path was valid, false otherwise. A gTest failure is // recorded before returning false. -bool FollowPath(const Message& root, const int* path_begin, const int* path_end, +bool FollowPath(const Message& root, + RepeatedField<int>::const_iterator path_begin, + RepeatedField<int>::const_iterator path_end, const Message** output_message, const FieldDescriptor** output_field, int* output_index) { if (path_begin == path_end) { // Path refers to this whole message. *output_message = &root; - *output_field = NULL; + *output_field = nullptr; *output_index = -1; return true; } @@ -2482,7 +2486,7 @@ bool FollowPath(const Message& root, const int* path_begin, const int* path_end, const FieldDescriptor* field = descriptor->FindFieldByNumber(*path_begin); - if (field == NULL) { + if (field == nullptr) { ADD_FAILURE() << descriptor->name() << " has no field number: " << *path_begin; return false; @@ -2573,8 +2577,8 @@ class SourceInfoTest : public ParserTest { const SourceCodeInfo& source_info = file_.source_code_info(); for (int i = 0; i < source_info.location_size(); i++) { const SourceCodeInfo::Location& location = source_info.location(i); - const Message* descriptor_proto = NULL; - const FieldDescriptor* field = NULL; + const Message* descriptor_proto = nullptr; + const FieldDescriptor* field = nullptr; int index = 0; if (!FollowPath(file_, location.path().begin(), location.path().end(), &descriptor_proto, &field, &index)) { @@ -2601,8 +2605,8 @@ class SourceInfoTest : public ParserTest { bool HasSpan(char start_marker, char end_marker, const Message& descriptor_proto) { - return HasSpanWithComment(start_marker, end_marker, descriptor_proto, NULL, - -1, NULL, NULL, NULL); + return HasSpanWithComment(start_marker, end_marker, descriptor_proto, + nullptr, -1, nullptr, nullptr, nullptr); } bool HasSpanWithComment(char start_marker, char end_marker, @@ -2610,8 +2614,8 @@ class SourceInfoTest : public ParserTest { const char* expected_leading_comments, const char* expected_trailing_comments, const char* expected_leading_detached_comments) { - return HasSpanWithComment(start_marker, end_marker, descriptor_proto, NULL, - -1, expected_leading_comments, + return HasSpanWithComment(start_marker, end_marker, descriptor_proto, + nullptr, -1, expected_leading_comments, expected_trailing_comments, expected_leading_detached_comments); } @@ -2625,7 +2629,7 @@ class SourceInfoTest : public ParserTest { const Message& descriptor_proto, const std::string& field_name, int index) { return HasSpan(start_marker, end_marker, descriptor_proto, field_name, - index, NULL, NULL, NULL); + index, nullptr, nullptr, nullptr); } bool HasSpan(char start_marker, char end_marker, @@ -2635,7 +2639,7 @@ class SourceInfoTest : public ParserTest { const char* expected_leading_detached_comments) { const FieldDescriptor* field = descriptor_proto.GetDescriptor()->FindFieldByName(field_name); - if (field == NULL) { + if (field == nullptr) { ADD_FAILURE() << descriptor_proto.GetDescriptor()->name() << " has no such field: " << field_name; return false; @@ -2648,8 +2652,8 @@ class SourceInfoTest : public ParserTest { } bool HasSpan(const Message& descriptor_proto) { - return HasSpanWithComment('\0', '\0', descriptor_proto, NULL, -1, NULL, - NULL, NULL); + return HasSpanWithComment('\0', '\0', descriptor_proto, nullptr, -1, + nullptr, nullptr, nullptr); } bool HasSpan(const Message& descriptor_proto, const std::string& field_name) { @@ -2686,21 +2690,21 @@ class SourceInfoTest : public ParserTest { for (SpanMap::iterator iter = range.first; iter != range.second; ++iter) { if (CompareSpans(expected_span, iter->second->span())) { - if (expected_leading_comments == NULL) { + if (expected_leading_comments == nullptr) { EXPECT_FALSE(iter->second->has_leading_comments()); } else { EXPECT_TRUE(iter->second->has_leading_comments()); EXPECT_EQ(expected_leading_comments, iter->second->leading_comments()); } - if (expected_trailing_comments == NULL) { + if (expected_trailing_comments == nullptr) { EXPECT_FALSE(iter->second->has_trailing_comments()); } else { EXPECT_TRUE(iter->second->has_trailing_comments()); EXPECT_EQ(expected_trailing_comments, iter->second->trailing_comments()); } - if (expected_leading_detached_comments == NULL) { + if (expected_leading_detached_comments == nullptr) { EXPECT_EQ(0, iter->second->leading_detached_comments_size()); } else { EXPECT_EQ( @@ -3496,7 +3500,7 @@ TEST_F(SourceInfoTest, DocComments) { const FieldDescriptorProto& bar = foo.field(0); EXPECT_TRUE(HasSpanWithComment('a', 'd', foo, " Foo leading\n line 2\n", - " Foo trailing\n line 2\n", NULL)); + " Foo trailing\n line 2\n", nullptr)); EXPECT_TRUE(HasSpanWithComment('b', 'c', bar, " bar leading\n", " bar trailing\n", " detached\n")); @@ -3572,7 +3576,7 @@ TEST_F(SourceInfoTest, DocComments3) { const FieldDescriptorProto& bar = foo.field(0); EXPECT_TRUE(HasSpanWithComment('b', 'c', bar, " bar leading\n", - " bar trailing\n", NULL)); + " bar trailing\n", nullptr)); // Ignore these. EXPECT_TRUE(HasSpan(file_)); @@ -3655,7 +3659,7 @@ TEST_F(SourceInfoTest, DocCommentsOneof) { const FieldDescriptorProto& bar_int = foo.field(0); EXPECT_TRUE(HasSpanWithComment('a', 'f', foo, " Foo leading\n", - " Foo trailing\n", NULL)); + " Foo trailing\n", nullptr)); EXPECT_TRUE(HasSpanWithComment('b', 'e', bar, " bar leading\n line 2 ", " bar trailing\n line 2 ", " detached before oneof\n")); diff --git a/r5dev/thirdparty/protobuf/compiler/php/php_generator.cc b/r5dev/thirdparty/protobuf/compiler/php/php_generator.cc index 4b8fff57..0e14dc4e 100644 --- a/r5dev/thirdparty/protobuf/compiler/php/php_generator.cc +++ b/r5dev/thirdparty/protobuf/compiler/php/php_generator.cc @@ -48,28 +48,29 @@ const std::string kDescriptorMetadataFile = const std::string kDescriptorDirName = "Google/Protobuf/Internal"; const std::string kDescriptorPackageName = "Google\\Protobuf\\Internal"; const char* const kReservedNames[] = { - "abstract", "and", "array", "as", "break", - "callable", "case", "catch", "class", "clone", - "const", "continue", "declare", "default", "die", - "do", "echo", "else", "elseif", "empty", - "enddeclare", "endfor", "endforeach", "endif", "endswitch", - "endwhile", "eval", "exit", "extends", "final", - "finally", "fn", "for", "foreach", "function", - "global", "goto", "if", "implements", "include", - "include_once", "instanceof", "insteadof", "interface", "isset", - "list", "match", "namespace", "new", "or", - "print", "private", "protected", "public", "require", - "require_once", "return", "static", "switch", "throw", - "trait", "try", "unset", "use", "var", - "while", "xor", "yield", "int", "float", - "bool", "string", "true", "false", "null", - "void", "iterable"}; + "abstract", "and", "array", "as", "break", + "callable", "case", "catch", "class", "clone", + "const", "continue", "declare", "default", "die", + "do", "echo", "else", "elseif", "empty", + "enddeclare", "endfor", "endforeach", "endif", "endswitch", + "endwhile", "eval", "exit", "extends", "final", + "finally", "fn", "for", "foreach", "function", + "global", "goto", "if", "implements", "include", + "include_once", "instanceof", "insteadof", "interface", "isset", + "list", "match", "namespace", "new", "or", + "parent", "print", "private", "protected", "public", + "readonly", "require", "require_once", "return", "self", + "static", "switch", "throw", "trait", "try", + "unset", "use", "var", "while", "xor", + "yield", "int", "float", "bool", "string", + "true", "false", "null", "void", "iterable"}; const char* const kValidConstantNames[] = { "int", "float", "bool", "string", "true", - "false", "null", "void", "iterable", + "false", "null", "void", "iterable", "parent", + "self", "readonly" }; -const int kReservedNamesSize = 77; -const int kValidConstantNamesSize = 9; +const int kReservedNamesSize = 80; +const int kValidConstantNamesSize = 12; const int kFieldSetter = 1; const int kFieldGetter = 2; const int kFieldProperty = 3; @@ -83,14 +84,14 @@ struct Options { bool is_descriptor = false; bool aggregate_metadata = false; bool gen_c_wkt = false; - std::set<string> aggregate_metadata_prefixes; + std::set<std::string> aggregate_metadata_prefixes; }; namespace { // Forward decls. std::string PhpName(const std::string& full_name, const Options& options); -std::string IntToString(int32 value); +std::string IntToString(int32_t value); std::string FilenameToClassname(const std::string& filename); std::string GeneratedMetadataFileName(const FileDescriptor* file, const Options& options); @@ -419,6 +420,21 @@ std::string LegacyGeneratedClassFileName(const DescriptorType* desc, return result + ".php"; } +template <typename DescriptorType> +std::string LegacyReadOnlyGeneratedClassFileName(std::string php_namespace, + const DescriptorType* desc) { + if (!php_namespace.empty()) { + for (int i = 0; i < php_namespace.size(); i++) { + if (php_namespace[i] == '\\') { + php_namespace[i] = '/'; + } + } + return php_namespace + "/" + desc->name() + ".php"; + } + + return desc->name() + ".php"; +} + std::string GeneratedServiceFileName(const ServiceDescriptor* service, const Options& options) { std::string result = FullClassName(service, options) + "Interface"; @@ -430,7 +446,7 @@ std::string GeneratedServiceFileName(const ServiceDescriptor* service, return result + ".php"; } -std::string IntToString(int32 value) { +std::string IntToString(int32_t value) { std::ostringstream os; os << value; return os.str(); @@ -489,9 +505,9 @@ std::string PhpSetterTypeName(const FieldDescriptor* field, // accommodate for edge case with multiple types. size_t start_pos = type.find("|"); if (start_pos != std::string::npos) { - type.replace(start_pos, 1, "[]|"); + type.replace(start_pos, 1, ">|array<"); } - type += "[]|\\Google\\Protobuf\\Internal\\RepeatedField"; + type = "array<" + type + ">|\\Google\\Protobuf\\Internal\\RepeatedField"; } return type; } @@ -741,8 +757,8 @@ void GenerateFieldAccessor(const FieldDescriptor* field, const Options& options, // Type check. if (field->is_map()) { const Descriptor* map_entry = field->message_type(); - const FieldDescriptor* key = map_entry->FindFieldByName("key"); - const FieldDescriptor* value = map_entry->FindFieldByName("value"); + const FieldDescriptor* key = map_entry->map_key(); + const FieldDescriptor* value = map_entry->map_value(); printer->Print( "$arr = GPBUtil::checkMapField($var, " "\\Google\\Protobuf\\Internal\\GPBType::^key_type^, " @@ -889,9 +905,9 @@ void GenerateMessageToPool(const std::string& name_prefix, const FieldDescriptor* field = message->field(i); if (field->is_map()) { const FieldDescriptor* key = - field->message_type()->FindFieldByName("key"); + field->message_type()->map_key(); const FieldDescriptor* val = - field->message_type()->FindFieldByName("value"); + field->message_type()->map_value(); printer->Print( "->map('^field^', \\Google\\Protobuf\\Internal\\GPBType::^key^, " "\\Google\\Protobuf\\Internal\\GPBType::^value^, ^number^^other^)\n", @@ -1114,7 +1130,7 @@ void GenerateAddFilesToPool(const FileDescriptor* file, const Options& options, std::map<const FileDescriptor*, int> dependency_count; std::set<const FileDescriptor*> nodes_without_dependency; FileDescriptorSet sorted_file_set; - + AnalyzeDependencyForFile( file, &nodes_without_dependency, &deps, &dependency_count); @@ -1301,6 +1317,45 @@ void LegacyGenerateClassFile(const FileDescriptor* file, "fullname", newname); } +template <typename DescriptorType> +void LegacyReadOnlyGenerateClassFile(const FileDescriptor* file, + const DescriptorType* desc, const Options& options, + GeneratorContext* generator_context) { + std::string fullname = FullClassName(desc, options); + std::string php_namespace; + std::string classname; + int lastindex = fullname.find_last_of("\\"); + + if (lastindex != std::string::npos) { + php_namespace = fullname.substr(0, lastindex); + classname = fullname.substr(lastindex + 1); + } else { + php_namespace = ""; + classname = fullname; + } + + std::string filename = LegacyReadOnlyGeneratedClassFileName(php_namespace, desc); + std::unique_ptr<io::ZeroCopyOutputStream> output( + generator_context->Open(filename)); + io::Printer printer(output.get(), '^'); + + GenerateHead(file, &printer); + + if (!php_namespace.empty()) { + printer.Print( + "namespace ^name^;\n\n", + "name", php_namespace); + } + + printer.Print("class_exists(^new^::class); // autoload the new class, which " + "will also create an alias to the deprecated class\n", + "new", classname); + printer.Print("@trigger_error(__NAMESPACE__ . '\\^old^ is deprecated and will be removed in " + "the next major release. Use ^fullname^ instead', E_USER_DEPRECATED);\n\n", + "old", desc->name(), + "fullname", classname); +} + void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, const Options& options, GeneratorContext* generator_context) { @@ -1336,11 +1391,18 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, "name", fullname); Indent(&printer); + bool hasReserved = false; for (int i = 0; i < en->value_count(); i++) { const EnumValueDescriptor* value = en->value(i); GenerateEnumValueDocComment(&printer, value); + + std::string prefix = ConstantNamePrefix(value->name()); + if (!prefix.empty()) { + hasReserved = true; + } + printer.Print("const ^name^ = ^number^;\n", - "name", ConstantNamePrefix(value->name()) + value->name(), + "name", prefix + value->name(), "number", IntToString(value->number())); } @@ -1348,8 +1410,9 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, Indent(&printer); for (int i = 0; i < en->value_count(); i++) { const EnumValueDescriptor* value = en->value(i); - printer.Print("self::^name^ => '^name^',\n", - "name", ConstantNamePrefix(value->name()) + value->name()); + printer.Print("self::^constant^ => '^name^',\n", + "constant", ConstantNamePrefix(value->name()) + value->name(), + "name", value->name()); } Outdent(&printer); printer.Print("];\n"); @@ -1379,12 +1442,22 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, printer.Print("$const = __CLASS__ . '::' . strtoupper($name);\n" "if (!defined($const)) {\n"); Indent(&printer); + if (hasReserved) { + printer.Print("$pbconst = __CLASS__. '::PB' . strtoupper($name);\n" + "if (!defined($pbconst)) {\n"); + Indent(&printer); + } printer.Print("throw new UnexpectedValueException(sprintf(\n"); Indent(&printer); Indent(&printer); printer.Print("'Enum %s has no value defined for name %s', __CLASS__, $name));\n"); Outdent(&printer); Outdent(&printer); + if (hasReserved) { + Outdent(&printer); + printer.Print("}\n" + "return constant($pbconst);\n"); + } Outdent(&printer); printer.Print("}\n" "return constant($const);\n"); @@ -1404,6 +1477,19 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, "old", LegacyFullClassName(en, options)); LegacyGenerateClassFile(file, en, options, generator_context); } + + // Write legacy file for backwards compatibility with "readonly" keywword + std::string lower = en->name(); + std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); + if (lower == "readonly") { + printer.Print( + "// Adding a class alias for backwards compatibility with the \"readonly\" keyword.\n"); + printer.Print( + "class_alias(^new^::class, __NAMESPACE__ . '\\^old^');\n\n", + "new", fullname, + "old", en->name()); + LegacyReadOnlyGenerateClassFile(file, en, options, generator_context); + } } void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, @@ -1520,6 +1606,19 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, LegacyGenerateClassFile(file, message, options, generator_context); } + // Write legacy file for backwards compatibility with "readonly" keywword + std::string lower = message->name(); + std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); + if (lower == "readonly") { + printer.Print( + "// Adding a class alias for backwards compatibility with the \"readonly\" keyword.\n"); + printer.Print( + "class_alias(^new^::class, __NAMESPACE__ . '\\^old^');\n\n", + "new", fullname, + "old", message->name()); + LegacyReadOnlyGenerateClassFile(file, message, options, generator_context); + } + // Nested messages and enums. for (int i = 0; i < message->nested_type_count(); i++) { GenerateMessageFile(file, message->nested_type(i), options, @@ -1869,44 +1968,45 @@ void GenerateCEnum(const EnumDescriptor* desc, io::Printer* printer) { "\n" "PHP_METHOD($c_name$, name) {\n" " $file_c_name$_AddDescriptor();\n" - " const upb_symtab *symtab = DescriptorPool_GetSymbolTable();\n" - " const upb_enumdef *e = upb_symtab_lookupenum(symtab, \"$name$\");\n" - " const char *name;\n" + " const upb_DefPool *symtab = DescriptorPool_GetSymbolTable();\n" + " const upb_EnumDef *e = upb_DefPool_FindEnumByName(symtab, \"$name$\");\n" " zend_long value;\n" " if (zend_parse_parameters(ZEND_NUM_ARGS(), \"l\", &value) ==\n" " FAILURE) {\n" " return;\n" " }\n" - " name = upb_enumdef_iton(e, value);\n" - " if (!name) {\n" + " const upb_EnumValueDef* ev =\n" + " upb_EnumDef_FindValueByNumber(e, value);\n" + " if (!ev) {\n" " zend_throw_exception_ex(NULL, 0,\n" " \"$php_name$ has no name \"\n" " \"defined for value \" ZEND_LONG_FMT \".\",\n" " value);\n" " return;\n" " }\n" - " RETURN_STRING(name);\n" + " RETURN_STRING(upb_EnumValueDef_Name(ev));\n" "}\n" "\n" "PHP_METHOD($c_name$, value) {\n" " $file_c_name$_AddDescriptor();\n" - " const upb_symtab *symtab = DescriptorPool_GetSymbolTable();\n" - " const upb_enumdef *e = upb_symtab_lookupenum(symtab, \"$name$\");\n" + " const upb_DefPool *symtab = DescriptorPool_GetSymbolTable();\n" + " const upb_EnumDef *e = upb_DefPool_FindEnumByName(symtab, \"$name$\");\n" " char *name = NULL;\n" " size_t name_len;\n" - " int32_t num;\n" " if (zend_parse_parameters(ZEND_NUM_ARGS(), \"s\", &name,\n" " &name_len) == FAILURE) {\n" " return;\n" " }\n" - " if (!upb_enumdef_ntoi(e, name, name_len, &num)) {\n" + " const upb_EnumValueDef* ev = upb_EnumDef_FindValueByNameWithSize(\n" + " e, name, name_len);\n" + " if (!ev) {\n" " zend_throw_exception_ex(NULL, 0,\n" " \"$php_name$ has no value \"\n" " \"defined for name %s.\",\n" " name);\n" " return;\n" " }\n" - " RETURN_LONG(num);\n" + " RETURN_LONG(upb_EnumValueDef_Number(ev));\n" "}\n" "\n" "static zend_function_entry $c_name$_phpmethods[] = {\n" @@ -1965,8 +2065,8 @@ void GenerateCMessage(const Descriptor* message, io::Printer* printer) { printer->Print( "static PHP_METHOD($c_name$, get$camel_name$) {\n" " Message* intern = (Message*)Z_OBJ_P(getThis());\n" - " const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,\n" - " \"$name$\");\n" + " const upb_FieldDef *f = upb_MessageDef_FindFieldByName(\n" + " intern->desc->msgdef, \"$name$\");\n" " zval ret;\n" " Message_get(intern, f, &ret);\n" " RETURN_COPY_VALUE(&ret);\n" @@ -1974,8 +2074,8 @@ void GenerateCMessage(const Descriptor* message, io::Printer* printer) { "\n" "static PHP_METHOD($c_name$, set$camel_name$) {\n" " Message* intern = (Message*)Z_OBJ_P(getThis());\n" - " const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef,\n" - " \"$name$\");\n" + " const upb_FieldDef *f = upb_MessageDef_FindFieldByName(\n" + " intern->desc->msgdef, \"$name$\");\n" " zval *val;\n" " if (zend_parse_parameters(ZEND_NUM_ARGS(), \"z\", &val)\n" " == FAILURE) {\n" @@ -1995,10 +2095,11 @@ void GenerateCMessage(const Descriptor* message, io::Printer* printer) { printer->Print( "static PHP_METHOD($c_name$, get$camel_name$) {\n" " Message* intern = (Message*)Z_OBJ_P(getThis());\n" - " const upb_oneofdef *oneof = upb_msgdef_ntooz(intern->desc->msgdef,\n" - " \"$name$\");\n" - " const upb_fielddef *field = upb_msg_whichoneof(intern->msg, oneof);\n" - " RETURN_STRING(field ? upb_fielddef_name(field) : \"\");\n" + " const upb_OneofDef *oneof = upb_MessageDef_FindOneofByName(\n" + " intern->desc->msgdef, \"$name$\");\n" + " const upb_FieldDef *field = \n" + " upb_Message_WhichOneof(intern->msg, oneof);\n" + " RETURN_STRING(field ? upb_FieldDef_Name(field) : \"\");\n" "}\n", "c_name", c_name, "name", oneof->name(), @@ -2065,7 +2166,7 @@ void GenerateCMessage(const Descriptor* message, io::Printer* printer) { break; default: break; - } + } printer->Print( " ZEND_FE_END\n" diff --git a/r5dev/thirdparty/protobuf/compiler/plugin.cc b/r5dev/thirdparty/protobuf/compiler/plugin.cc index 2f954311..0aa306e3 100644 --- a/r5dev/thirdparty/protobuf/compiler/plugin.cc +++ b/r5dev/thirdparty/protobuf/compiler/plugin.cc @@ -45,9 +45,10 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/compiler/plugin.pb.h> #include <thirdparty/protobuf/compiler/code_generator.h> -#include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/io_win32.h> +#include <thirdparty/protobuf/io/zero_copy_stream_impl.h> namespace google { @@ -68,7 +69,7 @@ class GeneratorResponseContext : public GeneratorContext { : compiler_version_(compiler_version), response_(response), parsed_files_(parsed_files) {} - virtual ~GeneratorResponseContext() {} + ~GeneratorResponseContext() override {} // implements GeneratorContext -------------------------------------- @@ -117,7 +118,7 @@ bool GenerateCode(const CodeGeneratorRequest& request, DescriptorPool pool; for (int i = 0; i < request.proto_file_size(); i++) { const FileDescriptor* file = pool.BuildFile(request.proto_file(i)); - if (file == NULL) { + if (file == nullptr) { // BuildFile() already wrote an error message. return false; } @@ -126,7 +127,7 @@ bool GenerateCode(const CodeGeneratorRequest& request, std::vector<const FileDescriptor*> parsed_files; for (int i = 0; i < request.file_to_generate_size(); i++) { parsed_files.push_back(pool.FindFileByName(request.file_to_generate(i))); - if (parsed_files.back() == NULL) { + if (parsed_files.back() == nullptr) { *error_msg = "protoc asked plugin to generate a file but " "did not provide a descriptor for the file: " + diff --git a/r5dev/thirdparty/protobuf/compiler/plugin.h b/r5dev/thirdparty/protobuf/compiler/plugin.h index 8384337c..463dd5bf 100644 --- a/r5dev/thirdparty/protobuf/compiler/plugin.h +++ b/r5dev/thirdparty/protobuf/compiler/plugin.h @@ -64,6 +64,7 @@ #include <string> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/compiler/plugin.pb.cc b/r5dev/thirdparty/protobuf/compiler/plugin.pb.cc index 43517122..23b90143 100644 --- a/r5dev/thirdparty/protobuf/compiler/plugin.pb.cc +++ b/r5dev/thirdparty/protobuf/compiler/plugin.pb.cc @@ -16,141 +16,153 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + PROTOBUF_NAMESPACE_OPEN namespace compiler { -constexpr Version::Version( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : suffix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , major_(0) - , minor_(0) - , patch_(0){} +PROTOBUF_CONSTEXPR Version::Version( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.suffix_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.major_)*/0 + , /*decltype(_impl_.minor_)*/0 + , /*decltype(_impl_.patch_)*/0} {} struct VersionDefaultTypeInternal { - constexpr VersionDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR VersionDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~VersionDefaultTypeInternal() {} union { Version _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT VersionDefaultTypeInternal _Version_default_instance_; -constexpr CodeGeneratorRequest::CodeGeneratorRequest( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : file_to_generate_() - , proto_file_() - , parameter_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , compiler_version_(nullptr){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 VersionDefaultTypeInternal _Version_default_instance_; +PROTOBUF_CONSTEXPR CodeGeneratorRequest::CodeGeneratorRequest( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.file_to_generate_)*/{} + , /*decltype(_impl_.proto_file_)*/{} + , /*decltype(_impl_.parameter_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.compiler_version_)*/nullptr} {} struct CodeGeneratorRequestDefaultTypeInternal { - constexpr CodeGeneratorRequestDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR CodeGeneratorRequestDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~CodeGeneratorRequestDefaultTypeInternal() {} union { CodeGeneratorRequest _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; -constexpr CodeGeneratorResponse_File::CodeGeneratorResponse_File( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , insertion_point_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , content_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , generated_code_info_(nullptr){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; +PROTOBUF_CONSTEXPR CodeGeneratorResponse_File::CodeGeneratorResponse_File( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.insertion_point_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.content_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.generated_code_info_)*/nullptr} {} struct CodeGeneratorResponse_FileDefaultTypeInternal { - constexpr CodeGeneratorResponse_FileDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR CodeGeneratorResponse_FileDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~CodeGeneratorResponse_FileDefaultTypeInternal() {} union { CodeGeneratorResponse_File _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; -constexpr CodeGeneratorResponse::CodeGeneratorResponse( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : file_() - , error_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , supported_features_(uint64_t{0u}){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; +PROTOBUF_CONSTEXPR CodeGeneratorResponse::CodeGeneratorResponse( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.file_)*/{} + , /*decltype(_impl_.error_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.supported_features_)*/uint64_t{0u}} {} struct CodeGeneratorResponseDefaultTypeInternal { - constexpr CodeGeneratorResponseDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR CodeGeneratorResponseDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~CodeGeneratorResponseDefaultTypeInternal() {} union { CodeGeneratorResponse _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; } // namespace compiler PROTOBUF_NAMESPACE_CLOSE -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[4]; -static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; +static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[4]; +static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; const uint32_t TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, major_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, minor_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, patch_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, suffix_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.major_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.minor_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.patch_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.suffix_), 1, 2, 3, 0, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, file_to_generate_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, parameter_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, proto_file_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, compiler_version_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.file_to_generate_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.parameter_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.proto_file_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.compiler_version_), ~0u, 0, ~0u, 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, insertion_point_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, content_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, generated_code_info_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.insertion_point_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.content_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.generated_code_info_), 0, 1, 2, 3, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, error_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, supported_features_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, file_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.error_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.supported_features_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.file_), 0, 1, ~0u, }; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, 10, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::Version)}, { 14, 24, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)}, { 28, 38, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)}, { 42, 51, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)}, }; -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_File_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_default_instance_), +static const ::_pb::Message* const file_default_instances[] = { + &::PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_File_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_default_instance_._instance, }; const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = @@ -175,22 +187,24 @@ const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2epro "uginProtosZ)google.golang.org/protobuf/t" "ypes/pluginpb" ; -static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = { +static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = { &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, }; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto = { - false, false, 773, descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, "google/protobuf/compiler/plugin.proto", - &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps, 1, 4, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, +static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto = { + false, false, 773, descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + "google/protobuf/compiler/plugin.proto", + &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps, 1, 4, + schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter() { +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; } // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fcompiler_2fplugin_2eproto(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fcompiler_2fplugin_2eproto(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); PROTOBUF_NAMESPACE_OPEN namespace compiler { const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CodeGeneratorResponse_Feature_descriptor() { @@ -219,7 +233,7 @@ constexpr int CodeGeneratorResponse::Feature_ARRAYSIZE; class Version::_Internal { public: - using HasBits = decltype(std::declval<Version>()._has_bits_); + using HasBits = decltype(std::declval<Version>()._impl_._has_bits_); static void set_has_major(HasBits* has_bits) { (*has_bits)[0] |= 2u; } @@ -237,61 +251,69 @@ class Version::_Internal { Version::Version(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.Version) } Version::Version(const Version& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + Version* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.suffix_){} + , decltype(_impl_.major_){} + , decltype(_impl_.minor_){} + , decltype(_impl_.patch_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.suffix_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.suffix_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_suffix()) { - suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_suffix(), - GetArenaForAllocation()); + _this->_impl_.suffix_.Set(from._internal_suffix(), + _this->GetArenaForAllocation()); } - ::memcpy(&major_, &from.major_, - static_cast<size_t>(reinterpret_cast<char*>(&patch_) - - reinterpret_cast<char*>(&major_)) + sizeof(patch_)); + ::memcpy(&_impl_.major_, &from._impl_.major_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.patch_) - + reinterpret_cast<char*>(&_impl_.major_)) + sizeof(_impl_.patch_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.Version) } -inline void Version::SharedCtor() { -suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&major_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&patch_) - - reinterpret_cast<char*>(&major_)) + sizeof(patch_)); +inline void Version::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.suffix_){} + , decltype(_impl_.major_){0} + , decltype(_impl_.minor_){0} + , decltype(_impl_.patch_){0} + }; + _impl_.suffix_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.suffix_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } Version::~Version() { // @@protoc_insertion_point(destructor:google.protobuf.compiler.Version) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Version::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - suffix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.suffix_.Destroy(); } -void Version::ArenaDtor(void* object) { - Version* _this = reinterpret_cast< Version* >(object); - (void)_this; -} -void Version::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Version::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Version::Clear() { @@ -300,31 +322,31 @@ void Version::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000001u) { - suffix_.ClearNonDefaultToEmpty(); + _impl_.suffix_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x0000000eu) { - ::memset(&major_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&patch_) - - reinterpret_cast<char*>(&major_)) + sizeof(patch_)); + ::memset(&_impl_.major_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.patch_) - + reinterpret_cast<char*>(&_impl_.major_)) + sizeof(_impl_.patch_)); } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Version::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional int32 major = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { _Internal::set_has_major(&has_bits); - major_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.major_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -333,7 +355,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { _Internal::set_has_minor(&has_bits); - minor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.minor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -342,7 +364,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) { _Internal::set_has_patch(&has_bits); - patch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.patch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -351,11 +373,11 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) { auto str = _internal_mutable_suffix(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.Version.suffix"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.Version.suffix"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -375,7 +397,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -389,23 +411,23 @@ uint8_t* Version::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional int32 major = 1; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_major(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_major(), target); } // optional int32 minor = 2; if (cached_has_bits & 0x00000004u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_minor(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_minor(), target); } // optional int32 patch = 3; if (cached_has_bits & 0x00000008u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_patch(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_patch(), target); } // optional string suffix = 4; @@ -419,7 +441,7 @@ uint8_t* Version::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.Version) @@ -434,7 +456,7 @@ size_t Version::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { // optional string suffix = 4; if (cached_has_bits & 0x00000001u) { @@ -445,59 +467,55 @@ size_t Version::ByteSizeLong() const { // optional int32 major = 1; if (cached_has_bits & 0x00000002u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_major()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_major()); } // optional int32 minor = 2; if (cached_has_bits & 0x00000004u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_minor()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_minor()); } // optional int32 patch = 3; if (cached_has_bits & 0x00000008u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_patch()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_patch()); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Version::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Version::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Version::GetClassData() const { return &_class_data_; } -void Version::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Version *>(to)->MergeFrom( - static_cast<const Version &>(from)); -} - -void Version::MergeFrom(const Version& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version) - GOOGLE_DCHECK_NE(&from, this); +void Version::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Version*>(&to_msg); + auto& from = static_cast<const Version&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _internal_set_suffix(from._internal_suffix()); + _this->_internal_set_suffix(from._internal_suffix()); } if (cached_has_bits & 0x00000002u) { - major_ = from.major_; + _this->_impl_.major_ = from._impl_.major_; } if (cached_has_bits & 0x00000004u) { - minor_ = from.minor_; + _this->_impl_.minor_ = from._impl_.minor_; } if (cached_has_bits & 0x00000008u) { - patch_ = from.patch_; + _this->_impl_.patch_ = from._impl_.patch_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Version::CopyFrom(const Version& from) { @@ -516,22 +534,21 @@ void Version::InternalSwap(Version* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &suffix_, lhs_arena, - &other->suffix_, rhs_arena + &_impl_.suffix_, lhs_arena, + &other->_impl_.suffix_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Version, patch_) - + sizeof(Version::patch_) - - PROTOBUF_FIELD_OFFSET(Version, major_)>( - reinterpret_cast<char*>(&major_), - reinterpret_cast<char*>(&other->major_)); + PROTOBUF_FIELD_OFFSET(Version, _impl_.patch_) + + sizeof(Version::_impl_.patch_) + - PROTOBUF_FIELD_OFFSET(Version, _impl_.major_)>( + reinterpret_cast<char*>(&_impl_.major_), + reinterpret_cast<char*>(&other->_impl_.major_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Version::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[0]); } @@ -540,7 +557,7 @@ void Version::InternalSwap(Version* other) { class CodeGeneratorRequest::_Internal { public: - using HasBits = decltype(std::declval<CodeGeneratorRequest>()._has_bits_); + using HasBits = decltype(std::declval<CodeGeneratorRequest>()._impl_._has_bits_); static void set_has_parameter(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -552,73 +569,80 @@ class CodeGeneratorRequest::_Internal { const ::PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::_Internal::compiler_version(const CodeGeneratorRequest* msg) { - return *msg->compiler_version_; + return *msg->_impl_.compiler_version_; } void CodeGeneratorRequest::clear_proto_file() { - proto_file_.Clear(); + _impl_.proto_file_.Clear(); } CodeGeneratorRequest::CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - file_to_generate_(arena), - proto_file_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorRequest) } CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - file_to_generate_(from.file_to_generate_), - proto_file_(from.proto_file_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + CodeGeneratorRequest* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.file_to_generate_){from._impl_.file_to_generate_} + , decltype(_impl_.proto_file_){from._impl_.proto_file_} + , decltype(_impl_.parameter_){} + , decltype(_impl_.compiler_version_){nullptr}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.parameter_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.parameter_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_parameter()) { - parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_parameter(), - GetArenaForAllocation()); + _this->_impl_.parameter_.Set(from._internal_parameter(), + _this->GetArenaForAllocation()); } if (from._internal_has_compiler_version()) { - compiler_version_ = new ::PROTOBUF_NAMESPACE_ID::compiler::Version(*from.compiler_version_); - } else { - compiler_version_ = nullptr; + _this->_impl_.compiler_version_ = new ::PROTOBUF_NAMESPACE_ID::compiler::Version(*from._impl_.compiler_version_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest) } -inline void CodeGeneratorRequest::SharedCtor() { -parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -compiler_version_ = nullptr; +inline void CodeGeneratorRequest::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.file_to_generate_){arena} + , decltype(_impl_.proto_file_){arena} + , decltype(_impl_.parameter_){} + , decltype(_impl_.compiler_version_){nullptr} + }; + _impl_.parameter_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.parameter_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } CodeGeneratorRequest::~CodeGeneratorRequest() { // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorRequest) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void CodeGeneratorRequest::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - parameter_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete compiler_version_; + _impl_.file_to_generate_.~RepeatedPtrField(); + _impl_.proto_file_.~RepeatedPtrField(); + _impl_.parameter_.Destroy(); + if (this != internal_default_instance()) delete _impl_.compiler_version_; } -void CodeGeneratorRequest::ArenaDtor(void* object) { - CodeGeneratorRequest* _this = reinterpret_cast< CodeGeneratorRequest* >(object); - (void)_this; -} -void CodeGeneratorRequest::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void CodeGeneratorRequest::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void CodeGeneratorRequest::Clear() { @@ -627,28 +651,28 @@ void CodeGeneratorRequest::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - file_to_generate_.Clear(); - proto_file_.Clear(); - cached_has_bits = _has_bits_[0]; + _impl_.file_to_generate_.Clear(); + _impl_.proto_file_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - parameter_.ClearNonDefaultToEmpty(); + _impl_.parameter_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(compiler_version_ != nullptr); - compiler_version_->Clear(); + GOOGLE_DCHECK(_impl_.compiler_version_ != nullptr); + _impl_.compiler_version_->Clear(); } } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // repeated string file_to_generate = 1; case 1: @@ -657,11 +681,11 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM do { ptr += 1; auto str = _internal_add_file_to_generate(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate"); + #endif // !NDEBUG if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); } else @@ -671,11 +695,11 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_parameter(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorRequest.parameter"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorRequest.parameter"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -716,7 +740,7 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -740,7 +764,7 @@ uint8_t* CodeGeneratorRequest::_InternalSerialize( target = stream->WriteString(1, s, target); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string parameter = 2; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -753,22 +777,21 @@ uint8_t* CodeGeneratorRequest::_InternalSerialize( // optional .google.protobuf.compiler.Version compiler_version = 3; if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 3, _Internal::compiler_version(this), target, stream); + InternalWriteMessage(3, _Internal::compiler_version(this), + _Internal::compiler_version(this).GetCachedSize(), target, stream); } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_proto_file_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_proto_file_size()); i < n; i++) { + const auto& repfield = this->_internal_proto_file(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(15, this->_internal_proto_file(i), target, stream); + InternalWriteMessage(15, repfield, repfield.GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorRequest) @@ -785,20 +808,20 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { // repeated string file_to_generate = 1; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(file_to_generate_.size()); - for (int i = 0, n = file_to_generate_.size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.file_to_generate_.size()); + for (int i = 0, n = _impl_.file_to_generate_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - file_to_generate_.Get(i)); + _impl_.file_to_generate_.Get(i)); } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; total_size += 1UL * this->_internal_proto_file_size(); - for (const auto& msg : this->proto_file_) { + for (const auto& msg : this->_impl_.proto_file_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { // optional string parameter = 2; if (cached_has_bits & 0x00000001u) { @@ -811,44 +834,41 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *compiler_version_); + *_impl_.compiler_version_); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CodeGeneratorRequest::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, CodeGeneratorRequest::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CodeGeneratorRequest::GetClassData() const { return &_class_data_; } -void CodeGeneratorRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<CodeGeneratorRequest *>(to)->MergeFrom( - static_cast<const CodeGeneratorRequest &>(from)); -} - -void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) - GOOGLE_DCHECK_NE(&from, this); +void CodeGeneratorRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<CodeGeneratorRequest*>(&to_msg); + auto& from = static_cast<const CodeGeneratorRequest&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - file_to_generate_.MergeFrom(from.file_to_generate_); - proto_file_.MergeFrom(from.proto_file_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.file_to_generate_.MergeFrom(from._impl_.file_to_generate_); + _this->_impl_.proto_file_.MergeFrom(from._impl_.proto_file_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _internal_set_parameter(from._internal_parameter()); + _this->_internal_set_parameter(from._internal_parameter()); } if (cached_has_bits & 0x00000002u) { - _internal_mutable_compiler_version()->::PROTOBUF_NAMESPACE_ID::compiler::Version::MergeFrom(from._internal_compiler_version()); + _this->_internal_mutable_compiler_version()->::PROTOBUF_NAMESPACE_ID::compiler::Version::MergeFrom( + from._internal_compiler_version()); } } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) { @@ -859,7 +879,7 @@ void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) { } bool CodeGeneratorRequest::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(proto_file_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.proto_file_)) return false; return true; } @@ -869,19 +889,18 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - file_to_generate_.InternalSwap(&other->file_to_generate_); - proto_file_.InternalSwap(&other->proto_file_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.file_to_generate_.InternalSwap(&other->_impl_.file_to_generate_); + _impl_.proto_file_.InternalSwap(&other->_impl_.proto_file_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - ¶meter_, lhs_arena, - &other->parameter_, rhs_arena + &_impl_.parameter_, lhs_arena, + &other->_impl_.parameter_, rhs_arena ); - swap(compiler_version_, other->compiler_version_); + swap(_impl_.compiler_version_, other->_impl_.compiler_version_); } ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorRequest::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]); } @@ -890,7 +909,7 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { class CodeGeneratorResponse_File::_Internal { public: - using HasBits = decltype(std::declval<CodeGeneratorResponse_File>()._has_bits_); + using HasBits = decltype(std::declval<CodeGeneratorResponse_File>()._impl_._has_bits_); static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -908,96 +927,105 @@ class CodeGeneratorResponse_File::_Internal { const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& CodeGeneratorResponse_File::_Internal::generated_code_info(const CodeGeneratorResponse_File* msg) { - return *msg->generated_code_info_; + return *msg->_impl_.generated_code_info_; } void CodeGeneratorResponse_File::clear_generated_code_info() { - if (generated_code_info_ != nullptr) generated_code_info_->Clear(); - _has_bits_[0] &= ~0x00000008u; + if (_impl_.generated_code_info_ != nullptr) _impl_.generated_code_info_->Clear(); + _impl_._has_bits_[0] &= ~0x00000008u; } CodeGeneratorResponse_File::CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + CodeGeneratorResponse_File* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_){} + , decltype(_impl_.insertion_point_){} + , decltype(_impl_.content_){} + , decltype(_impl_.generated_code_info_){nullptr}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } - insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.insertion_point_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.insertion_point_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_insertion_point()) { - insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_insertion_point(), - GetArenaForAllocation()); + _this->_impl_.insertion_point_.Set(from._internal_insertion_point(), + _this->GetArenaForAllocation()); } - content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.content_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.content_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_content()) { - content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_content(), - GetArenaForAllocation()); + _this->_impl_.content_.Set(from._internal_content(), + _this->GetArenaForAllocation()); } if (from._internal_has_generated_code_info()) { - generated_code_info_ = new ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo(*from.generated_code_info_); - } else { - generated_code_info_ = nullptr; + _this->_impl_.generated_code_info_ = new ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo(*from._impl_.generated_code_info_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } -inline void CodeGeneratorResponse_File::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -generated_code_info_ = nullptr; +inline void CodeGeneratorResponse_File::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_){} + , decltype(_impl_.insertion_point_){} + , decltype(_impl_.content_){} + , decltype(_impl_.generated_code_info_){nullptr} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.insertion_point_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.insertion_point_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.content_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.content_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } CodeGeneratorResponse_File::~CodeGeneratorResponse_File() { // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse.File) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void CodeGeneratorResponse_File::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - insertion_point_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - content_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete generated_code_info_; + _impl_.name_.Destroy(); + _impl_.insertion_point_.Destroy(); + _impl_.content_.Destroy(); + if (this != internal_default_instance()) delete _impl_.generated_code_info_; } -void CodeGeneratorResponse_File::ArenaDtor(void* object) { - CodeGeneratorResponse_File* _this = reinterpret_cast< CodeGeneratorResponse_File* >(object); - (void)_this; -} -void CodeGeneratorResponse_File::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void CodeGeneratorResponse_File::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void CodeGeneratorResponse_File::Clear() { @@ -1006,42 +1034,42 @@ void CodeGeneratorResponse_File::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - insertion_point_.ClearNonDefaultToEmpty(); + _impl_.insertion_point_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - content_.ClearNonDefaultToEmpty(); + _impl_.content_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000008u) { - GOOGLE_DCHECK(generated_code_info_ != nullptr); - generated_code_info_->Clear(); + GOOGLE_DCHECK(_impl_.generated_code_info_ != nullptr); + _impl_.generated_code_info_->Clear(); } } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -1049,11 +1077,11 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_insertion_point(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -1061,11 +1089,11 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB case 15: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 122)) { auto str = _internal_mutable_content(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.content"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.File.content"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -1093,7 +1121,7 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -1107,7 +1135,7 @@ uint8_t* CodeGeneratorResponse_File::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1140,14 +1168,13 @@ uint8_t* CodeGeneratorResponse_File::_InternalSerialize( // optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16; if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 16, _Internal::generated_code_info(this), target, stream); + InternalWriteMessage(16, _Internal::generated_code_info(this), + _Internal::generated_code_info(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorResponse.File) @@ -1162,7 +1189,7 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { // optional string name = 1; if (cached_has_bits & 0x00000001u) { @@ -1189,48 +1216,45 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const { if (cached_has_bits & 0x00000008u) { total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *generated_code_info_); + *_impl_.generated_code_info_); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CodeGeneratorResponse_File::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, CodeGeneratorResponse_File::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CodeGeneratorResponse_File::GetClassData() const { return &_class_data_; } -void CodeGeneratorResponse_File::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<CodeGeneratorResponse_File *>(to)->MergeFrom( - static_cast<const CodeGeneratorResponse_File &>(from)); -} - -void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) - GOOGLE_DCHECK_NE(&from, this); +void CodeGeneratorResponse_File::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<CodeGeneratorResponse_File*>(&to_msg); + auto& from = static_cast<const CodeGeneratorResponse_File&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - _internal_set_insertion_point(from._internal_insertion_point()); + _this->_internal_set_insertion_point(from._internal_insertion_point()); } if (cached_has_bits & 0x00000004u) { - _internal_set_content(from._internal_content()); + _this->_internal_set_content(from._internal_content()); } if (cached_has_bits & 0x00000008u) { - _internal_mutable_generated_code_info()->::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo::MergeFrom(from._internal_generated_code_info()); + _this->_internal_mutable_generated_code_info()->::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo::MergeFrom( + from._internal_generated_code_info()); } } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void CodeGeneratorResponse_File::CopyFrom(const CodeGeneratorResponse_File& from) { @@ -1249,27 +1273,24 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &insertion_point_, lhs_arena, - &other->insertion_point_, rhs_arena + &_impl_.insertion_point_, lhs_arena, + &other->_impl_.insertion_point_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &content_, lhs_arena, - &other->content_, rhs_arena + &_impl_.content_, lhs_arena, + &other->_impl_.content_, rhs_arena ); - swap(generated_code_info_, other->generated_code_info_); + swap(_impl_.generated_code_info_, other->_impl_.generated_code_info_); } ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse_File::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[2]); } @@ -1278,7 +1299,7 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) class CodeGeneratorResponse::_Internal { public: - using HasBits = decltype(std::declval<CodeGeneratorResponse>()._has_bits_); + using HasBits = decltype(std::declval<CodeGeneratorResponse>()._impl_._has_bits_); static void set_has_error(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -1289,59 +1310,67 @@ class CodeGeneratorResponse::_Internal { CodeGeneratorResponse::CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - file_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse) } CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - file_(from.file_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + CodeGeneratorResponse* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.file_){from._impl_.file_} + , decltype(_impl_.error_){} + , decltype(_impl_.supported_features_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.error_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.error_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_error()) { - error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_error(), - GetArenaForAllocation()); + _this->_impl_.error_.Set(from._internal_error(), + _this->GetArenaForAllocation()); } - supported_features_ = from.supported_features_; + _this->_impl_.supported_features_ = from._impl_.supported_features_; // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse) } -inline void CodeGeneratorResponse::SharedCtor() { -error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -supported_features_ = uint64_t{0u}; +inline void CodeGeneratorResponse::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.file_){arena} + , decltype(_impl_.error_){} + , decltype(_impl_.supported_features_){uint64_t{0u}} + }; + _impl_.error_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.error_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } CodeGeneratorResponse::~CodeGeneratorResponse() { // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void CodeGeneratorResponse::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - error_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.file_.~RepeatedPtrField(); + _impl_.error_.Destroy(); } -void CodeGeneratorResponse::ArenaDtor(void* object) { - CodeGeneratorResponse* _this = reinterpret_cast< CodeGeneratorResponse* >(object); - (void)_this; -} -void CodeGeneratorResponse::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void CodeGeneratorResponse::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void CodeGeneratorResponse::Clear() { @@ -1350,32 +1379,32 @@ void CodeGeneratorResponse::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - file_.Clear(); - cached_has_bits = _has_bits_[0]; + _impl_.file_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000001u) { - error_.ClearNonDefaultToEmpty(); + _impl_.error_.ClearNonDefaultToEmpty(); } - supported_features_ = uint64_t{0u}; - _has_bits_.Clear(); + _impl_.supported_features_ = uint64_t{0u}; + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string error = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_error(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.error"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.compiler.CodeGeneratorResponse.error"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -1383,7 +1412,7 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NA case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { _Internal::set_has_supported_features(&has_bits); - supported_features_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.supported_features_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -1417,7 +1446,7 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NA CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -1431,7 +1460,7 @@ uint8_t* CodeGeneratorResponse::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string error = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1445,19 +1474,19 @@ uint8_t* CodeGeneratorResponse::_InternalSerialize( // optional uint64 supported_features = 2; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(2, this->_internal_supported_features(), target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(2, this->_internal_supported_features(), target); } // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_file_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_file_size()); i < n; i++) { + const auto& repfield = this->_internal_file(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(15, this->_internal_file(i), target, stream); + InternalWriteMessage(15, repfield, repfield.GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorResponse) @@ -1474,12 +1503,12 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; total_size += 1UL * this->_internal_file_size(); - for (const auto& msg : this->file_) { + for (const auto& msg : this->_impl_.file_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { // optional string error = 1; if (cached_has_bits & 0x00000001u) { @@ -1490,44 +1519,40 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { // optional uint64 supported_features = 2; if (cached_has_bits & 0x00000002u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64SizePlusOne(this->_internal_supported_features()); + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_supported_features()); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CodeGeneratorResponse::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, CodeGeneratorResponse::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CodeGeneratorResponse::GetClassData() const { return &_class_data_; } -void CodeGeneratorResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<CodeGeneratorResponse *>(to)->MergeFrom( - static_cast<const CodeGeneratorResponse &>(from)); -} - -void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) - GOOGLE_DCHECK_NE(&from, this); +void CodeGeneratorResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<CodeGeneratorResponse*>(&to_msg); + auto& from = static_cast<const CodeGeneratorResponse&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - file_.MergeFrom(from.file_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.file_.MergeFrom(from._impl_.file_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _internal_set_error(from._internal_error()); + _this->_internal_set_error(from._internal_error()); } if (cached_has_bits & 0x00000002u) { - supported_features_ = from.supported_features_; + _this->_impl_.supported_features_ = from._impl_.supported_features_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void CodeGeneratorResponse::CopyFrom(const CodeGeneratorResponse& from) { @@ -1546,18 +1571,17 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - file_.InternalSwap(&other->file_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.file_.InternalSwap(&other->_impl_.file_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &error_, lhs_arena, - &other->error_, rhs_arena + &_impl_.error_, lhs_arena, + &other->_impl_.error_, rhs_arena ); - swap(supported_features_, other->supported_features_); + swap(_impl_.supported_features_, other->_impl_.supported_features_); } ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[3]); } @@ -1566,16 +1590,20 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { } // namespace compiler PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::Version* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::Version >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::Version* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::Version >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::compiler::Version >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/thirdparty/protobuf/compiler/plugin.pb.h b/r5dev/thirdparty/protobuf/compiler/plugin.pb.h index 61b473d2..3b2962ec 100644 --- a/r5dev/thirdparty/protobuf/compiler/plugin.pb.h +++ b/r5dev/thirdparty/protobuf/compiler/plugin.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/generated_message_reflection.h> @@ -50,14 +49,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct PROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[4] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; PROTOC_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; @@ -116,7 +107,7 @@ class PROTOC_EXPORT Version final : public: inline Version() : Version(nullptr) {} ~Version() override; - explicit constexpr Version(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Version(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Version(const Version& from); Version(Version&& from) noexcept @@ -198,9 +189,11 @@ class PROTOC_EXPORT Version final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Version& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Version& from); + void MergeFrom( const Version& from) { + Version::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -209,10 +202,10 @@ class PROTOC_EXPORT Version final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Version* other); @@ -225,9 +218,6 @@ class PROTOC_EXPORT Version final : protected: explicit Version(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -309,12 +299,15 @@ class PROTOC_EXPORT Version final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr suffix_; - int32_t major_; - int32_t minor_; - int32_t patch_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr suffix_; + int32_t major_; + int32_t minor_; + int32_t patch_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; }; // ------------------------------------------------------------------- @@ -324,7 +317,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final : public: inline CodeGeneratorRequest() : CodeGeneratorRequest(nullptr) {} ~CodeGeneratorRequest() override; - explicit constexpr CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); CodeGeneratorRequest(const CodeGeneratorRequest& from); CodeGeneratorRequest(CodeGeneratorRequest&& from) noexcept @@ -406,9 +399,11 @@ class PROTOC_EXPORT CodeGeneratorRequest final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const CodeGeneratorRequest& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const CodeGeneratorRequest& from); + void MergeFrom( const CodeGeneratorRequest& from) { + CodeGeneratorRequest::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -417,10 +412,10 @@ class PROTOC_EXPORT CodeGeneratorRequest final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(CodeGeneratorRequest* other); @@ -433,9 +428,6 @@ class PROTOC_EXPORT CodeGeneratorRequest final : protected: explicit CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -538,12 +530,15 @@ class PROTOC_EXPORT CodeGeneratorRequest final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> file_to_generate_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto > proto_file_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr parameter_; - ::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> file_to_generate_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto > proto_file_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr parameter_; + ::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; }; // ------------------------------------------------------------------- @@ -553,7 +548,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : public: inline CodeGeneratorResponse_File() : CodeGeneratorResponse_File(nullptr) {} ~CodeGeneratorResponse_File() override; - explicit constexpr CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from); CodeGeneratorResponse_File(CodeGeneratorResponse_File&& from) noexcept @@ -635,9 +630,11 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const CodeGeneratorResponse_File& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const CodeGeneratorResponse_File& from); + void MergeFrom( const CodeGeneratorResponse_File& from) { + CodeGeneratorResponse_File::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -646,10 +643,10 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(CodeGeneratorResponse_File* other); @@ -662,9 +659,6 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : protected: explicit CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -761,12 +755,15 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr insertion_point_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr content_; - ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr insertion_point_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr content_; + ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; }; // ------------------------------------------------------------------- @@ -776,7 +773,7 @@ class PROTOC_EXPORT CodeGeneratorResponse final : public: inline CodeGeneratorResponse() : CodeGeneratorResponse(nullptr) {} ~CodeGeneratorResponse() override; - explicit constexpr CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); CodeGeneratorResponse(const CodeGeneratorResponse& from); CodeGeneratorResponse(CodeGeneratorResponse&& from) noexcept @@ -858,9 +855,11 @@ class PROTOC_EXPORT CodeGeneratorResponse final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const CodeGeneratorResponse& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const CodeGeneratorResponse& from); + void MergeFrom( const CodeGeneratorResponse& from) { + CodeGeneratorResponse::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -869,10 +868,10 @@ class PROTOC_EXPORT CodeGeneratorResponse final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(CodeGeneratorResponse* other); @@ -885,9 +884,6 @@ class PROTOC_EXPORT CodeGeneratorResponse final : protected: explicit CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -992,11 +988,14 @@ class PROTOC_EXPORT CodeGeneratorResponse final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File > file_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr error_; - uint64_t supported_features_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File > file_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr error_; + uint64_t supported_features_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; }; // =================================================================== @@ -1012,26 +1011,26 @@ class PROTOC_EXPORT CodeGeneratorResponse final : // optional int32 major = 1; inline bool Version::_internal_has_major() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool Version::has_major() const { return _internal_has_major(); } inline void Version::clear_major() { - major_ = 0; - _has_bits_[0] &= ~0x00000002u; + _impl_.major_ = 0; + _impl_._has_bits_[0] &= ~0x00000002u; } inline int32_t Version::_internal_major() const { - return major_; + return _impl_.major_; } inline int32_t Version::major() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.major) return _internal_major(); } inline void Version::_internal_set_major(int32_t value) { - _has_bits_[0] |= 0x00000002u; - major_ = value; + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.major_ = value; } inline void Version::set_major(int32_t value) { _internal_set_major(value); @@ -1040,26 +1039,26 @@ inline void Version::set_major(int32_t value) { // optional int32 minor = 2; inline bool Version::_internal_has_minor() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool Version::has_minor() const { return _internal_has_minor(); } inline void Version::clear_minor() { - minor_ = 0; - _has_bits_[0] &= ~0x00000004u; + _impl_.minor_ = 0; + _impl_._has_bits_[0] &= ~0x00000004u; } inline int32_t Version::_internal_minor() const { - return minor_; + return _impl_.minor_; } inline int32_t Version::minor() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.minor) return _internal_minor(); } inline void Version::_internal_set_minor(int32_t value) { - _has_bits_[0] |= 0x00000004u; - minor_ = value; + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.minor_ = value; } inline void Version::set_minor(int32_t value) { _internal_set_minor(value); @@ -1068,26 +1067,26 @@ inline void Version::set_minor(int32_t value) { // optional int32 patch = 3; inline bool Version::_internal_has_patch() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } inline bool Version::has_patch() const { return _internal_has_patch(); } inline void Version::clear_patch() { - patch_ = 0; - _has_bits_[0] &= ~0x00000008u; + _impl_.patch_ = 0; + _impl_._has_bits_[0] &= ~0x00000008u; } inline int32_t Version::_internal_patch() const { - return patch_; + return _impl_.patch_; } inline int32_t Version::patch() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.patch) return _internal_patch(); } inline void Version::_internal_set_patch(int32_t value) { - _has_bits_[0] |= 0x00000008u; - patch_ = value; + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.patch_ = value; } inline void Version::set_patch(int32_t value) { _internal_set_patch(value); @@ -1096,15 +1095,15 @@ inline void Version::set_patch(int32_t value) { // optional string suffix = 4; inline bool Version::_internal_has_suffix() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool Version::has_suffix() const { return _internal_has_suffix(); } inline void Version::clear_suffix() { - suffix_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.suffix_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& Version::suffix() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix) @@ -1113,8 +1112,8 @@ inline const std::string& Version::suffix() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Version::set_suffix(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.suffix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) } inline std::string* Version::mutable_suffix() { @@ -1123,41 +1122,40 @@ inline std::string* Version::mutable_suffix() { return _s; } inline const std::string& Version::_internal_suffix() const { - return suffix_.Get(); + return _impl_.suffix_.Get(); } inline void Version::_internal_set_suffix(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.suffix_.Set(value, GetArenaForAllocation()); } inline std::string* Version::_internal_mutable_suffix() { - _has_bits_[0] |= 0x00000001u; - return suffix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.suffix_.Mutable(GetArenaForAllocation()); } inline std::string* Version::release_suffix() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) if (!_internal_has_suffix()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = suffix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.suffix_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (suffix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.suffix_.IsDefault()) { + _impl_.suffix_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void Version::set_allocated_suffix(std::string* suffix) { if (suffix != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - suffix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), suffix, - GetArenaForAllocation()); + _impl_.suffix_.SetAllocated(suffix, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (suffix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - suffix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.suffix_.IsDefault()) { + _impl_.suffix_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) @@ -1169,13 +1167,13 @@ inline void Version::set_allocated_suffix(std::string* suffix) { // repeated string file_to_generate = 1; inline int CodeGeneratorRequest::_internal_file_to_generate_size() const { - return file_to_generate_.size(); + return _impl_.file_to_generate_.size(); } inline int CodeGeneratorRequest::file_to_generate_size() const { return _internal_file_to_generate_size(); } inline void CodeGeneratorRequest::clear_file_to_generate() { - file_to_generate_.Clear(); + _impl_.file_to_generate_.Clear(); } inline std::string* CodeGeneratorRequest::add_file_to_generate() { std::string* _s = _internal_add_file_to_generate(); @@ -1183,7 +1181,7 @@ inline std::string* CodeGeneratorRequest::add_file_to_generate() { return _s; } inline const std::string& CodeGeneratorRequest::_internal_file_to_generate(int index) const { - return file_to_generate_.Get(index); + return _impl_.file_to_generate_.Get(index); } inline const std::string& CodeGeneratorRequest::file_to_generate(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) @@ -1191,68 +1189,68 @@ inline const std::string& CodeGeneratorRequest::file_to_generate(int index) cons } inline std::string* CodeGeneratorRequest::mutable_file_to_generate(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) - return file_to_generate_.Mutable(index); + return _impl_.file_to_generate_.Mutable(index); } inline void CodeGeneratorRequest::set_file_to_generate(int index, const std::string& value) { - file_to_generate_.Mutable(index)->assign(value); + _impl_.file_to_generate_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } inline void CodeGeneratorRequest::set_file_to_generate(int index, std::string&& value) { - file_to_generate_.Mutable(index)->assign(std::move(value)); + _impl_.file_to_generate_.Mutable(index)->assign(std::move(value)); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { GOOGLE_DCHECK(value != nullptr); - file_to_generate_.Mutable(index)->assign(value); + _impl_.file_to_generate_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value, size_t size) { - file_to_generate_.Mutable(index)->assign( + _impl_.file_to_generate_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } inline std::string* CodeGeneratorRequest::_internal_add_file_to_generate() { - return file_to_generate_.Add(); + return _impl_.file_to_generate_.Add(); } inline void CodeGeneratorRequest::add_file_to_generate(const std::string& value) { - file_to_generate_.Add()->assign(value); + _impl_.file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } inline void CodeGeneratorRequest::add_file_to_generate(std::string&& value) { - file_to_generate_.Add(std::move(value)); + _impl_.file_to_generate_.Add(std::move(value)); // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } inline void CodeGeneratorRequest::add_file_to_generate(const char* value) { GOOGLE_DCHECK(value != nullptr); - file_to_generate_.Add()->assign(value); + _impl_.file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } inline void CodeGeneratorRequest::add_file_to_generate(const char* value, size_t size) { - file_to_generate_.Add()->assign(reinterpret_cast<const char*>(value), size); + _impl_.file_to_generate_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>& CodeGeneratorRequest::file_to_generate() const { // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) - return file_to_generate_; + return _impl_.file_to_generate_; } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>* CodeGeneratorRequest::mutable_file_to_generate() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) - return &file_to_generate_; + return &_impl_.file_to_generate_; } // optional string parameter = 2; inline bool CodeGeneratorRequest::_internal_has_parameter() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool CodeGeneratorRequest::has_parameter() const { return _internal_has_parameter(); } inline void CodeGeneratorRequest::clear_parameter() { - parameter_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.parameter_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& CodeGeneratorRequest::parameter() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter) @@ -1261,8 +1259,8 @@ inline const std::string& CodeGeneratorRequest::parameter() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.parameter_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) } inline std::string* CodeGeneratorRequest::mutable_parameter() { @@ -1271,41 +1269,40 @@ inline std::string* CodeGeneratorRequest::mutable_parameter() { return _s; } inline const std::string& CodeGeneratorRequest::_internal_parameter() const { - return parameter_.Get(); + return _impl_.parameter_.Get(); } inline void CodeGeneratorRequest::_internal_set_parameter(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.parameter_.Set(value, GetArenaForAllocation()); } inline std::string* CodeGeneratorRequest::_internal_mutable_parameter() { - _has_bits_[0] |= 0x00000001u; - return parameter_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.parameter_.Mutable(GetArenaForAllocation()); } inline std::string* CodeGeneratorRequest::release_parameter() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter) if (!_internal_has_parameter()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = parameter_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.parameter_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (parameter_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.parameter_.IsDefault()) { + _impl_.parameter_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void CodeGeneratorRequest::set_allocated_parameter(std::string* parameter) { if (parameter != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - parameter_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), parameter, - GetArenaForAllocation()); + _impl_.parameter_.SetAllocated(parameter, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (parameter_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - parameter_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.parameter_.IsDefault()) { + _impl_.parameter_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter) @@ -1313,29 +1310,29 @@ inline void CodeGeneratorRequest::set_allocated_parameter(std::string* parameter // repeated .google.protobuf.FileDescriptorProto proto_file = 15; inline int CodeGeneratorRequest::_internal_proto_file_size() const { - return proto_file_.size(); + return _impl_.proto_file_.size(); } inline int CodeGeneratorRequest::proto_file_size() const { return _internal_proto_file_size(); } inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::mutable_proto_file(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return proto_file_.Mutable(index); + return _impl_.proto_file_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >* CodeGeneratorRequest::mutable_proto_file() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return &proto_file_; + return &_impl_.proto_file_; } inline const ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto& CodeGeneratorRequest::_internal_proto_file(int index) const { - return proto_file_.Get(index); + return _impl_.proto_file_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto& CodeGeneratorRequest::proto_file(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.proto_file) return _internal_proto_file(index); } inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::_internal_add_proto_file() { - return proto_file_.Add(); + return _impl_.proto_file_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::add_proto_file() { ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* _add = _internal_add_proto_file(); @@ -1345,24 +1342,24 @@ inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::add_p inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >& CodeGeneratorRequest::proto_file() const { // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file) - return proto_file_; + return _impl_.proto_file_; } // optional .google.protobuf.compiler.Version compiler_version = 3; inline bool CodeGeneratorRequest::_internal_has_compiler_version() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || compiler_version_ != nullptr); + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || _impl_.compiler_version_ != nullptr); return value; } inline bool CodeGeneratorRequest::has_compiler_version() const { return _internal_has_compiler_version(); } inline void CodeGeneratorRequest::clear_compiler_version() { - if (compiler_version_ != nullptr) compiler_version_->Clear(); - _has_bits_[0] &= ~0x00000002u; + if (_impl_.compiler_version_ != nullptr) _impl_.compiler_version_->Clear(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const ::PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::_internal_compiler_version() const { - const ::PROTOBUF_NAMESPACE_ID::compiler::Version* p = compiler_version_; + const ::PROTOBUF_NAMESPACE_ID::compiler::Version* p = _impl_.compiler_version_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::compiler::Version&>( ::PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_); } @@ -1373,20 +1370,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::c inline void CodeGeneratorRequest::unsafe_arena_set_allocated_compiler_version( ::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(compiler_version_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.compiler_version_); } - compiler_version_ = compiler_version; + _impl_.compiler_version_ = compiler_version; if (compiler_version) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) } inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::release_compiler_version() { - _has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::compiler::Version* temp = compiler_version_; - compiler_version_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000002u; + ::PROTOBUF_NAMESPACE_ID::compiler::Version* temp = _impl_.compiler_version_; + _impl_.compiler_version_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -1400,18 +1397,18 @@ inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::release } inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::unsafe_arena_release_compiler_version() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) - _has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::compiler::Version* temp = compiler_version_; - compiler_version_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000002u; + ::PROTOBUF_NAMESPACE_ID::compiler::Version* temp = _impl_.compiler_version_; + _impl_.compiler_version_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::_internal_mutable_compiler_version() { - _has_bits_[0] |= 0x00000002u; - if (compiler_version_ == nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.compiler_version_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::Version>(GetArenaForAllocation()); - compiler_version_ = p; + _impl_.compiler_version_ = p; } - return compiler_version_; + return _impl_.compiler_version_; } inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() { ::PROTOBUF_NAMESPACE_ID::compiler::Version* _msg = _internal_mutable_compiler_version(); @@ -1421,20 +1418,20 @@ inline ::PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::mutable inline void CodeGeneratorRequest::set_allocated_compiler_version(::PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete compiler_version_; + delete _impl_.compiler_version_; } if (compiler_version) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::compiler::Version>::GetOwningArena(compiler_version); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(compiler_version); if (message_arena != submessage_arena) { compiler_version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, compiler_version, submessage_arena); } - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - compiler_version_ = compiler_version; + _impl_.compiler_version_ = compiler_version; // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) } @@ -1444,15 +1441,15 @@ inline void CodeGeneratorRequest::set_allocated_compiler_version(::PROTOBUF_NAME // optional string name = 1; inline bool CodeGeneratorResponse_File::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool CodeGeneratorResponse_File::has_name() const { return _internal_has_name(); } inline void CodeGeneratorResponse_File::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.name_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& CodeGeneratorResponse_File::name() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name) @@ -1461,8 +1458,8 @@ inline const std::string& CodeGeneratorResponse_File::name() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) } inline std::string* CodeGeneratorResponse_File::mutable_name() { @@ -1471,41 +1468,40 @@ inline std::string* CodeGeneratorResponse_File::mutable_name() { return _s; } inline const std::string& CodeGeneratorResponse_File::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void CodeGeneratorResponse_File::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse_File::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse_File::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name) if (!_internal_has_name()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void CodeGeneratorResponse_File::set_allocated_name(std::string* name) { if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) @@ -1513,15 +1509,15 @@ inline void CodeGeneratorResponse_File::set_allocated_name(std::string* name) { // optional string insertion_point = 2; inline bool CodeGeneratorResponse_File::_internal_has_insertion_point() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool CodeGeneratorResponse_File::has_insertion_point() const { return _internal_has_insertion_point(); } inline void CodeGeneratorResponse_File::clear_insertion_point() { - insertion_point_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; + _impl_.insertion_point_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const std::string& CodeGeneratorResponse_File::insertion_point() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) @@ -1530,8 +1526,8 @@ inline const std::string& CodeGeneratorResponse_File::insertion_point() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000002u; - insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.insertion_point_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } inline std::string* CodeGeneratorResponse_File::mutable_insertion_point() { @@ -1540,41 +1536,40 @@ inline std::string* CodeGeneratorResponse_File::mutable_insertion_point() { return _s; } inline const std::string& CodeGeneratorResponse_File::_internal_insertion_point() const { - return insertion_point_.Get(); + return _impl_.insertion_point_.Get(); } inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.insertion_point_.Set(value, GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse_File::_internal_mutable_insertion_point() { - _has_bits_[0] |= 0x00000002u; - return insertion_point_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.insertion_point_.Mutable(GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse_File::release_insertion_point() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) if (!_internal_has_insertion_point()) { return nullptr; } - _has_bits_[0] &= ~0x00000002u; - auto* p = insertion_point_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.insertion_point_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (insertion_point_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.insertion_point_.IsDefault()) { + _impl_.insertion_point_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::string* insertion_point) { if (insertion_point != nullptr) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - insertion_point_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), insertion_point, - GetArenaForAllocation()); + _impl_.insertion_point_.SetAllocated(insertion_point, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (insertion_point_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - insertion_point_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.insertion_point_.IsDefault()) { + _impl_.insertion_point_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) @@ -1582,15 +1577,15 @@ inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::strin // optional string content = 15; inline bool CodeGeneratorResponse_File::_internal_has_content() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool CodeGeneratorResponse_File::has_content() const { return _internal_has_content(); } inline void CodeGeneratorResponse_File::clear_content() { - content_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000004u; + _impl_.content_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; } inline const std::string& CodeGeneratorResponse_File::content() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content) @@ -1599,8 +1594,8 @@ inline const std::string& CodeGeneratorResponse_File::content() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000004u; - content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.content_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) } inline std::string* CodeGeneratorResponse_File::mutable_content() { @@ -1609,41 +1604,40 @@ inline std::string* CodeGeneratorResponse_File::mutable_content() { return _s; } inline const std::string& CodeGeneratorResponse_File::_internal_content() const { - return content_.Get(); + return _impl_.content_.Get(); } inline void CodeGeneratorResponse_File::_internal_set_content(const std::string& value) { - _has_bits_[0] |= 0x00000004u; - content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.content_.Set(value, GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse_File::_internal_mutable_content() { - _has_bits_[0] |= 0x00000004u; - return content_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.content_.Mutable(GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse_File::release_content() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content) if (!_internal_has_content()) { return nullptr; } - _has_bits_[0] &= ~0x00000004u; - auto* p = content_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.content_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (content_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.content_.IsDefault()) { + _impl_.content_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void CodeGeneratorResponse_File::set_allocated_content(std::string* content) { if (content != nullptr) { - _has_bits_[0] |= 0x00000004u; + _impl_._has_bits_[0] |= 0x00000004u; } else { - _has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000004u; } - content_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), content, - GetArenaForAllocation()); + _impl_.content_.SetAllocated(content, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (content_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - content_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.content_.IsDefault()) { + _impl_.content_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) @@ -1651,15 +1645,15 @@ inline void CodeGeneratorResponse_File::set_allocated_content(std::string* conte // optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16; inline bool CodeGeneratorResponse_File::_internal_has_generated_code_info() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; - PROTOBUF_ASSUME(!value || generated_code_info_ != nullptr); + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + PROTOBUF_ASSUME(!value || _impl_.generated_code_info_ != nullptr); return value; } inline bool CodeGeneratorResponse_File::has_generated_code_info() const { return _internal_has_generated_code_info(); } inline const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& CodeGeneratorResponse_File::_internal_generated_code_info() const { - const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* p = generated_code_info_; + const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* p = _impl_.generated_code_info_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo&>( ::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_); } @@ -1670,20 +1664,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo& CodeGeneratorResponse_F inline void CodeGeneratorResponse_File::unsafe_arena_set_allocated_generated_code_info( ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.generated_code_info_); } - generated_code_info_ = generated_code_info; + _impl_.generated_code_info_ = generated_code_info; if (generated_code_info) { - _has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000008u; } else { - _has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000008u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info) } inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::release_generated_code_info() { - _has_bits_[0] &= ~0x00000008u; - ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = generated_code_info_; - generated_code_info_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000008u; + ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = _impl_.generated_code_info_; + _impl_.generated_code_info_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -1697,18 +1691,18 @@ inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::r } inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::unsafe_arena_release_generated_code_info() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info) - _has_bits_[0] &= ~0x00000008u; - ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = generated_code_info_; - generated_code_info_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000008u; + ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* temp = _impl_.generated_code_info_; + _impl_.generated_code_info_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::_internal_mutable_generated_code_info() { - _has_bits_[0] |= 0x00000008u; - if (generated_code_info_ == nullptr) { + _impl_._has_bits_[0] |= 0x00000008u; + if (_impl_.generated_code_info_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo>(GetArenaForAllocation()); - generated_code_info_ = p; + _impl_.generated_code_info_ = p; } - return generated_code_info_; + return _impl_.generated_code_info_; } inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::mutable_generated_code_info() { ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* _msg = _internal_mutable_generated_code_info(); @@ -1718,22 +1712,21 @@ inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* CodeGeneratorResponse_File::m inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info_); + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.generated_code_info_); } if (generated_code_info) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper< - ::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena( + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(generated_code_info)); if (message_arena != submessage_arena) { generated_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, generated_code_info, submessage_arena); } - _has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000008u; } else { - _has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000008u; } - generated_code_info_ = generated_code_info; + _impl_.generated_code_info_ = generated_code_info; // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info) } @@ -1743,15 +1736,15 @@ inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(::PROT // optional string error = 1; inline bool CodeGeneratorResponse::_internal_has_error() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool CodeGeneratorResponse::has_error() const { return _internal_has_error(); } inline void CodeGeneratorResponse::clear_error() { - error_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.error_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& CodeGeneratorResponse::error() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error) @@ -1760,8 +1753,8 @@ inline const std::string& CodeGeneratorResponse::error() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.error_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) } inline std::string* CodeGeneratorResponse::mutable_error() { @@ -1770,41 +1763,40 @@ inline std::string* CodeGeneratorResponse::mutable_error() { return _s; } inline const std::string& CodeGeneratorResponse::_internal_error() const { - return error_.Get(); + return _impl_.error_.Get(); } inline void CodeGeneratorResponse::_internal_set_error(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.error_.Set(value, GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse::_internal_mutable_error() { - _has_bits_[0] |= 0x00000001u; - return error_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.error_.Mutable(GetArenaForAllocation()); } inline std::string* CodeGeneratorResponse::release_error() { // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error) if (!_internal_has_error()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = error_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.error_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (error_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.error_.IsDefault()) { + _impl_.error_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void CodeGeneratorResponse::set_allocated_error(std::string* error) { if (error != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - error_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), error, - GetArenaForAllocation()); + _impl_.error_.SetAllocated(error, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (error_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - error_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.error_.IsDefault()) { + _impl_.error_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error) @@ -1812,26 +1804,26 @@ inline void CodeGeneratorResponse::set_allocated_error(std::string* error) { // optional uint64 supported_features = 2; inline bool CodeGeneratorResponse::_internal_has_supported_features() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool CodeGeneratorResponse::has_supported_features() const { return _internal_has_supported_features(); } inline void CodeGeneratorResponse::clear_supported_features() { - supported_features_ = uint64_t{0u}; - _has_bits_[0] &= ~0x00000002u; + _impl_.supported_features_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000002u; } inline uint64_t CodeGeneratorResponse::_internal_supported_features() const { - return supported_features_; + return _impl_.supported_features_; } inline uint64_t CodeGeneratorResponse::supported_features() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.supported_features) return _internal_supported_features(); } inline void CodeGeneratorResponse::_internal_set_supported_features(uint64_t value) { - _has_bits_[0] |= 0x00000002u; - supported_features_ = value; + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.supported_features_ = value; } inline void CodeGeneratorResponse::set_supported_features(uint64_t value) { _internal_set_supported_features(value); @@ -1840,32 +1832,32 @@ inline void CodeGeneratorResponse::set_supported_features(uint64_t value) { // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; inline int CodeGeneratorResponse::_internal_file_size() const { - return file_.size(); + return _impl_.file_.size(); } inline int CodeGeneratorResponse::file_size() const { return _internal_file_size(); } inline void CodeGeneratorResponse::clear_file() { - file_.Clear(); + _impl_.file_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::mutable_file(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.file) - return file_.Mutable(index); + return _impl_.file_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >* CodeGeneratorResponse::mutable_file() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorResponse.file) - return &file_; + return &_impl_.file_; } inline const ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::_internal_file(int index) const { - return file_.Get(index); + return _impl_.file_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::file(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.file) return _internal_file(index); } inline ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::_internal_add_file() { - return file_.Add(); + return _impl_.file_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::add_file() { ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* _add = _internal_add_file(); @@ -1875,7 +1867,7 @@ inline ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGenera inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >& CodeGeneratorResponse::file() const { // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorResponse.file) - return file_; + return _impl_.file_; } #ifdef __GNUC__ diff --git a/r5dev/thirdparty/protobuf/compiler/python/python_generator.cc b/r5dev/thirdparty/protobuf/compiler/python/generator.cc similarity index 86% rename from r5dev/thirdparty/protobuf/compiler/python/python_generator.cc rename to r5dev/thirdparty/protobuf/compiler/python/generator.cc index 65a793f6..fb3ce14f 100644 --- a/r5dev/thirdparty/protobuf/compiler/python/python_generator.cc +++ b/r5dev/thirdparty/protobuf/compiler/python/generator.cc @@ -42,7 +42,7 @@ // performance-minded Python code leverage the fast C++ implementation // directly. -#include <thirdparty/protobuf/compiler/python/python_generator.h> +#include <thirdparty/protobuf/compiler/python/generator.h> #include <algorithm> #include <limits> @@ -54,13 +54,15 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> +#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/stringprintf.h> +#include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/compiler/python/helpers.h> +#include <thirdparty/protobuf/compiler/python/pyi_generator.h> +#include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> -#include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/stubs/strutil.h> -#include <thirdparty/protobuf/stubs/substitute.h> namespace google { namespace protobuf { @@ -68,16 +70,6 @@ namespace compiler { namespace python { namespace { - - -// Returns the Python module name expected for a given .proto filename. -std::string ModuleName(const std::string& filename) { - std::string basename = StripProto(filename); - ReplaceCharacters(&basename, "-", '_'); - ReplaceCharacters(&basename, "/", '.'); - return basename + "_pb2"; -} - // Returns the alias we assign to the module of the given .proto filename // when importing. See testPackageInitializationImport in // net/proto2/python/internal/reflection_test.py @@ -92,78 +84,13 @@ std::string ModuleAlias(const std::string& filename) { return module_name; } -// Keywords reserved by the Python language. -const char* const kKeywords[] = { - "False", "None", "True", "and", "as", "assert", - "async", "await", "break", "class", "continue", "def", - "del", "elif", "else", "except", "finally", "for", - "from", "global", "if", "import", "in", "is", - "lambda", "nonlocal", "not", "or", "pass", "raise", - "return", "try", "while", "with", "yield", "print", -}; -const char* const* kKeywordsEnd = - kKeywords + (sizeof(kKeywords) / sizeof(kKeywords[0])); - -bool ContainsPythonKeyword(const std::string& module_name) { - std::vector<std::string> tokens = Split(module_name, "."); - for (int i = 0; i < tokens.size(); ++i) { - if (std::find(kKeywords, kKeywordsEnd, tokens[i]) != kKeywordsEnd) { - return true; - } - } - return false; -} - -inline bool IsPythonKeyword(const std::string& name) { - return (std::find(kKeywords, kKeywordsEnd, name) != kKeywordsEnd); -} - -std::string ResolveKeyword(const std::string& name) { - if (IsPythonKeyword(name)) { - return "globals()['" + name + "']"; - } - return name; -} - -// Returns the name of all containing types for descriptor, -// in order from outermost to innermost, followed by descriptor's -// own name. Each name is separated by |separator|. -template <typename DescriptorT> -std::string NamePrefixedWithNestedTypes(const DescriptorT& descriptor, - const std::string& separator) { - std::string name = descriptor.name(); - const Descriptor* parent = descriptor.containing_type(); - if (parent != nullptr) { - std::string prefix = NamePrefixedWithNestedTypes(*parent, separator); - if (separator == "." && IsPythonKeyword(name)) { - return "getattr(" + prefix + ", '" + name + "')"; - } else { - return prefix + separator + name; - } - } - if (separator == ".") { - name = ResolveKeyword(name); - } - return name; -} - // Name of the class attribute where we store the Python // descriptor.Descriptor instance for the generated class. // Must stay consistent with the _DESCRIPTOR_KEY constant // in proto2/public/reflection.py. const char kDescriptorKey[] = "DESCRIPTOR"; -// Does the file have top-level enums? -inline bool HasTopLevelEnums(const FileDescriptor* file) { - return file->enum_type_count() > 0; -} -// Should we generate generic services for this file? -inline bool HasGenericServices(const FileDescriptor* file) { - return file->service_count() > 0 && file->options().py_generic_services(); -} - -// Prints the common boilerplate needed at the top of every .py // file output by this generator. void PrintTopBoilerplate(io::Printer* printer, const FileDescriptor* file, bool descriptor_proto) { @@ -174,27 +101,16 @@ void PrintTopBoilerplate(io::Printer* printer, const FileDescriptor* file, "# source: $filename$\n" "\"\"\"Generated protocol buffer code.\"\"\"\n", "filename", file->name()); - if (HasTopLevelEnums(file)) { - printer->Print( - "from google.protobuf.internal import enum_type_wrapper\n"); - } printer->Print( + "from google.protobuf.internal import builder as _builder\n" "from google.protobuf import descriptor as _descriptor\n" "from google.protobuf import descriptor_pool as " "_descriptor_pool\n" - "from google.protobuf import message as _message\n" - "from google.protobuf import reflection as _reflection\n" "from google.protobuf import symbol_database as " "_symbol_database\n"); - if (HasGenericServices(file)) { - printer->Print( - "from google.protobuf import service as _service\n" - "from google.protobuf import service_reflection\n"); - } - printer->Print( - "# @@protoc_insertion_point(imports)\n\n" - "_sym_db = _symbol_database.Default()\n"); + printer->Print("# @@protoc_insertion_point(imports)\n\n"); + printer->Print("_sym_db = _symbol_database.Default()\n"); printer->Print("\n\n"); } @@ -309,6 +225,11 @@ bool Generator::Generate(const FileDescriptor* file, for (int i = 0; i < options.size(); i++) { if (options[i].first == "cpp_generated_lib_linked") { cpp_generated_lib_linked = true; + } else if (options[i].first == "pyi_out") { + python::PyiGenerator pyi_generator; + if (!pyi_generator.Generate(file, "", context, error)) { + return false; + } } else { *error = "Unknown generator option: " + options[i].first; return false; @@ -324,11 +245,8 @@ bool Generator::Generate(const FileDescriptor* file, // to have any mutable members. Then it is implicitly thread-safe. MutexLock lock(&mutex_); file_ = file; - std::string module_name = ModuleName(file->name()); - std::string filename = module_name; - ReplaceCharacters(&filename, ".", '/'); - filename += ".py"; + std::string filename = GetFileName(file, ".py"); pure_python_workable_ = !cpp_generated_lib_linked; if (HasPrefixString(file->name(), "google/protobuf/")) { pure_python_workable_ = true; @@ -349,15 +267,13 @@ bool Generator::Generate(const FileDescriptor* file, PrintImports(); } PrintFileDescriptor(); - PrintTopLevelEnums(); - PrintTopLevelExtensions(); if (pure_python_workable_) { if (GeneratingDescriptorProto()) { printer_->Print("if _descriptor._USE_C_DESCRIPTORS == False:\n"); printer_->Indent(); // Create enums before message descriptors - PrintAllNestedEnumsInFile(StripPrintDescriptor::kCreate); - PrintMessageDescriptors(StripPrintDescriptor::kCreate); + PrintAllNestedEnumsInFile(); + PrintMessageDescriptors(); FixForeignFieldsInDescriptors(); printer_->Outdent(); printer_->Print("else:\n"); @@ -365,16 +281,18 @@ bool Generator::Generate(const FileDescriptor* file, } // Find the message descriptors first and then use the message // descriptor to find enums. - PrintMessageDescriptors(StripPrintDescriptor::kFind); - PrintAllNestedEnumsInFile(StripPrintDescriptor::kFind); + printer_->Print( + "_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())\n"); if (GeneratingDescriptorProto()) { printer_->Outdent(); } } - PrintMessages(); + std::string module_name = ModuleName(file->name()); + printer_->Print( + "_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, '$module_name$', " + "globals())\n", + "module_name", module_name); if (pure_python_workable_) { - PrintServiceDescriptors(); - printer.Print("if _descriptor._USE_C_DESCRIPTORS == False:\n"); printer_->Indent(); @@ -395,7 +313,9 @@ bool Generator::Generate(const FileDescriptor* file, printer_->Outdent(); } if (HasGenericServices(file)) { - PrintServices(); + printer_->Print( + "_builder.BuildServices(DESCRIPTOR, '$module_name$', globals())\n", + "module_name", module_name); } printer.Print("# @@protoc_insertion_point(module_scope)\n"); @@ -403,7 +323,6 @@ bool Generator::Generate(const FileDescriptor* file, return !printer.failed(); } - // Prints Python imports for all modules imported by |file|. void Generator::PrintImports() const { for (int i = 0; i < file_->dependency_count(); ++i) { @@ -516,47 +435,17 @@ void Generator::PrintFileDescriptor() const { printer_->Print("\n"); } -// Prints descriptors and module-level constants for all top-level -// enums defined in |file|. -void Generator::PrintTopLevelEnums() const { - std::vector<std::pair<std::string, int> > top_level_enum_values; - for (int i = 0; i < file_->enum_type_count(); ++i) { - const EnumDescriptor& enum_descriptor = *file_->enum_type(i); - PrintFindEnum(enum_descriptor); - printer_->Print( - "$name$ = " - "enum_type_wrapper.EnumTypeWrapper($descriptor_name$)", - "name", ResolveKeyword(enum_descriptor.name()), "descriptor_name", - ModuleLevelDescriptorName(enum_descriptor)); - printer_->Print("\n"); - - for (int j = 0; j < enum_descriptor.value_count(); ++j) { - const EnumValueDescriptor& value_descriptor = *enum_descriptor.value(j); - top_level_enum_values.push_back( - std::make_pair(value_descriptor.name(), value_descriptor.number())); - } - } - - for (int i = 0; i < top_level_enum_values.size(); ++i) { - printer_->Print("$name$ = $value$\n", "name", - ResolveKeyword(top_level_enum_values[i].first), "value", - StrCat(top_level_enum_values[i].second)); - } - printer_->Print("\n"); -} - // Prints all enums contained in all message types in |file|. -void Generator::PrintAllNestedEnumsInFile( - StripPrintDescriptor print_mode) const { +void Generator::PrintAllNestedEnumsInFile() const { for (int i = 0; i < file_->message_type_count(); ++i) { - PrintNestedEnums(*file_->message_type(i), print_mode); + PrintNestedEnums(*file_->message_type(i)); } } // Prints a Python statement assigning the appropriate module-level // enum name to a Python EnumDescriptor object equivalent to // enum_descriptor. -void Generator::PrintCreateEnum(const EnumDescriptor& enum_descriptor) const { +void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const { std::map<std::string, std::string> m; std::string module_level_descriptor_name = ModuleLevelDescriptorName(enum_descriptor); @@ -600,68 +489,23 @@ void Generator::PrintCreateEnum(const EnumDescriptor& enum_descriptor) const { printer_->Print("\n"); } -void Generator::PrintFindEnum(const EnumDescriptor& enum_descriptor) const { - std::map<std::string, std::string> m; - m["descriptor_name"] = ModuleLevelDescriptorName(enum_descriptor); - m["name"] = enum_descriptor.name(); - m["file"] = kDescriptorKey; - if (enum_descriptor.containing_type()) { - m["containing_type"] = - ModuleLevelDescriptorName(*enum_descriptor.containing_type()); - printer_->Print(m, - "$descriptor_name$ = " - "$containing_type$.enum_types_by_name['$name$']\n"); - } else { - printer_->Print( - m, "$descriptor_name$ = $file$.enum_types_by_name['$name$']\n"); - } -} - // Recursively prints enums in nested types within descriptor, then // prints enums contained at the top level in descriptor. -void Generator::PrintNestedEnums(const Descriptor& descriptor, - StripPrintDescriptor print_mode) const { +void Generator::PrintNestedEnums(const Descriptor& descriptor) const { for (int i = 0; i < descriptor.nested_type_count(); ++i) { - PrintNestedEnums(*descriptor.nested_type(i), print_mode); + PrintNestedEnums(*descriptor.nested_type(i)); } for (int i = 0; i < descriptor.enum_type_count(); ++i) { - if (print_mode == StripPrintDescriptor::kCreate) { - PrintCreateEnum(*descriptor.enum_type(i)); - } else { - PrintFindEnum(*descriptor.enum_type(i)); - } + PrintEnum(*descriptor.enum_type(i)); } } -void Generator::PrintTopLevelExtensions() const { - for (int i = 0; i < file_->extension_count(); ++i) { - const FieldDescriptor& extension_field = *file_->extension(i); - std::string constant_name = extension_field.name() + "_FIELD_NUMBER"; - ToUpper(&constant_name); - printer_->Print("$constant_name$ = $number$\n", "constant_name", - constant_name, "number", - StrCat(extension_field.number())); - printer_->Print( - "$resolved_name$ = " - "$file$.extensions_by_name['$name$']\n", - "resolved_name", ResolveKeyword(extension_field.name()), "file", - kDescriptorKey, "name", extension_field.name()); - } - printer_->Print("\n"); -} - // Prints Python equivalents of all Descriptors in |file|. -void Generator::PrintMessageDescriptors(StripPrintDescriptor print_mode) const { - if (print_mode == StripPrintDescriptor::kCreate) { - for (int i = 0; i < file_->message_type_count(); ++i) { - PrintCreateDescriptor(*file_->message_type(i)); - printer_->Print("\n"); - } - } else { - for (int i = 0; i < file_->message_type_count(); ++i) { - PrintFindDescriptor(*file_->message_type(i)); - } +void Generator::PrintMessageDescriptors() const { + for (int i = 0; i < file_->message_type_count(); ++i) { + PrintDescriptor(*file_->message_type(i)); + printer_->Print("\n"); } } @@ -730,14 +574,13 @@ void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const { // to a Python Descriptor object for message_descriptor. // // Mutually recursive with PrintNestedDescriptors(). -void Generator::PrintCreateDescriptor( - const Descriptor& message_descriptor) const { +void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { std::map<std::string, std::string> m; m["name"] = message_descriptor.name(); m["full_name"] = message_descriptor.full_name(); m["file"] = kDescriptorKey; - PrintNestedDescriptors(message_descriptor, StripPrintDescriptor::kCreate); + PrintNestedDescriptors(message_descriptor); printer_->Print("\n"); printer_->Print("$descriptor_name$ = _descriptor.Descriptor(\n", @@ -823,41 +666,14 @@ void Generator::PrintCreateDescriptor( printer_->Print(")\n"); } -void Generator::PrintFindDescriptor( - const Descriptor& message_descriptor) const { - std::map<std::string, std::string> m; - m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor); - m["name"] = message_descriptor.name(); - - if (message_descriptor.containing_type()) { - m["containing_type"] = - ModuleLevelDescriptorName(*message_descriptor.containing_type()); - printer_->Print(m, - "$descriptor_name$ = " - "$containing_type$.nested_types_by_name['$name$']\n"); - } else { - m["file"] = kDescriptorKey; - printer_->Print( - m, "$descriptor_name$ = $file$.message_types_by_name['$name$']\n"); - } - - PrintNestedDescriptors(message_descriptor, StripPrintDescriptor::kFind); -} - // Prints Python Descriptor objects for all nested types contained in // message_descriptor. // // Mutually recursive with PrintDescriptor(). -void Generator::PrintNestedDescriptors(const Descriptor& containing_descriptor, - StripPrintDescriptor print_mode) const { - if (print_mode == StripPrintDescriptor::kCreate) { - for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) { - PrintCreateDescriptor(*containing_descriptor.nested_type(i)); - } - } else { - for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) { - PrintFindDescriptor(*containing_descriptor.nested_type(i)); - } +void Generator::PrintNestedDescriptors( + const Descriptor& containing_descriptor) const { + for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) { + PrintDescriptor(*containing_descriptor.nested_type(i)); } } @@ -1463,7 +1279,7 @@ void Generator::FixOptionsForEnum(const EnumDescriptor& enum_descriptor) const { if (value_options != "None") { PrintDescriptorOptionsFixingCode( StringPrintf("%s.values_by_name[\"%s\"]", descriptor_name.c_str(), - value_descriptor.name().c_str()), + value_descriptor.name().c_str()), value_options, printer_); } } diff --git a/r5dev/thirdparty/protobuf/compiler/python/generator.h b/r5dev/thirdparty/protobuf/compiler/python/generator.h new file mode 100644 index 00000000..21cbc4b6 --- /dev/null +++ b/r5dev/thirdparty/protobuf/compiler/python/generator.h @@ -0,0 +1,185 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Author: robinson@google.com (Will Robinson) +// +// Generates Python code for a given .proto file. + +#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ +#define GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ + +#include <string> + +#include <thirdparty/protobuf/stubs/mutex.h> +#include <thirdparty/protobuf/compiler/code_generator.h> + +// Must be included last. +#include <thirdparty/protobuf/port_def.inc> + +namespace google { +namespace protobuf { + +class Descriptor; +class EnumDescriptor; +class EnumValueDescriptor; +class FieldDescriptor; +class OneofDescriptor; +class ServiceDescriptor; + +namespace io { +class Printer; +} + +namespace compiler { +namespace python { + +// CodeGenerator implementation for generated Python protocol buffer classes. +// If you create your own protocol compiler binary and you want it to support +// Python output, you can do so by registering an instance of this +// CodeGenerator with the CommandLineInterface in your main() function. +class PROTOC_EXPORT Generator : public CodeGenerator { + public: + Generator(); + ~Generator() override; + + // CodeGenerator methods. + bool Generate(const FileDescriptor* file, const std::string& parameter, + GeneratorContext* generator_context, + std::string* error) const override; + + uint64_t GetSupportedFeatures() const override; + + private: + void PrintImports() const; + void PrintFileDescriptor() const; + void PrintAllNestedEnumsInFile() const; + void PrintNestedEnums(const Descriptor& descriptor) const; + void PrintEnum(const EnumDescriptor& enum_descriptor) const; + + void PrintFieldDescriptor(const FieldDescriptor& field, + bool is_extension) const; + void PrintFieldDescriptorsInDescriptor( + const Descriptor& message_descriptor, bool is_extension, + const std::string& list_variable_name, int (Descriptor::*CountFn)() const, + const FieldDescriptor* (Descriptor::*GetterFn)(int)const) const; + void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const; + void PrintExtensionsInDescriptor(const Descriptor& message_descriptor) const; + void PrintMessageDescriptors() const; + void PrintDescriptor(const Descriptor& message_descriptor) const; + void PrintNestedDescriptors(const Descriptor& containing_descriptor) const; + + void PrintMessages() const; + void PrintMessage(const Descriptor& message_descriptor, + const std::string& prefix, + std::vector<std::string>* to_register, + bool is_nested) const; + void PrintNestedMessages(const Descriptor& containing_descriptor, + const std::string& prefix, + std::vector<std::string>* to_register) const; + + void FixForeignFieldsInDescriptors() const; + void FixForeignFieldsInDescriptor( + const Descriptor& descriptor, + const Descriptor* containing_descriptor) const; + void FixForeignFieldsInField(const Descriptor* containing_type, + const FieldDescriptor& field, + const std::string& python_dict_name) const; + void AddMessageToFileDescriptor(const Descriptor& descriptor) const; + void AddEnumToFileDescriptor(const EnumDescriptor& descriptor) const; + void AddExtensionToFileDescriptor(const FieldDescriptor& descriptor) const; + void AddServiceToFileDescriptor(const ServiceDescriptor& descriptor) const; + std::string FieldReferencingExpression( + const Descriptor* containing_type, const FieldDescriptor& field, + const std::string& python_dict_name) const; + template <typename DescriptorT> + void FixContainingTypeInDescriptor( + const DescriptorT& descriptor, + const Descriptor* containing_descriptor) const; + + void FixForeignFieldsInExtensions() const; + void FixForeignFieldsInExtension( + const FieldDescriptor& extension_field) const; + void FixForeignFieldsInNestedExtensions(const Descriptor& descriptor) const; + + void PrintServices() const; + void PrintServiceDescriptors() const; + void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const; + void PrintServiceClass(const ServiceDescriptor& descriptor) const; + void PrintServiceStub(const ServiceDescriptor& descriptor) const; + void PrintDescriptorKeyAndModuleName( + const ServiceDescriptor& descriptor) const; + + void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const; + std::string OptionsValue(const std::string& serialized_options) const; + bool GeneratingDescriptorProto() const; + + template <typename DescriptorT> + std::string ModuleLevelDescriptorName(const DescriptorT& descriptor) const; + std::string ModuleLevelMessageName(const Descriptor& descriptor) const; + std::string ModuleLevelServiceDescriptorName( + const ServiceDescriptor& descriptor) const; + + template <typename DescriptorT, typename DescriptorProtoT> + void PrintSerializedPbInterval(const DescriptorT& descriptor, + DescriptorProtoT& proto, + const std::string& name) const; + + void FixAllDescriptorOptions() const; + void FixOptionsForField(const FieldDescriptor& field) const; + void FixOptionsForOneof(const OneofDescriptor& oneof) const; + void FixOptionsForEnum(const EnumDescriptor& descriptor) const; + void FixOptionsForService(const ServiceDescriptor& descriptor) const; + void FixOptionsForMessage(const Descriptor& descriptor) const; + + void SetSerializedPbInterval() const; + void SetMessagePbInterval(const Descriptor& descriptor) const; + + void CopyPublicDependenciesAliases(const std::string& copy_from, + const FileDescriptor* file) const; + + // Very coarse-grained lock to ensure that Generate() is reentrant. + // Guards file_, printer_ and file_descriptor_serialized_. + mutable Mutex mutex_; + mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_. + mutable std::string file_descriptor_serialized_; + mutable io::Printer* printer_; // Set in Generate(). Under mutex_. + mutable bool pure_python_workable_; + + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator); +}; + +} // namespace python +} // namespace compiler +} // namespace protobuf +} // namespace google + +#include <thirdparty/protobuf/port_undef.inc> + +#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ diff --git a/r5dev/thirdparty/protobuf/compiler/python/helpers.cc b/r5dev/thirdparty/protobuf/compiler/python/helpers.cc new file mode 100644 index 00000000..9bd4ba68 --- /dev/null +++ b/r5dev/thirdparty/protobuf/compiler/python/helpers.cc @@ -0,0 +1,131 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <thirdparty/protobuf/compiler/python/helpers.h> + +#include <algorithm> + +#include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/code_generator.h> +#include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/descriptor.pb.h> + +namespace google { +namespace protobuf { +namespace compiler { +namespace python { + +// Returns the Python module name expected for a given .proto filename. +std::string ModuleName(const std::string& filename) { + std::string basename = StripProto(filename); + ReplaceCharacters(&basename, "-", '_'); + ReplaceCharacters(&basename, "/", '.'); + return basename + "_pb2"; +} + +std::string StrippedModuleName(const std::string& filename) { + std::string module_name = ModuleName(filename); + return module_name; +} + +// Keywords reserved by the Python language. +const char* const kKeywords[] = { + "False", "None", "True", "and", "as", "assert", + "async", "await", "break", "class", "continue", "def", + "del", "elif", "else", "except", "finally", "for", + "from", "global", "if", "import", "in", "is", + "lambda", "nonlocal", "not", "or", "pass", "raise", + "return", "try", "while", "with", "yield", +}; +const char* const* kKeywordsEnd = + kKeywords + (sizeof(kKeywords) / sizeof(kKeywords[0])); + +bool ContainsPythonKeyword(const std::string& module_name) { + std::vector<std::string> tokens = Split(module_name, "."); + for (int i = 0; i < static_cast<int>(tokens.size()); ++i) { + if (std::find(kKeywords, kKeywordsEnd, tokens[i]) != kKeywordsEnd) { + return true; + } + } + return false; +} + +bool IsPythonKeyword(const std::string& name) { + return (std::find(kKeywords, kKeywordsEnd, name) != kKeywordsEnd); +} + +std::string ResolveKeyword(const std::string& name) { + if (IsPythonKeyword(name)) { + return "globals()['" + name + "']"; + } + return name; +} + +std::string GetFileName(const FileDescriptor* file_des, + const std::string& suffix) { + std::string module_name = ModuleName(file_des->name()); + std::string filename = module_name; + ReplaceCharacters(&filename, ".", '/'); + filename += suffix; + return filename; +} + +bool HasGenericServices(const FileDescriptor* file) { + return file->service_count() > 0 && file->options().py_generic_services(); +} + +template <typename DescriptorT> +std::string NamePrefixedWithNestedTypes(const DescriptorT& descriptor, + const std::string& separator) { + std::string name = descriptor.name(); + const Descriptor* parent = descriptor.containing_type(); + if (parent != nullptr) { + std::string prefix = NamePrefixedWithNestedTypes(*parent, separator); + if (separator == "." && IsPythonKeyword(name)) { + return "getattr(" + prefix + ", '" + name + "')"; + } else { + return prefix + separator + name; + } + } + if (separator == ".") { + name = ResolveKeyword(name); + } + return name; +} + +template std::string NamePrefixedWithNestedTypes<Descriptor>( + const Descriptor& descriptor, const std::string& separator); +template std::string NamePrefixedWithNestedTypes<EnumDescriptor>( + const EnumDescriptor& descriptor, const std::string& separator); + +} // namespace python +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/r5dev/thirdparty/protobuf/compiler/js/well_known_types_embed.h b/r5dev/thirdparty/protobuf/compiler/python/helpers.h similarity index 63% rename from r5dev/thirdparty/protobuf/compiler/js/well_known_types_embed.h rename to r5dev/thirdparty/protobuf/compiler/python/helpers.h index 174c665e..9ad5bf6b 100644 --- a/r5dev/thirdparty/protobuf/compiler/js/well_known_types_embed.h +++ b/r5dev/thirdparty/protobuf/compiler/python/helpers.h @@ -28,16 +28,35 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__ -#define GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__ +#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_HELPERS_H__ +#define GOOGLE_PROTOBUF_COMPILER_PYTHON_HELPERS_H__ -#include <stddef.h> +#include <string> -struct FileToc { - const char* name; - const char* data; -}; +#include <thirdparty/protobuf/descriptor.h> -extern struct FileToc well_known_types_js[]; +namespace google { +namespace protobuf { +namespace compiler { +namespace python { -#endif // GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__ + +std::string ModuleName(const std::string& filename); +std::string StrippedModuleName(const std::string& filename); +bool ContainsPythonKeyword(const std::string& module_name); +bool IsPythonKeyword(const std::string& name); +std::string ResolveKeyword(const std::string& name); +std::string GetFileName(const FileDescriptor* file_des, + const std::string& suffix); +bool HasGenericServices(const FileDescriptor* file); + +template <typename DescriptorT> +std::string NamePrefixedWithNestedTypes(const DescriptorT& descriptor, + const std::string& separator); + +} // namespace python +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_HELPERS_H__ diff --git a/r5dev/thirdparty/protobuf/compiler/python/python_plugin_unittest.cc b/r5dev/thirdparty/protobuf/compiler/python/plugin_unittest.cc similarity index 74% rename from r5dev/thirdparty/protobuf/compiler/python/python_plugin_unittest.cc rename to r5dev/thirdparty/protobuf/compiler/python/plugin_unittest.cc index 4f3b1286..24cbc57b 100644 --- a/r5dev/thirdparty/protobuf/compiler/python/python_plugin_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/python/plugin_unittest.cc @@ -29,17 +29,14 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Author: kenton@google.com (Kenton Varda) -// -// TODO(kenton): Share code with the versions of this test in other languages? -// It seemed like parameterizing it would add more complexity than it is -// worth. #include <memory> +#include <string> #include <thirdparty/protobuf/testing/file.h> #include <thirdparty/protobuf/testing/file.h> #include <thirdparty/protobuf/compiler/command_line_interface.h> -#include <thirdparty/protobuf/compiler/python/python_generator.h> +#include <thirdparty/protobuf/compiler/python/generator.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/stubs/strutil.h> @@ -55,11 +52,10 @@ namespace { class TestGenerator : public CodeGenerator { public: TestGenerator() {} - ~TestGenerator() {} + ~TestGenerator() override {} - virtual bool Generate(const FileDescriptor* file, - const std::string& parameter, GeneratorContext* context, - std::string* error) const { + bool Generate(const FileDescriptor* file, const std::string& parameter, + GeneratorContext* context, std::string* error) const override { TryInsert("test_pb2.py", "imports", context); TryInsert("test_pb2.py", "module_scope", context); TryInsert("test_pb2.py", "class_scope:foo.Bar", context); @@ -77,37 +73,6 @@ class TestGenerator : public CodeGenerator { } }; -// This test verifies that all the expected insertion points exist. It does -// not verify that they are correctly-placed; that would require actually -// compiling the output which is a bit more than I care to do for this test. -TEST(PythonPluginTest, PluginTest) { - GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + "/test.proto", - "syntax = \"proto2\";\n" - "package foo;\n" - "message Bar {\n" - " message Baz {}\n" - "}\n", - true)); - - compiler::CommandLineInterface cli; - cli.SetInputsAreProtoPathRelative(true); - - python::Generator python_generator; - TestGenerator test_generator; - cli.RegisterGenerator("--python_out", &python_generator, ""); - cli.RegisterGenerator("--test_out", &test_generator, ""); - - std::string proto_path = "-I" + TestTempDir(); - std::string python_out = "--python_out=" + TestTempDir(); - std::string test_out = "--test_out=" + TestTempDir(); - - const char* argv[] = {"protoc", proto_path.c_str(), python_out.c_str(), - test_out.c_str(), "test.proto"}; - - EXPECT_EQ(0, cli.Run(5, argv)); -} - -// This test verifies that the generated Python output uses regular imports (as // opposed to importlib) in the usual case where the .proto file paths do not // not contain any Python keywords. TEST(PythonPluginTest, ImportTest) { diff --git a/r5dev/thirdparty/protobuf/compiler/python/pyi_generator.cc b/r5dev/thirdparty/protobuf/compiler/python/pyi_generator.cc new file mode 100644 index 00000000..b3f71694 --- /dev/null +++ b/r5dev/thirdparty/protobuf/compiler/python/pyi_generator.cc @@ -0,0 +1,636 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <thirdparty/protobuf/compiler/python/pyi_generator.h> + +#include <string> + +#include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/compiler/python/helpers.h> +#include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/descriptor.pb.h> +#include <thirdparty/protobuf/io/printer.h> +#include <thirdparty/protobuf/io/zero_copy_stream.h> + +namespace google { +namespace protobuf { +namespace compiler { +namespace python { + +template <typename DescriptorT> +struct SortByName { + bool operator()(const DescriptorT* l, const DescriptorT* r) const { + return l->name() < r->name(); + } +}; + +PyiGenerator::PyiGenerator() : file_(nullptr) {} + +PyiGenerator::~PyiGenerator() {} + +void PyiGenerator::PrintItemMap( + const std::map<std::string, std::string>& item_map) const { + for (const auto& entry : item_map) { + printer_->Print("$key$: $value$\n", "key", entry.first, "value", + entry.second); + } +} + +template <typename DescriptorT> +std::string PyiGenerator::ModuleLevelName( + const DescriptorT& descriptor, + const std::map<std::string, std::string>& import_map) const { + std::string name = NamePrefixedWithNestedTypes(descriptor, "."); + if (descriptor.file() != file_) { + std::string module_alias; + std::string filename = descriptor.file()->name(); + if (import_map.find(filename) == import_map.end()) { + std::string module_name = ModuleName(descriptor.file()->name()); + std::vector<std::string> tokens = Split(module_name, "."); + module_alias = "_" + tokens.back(); + } else { + module_alias = import_map.at(filename); + } + name = module_alias + "." + name; + } + return name; +} + +struct ImportModules { + bool has_repeated = false; // _containers + bool has_iterable = false; // typing.Iterable + bool has_messages = false; // _message + bool has_enums = false; // _enum_type_wrapper + bool has_extendable = false; // _python_message + bool has_mapping = false; // typing.Mapping + bool has_optional = false; // typing.Optional + bool has_union = false; // typing.Union + bool has_well_known_type = false; +}; + +// Checks whether a descriptor name matches a well-known type. +bool IsWellKnownType(const std::string& name) { + // LINT.IfChange(wktbases) + return (name == "google.protobuf.Any" || + name == "google.protobuf.Duration" || + name == "google.protobuf.FieldMask" || + name == "google.protobuf.ListValue" || + name == "google.protobuf.Struct" || + name == "google.protobuf.Timestamp"); + // LINT.ThenChange(//depot/google3/net/proto2/python/internal/well_known_types.py:wktbases) +} + +// Checks what modules should be imported for this message +// descriptor. +void CheckImportModules(const Descriptor* descriptor, + ImportModules* import_modules) { + if (descriptor->extension_range_count() > 0) { + import_modules->has_extendable = true; + } + if (descriptor->enum_type_count() > 0) { + import_modules->has_enums = true; + } + if (IsWellKnownType(descriptor->full_name())) { + import_modules->has_well_known_type = true; + } + for (int i = 0; i < descriptor->field_count(); ++i) { + const FieldDescriptor* field = descriptor->field(i); + if (IsPythonKeyword(field->name())) { + continue; + } + import_modules->has_optional = true; + if (field->is_repeated()) { + import_modules->has_repeated = true; + } + if (field->is_map()) { + import_modules->has_mapping = true; + const FieldDescriptor* value_des = field->message_type()->field(1); + if (value_des->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || + value_des->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { + import_modules->has_union = true; + } + } else { + if (field->is_repeated()) { + import_modules->has_iterable = true; + } + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + import_modules->has_union = true; + import_modules->has_mapping = true; + } + if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { + import_modules->has_union = true; + } + } + } + for (int i = 0; i < descriptor->nested_type_count(); ++i) { + CheckImportModules(descriptor->nested_type(i), import_modules); + } +} + +void PyiGenerator::PrintImportForDescriptor( + const FileDescriptor& desc, + std::map<std::string, std::string>* import_map, + std::set<std::string>* seen_aliases) const { + const std::string& filename = desc.name(); + std::string module_name = StrippedModuleName(filename); + size_t last_dot_pos = module_name.rfind('.'); + std::string import_statement; + if (last_dot_pos == std::string::npos) { + import_statement = "import " + module_name; + } else { + import_statement = "from " + module_name.substr(0, last_dot_pos) + + " import " + module_name.substr(last_dot_pos + 1); + module_name = module_name.substr(last_dot_pos + 1); + } + std::string alias = "_" + module_name; + // Generate a unique alias by adding _1 suffixes until we get an unused alias. + while (seen_aliases->find(alias) != seen_aliases->end()) { + alias = alias + "_1"; + } + printer_->Print("$statement$ as $alias$\n", "statement", + import_statement, "alias", alias); + (*import_map)[filename] = alias; + seen_aliases->insert(alias); +} + +void PyiGenerator::PrintImports( + std::map<std::string, std::string>* item_map, + std::map<std::string, std::string>* import_map) const { + // Prints imported dependent _pb2 files. + std::set<std::string> seen_aliases; + for (int i = 0; i < file_->dependency_count(); ++i) { + const FileDescriptor* dep = file_->dependency(i); + PrintImportForDescriptor(*dep, import_map, &seen_aliases); + for (int j = 0; j < dep->public_dependency_count(); ++j) { + PrintImportForDescriptor( + *dep->public_dependency(j), import_map, &seen_aliases); + } + } + + // Checks what modules should be imported. + ImportModules import_modules; + if (file_->message_type_count() > 0) { + import_modules.has_messages = true; + } + if (file_->enum_type_count() > 0) { + import_modules.has_enums = true; + } + for (int i = 0; i < file_->message_type_count(); i++) { + CheckImportModules(file_->message_type(i), &import_modules); + } + + // Prints modules (e.g. _containers, _messages, typing) that are + // required in the proto file. + if (import_modules.has_repeated) { + printer_->Print( + "from google.protobuf.internal import containers as " + "_containers\n"); + } + if (import_modules.has_enums) { + printer_->Print( + "from google.protobuf.internal import enum_type_wrapper" + " as _enum_type_wrapper\n"); + } + if (import_modules.has_extendable) { + printer_->Print( + "from google.protobuf.internal import python_message" + " as _python_message\n"); + } + if (import_modules.has_well_known_type) { + printer_->Print( + "from google.protobuf.internal import well_known_types" + " as _well_known_types\n"); + } + printer_->Print( + "from google.protobuf import" + " descriptor as _descriptor\n"); + if (import_modules.has_messages) { + printer_->Print( + "from google.protobuf import message as _message\n"); + } + if (HasGenericServices(file_)) { + printer_->Print( + "from google.protobuf import service as" + " _service\n"); + } + printer_->Print("from typing import "); + printer_->Print("ClassVar as _ClassVar"); + if (import_modules.has_iterable) { + printer_->Print(", Iterable as _Iterable"); + } + if (import_modules.has_mapping) { + printer_->Print(", Mapping as _Mapping"); + } + if (import_modules.has_optional) { + printer_->Print(", Optional as _Optional"); + } + if (import_modules.has_union) { + printer_->Print(", Union as _Union"); + } + printer_->Print("\n\n"); + + // Public imports + for (int i = 0; i < file_->public_dependency_count(); ++i) { + const FileDescriptor* public_dep = file_->public_dependency(i); + std::string module_name = StrippedModuleName(public_dep->name()); + // Top level messages in public imports + for (int i = 0; i < public_dep->message_type_count(); ++i) { + printer_->Print("from $module$ import $message_class$\n", "module", + module_name, "message_class", + public_dep->message_type(i)->name()); + } + // Top level enums for public imports + for (int i = 0; i < public_dep->enum_type_count(); ++i) { + printer_->Print("from $module$ import $enum_class$\n", "module", + module_name, "enum_class", + public_dep->enum_type(i)->name()); + } + // Enum values for public imports + for (int i = 0; i < public_dep->enum_type_count(); ++i) { + const EnumDescriptor* enum_descriptor = public_dep->enum_type(i); + for (int j = 0; j < enum_descriptor->value_count(); ++j) { + (*item_map)[enum_descriptor->value(j)->name()] = + ModuleLevelName(*enum_descriptor, *import_map); + } + } + // Top level extensions for public imports + AddExtensions(*public_dep, item_map); + } +} + +void PyiGenerator::PrintEnum(const EnumDescriptor& enum_descriptor) const { + std::string enum_name = enum_descriptor.name(); + printer_->Print( + "class $enum_name$(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):\n" + " __slots__ = []\n", + "enum_name", enum_name); +} + +// Adds enum value to item map which will be ordered and printed later. +void PyiGenerator::AddEnumValue( + const EnumDescriptor& enum_descriptor, + std::map<std::string, std::string>* item_map, + const std::map<std::string, std::string>& import_map) const { + // enum values + std::string module_enum_name = ModuleLevelName(enum_descriptor, import_map); + for (int j = 0; j < enum_descriptor.value_count(); ++j) { + const EnumValueDescriptor* value_descriptor = enum_descriptor.value(j); + (*item_map)[value_descriptor->name()] = module_enum_name; + } +} + +// Prints top level enums +void PyiGenerator::PrintTopLevelEnums() const { + for (int i = 0; i < file_->enum_type_count(); ++i) { + printer_->Print("\n"); + PrintEnum(*file_->enum_type(i)); + } +} + +// Add top level extensions to item_map which will be ordered and +// printed later. +template <typename DescriptorT> +void PyiGenerator::AddExtensions( + const DescriptorT& descriptor, + std::map<std::string, std::string>* item_map) const { + for (int i = 0; i < descriptor.extension_count(); ++i) { + const FieldDescriptor* extension_field = descriptor.extension(i); + std::string constant_name = extension_field->name() + "_FIELD_NUMBER"; + ToUpper(&constant_name); + (*item_map)[constant_name] = "_ClassVar[int]"; + (*item_map)[extension_field->name()] = "_descriptor.FieldDescriptor"; + } +} + +// Returns the string format of a field's cpp_type +std::string PyiGenerator::GetFieldType( + const FieldDescriptor& field_des, const Descriptor& containing_des, + const std::map<std::string, std::string>& import_map) const { + switch (field_des.cpp_type()) { + case FieldDescriptor::CPPTYPE_INT32: + case FieldDescriptor::CPPTYPE_UINT32: + case FieldDescriptor::CPPTYPE_INT64: + case FieldDescriptor::CPPTYPE_UINT64: + return "int"; + case FieldDescriptor::CPPTYPE_DOUBLE: + case FieldDescriptor::CPPTYPE_FLOAT: + return "float"; + case FieldDescriptor::CPPTYPE_BOOL: + return "bool"; + case FieldDescriptor::CPPTYPE_ENUM: + return ModuleLevelName(*field_des.enum_type(), import_map); + case FieldDescriptor::CPPTYPE_STRING: + if (field_des.type() == FieldDescriptor::TYPE_STRING) { + return "str"; + } else { + return "bytes"; + } + case FieldDescriptor::CPPTYPE_MESSAGE: { + // If the field is inside a nested message and the nested message has the + // same name as a top-level message, then we need to prefix the field type + // with the module name for disambiguation. + std::string name = ModuleLevelName(*field_des.message_type(), import_map); + if ((containing_des.containing_type() != nullptr && + name == containing_des.name())) { + std::string module = ModuleName(field_des.file()->name()); + name = module + "." + name; + } + return name; + } + default: + GOOGLE_LOG(FATAL) << "Unsupported field type."; + } + return ""; +} + +void PyiGenerator::PrintMessage( + const Descriptor& message_descriptor, bool is_nested, + const std::map<std::string, std::string>& import_map) const { + if (!is_nested) { + printer_->Print("\n"); + } + std::string class_name = message_descriptor.name(); + std::string extra_base; + // A well-known type needs to inherit from its corresponding base class in + // net/proto2/python/internal/well_known_types. + if (IsWellKnownType(message_descriptor.full_name())) { + extra_base = ", _well_known_types." + message_descriptor.name(); + } else { + extra_base = ""; + } + printer_->Print("class $class_name$(_message.Message$extra_base$):\n", + "class_name", class_name, "extra_base", extra_base); + printer_->Indent(); + printer_->Indent(); + + std::vector<const FieldDescriptor*> fields; + fields.reserve(message_descriptor.field_count()); + for (int i = 0; i < message_descriptor.field_count(); ++i) { + fields.push_back(message_descriptor.field(i)); + } + std::sort(fields.begin(), fields.end(), SortByName<FieldDescriptor>()); + + // Prints slots + printer_->Print("__slots__ = [", "class_name", class_name); + bool first_item = true; + for (const auto& field_des : fields) { + if (IsPythonKeyword(field_des->name())) { + continue; + } + if (first_item) { + first_item = false; + } else { + printer_->Print(", "); + } + printer_->Print("\"$field_name$\"", "field_name", field_des->name()); + } + printer_->Print("]\n"); + + std::map<std::string, std::string> item_map; + // Prints Extensions for extendable messages + if (message_descriptor.extension_range_count() > 0) { + item_map["Extensions"] = "_python_message._ExtensionDict"; + } + + // Prints nested enums + std::vector<const EnumDescriptor*> nested_enums; + nested_enums.reserve(message_descriptor.enum_type_count()); + for (int i = 0; i < message_descriptor.enum_type_count(); ++i) { + nested_enums.push_back(message_descriptor.enum_type(i)); + } + std::sort(nested_enums.begin(), nested_enums.end(), + SortByName<EnumDescriptor>()); + + for (const auto& entry : nested_enums) { + PrintEnum(*entry); + // Adds enum value to item_map which will be ordered and printed later + AddEnumValue(*entry, &item_map, import_map); + } + + // Prints nested messages + std::vector<const Descriptor*> nested_messages; + nested_messages.reserve(message_descriptor.nested_type_count()); + for (int i = 0; i < message_descriptor.nested_type_count(); ++i) { + nested_messages.push_back(message_descriptor.nested_type(i)); + } + std::sort(nested_messages.begin(), nested_messages.end(), + SortByName<Descriptor>()); + + for (const auto& entry : nested_messages) { + PrintMessage(*entry, true, import_map); + } + + // Adds extensions to item_map which will be ordered and printed later + AddExtensions(message_descriptor, &item_map); + + // Adds field number and field descriptor to item_map + for (int i = 0; i < message_descriptor.field_count(); ++i) { + const FieldDescriptor& field_des = *message_descriptor.field(i); + item_map[ToUpper(field_des.name()) + "_FIELD_NUMBER"] = + "_ClassVar[int]"; + if (IsPythonKeyword(field_des.name())) { + continue; + } + std::string field_type = ""; + if (field_des.is_map()) { + const FieldDescriptor* key_des = field_des.message_type()->field(0); + const FieldDescriptor* value_des = field_des.message_type()->field(1); + field_type = (value_des->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE + ? "_containers.MessageMap[" + : "_containers.ScalarMap["); + field_type += GetFieldType(*key_des, message_descriptor, import_map); + field_type += ", "; + field_type += GetFieldType(*value_des, message_descriptor, import_map); + } else { + if (field_des.is_repeated()) { + field_type = (field_des.cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE + ? "_containers.RepeatedCompositeFieldContainer[" + : "_containers.RepeatedScalarFieldContainer["); + } + field_type += GetFieldType(field_des, message_descriptor, import_map); + } + + if (field_des.is_repeated()) { + field_type += "]"; + } + item_map[field_des.name()] = field_type; + } + + // Prints all items in item_map + PrintItemMap(item_map); + + // Prints __init__ + printer_->Print("def __init__(self"); + bool has_key_words = false; + bool is_first = true; + for (int i = 0; i < message_descriptor.field_count(); ++i) { + const FieldDescriptor* field_des = message_descriptor.field(i); + if (IsPythonKeyword(field_des->name())) { + has_key_words = true; + continue; + } + std::string field_name = field_des->name(); + if (is_first && field_name == "self") { + // See b/144146793 for an example of real code that generates a (self, + // self) method signature. Since repeating a parameter name is illegal in + // Python, we rename the duplicate self. + field_name = "self_"; + } + is_first = false; + printer_->Print(", $field_name$: ", "field_name", field_name); + if (field_des->is_repeated() || + field_des->cpp_type() != FieldDescriptor::CPPTYPE_BOOL) { + printer_->Print("_Optional["); + } + if (field_des->is_map()) { + const Descriptor* map_entry = field_des->message_type(); + printer_->Print( + "_Mapping[$key_type$, $value_type$]", "key_type", + GetFieldType(*map_entry->field(0), message_descriptor, import_map), + "value_type", + GetFieldType(*map_entry->field(1), message_descriptor, import_map)); + } else { + if (field_des->is_repeated()) { + printer_->Print("_Iterable["); + } + if (field_des->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + printer_->Print( + "_Union[$type_name$, _Mapping]", "type_name", + GetFieldType(*field_des, message_descriptor, import_map)); + } else { + if (field_des->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { + printer_->Print("_Union[$type_name$, str]", "type_name", + ModuleLevelName(*field_des->enum_type(), import_map)); + } else { + printer_->Print( + "$type_name$", "type_name", + GetFieldType(*field_des, message_descriptor, import_map)); + } + } + if (field_des->is_repeated()) { + printer_->Print("]"); + } + } + if (field_des->is_repeated() || + field_des->cpp_type() != FieldDescriptor::CPPTYPE_BOOL) { + printer_->Print("]"); + } + printer_->Print(" = ..."); + } + if (has_key_words) { + printer_->Print(", **kwargs"); + } + printer_->Print(") -> None: ...\n"); + + printer_->Outdent(); + printer_->Outdent(); +} + +void PyiGenerator::PrintMessages( + const std::map<std::string, std::string>& import_map) const { + // Deterministically order the descriptors. + std::vector<const Descriptor*> messages; + messages.reserve(file_->message_type_count()); + for (int i = 0; i < file_->message_type_count(); ++i) { + messages.push_back(file_->message_type(i)); + } + std::sort(messages.begin(), messages.end(), SortByName<Descriptor>()); + + for (const auto& entry : messages) { + PrintMessage(*entry, false, import_map); + } +} + +void PyiGenerator::PrintServices() const { + std::vector<const ServiceDescriptor*> services; + services.reserve(file_->service_count()); + for (int i = 0; i < file_->service_count(); ++i) { + services.push_back(file_->service(i)); + } + std::sort(services.begin(), services.end(), SortByName<ServiceDescriptor>()); + + // Prints $Service$ and $Service$_Stub classes + for (const auto& entry : services) { + printer_->Print("\n"); + printer_->Print( + "class $service_name$(_service.service): ...\n\n" + "class $service_name$_Stub($service_name$): ...\n", + "service_name", entry->name()); + } +} + +bool PyiGenerator::Generate(const FileDescriptor* file, + const std::string& parameter, + GeneratorContext* context, + std::string* error) const { + MutexLock lock(&mutex_); + // Calculate file name. + file_ = file; + std::string filename = + parameter.empty() ? GetFileName(file, ".pyi") : parameter; + + std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename)); + GOOGLE_CHECK(output.get()); + io::Printer printer(output.get(), '$'); + printer_ = &printer; + + // item map will store "DESCRIPTOR", top level extensions, top level enum + // values. The items will be sorted and printed later. + std::map<std::string, std::string> item_map; + + // Adds "DESCRIPTOR" into item_map. + item_map["DESCRIPTOR"] = "_descriptor.FileDescriptor"; + + // import_map will be a mapping from filename to module alias, e.g. + // "google3/foo/bar.py" -> "_bar" + std::map<std::string, std::string> import_map; + + PrintImports(&item_map, &import_map); + // Adds top level enum values to item_map. + for (int i = 0; i < file_->enum_type_count(); ++i) { + AddEnumValue(*file_->enum_type(i), &item_map, import_map); + } + // Adds top level extensions to item_map. + AddExtensions(*file_, &item_map); + // Prints item map + PrintItemMap(item_map); + + PrintMessages(import_map); + PrintTopLevelEnums(); + if (HasGenericServices(file)) { + PrintServices(); + } + return true; +} + +} // namespace python +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/r5dev/thirdparty/protobuf/compiler/python/pyi_generator.h b/r5dev/thirdparty/protobuf/compiler/python/pyi_generator.h new file mode 100644 index 00000000..ba8ca642 --- /dev/null +++ b/r5dev/thirdparty/protobuf/compiler/python/pyi_generator.h @@ -0,0 +1,120 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Author: jieluo@google.com (Jie Luo) +// +// Generates Python stub (.pyi) for a given .proto file. + +#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__ +#define GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__ + +#include <map> +#include <set> +#include <string> + +#include <thirdparty/protobuf/stubs/mutex.h> +#include <thirdparty/protobuf/compiler/code_generator.h> + +// Must be included last. +#include <thirdparty/protobuf/port_def.inc> + +namespace google { +namespace protobuf { +class Descriptor; +class EnumDescriptor; +class FieldDescriptor; +class MethodDescriptor; +class ServiceDescriptor; + +namespace io { +class Printer; +} + +namespace compiler { +namespace python { + +class PROTOC_EXPORT PyiGenerator : public google::protobuf::compiler::CodeGenerator { + public: + PyiGenerator(); + ~PyiGenerator() override; + + // CodeGenerator methods. + uint64_t GetSupportedFeatures() const override { + // Code generators must explicitly support proto3 optional. + return CodeGenerator::FEATURE_PROTO3_OPTIONAL; + } + bool Generate(const FileDescriptor* file, const std::string& parameter, + GeneratorContext* generator_context, + std::string* error) const override; + + private: + void PrintImportForDescriptor(const FileDescriptor& desc, + std::map<std::string, std::string>* import_map, + std::set<std::string>* seen_aliases) const; + void PrintImports(std::map<std::string, std::string>* item_map, + std::map<std::string, std::string>* import_map) const; + void PrintEnum(const EnumDescriptor& enum_descriptor) const; + void AddEnumValue(const EnumDescriptor& enum_descriptor, + std::map<std::string, std::string>* item_map, + const std::map<std::string, std::string>& import_map) const; + void PrintTopLevelEnums() const; + template <typename DescriptorT> + void AddExtensions(const DescriptorT& descriptor, + std::map<std::string, std::string>* item_map) const; + void PrintMessages( + const std::map<std::string, std::string>& import_map) const; + void PrintMessage(const Descriptor& message_descriptor, bool is_nested, + const std::map<std::string, std::string>& import_map) const; + void PrintServices() const; + void PrintItemMap(const std::map<std::string, std::string>& item_map) const; + std::string GetFieldType( + const FieldDescriptor& field_des, const Descriptor& containing_des, + const std::map<std::string, std::string>& import_map) const; + template <typename DescriptorT> + std::string ModuleLevelName( + const DescriptorT& descriptor, + const std::map<std::string, std::string>& import_map) const; + + // Very coarse-grained lock to ensure that Generate() is reentrant. + // Guards file_ and printer_. + mutable Mutex mutex_; + mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_. + mutable io::Printer* printer_; // Set in Generate(). Under mutex_. + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PyiGenerator); +}; + +} // namespace python +} // namespace compiler +} // namespace protobuf +} // namespace google + +#include <thirdparty/protobuf/port_undef.inc> + +#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_PYI_GENERATOR_H__ diff --git a/r5dev/thirdparty/protobuf/compiler/python/python_generator.h b/r5dev/thirdparty/protobuf/compiler/python/python_generator.h index bc311640..055311c8 100644 --- a/r5dev/thirdparty/protobuf/compiler/python/python_generator.h +++ b/r5dev/thirdparty/protobuf/compiler/python/python_generator.h @@ -1,193 +1,6 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_PYTHON_GENERATOR_H_ +#define GOOGLE_PROTOBUF_COMPILER_PYTHON_PYTHON_GENERATOR_H_ -// Author: robinson@google.com (Will Robinson) -// -// Generates Python code for a given .proto file. +#include <thirdparty/protobuf/compiler/python/generator.h> -#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ - -#include <string> - -#include <thirdparty/protobuf/compiler/code_generator.h> -#include <thirdparty/protobuf/stubs/mutex.h> - -#include <thirdparty/protobuf/port_def.inc> - -namespace google { -namespace protobuf { - -class Descriptor; -class EnumDescriptor; -class EnumValueDescriptor; -class FieldDescriptor; -class OneofDescriptor; -class ServiceDescriptor; - -namespace io { -class Printer; -} - -namespace compiler { -namespace python { - -enum class StripPrintDescriptor { kCreate, kFind }; - -// CodeGenerator implementation for generated Python protocol buffer classes. -// If you create your own protocol compiler binary and you want it to support -// Python output, you can do so by registering an instance of this -// CodeGenerator with the CommandLineInterface in your main() function. -class PROTOC_EXPORT Generator : public CodeGenerator { - public: - Generator(); - virtual ~Generator(); - - // CodeGenerator methods. - bool Generate(const FileDescriptor* file, const std::string& parameter, - GeneratorContext* generator_context, - std::string* error) const override; - - uint64_t GetSupportedFeatures() const override; - - private: - void PrintImports() const; - void PrintFileDescriptor() const; - void PrintTopLevelEnums() const; - void PrintAllNestedEnumsInFile(StripPrintDescriptor print_mode) const; - void PrintNestedEnums(const Descriptor& descriptor, - StripPrintDescriptor print_mode) const; - void PrintCreateEnum(const EnumDescriptor& enum_descriptor) const; - void PrintFindEnum(const EnumDescriptor& enum_descriptor) const; - - void PrintTopLevelExtensions() const; - - void PrintFieldDescriptor(const FieldDescriptor& field, - bool is_extension) const; - void PrintFieldDescriptorsInDescriptor( - const Descriptor& message_descriptor, bool is_extension, - const std::string& list_variable_name, int (Descriptor::*CountFn)() const, - const FieldDescriptor* (Descriptor::*GetterFn)(int)const) const; - void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const; - void PrintExtensionsInDescriptor(const Descriptor& message_descriptor) const; - void PrintMessageDescriptors(StripPrintDescriptor print_mode) const; - void PrintCreateDescriptor(const Descriptor& message_descriptor) const; - void PrintFindDescriptor(const Descriptor& message_descriptor) const; - void PrintNestedDescriptors(const Descriptor& containing_descriptor, - StripPrintDescriptor print_mode) const; - - void PrintMessages() const; - void PrintMessage(const Descriptor& message_descriptor, - const std::string& prefix, - std::vector<std::string>* to_register, - bool is_nested) const; - void PrintNestedMessages(const Descriptor& containing_descriptor, - const std::string& prefix, - std::vector<std::string>* to_register) const; - - void FixForeignFieldsInDescriptors() const; - void FixForeignFieldsInDescriptor( - const Descriptor& descriptor, - const Descriptor* containing_descriptor) const; - void FixForeignFieldsInField(const Descriptor* containing_type, - const FieldDescriptor& field, - const std::string& python_dict_name) const; - void AddMessageToFileDescriptor(const Descriptor& descriptor) const; - void AddEnumToFileDescriptor(const EnumDescriptor& descriptor) const; - void AddExtensionToFileDescriptor(const FieldDescriptor& descriptor) const; - void AddServiceToFileDescriptor(const ServiceDescriptor& descriptor) const; - std::string FieldReferencingExpression( - const Descriptor* containing_type, const FieldDescriptor& field, - const std::string& python_dict_name) const; - template <typename DescriptorT> - void FixContainingTypeInDescriptor( - const DescriptorT& descriptor, - const Descriptor* containing_descriptor) const; - - void FixForeignFieldsInExtensions() const; - void FixForeignFieldsInExtension( - const FieldDescriptor& extension_field) const; - void FixForeignFieldsInNestedExtensions(const Descriptor& descriptor) const; - - void PrintServices() const; - void PrintServiceDescriptors() const; - void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const; - void PrintServiceClass(const ServiceDescriptor& descriptor) const; - void PrintServiceStub(const ServiceDescriptor& descriptor) const; - void PrintDescriptorKeyAndModuleName( - const ServiceDescriptor& descriptor) const; - - void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const; - std::string OptionsValue(const std::string& serialized_options) const; - bool GeneratingDescriptorProto() const; - - template <typename DescriptorT> - std::string ModuleLevelDescriptorName(const DescriptorT& descriptor) const; - std::string ModuleLevelMessageName(const Descriptor& descriptor) const; - std::string ModuleLevelServiceDescriptorName( - const ServiceDescriptor& descriptor) const; - - template <typename DescriptorT, typename DescriptorProtoT> - void PrintSerializedPbInterval(const DescriptorT& descriptor, - DescriptorProtoT& proto, - const std::string& name) const; - - void FixAllDescriptorOptions() const; - void FixOptionsForField(const FieldDescriptor& field) const; - void FixOptionsForOneof(const OneofDescriptor& oneof) const; - void FixOptionsForEnum(const EnumDescriptor& descriptor) const; - void FixOptionsForService(const ServiceDescriptor& descriptor) const; - void FixOptionsForMessage(const Descriptor& descriptor) const; - - void SetSerializedPbInterval() const; - void SetMessagePbInterval(const Descriptor& descriptor) const; - - void CopyPublicDependenciesAliases(const std::string& copy_from, - const FileDescriptor* file) const; - - // Very coarse-grained lock to ensure that Generate() is reentrant. - // Guards file_, printer_ and file_descriptor_serialized_. - mutable Mutex mutex_; - mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_. - mutable std::string file_descriptor_serialized_; - mutable io::Printer* printer_; // Set in Generate(). Under mutex_. - mutable bool pure_python_workable_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator); -}; - -} // namespace python -} // namespace compiler -} // namespace protobuf -} // namespace google - -#include <thirdparty/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ +#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_PYTHON_GENERATOR_H_ diff --git a/r5dev/thirdparty/protobuf/compiler/ruby/ruby_generator.cc b/r5dev/thirdparty/protobuf/compiler/ruby/ruby_generator.cc index 4639ec70..31b91bb7 100644 --- a/r5dev/thirdparty/protobuf/compiler/ruby/ruby_generator.cc +++ b/r5dev/thirdparty/protobuf/compiler/ruby/ruby_generator.cc @@ -158,7 +158,7 @@ std::string DefaultValueForField(const FieldDescriptor* field) { for (int i = 0; i < default_str.length(); ++i) { // Write the hex form of each byte. os << "\\x" << std::hex << std::setw(2) - << ((uint16)((unsigned char)default_str.at(i))); + << ((uint16_t)((unsigned char)default_str.at(i))); } os << "\".force_encoding(\"ASCII-8BIT\")"; } @@ -421,7 +421,7 @@ int GeneratePackageModules(const FileDescriptor* file, io::Printer* printer) { // -> A.B.C if (package_name.find("::") != std::string::npos) { need_change_to_module = false; - } else { + } else if (package_name.find(".") != std::string::npos) { GOOGLE_LOG(WARNING) << "ruby_package option should be in the form of:" << " 'A::B::C' and not 'A.B.C'"; } diff --git a/r5dev/thirdparty/protobuf/compiler/ruby/ruby_generator_unittest.cc b/r5dev/thirdparty/protobuf/compiler/ruby/ruby_generator_unittest.cc index ba75a9ff..1c96e4bf 100644 --- a/r5dev/thirdparty/protobuf/compiler/ruby/ruby_generator_unittest.cc +++ b/r5dev/thirdparty/protobuf/compiler/ruby/ruby_generator_unittest.cc @@ -57,7 +57,7 @@ std::string FindRubyTestDir() { // Some day, we may integrate build systems between protoc and the language // extensions to the point where we can do this test in a more automated way. -void RubyTest(string proto_file, string import_proto_file = "") { +void RubyTest(std::string proto_file, std::string import_proto_file = "") { std::string ruby_tests = FindRubyTestDir(); google::protobuf::compiler::CommandLineInterface cli; diff --git a/r5dev/thirdparty/protobuf/compiler/scc.h b/r5dev/thirdparty/protobuf/compiler/scc.h index e4e46645..ab213114 100644 --- a/r5dev/thirdparty/protobuf/compiler/scc.h +++ b/r5dev/thirdparty/protobuf/compiler/scc.h @@ -37,6 +37,7 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/descriptor.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/compiler/subprocess.cc b/r5dev/thirdparty/protobuf/compiler/subprocess.cc index b5fba29a..fdc76f7b 100644 --- a/r5dev/thirdparty/protobuf/compiler/subprocess.cc +++ b/r5dev/thirdparty/protobuf/compiler/subprocess.cc @@ -45,8 +45,9 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/message.h> +#include <thirdparty/protobuf/io/io_win32.h> namespace google { namespace protobuf { @@ -55,7 +56,7 @@ namespace compiler { namespace { char* portable_strdup(const char* s) { char* ns = (char*)malloc(strlen(s) + 1); - if (ns != NULL) { + if (ns != nullptr) { strcpy(ns, s); } return ns; @@ -73,15 +74,15 @@ static void CloseHandleOrDie(HANDLE handle) { Subprocess::Subprocess() : process_start_error_(ERROR_SUCCESS), - child_handle_(NULL), - child_stdin_(NULL), - child_stdout_(NULL) {} + child_handle_(nullptr), + child_stdin_(nullptr), + child_stdout_(nullptr) {} Subprocess::~Subprocess() { - if (child_stdin_ != NULL) { + if (child_stdin_ != nullptr) { CloseHandleOrDie(child_stdin_); } - if (child_stdout_ != NULL) { + if (child_stdout_ != nullptr) { CloseHandleOrDie(child_stdout_); } } @@ -93,10 +94,10 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) { HANDLE stdout_pipe_read; HANDLE stdout_pipe_write; - if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, NULL, 0)) { + if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, nullptr, 0)) { GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError()); } - if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, NULL, 0)) { + if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, nullptr, 0)) { GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError()); } @@ -113,7 +114,7 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) { } // Setup STARTUPINFO to redirect handles. - STARTUPINFOA startup_info; + STARTUPINFOW startup_info; ZeroMemory(&startup_info, sizeof(startup_info)); startup_info.cb = sizeof(startup_info); startup_info.dwFlags = STARTF_USESTDHANDLES; @@ -125,23 +126,36 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) { GOOGLE_LOG(FATAL) << "GetStdHandle: " << Win32ErrorMessage(GetLastError()); } + // get wide string version of program as the path may contain non-ascii characters + std::wstring wprogram; + if (!io::win32::strings::utf8_to_wcs(program.c_str(), &wprogram)) { + GOOGLE_LOG(FATAL) << "utf8_to_wcs: " << Win32ErrorMessage(GetLastError()); + } + // Invoking cmd.exe allows for '.bat' files from the path as well as '.exe'. + std::string command_line = "cmd.exe /c \"" + program + "\""; + + // get wide string version of command line as the path may contain non-ascii characters + std::wstring wcommand_line; + if (!io::win32::strings::utf8_to_wcs(command_line.c_str(), &wcommand_line)) { + GOOGLE_LOG(FATAL) << "utf8_to_wcs: " << Win32ErrorMessage(GetLastError()); + } + // Using a malloc'ed string because CreateProcess() can mutate its second // parameter. - char* command_line = - portable_strdup(("cmd.exe /c \"" + program + "\"").c_str()); + wchar_t *wcommand_line_copy = _wcsdup(wcommand_line.c_str()); // Create the process. PROCESS_INFORMATION process_info; - if (CreateProcessA((search_mode == SEARCH_PATH) ? NULL : program.c_str(), - (search_mode == SEARCH_PATH) ? command_line : NULL, - NULL, // process security attributes - NULL, // thread security attributes - TRUE, // inherit handles? - 0, // obscure creation flags - NULL, // environment (inherit from parent) - NULL, // current directory (inherit from parent) + if (CreateProcessW((search_mode == SEARCH_PATH) ? nullptr : wprogram.c_str(), + (search_mode == SEARCH_PATH) ? wcommand_line_copy : NULL, + nullptr, // process security attributes + nullptr, // thread security attributes + TRUE, // inherit handles? + 0, // obscure creation flags + nullptr, // environment (inherit from parent) + nullptr, // current directory (inherit from parent) &startup_info, &process_info)) { child_handle_ = process_info.hProcess; CloseHandleOrDie(process_info.hThread); @@ -155,7 +169,7 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) { CloseHandleOrDie(stdin_pipe_read); CloseHandleOrDie(stdout_pipe_write); - free(command_line); + free(wcommand_line_copy); } bool Subprocess::Communicate(const Message& input, Message* output, @@ -165,28 +179,32 @@ bool Subprocess::Communicate(const Message& input, Message* output, return false; } - GOOGLE_CHECK(child_handle_ != NULL) << "Must call Start() first."; + GOOGLE_CHECK(child_handle_ != nullptr) << "Must call Start() first."; - std::string input_data = input.SerializeAsString(); + std::string input_data; + if (!input.SerializeToString(&input_data)) { + *error = "Failed to serialize request."; + return false; + } std::string output_data; int input_pos = 0; - while (child_stdout_ != NULL) { + while (child_stdout_ != nullptr) { HANDLE handles[2]; int handle_count = 0; - if (child_stdin_ != NULL) { + if (child_stdin_ != nullptr) { handles[handle_count++] = child_stdin_; } - if (child_stdout_ != NULL) { + if (child_stdout_ != nullptr) { handles[handle_count++] = child_stdout_; } DWORD wait_result = WaitForMultipleObjects(handle_count, handles, FALSE, INFINITE); - HANDLE signaled_handle = NULL; + HANDLE signaled_handle = nullptr; if (wait_result >= WAIT_OBJECT_0 && wait_result < WAIT_OBJECT_0 + handle_count) { signaled_handle = handles[wait_result - WAIT_OBJECT_0]; @@ -201,7 +219,7 @@ bool Subprocess::Communicate(const Message& input, Message* output, if (signaled_handle == child_stdin_) { DWORD n; if (!WriteFile(child_stdin_, input_data.data() + input_pos, - input_data.size() - input_pos, &n, NULL)) { + input_data.size() - input_pos, &n, nullptr)) { // Child closed pipe. Presumably it will report an error later. // Pretend we're done for now. input_pos = input_data.size(); @@ -212,27 +230,27 @@ bool Subprocess::Communicate(const Message& input, Message* output, if (input_pos == input_data.size()) { // We're done writing. Close. CloseHandleOrDie(child_stdin_); - child_stdin_ = NULL; + child_stdin_ = nullptr; } } else if (signaled_handle == child_stdout_) { char buffer[4096]; DWORD n; - if (!ReadFile(child_stdout_, buffer, sizeof(buffer), &n, NULL)) { + if (!ReadFile(child_stdout_, buffer, sizeof(buffer), &n, nullptr)) { // We're done reading. Close. CloseHandleOrDie(child_stdout_); - child_stdout_ = NULL; + child_stdout_ = nullptr; } else { output_data.append(buffer, n); } } } - if (child_stdin_ != NULL) { + if (child_stdin_ != nullptr) { // Child did not finish reading input before it closed the output. // Presumably it exited with an error. CloseHandleOrDie(child_stdin_); - child_stdin_ = NULL; + child_stdin_ = nullptr; } DWORD wait_result = WaitForSingleObject(child_handle_, INFINITE); @@ -252,7 +270,7 @@ bool Subprocess::Communicate(const Message& input, Message* output, } CloseHandleOrDie(child_handle_); - child_handle_ = NULL; + child_handle_ = nullptr; if (exit_code != 0) { *error = strings::Substitute("Plugin failed with status code $0.", exit_code); @@ -273,9 +291,10 @@ std::string Subprocess::Win32ErrorMessage(DWORD error_code) { // WTF? FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, error_code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), + nullptr, error_code, + MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (LPSTR)&message, // NOT A BUG! - 0, NULL); + 0, nullptr); std::string result = message; LocalFree(message); @@ -309,7 +328,7 @@ void Subprocess::Start(const std::string& program, SearchMode search_mode) { GOOGLE_CHECK(pipe(stdin_pipe) != -1); GOOGLE_CHECK(pipe(stdout_pipe) != -1); - char* argv[2] = {portable_strdup(program.c_str()), NULL}; + char* argv[2] = {portable_strdup(program.c_str()), nullptr}; child_pid_ = fork(); if (child_pid_ == -1) { @@ -368,7 +387,11 @@ bool Subprocess::Communicate(const Message& input, Message* output, // Make sure SIGPIPE is disabled so that if the child dies it doesn't kill us. SignalHandler* old_pipe_handler = signal(SIGPIPE, SIG_IGN); - std::string input_data = input.SerializeAsString(); + std::string input_data; + if (!input.SerializeToString(&input_data)) { + *error = "Failed to serialize request."; + return false; + } std::string output_data; int input_pos = 0; @@ -386,7 +409,7 @@ bool Subprocess::Communicate(const Message& input, Message* output, FD_SET(child_stdin_, &write_fds); } - if (select(max_fd + 1, &read_fds, &write_fds, NULL, NULL) < 0) { + if (select(max_fd + 1, &read_fds, &write_fds, nullptr, nullptr) < 0) { if (errno == EINTR) { // Interrupted by signal. Try again. continue; diff --git a/r5dev/thirdparty/protobuf/compiler/subprocess.h b/r5dev/thirdparty/protobuf/compiler/subprocess.h index a2b0300b..d4f15c59 100644 --- a/r5dev/thirdparty/protobuf/compiler/subprocess.h +++ b/r5dev/thirdparty/protobuf/compiler/subprocess.h @@ -46,6 +46,7 @@ #include <string> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/compiler/test_plugin.cc b/r5dev/thirdparty/protobuf/compiler/test_plugin.cc index 71a1699c..45f14c68 100644 --- a/r5dev/thirdparty/protobuf/compiler/test_plugin.cc +++ b/r5dev/thirdparty/protobuf/compiler/test_plugin.cc @@ -34,7 +34,9 @@ // command_line_interface_unittest. #include <stdlib.h> + #include <string> + #include <thirdparty/protobuf/compiler/mock_code_generator.h> #include <thirdparty/protobuf/compiler/plugin.h> diff --git a/r5dev/thirdparty/protobuf/compiler/zip_writer.h b/r5dev/thirdparty/protobuf/compiler/zip_writer.h index 5456b0ca..cba4be2f 100644 --- a/r5dev/thirdparty/protobuf/compiler/zip_writer.h +++ b/r5dev/thirdparty/protobuf/compiler/zip_writer.h @@ -29,6 +29,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Author: kenton@google.com (Kenton Varda) +#ifndef GOOGLE_PROTOBUF_COMPILER_ZIP_WRITER_H__ +#define GOOGLE_PROTOBUF_COMPILER_ZIP_WRITER_H__ #include <cstdint> #include <vector> @@ -63,3 +65,5 @@ class ZipWriter { } // namespace compiler } // namespace protobuf } // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_ZIP_WRITER_H__ diff --git a/r5dev/thirdparty/protobuf/descriptor.cc b/r5dev/thirdparty/protobuf/descriptor.cc index 708db443..beba114e 100644 --- a/r5dev/thirdparty/protobuf/descriptor.cc +++ b/r5dev/thirdparty/protobuf/descriptor.cc @@ -41,30 +41,32 @@ #include <map> #include <memory> #include <set> +#include <sstream> #include <string> +#include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/stubs/once.h> #include <thirdparty/protobuf/any.h> #include <thirdparty/protobuf/descriptor.pb.h> -#include <thirdparty/protobuf/stubs/once.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/tokenizer.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> +#include <thirdparty/protobuf/stubs/casts.h> +#include <thirdparty/protobuf/stubs/stringprintf.h> +#include <thirdparty/protobuf/stubs/substitute.h> #include <thirdparty/protobuf/descriptor_database.h> #include <thirdparty/protobuf/dynamic_message.h> #include <thirdparty/protobuf/generated_message_util.h> +#include <thirdparty/protobuf/io/strtod.h> +#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/text_format.h> #include <thirdparty/protobuf/unknown_field_set.h> -#include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/stubs/casts.h> -#include <thirdparty/protobuf/stubs/substitute.h> -#include <thirdparty/protobuf/io/strtod.h> #include <thirdparty/protobuf/stubs/map_util.h> #include <thirdparty/protobuf/stubs/stl_util.h> #include <thirdparty/protobuf/stubs/hash.h> @@ -72,11 +74,493 @@ #undef PACKAGE // autoheader #defines this. :( +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { +namespace { +const int kPackageLimit = 100; + +// Note: I distrust ctype.h due to locales. +char ToUpper(char ch) { + return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch; +} + +char ToLower(char ch) { + return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch; +} + +std::string ToCamelCase(const std::string& input, bool lower_first) { + bool capitalize_next = !lower_first; + std::string result; + result.reserve(input.size()); + + for (char character : input) { + if (character == '_') { + capitalize_next = true; + } else if (capitalize_next) { + result.push_back(ToUpper(character)); + capitalize_next = false; + } else { + result.push_back(character); + } + } + + // Lower-case the first letter. + if (lower_first && !result.empty()) { + result[0] = ToLower(result[0]); + } + + return result; +} + +std::string ToJsonName(const std::string& input) { + bool capitalize_next = false; + std::string result; + result.reserve(input.size()); + + for (char character : input) { + if (character == '_') { + capitalize_next = true; + } else if (capitalize_next) { + result.push_back(ToUpper(character)); + capitalize_next = false; + } else { + result.push_back(character); + } + } + + return result; +} + +// Backport of fold expressions for the comma operator to C++11. +// Usage: Fold({expr...}); +// Guaranteed to evaluate left-to-right +struct ExpressionEater { + template <typename T> + ExpressionEater(T&&) {} // NOLINT +}; +void Fold(std::initializer_list<ExpressionEater>) {} + +template <int R> +constexpr size_t RoundUpTo(size_t n) { + static_assert((R & (R - 1)) == 0, "Must be power of two"); + return (n + (R - 1)) & ~(R - 1); +} + +constexpr size_t Max(size_t a, size_t b) { return a > b ? a : b; } +template <typename T, typename... Ts> +constexpr size_t Max(T a, Ts... b) { + return Max(a, Max(b...)); +} + +template <typename T> +constexpr size_t EffectiveAlignof() { + // `char` is special in that it gets aligned to 8. It is where we drop the + // trivial structs. + return std::is_same<T, char>::value ? 8 : alignof(T); +} + +template <int align, typename U, typename... T> +using AppendIfAlign = + typename std::conditional<EffectiveAlignof<U>() == align, void (*)(T..., U), + void (*)(T...)>::type; + +// Metafunction to sort types in descending order of alignment. +// Useful for the flat allocator to ensure proper alignment of all elements +// without having to add padding. +// Instead of implementing a proper sort metafunction we just do a +// filter+merge, which is much simpler to write as a metafunction. +// We have a fixed set of alignments we can filter on. +// For simplicity we use a function pointer as a type list. +template <typename In, typename T16, typename T8, typename T4, typename T2, + typename T1> +struct TypeListSortImpl; + +template <typename... T16, typename... T8, typename... T4, typename... T2, + typename... T1> +struct TypeListSortImpl<void (*)(), void (*)(T16...), void (*)(T8...), + void (*)(T4...), void (*)(T2...), void (*)(T1...)> { + using type = void (*)(T16..., T8..., T4..., T2..., T1...); +}; + +template <typename First, typename... Rest, typename... T16, typename... T8, + typename... T4, typename... T2, typename... T1> +struct TypeListSortImpl<void (*)(First, Rest...), void (*)(T16...), + void (*)(T8...), void (*)(T4...), void (*)(T2...), + void (*)(T1...)> { + using type = typename TypeListSortImpl< + void (*)(Rest...), AppendIfAlign<16, First, T16...>, + AppendIfAlign<8, First, T8...>, AppendIfAlign<4, First, T4...>, + AppendIfAlign<2, First, T2...>, AppendIfAlign<1, First, T1...>>::type; +}; + +template <typename... T> +using SortByAlignment = + typename TypeListSortImpl<void (*)(T...), void (*)(), void (*)(), + void (*)(), void (*)(), void (*)()>::type; + +template <template <typename...> class C, typename... T> +auto ApplyTypeList(void (*)(T...)) -> C<T...>; + +template <typename T> +constexpr int FindTypeIndex() { + return -1; +} + +template <typename T, typename T1, typename... Ts> +constexpr int FindTypeIndex() { + return std::is_same<T, T1>::value ? 0 : FindTypeIndex<T, Ts...>() + 1; +} + +// A type to value map, where the possible keys as specified in `Keys...`. +// The values for key `K` is `ValueT<K>` +template <template <typename> class ValueT, typename... Keys> +class TypeMap { + public: + template <typename K> + ValueT<K>& Get() { + return static_cast<Base<K>&>(payload_).value; + } + + template <typename K> + const ValueT<K>& Get() const { + return static_cast<const Base<K>&>(payload_).value; + } + + private: + template <typename K> + struct Base { + ValueT<K> value{}; + }; + struct Payload : Base<Keys>... {}; + Payload payload_; +}; + +template <typename T> +using IntT = int; +template <typename T> +using PointerT = T*; + +// Manages an allocation of sequential arrays of type `T...`. +// It is more space efficient than storing N (ptr, size) pairs, by storing only +// the pointer to the head and the boundaries between the arrays. +template <typename... T> +class FlatAllocation { + public: + static constexpr size_t kMaxAlign = Max(alignof(T)...); + + FlatAllocation(const TypeMap<IntT, T...>& ends) : ends_(ends) { + // The arrays start just after FlatAllocation, so adjust the ends. + Fold({(ends_.template Get<T>() += + RoundUpTo<kMaxAlign>(sizeof(FlatAllocation)))...}); + Fold({Init<T>()...}); + } + + void Destroy() { + Fold({Destroy<T>()...}); + internal::SizedDelete(this, total_bytes()); + } + + template <int I> + using type = typename std::tuple_element<I, std::tuple<T...>>::type; + + // Gets a tuple of the head pointers for the arrays + TypeMap<PointerT, T...> Pointers() const { + TypeMap<PointerT, T...> out; + Fold({(out.template Get<T>() = Begin<T>())...}); + return out; + } + + + private: + // Total number of bytes used by all arrays. + int total_bytes() const { + // Get the last end. + return ends_.template Get<typename std::tuple_element< + sizeof...(T) - 1, std::tuple<T...>>::type>(); + } + + + template <typename U> + int BeginOffset() const { + constexpr int type_index = FindTypeIndex<U, T...>(); + // Avoid a negative value here to keep it compiling when type_index == 0 + constexpr int prev_type_index = type_index == 0 ? 0 : type_index - 1; + using PrevType = + typename std::tuple_element<prev_type_index, std::tuple<T...>>::type; + // Ensure the types are properly aligned. + static_assert(EffectiveAlignof<PrevType>() >= EffectiveAlignof<U>(), ""); + return type_index == 0 ? RoundUpTo<kMaxAlign>(sizeof(FlatAllocation)) + : ends_.template Get<PrevType>(); + } + + template <typename U> + int EndOffset() const { + return ends_.template Get<U>(); + } + + // Avoid the reinterpret_cast if the array is empty. + // Clang's Control Flow Integrity does not like the cast pointing to memory + // that is not yet initialized to be of that type. + // (from -fsanitize=cfi-unrelated-cast) + template <typename U> + U* Begin() const { + int begin = BeginOffset<U>(), end = EndOffset<U>(); + if (begin == end) return nullptr; + return reinterpret_cast<U*>(data() + begin); + } + + template <typename U> + U* End() const { + int begin = BeginOffset<U>(), end = EndOffset<U>(); + if (begin == end) return nullptr; + return reinterpret_cast<U*>(data() + end); + } + + template <typename U> + bool Init() { + // Skip for the `char` block. No need to zero initialize it. + if (std::is_same<U, char>::value) return true; + for (char *p = data() + BeginOffset<U>(), *end = data() + EndOffset<U>(); + p != end; p += sizeof(U)) { + ::new (p) U{}; + } + return true; + } + + template <typename U> + bool Destroy() { + if (std::is_trivially_destructible<U>::value) return true; + for (U* it = Begin<U>(), *end = End<U>(); it != end; ++it) { + it->~U(); + } + return true; + } + + char* data() const { + return const_cast<char*>(reinterpret_cast<const char*>(this)); + } + + TypeMap<IntT, T...> ends_; +}; + +template <typename... T> +TypeMap<IntT, T...> CalculateEnds(const TypeMap<IntT, T...>& sizes) { + int total = 0; + TypeMap<IntT, T...> out; + Fold({(out.template Get<T>() = total += + sizeof(T) * sizes.template Get<T>())...}); + return out; +} + +// The implementation for FlatAllocator below. +// This separate class template makes it easier to have methods that fold on +// `T...`. +template <typename... T> +class FlatAllocatorImpl { + public: + using Allocation = FlatAllocation<T...>; + + template <typename U> + void PlanArray(int array_size) { + // We can't call PlanArray after FinalizePlanning has been called. + GOOGLE_CHECK(!has_allocated()); + if (std::is_trivially_destructible<U>::value) { + // Trivial types are aligned to 8 bytes. + static_assert(alignof(U) <= 8, ""); + total_.template Get<char>() += RoundUpTo<8>(array_size * sizeof(U)); + } else { + // Since we can't use `if constexpr`, just make the expression compile + // when this path is not taken. + using TypeToUse = + typename std::conditional<std::is_trivially_destructible<U>::value, + char, U>::type; + total_.template Get<TypeToUse>() += array_size; + } + } + + template <typename U> + U* AllocateArray(int array_size) { + constexpr bool trivial = std::is_trivially_destructible<U>::value; + using TypeToUse = typename std::conditional<trivial, char, U>::type; + + // We can only allocate after FinalizePlanning has been called. + GOOGLE_CHECK(has_allocated()); + + TypeToUse*& data = pointers_.template Get<TypeToUse>(); + int& used = used_.template Get<TypeToUse>(); + U* res = reinterpret_cast<U*>(data + used); + used += trivial ? RoundUpTo<8>(array_size * sizeof(U)) : array_size; + GOOGLE_CHECK_LE(used, total_.template Get<TypeToUse>()); + return res; + } + + template <typename... In> + const std::string* AllocateStrings(In&&... in) { + std::string* strings = AllocateArray<std::string>(sizeof...(in)); + std::string* res = strings; + Fold({(*strings++ = std::string(std::forward<In>(in)))...}); + return res; + } + + // Allocate all 5 names of the field: + // name, full name, lowercase, camelcase and json. + // It will dedup the strings when possible. + // The resulting array contains `name` at index 0, `full_name` at index 1 + // and the other 3 indices are specified in the result. + void PlanFieldNames(const std::string& name, + const std::string* opt_json_name) { + GOOGLE_CHECK(!has_allocated()); + + // Fast path for snake_case names, which follow the style guide. + if (opt_json_name == nullptr) { + switch (GetFieldNameCase(name)) { + case FieldNameCase::kAllLower: + // Case 1: they are all the same. + return PlanArray<std::string>(2); + case FieldNameCase::kSnakeCase: + // Case 2: name==lower, camel==json + return PlanArray<std::string>(3); + default: + break; + } + } + + std::string lowercase_name = name; + LowerString(&lowercase_name); + + std::string camelcase_name = ToCamelCase(name, /* lower_first = */ true); + std::string json_name = + opt_json_name != nullptr ? *opt_json_name : ToJsonName(name); + + StringPiece all_names[] = {name, lowercase_name, camelcase_name, + json_name}; + std::sort(all_names, all_names + 4); + int unique = + static_cast<int>(std::unique(all_names, all_names + 4) - all_names); + + PlanArray<std::string>(unique + 1); + } + + struct FieldNamesResult { + const std::string* array; + int lowercase_index; + int camelcase_index; + int json_index; + }; + FieldNamesResult AllocateFieldNames(const std::string& name, + const std::string& scope, + const std::string* opt_json_name) { + GOOGLE_CHECK(has_allocated()); + + std::string full_name = + scope.empty() ? name : StrCat(scope, ".", name); + + // Fast path for snake_case names, which follow the style guide. + if (opt_json_name == nullptr) { + switch (GetFieldNameCase(name)) { + case FieldNameCase::kAllLower: + // Case 1: they are all the same. + return {AllocateStrings(name, std::move(full_name)), 0, 0, 0}; + case FieldNameCase::kSnakeCase: + // Case 2: name==lower, camel==json + return {AllocateStrings(name, std::move(full_name), + ToCamelCase(name, /* lower_first = */ true)), + 0, 2, 2}; + default: + break; + } + } + + std::vector<std::string> names; + names.push_back(name); + names.push_back(std::move(full_name)); + + const auto push_name = [&](std::string new_name) { + for (size_t i = 0; i < names.size(); ++i) { + // Do not compare the full_name. It is unlikely to match, except in + // custom json_name. We are not taking this into account in + // PlanFieldNames so better to not try it. + if (i == 1) continue; + if (names[i] == new_name) return i; + } + names.push_back(std::move(new_name)); + return names.size() - 1; + }; + + FieldNamesResult result{nullptr, 0, 0, 0}; + + std::string lowercase_name = name; + LowerString(&lowercase_name); + result.lowercase_index = push_name(std::move(lowercase_name)); + result.camelcase_index = + push_name(ToCamelCase(name, /* lower_first = */ true)); + result.json_index = + push_name(opt_json_name != nullptr ? *opt_json_name : ToJsonName(name)); + + std::string* all_names = AllocateArray<std::string>(names.size()); + result.array = all_names; + std::move(names.begin(), names.end(), all_names); + + return result; + } + + template <typename Alloc> + void FinalizePlanning(Alloc& alloc) { + GOOGLE_CHECK(!has_allocated()); + + pointers_ = alloc->CreateFlatAlloc(total_)->Pointers(); + + GOOGLE_CHECK(has_allocated()); + } + + void ExpectConsumed() const { + // We verify that we consumed all the memory requested if there was no + // error in processing. + Fold({ExpectConsumed<T>()...}); + } + + private: + bool has_allocated() const { + return pointers_.template Get<char>() != nullptr; + } + + static bool IsLower(char c) { return 'a' <= c && c <= 'z'; } + static bool IsDigit(char c) { return '0' <= c && c <= '9'; } + static bool IsLowerOrDigit(char c) { return IsLower(c) || IsDigit(c); } + + enum class FieldNameCase { kAllLower, kSnakeCase, kOther }; + FieldNameCase GetFieldNameCase(const std::string& name) { + if (!IsLower(name[0])) return FieldNameCase::kOther; + FieldNameCase best = FieldNameCase::kAllLower; + for (char c : name) { + if (IsLowerOrDigit(c)) { + // nothing to do + } else if (c == '_') { + best = FieldNameCase::kSnakeCase; + } else { + return FieldNameCase::kOther; + } + } + return best; + } + + template <typename U> + bool ExpectConsumed() const { + GOOGLE_CHECK_EQ(total_.template Get<U>(), used_.template Get<U>()); + return true; + } + + TypeMap<PointerT, T...> pointers_; + TypeMap<IntT, T...> total_; + TypeMap<IntT, T...> used_; +}; + +} // namespace + class Symbol { public: enum Type { @@ -89,11 +573,17 @@ class Symbol { ENUM_VALUE_OTHER_PARENT, SERVICE, METHOD, - PACKAGE, + FULL_PACKAGE, + SUB_PACKAGE, QUERY_KEY }; - Symbol() : ptr_(nullptr) {} + Symbol() { + static constexpr internal::SymbolBase null_symbol{}; + static_assert(null_symbol.symbol_type_ == NULL_SYMBOL, ""); + // Initialize with a sentinel to make sure `ptr_` is never null. + ptr_ = &null_symbol; + } // Every object we store derives from internal::SymbolBase, where we store the // symbol type enum. @@ -113,15 +603,16 @@ class Symbol { DEFINE_MEMBERS(EnumDescriptor, ENUM, enum_descriptor) DEFINE_MEMBERS(ServiceDescriptor, SERVICE, service_descriptor) DEFINE_MEMBERS(MethodDescriptor, METHOD, method_descriptor) + DEFINE_MEMBERS(FileDescriptor, FULL_PACKAGE, file_descriptor) - // We use a special node for FileDescriptor. + // We use a special node for subpackage FileDescriptor. // It is potentially added to the table with multiple different names, so we // need a separate place to put the name. - struct Package : internal::SymbolBase { - const std::string* name; + struct Subpackage : internal::SymbolBase { + int name_size; const FileDescriptor* file; }; - DEFINE_MEMBERS(Package, PACKAGE, package_file_descriptor) + DEFINE_MEMBERS(Subpackage, SUB_PACKAGE, sub_package_file_descriptor) // Enum values have two different parents. // We use two different identitied for the same object to determine the two @@ -153,23 +644,42 @@ class Symbol { // Not a real symbol. // Only used for heterogeneous lookups and never actually inserted in the // tables. + // TODO(b/215557658): If we templetize QueryKey on the expected object type we + // can skip the switches for the eq function altogether. struct QueryKey : internal::SymbolBase { StringPiece name; const void* parent; int field_number; + + // Adaptor functions to look like a Symbol to the comparators. + StringPiece full_name() const { return name; } + std::pair<const void*, int> parent_number_key() const { + return {parent, field_number}; + } + std::pair<const void*, StringPiece> parent_name_key() const { + return {parent, name}; + } }; - DEFINE_MEMBERS(QueryKey, QUERY_KEY, query_key); + // This constructor is implicit to allow for non-transparent lookups when + // necessary. + // For transparent lookup cases we query directly with the object without the + // type erasure layer. + Symbol(QueryKey& value) : ptr_(&value) { // NOLINT + value.symbol_type_ = QUERY_KEY; + } + const QueryKey* query_key() const { + return type() == QUERY_KEY ? static_cast<const QueryKey*>(ptr_) : nullptr; + } #undef DEFINE_MEMBERS - Type type() const { - return ptr_ == nullptr ? NULL_SYMBOL - : static_cast<Type>(ptr_->symbol_type_); - } + Type type() const { return static_cast<Type>(ptr_->symbol_type_); } bool IsNull() const { return type() == NULL_SYMBOL; } bool IsType() const { return type() == MESSAGE || type() == ENUM; } bool IsAggregate() const { - return type() == MESSAGE || type() == PACKAGE || type() == ENUM || - type() == SERVICE; + return IsType() || IsPackage() || type() == SERVICE; + } + bool IsPackage() const { + return type() == FULL_PACKAGE || type() == SUB_PACKAGE; } const FileDescriptor* GetFile() const { @@ -188,8 +698,10 @@ class Symbol { return service_descriptor()->file(); case METHOD: return method_descriptor()->service()->file(); - case PACKAGE: - return package_file_descriptor()->file; + case FULL_PACKAGE: + return file_descriptor(); + case SUB_PACKAGE: + return sub_package_file_descriptor()->file; default: return nullptr; } @@ -211,10 +723,13 @@ class Symbol { return service_descriptor()->full_name(); case METHOD: return method_descriptor()->full_name(); - case PACKAGE: - return *package_file_descriptor()->name; + case FULL_PACKAGE: + return file_descriptor()->package(); + case SUB_PACKAGE: + return StringPiece(sub_package_file_descriptor()->file->package()) + .substr(0, sub_package_file_descriptor()->name_size); case QUERY_KEY: - return query_key()->name; + return query_key()->full_name(); default: GOOGLE_CHECK(false); } @@ -249,7 +764,7 @@ class Symbol { case METHOD: return {method_descriptor()->service(), method_descriptor()->name()}; case QUERY_KEY: - return {query_key()->parent, query_key()->name}; + return query_key()->parent_name_key(); default: GOOGLE_CHECK(false); } @@ -265,7 +780,7 @@ class Symbol { return {enum_value_descriptor()->type(), enum_value_descriptor()->number()}; case QUERY_KEY: - return {query_key()->parent, query_key()->field_number}; + return query_key()->parent_number_key(); default: GOOGLE_CHECK(false); } @@ -369,58 +884,6 @@ const int FieldDescriptor::kLastReservedNumber; namespace { -// Note: I distrust ctype.h due to locales. -char ToUpper(char ch) { - return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch; -} - -char ToLower(char ch) { - return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch; -} - -std::string ToCamelCase(const std::string& input, bool lower_first) { - bool capitalize_next = !lower_first; - std::string result; - result.reserve(input.size()); - - for (char character : input) { - if (character == '_') { - capitalize_next = true; - } else if (capitalize_next) { - result.push_back(ToUpper(character)); - capitalize_next = false; - } else { - result.push_back(character); - } - } - - // Lower-case the first letter. - if (lower_first && !result.empty()) { - result[0] = ToLower(result[0]); - } - - return result; -} - -std::string ToJsonName(const std::string& input) { - bool capitalize_next = false; - std::string result; - result.reserve(input.size()); - - for (char character : input) { - if (character == '_') { - capitalize_next = true; - } else if (capitalize_next) { - result.push_back(ToUpper(character)); - capitalize_next = false; - } else { - result.push_back(character); - } - } - - return result; -} - std::string EnumValueToPascalCase(const std::string& input) { bool next_upper = true; std::string result; @@ -560,15 +1023,19 @@ struct PointerStringPairHash { }; -const Symbol kNullSymbol; - struct SymbolByFullNameHash { - size_t operator()(Symbol s) const { + using is_transparent = void; + + template <typename T> + size_t operator()(const T& s) const { return HASH_FXN<StringPiece>{}(s.full_name()); } }; struct SymbolByFullNameEq { - bool operator()(Symbol a, Symbol b) const { + using is_transparent = void; + + template <typename T, typename U> + bool operator()(const T& a, const U& b) const { return a.full_name() == b.full_name(); } }; @@ -576,12 +1043,18 @@ using SymbolsByNameSet = HASH_SET<Symbol, SymbolByFullNameHash, SymbolByFullNameEq>; struct SymbolByParentHash { - size_t operator()(Symbol s) const { + using is_transparent = void; + + template <typename T> + size_t operator()(const T& s) const { return PointerStringPairHash{}(s.parent_name_key()); } }; struct SymbolByParentEq { - bool operator()(Symbol a, Symbol b) const { + using is_transparent = void; + + template <typename T, typename U> + bool operator()(const T& a, const U& b) const { return a.parent_name_key() == b.parent_name_key(); } }; @@ -597,13 +1070,19 @@ typedef HASH_MAP<PointerStringPair, const FieldDescriptor*, FieldsByNameMap; struct FieldsByNumberHash { - size_t operator()(Symbol s) const { + using is_transparent = void; + + template <typename T> + size_t operator()(const T& s) const { return PointerIntegerPairHash<std::pair<const void*, int>>{}( s.parent_number_key()); } }; struct FieldsByNumberEq { - bool operator()(Symbol a, Symbol b) const { + using is_transparent = void; + + template <typename T, typename U> + bool operator()(const T& a, const U& b) const { return a.parent_number_key() == b.parent_number_key(); } }; @@ -623,8 +1102,9 @@ typedef HASH_MAP<std::string, const SourceCodeInfo_Location*> std::set<std::string>* NewAllowedProto3Extendee() { auto allowed_proto3_extendees = new std::set<std::string>; const char* kOptionNames[] = { - "FileOptions", "MessageOptions", "FieldOptions", "EnumOptions", - "EnumValueOptions", "ServiceOptions", "MethodOptions", "OneofOptions"}; + "FileOptions", "MessageOptions", "FieldOptions", + "EnumOptions", "EnumValueOptions", "ServiceOptions", + "MethodOptions", "OneofOptions", "ExtensionRangeOptions"}; for (const char* option_name : kOptionNames) { // descriptor.proto has a different package name in opensource. We allow // both so the opensource protocol compiler can also compile internal @@ -648,405 +1128,125 @@ bool AllowedExtendeeInProto3(const std::string& name) { return allowed_proto3_extendees->find(name) != allowed_proto3_extendees->end(); } +} // anonymous namespace -// This bump allocator arena is optimized for the use case of this file. It is -// mostly optimized for memory usage, since these objects are expected to live -// for the entirety of the program. +// Contains tables specific to a particular file. These tables are not +// modified once the file has been constructed, so they need not be +// protected by a mutex. This makes operations that depend only on the +// contents of a single file -- e.g. Descriptor::FindFieldByName() -- +// lock-free. // -// Some differences from other arenas: -// - It has a fixed number of non-trivial types it can hold. This allows -// tracking the allocations with a single byte. In contrast, google::protobuf::Arena -// uses 16 bytes per non-trivial object created. -// - It has some extra metadata for rollbacks. This is necessary for -// implementing the API below. This metadata is flushed at the end and would -// not cause persistent memory usage. -// - It tries to squeeze every byte of out the blocks. If an allocation is too -// large for the current block we move the block to a secondary area where we -// can still use it for smaller objects. This complicates rollback logic but -// makes it much more memory efficient. -// -// The allocation strategy is as follows: -// - Memory is allocated from the front, with a forced 8 byte alignment. -// - Metadata is allocated from the back, one byte per element. -// - The metadata encodes one of two things: -// * For types we want to track, the index into KnownTypes. -// * For raw memory blocks, the size of the block (in 8 byte increments -// to allow for a larger limit). -// - When the raw data is too large to represent in the metadata byte, we -// allocate this memory separately in the heap and store an OutOfLineAlloc -// object instead. These come from large array allocations and alike. -// -// Blocks are kept in 3 areas: -// - `current_` is the one we are currently allocating from. When we need to -// allocate a block that doesn't fit there, we make a new block and move the -// old `current_` to one of the areas below. -// - Blocks that have no more usable space left (ie less than 9 bytes) are -// stored in `full_blocks_`. -// - Blocks that have some usable space are categorized in -// `small_size_blocks_` depending on how much space they have left. -// See `kSmallSizes` to see which sizes we track. -// -class TableArena { +// For historical reasons, the definitions of the methods of +// FileDescriptorTables and DescriptorPool::Tables are interleaved below. +// These used to be a single class. +class FileDescriptorTables { public: - // Allocate a block on `n` bytes, with no destructor information saved. - void* AllocateMemory(uint32_t n) { - uint32_t tag = SizeToRawTag(n) + kFirstRawTag; - if (tag > 255) { - // We can't fit the size, use an OutOfLineAlloc. - return Create<OutOfLineAlloc>(OutOfLineAlloc{::operator new(n), n})->ptr; - } + FileDescriptorTables(); + ~FileDescriptorTables(); - return AllocRawInternal(n, static_cast<Tag>(tag)); - } + // Empty table, used with placeholder files. + inline static const FileDescriptorTables& GetEmptyInstance(); - // Allocate and construct an element of type `T` as if by - // `T(std::forward<Args>(args...))`. - // The object is registered for destruction, if its destructor is not trivial. - template <typename T, typename... Args> - T* Create(Args&&... args) { - static_assert(alignof(T) <= 8, ""); - return ::new (AllocRawInternal(sizeof(T), TypeTag<T>(KnownTypes{}))) - T(std::forward<Args>(args)...); - } + // ----------------------------------------------------------------- + // Finding items. - TableArena() {} + // Returns a null Symbol (symbol.IsNull() is true) if not found. + inline Symbol FindNestedSymbol(const void* parent, + StringPiece name) const; - TableArena(const TableArena&) = delete; - TableArena& operator=(const TableArena&) = delete; + // These return nullptr if not found. + inline const FieldDescriptor* FindFieldByNumber(const Descriptor* parent, + int number) const; + inline const FieldDescriptor* FindFieldByLowercaseName( + const void* parent, StringPiece lowercase_name) const; + inline const FieldDescriptor* FindFieldByCamelcaseName( + const void* parent, StringPiece camelcase_name) const; + inline const EnumValueDescriptor* FindEnumValueByNumber( + const EnumDescriptor* parent, int number) const; + // This creates a new EnumValueDescriptor if not found, in a thread-safe way. + inline const EnumValueDescriptor* FindEnumValueByNumberCreatingIfUnknown( + const EnumDescriptor* parent, int number) const; - ~TableArena() { - // Uncomment this to debug usage statistics of the arena blocks. - // PrintUsageInfo(); + // ----------------------------------------------------------------- + // Adding items. - for (Block* list : GetLists()) { - while (list != nullptr) { - Block* b = list; - list = list->next; - b->VisitBlock(DestroyVisitor{}); - b->Destroy(); - } - } - } + // These add items to the corresponding tables. They return false if + // the key already exists in the table. + bool AddAliasUnderParent(const void* parent, const std::string& name, + Symbol symbol); + bool AddFieldByNumber(FieldDescriptor* field); + bool AddEnumValueByNumber(EnumValueDescriptor* value); + // Populates p->first->locations_by_path_ from p->second. + // Unusual signature dictated by internal::call_once. + static void BuildLocationsByPath( + std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p); - // This function exists for debugging only. - // It can be called from the destructor to dump some info in the tests to - // inspect the usage of the arena. - void PrintUsageInfo() const { - const auto print_histogram = [](Block* b, int size) { - std::map<uint32_t, uint32_t> unused_space_count; - int count = 0; - for (; b != nullptr; b = b->next) { - ++unused_space_count[b->space_left()]; - ++count; - } - if (size > 0) { - fprintf(stderr, " Blocks `At least %d`", size); - } else { - fprintf(stderr, " Blocks `full`"); - } - fprintf(stderr, ": %d blocks.\n", count); - for (auto p : unused_space_count) { - fprintf(stderr, " space=%4u, count=%3u\n", p.first, p.second); - } - }; + // Returns the location denoted by the specified path through info, + // or nullptr if not found. + // The value of info must be that of the corresponding FileDescriptor. + // (Conceptually a pure function, but stateful as an optimisation.) + const SourceCodeInfo_Location* GetSourceLocation( + const std::vector<int>& path, const SourceCodeInfo* info) const; - fprintf(stderr, "TableArena unused space histogram:\n"); - fprintf(stderr, " Current: %u\n", - current_ != nullptr ? current_->space_left() : 0); - print_histogram(full_blocks_, 0); - for (size_t i = 0; i < kSmallSizes.size(); ++i) { - print_histogram(small_size_blocks_[i], kSmallSizes[i]); - } - } - - // Current allocation count. - // This can be used for checkpointing. - size_t num_allocations() const { return num_allocations_; } - - // Rollback the latest allocations until we reach back to `checkpoint` - // num_allocations. - void RollbackTo(size_t checkpoint) { - while (num_allocations_ > checkpoint) { - GOOGLE_DCHECK(!rollback_info_.empty()); - auto& info = rollback_info_.back(); - Block* b = info.block; - - VisitAlloc(b->data(), &b->start_offset, &b->end_offset, DestroyVisitor{}, - KnownTypes{}); - if (--info.count == 0) { - rollback_info_.pop_back(); - } - --num_allocations_; - } - - // Reconstruct the lists and destroy empty blocks. - auto lists = GetLists(); - current_ = full_blocks_ = nullptr; - small_size_blocks_.fill(nullptr); - - for (Block* list : lists) { - while (list != nullptr) { - Block* b = list; - list = list->next; - - if (b->start_offset == 0) { - // This is empty, free it. - b->Destroy(); - } else { - RelocateToUsedList(b); - } - } - } - } - - // Clear all rollback information. Reduces memory usage. - // Trying to rollback past num_allocations() is now impossible. - void ClearRollbackData() { - rollback_info_.clear(); - rollback_info_.shrink_to_fit(); - } + // Must be called after BuildFileImpl(), even if the build failed and + // we are going to roll back to the last checkpoint. + void FinalizeTables(); private: - static constexpr size_t RoundUp(size_t n) { return (n + 7) & ~7; } + const void* FindParentForFieldsByMap(const FieldDescriptor* field) const; + static void FieldsByLowercaseNamesLazyInitStatic( + const FileDescriptorTables* tables); + void FieldsByLowercaseNamesLazyInitInternal() const; + static void FieldsByCamelcaseNamesLazyInitStatic( + const FileDescriptorTables* tables); + void FieldsByCamelcaseNamesLazyInitInternal() const; - using Tag = unsigned char; + SymbolsByParentSet symbols_by_parent_; + mutable internal::once_flag fields_by_lowercase_name_once_; + mutable internal::once_flag fields_by_camelcase_name_once_; + // Make these fields atomic to avoid race conditions with + // GetEstimatedOwnedMemoryBytesSize. Once the pointer is set the map won't + // change anymore. + mutable std::atomic<const FieldsByNameMap*> fields_by_lowercase_name_{}; + mutable std::atomic<const FieldsByNameMap*> fields_by_camelcase_name_{}; + FieldsByNumberSet fields_by_number_; // Not including extensions. + EnumValuesByNumberSet enum_values_by_number_; + mutable EnumValuesByNumberSet unknown_enum_values_by_number_ + PROTOBUF_GUARDED_BY(unknown_enum_values_mu_); - void* AllocRawInternal(uint32_t size, Tag tag) { - GOOGLE_DCHECK_GT(size, 0); - size = RoundUp(size); + // Populated on first request to save space, hence constness games. + mutable internal::once_flag locations_by_path_once_; + mutable LocationsByPathMap locations_by_path_; - Block* to_relocate = nullptr; - Block* to_use = nullptr; - - for (size_t i = 0; i < kSmallSizes.size(); ++i) { - if (small_size_blocks_[i] != nullptr && size <= kSmallSizes[i]) { - to_use = to_relocate = PopBlock(small_size_blocks_[i]); - break; - } - } - - if (to_relocate != nullptr) { - // We found one in the loop. - } else if (current_ != nullptr && size + 1 <= current_->space_left()) { - to_use = current_; - } else { - // No space left anywhere, make a new block. - to_relocate = current_; - // For now we hardcode the size to one page. Note that the maximum we can - // allocate in the block according to the limits of Tag is less than 2k, - // so this can fit anything that Tag can represent. - constexpr size_t kBlockSize = 4096; - to_use = current_ = ::new (::operator new(kBlockSize)) Block(kBlockSize); - GOOGLE_DCHECK_GE(current_->space_left(), size + 1); - } - - ++num_allocations_; - if (!rollback_info_.empty() && rollback_info_.back().block == to_use) { - ++rollback_info_.back().count; - } else { - rollback_info_.push_back({to_use, 1}); - } - - void* p = to_use->Allocate(size, tag); - if (to_relocate != nullptr) { - RelocateToUsedList(to_relocate); - } - return p; - } - - static void OperatorDelete(void* p, size_t s) { -#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) - ::operator delete(p, s); -#else - ::operator delete(p); -#endif - } - - struct OutOfLineAlloc { - void* ptr; - uint32_t size; - }; - - template <typename... T> - struct TypeList { - static constexpr Tag kSize = static_cast<Tag>(sizeof...(T)); - }; - - template <typename T, typename Visitor> - static void RunVisitor(char* p, uint16_t* start, Visitor visit) { - *start -= RoundUp(sizeof(T)); - visit(reinterpret_cast<T*>(p + *start)); - } - - // Visit the allocation at the passed location. - // It updates start/end to be after the visited object. - // This allows visiting a whole block by calling the function in a loop. - template <typename Visitor, typename... T> - static void VisitAlloc(char* p, uint16_t* start, uint16_t* end, Visitor visit, - TypeList<T...>) { - const Tag tag = static_cast<Tag>(p[*end]); - if (tag >= kFirstRawTag) { - // Raw memory. Skip it. - *start -= TagToSize(tag); - } else { - using F = void (*)(char*, uint16_t*, Visitor); - static constexpr F kFuncs[] = {&RunVisitor<T, Visitor>...}; - kFuncs[tag](p, start, visit); - } - ++*end; - } - - template <typename U, typename... Ts> - static constexpr Tag TypeTag(TypeList<U, Ts...>) { - return 0; - } - - template < - typename U, typename T, typename... Ts, - typename = typename std::enable_if<!std::is_same<U, T>::value>::type> - static constexpr Tag TypeTag(TypeList<T, Ts...>) { - return 1 + TypeTag<U>(TypeList<Ts...>{}); - } - - template <typename U> - static constexpr Tag TypeTag(TypeList<>) { - static_assert(std::is_trivially_destructible<U>::value, ""); - return SizeToRawTag(sizeof(U)); - } - - using KnownTypes = - TypeList<OutOfLineAlloc, std::string, - // For name arrays - std::array<std::string, 2>, std::array<std::string, 3>, - std::array<std::string, 4>, std::array<std::string, 5>, - FileDescriptorTables, SourceCodeInfo, FileOptions, - MessageOptions, FieldOptions, ExtensionRangeOptions, - OneofOptions, EnumOptions, EnumValueOptions, ServiceOptions, - MethodOptions>; - static constexpr Tag kFirstRawTag = KnownTypes::kSize; - - - struct DestroyVisitor { - template <typename T> - void operator()(T* p) { - p->~T(); - } - void operator()(OutOfLineAlloc* p) { OperatorDelete(p->ptr, p->size); } - }; - - static uint32_t SizeToRawTag(size_t n) { return (RoundUp(n) / 8) - 1; } - - static uint32_t TagToSize(Tag tag) { - GOOGLE_DCHECK_GE(tag, kFirstRawTag); - return static_cast<uint32_t>(tag - kFirstRawTag + 1) * 8; - } - - struct Block { - uint16_t start_offset; - uint16_t end_offset; - uint16_t capacity; - Block* next; - - // `allocated_size` is the total size of the memory block allocated. - // The `Block` structure is constructed at the start and the rest of the - // memory is used as the payload of the `Block`. - explicit Block(uint32_t allocated_size) { - start_offset = 0; - end_offset = capacity = - reinterpret_cast<char*>(this) + allocated_size - data(); - next = nullptr; - } - - char* data() { - return reinterpret_cast<char*>(this) + RoundUp(sizeof(Block)); - } - - uint32_t memory_used() { - return data() + capacity - reinterpret_cast<char*>(this); - } - uint32_t space_left() const { return end_offset - start_offset; } - - void* Allocate(uint32_t n, Tag tag) { - GOOGLE_DCHECK_LE(n + 1, space_left()); - void* p = data() + start_offset; - start_offset += n; - data()[--end_offset] = tag; - return p; - } - - void Destroy() { OperatorDelete(this, memory_used()); } - - void PrependTo(Block*& list) { - next = list; - list = this; - } - - template <typename Visitor> - void VisitBlock(Visitor visit) { - for (uint16_t s = start_offset, e = end_offset; s != 0;) { - VisitAlloc(data(), &s, &e, visit, KnownTypes{}); - } - } - }; - - Block* PopBlock(Block*& list) { - Block* res = list; - list = list->next; - return res; - } - - void RelocateToUsedList(Block* to_relocate) { - if (current_ == nullptr) { - current_ = to_relocate; - current_->next = nullptr; - return; - } else if (current_->space_left() < to_relocate->space_left()) { - std::swap(current_, to_relocate); - current_->next = nullptr; - } - - for (int i = kSmallSizes.size(); --i >= 0;) { - if (to_relocate->space_left() >= 1 + kSmallSizes[i]) { - to_relocate->PrependTo(small_size_blocks_[i]); - return; - } - } - - to_relocate->PrependTo(full_blocks_); - } - - static constexpr std::array<uint8_t, 6> kSmallSizes = { - {// Sizes for pointer arrays. - 8, 16, 24, 32, - // Sizes for string arrays (for descriptor names). - // The most common array sizes are 2 and 3. - 2 * sizeof(std::string), 3 * sizeof(std::string)}}; - - // Helper function to iterate all lists. - std::array<Block*, 2 + kSmallSizes.size()> GetLists() const { - std::array<Block*, 2 + kSmallSizes.size()> res; - res[0] = current_; - res[1] = full_blocks_; - std::copy(small_size_blocks_.begin(), small_size_blocks_.end(), &res[2]); - return res; - } - - Block* current_ = nullptr; - std::array<Block*, kSmallSizes.size()> small_size_blocks_ = {{}}; - Block* full_blocks_ = nullptr; - - size_t num_allocations_ = 0; - struct RollbackInfo { - Block* block; - size_t count; - }; - std::vector<RollbackInfo> rollback_info_; + // Mutex to protect the unknown-enum-value map due to dynamic + // EnumValueDescriptor creation on unknown values. + mutable internal::WrappedMutex unknown_enum_values_mu_; }; -constexpr std::array<uint8_t, 6> TableArena::kSmallSizes; +namespace internal { -} // anonymous namespace +// Small sequential allocator to be used within a single file. +// Most of the memory for a single FileDescriptor and everything under it is +// allocated in a single block of memory, with the FlatAllocator giving it out +// in parts later. +// The code first plans the total number of bytes needed by calling PlanArray +// with all the allocations that will happen afterwards, then calls +// FinalizePlanning passing the underlying allocator (the DescriptorPool::Tables +// instance), and then proceeds to get the memory via +// `AllocateArray`/`AllocateString` calls. The calls to PlanArray and +// The calls have to match between planning and allocating, though not +// necessarily in the same order. +class FlatAllocator + : public decltype(ApplyTypeList<FlatAllocatorImpl>( + SortByAlignment<char, std::string, SourceCodeInfo, + FileDescriptorTables, + // Option types + MessageOptions, FieldOptions, EnumOptions, + EnumValueOptions, ExtensionRangeOptions, OneofOptions, + ServiceOptions, MethodOptions, FileOptions>())) {}; + +} // namespace internal // =================================================================== // DescriptorPool::Tables @@ -1162,59 +1362,36 @@ class DescriptorPool::Tables { template <typename Type> Type* Allocate(); - // Allocate an array of objects which will be reclaimed when the - // pool in destroyed. Again, destructors are never called. - template <typename Type> - Type* AllocateArray(int count); + // Allocate some bytes which will be reclaimed when the pool is + // destroyed. Memory is aligned to 8 bytes. + void* AllocateBytes(int size); - // Allocate a string which will be destroyed when the pool is destroyed. - // The string is initialized to the given value for convenience. - const std::string* AllocateString(StringPiece value); + // Create a FlatAllocation for the corresponding sizes. + // All objects within it will be default constructed. + // The whole allocation, including the non-trivial objects within, will be + // destroyed with the pool. + template <typename... T> + internal::FlatAllocator::Allocation* CreateFlatAlloc( + const TypeMap<IntT, T...>& sizes); - // Copy the input into a NUL terminated string whose lifetime is managed by - // the pool. - const char* Strdup(StringPiece value); - - // Allocates an array of strings which will be destroyed when the pool is - // destroyed. The array is initialized with the input values. - template <typename... In> - const std::string* AllocateStringArray(In&&... values); - - struct FieldNamesResult { - std::string* array; - int lowercase_index; - int camelcase_index; - int json_index; - }; - // Allocate all 5 names of the field: - // name, full name, lowercase, camelcase and json. - // This function will dedup the strings when possible. - // The resulting array contains `name` at index 0, `full_name` at index 1 and - // the other 3 indices are specified in the result. - FieldNamesResult AllocateFieldNames(const std::string& name, - const std::string& scope, - const std::string* opt_json_name); - - // Create an object that will be deleted when the pool is destroyed. - // The object is value initialized, and its destructor will be called if - // non-trivial. - template <typename Type> - Type* Create(); - - // Allocate a protocol message object. Some older versions of GCC have - // trouble understanding explicit template instantiations in some cases, so - // in those cases we have to pass a dummy pointer of the right type as the - // parameter instead of specifying the type explicitly. - template <typename Type> - Type* AllocateMessage(Type* dummy = nullptr); - - // Allocate a FileDescriptorTables object. - FileDescriptorTables* AllocateFileTables(); private: - // All other memory allocated in the pool. Must be first as other objects can + // All memory allocated in the pool. Must be first as other objects can // point into these. - TableArena arena_; + struct MiscDeleter { + void operator()(int* p) const { internal::SizedDelete(p, *p + 8); } + }; + // Miscellaneous allocations are length prefixed. The paylaod is 8 bytes after + // the `int` that contains the size. This keeps the payload aligned. + std::vector<std::unique_ptr<int, MiscDeleter>> misc_allocs_; + struct FlatAllocDeleter { + void operator()(internal::FlatAllocator::Allocation* p) const { + p->Destroy(); + } + }; + std::vector< + std::unique_ptr<internal::FlatAllocator::Allocation, FlatAllocDeleter>> + flat_allocs_; SymbolsByNameSet symbols_by_name_; FilesByNameMap files_by_name_; @@ -1222,125 +1399,26 @@ class DescriptorPool::Tables { struct CheckPoint { explicit CheckPoint(const Tables* tables) - : arena_before_checkpoint(tables->arena_.num_allocations()), + : flat_allocations_before_checkpoint( + static_cast<int>(tables->flat_allocs_.size())), + misc_allocations_before_checkpoint( + static_cast<int>(tables->misc_allocs_.size())), pending_symbols_before_checkpoint( tables->symbols_after_checkpoint_.size()), pending_files_before_checkpoint( tables->files_after_checkpoint_.size()), pending_extensions_before_checkpoint( tables->extensions_after_checkpoint_.size()) {} - int arena_before_checkpoint; + int flat_allocations_before_checkpoint; + int misc_allocations_before_checkpoint; int pending_symbols_before_checkpoint; int pending_files_before_checkpoint; int pending_extensions_before_checkpoint; }; std::vector<CheckPoint> checkpoints_; - std::vector<const char*> symbols_after_checkpoint_; - std::vector<const char*> files_after_checkpoint_; + std::vector<Symbol> symbols_after_checkpoint_; + std::vector<const FileDescriptor*> files_after_checkpoint_; std::vector<DescriptorIntPair> extensions_after_checkpoint_; - - // Allocate some bytes which will be reclaimed when the pool is - // destroyed. - void* AllocateBytes(int size); -}; - -// Contains tables specific to a particular file. These tables are not -// modified once the file has been constructed, so they need not be -// protected by a mutex. This makes operations that depend only on the -// contents of a single file -- e.g. Descriptor::FindFieldByName() -- -// lock-free. -// -// For historical reasons, the definitions of the methods of -// FileDescriptorTables and DescriptorPool::Tables are interleaved below. -// These used to be a single class. -class FileDescriptorTables { - public: - FileDescriptorTables(); - ~FileDescriptorTables(); - - // Empty table, used with placeholder files. - inline static const FileDescriptorTables& GetEmptyInstance(); - - // ----------------------------------------------------------------- - // Finding items. - - // Returns a null Symbol (symbol.IsNull() is true) if not found. - inline Symbol FindNestedSymbol(const void* parent, - StringPiece name) const; - - // These return nullptr if not found. - inline const FieldDescriptor* FindFieldByNumber(const Descriptor* parent, - int number) const; - inline const FieldDescriptor* FindFieldByLowercaseName( - const void* parent, StringPiece lowercase_name) const; - inline const FieldDescriptor* FindFieldByCamelcaseName( - const void* parent, StringPiece camelcase_name) const; - inline const EnumValueDescriptor* FindEnumValueByNumber( - const EnumDescriptor* parent, int number) const; - // This creates a new EnumValueDescriptor if not found, in a thread-safe way. - inline const EnumValueDescriptor* FindEnumValueByNumberCreatingIfUnknown( - const EnumDescriptor* parent, int number) const; - - // ----------------------------------------------------------------- - // Adding items. - - // These add items to the corresponding tables. They return false if - // the key already exists in the table. For AddAliasUnderParent(), the - // string passed in must be one that was constructed using AllocateString(), - // as it will be used as a key in the symbols_by_parent_ map without copying. - bool AddAliasUnderParent(const void* parent, const std::string& name, - Symbol symbol); - bool AddFieldByNumber(FieldDescriptor* field); - bool AddEnumValueByNumber(EnumValueDescriptor* value); - - // Adds the field to the lowercase_name and camelcase_name maps. Never - // fails because we allow duplicates; the first field by the name wins. - void AddFieldByStylizedNames(const FieldDescriptor* field); - - // Populates p->first->locations_by_path_ from p->second. - // Unusual signature dictated by internal::call_once. - static void BuildLocationsByPath( - std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p); - - // Returns the location denoted by the specified path through info, - // or nullptr if not found. - // The value of info must be that of the corresponding FileDescriptor. - // (Conceptually a pure function, but stateful as an optimisation.) - const SourceCodeInfo_Location* GetSourceLocation( - const std::vector<int>& path, const SourceCodeInfo* info) const; - - // Must be called after BuildFileImpl(), even if the build failed and - // we are going to roll back to the last checkpoint. - void FinalizeTables(); - - private: - const void* FindParentForFieldsByMap(const FieldDescriptor* field) const; - static void FieldsByLowercaseNamesLazyInitStatic( - const FileDescriptorTables* tables); - void FieldsByLowercaseNamesLazyInitInternal() const; - static void FieldsByCamelcaseNamesLazyInitStatic( - const FileDescriptorTables* tables); - void FieldsByCamelcaseNamesLazyInitInternal() const; - - SymbolsByParentSet symbols_by_parent_; - mutable FieldsByNameMap fields_by_lowercase_name_; - std::unique_ptr<FieldsByNameMap> fields_by_lowercase_name_tmp_; - mutable internal::once_flag fields_by_lowercase_name_once_; - mutable FieldsByNameMap fields_by_camelcase_name_; - std::unique_ptr<FieldsByNameMap> fields_by_camelcase_name_tmp_; - mutable internal::once_flag fields_by_camelcase_name_once_; - FieldsByNumberSet fields_by_number_; // Not including extensions. - EnumValuesByNumberSet enum_values_by_number_; - mutable EnumValuesByNumberSet unknown_enum_values_by_number_ - PROTOBUF_GUARDED_BY(unknown_enum_values_mu_); - - // Populated on first request to save space, hence constness games. - mutable internal::once_flag locations_by_path_once_; - mutable LocationsByPathMap locations_by_path_; - - // Mutex to protect the unknown-enum-value map due to dynamic - // EnumValueDescriptor creation on unknown values. - mutable internal::WrappedMutex unknown_enum_values_mu_; }; DescriptorPool::Tables::Tables() { @@ -1366,11 +1444,12 @@ DescriptorPool::Tables::Tables() { DescriptorPool::Tables::~Tables() { GOOGLE_DCHECK(checkpoints_.empty()); } -FileDescriptorTables::FileDescriptorTables() - : fields_by_lowercase_name_tmp_(new FieldsByNameMap()), - fields_by_camelcase_name_tmp_(new FieldsByNameMap()) {} +FileDescriptorTables::FileDescriptorTables() {} -FileDescriptorTables::~FileDescriptorTables() {} +FileDescriptorTables::~FileDescriptorTables() { + delete fields_by_lowercase_name_.load(std::memory_order_acquire); + delete fields_by_camelcase_name_.load(std::memory_order_acquire); +} inline const FileDescriptorTables& FileDescriptorTables::GetEmptyInstance() { static auto file_descriptor_tables = @@ -1391,7 +1470,6 @@ void DescriptorPool::Tables::ClearLastCheckpoint() { symbols_after_checkpoint_.clear(); files_after_checkpoint_.clear(); extensions_after_checkpoint_.clear(); - arena_.ClearRollbackData(); } } @@ -1401,13 +1479,11 @@ void DescriptorPool::Tables::RollbackToLastCheckpoint() { for (size_t i = checkpoint.pending_symbols_before_checkpoint; i < symbols_after_checkpoint_.size(); i++) { - Symbol::QueryKey name; - name.name = symbols_after_checkpoint_[i]; - symbols_by_name_.erase(Symbol(&name)); + symbols_by_name_.erase(symbols_after_checkpoint_[i]); } for (size_t i = checkpoint.pending_files_before_checkpoint; i < files_after_checkpoint_.size(); i++) { - files_by_name_.erase(files_after_checkpoint_[i]); + files_by_name_.erase(files_after_checkpoint_[i]->name()); } for (size_t i = checkpoint.pending_extensions_before_checkpoint; i < extensions_after_checkpoint_.size(); i++) { @@ -1420,7 +1496,8 @@ void DescriptorPool::Tables::RollbackToLastCheckpoint() { extensions_after_checkpoint_.resize( checkpoint.pending_extensions_before_checkpoint); - arena_.RollbackTo(checkpoint.arena_before_checkpoint); + flat_allocs_.resize(checkpoint.flat_allocations_before_checkpoint); + misc_allocs_.resize(checkpoint.misc_allocations_before_checkpoint); checkpoints_.pop_back(); } @@ -1429,8 +1506,8 @@ void DescriptorPool::Tables::RollbackToLastCheckpoint() { inline Symbol DescriptorPool::Tables::FindSymbol(StringPiece key) const { Symbol::QueryKey name; name.name = key; - auto it = symbols_by_name_.find(Symbol(&name)); - return it == symbols_by_name_.end() ? kNullSymbol : *it; + auto it = symbols_by_name_.find(name); + return it == symbols_by_name_.end() ? Symbol() : *it; } inline Symbol FileDescriptorTables::FindNestedSymbol( @@ -1438,8 +1515,8 @@ inline Symbol FileDescriptorTables::FindNestedSymbol( Symbol::QueryKey query; query.name = name; query.parent = parent; - auto it = symbols_by_parent_.find(Symbol(&query)); - return it == symbols_by_parent_.end() ? kNullSymbol : *it; + auto it = symbols_by_parent_.find(query); + return it == symbols_by_parent_.end() ? Symbol() : *it; } Symbol DescriptorPool::Tables::FindByNameHelper(const DescriptorPool* pool, @@ -1492,7 +1569,7 @@ inline const FieldDescriptor* FileDescriptorTables::FindFieldByNumber( query.parent = parent; query.field_number = number; - auto it = fields_by_number_.find(Symbol(&query)); + auto it = fields_by_number_.find(query); return it == fields_by_number_.end() ? nullptr : it->field_descriptor(); } @@ -1515,13 +1592,14 @@ void FileDescriptorTables::FieldsByLowercaseNamesLazyInitStatic( } void FileDescriptorTables::FieldsByLowercaseNamesLazyInitInternal() const { + auto* map = new FieldsByNameMap; for (Symbol symbol : symbols_by_parent_) { const FieldDescriptor* field = symbol.field_descriptor(); if (!field) continue; - PointerStringPair lowercase_key(FindParentForFieldsByMap(field), - field->lowercase_name().c_str()); - InsertIfNotPresent(&fields_by_lowercase_name_, lowercase_key, field); + (*map)[{FindParentForFieldsByMap(field), field->lowercase_name().c_str()}] = + field; } + fields_by_lowercase_name_.store(map, std::memory_order_release); } inline const FieldDescriptor* FileDescriptorTables::FindFieldByLowercaseName( @@ -1529,8 +1607,9 @@ inline const FieldDescriptor* FileDescriptorTables::FindFieldByLowercaseName( internal::call_once( fields_by_lowercase_name_once_, &FileDescriptorTables::FieldsByLowercaseNamesLazyInitStatic, this); - return FindPtrOrNull(fields_by_lowercase_name_, - PointerStringPair(parent, lowercase_name)); + return FindPtrOrNull( + *fields_by_lowercase_name_.load(std::memory_order_acquire), + PointerStringPair(parent, lowercase_name)); } void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic( @@ -1539,13 +1618,14 @@ void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic( } void FileDescriptorTables::FieldsByCamelcaseNamesLazyInitInternal() const { + auto* map = new FieldsByNameMap; for (Symbol symbol : symbols_by_parent_) { const FieldDescriptor* field = symbol.field_descriptor(); if (!field) continue; - PointerStringPair camelcase_key(FindParentForFieldsByMap(field), - field->camelcase_name().c_str()); - InsertIfNotPresent(&fields_by_camelcase_name_, camelcase_key, field); + (*map)[{FindParentForFieldsByMap(field), field->camelcase_name().c_str()}] = + field; } + fields_by_camelcase_name_.store(map, std::memory_order_release); } inline const FieldDescriptor* FileDescriptorTables::FindFieldByCamelcaseName( @@ -1553,8 +1633,9 @@ inline const FieldDescriptor* FileDescriptorTables::FindFieldByCamelcaseName( internal::call_once( fields_by_camelcase_name_once_, FileDescriptorTables::FieldsByCamelcaseNamesLazyInitStatic, this); - return FindPtrOrNull(fields_by_camelcase_name_, - PointerStringPair(parent, camelcase_name)); + return FindPtrOrNull( + *fields_by_camelcase_name_.load(std::memory_order_acquire), + PointerStringPair(parent, camelcase_name)); } inline const EnumValueDescriptor* FileDescriptorTables::FindEnumValueByNumber( @@ -1571,7 +1652,7 @@ inline const EnumValueDescriptor* FileDescriptorTables::FindEnumValueByNumber( query.parent = parent; query.field_number = number; - auto it = enum_values_by_number_.find(Symbol(&query)); + auto it = enum_values_by_number_.find(query); return it == enum_values_by_number_.end() ? nullptr : it->enum_value_descriptor(); } @@ -1594,7 +1675,7 @@ FileDescriptorTables::FindEnumValueByNumberCreatingIfUnknown( // Second try, with reader lock held on unknown enum values: common case. { ReaderMutexLock l(&unknown_enum_values_mu_); - auto it = unknown_enum_values_by_number_.find(Symbol(&query)); + auto it = unknown_enum_values_by_number_.find(query); if (it != unknown_enum_values_by_number_.end() && it->enum_value_descriptor() != nullptr) { return it->enum_value_descriptor(); @@ -1604,7 +1685,7 @@ FileDescriptorTables::FindEnumValueByNumberCreatingIfUnknown( // necessary. { WriterMutexLock l(&unknown_enum_values_mu_); - auto it = unknown_enum_values_by_number_.find(Symbol(&query)); + auto it = unknown_enum_values_by_number_.find(query); if (it != unknown_enum_values_by_number_.end() && it->enum_value_descriptor() != nullptr) { return it->enum_value_descriptor(); @@ -1614,19 +1695,23 @@ FileDescriptorTables::FindEnumValueByNumberCreatingIfUnknown( // EnumDescriptor (it's not a part of the enum as originally defined), but // we do insert it into the table so that we can return the same pointer // later. - std::string enum_value_name = StringPrintf("UNKNOWN_ENUM_VALUE_%s_%d", - parent->name().c_str(), number); + std::string enum_value_name = StringPrintf( + "UNKNOWN_ENUM_VALUE_%s_%d", parent->name().c_str(), number); auto* pool = DescriptorPool::generated_pool(); auto* tables = const_cast<DescriptorPool::Tables*>(pool->tables_.get()); - EnumValueDescriptor* result; + internal::FlatAllocator alloc; + alloc.PlanArray<EnumValueDescriptor>(1); + alloc.PlanArray<std::string>(2); + { // Must lock the pool because we will do allocations in the shared arena. MutexLockMaybe l2(pool->mutex_); - result = tables->Allocate<EnumValueDescriptor>(); - result->all_names_ = tables->AllocateStringArray( - enum_value_name, - StrCat(parent->full_name(), ".", enum_value_name)); + alloc.FinalizePlanning(tables); } + EnumValueDescriptor* result = alloc.AllocateArray<EnumValueDescriptor>(1); + result->all_names_ = alloc.AllocateStrings( + enum_value_name, + StrCat(parent->full_name(), ".", enum_value_name)); result->number_ = number; result->type_ = parent; result->options_ = &EnumValueOptions::default_instance(); @@ -1656,7 +1741,7 @@ bool DescriptorPool::Tables::AddSymbol(const std::string& full_name, Symbol symbol) { GOOGLE_DCHECK_EQ(full_name, symbol.full_name()); if (symbols_by_name_.insert(symbol).second) { - symbols_after_checkpoint_.push_back(full_name.c_str()); + symbols_after_checkpoint_.push_back(symbol); return true; } else { return false; @@ -1673,46 +1758,14 @@ bool FileDescriptorTables::AddAliasUnderParent(const void* parent, bool DescriptorPool::Tables::AddFile(const FileDescriptor* file) { if (InsertIfNotPresent(&files_by_name_, file->name(), file)) { - files_after_checkpoint_.push_back(file->name().c_str()); + files_after_checkpoint_.push_back(file); return true; } else { return false; } } -void FileDescriptorTables::FinalizeTables() { - // Clean up the temporary maps used by AddFieldByStylizedNames(). - fields_by_lowercase_name_tmp_ = nullptr; - fields_by_camelcase_name_tmp_ = nullptr; -} - -void FileDescriptorTables::AddFieldByStylizedNames( - const FieldDescriptor* field) { - const void* parent = FindParentForFieldsByMap(field); - - // We want fields_by_{lower,camel}case_name_ to be lazily built, but - // cross-link order determines which entry will be present in the case of a - // conflict. So we use the temporary maps that get destroyed after - // BuildFileImpl() to detect the conflicts, and only store the conflicts in - // the map that will persist. We will then lazily populate the rest of the - // entries from fields_by_number_. - - PointerStringPair lowercase_key(parent, field->lowercase_name().c_str()); - if (!InsertIfNotPresent(fields_by_lowercase_name_tmp_.get(), - lowercase_key, field)) { - InsertIfNotPresent( - &fields_by_lowercase_name_, lowercase_key, - FindPtrOrNull(*fields_by_lowercase_name_tmp_, lowercase_key)); - } - - PointerStringPair camelcase_key(parent, field->camelcase_name().c_str()); - if (!InsertIfNotPresent(fields_by_camelcase_name_tmp_.get(), - camelcase_key, field)) { - InsertIfNotPresent( - &fields_by_camelcase_name_, camelcase_key, - FindPtrOrNull(*fields_by_camelcase_name_tmp_, camelcase_key)); - } -} +void FileDescriptorTables::FinalizeTables() {} bool FileDescriptorTables::AddFieldByNumber(FieldDescriptor* field) { // Skip fields that are at the start of the sequence. @@ -1754,123 +1807,35 @@ bool DescriptorPool::Tables::AddExtension(const FieldDescriptor* field) { template <typename Type> Type* DescriptorPool::Tables::Allocate() { - return reinterpret_cast<Type*>(AllocateBytes(sizeof(Type))); -} - -template <typename Type> -Type* DescriptorPool::Tables::AllocateArray(int count) { - return reinterpret_cast<Type*>(AllocateBytes(sizeof(Type) * count)); -} - -const std::string* DescriptorPool::Tables::AllocateString( - StringPiece value) { - return arena_.Create<std::string>(value); -} - -const char* DescriptorPool::Tables::Strdup(StringPiece value) { - char* p = AllocateArray<char>(static_cast<int>(value.size() + 1)); - memcpy(p, value.data(), value.size()); - p[value.size()] = 0; - return p; -} - -template <typename... In> -const std::string* DescriptorPool::Tables::AllocateStringArray(In&&... values) { - auto& array = *arena_.Create<std::array<std::string, sizeof...(In)>>(); - array = {{std::string(std::forward<In>(values))...}}; - return array.data(); -} - -DescriptorPool::Tables::FieldNamesResult -DescriptorPool::Tables::AllocateFieldNames(const std::string& name, - const std::string& scope, - const std::string* opt_json_name) { - std::string lowercase_name = name; - LowerString(&lowercase_name); - - std::string camelcase_name = ToCamelCase(name, /* lower_first = */ true); - std::string json_name; - if (opt_json_name != nullptr) { - json_name = *opt_json_name; - } else { - json_name = ToJsonName(name); - } - - const bool lower_eq_name = lowercase_name == name; - const bool camel_eq_name = camelcase_name == name; - const bool json_eq_name = json_name == name; - const bool json_eq_camel = json_name == camelcase_name; - - const int total_count = 2 + (lower_eq_name ? 0 : 1) + - (camel_eq_name ? 0 : 1) + - (json_eq_name || json_eq_camel ? 0 : 1); - FieldNamesResult result{nullptr, 0, 0, 0}; - // We use std::array to allow handling of the destruction of the strings. - switch (total_count) { - case 2: - result.array = arena_.Create<std::array<std::string, 2>>()->data(); - break; - case 3: - result.array = arena_.Create<std::array<std::string, 3>>()->data(); - break; - case 4: - result.array = arena_.Create<std::array<std::string, 4>>()->data(); - break; - case 5: - result.array = arena_.Create<std::array<std::string, 5>>()->data(); - break; - } - - result.array[0] = name; - if (scope.empty()) { - result.array[1] = name; - } else { - result.array[1] = StrCat(scope, ".", name); - } - int index = 2; - if (lower_eq_name) { - result.lowercase_index = 0; - } else { - result.lowercase_index = index; - result.array[index++] = std::move(lowercase_name); - } - - if (camel_eq_name) { - result.camelcase_index = 0; - } else { - result.camelcase_index = index; - result.array[index++] = std::move(camelcase_name); - } - - if (json_eq_name) { - result.json_index = 0; - } else if (json_eq_camel) { - result.json_index = result.camelcase_index; - } else { - result.json_index = index; - result.array[index] = std::move(json_name); - } - - return result; -} - -template <typename Type> -Type* DescriptorPool::Tables::Create() { - return arena_.Create<Type>(); -} - -template <typename Type> -Type* DescriptorPool::Tables::AllocateMessage(Type* /* dummy */) { - return arena_.Create<Type>(); -} - -FileDescriptorTables* DescriptorPool::Tables::AllocateFileTables() { - return arena_.Create<FileDescriptorTables>(); + static_assert(std::is_trivially_destructible<Type>::value, ""); + static_assert(alignof(Type) <= 8, ""); + return ::new (AllocateBytes(sizeof(Type))) Type{}; } void* DescriptorPool::Tables::AllocateBytes(int size) { if (size == 0) return nullptr; - return arena_.AllocateMemory(size); + void* p = ::operator new(size + RoundUpTo<8>(sizeof(int))); + int* sizep = static_cast<int*>(p); + misc_allocs_.emplace_back(sizep); + *sizep = size; + return static_cast<char*>(p) + RoundUpTo<8>(sizeof(int)); +} + +template <typename... T> +internal::FlatAllocator::Allocation* DescriptorPool::Tables::CreateFlatAlloc( + const TypeMap<IntT, T...>& sizes) { + auto ends = CalculateEnds(sizes); + using FlatAlloc = internal::FlatAllocator::Allocation; + + int last_end = ends.template Get< + typename std::tuple_element<sizeof...(T) - 1, std::tuple<T...>>::type>(); + size_t total_size = + last_end + RoundUpTo<FlatAlloc::kMaxAlign>(sizeof(FlatAlloc)); + char* data = static_cast<char*>(::operator new(total_size)); + auto* res = ::new (data) FlatAlloc(ends); + flat_allocs_.emplace_back(res); + + return res; } void FileDescriptorTables::BuildLocationsByPath( @@ -2469,7 +2434,7 @@ bool DescriptorPool::IsSubSymbolOfBuiltType(StringPiece name) const { Symbol symbol = tables_->FindSymbol(prefix); // If the symbol type is anything other than PACKAGE, then its complete // definition is already known. - if (!symbol.IsNull() && symbol.type() != Symbol::PACKAGE) { + if (!symbol.IsNull() && !symbol.IsPackage()) { return true; } } @@ -3532,7 +3497,6 @@ void MethodDescriptor::DebugString( comment_printer.AddPostComment(contents); } - // Location methods =============================================== bool FileDescriptor::GetSourceLocation(const std::vector<int>& path, @@ -3718,7 +3682,8 @@ class DescriptorBuilder { friend class OptionInterpreter; // Non-recursive part of BuildFile functionality. - FileDescriptor* BuildFileImpl(const FileDescriptorProto& proto); + FileDescriptor* BuildFileImpl(const FileDescriptorProto& proto, + internal::FlatAllocator& alloc); const DescriptorPool* pool_; DescriptorPool::Tables* tables_; // for convenience @@ -3735,6 +3700,29 @@ class DescriptorBuilder { FileDescriptorTables* file_tables_; std::set<const FileDescriptor*> dependencies_; + struct MessageHints { + int fields_to_suggest = 0; + const Message* first_reason = nullptr; + DescriptorPool::ErrorCollector::ErrorLocation first_reason_location = + DescriptorPool::ErrorCollector::ErrorLocation::OTHER; + + void RequestHintOnFieldNumbers( + const Message& reason, + DescriptorPool::ErrorCollector::ErrorLocation reason_location, + int range_start = 0, int range_end = 1) { + auto fit = [](int value) { + return std::min(std::max(value, 0), FieldDescriptor::kMaxNumber); + }; + fields_to_suggest = + fit(fields_to_suggest + fit(fit(range_end) - fit(range_start))); + if (first_reason) return; + first_reason = &reason; + first_reason_location = reason_location; + } + }; + + std::unordered_map<const Descriptor*, MessageHints> message_hints_; + // unused_dependency_ is used to record the unused imported files. // Note: public import is not considered. std::set<const FileDescriptor*> unused_dependency_; @@ -3754,6 +3742,13 @@ class DescriptorBuilder { // to report a more useful error message. std::string undefine_resolved_name_; + // Tracker for current recursion depth to implement recursion protection. + // + // Counts down to 0 when there is no depth remaining. + // + // Maximum recursion depth corresponds to 32 nested message declarations. + int recursion_depth_ = 32; + void AddError(const std::string& element_name, const Message& descriptor, DescriptorPool::ErrorCollector::ErrorLocation location, const std::string& error); @@ -3802,9 +3797,9 @@ class DescriptorBuilder { // Like FindSymbol(), but looks up the name relative to some other symbol // name. This first searches siblings of relative_to, then siblings of its - // parents, etc. For example, LookupSymbol("foo.bar", "baz.qux.corge") makes + // parents, etc. For example, LookupSymbol("foo.bar", "baz.moo.corge") makes // the following calls, returning the first non-null result: - // FindSymbol("baz.qux.foo.bar"), FindSymbol("baz.foo.bar"), + // FindSymbol("baz.moo.foo.bar"), FindSymbol("baz.foo.bar"), // FindSymbol("foo.bar"). If AllowUnknownDependencies() has been called // on the DescriptorPool, this will generate a placeholder type if // the name is not found (unless the name itself is malformed). The @@ -3847,13 +3842,6 @@ class DescriptorBuilder { void ValidateSymbolName(const std::string& name, const std::string& full_name, const Message& proto); - // Used by BUILD_ARRAY macro (below) to avoid having to have the type - // specified as a macro parameter. - template <typename Type> - inline void AllocateArray(int size, Type** output) { - *output = tables_->AllocateArray<Type>(size); - } - // Allocates a copy of orig_options in tables_ and stores it in the // descriptor. Remembers its uninterpreted options, to be interpreted // later. DescriptorT must be one of the Descriptor messages from @@ -3861,10 +3849,12 @@ class DescriptorBuilder { template <class DescriptorT> void AllocateOptions(const typename DescriptorT::OptionsType& orig_options, DescriptorT* descriptor, int options_field_tag, - const std::string& option_name); + const std::string& option_name, + internal::FlatAllocator& alloc); // Specialization for FileOptions. void AllocateOptions(const FileOptions& orig_options, - FileDescriptor* descriptor); + FileDescriptor* descriptor, + internal::FlatAllocator& alloc); // Implementation for AllocateOptions(). Don't call this directly. template <class DescriptorT> @@ -3872,52 +3862,57 @@ class DescriptorBuilder { const std::string& name_scope, const std::string& element_name, const typename DescriptorT::OptionsType& orig_options, DescriptorT* descriptor, const std::vector<int>& options_path, - const std::string& option_name); + const std::string& option_name, internal::FlatAllocator& alloc); // Allocates an array of two strings, the first one is a copy of `proto_name`, // and the second one is the full name. // Full proto name is "scope.proto_name" if scope is non-empty and // "proto_name" otherwise. const std::string* AllocateNameStrings(const std::string& scope, - const std::string& proto_name); + const std::string& proto_name, + internal::FlatAllocator& alloc); // These methods all have the same signature for the sake of the BUILD_ARRAY // macro, below. void BuildMessage(const DescriptorProto& proto, const Descriptor* parent, - Descriptor* result); + Descriptor* result, internal::FlatAllocator& alloc); void BuildFieldOrExtension(const FieldDescriptorProto& proto, Descriptor* parent, FieldDescriptor* result, - bool is_extension); + bool is_extension, internal::FlatAllocator& alloc); void BuildField(const FieldDescriptorProto& proto, Descriptor* parent, - FieldDescriptor* result) { - BuildFieldOrExtension(proto, parent, result, false); + FieldDescriptor* result, internal::FlatAllocator& alloc) { + BuildFieldOrExtension(proto, parent, result, false, alloc); } void BuildExtension(const FieldDescriptorProto& proto, Descriptor* parent, - FieldDescriptor* result) { - BuildFieldOrExtension(proto, parent, result, true); + FieldDescriptor* result, internal::FlatAllocator& alloc) { + BuildFieldOrExtension(proto, parent, result, true, alloc); } void BuildExtensionRange(const DescriptorProto::ExtensionRange& proto, const Descriptor* parent, - Descriptor::ExtensionRange* result); + Descriptor::ExtensionRange* result, + internal::FlatAllocator& alloc); void BuildReservedRange(const DescriptorProto::ReservedRange& proto, const Descriptor* parent, - Descriptor::ReservedRange* result); + Descriptor::ReservedRange* result, + internal::FlatAllocator& alloc); void BuildReservedRange(const EnumDescriptorProto::EnumReservedRange& proto, const EnumDescriptor* parent, - EnumDescriptor::ReservedRange* result); + EnumDescriptor::ReservedRange* result, + internal::FlatAllocator& alloc); void BuildOneof(const OneofDescriptorProto& proto, Descriptor* parent, - OneofDescriptor* result); + OneofDescriptor* result, internal::FlatAllocator& alloc); void CheckEnumValueUniqueness(const EnumDescriptorProto& proto, const EnumDescriptor* result); void BuildEnum(const EnumDescriptorProto& proto, const Descriptor* parent, - EnumDescriptor* result); + EnumDescriptor* result, internal::FlatAllocator& alloc); void BuildEnumValue(const EnumValueDescriptorProto& proto, - const EnumDescriptor* parent, - EnumValueDescriptor* result); + const EnumDescriptor* parent, EnumValueDescriptor* result, + internal::FlatAllocator& alloc); void BuildService(const ServiceDescriptorProto& proto, const void* dummy, - ServiceDescriptor* result); + ServiceDescriptor* result, internal::FlatAllocator& alloc); void BuildMethod(const MethodDescriptorProto& proto, - const ServiceDescriptor* parent, MethodDescriptor* result); + const ServiceDescriptor* parent, MethodDescriptor* result, + internal::FlatAllocator& alloc); void LogUnusedDependency(const FileDescriptorProto& proto, const FileDescriptor* result); @@ -3941,6 +3936,8 @@ class DescriptorBuilder { const ServiceDescriptorProto& proto); void CrossLinkMethod(MethodDescriptor* method, const MethodDescriptorProto& proto); + void SuggestFieldNumbers(FileDescriptor* file, + const FileDescriptorProto& proto); // Must be run only after cross-linking. void InterpretOptions(); @@ -4331,7 +4328,7 @@ Symbol DescriptorBuilder::FindSymbol(const std::string& name, bool build_it) { return result; } - if (result.type() == Symbol::PACKAGE) { + if (result.IsPackage()) { // Arg, this is overcomplicated. The symbol is a package name. It could // be that the package was defined in multiple files. result.GetFile() // returns the first file we saw that used this package. We've determined @@ -4350,7 +4347,7 @@ Symbol DescriptorBuilder::FindSymbol(const std::string& name, bool build_it) { possible_undeclared_dependency_ = file; possible_undeclared_dependency_name_ = name; - return kNullSymbol; + return Symbol(); } Symbol DescriptorBuilder::LookupSymbolNoPlaceholder( @@ -4478,7 +4475,7 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld( StringPiece placeholder_name; const std::string* placeholder_package; - if (!ValidateQualifiedName(name)) return kNullSymbol; + if (!ValidateQualifiedName(name)) return Symbol(); if (name[0] == '.') { // Fully-qualified. placeholder_full_name = name.substr(1); @@ -4486,30 +4483,47 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld( placeholder_full_name = name; } - std::string::size_type dotpos = placeholder_full_name.find_last_of('.'); + // Create the placeholders. + internal::FlatAllocator alloc; + alloc.PlanArray<FileDescriptor>(1); + alloc.PlanArray<std::string>(2); + if (placeholder_type == PLACEHOLDER_ENUM) { + alloc.PlanArray<EnumDescriptor>(1); + alloc.PlanArray<EnumValueDescriptor>(1); + alloc.PlanArray<std::string>(2); // names for the descriptor. + alloc.PlanArray<std::string>(2); // names for the value. + } else { + alloc.PlanArray<Descriptor>(1); + alloc.PlanArray<std::string>(2); // names for the descriptor. + if (placeholder_type == PLACEHOLDER_EXTENDABLE_MESSAGE) { + alloc.PlanArray<Descriptor::ExtensionRange>(1); + } + } + alloc.FinalizePlanning(tables_); + + const std::string::size_type dotpos = placeholder_full_name.find_last_of('.'); if (dotpos != std::string::npos) { placeholder_package = - tables_->AllocateString(placeholder_full_name.substr(0, dotpos)); + alloc.AllocateStrings(placeholder_full_name.substr(0, dotpos)); placeholder_name = placeholder_full_name.substr(dotpos + 1); } else { - placeholder_package = &internal::GetEmptyString(); + placeholder_package = alloc.AllocateStrings(""); placeholder_name = placeholder_full_name; } - // Create the placeholders. FileDescriptor* placeholder_file = NewPlaceholderFileWithMutexHeld( - StrCat(placeholder_full_name, ".placeholder.proto")); + StrCat(placeholder_full_name, ".placeholder.proto"), alloc); placeholder_file->package_ = placeholder_package; if (placeholder_type == PLACEHOLDER_ENUM) { placeholder_file->enum_type_count_ = 1; - placeholder_file->enum_types_ = tables_->AllocateArray<EnumDescriptor>(1); + placeholder_file->enum_types_ = alloc.AllocateArray<EnumDescriptor>(1); EnumDescriptor* placeholder_enum = &placeholder_file->enum_types_[0]; memset(static_cast<void*>(placeholder_enum), 0, sizeof(*placeholder_enum)); placeholder_enum->all_names_ = - tables_->AllocateStringArray(placeholder_name, placeholder_full_name); + alloc.AllocateStrings(placeholder_name, placeholder_full_name); placeholder_enum->file_ = placeholder_file; placeholder_enum->options_ = &EnumOptions::default_instance(); placeholder_enum->is_placeholder_ = true; @@ -4517,7 +4531,7 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld( // Enums must have at least one value. placeholder_enum->value_count_ = 1; - placeholder_enum->values_ = tables_->AllocateArray<EnumValueDescriptor>(1); + placeholder_enum->values_ = alloc.AllocateArray<EnumValueDescriptor>(1); // Disable fast-path lookup for this enum. placeholder_enum->sequential_value_limit_ = -1; @@ -4526,7 +4540,7 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld( sizeof(*placeholder_value)); // Note that enum value names are siblings of their type, not children. - placeholder_value->all_names_ = tables_->AllocateStringArray( + placeholder_value->all_names_ = alloc.AllocateStrings( "PLACEHOLDER_VALUE", placeholder_package->empty() ? "PLACEHOLDER_VALUE" : *placeholder_package + ".PLACEHOLDER_VALUE"); @@ -4538,14 +4552,14 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld( return Symbol(placeholder_enum); } else { placeholder_file->message_type_count_ = 1; - placeholder_file->message_types_ = tables_->AllocateArray<Descriptor>(1); + placeholder_file->message_types_ = alloc.AllocateArray<Descriptor>(1); Descriptor* placeholder_message = &placeholder_file->message_types_[0]; memset(static_cast<void*>(placeholder_message), 0, sizeof(*placeholder_message)); placeholder_message->all_names_ = - tables_->AllocateStringArray(placeholder_name, placeholder_full_name); + alloc.AllocateStrings(placeholder_name, placeholder_full_name); placeholder_message->file_ = placeholder_file; placeholder_message->options_ = &MessageOptions::default_instance(); placeholder_message->is_placeholder_ = true; @@ -4554,12 +4568,12 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld( if (placeholder_type == PLACEHOLDER_EXTENDABLE_MESSAGE) { placeholder_message->extension_range_count_ = 1; placeholder_message->extension_ranges_ = - tables_->AllocateArray<Descriptor::ExtensionRange>(1); - placeholder_message->extension_ranges_->start = 1; + alloc.AllocateArray<Descriptor::ExtensionRange>(1); + placeholder_message->extension_ranges_[0].start = 1; // kMaxNumber + 1 because ExtensionRange::end is exclusive. - placeholder_message->extension_ranges_->end = + placeholder_message->extension_ranges_[0].end = FieldDescriptor::kMaxNumber + 1; - placeholder_message->extension_ranges_->options_ = nullptr; + placeholder_message->extension_ranges_[0].options_ = nullptr; } return Symbol(placeholder_message); @@ -4569,18 +4583,23 @@ Symbol DescriptorPool::NewPlaceholderWithMutexHeld( FileDescriptor* DescriptorPool::NewPlaceholderFile( StringPiece name) const { MutexLockMaybe lock(mutex_); - return NewPlaceholderFileWithMutexHeld(name); + internal::FlatAllocator alloc; + alloc.PlanArray<FileDescriptor>(1); + alloc.PlanArray<std::string>(1); + alloc.FinalizePlanning(tables_); + + return NewPlaceholderFileWithMutexHeld(name, alloc); } FileDescriptor* DescriptorPool::NewPlaceholderFileWithMutexHeld( - StringPiece name) const { + StringPiece name, internal::FlatAllocator& alloc) const { if (mutex_) { mutex_->AssertHeld(); } - FileDescriptor* placeholder = tables_->Allocate<FileDescriptor>(); + FileDescriptor* placeholder = alloc.AllocateArray<FileDescriptor>(1); memset(static_cast<void*>(placeholder), 0, sizeof(*placeholder)); - placeholder->name_ = tables_->AllocateString(name); + placeholder->name_ = alloc.AllocateStrings(name); placeholder->package_ = &internal::GetEmptyString(); placeholder->pool_ = this; placeholder->options_ = &FileOptions::default_instance(); @@ -4654,13 +4673,17 @@ void DescriptorBuilder::AddPackage(const std::string& name, Symbol existing_symbol = tables_->FindSymbol(name); // It's OK to redefine a package. if (existing_symbol.IsNull()) { - auto* package = tables_->AllocateArray<Symbol::Package>(1); - // If the name is the package name, then it is already in the arena. - // If not, copy it there. It came from the call to AddPackage below. - package->name = - &name == &file->package() ? &name : tables_->AllocateString(name); - package->file = file; - tables_->AddSymbol(*package->name, Symbol(package)); + if (&name == &file->package()) { + // It is the toplevel package name, so insert the descriptor directly. + tables_->AddSymbol(file->package(), Symbol(file)); + } else { + auto* package = tables_->Allocate<Symbol::Subpackage>(); + // If the name is the package name, then it is already in the arena. + // If not, copy it there. It came from the call to AddPackage below. + package->name_size = static_cast<int>(name.size()); + package->file = file; + tables_->AddSymbol(name, Symbol(package)); + } // Also add parent package, if any. std::string::size_type dot_pos = name.find_last_of('.'); if (dot_pos == std::string::npos) { @@ -4671,13 +4694,14 @@ void DescriptorBuilder::AddPackage(const std::string& name, AddPackage(name.substr(0, dot_pos), proto, file); ValidateSymbolName(name.substr(dot_pos + 1), name, proto); } - } else if (existing_symbol.type() != Symbol::PACKAGE) { + } else if (!existing_symbol.IsPackage()) { // Symbol seems to have been defined in a different file. + const FileDescriptor* other_file = existing_symbol.GetFile(); AddError(name, proto, DescriptorPool::ErrorCollector::NAME, "\"" + name + "\" is already defined (as something other than " "a package) in file \"" + - existing_symbol.GetFile()->name() + "\"."); + (other_file == nullptr ? "null" : other_file->name()) + "\"."); } } @@ -4695,6 +4719,7 @@ void DescriptorBuilder::ValidateSymbolName(const std::string& name, (character < '0' || '9' < character) && (character != '_')) { AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME, "\"" + name + "\" is not a valid identifier."); + return; } } } @@ -4708,23 +4733,25 @@ template <class DescriptorT> void DescriptorBuilder::AllocateOptions( const typename DescriptorT::OptionsType& orig_options, DescriptorT* descriptor, int options_field_tag, - const std::string& option_name) { + const std::string& option_name, internal::FlatAllocator& alloc) { std::vector<int> options_path; descriptor->GetLocationPath(&options_path); options_path.push_back(options_field_tag); AllocateOptionsImpl(descriptor->full_name(), descriptor->full_name(), - orig_options, descriptor, options_path, option_name); + orig_options, descriptor, options_path, option_name, + alloc); } // We specialize for FileDescriptor. void DescriptorBuilder::AllocateOptions(const FileOptions& orig_options, - FileDescriptor* descriptor) { + FileDescriptor* descriptor, + internal::FlatAllocator& alloc) { std::vector<int> options_path; options_path.push_back(FileDescriptorProto::kOptionsFieldNumber); // We add the dummy token so that LookupSymbol does the right thing. AllocateOptionsImpl(descriptor->package() + ".dummy", descriptor->name(), orig_options, descriptor, options_path, - "google.protobuf.FileOptions"); + "google.protobuf.FileOptions", alloc); } template <class DescriptorT> @@ -4732,13 +4759,8 @@ void DescriptorBuilder::AllocateOptionsImpl( const std::string& name_scope, const std::string& element_name, const typename DescriptorT::OptionsType& orig_options, DescriptorT* descriptor, const std::vector<int>& options_path, - const std::string& option_name) { - // We need to use a dummy pointer to work around a bug in older versions of - // GCC. Otherwise, the following two lines could be replaced with: - // typename DescriptorT::OptionsType* options = - // tables_->AllocateMessage<typename DescriptorT::OptionsType>(); - typename DescriptorT::OptionsType* const dummy = nullptr; - typename DescriptorT::OptionsType* options = tables_->AllocateMessage(dummy); + const std::string& option_name, internal::FlatAllocator& alloc) { + auto* options = alloc.AllocateArray<typename DescriptorT::OptionsType>(1); if (!orig_options.IsInitialized()) { AddError(name_scope + "." + element_name, orig_options, @@ -4788,11 +4810,13 @@ void DescriptorBuilder::AllocateOptionsImpl( // A common pattern: We want to convert a repeated field in the descriptor // to an array of values, calling some method to build each value. -#define BUILD_ARRAY(INPUT, OUTPUT, NAME, METHOD, PARENT) \ - OUTPUT->NAME##_count_ = INPUT.NAME##_size(); \ - AllocateArray(INPUT.NAME##_size(), &OUTPUT->NAME##s_); \ - for (int i = 0; i < INPUT.NAME##_size(); i++) { \ - METHOD(INPUT.NAME(i), PARENT, OUTPUT->NAME##s_ + i); \ +#define BUILD_ARRAY(INPUT, OUTPUT, NAME, METHOD, PARENT) \ + OUTPUT->NAME##_count_ = INPUT.NAME##_size(); \ + OUTPUT->NAME##s_ = alloc.AllocateArray< \ + typename std::remove_pointer<decltype(OUTPUT->NAME##s_)>::type>( \ + INPUT.NAME##_size()); \ + for (int i = 0; i < INPUT.NAME##_size(); i++) { \ + METHOD(INPUT.NAME(i), PARENT, OUTPUT->NAME##s_ + i, alloc); \ } void DescriptorBuilder::AddRecursiveImportError( @@ -4848,6 +4872,130 @@ static bool ExistingFileMatchesProto(const FileDescriptor* existing_file, return existing_proto.SerializeAsString() == proto.SerializeAsString(); } +// These PlanAllocationSize functions will gather into the FlatAllocator all the +// necessary memory allocations that BuildXXX functions below will do on the +// Tables object. +// They *must* be kept in sync. If we miss some PlanArray call we won't have +// enough memory and will GOOGLE_CHECK-fail. +static void PlanAllocationSize( + const RepeatedPtrField<EnumValueDescriptorProto>& values, + internal::FlatAllocator& alloc) { + alloc.PlanArray<EnumValueDescriptor>(values.size()); + alloc.PlanArray<std::string>(2 * values.size()); // name + full_name + for (const auto& v : values) { + if (v.has_options()) alloc.PlanArray<EnumValueOptions>(1); + } +} + +static void PlanAllocationSize( + const RepeatedPtrField<EnumDescriptorProto>& enums, + internal::FlatAllocator& alloc) { + alloc.PlanArray<EnumDescriptor>(enums.size()); + alloc.PlanArray<std::string>(2 * enums.size()); // name + full_name + for (const auto& e : enums) { + if (e.has_options()) alloc.PlanArray<EnumOptions>(1); + PlanAllocationSize(e.value(), alloc); + alloc.PlanArray<EnumDescriptor::ReservedRange>(e.reserved_range_size()); + alloc.PlanArray<const std::string*>(e.reserved_name_size()); + alloc.PlanArray<std::string>(e.reserved_name_size()); + } +} + +static void PlanAllocationSize( + const RepeatedPtrField<OneofDescriptorProto>& oneofs, + internal::FlatAllocator& alloc) { + alloc.PlanArray<OneofDescriptor>(oneofs.size()); + alloc.PlanArray<std::string>(2 * oneofs.size()); // name + full_name + for (const auto& oneof : oneofs) { + if (oneof.has_options()) alloc.PlanArray<OneofOptions>(1); + } +} + +static void PlanAllocationSize( + const RepeatedPtrField<FieldDescriptorProto>& fields, + internal::FlatAllocator& alloc) { + alloc.PlanArray<FieldDescriptor>(fields.size()); + for (const auto& field : fields) { + if (field.has_options()) alloc.PlanArray<FieldOptions>(1); + alloc.PlanFieldNames(field.name(), + field.has_json_name() ? &field.json_name() : nullptr); + if (field.has_default_value() && field.has_type() && + (field.type() == FieldDescriptorProto::TYPE_STRING || + field.type() == FieldDescriptorProto::TYPE_BYTES)) { + // For the default string value. + alloc.PlanArray<std::string>(1); + } + } +} + +static void PlanAllocationSize( + const RepeatedPtrField<DescriptorProto::ExtensionRange>& ranges, + internal::FlatAllocator& alloc) { + alloc.PlanArray<Descriptor::ExtensionRange>(ranges.size()); + for (const auto& r : ranges) { + if (r.has_options()) alloc.PlanArray<ExtensionRangeOptions>(1); + } +} + +static void PlanAllocationSize( + const RepeatedPtrField<DescriptorProto>& messages, + internal::FlatAllocator& alloc) { + alloc.PlanArray<Descriptor>(messages.size()); + alloc.PlanArray<std::string>(2 * messages.size()); // name + full_name + + for (const auto& message : messages) { + if (message.has_options()) alloc.PlanArray<MessageOptions>(1); + PlanAllocationSize(message.nested_type(), alloc); + PlanAllocationSize(message.field(), alloc); + PlanAllocationSize(message.extension(), alloc); + PlanAllocationSize(message.extension_range(), alloc); + alloc.PlanArray<Descriptor::ReservedRange>(message.reserved_range_size()); + alloc.PlanArray<const std::string*>(message.reserved_name_size()); + alloc.PlanArray<std::string>(message.reserved_name_size()); + PlanAllocationSize(message.enum_type(), alloc); + PlanAllocationSize(message.oneof_decl(), alloc); + } +} + +static void PlanAllocationSize( + const RepeatedPtrField<MethodDescriptorProto>& methods, + internal::FlatAllocator& alloc) { + alloc.PlanArray<MethodDescriptor>(methods.size()); + alloc.PlanArray<std::string>(2 * methods.size()); // name + full_name + for (const auto& m : methods) { + if (m.has_options()) alloc.PlanArray<MethodOptions>(1); + } +} + +static void PlanAllocationSize( + const RepeatedPtrField<ServiceDescriptorProto>& services, + internal::FlatAllocator& alloc) { + alloc.PlanArray<ServiceDescriptor>(services.size()); + alloc.PlanArray<std::string>(2 * services.size()); // name + full_name + for (const auto& service : services) { + if (service.has_options()) alloc.PlanArray<ServiceOptions>(1); + PlanAllocationSize(service.method(), alloc); + } +} + +static void PlanAllocationSize(const FileDescriptorProto& proto, + internal::FlatAllocator& alloc) { + alloc.PlanArray<FileDescriptor>(1); + alloc.PlanArray<FileDescriptorTables>(1); + alloc.PlanArray<std::string>(2); // name + package + if (proto.has_options()) alloc.PlanArray<FileOptions>(1); + if (proto.has_source_code_info()) alloc.PlanArray<SourceCodeInfo>(1); + + PlanAllocationSize(proto.service(), alloc); + PlanAllocationSize(proto.message_type(), alloc); + PlanAllocationSize(proto.enum_type(), alloc); + PlanAllocationSize(proto.extension(), alloc); + + alloc.PlanArray<int>(proto.weak_dependency_size()); + alloc.PlanArray<int>(proto.public_dependency_size()); + alloc.PlanArray<const FileDescriptor*>(proto.dependency_size()); +} + const FileDescriptor* DescriptorBuilder::BuildFile( const FileDescriptorProto& proto) { filename_ = proto.name(); @@ -4884,6 +5032,13 @@ const FileDescriptor* DescriptorBuilder::BuildFile( } } + static const int kMaximumPackageLength = 511; + if (proto.package().size() > kMaximumPackageLength) { + AddError(proto.package(), proto, DescriptorPool::ErrorCollector::NAME, + "Package name is too long"); + return nullptr; + } + // If we have a fallback_database_, and we aren't doing lazy import building, // attempt to load all dependencies now, before checkpointing tables_. This // avoids confusion with recursive checkpoints. @@ -4906,12 +5061,16 @@ const FileDescriptor* DescriptorBuilder::BuildFile( // Checkpoint the tables so that we can roll back if something goes wrong. tables_->AddCheckpoint(); - FileDescriptor* result = BuildFileImpl(proto); + internal::FlatAllocator alloc; + PlanAllocationSize(proto, alloc); + alloc.FinalizePlanning(tables_); + FileDescriptor* result = BuildFileImpl(proto, alloc); file_tables_->FinalizeTables(); if (result) { tables_->ClearLastCheckpoint(); result->finished_building_ = true; + alloc.ExpectConsumed(); } else { tables_->RollbackToLastCheckpoint(); } @@ -4920,22 +5079,22 @@ const FileDescriptor* DescriptorBuilder::BuildFile( } FileDescriptor* DescriptorBuilder::BuildFileImpl( - const FileDescriptorProto& proto) { - FileDescriptor* result = tables_->Allocate<FileDescriptor>(); + const FileDescriptorProto& proto, internal::FlatAllocator& alloc) { + FileDescriptor* result = alloc.AllocateArray<FileDescriptor>(1); file_ = result; result->is_placeholder_ = false; result->finished_building_ = false; SourceCodeInfo* info = nullptr; if (proto.has_source_code_info()) { - info = tables_->AllocateMessage<SourceCodeInfo>(); + info = alloc.AllocateArray<SourceCodeInfo>(1); info->CopyFrom(proto.source_code_info()); result->source_code_info_ = info; } else { result->source_code_info_ = &SourceCodeInfo::default_instance(); } - file_tables_ = tables_->AllocateFileTables(); + file_tables_ = alloc.AllocateArray<FileDescriptorTables>(1); file_->tables_ = file_tables_; if (!proto.has_name()) { @@ -4955,15 +5114,15 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( "Unrecognized syntax: " + proto.syntax()); } - result->name_ = tables_->AllocateString(proto.name()); + result->name_ = alloc.AllocateStrings(proto.name()); if (proto.has_package()) { - result->package_ = tables_->AllocateString(proto.package()); + result->package_ = alloc.AllocateStrings(proto.package()); } else { // We cannot rely on proto.package() returning a valid string if // proto.has_package() is false, because we might be running at static // initialization time, in which case default values have not yet been // initialized. - result->package_ = tables_->AllocateString(""); + result->package_ = alloc.AllocateStrings(""); } result->pool_ = pool_; @@ -4982,6 +5141,12 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( return nullptr; } if (!result->package().empty()) { + if (std::count(result->package().begin(), result->package().end(), '.') > + kPackageLimit) { + AddError(result->package(), proto, DescriptorPool::ErrorCollector::NAME, + "Exceeds Maximum Package Depth"); + return nullptr; + } AddPackage(result->package(), proto, result); } @@ -4989,13 +5154,15 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( std::set<std::string> seen_dependencies; result->dependency_count_ = proto.dependency_size(); result->dependencies_ = - tables_->AllocateArray<const FileDescriptor*>(proto.dependency_size()); + alloc.AllocateArray<const FileDescriptor*>(proto.dependency_size()); result->dependencies_once_ = nullptr; unused_dependency_.clear(); std::set<int> weak_deps; for (int i = 0; i < proto.weak_dependency_size(); ++i) { weak_deps.insert(proto.weak_dependency(i)); } + + bool need_lazy_deps = false; for (int i = 0; i < proto.dependency_size(); i++) { if (!seen_dependencies.insert(proto.dependency(i)).second) { AddTwiceListedError(proto, i); @@ -5017,8 +5184,12 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( if (!pool_->lazily_build_dependencies_) { if (pool_->allow_unknown_ || (!pool_->enforce_weak_ && weak_deps.find(i) != weak_deps.end())) { - dependency = - pool_->NewPlaceholderFileWithMutexHeld(proto.dependency(i)); + internal::FlatAllocator lazy_dep_alloc; + lazy_dep_alloc.PlanArray<FileDescriptor>(1); + lazy_dep_alloc.PlanArray<std::string>(1); + lazy_dep_alloc.FinalizePlanning(tables_); + dependency = pool_->NewPlaceholderFileWithMutexHeld( + proto.dependency(i), lazy_dep_alloc); } else { AddImportError(proto, i); } @@ -5036,26 +5207,37 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( result->dependencies_[i] = dependency; if (pool_->lazily_build_dependencies_ && !dependency) { - if (result->dependencies_once_ == nullptr) { - result->dependencies_once_ = - tables_->Create<FileDescriptor::LazyInitData>(); - result->dependencies_once_->dependencies_names = - tables_->AllocateArray<const char*>(proto.dependency_size()); - if (proto.dependency_size() > 0) { - std::fill_n(result->dependencies_once_->dependencies_names, - proto.dependency_size(), nullptr); - } + need_lazy_deps = true; + } + } + if (need_lazy_deps) { + int total_char_size = 0; + for (int i = 0; i < proto.dependency_size(); i++) { + if (result->dependencies_[i] == nullptr) { + total_char_size += static_cast<int>(proto.dependency(i).size()); } + ++total_char_size; // For NUL char + } - result->dependencies_once_->dependencies_names[i] = - tables_->Strdup(proto.dependency(i)); + void* data = tables_->AllocateBytes( + static_cast<int>(sizeof(internal::once_flag) + total_char_size)); + result->dependencies_once_ = ::new (data) internal::once_flag{}; + char* name_data = reinterpret_cast<char*>(result->dependencies_once_ + 1); + + for (int i = 0; i < proto.dependency_size(); i++) { + if (result->dependencies_[i] == nullptr) { + memcpy(name_data, proto.dependency(i).c_str(), + proto.dependency(i).size()); + name_data += proto.dependency(i).size(); + } + *name_data++ = '\0'; } } // Check public dependencies. int public_dependency_count = 0; result->public_dependencies_ = - tables_->AllocateArray<int>(proto.public_dependency_size()); + alloc.AllocateArray<int>(proto.public_dependency_size()); for (int i = 0; i < proto.public_dependency_size(); i++) { // Only put valid public dependency indexes. int index = proto.public_dependency(i); @@ -5089,7 +5271,7 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( // Check weak dependencies. int weak_dependency_count = 0; result->weak_dependencies_ = - tables_->AllocateArray<int>(proto.weak_dependency_size()); + alloc.AllocateArray<int>(proto.weak_dependency_size()); for (int i = 0; i < proto.weak_dependency_size(); i++) { int index = proto.weak_dependency(i); if (index >= 0 && index < proto.dependency_size()) { @@ -5110,7 +5292,7 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( // Copy options. result->options_ = nullptr; // Set to default_instance later if necessary. if (proto.has_options()) { - AllocateOptions(proto.options(), result); + AllocateOptions(proto.options(), result, alloc); } // Note that the following steps must occur in exactly the specified order. @@ -5118,6 +5300,10 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( // Cross-link. CrossLinkFile(result, proto); + if (!message_hints_.empty()) { + SuggestFieldNumbers(result, proto); + } + // Interpret any remaining uninterpreted options gathered into // options_to_interpret_ during descriptor building. Cross-linking has made // extension options known, so all interpretations should now succeed. @@ -5166,21 +5352,33 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( const std::string* DescriptorBuilder::AllocateNameStrings( - const std::string& scope, const std::string& proto_name) { + const std::string& scope, const std::string& proto_name, + internal::FlatAllocator& alloc) { if (scope.empty()) { - return tables_->AllocateStringArray(proto_name, proto_name); + return alloc.AllocateStrings(proto_name, proto_name); } else { - return tables_->AllocateStringArray(proto_name, - StrCat(scope, ".", proto_name)); + return alloc.AllocateStrings(proto_name, + StrCat(scope, ".", proto_name)); } } +namespace { + +// Helper for BuildMessage below. +struct IncrementWhenDestroyed { + ~IncrementWhenDestroyed() { ++to_increment; } + int& to_increment; +}; + +} // namespace + void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, const Descriptor* parent, - Descriptor* result) { + Descriptor* result, + internal::FlatAllocator& alloc) { const std::string& scope = (parent == nullptr) ? file_->package() : parent->full_name(); - result->all_names_ = AllocateNameStrings(scope, proto.name()); + result->all_names_ = AllocateNameStrings(scope, proto.name(), alloc); ValidateSymbolName(proto.name(), result->full_name(), proto); result->file_ = file_; @@ -5188,6 +5386,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, result->is_placeholder_ = false; result->is_unqualified_placeholder_ = false; result->well_known_type_ = Descriptor::WELLKNOWNTYPE_UNSPECIFIED; + result->options_ = nullptr; // Set to default_instance later if necessary. auto it = pool_->tables_->well_known_types_.find(result->full_name()); if (it != pool_->tables_->well_known_types_.end()) { @@ -5210,28 +5409,38 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, // Build oneofs first so that fields and extension ranges can refer to them. BUILD_ARRAY(proto, result, oneof_decl, BuildOneof, result); BUILD_ARRAY(proto, result, field, BuildField, result); - BUILD_ARRAY(proto, result, nested_type, BuildMessage, result); BUILD_ARRAY(proto, result, enum_type, BuildEnum, result); BUILD_ARRAY(proto, result, extension_range, BuildExtensionRange, result); BUILD_ARRAY(proto, result, extension, BuildExtension, result); BUILD_ARRAY(proto, result, reserved_range, BuildReservedRange, result); + // Before building submessages, check recursion limit. + --recursion_depth_; + IncrementWhenDestroyed revert{recursion_depth_}; + if (recursion_depth_ <= 0) { + AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::OTHER, + "Reached maximum recursion limit for nested messages."); + result->nested_types_ = nullptr; + result->nested_type_count_ = 0; + return; + } + BUILD_ARRAY(proto, result, nested_type, BuildMessage, result); + // Copy reserved names. int reserved_name_count = proto.reserved_name_size(); result->reserved_name_count_ = reserved_name_count; result->reserved_names_ = - tables_->AllocateArray<const std::string*>(reserved_name_count); + alloc.AllocateArray<const std::string*>(reserved_name_count); for (int i = 0; i < reserved_name_count; ++i) { result->reserved_names_[i] = - tables_->AllocateString(proto.reserved_name(i)); + alloc.AllocateStrings(proto.reserved_name(i)); } // Copy options. - result->options_ = nullptr; // Set to default_instance later if necessary. if (proto.has_options()) { AllocateOptions(proto.options(), result, DescriptorProto::kOptionsFieldNumber, - "google.protobuf.MessageOptions"); + "google.protobuf.MessageOptions", alloc); } AddSymbol(result->full_name(), parent, result->name(), proto, Symbol(result)); @@ -5269,6 +5478,8 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, for (int j = 0; j < result->extension_range_count(); j++) { const Descriptor::ExtensionRange* range = result->extension_range(j); if (range->start <= field->number() && field->number() < range->end) { + message_hints_[result].RequestHintOnFieldNumbers( + proto.extension_range(j), DescriptorPool::ErrorCollector::NUMBER); AddError( field->full_name(), proto.extension_range(j), DescriptorPool::ErrorCollector::NUMBER, @@ -5280,6 +5491,8 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, for (int j = 0; j < result->reserved_range_count(); j++) { const Descriptor::ReservedRange* range = result->reserved_range(j); if (range->start <= field->number() && field->number() < range->end) { + message_hints_[result].RequestHintOnFieldNumbers( + proto.reserved_range(j), DescriptorPool::ErrorCollector::NUMBER); AddError(field->full_name(), proto.reserved_range(j), DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Field \"$0\" uses reserved number $1.", @@ -5327,13 +5540,14 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, Descriptor* parent, FieldDescriptor* result, - bool is_extension) { + bool is_extension, + internal::FlatAllocator& alloc) { const std::string& scope = (parent == nullptr) ? file_->package() : parent->full_name(); // We allocate all names in a single array, and dedup them. // We remember the indices for the potentially deduped values. - auto all_names = tables_->AllocateFieldNames( + auto all_names = alloc.AllocateFieldNames( proto.name(), scope, proto.has_json_name() ? &proto.json_name() : nullptr); result->all_names_ = all_names.array; @@ -5459,11 +5673,11 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, break; case FieldDescriptor::CPPTYPE_STRING: if (result->type() == FieldDescriptor::TYPE_BYTES) { - result->default_value_string_ = tables_->AllocateString( + result->default_value_string_ = alloc.AllocateStrings( UnescapeCEscapeString(proto.default_value())); } else { result->default_value_string_ = - tables_->AllocateString(proto.default_value()); + alloc.AllocateStrings(proto.default_value()); } break; case FieldDescriptor::CPPTYPE_MESSAGE: @@ -5525,6 +5739,8 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, } if (result->number() <= 0) { + message_hints_[parent].RequestHintOnFieldNumbers( + proto, DescriptorPool::ErrorCollector::NUMBER); AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, "Field numbers must be positive integers."); } else if (!is_extension && result->number() > FieldDescriptor::kMaxNumber) { @@ -5536,11 +5752,15 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, // This avoids cross-linking issues that arise when attempting to check if // the extendee is a message_set_wire_format message, which has a higher max // on extension numbers. + message_hints_[parent].RequestHintOnFieldNumbers( + proto, DescriptorPool::ErrorCollector::NUMBER); AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Field numbers cannot be greater than $0.", FieldDescriptor::kMaxNumber)); } else if (result->number() >= FieldDescriptor::kFirstReservedNumber && result->number() <= FieldDescriptor::kLastReservedNumber) { + message_hints_[parent].RequestHintOnFieldNumbers( + proto, DescriptorPool::ErrorCollector::NUMBER); AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, strings::Substitute( "Field numbers $0 through $1 are reserved for the protocol " @@ -5593,19 +5813,21 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, if (proto.has_options()) { AllocateOptions(proto.options(), result, FieldDescriptorProto::kOptionsFieldNumber, - "google.protobuf.FieldOptions"); + "google.protobuf.FieldOptions", alloc); } - AddSymbol(result->full_name(), parent, result->name(), proto, Symbol(result)); } void DescriptorBuilder::BuildExtensionRange( const DescriptorProto::ExtensionRange& proto, const Descriptor* parent, - Descriptor::ExtensionRange* result) { + Descriptor::ExtensionRange* result, internal::FlatAllocator& alloc) { result->start = proto.start(); result->end = proto.end(); if (result->start <= 0) { + message_hints_[parent].RequestHintOnFieldNumbers( + proto, DescriptorPool::ErrorCollector::NUMBER, result->start, + result->end); AddError(parent->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, "Extension numbers must be positive integers."); } @@ -5633,16 +5855,19 @@ void DescriptorBuilder::BuildExtensionRange( options_path.push_back(DescriptorProto_ExtensionRange::kOptionsFieldNumber); AllocateOptionsImpl(parent->full_name(), parent->full_name(), proto.options(), result, options_path, - "google.protobuf.ExtensionRangeOptions"); + "google.protobuf.ExtensionRangeOptions", alloc); } } void DescriptorBuilder::BuildReservedRange( const DescriptorProto::ReservedRange& proto, const Descriptor* parent, - Descriptor::ReservedRange* result) { + Descriptor::ReservedRange* result, internal::FlatAllocator&) { result->start = proto.start(); result->end = proto.end(); if (result->start <= 0) { + message_hints_[parent].RequestHintOnFieldNumbers( + proto, DescriptorPool::ErrorCollector::NUMBER, result->start, + result->end); AddError(parent->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, "Reserved numbers must be positive integers."); } @@ -5650,7 +5875,8 @@ void DescriptorBuilder::BuildReservedRange( void DescriptorBuilder::BuildReservedRange( const EnumDescriptorProto::EnumReservedRange& proto, - const EnumDescriptor* parent, EnumDescriptor::ReservedRange* result) { + const EnumDescriptor* parent, EnumDescriptor::ReservedRange* result, + internal::FlatAllocator&) { result->start = proto.start(); result->end = proto.end(); @@ -5661,9 +5887,10 @@ void DescriptorBuilder::BuildReservedRange( } void DescriptorBuilder::BuildOneof(const OneofDescriptorProto& proto, - Descriptor* parent, - OneofDescriptor* result) { - result->all_names_ = AllocateNameStrings(parent->full_name(), proto.name()); + Descriptor* parent, OneofDescriptor* result, + internal::FlatAllocator& alloc) { + result->all_names_ = + AllocateNameStrings(parent->full_name(), proto.name(), alloc); ValidateSymbolName(proto.name(), result->full_name(), proto); result->containing_type_ = parent; @@ -5677,7 +5904,7 @@ void DescriptorBuilder::BuildOneof(const OneofDescriptorProto& proto, if (proto.has_options()) { AllocateOptions(proto.options(), result, OneofDescriptorProto::kOptionsFieldNumber, - "google.protobuf.OneofOptions"); + "google.protobuf.OneofOptions", alloc); } AddSymbol(result->full_name(), parent, result->name(), proto, Symbol(result)); @@ -5751,11 +5978,12 @@ void DescriptorBuilder::CheckEnumValueUniqueness( void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, const Descriptor* parent, - EnumDescriptor* result) { + EnumDescriptor* result, + internal::FlatAllocator& alloc) { const std::string& scope = (parent == nullptr) ? file_->package() : parent->full_name(); - result->all_names_ = AllocateNameStrings(scope, proto.name()); + result->all_names_ = AllocateNameStrings(scope, proto.name(), alloc); ValidateSymbolName(proto.name(), result->full_name(), proto); result->file_ = file_; result->containing_type_ = parent; @@ -5791,10 +6019,10 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, int reserved_name_count = proto.reserved_name_size(); result->reserved_name_count_ = reserved_name_count; result->reserved_names_ = - tables_->AllocateArray<const std::string*>(reserved_name_count); + alloc.AllocateArray<const std::string*>(reserved_name_count); for (int i = 0; i < reserved_name_count; ++i) { result->reserved_names_[i] = - tables_->AllocateString(proto.reserved_name(i)); + alloc.AllocateStrings(proto.reserved_name(i)); } CheckEnumValueUniqueness(proto, result); @@ -5804,7 +6032,7 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, if (proto.has_options()) { AllocateOptions(proto.options(), result, EnumDescriptorProto::kOptionsFieldNumber, - "google.protobuf.EnumOptions"); + "google.protobuf.EnumOptions", alloc); } AddSymbol(result->full_name(), parent, result->name(), proto, Symbol(result)); @@ -5860,7 +6088,8 @@ void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, void DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto, const EnumDescriptor* parent, - EnumValueDescriptor* result) { + EnumValueDescriptor* result, + internal::FlatAllocator& alloc) { // Note: full_name for enum values is a sibling to the parent's name, not a // child of it. std::string full_name; @@ -5870,7 +6099,7 @@ void DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto, full_name.append(proto.name()); result->all_names_ = - tables_->AllocateStringArray(proto.name(), std::move(full_name)); + alloc.AllocateStrings(proto.name(), std::move(full_name)); result->number_ = proto.number(); result->type_ = parent; @@ -5881,7 +6110,7 @@ void DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto, if (proto.has_options()) { AllocateOptions(proto.options(), result, EnumValueDescriptorProto::kOptionsFieldNumber, - "google.protobuf.EnumValueOptions"); + "google.protobuf.EnumValueOptions", alloc); } // Again, enum values are weird because we makes them appear as siblings @@ -5931,8 +6160,10 @@ void DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto, void DescriptorBuilder::BuildService(const ServiceDescriptorProto& proto, const void* /* dummy */, - ServiceDescriptor* result) { - result->all_names_ = AllocateNameStrings(file_->package(), proto.name()); + ServiceDescriptor* result, + internal::FlatAllocator& alloc) { + result->all_names_ = + AllocateNameStrings(file_->package(), proto.name(), alloc); result->file_ = file_; ValidateSymbolName(proto.name(), result->full_name(), proto); @@ -5943,7 +6174,7 @@ void DescriptorBuilder::BuildService(const ServiceDescriptorProto& proto, if (proto.has_options()) { AllocateOptions(proto.options(), result, ServiceDescriptorProto::kOptionsFieldNumber, - "google.protobuf.ServiceOptions"); + "google.protobuf.ServiceOptions", alloc); } AddSymbol(result->full_name(), nullptr, result->name(), proto, @@ -5952,9 +6183,11 @@ void DescriptorBuilder::BuildService(const ServiceDescriptorProto& proto, void DescriptorBuilder::BuildMethod(const MethodDescriptorProto& proto, const ServiceDescriptor* parent, - MethodDescriptor* result) { + MethodDescriptor* result, + internal::FlatAllocator& alloc) { result->service_ = parent; - result->all_names_ = AllocateNameStrings(parent->full_name(), proto.name()); + result->all_names_ = + AllocateNameStrings(parent->full_name(), proto.name(), alloc); ValidateSymbolName(proto.name(), result->full_name(), proto); @@ -5967,7 +6200,7 @@ void DescriptorBuilder::BuildMethod(const MethodDescriptorProto& proto, if (proto.has_options()) { AllocateOptions(proto.options(), result, MethodDescriptorProto::kOptionsFieldNumber, - "google.protobuf.MethodOptions"); + "google.protobuf.MethodOptions", alloc); } result->client_streaming_ = proto.client_streaming(); @@ -6136,9 +6369,6 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field, field->options_ = &FieldOptions::default_instance(); } - // Add the field to the lowercase-name and camelcase-name tables. - file_tables_->AddFieldByStylizedNames(field); - if (proto.has_extendee()) { Symbol extendee = LookupSymbol(proto.extendee(), field->full_name(), @@ -6214,12 +6444,18 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field, if (is_lazy) { // Save the symbol names for later for lookup, and allocate the once // object needed for the accessors. - std::string name = proto.type_name(); - field->type_once_ = tables_->Create<internal::once_flag>(); - field->type_descriptor_.lazy_type_name = tables_->Strdup(name); - field->lazy_default_value_enum_name_ = - proto.has_default_value() ? tables_->Strdup(proto.default_value()) - : nullptr; + const std::string& name = proto.type_name(); + + int name_sizes = static_cast<int>(name.size() + 1 + + proto.default_value().size() + 1); + + field->type_once_ = ::new (tables_->AllocateBytes(static_cast<int>( + sizeof(internal::once_flag) + name_sizes))) internal::once_flag{}; + char* names = reinterpret_cast<char*>(field->type_once_ + 1); + + memcpy(names, name.c_str(), name.size() + 1); + memcpy(names + name.size() + 1, proto.default_value().c_str(), + proto.default_value().size() + 1); // AddFieldByNumber and AddExtension are done later in this function, // and can/must be done if the field type was not found. The related @@ -6467,6 +6703,78 @@ void DescriptorBuilder::CrossLinkMethod(MethodDescriptor* method, } } +void DescriptorBuilder::SuggestFieldNumbers(FileDescriptor* file, + const FileDescriptorProto& proto) { + for (int message_index = 0; message_index < file->message_type_count(); + message_index++) { + const Descriptor* message = &file->message_types_[message_index]; + auto* hints = FindOrNull(message_hints_, message); + if (!hints) continue; + constexpr int kMaxSuggestions = 3; + int fields_to_suggest = std::min(kMaxSuggestions, hints->fields_to_suggest); + if (fields_to_suggest <= 0) continue; + struct Range { + int from; + int to; + }; + std::vector<Range> used_ordinals; + auto add_ordinal = [&](int ordinal) { + if (ordinal <= 0 || ordinal > FieldDescriptor::kMaxNumber) return; + if (!used_ordinals.empty() && + ordinal == used_ordinals.back().to) { + used_ordinals.back().to = ordinal + 1; + } else { + used_ordinals.push_back({ordinal, ordinal + 1}); + } + }; + auto add_range = [&](int from, int to) { + from = std::max(0, std::min(FieldDescriptor::kMaxNumber + 1, from)); + to = std::max(0, std::min(FieldDescriptor::kMaxNumber + 1, to)); + if (from >= to) return; + used_ordinals.push_back({from, to}); + }; + for (int i = 0; i < message->field_count(); i++) { + add_ordinal(message->field(i)->number()); + } + for (int i = 0; i < message->extension_count(); i++) { + add_ordinal(message->extension(i)->number()); + } + for (int i = 0; i < message->reserved_range_count(); i++) { + auto range = message->reserved_range(i); + add_range(range->start, range->end); + } + for (int i = 0; i < message->extension_range_count(); i++) { + auto range = message->extension_range(i); + add_range(range->start, range->end); + } + used_ordinals.push_back( + {FieldDescriptor::kMaxNumber, FieldDescriptor::kMaxNumber + 1}); + used_ordinals.push_back({FieldDescriptor::kFirstReservedNumber, + FieldDescriptor::kLastReservedNumber}); + std::sort(used_ordinals.begin(), used_ordinals.end(), + [](Range lhs, Range rhs) { + return std::tie(lhs.from, lhs.to) < std::tie(rhs.from, rhs.to); + }); + int current_ordinal = 1; + std::stringstream id_list; + id_list << "Suggested field numbers for " << message->full_name() << ": "; + const char* separator = ""; + for (auto& current_range : used_ordinals) { + while (current_ordinal < current_range.from && fields_to_suggest > 0) { + id_list << separator << current_ordinal++; + separator = ", "; + fields_to_suggest--; + } + if (fields_to_suggest == 0) break; + current_ordinal = std::max(current_ordinal, current_range.to); + } + if (hints->first_reason) { + AddError(message->full_name(), *hints->first_reason, + hints->first_reason_location, id_list.str()); + } + } +} + // ------------------------------------------------------------------- #define VALIDATE_OPTIONS_FROM_ARRAY(descriptor, array_name, type) \ @@ -6660,7 +6968,7 @@ void DescriptorBuilder::ValidateFieldOptions( return; } // Only message type fields may be lazy. - if (field->options().lazy()) { + if (field->options().lazy() || field->options().unverified_lazy()) { if (field->type() != FieldDescriptor::TYPE_MESSAGE) { AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, "[lazy = true] can only be specified for submessage fields."); @@ -6877,6 +7185,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message, DescriptorPool::ErrorCollector::NAME, "Expanded map entry type " + nested->name() + " conflicts with an existing nested message type."); + break; } } // Recursively test on the nested types. @@ -7218,11 +7527,9 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption( new UnknownFieldSet()); switch ((*iter)->type()) { case FieldDescriptor::TYPE_MESSAGE: { - io::StringOutputStream outstr( - parent_unknown_fields->AddLengthDelimited((*iter)->number())); - io::CodedOutputStream out(&outstr); - internal::WireFormat::SerializeUnknownFields(*unknown_fields, &out); - GOOGLE_CHECK(!out.HadError()) + std::string* outstr = + parent_unknown_fields->AddLengthDelimited((*iter)->number()); + GOOGLE_CHECK(unknown_fields->SerializeToString(outstr)) << "Unexpected failure while serializing option submessage " << debug_msg_name << "\"."; break; @@ -7880,8 +8187,11 @@ Symbol DescriptorPool::CrossLinkOnDemandHelper(StringPiece name, void FieldDescriptor::InternalTypeOnceInit() const { GOOGLE_CHECK(file()->finished_building_ == true); const EnumDescriptor* enum_type = nullptr; + const char* lazy_type_name = reinterpret_cast<const char*>(type_once_ + 1); + const char* lazy_default_value_enum_name = + lazy_type_name + strlen(lazy_type_name) + 1; Symbol result = file()->pool()->CrossLinkOnDemandHelper( - type_descriptor_.lazy_type_name, type_ == FieldDescriptor::TYPE_ENUM); + lazy_type_name, type_ == FieldDescriptor::TYPE_ENUM); if (result.type() == Symbol::MESSAGE) { type_ = FieldDescriptor::TYPE_MESSAGE; type_descriptor_.message_type = result.descriptor(); @@ -7891,16 +8201,16 @@ void FieldDescriptor::InternalTypeOnceInit() const { } if (enum_type) { - if (lazy_default_value_enum_name_) { + if (lazy_default_value_enum_name[0] != '\0') { // Have to build the full name now instead of at CrossLink time, // because enum_type may not be known at the time. std::string name = enum_type->full_name(); // Enum values reside in the same scope as the enum type. std::string::size_type last_dot = name.find_last_of('.'); if (last_dot != std::string::npos) { - name = name.substr(0, last_dot) + "." + lazy_default_value_enum_name_; + name = name.substr(0, last_dot) + "." + lazy_default_value_enum_name; } else { - name = lazy_default_value_enum_name_; + name = lazy_default_value_enum_name; } Symbol result = file()->pool()->CrossLinkOnDemandHelper(name, true); default_value_enum_ = result.enum_value_descriptor(); @@ -7957,10 +8267,12 @@ const std::string& FieldDescriptor::PrintableNameForExtension() const { void FileDescriptor::InternalDependenciesOnceInit() const { GOOGLE_CHECK(finished_building_ == true); - auto* names = dependencies_once_->dependencies_names; + const char* names_ptr = reinterpret_cast<const char*>(dependencies_once_ + 1); for (int i = 0; i < dependency_count(); i++) { - if (names[i]) { - dependencies_[i] = pool_->FindFileByName(names[i]); + const char* name = names_ptr; + names_ptr += strlen(name) + 1; + if (name[0] != '\0') { + dependencies_[i] = pool_->FindFileByName(name); } } } @@ -7973,7 +8285,7 @@ const FileDescriptor* FileDescriptor::dependency(int index) const { if (dependencies_once_) { // Do once init for all indices, as it's unlikely only a single index would // be called, and saves on internal::call_once allocations. - internal::call_once(dependencies_once_->once, + internal::call_once(*dependencies_once_, FileDescriptor::DependenciesOnceInit, this); } return dependencies_[index]; @@ -7987,7 +8299,6 @@ const Descriptor* MethodDescriptor::output_type() const { return output_type_.Get(service()); } - namespace internal { void LazyDescriptor::Set(const Descriptor* descriptor) { GOOGLE_CHECK(!once_); @@ -8002,8 +8313,11 @@ void LazyDescriptor::SetLazy(StringPiece name, GOOGLE_CHECK(file && file->pool_); GOOGLE_CHECK(file->pool_->lazily_build_dependencies_); GOOGLE_CHECK(!file->finished_building_); - once_ = file->pool_->tables_->Create<internal::once_flag>(); - lazy_name_ = file->pool_->tables_->Strdup(name); + once_ = ::new (file->pool_->tables_->AllocateBytes(static_cast<int>( + sizeof(internal::once_flag) + name.size() + 1))) internal::once_flag{}; + char* lazy_name = reinterpret_cast<char*>(once_ + 1); + memcpy(lazy_name, name.data(), name.size()); + lazy_name[name.size()] = 0; } void LazyDescriptor::Once(const ServiceDescriptor* service) { @@ -8011,8 +8325,9 @@ void LazyDescriptor::Once(const ServiceDescriptor* service) { internal::call_once(*once_, [&] { auto* file = service->file(); GOOGLE_CHECK(file->finished_building_); + const char* lazy_name = reinterpret_cast<const char*>(once_ + 1); descriptor_ = - file->pool_->CrossLinkOnDemandHelper(lazy_name_, false).descriptor(); + file->pool_->CrossLinkOnDemandHelper(lazy_name, false).descriptor(); }); } } diff --git a/r5dev/thirdparty/protobuf/descriptor.h b/r5dev/thirdparty/protobuf/descriptor.h index e00a7983..adcbbc67 100644 --- a/r5dev/thirdparty/protobuf/descriptor.h +++ b/r5dev/thirdparty/protobuf/descriptor.h @@ -54,6 +54,7 @@ #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_H__ #define GOOGLE_PROTOBUF_DESCRIPTOR_H__ + #include <atomic> #include <map> #include <memory> @@ -66,6 +67,8 @@ #include <thirdparty/protobuf/stubs/mutex.h> #include <thirdparty/protobuf/stubs/once.h> #include <thirdparty/protobuf/port.h> + +// Must be included last. #include <thirdparty/protobuf/port_def.inc> // TYPE_BOOL is defined in the MacOS's ConditionalMacros.h. @@ -184,6 +187,19 @@ struct DebugStringOptions { // Must be instantiated as mutable in a descriptor. namespace internal { +// The classes in this file represent a significant memory footprint for the +// library. We make sure we are not accidentally making them larger by +// hardcoding the struct size for a specific platform. Use as: +// +// PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(type, expected_size_in_x84-64); +// + +#if !defined(PROTOBUF_INTERNAL_CHECK_CLASS_SIZE) +#define PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(t, expected) +#endif + +class FlatAllocator; + class PROTOBUF_EXPORT LazyDescriptor { public: // Init function to be called at init time of a descriptor containing @@ -217,10 +233,8 @@ class PROTOBUF_EXPORT LazyDescriptor { private: void Once(const ServiceDescriptor* service); - union { - const Descriptor* descriptor_; - const char* lazy_name_; - }; + const Descriptor* descriptor_; + // The once_ flag is followed by a NUL terminated string for the type name. internal::once_flag* once_; }; @@ -598,6 +612,7 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Descriptor); }; +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(Descriptor, 136); // Describes a single field of a message. To get the descriptor for a given // field, first get the Descriptor for the message in which it is defined, @@ -881,7 +896,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase { // formats the default value appropriately and returns it as a string. // Must have a default value to call this. If quote_string_type is true, then - // types of CPPTYPE_STRING whill be surrounded by quotes and CEscaped. + // types of CPPTYPE_STRING will be surrounded by quotes and CEscaped. std::string DefaultValueAsString(bool quote_string_type) const; // Helper function that returns the field type name for DebugString. @@ -924,6 +939,8 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase { const std::string* all_names_; const FileDescriptor* file_; + // The once_flag is followed by a NUL terminated string for the type name and + // enum default value (or empty string if no default enum). internal::once_flag* type_once_; static void TypeOnceInit(const FieldDescriptor* to_init); void InternalTypeOnceInit() const; @@ -935,7 +952,6 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase { union { mutable const Descriptor* message_type; mutable const EnumDescriptor* enum_type; - const char* lazy_type_name; } type_descriptor_; const FieldOptions* options_; // IMPORTANT: If you add a new field, make sure to search for all instances @@ -952,7 +968,6 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase { bool default_value_bool_; mutable const EnumValueDescriptor* default_value_enum_; - const char* lazy_default_value_enum_name_; const std::string* default_value_string_; mutable std::atomic<const Message*> default_generated_instance_; }; @@ -974,6 +989,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldDescriptor); }; +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FieldDescriptor, 72); // Describes a oneof defined in a message type. class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase { @@ -1054,6 +1070,8 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OneofDescriptor); }; +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(OneofDescriptor, 40); + // Describes an enum type defined in a .proto file. To get the EnumDescriptor // for a generated enum type, call TypeName_descriptor(). Use DescriptorPool // to construct your own descriptors. @@ -1223,6 +1241,8 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumDescriptor); }; +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumDescriptor, 72); + // Describes an individual enum constant of a particular type. To get the // EnumValueDescriptor for a given enum value, first get the EnumDescriptor // for its type, then use EnumDescriptor::FindValueByName() or @@ -1306,6 +1326,8 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>, GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumValueDescriptor); }; +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumValueDescriptor, 32); + // Describes an RPC service. Use DescriptorPool to construct your own // descriptors. class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase { @@ -1336,6 +1358,7 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase { // Look up a MethodDescriptor by name. const MethodDescriptor* FindMethodByName(ConstStringParam name) const; + // See Descriptor::CopyTo(). void CopyTo(ServiceDescriptorProto* proto) const; @@ -1386,6 +1409,7 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceDescriptor); }; +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(ServiceDescriptor, 48); // Describes an individual service method. To obtain a MethodDescriptor given // a service, first get its ServiceDescriptor, then call @@ -1474,11 +1498,12 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MethodDescriptor); }; +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(MethodDescriptor, 64); // Describes a whole .proto file. To get the FileDescriptor for a compiled-in // file, get the descriptor for something defined in that file and call // descriptor->file(). Use DescriptorPool to construct your own descriptors. -class PROTOBUF_EXPORT FileDescriptor { +class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase { public: typedef FileDescriptorProto Proto; @@ -1615,32 +1640,9 @@ class PROTOBUF_EXPORT FileDescriptor { SourceLocation* out_location) const; private: + friend class Symbol; typedef FileOptions OptionsType; - const std::string* name_; - const std::string* package_; - const DescriptorPool* pool_; - - // Data required to do lazy initialization. - struct PROTOBUF_EXPORT LazyInitData { -#ifndef SWIG - internal::once_flag once; -#endif - const char** dependencies_names; - }; - - LazyInitData* dependencies_once_; - static void DependenciesOnceInit(const FileDescriptor* to_init); - void InternalDependenciesOnceInit() const; - - // These are arranged to minimize padding on 64-bit. - int dependency_count_; - int public_dependency_count_; - int weak_dependency_count_; - int message_type_count_; - int enum_type_count_; - int service_count_; - bool is_placeholder_; // Indicates the FileDescriptor is completed building. Used to verify // that type accessor functions that can possibly build a dependent file @@ -1651,6 +1653,25 @@ class PROTOBUF_EXPORT FileDescriptor { // This one is here to fill the padding. int extension_count_; + const std::string* name_; + const std::string* package_; + const DescriptorPool* pool_; + + // dependencies_once_ contain a once_flag followed by N NUL terminated + // strings. Dependencies that do not need to be loaded will be empty. ie just + // {'\0'} + internal::once_flag* dependencies_once_; + static void DependenciesOnceInit(const FileDescriptor* to_init); + void InternalDependenciesOnceInit() const; + + // These are arranged to minimize padding on 64-bit. + int dependency_count_; + int public_dependency_count_; + int weak_dependency_count_; + int message_type_count_; + int enum_type_count_; + int service_count_; + mutable const FileDescriptor** dependencies_; int* public_dependencies_; int* weak_dependencies_; @@ -1681,6 +1702,7 @@ class PROTOBUF_EXPORT FileDescriptor { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileDescriptor); }; +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FileDescriptor, 144); // =================================================================== @@ -1973,7 +1995,6 @@ class PROTOBUF_EXPORT DescriptorPool { friend class ServiceDescriptor; friend class MethodDescriptor; friend class FileDescriptor; - friend class StreamDescriptor; friend class DescriptorBuilder; friend class FileDescriptorTables; @@ -2013,7 +2034,8 @@ class PROTOBUF_EXPORT DescriptorPool { // Create a placeholder FileDescriptor of the specified name FileDescriptor* NewPlaceholderFile(StringPiece name) const; - FileDescriptor* NewPlaceholderFileWithMutexHeld(StringPiece name) const; + FileDescriptor* NewPlaceholderFileWithMutexHeld( + StringPiece name, internal::FlatAllocator& alloc) const; enum PlaceholderType { PLACEHOLDER_MESSAGE, @@ -2412,6 +2434,7 @@ inline FileDescriptor::Syntax FileDescriptor::syntax() const { } // namespace protobuf } // namespace google +#undef PROTOBUF_INTERNAL_CHECK_CLASS_SIZE #include <thirdparty/protobuf/port_undef.inc> #endif // GOOGLE_PROTOBUF_DESCRIPTOR_H__ diff --git a/r5dev/thirdparty/protobuf/descriptor.pb.cc b/r5dev/thirdparty/protobuf/descriptor.pb.cc index 0cd457b0..9d993b50 100644 --- a/r5dev/thirdparty/protobuf/descriptor.pb.cc +++ b/r5dev/thirdparty/protobuf/descriptor.pb.cc @@ -16,442 +16,499 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + PROTOBUF_NAMESPACE_OPEN -constexpr FileDescriptorSet::FileDescriptorSet( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : file_(){} +PROTOBUF_CONSTEXPR FileDescriptorSet::FileDescriptorSet( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.file_)*/{} + , /*decltype(_impl_._cached_size_)*/{}} {} struct FileDescriptorSetDefaultTypeInternal { - constexpr FileDescriptorSetDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FileDescriptorSetDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~FileDescriptorSetDefaultTypeInternal() {} union { FileDescriptorSet _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; -constexpr FileDescriptorProto::FileDescriptorProto( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : dependency_() - , message_type_() - , enum_type_() - , service_() - , extension_() - , public_dependency_() - , weak_dependency_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , syntax_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , options_(nullptr) - , source_code_info_(nullptr){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; +PROTOBUF_CONSTEXPR FileDescriptorProto::FileDescriptorProto( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.dependency_)*/{} + , /*decltype(_impl_.message_type_)*/{} + , /*decltype(_impl_.enum_type_)*/{} + , /*decltype(_impl_.service_)*/{} + , /*decltype(_impl_.extension_)*/{} + , /*decltype(_impl_.public_dependency_)*/{} + , /*decltype(_impl_.weak_dependency_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.package_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.syntax_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.options_)*/nullptr + , /*decltype(_impl_.source_code_info_)*/nullptr} {} struct FileDescriptorProtoDefaultTypeInternal { - constexpr FileDescriptorProtoDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FileDescriptorProtoDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~FileDescriptorProtoDefaultTypeInternal() {} union { FileDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; -constexpr DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : options_(nullptr) - , start_(0) - , end_(0){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; +PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.options_)*/nullptr + , /*decltype(_impl_.start_)*/0 + , /*decltype(_impl_.end_)*/0} {} struct DescriptorProto_ExtensionRangeDefaultTypeInternal { - constexpr DescriptorProto_ExtensionRangeDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRangeDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~DescriptorProto_ExtensionRangeDefaultTypeInternal() {} union { DescriptorProto_ExtensionRange _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; -constexpr DescriptorProto_ReservedRange::DescriptorProto_ReservedRange( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : start_(0) - , end_(0){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; +PROTOBUF_CONSTEXPR DescriptorProto_ReservedRange::DescriptorProto_ReservedRange( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.start_)*/0 + , /*decltype(_impl_.end_)*/0} {} struct DescriptorProto_ReservedRangeDefaultTypeInternal { - constexpr DescriptorProto_ReservedRangeDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR DescriptorProto_ReservedRangeDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~DescriptorProto_ReservedRangeDefaultTypeInternal() {} union { DescriptorProto_ReservedRange _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; -constexpr DescriptorProto::DescriptorProto( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : field_() - , nested_type_() - , enum_type_() - , extension_range_() - , extension_() - , oneof_decl_() - , reserved_range_() - , reserved_name_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , options_(nullptr){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; +PROTOBUF_CONSTEXPR DescriptorProto::DescriptorProto( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.field_)*/{} + , /*decltype(_impl_.nested_type_)*/{} + , /*decltype(_impl_.enum_type_)*/{} + , /*decltype(_impl_.extension_range_)*/{} + , /*decltype(_impl_.extension_)*/{} + , /*decltype(_impl_.oneof_decl_)*/{} + , /*decltype(_impl_.reserved_range_)*/{} + , /*decltype(_impl_.reserved_name_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.options_)*/nullptr} {} struct DescriptorProtoDefaultTypeInternal { - constexpr DescriptorProtoDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR DescriptorProtoDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~DescriptorProtoDefaultTypeInternal() {} union { DescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; -constexpr ExtensionRangeOptions::ExtensionRangeOptions( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : uninterpreted_option_(){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; +PROTOBUF_CONSTEXPR ExtensionRangeOptions::ExtensionRangeOptions( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._extensions_)*/{} + , /*decltype(_impl_.uninterpreted_option_)*/{} + , /*decltype(_impl_._cached_size_)*/{}} {} struct ExtensionRangeOptionsDefaultTypeInternal { - constexpr ExtensionRangeOptionsDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR ExtensionRangeOptionsDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~ExtensionRangeOptionsDefaultTypeInternal() {} union { ExtensionRangeOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_; -constexpr FieldDescriptorProto::FieldDescriptorProto( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , extendee_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , type_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , default_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , json_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , options_(nullptr) - , number_(0) - , oneof_index_(0) - , proto3_optional_(false) - , label_(1) - - , type_(1) -{} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_; +PROTOBUF_CONSTEXPR FieldDescriptorProto::FieldDescriptorProto( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.extendee_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.type_name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.default_value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.json_name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.options_)*/nullptr + , /*decltype(_impl_.number_)*/0 + , /*decltype(_impl_.oneof_index_)*/0 + , /*decltype(_impl_.proto3_optional_)*/false + , /*decltype(_impl_.label_)*/1 + , /*decltype(_impl_.type_)*/1} {} struct FieldDescriptorProtoDefaultTypeInternal { - constexpr FieldDescriptorProtoDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FieldDescriptorProtoDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~FieldDescriptorProtoDefaultTypeInternal() {} union { FieldDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; -constexpr OneofDescriptorProto::OneofDescriptorProto( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , options_(nullptr){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; +PROTOBUF_CONSTEXPR OneofDescriptorProto::OneofDescriptorProto( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.options_)*/nullptr} {} struct OneofDescriptorProtoDefaultTypeInternal { - constexpr OneofDescriptorProtoDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR OneofDescriptorProtoDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~OneofDescriptorProtoDefaultTypeInternal() {} union { OneofDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; -constexpr EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : start_(0) - , end_(0){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; +PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.start_)*/0 + , /*decltype(_impl_.end_)*/0} {} struct EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal { - constexpr EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() {} union { EnumDescriptorProto_EnumReservedRange _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_; -constexpr EnumDescriptorProto::EnumDescriptorProto( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : value_() - , reserved_range_() - , reserved_name_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , options_(nullptr){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_; +PROTOBUF_CONSTEXPR EnumDescriptorProto::EnumDescriptorProto( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.value_)*/{} + , /*decltype(_impl_.reserved_range_)*/{} + , /*decltype(_impl_.reserved_name_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.options_)*/nullptr} {} struct EnumDescriptorProtoDefaultTypeInternal { - constexpr EnumDescriptorProtoDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumDescriptorProtoDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~EnumDescriptorProtoDefaultTypeInternal() {} union { EnumDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; -constexpr EnumValueDescriptorProto::EnumValueDescriptorProto( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , options_(nullptr) - , number_(0){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; +PROTOBUF_CONSTEXPR EnumValueDescriptorProto::EnumValueDescriptorProto( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.options_)*/nullptr + , /*decltype(_impl_.number_)*/0} {} struct EnumValueDescriptorProtoDefaultTypeInternal { - constexpr EnumValueDescriptorProtoDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumValueDescriptorProtoDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~EnumValueDescriptorProtoDefaultTypeInternal() {} union { EnumValueDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; -constexpr ServiceDescriptorProto::ServiceDescriptorProto( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : method_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , options_(nullptr){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; +PROTOBUF_CONSTEXPR ServiceDescriptorProto::ServiceDescriptorProto( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.method_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.options_)*/nullptr} {} struct ServiceDescriptorProtoDefaultTypeInternal { - constexpr ServiceDescriptorProtoDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR ServiceDescriptorProtoDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~ServiceDescriptorProtoDefaultTypeInternal() {} union { ServiceDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; -constexpr MethodDescriptorProto::MethodDescriptorProto( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , input_type_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , output_type_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , options_(nullptr) - , client_streaming_(false) - , server_streaming_(false){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; +PROTOBUF_CONSTEXPR MethodDescriptorProto::MethodDescriptorProto( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.input_type_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.output_type_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.options_)*/nullptr + , /*decltype(_impl_.client_streaming_)*/false + , /*decltype(_impl_.server_streaming_)*/false} {} struct MethodDescriptorProtoDefaultTypeInternal { - constexpr MethodDescriptorProtoDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR MethodDescriptorProtoDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~MethodDescriptorProtoDefaultTypeInternal() {} union { MethodDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; -constexpr FileOptions::FileOptions( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : uninterpreted_option_() - , java_package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , java_outer_classname_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , go_package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , objc_class_prefix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , csharp_namespace_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , swift_prefix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , php_class_prefix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , php_namespace_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , php_metadata_namespace_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , ruby_package_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , java_multiple_files_(false) - , java_generate_equals_and_hash_(false) - , java_string_check_utf8_(false) - , cc_generic_services_(false) - , java_generic_services_(false) - , py_generic_services_(false) - , php_generic_services_(false) - , deprecated_(false) - , optimize_for_(1) - - , cc_enable_arenas_(true){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; +PROTOBUF_CONSTEXPR FileOptions::FileOptions( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._extensions_)*/{} + , /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.uninterpreted_option_)*/{} + , /*decltype(_impl_.java_package_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.java_outer_classname_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.go_package_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.objc_class_prefix_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.csharp_namespace_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.swift_prefix_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.php_class_prefix_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.php_namespace_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.php_metadata_namespace_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.ruby_package_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.java_multiple_files_)*/false + , /*decltype(_impl_.java_generate_equals_and_hash_)*/false + , /*decltype(_impl_.java_string_check_utf8_)*/false + , /*decltype(_impl_.cc_generic_services_)*/false + , /*decltype(_impl_.java_generic_services_)*/false + , /*decltype(_impl_.py_generic_services_)*/false + , /*decltype(_impl_.php_generic_services_)*/false + , /*decltype(_impl_.deprecated_)*/false + , /*decltype(_impl_.optimize_for_)*/1 + , /*decltype(_impl_.cc_enable_arenas_)*/true} {} struct FileOptionsDefaultTypeInternal { - constexpr FileOptionsDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FileOptionsDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~FileOptionsDefaultTypeInternal() {} union { FileOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FileOptionsDefaultTypeInternal _FileOptions_default_instance_; -constexpr MessageOptions::MessageOptions( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : uninterpreted_option_() - , message_set_wire_format_(false) - , no_standard_descriptor_accessor_(false) - , deprecated_(false) - , map_entry_(false){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileOptionsDefaultTypeInternal _FileOptions_default_instance_; +PROTOBUF_CONSTEXPR MessageOptions::MessageOptions( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._extensions_)*/{} + , /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.uninterpreted_option_)*/{} + , /*decltype(_impl_.message_set_wire_format_)*/false + , /*decltype(_impl_.no_standard_descriptor_accessor_)*/false + , /*decltype(_impl_.deprecated_)*/false + , /*decltype(_impl_.map_entry_)*/false} {} struct MessageOptionsDefaultTypeInternal { - constexpr MessageOptionsDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR MessageOptionsDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~MessageOptionsDefaultTypeInternal() {} union { MessageOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; -constexpr FieldOptions::FieldOptions( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : uninterpreted_option_() - , ctype_(0) - - , packed_(false) - , lazy_(false) - , deprecated_(false) - , weak_(false) - , jstype_(0) -{} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; +PROTOBUF_CONSTEXPR FieldOptions::FieldOptions( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._extensions_)*/{} + , /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.uninterpreted_option_)*/{} + , /*decltype(_impl_.ctype_)*/0 + , /*decltype(_impl_.jstype_)*/0 + , /*decltype(_impl_.packed_)*/false + , /*decltype(_impl_.lazy_)*/false + , /*decltype(_impl_.unverified_lazy_)*/false + , /*decltype(_impl_.deprecated_)*/false + , /*decltype(_impl_.weak_)*/false} {} struct FieldOptionsDefaultTypeInternal { - constexpr FieldOptionsDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FieldOptionsDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~FieldOptionsDefaultTypeInternal() {} union { FieldOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; -constexpr OneofOptions::OneofOptions( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : uninterpreted_option_(){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; +PROTOBUF_CONSTEXPR OneofOptions::OneofOptions( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._extensions_)*/{} + , /*decltype(_impl_.uninterpreted_option_)*/{} + , /*decltype(_impl_._cached_size_)*/{}} {} struct OneofOptionsDefaultTypeInternal { - constexpr OneofOptionsDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR OneofOptionsDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~OneofOptionsDefaultTypeInternal() {} union { OneofOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; -constexpr EnumOptions::EnumOptions( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : uninterpreted_option_() - , allow_alias_(false) - , deprecated_(false){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; +PROTOBUF_CONSTEXPR EnumOptions::EnumOptions( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._extensions_)*/{} + , /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.uninterpreted_option_)*/{} + , /*decltype(_impl_.allow_alias_)*/false + , /*decltype(_impl_.deprecated_)*/false} {} struct EnumOptionsDefaultTypeInternal { - constexpr EnumOptionsDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumOptionsDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~EnumOptionsDefaultTypeInternal() {} union { EnumOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; -constexpr EnumValueOptions::EnumValueOptions( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : uninterpreted_option_() - , deprecated_(false){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; +PROTOBUF_CONSTEXPR EnumValueOptions::EnumValueOptions( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._extensions_)*/{} + , /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.uninterpreted_option_)*/{} + , /*decltype(_impl_.deprecated_)*/false} {} struct EnumValueOptionsDefaultTypeInternal { - constexpr EnumValueOptionsDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumValueOptionsDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~EnumValueOptionsDefaultTypeInternal() {} union { EnumValueOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; -constexpr ServiceOptions::ServiceOptions( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : uninterpreted_option_() - , deprecated_(false){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; +PROTOBUF_CONSTEXPR ServiceOptions::ServiceOptions( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._extensions_)*/{} + , /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.uninterpreted_option_)*/{} + , /*decltype(_impl_.deprecated_)*/false} {} struct ServiceOptionsDefaultTypeInternal { - constexpr ServiceOptionsDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR ServiceOptionsDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~ServiceOptionsDefaultTypeInternal() {} union { ServiceOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; -constexpr MethodOptions::MethodOptions( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : uninterpreted_option_() - , deprecated_(false) - , idempotency_level_(0) -{} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; +PROTOBUF_CONSTEXPR MethodOptions::MethodOptions( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._extensions_)*/{} + , /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.uninterpreted_option_)*/{} + , /*decltype(_impl_.deprecated_)*/false + , /*decltype(_impl_.idempotency_level_)*/0} {} struct MethodOptionsDefaultTypeInternal { - constexpr MethodOptionsDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR MethodOptionsDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~MethodOptionsDefaultTypeInternal() {} union { MethodOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; -constexpr UninterpretedOption_NamePart::UninterpretedOption_NamePart( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : name_part_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , is_extension_(false){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; +PROTOBUF_CONSTEXPR UninterpretedOption_NamePart::UninterpretedOption_NamePart( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.name_part_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.is_extension_)*/false} {} struct UninterpretedOption_NamePartDefaultTypeInternal { - constexpr UninterpretedOption_NamePartDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR UninterpretedOption_NamePartDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~UninterpretedOption_NamePartDefaultTypeInternal() {} union { UninterpretedOption_NamePart _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; -constexpr UninterpretedOption::UninterpretedOption( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : name_() - , identifier_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , string_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , aggregate_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , positive_int_value_(uint64_t{0u}) - , negative_int_value_(int64_t{0}) - , double_value_(0){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; +PROTOBUF_CONSTEXPR UninterpretedOption::UninterpretedOption( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.name_)*/{} + , /*decltype(_impl_.identifier_value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.string_value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.aggregate_value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.positive_int_value_)*/uint64_t{0u} + , /*decltype(_impl_.negative_int_value_)*/int64_t{0} + , /*decltype(_impl_.double_value_)*/0} {} struct UninterpretedOptionDefaultTypeInternal { - constexpr UninterpretedOptionDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR UninterpretedOptionDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~UninterpretedOptionDefaultTypeInternal() {} union { UninterpretedOption _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; -constexpr SourceCodeInfo_Location::SourceCodeInfo_Location( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : path_() - , _path_cached_byte_size_(0) - , span_() - , _span_cached_byte_size_(0) - , leading_detached_comments_() - , leading_comments_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , trailing_comments_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; +PROTOBUF_CONSTEXPR SourceCodeInfo_Location::SourceCodeInfo_Location( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.path_)*/{} + , /*decltype(_impl_._path_cached_byte_size_)*/{0} + , /*decltype(_impl_.span_)*/{} + , /*decltype(_impl_._span_cached_byte_size_)*/{0} + , /*decltype(_impl_.leading_detached_comments_)*/{} + , /*decltype(_impl_.leading_comments_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.trailing_comments_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}} {} struct SourceCodeInfo_LocationDefaultTypeInternal { - constexpr SourceCodeInfo_LocationDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR SourceCodeInfo_LocationDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~SourceCodeInfo_LocationDefaultTypeInternal() {} union { SourceCodeInfo_Location _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; -constexpr SourceCodeInfo::SourceCodeInfo( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : location_(){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; +PROTOBUF_CONSTEXPR SourceCodeInfo::SourceCodeInfo( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.location_)*/{} + , /*decltype(_impl_._cached_size_)*/{}} {} struct SourceCodeInfoDefaultTypeInternal { - constexpr SourceCodeInfoDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR SourceCodeInfoDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~SourceCodeInfoDefaultTypeInternal() {} union { SourceCodeInfo _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; -constexpr GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : path_() - , _path_cached_byte_size_(0) - , source_file_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , begin_(0) - , end_(0){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; +PROTOBUF_CONSTEXPR GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.path_)*/{} + , /*decltype(_impl_._path_cached_byte_size_)*/{0} + , /*decltype(_impl_.source_file_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.begin_)*/0 + , /*decltype(_impl_.end_)*/0} {} struct GeneratedCodeInfo_AnnotationDefaultTypeInternal { - constexpr GeneratedCodeInfo_AnnotationDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR GeneratedCodeInfo_AnnotationDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~GeneratedCodeInfo_AnnotationDefaultTypeInternal() {} union { GeneratedCodeInfo_Annotation _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; -constexpr GeneratedCodeInfo::GeneratedCodeInfo( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : annotation_(){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; +PROTOBUF_CONSTEXPR GeneratedCodeInfo::GeneratedCodeInfo( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.annotation_)*/{} + , /*decltype(_impl_._cached_size_)*/{}} {} struct GeneratedCodeInfoDefaultTypeInternal { - constexpr GeneratedCodeInfoDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR GeneratedCodeInfoDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~GeneratedCodeInfoDefaultTypeInternal() {} union { GeneratedCodeInfo _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[27]; -static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[6]; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto = nullptr; +static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[27]; +static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[6]; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto = nullptr; const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ @@ -460,25 +517,25 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, file_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _impl_.file_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, package_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, dependency_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, public_dependency_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, weak_dependency_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, message_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, enum_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, service_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, extension_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, source_code_info_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, syntax_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.package_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.dependency_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.public_dependency_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.weak_dependency_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.message_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.enum_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.service_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.extension_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.source_code_info_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.syntax_), 0, 1, ~0u, @@ -491,44 +548,44 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO 3, 4, 2, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, start_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, end_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.start_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.end_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.options_), 1, 2, 0, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, start_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, end_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.start_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.end_), 0, 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, field_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, extension_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, nested_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, enum_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, extension_range_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, oneof_decl_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, reserved_range_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, reserved_name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.field_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.nested_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.enum_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_range_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.oneof_decl_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_range_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_name_), 0, ~0u, ~0u, @@ -541,28 +598,28 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _extensions_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_._extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, uninterpreted_option_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_.uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, number_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, label_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, type_name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, extendee_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, default_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, oneof_index_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, json_name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, proto3_optional_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.number_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.label_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.extendee_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.default_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.oneof_index_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.json_name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.proto3_optional_), 0, 6, 9, @@ -574,111 +631,111 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO 4, 5, 8, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.options_), 0, 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, start_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, end_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.start_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.end_), 0, 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, reserved_range_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, reserved_name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_range_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_name_), 0, ~0u, 1, ~0u, ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, number_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.number_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.options_), 0, 2, 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, method_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.method_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.options_), 0, ~0u, 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, input_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, output_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, client_streaming_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, server_streaming_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.input_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.output_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.client_streaming_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.server_streaming_), 0, 1, 2, 3, 4, 5, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _extensions_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, java_package_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, java_outer_classname_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, java_multiple_files_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, java_generate_equals_and_hash_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, java_string_check_utf8_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, optimize_for_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, go_package_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, cc_generic_services_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, java_generic_services_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, py_generic_services_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, php_generic_services_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, cc_enable_arenas_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, objc_class_prefix_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, csharp_namespace_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, swift_prefix_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, php_class_prefix_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, php_namespace_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, php_metadata_namespace_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, ruby_package_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_package_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_outer_classname_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_multiple_files_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generate_equals_and_hash_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_string_check_utf8_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.optimize_for_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.go_package_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_generic_services_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generic_services_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.py_generic_services_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_generic_services_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_enable_arenas_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.objc_class_prefix_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.csharp_namespace_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.swift_prefix_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_class_prefix_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_namespace_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_metadata_namespace_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.ruby_package_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.uninterpreted_option_), 0, 1, 10, @@ -700,116 +757,118 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO 8, 9, ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _extensions_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, message_set_wire_format_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, no_standard_descriptor_accessor_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, map_entry_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.message_set_wire_format_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.no_standard_descriptor_accessor_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.map_entry_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.uninterpreted_option_), 0, 1, 2, 3, ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _extensions_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, ctype_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, packed_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, jstype_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, lazy_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, weak_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.ctype_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.packed_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.jstype_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.lazy_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.unverified_lazy_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.weak_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.uninterpreted_option_), 0, - 1, - 5, 2, + 1, 3, 4, + 5, + 6, ~0u, ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _extensions_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_._extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, uninterpreted_option_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_.uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _extensions_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, allow_alias_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.allow_alias_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.uninterpreted_option_), 0, 1, ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _extensions_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.uninterpreted_option_), 0, ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _extensions_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.uninterpreted_option_), 0, ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _extensions_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._extensions_), ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, idempotency_level_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.idempotency_level_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.uninterpreted_option_), 0, 1, ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, name_part_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, is_extension_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.name_part_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.is_extension_), 0, 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, identifier_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, positive_int_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, negative_int_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, double_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, string_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, aggregate_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.identifier_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.positive_int_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.negative_int_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.double_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.string_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.aggregate_value_), ~0u, 0, 3, @@ -817,17 +876,17 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO 5, 1, 2, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, path_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, span_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, leading_comments_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, trailing_comments_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, leading_detached_comments_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.path_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.span_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_comments_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.trailing_comments_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_detached_comments_), ~0u, ~0u, 0, @@ -839,17 +898,17 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, location_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _impl_.location_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, path_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, source_file_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, begin_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, end_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.path_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.source_file_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.begin_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.end_), ~0u, 0, 1, @@ -860,9 +919,9 @@ const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PRO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, annotation_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _impl_.annotation_), }; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet)}, { 7, 25, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto)}, { 37, 46, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange)}, @@ -878,48 +937,48 @@ static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOB { 180, 192, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto)}, { 198, 225, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileOptions)}, { 246, 257, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MessageOptions)}, - { 262, 275, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)}, - { 282, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)}, - { 289, 298, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)}, - { 301, 309, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)}, - { 311, 319, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)}, - { 321, 330, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)}, - { 333, 341, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)}, - { 343, 356, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)}, - { 363, 374, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)}, - { 379, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)}, - { 386, 396, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)}, - { 400, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)}, + { 262, 276, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)}, + { 284, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)}, + { 291, 300, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)}, + { 303, 311, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)}, + { 313, 321, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)}, + { 323, 332, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)}, + { 335, 343, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)}, + { 345, 358, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)}, + { 365, 376, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)}, + { 381, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)}, + { 388, 398, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)}, + { 402, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)}, }; -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FileDescriptorSet_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FileDescriptorProto_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ExtensionRange_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ReservedRange_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_DescriptorProto_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FieldDescriptorProto_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_OneofDescriptorProto_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_EnumReservedRange_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_EnumValueDescriptorProto_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_ServiceDescriptorProto_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_MethodDescriptorProto_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_NamePart_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_Location_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_Annotation_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_), +static const ::_pb::Message* const file_default_instances[] = { + &::PROTOBUF_NAMESPACE_ID::_FileDescriptorSet_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FileDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ExtensionRange_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ReservedRange_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FieldDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_OneofDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_EnumReservedRange_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumValueDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_ServiceDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_MethodDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_NamePart_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_Location_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_Annotation_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_._instance, }; const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = @@ -1023,72 +1082,74 @@ const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PR "ed\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024un" "interpreted_option\030\347\007 \003(\0132$.google.proto" "buf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005" - "J\004\010\005\020\006J\004\010\006\020\007J\004\010\010\020\tJ\004\010\t\020\n\"\236\003\n\014FieldOption" + "J\004\010\005\020\006J\004\010\006\020\007J\004\010\010\020\tJ\004\010\t\020\n\"\276\003\n\014FieldOption" "s\022:\n\005ctype\030\001 \001(\0162#.google.protobuf.Field" "Options.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n" "\006jstype\030\006 \001(\0162$.google.protobuf.FieldOpt" "ions.JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005fa" - "lse\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n" + "lse\022\036\n\017unverified_lazy\030\017 \001(\010:\005false\022\031\n\nd" + "eprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005fa" + "lse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.goo" + "gle.protobuf.UninterpretedOption\"/\n\005CTyp" + "e\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020" + "\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_STRING\020" + "\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014One" + "ofOptions\022C\n\024uninterpreted_option\030\347\007 \003(\013" + "2$.google.protobuf.UninterpretedOption*\t" + "\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptions\022\023\n\013allow_alias" + "\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n\024uni" + "nterpreted_option\030\347\007 \003(\0132$.google.protob" + "uf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"" + "}\n\020EnumValueOptions\022\031\n\ndeprecated\030\001 \001(\010:" + "\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$." + "google.protobuf.UninterpretedOption*\t\010\350\007" + "\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndeprecated\030!" " \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003" "(\0132$.google.protobuf.UninterpretedOption" - "\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRIN" - "G_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS" - "_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020" - "\005\"^\n\014OneofOptions\022C\n\024uninterpreted_optio" - "n\030\347\007 \003(\0132$.google.protobuf.Uninterpreted" - "Option*\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptions\022\023\n\013all" - "ow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005fals" - "e\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl" - "e.protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200" - "\002J\004\010\005\020\006\"}\n\020EnumValueOptions\022\031\n\ndeprecate" - "d\030\001 \001(\010:\005false\022C\n\024uninterpreted_option\030\347" - "\007 \003(\0132$.google.protobuf.UninterpretedOpt" - "ion*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndepr" - "ecated\030! \001(\010:\005false\022C\n\024uninterpreted_opt" - "ion\030\347\007 \003(\0132$.google.protobuf.Uninterpret" - "edOption*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n" - "\ndeprecated\030! \001(\010:\005false\022_\n\021idempotency_" - "level\030\" \001(\0162/.google.protobuf.MethodOpti" - "ons.IdempotencyLevel:\023IDEMPOTENCY_UNKNOW" - "N\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl" - "e.protobuf.UninterpretedOption\"P\n\020Idempo" - "tencyLevel\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017N" - "O_SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200" - "\200\200\002\"\236\002\n\023UninterpretedOption\022;\n\004name\030\002 \003(" - "\0132-.google.protobuf.UninterpretedOption." - "NamePart\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022po" - "sitive_int_value\030\004 \001(\004\022\032\n\022negative_int_v" - "alue\030\005 \001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014stri" - "ng_value\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\032" - "3\n\010NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_ext" - "ension\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010locat" - "ion\030\001 \003(\0132(.google.protobuf.SourceCodeIn" - "fo.Location\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002" - "\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments" - "\030\003 \001(\t\022\031\n\021trailing_comments\030\004 \001(\t\022!\n\031lea" - "ding_detached_comments\030\006 \003(\t\"\247\001\n\021Generat" - "edCodeInfo\022A\n\nannotation\030\001 \003(\0132-.google." - "protobuf.GeneratedCodeInfo.Annotation\032O\n" - "\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source_" - "file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B~" - "\n\023com.google.protobufB\020DescriptorProtosH" - "\001Z-google.golang.org/protobuf/types/desc" - "riptorpb\370\001\001\242\002\003GPB\252\002\032Google.Protobuf.Refl" - "ection" + "*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n\ndepreca" + "ted\030! \001(\010:\005false\022_\n\021idempotency_level\030\" " + "\001(\0162/.google.protobuf.MethodOptions.Idem" + "potencyLevel:\023IDEMPOTENCY_UNKNOWN\022C\n\024uni" + "nterpreted_option\030\347\007 \003(\0132$.google.protob" + "uf.UninterpretedOption\"P\n\020IdempotencyLev" + "el\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_E" + "FFECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023" + "UninterpretedOption\022;\n\004name\030\002 \003(\0132-.goog" + "le.protobuf.UninterpretedOption.NamePart" + "\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022positive_i" + "nt_value\030\004 \001(\004\022\032\n\022negative_int_value\030\005 \001" + "(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string_value" + "\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010NameP" + "art\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extension\030\002" + " \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location\030\001 \003(" + "\0132(.google.protobuf.SourceCodeInfo.Locat" + "ion\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004sp" + "an\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022\031" + "\n\021trailing_comments\030\004 \001(\t\022!\n\031leading_det" + "ached_comments\030\006 \003(\t\"\247\001\n\021GeneratedCodeIn" + "fo\022A\n\nannotation\030\001 \003(\0132-.google.protobuf" + ".GeneratedCodeInfo.Annotation\032O\n\nAnnotat" + "ion\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source_file\030\002 \001" + "(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B~\n\023com.go" + "ogle.protobufB\020DescriptorProtosH\001Z-googl" + "e.golang.org/protobuf/types/descriptorpb" + "\370\001\001\242\002\003GPB\252\002\032Google.Protobuf.Reflection" ; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = { - false, false, 6046, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, "google/protobuf/descriptor.proto", - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, nullptr, 0, 27, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto, +static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = { + false, false, 6078, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, + "google/protobuf/descriptor.proto", + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, nullptr, 0, 27, + schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, + file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter() { +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto; } // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fdescriptor_2eproto(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fdescriptor_2eproto(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); PROTOBUF_NAMESPACE_OPEN const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldDescriptorProto_Type_descriptor() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); @@ -1267,43 +1328,47 @@ class FileDescriptorSet::_Internal { FileDescriptorSet::FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - file_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.FileDescriptorSet) } FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - file_(from.file_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + FileDescriptorSet* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.file_){from._impl_.file_} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorSet) } -inline void FileDescriptorSet::SharedCtor() { +inline void FileDescriptorSet::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.file_){arena} + , /*decltype(_impl_._cached_size_)*/{} + }; } FileDescriptorSet::~FileDescriptorSet() { // @@protoc_insertion_point(destructor:google.protobuf.FileDescriptorSet) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void FileDescriptorSet::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.file_.~RepeatedPtrField(); } -void FileDescriptorSet::ArenaDtor(void* object) { - FileDescriptorSet* _this = reinterpret_cast< FileDescriptorSet* >(object); - (void)_this; -} -void FileDescriptorSet::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void FileDescriptorSet::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void FileDescriptorSet::Clear() { @@ -1312,15 +1377,15 @@ void FileDescriptorSet::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - file_.Clear(); + _impl_.file_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* FileDescriptorSet::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* FileDescriptorSet::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // repeated .google.protobuf.FileDescriptorProto file = 1; case 1: @@ -1365,15 +1430,15 @@ uint8_t* FileDescriptorSet::_InternalSerialize( (void) cached_has_bits; // repeated .google.protobuf.FileDescriptorProto file = 1; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_file_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_file_size()); i < n; i++) { + const auto& repfield = this->_internal_file(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, this->_internal_file(i), target, stream); + InternalWriteMessage(1, repfield, repfield.GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileDescriptorSet) @@ -1390,35 +1455,31 @@ size_t FileDescriptorSet::ByteSizeLong() const { // repeated .google.protobuf.FileDescriptorProto file = 1; total_size += 1UL * this->_internal_file_size(); - for (const auto& msg : this->file_) { + for (const auto& msg : this->_impl_.file_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FileDescriptorSet::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, FileDescriptorSet::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FileDescriptorSet::GetClassData() const { return &_class_data_; } -void FileDescriptorSet::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<FileDescriptorSet *>(to)->MergeFrom( - static_cast<const FileDescriptorSet &>(from)); -} - -void FileDescriptorSet::MergeFrom(const FileDescriptorSet& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet) - GOOGLE_DCHECK_NE(&from, this); +void FileDescriptorSet::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<FileDescriptorSet*>(&to_msg); + auto& from = static_cast<const FileDescriptorSet&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - file_.MergeFrom(from.file_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.file_.MergeFrom(from._impl_.file_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void FileDescriptorSet::CopyFrom(const FileDescriptorSet& from) { @@ -1429,7 +1490,7 @@ void FileDescriptorSet::CopyFrom(const FileDescriptorSet& from) { } bool FileDescriptorSet::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(file_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.file_)) return false; return true; } @@ -1437,11 +1498,11 @@ bool FileDescriptorSet::IsInitialized() const { void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - file_.InternalSwap(&other->file_); + _impl_.file_.InternalSwap(&other->_impl_.file_); } ::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorSet::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[0]); } @@ -1450,7 +1511,7 @@ void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) { class FileDescriptorProto::_Internal { public: - using HasBits = decltype(std::declval<FileDescriptorProto>()._has_bits_); + using HasBits = decltype(std::declval<FileDescriptorProto>()._impl_._has_bits_); static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -1472,119 +1533,132 @@ class FileDescriptorProto::_Internal { const ::PROTOBUF_NAMESPACE_ID::FileOptions& FileDescriptorProto::_Internal::options(const FileDescriptorProto* msg) { - return *msg->options_; + return *msg->_impl_.options_; } const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo& FileDescriptorProto::_Internal::source_code_info(const FileDescriptorProto* msg) { - return *msg->source_code_info_; + return *msg->_impl_.source_code_info_; } FileDescriptorProto::FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - dependency_(arena), - message_type_(arena), - enum_type_(arena), - service_(arena), - extension_(arena), - public_dependency_(arena), - weak_dependency_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.FileDescriptorProto) } FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - dependency_(from.dependency_), - message_type_(from.message_type_), - enum_type_(from.enum_type_), - service_(from.service_), - extension_(from.extension_), - public_dependency_(from.public_dependency_), - weak_dependency_(from.weak_dependency_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + FileDescriptorProto* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.dependency_){from._impl_.dependency_} + , decltype(_impl_.message_type_){from._impl_.message_type_} + , decltype(_impl_.enum_type_){from._impl_.enum_type_} + , decltype(_impl_.service_){from._impl_.service_} + , decltype(_impl_.extension_){from._impl_.extension_} + , decltype(_impl_.public_dependency_){from._impl_.public_dependency_} + , decltype(_impl_.weak_dependency_){from._impl_.weak_dependency_} + , decltype(_impl_.name_){} + , decltype(_impl_.package_){} + , decltype(_impl_.syntax_){} + , decltype(_impl_.options_){nullptr} + , decltype(_impl_.source_code_info_){nullptr}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } - package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.package_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.package_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_package()) { - package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_package(), - GetArenaForAllocation()); + _this->_impl_.package_.Set(from._internal_package(), + _this->GetArenaForAllocation()); } - syntax_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.syntax_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.syntax_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_syntax()) { - syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_syntax(), - GetArenaForAllocation()); + _this->_impl_.syntax_.Set(from._internal_syntax(), + _this->GetArenaForAllocation()); } if (from._internal_has_options()) { - options_ = new ::PROTOBUF_NAMESPACE_ID::FileOptions(*from.options_); - } else { - options_ = nullptr; + _this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::FileOptions(*from._impl_.options_); } if (from._internal_has_source_code_info()) { - source_code_info_ = new ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo(*from.source_code_info_); - } else { - source_code_info_ = nullptr; + _this->_impl_.source_code_info_ = new ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo(*from._impl_.source_code_info_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorProto) } -inline void FileDescriptorProto::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -syntax_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&source_code_info_) - - reinterpret_cast<char*>(&options_)) + sizeof(source_code_info_)); +inline void FileDescriptorProto::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.dependency_){arena} + , decltype(_impl_.message_type_){arena} + , decltype(_impl_.enum_type_){arena} + , decltype(_impl_.service_){arena} + , decltype(_impl_.extension_){arena} + , decltype(_impl_.public_dependency_){arena} + , decltype(_impl_.weak_dependency_){arena} + , decltype(_impl_.name_){} + , decltype(_impl_.package_){} + , decltype(_impl_.syntax_){} + , decltype(_impl_.options_){nullptr} + , decltype(_impl_.source_code_info_){nullptr} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.package_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.package_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.syntax_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.syntax_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } FileDescriptorProto::~FileDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.FileDescriptorProto) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void FileDescriptorProto::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - syntax_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete options_; - if (this != internal_default_instance()) delete source_code_info_; + _impl_.dependency_.~RepeatedPtrField(); + _impl_.message_type_.~RepeatedPtrField(); + _impl_.enum_type_.~RepeatedPtrField(); + _impl_.service_.~RepeatedPtrField(); + _impl_.extension_.~RepeatedPtrField(); + _impl_.public_dependency_.~RepeatedField(); + _impl_.weak_dependency_.~RepeatedField(); + _impl_.name_.Destroy(); + _impl_.package_.Destroy(); + _impl_.syntax_.Destroy(); + if (this != internal_default_instance()) delete _impl_.options_; + if (this != internal_default_instance()) delete _impl_.source_code_info_; } -void FileDescriptorProto::ArenaDtor(void* object) { - FileDescriptorProto* _this = reinterpret_cast< FileDescriptorProto* >(object); - (void)_this; -} -void FileDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void FileDescriptorProto::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void FileDescriptorProto::Clear() { @@ -1593,53 +1667,53 @@ void FileDescriptorProto::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - dependency_.Clear(); - message_type_.Clear(); - enum_type_.Clear(); - service_.Clear(); - extension_.Clear(); - public_dependency_.Clear(); - weak_dependency_.Clear(); - cached_has_bits = _has_bits_[0]; + _impl_.dependency_.Clear(); + _impl_.message_type_.Clear(); + _impl_.enum_type_.Clear(); + _impl_.service_.Clear(); + _impl_.extension_.Clear(); + _impl_.public_dependency_.Clear(); + _impl_.weak_dependency_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000001fu) { if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - package_.ClearNonDefaultToEmpty(); + _impl_.package_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - syntax_.ClearNonDefaultToEmpty(); + _impl_.syntax_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000008u) { - GOOGLE_DCHECK(options_ != nullptr); - options_->Clear(); + GOOGLE_DCHECK(_impl_.options_ != nullptr); + _impl_.options_->Clear(); } if (cached_has_bits & 0x00000010u) { - GOOGLE_DCHECK(source_code_info_ != nullptr); - source_code_info_->Clear(); + GOOGLE_DCHECK(_impl_.source_code_info_ != nullptr); + _impl_.source_code_info_->Clear(); } } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* FileDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -1647,11 +1721,11 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_package(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.package"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.package"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -1662,11 +1736,11 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME do { ptr += 1; auto str = _internal_add_dependency(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.dependency"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.dependency"); + #endif // !NDEBUG if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); } else @@ -1776,11 +1850,11 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME case 12: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 98)) { auto str = _internal_mutable_syntax(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.syntax"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileDescriptorProto.syntax"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -1800,7 +1874,7 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -1814,7 +1888,7 @@ uint8_t* FileDescriptorProto::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1846,63 +1920,61 @@ uint8_t* FileDescriptorProto::_InternalSerialize( } // repeated .google.protobuf.DescriptorProto message_type = 4; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_message_type_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_message_type_size()); i < n; i++) { + const auto& repfield = this->_internal_message_type(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(4, this->_internal_message_type(i), target, stream); + InternalWriteMessage(4, repfield, repfield.GetCachedSize(), target, stream); } // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_enum_type_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_enum_type_size()); i < n; i++) { + const auto& repfield = this->_internal_enum_type(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(5, this->_internal_enum_type(i), target, stream); + InternalWriteMessage(5, repfield, repfield.GetCachedSize(), target, stream); } // repeated .google.protobuf.ServiceDescriptorProto service = 6; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_service_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_service_size()); i < n; i++) { + const auto& repfield = this->_internal_service(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(6, this->_internal_service(i), target, stream); + InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream); } // repeated .google.protobuf.FieldDescriptorProto extension = 7; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_extension_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_extension_size()); i < n; i++) { + const auto& repfield = this->_internal_extension(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(7, this->_internal_extension(i), target, stream); + InternalWriteMessage(7, repfield, repfield.GetCachedSize(), target, stream); } // optional .google.protobuf.FileOptions options = 8; if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 8, _Internal::options(this), target, stream); + InternalWriteMessage(8, _Internal::options(this), + _Internal::options(this).GetCachedSize(), target, stream); } // optional .google.protobuf.SourceCodeInfo source_code_info = 9; if (cached_has_bits & 0x00000010u) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 9, _Internal::source_code_info(this), target, stream); + InternalWriteMessage(9, _Internal::source_code_info(this), + _Internal::source_code_info(this).GetCachedSize(), target, stream); } // repeated int32 public_dependency = 10; for (int i = 0, n = this->_internal_public_dependency_size(); i < n; i++) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(10, this->_internal_public_dependency(i), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(10, this->_internal_public_dependency(i), target); } // repeated int32 weak_dependency = 11; for (int i = 0, n = this->_internal_weak_dependency_size(); i < n; i++) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(11, this->_internal_weak_dependency(i), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(11, this->_internal_weak_dependency(i), target); } // optional string syntax = 12; @@ -1916,7 +1988,7 @@ uint8_t* FileDescriptorProto::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileDescriptorProto) @@ -1933,59 +2005,59 @@ size_t FileDescriptorProto::ByteSizeLong() const { // repeated string dependency = 3; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(dependency_.size()); - for (int i = 0, n = dependency_.size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.dependency_.size()); + for (int i = 0, n = _impl_.dependency_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - dependency_.Get(i)); + _impl_.dependency_.Get(i)); } // repeated .google.protobuf.DescriptorProto message_type = 4; total_size += 1UL * this->_internal_message_type_size(); - for (const auto& msg : this->message_type_) { + for (const auto& msg : this->_impl_.message_type_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; total_size += 1UL * this->_internal_enum_type_size(); - for (const auto& msg : this->enum_type_) { + for (const auto& msg : this->_impl_.enum_type_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.ServiceDescriptorProto service = 6; total_size += 1UL * this->_internal_service_size(); - for (const auto& msg : this->service_) { + for (const auto& msg : this->_impl_.service_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.FieldDescriptorProto extension = 7; total_size += 1UL * this->_internal_extension_size(); - for (const auto& msg : this->extension_) { + for (const auto& msg : this->_impl_.extension_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated int32 public_dependency = 10; { - size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - Int32Size(this->public_dependency_); + size_t data_size = ::_pbi::WireFormatLite:: + Int32Size(this->_impl_.public_dependency_); total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_public_dependency_size()); + ::_pbi::FromIntSize(this->_internal_public_dependency_size()); total_size += data_size; } // repeated int32 weak_dependency = 11; { - size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - Int32Size(this->weak_dependency_); + size_t data_size = ::_pbi::WireFormatLite:: + Int32Size(this->_impl_.weak_dependency_); total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_weak_dependency_size()); + ::_pbi::FromIntSize(this->_internal_weak_dependency_size()); total_size += data_size; } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000001fu) { // optional string name = 1; if (cached_has_bits & 0x00000001u) { @@ -2012,65 +2084,63 @@ size_t FileDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000008u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *options_); + *_impl_.options_); } // optional .google.protobuf.SourceCodeInfo source_code_info = 9; if (cached_has_bits & 0x00000010u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *source_code_info_); + *_impl_.source_code_info_); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FileDescriptorProto::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, FileDescriptorProto::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FileDescriptorProto::GetClassData() const { return &_class_data_; } -void FileDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<FileDescriptorProto *>(to)->MergeFrom( - static_cast<const FileDescriptorProto &>(from)); -} - -void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto) - GOOGLE_DCHECK_NE(&from, this); +void FileDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<FileDescriptorProto*>(&to_msg); + auto& from = static_cast<const FileDescriptorProto&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - dependency_.MergeFrom(from.dependency_); - message_type_.MergeFrom(from.message_type_); - enum_type_.MergeFrom(from.enum_type_); - service_.MergeFrom(from.service_); - extension_.MergeFrom(from.extension_); - public_dependency_.MergeFrom(from.public_dependency_); - weak_dependency_.MergeFrom(from.weak_dependency_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.dependency_.MergeFrom(from._impl_.dependency_); + _this->_impl_.message_type_.MergeFrom(from._impl_.message_type_); + _this->_impl_.enum_type_.MergeFrom(from._impl_.enum_type_); + _this->_impl_.service_.MergeFrom(from._impl_.service_); + _this->_impl_.extension_.MergeFrom(from._impl_.extension_); + _this->_impl_.public_dependency_.MergeFrom(from._impl_.public_dependency_); + _this->_impl_.weak_dependency_.MergeFrom(from._impl_.weak_dependency_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x0000001fu) { if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - _internal_set_package(from._internal_package()); + _this->_internal_set_package(from._internal_package()); } if (cached_has_bits & 0x00000004u) { - _internal_set_syntax(from._internal_syntax()); + _this->_internal_set_syntax(from._internal_syntax()); } if (cached_has_bits & 0x00000008u) { - _internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::FileOptions::MergeFrom(from._internal_options()); + _this->_internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::FileOptions::MergeFrom( + from._internal_options()); } if (cached_has_bits & 0x00000010u) { - _internal_mutable_source_code_info()->::PROTOBUF_NAMESPACE_ID::SourceCodeInfo::MergeFrom(from._internal_source_code_info()); + _this->_internal_mutable_source_code_info()->::PROTOBUF_NAMESPACE_ID::SourceCodeInfo::MergeFrom( + from._internal_source_code_info()); } } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void FileDescriptorProto::CopyFrom(const FileDescriptorProto& from) { @@ -2081,16 +2151,16 @@ void FileDescriptorProto::CopyFrom(const FileDescriptorProto& from) { } bool FileDescriptorProto::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(message_type_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.message_type_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(enum_type_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.enum_type_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(service_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.service_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(extension_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.extension_)) return false; if (_internal_has_options()) { - if (!options_->IsInitialized()) return false; + if (!_impl_.options_->IsInitialized()) return false; } return true; } @@ -2100,39 +2170,36 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - dependency_.InternalSwap(&other->dependency_); - message_type_.InternalSwap(&other->message_type_); - enum_type_.InternalSwap(&other->enum_type_); - service_.InternalSwap(&other->service_); - extension_.InternalSwap(&other->extension_); - public_dependency_.InternalSwap(&other->public_dependency_); - weak_dependency_.InternalSwap(&other->weak_dependency_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.dependency_.InternalSwap(&other->_impl_.dependency_); + _impl_.message_type_.InternalSwap(&other->_impl_.message_type_); + _impl_.enum_type_.InternalSwap(&other->_impl_.enum_type_); + _impl_.service_.InternalSwap(&other->_impl_.service_); + _impl_.extension_.InternalSwap(&other->_impl_.extension_); + _impl_.public_dependency_.InternalSwap(&other->_impl_.public_dependency_); + _impl_.weak_dependency_.InternalSwap(&other->_impl_.weak_dependency_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &package_, lhs_arena, - &other->package_, rhs_arena + &_impl_.package_, lhs_arena, + &other->_impl_.package_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &syntax_, lhs_arena, - &other->syntax_, rhs_arena + &_impl_.syntax_, lhs_arena, + &other->_impl_.syntax_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(FileDescriptorProto, source_code_info_) - + sizeof(FileDescriptorProto::source_code_info_) - - PROTOBUF_FIELD_OFFSET(FileDescriptorProto, options_)>( - reinterpret_cast<char*>(&options_), - reinterpret_cast<char*>(&other->options_)); + PROTOBUF_FIELD_OFFSET(FileDescriptorProto, _impl_.source_code_info_) + + sizeof(FileDescriptorProto::_impl_.source_code_info_) + - PROTOBUF_FIELD_OFFSET(FileDescriptorProto, _impl_.options_)>( + reinterpret_cast<char*>(&_impl_.options_), + reinterpret_cast<char*>(&other->_impl_.options_)); } ::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorProto::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[1]); } @@ -2141,7 +2208,7 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { class DescriptorProto_ExtensionRange::_Internal { public: - using HasBits = decltype(std::declval<DescriptorProto_ExtensionRange>()._has_bits_); + using HasBits = decltype(std::declval<DescriptorProto_ExtensionRange>()._impl_._has_bits_); static void set_has_start(HasBits* has_bits) { (*has_bits)[0] |= 2u; } @@ -2156,59 +2223,63 @@ class DescriptorProto_ExtensionRange::_Internal { const ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& DescriptorProto_ExtensionRange::_Internal::options(const DescriptorProto_ExtensionRange* msg) { - return *msg->options_; + return *msg->_impl_.options_; } DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto.ExtensionRange) } DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + DescriptorProto_ExtensionRange* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.options_){nullptr} + , decltype(_impl_.start_){} + , decltype(_impl_.end_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); if (from._internal_has_options()) { - options_ = new ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions(*from.options_); - } else { - options_ = nullptr; + _this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions(*from._impl_.options_); } - ::memcpy(&start_, &from.start_, - static_cast<size_t>(reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_)) + sizeof(end_)); + ::memcpy(&_impl_.start_, &from._impl_.start_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.end_) - + reinterpret_cast<char*>(&_impl_.start_)) + sizeof(_impl_.end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ExtensionRange) } -inline void DescriptorProto_ExtensionRange::SharedCtor() { -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&options_)) + sizeof(end_)); +inline void DescriptorProto_ExtensionRange::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.options_){nullptr} + , decltype(_impl_.start_){0} + , decltype(_impl_.end_){0} + }; } DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() { // @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto.ExtensionRange) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void DescriptorProto_ExtensionRange::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - if (this != internal_default_instance()) delete options_; + if (this != internal_default_instance()) delete _impl_.options_; } -void DescriptorProto_ExtensionRange::ArenaDtor(void* object) { - DescriptorProto_ExtensionRange* _this = reinterpret_cast< DescriptorProto_ExtensionRange* >(object); - (void)_this; -} -void DescriptorProto_ExtensionRange::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void DescriptorProto_ExtensionRange::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void DescriptorProto_ExtensionRange::Clear() { @@ -2217,32 +2288,32 @@ void DescriptorProto_ExtensionRange::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000001u) { - GOOGLE_DCHECK(options_ != nullptr); - options_->Clear(); + GOOGLE_DCHECK(_impl_.options_ != nullptr); + _impl_.options_->Clear(); } if (cached_has_bits & 0x00000006u) { - ::memset(&start_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_)) + sizeof(end_)); + ::memset(&_impl_.start_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.end_) - + reinterpret_cast<char*>(&_impl_.start_)) + sizeof(_impl_.end_)); } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional int32 start = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { _Internal::set_has_start(&has_bits); - start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -2251,7 +2322,7 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::PR case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { _Internal::set_has_end(&has_bits); - end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -2280,7 +2351,7 @@ const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::PR CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -2294,29 +2365,28 @@ uint8_t* DescriptorProto_ExtensionRange::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional int32 start = 1; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target); } // optional int32 end = 2; if (cached_has_bits & 0x00000004u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target); } // optional .google.protobuf.ExtensionRangeOptions options = 3; if (cached_has_bits & 0x00000001u) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 3, _Internal::options(this), target, stream); + InternalWriteMessage(3, _Internal::options(this), + _Internal::options(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto.ExtensionRange) @@ -2331,62 +2401,59 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000007u) { // optional .google.protobuf.ExtensionRangeOptions options = 3; if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *options_); + *_impl_.options_); } // optional int32 start = 1; if (cached_has_bits & 0x00000002u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_start()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_start()); } // optional int32 end = 2; if (cached_has_bits & 0x00000004u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_end()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_end()); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DescriptorProto_ExtensionRange::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, DescriptorProto_ExtensionRange::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DescriptorProto_ExtensionRange::GetClassData() const { return &_class_data_; } -void DescriptorProto_ExtensionRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<DescriptorProto_ExtensionRange *>(to)->MergeFrom( - static_cast<const DescriptorProto_ExtensionRange &>(from)); -} - -void DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRange& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange) - GOOGLE_DCHECK_NE(&from, this); +void DescriptorProto_ExtensionRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<DescriptorProto_ExtensionRange*>(&to_msg); + auto& from = static_cast<const DescriptorProto_ExtensionRange&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions::MergeFrom(from._internal_options()); + _this->_internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions::MergeFrom( + from._internal_options()); } if (cached_has_bits & 0x00000002u) { - start_ = from.start_; + _this->_impl_.start_ = from._impl_.start_; } if (cached_has_bits & 0x00000004u) { - end_ = from.end_; + _this->_impl_.end_ = from._impl_.end_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void DescriptorProto_ExtensionRange::CopyFrom(const DescriptorProto_ExtensionRange& from) { @@ -2398,7 +2465,7 @@ void DescriptorProto_ExtensionRange::CopyFrom(const DescriptorProto_ExtensionRan bool DescriptorProto_ExtensionRange::IsInitialized() const { if (_internal_has_options()) { - if (!options_->IsInitialized()) return false; + if (!_impl_.options_->IsInitialized()) return false; } return true; } @@ -2406,17 +2473,17 @@ bool DescriptorProto_ExtensionRange::IsInitialized() const { void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(DescriptorProto_ExtensionRange, end_) - + sizeof(DescriptorProto_ExtensionRange::end_) - - PROTOBUF_FIELD_OFFSET(DescriptorProto_ExtensionRange, options_)>( - reinterpret_cast<char*>(&options_), - reinterpret_cast<char*>(&other->options_)); + PROTOBUF_FIELD_OFFSET(DescriptorProto_ExtensionRange, _impl_.end_) + + sizeof(DescriptorProto_ExtensionRange::_impl_.end_) + - PROTOBUF_FIELD_OFFSET(DescriptorProto_ExtensionRange, _impl_.options_)>( + reinterpret_cast<char*>(&_impl_.options_), + reinterpret_cast<char*>(&other->_impl_.options_)); } ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ExtensionRange::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[2]); } @@ -2425,7 +2492,7 @@ void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange class DescriptorProto_ReservedRange::_Internal { public: - using HasBits = decltype(std::declval<DescriptorProto_ReservedRange>()._has_bits_); + using HasBits = decltype(std::declval<DescriptorProto_ReservedRange>()._impl_._has_bits_); static void set_has_start(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -2437,48 +2504,52 @@ class DescriptorProto_ReservedRange::_Internal { DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto.ReservedRange) } DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + DescriptorProto_ReservedRange* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.start_){} + , decltype(_impl_.end_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::memcpy(&start_, &from.start_, - static_cast<size_t>(reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_)) + sizeof(end_)); + ::memcpy(&_impl_.start_, &from._impl_.start_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.end_) - + reinterpret_cast<char*>(&_impl_.start_)) + sizeof(_impl_.end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ReservedRange) } -inline void DescriptorProto_ReservedRange::SharedCtor() { -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&start_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_)) + sizeof(end_)); +inline void DescriptorProto_ReservedRange::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.start_){0} + , decltype(_impl_.end_){0} + }; } DescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() { // @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto.ReservedRange) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void DescriptorProto_ReservedRange::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } -void DescriptorProto_ReservedRange::ArenaDtor(void* object) { - DescriptorProto_ReservedRange* _this = reinterpret_cast< DescriptorProto_ReservedRange* >(object); - (void)_this; -} -void DescriptorProto_ReservedRange::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void DescriptorProto_ReservedRange::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void DescriptorProto_ReservedRange::Clear() { @@ -2487,28 +2558,28 @@ void DescriptorProto_ReservedRange::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { - ::memset(&start_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_)) + sizeof(end_)); + ::memset(&_impl_.start_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.end_) - + reinterpret_cast<char*>(&_impl_.start_)) + sizeof(_impl_.end_)); } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional int32 start = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { _Internal::set_has_start(&has_bits); - start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -2517,7 +2588,7 @@ const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::PRO case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { _Internal::set_has_end(&has_bits); - end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -2538,7 +2609,7 @@ const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::PRO CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -2552,21 +2623,21 @@ uint8_t* DescriptorProto_ReservedRange::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional int32 start = 1; if (cached_has_bits & 0x00000001u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target); } // optional int32 end = 2; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto.ReservedRange) @@ -2581,52 +2652,48 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { // optional int32 start = 1; if (cached_has_bits & 0x00000001u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_start()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_start()); } // optional int32 end = 2; if (cached_has_bits & 0x00000002u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_end()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_end()); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DescriptorProto_ReservedRange::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, DescriptorProto_ReservedRange::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DescriptorProto_ReservedRange::GetClassData() const { return &_class_data_; } -void DescriptorProto_ReservedRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<DescriptorProto_ReservedRange *>(to)->MergeFrom( - static_cast<const DescriptorProto_ReservedRange &>(from)); -} - -void DescriptorProto_ReservedRange::MergeFrom(const DescriptorProto_ReservedRange& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange) - GOOGLE_DCHECK_NE(&from, this); +void DescriptorProto_ReservedRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<DescriptorProto_ReservedRange*>(&to_msg); + auto& from = static_cast<const DescriptorProto_ReservedRange&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - start_ = from.start_; + _this->_impl_.start_ = from._impl_.start_; } if (cached_has_bits & 0x00000002u) { - end_ = from.end_; + _this->_impl_.end_ = from._impl_.end_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void DescriptorProto_ReservedRange::CopyFrom(const DescriptorProto_ReservedRange& from) { @@ -2643,17 +2710,17 @@ bool DescriptorProto_ReservedRange::IsInitialized() const { void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(DescriptorProto_ReservedRange, end_) - + sizeof(DescriptorProto_ReservedRange::end_) - - PROTOBUF_FIELD_OFFSET(DescriptorProto_ReservedRange, start_)>( - reinterpret_cast<char*>(&start_), - reinterpret_cast<char*>(&other->start_)); + PROTOBUF_FIELD_OFFSET(DescriptorProto_ReservedRange, _impl_.end_) + + sizeof(DescriptorProto_ReservedRange::_impl_.end_) + - PROTOBUF_FIELD_OFFSET(DescriptorProto_ReservedRange, _impl_.start_)>( + reinterpret_cast<char*>(&_impl_.start_), + reinterpret_cast<char*>(&other->_impl_.start_)); } ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ReservedRange::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[3]); } @@ -2662,7 +2729,7 @@ void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange* class DescriptorProto::_Internal { public: - using HasBits = decltype(std::declval<DescriptorProto>()._has_bits_); + using HasBits = decltype(std::declval<DescriptorProto>()._impl_._has_bits_); static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -2674,82 +2741,95 @@ class DescriptorProto::_Internal { const ::PROTOBUF_NAMESPACE_ID::MessageOptions& DescriptorProto::_Internal::options(const DescriptorProto* msg) { - return *msg->options_; + return *msg->_impl_.options_; } DescriptorProto::DescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - field_(arena), - nested_type_(arena), - enum_type_(arena), - extension_range_(arena), - extension_(arena), - oneof_decl_(arena), - reserved_range_(arena), - reserved_name_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.DescriptorProto) } DescriptorProto::DescriptorProto(const DescriptorProto& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - field_(from.field_), - nested_type_(from.nested_type_), - enum_type_(from.enum_type_), - extension_range_(from.extension_range_), - extension_(from.extension_), - oneof_decl_(from.oneof_decl_), - reserved_range_(from.reserved_range_), - reserved_name_(from.reserved_name_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + DescriptorProto* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.field_){from._impl_.field_} + , decltype(_impl_.nested_type_){from._impl_.nested_type_} + , decltype(_impl_.enum_type_){from._impl_.enum_type_} + , decltype(_impl_.extension_range_){from._impl_.extension_range_} + , decltype(_impl_.extension_){from._impl_.extension_} + , decltype(_impl_.oneof_decl_){from._impl_.oneof_decl_} + , decltype(_impl_.reserved_range_){from._impl_.reserved_range_} + , decltype(_impl_.reserved_name_){from._impl_.reserved_name_} + , decltype(_impl_.name_){} + , decltype(_impl_.options_){nullptr}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } if (from._internal_has_options()) { - options_ = new ::PROTOBUF_NAMESPACE_ID::MessageOptions(*from.options_); - } else { - options_ = nullptr; + _this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::MessageOptions(*from._impl_.options_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto) } -inline void DescriptorProto::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -options_ = nullptr; +inline void DescriptorProto::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.field_){arena} + , decltype(_impl_.nested_type_){arena} + , decltype(_impl_.enum_type_){arena} + , decltype(_impl_.extension_range_){arena} + , decltype(_impl_.extension_){arena} + , decltype(_impl_.oneof_decl_){arena} + , decltype(_impl_.reserved_range_){arena} + , decltype(_impl_.reserved_name_){arena} + , decltype(_impl_.name_){} + , decltype(_impl_.options_){nullptr} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } DescriptorProto::~DescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void DescriptorProto::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete options_; + _impl_.field_.~RepeatedPtrField(); + _impl_.nested_type_.~RepeatedPtrField(); + _impl_.enum_type_.~RepeatedPtrField(); + _impl_.extension_range_.~RepeatedPtrField(); + _impl_.extension_.~RepeatedPtrField(); + _impl_.oneof_decl_.~RepeatedPtrField(); + _impl_.reserved_range_.~RepeatedPtrField(); + _impl_.reserved_name_.~RepeatedPtrField(); + _impl_.name_.Destroy(); + if (this != internal_default_instance()) delete _impl_.options_; } -void DescriptorProto::ArenaDtor(void* object) { - DescriptorProto* _this = reinterpret_cast< DescriptorProto* >(object); - (void)_this; -} -void DescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void DescriptorProto::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void DescriptorProto::Clear() { @@ -2758,44 +2838,44 @@ void DescriptorProto::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - field_.Clear(); - nested_type_.Clear(); - enum_type_.Clear(); - extension_range_.Clear(); - extension_.Clear(); - oneof_decl_.Clear(); - reserved_range_.Clear(); - reserved_name_.Clear(); - cached_has_bits = _has_bits_[0]; + _impl_.field_.Clear(); + _impl_.nested_type_.Clear(); + _impl_.enum_type_.Clear(); + _impl_.extension_range_.Clear(); + _impl_.extension_.Clear(); + _impl_.oneof_decl_.Clear(); + _impl_.reserved_range_.Clear(); + _impl_.reserved_name_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(options_ != nullptr); - options_->Clear(); + GOOGLE_DCHECK(_impl_.options_ != nullptr); + _impl_.options_->Clear(); } } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* DescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.DescriptorProto.name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.DescriptorProto.name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -2905,11 +2985,11 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC do { ptr += 1; auto str = _internal_add_reserved_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.DescriptorProto.reserved_name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.DescriptorProto.reserved_name"); + #endif // !NDEBUG if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<82>(ptr)); } else @@ -2931,7 +3011,7 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -2945,7 +3025,7 @@ uint8_t* DescriptorProto::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -2957,67 +3037,66 @@ uint8_t* DescriptorProto::_InternalSerialize( } // repeated .google.protobuf.FieldDescriptorProto field = 2; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_field_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_field_size()); i < n; i++) { + const auto& repfield = this->_internal_field(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, this->_internal_field(i), target, stream); + InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream); } // repeated .google.protobuf.DescriptorProto nested_type = 3; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_nested_type_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_nested_type_size()); i < n; i++) { + const auto& repfield = this->_internal_nested_type(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, this->_internal_nested_type(i), target, stream); + InternalWriteMessage(3, repfield, repfield.GetCachedSize(), target, stream); } // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_enum_type_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_enum_type_size()); i < n; i++) { + const auto& repfield = this->_internal_enum_type(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(4, this->_internal_enum_type(i), target, stream); + InternalWriteMessage(4, repfield, repfield.GetCachedSize(), target, stream); } // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_extension_range_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_extension_range_size()); i < n; i++) { + const auto& repfield = this->_internal_extension_range(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(5, this->_internal_extension_range(i), target, stream); + InternalWriteMessage(5, repfield, repfield.GetCachedSize(), target, stream); } // repeated .google.protobuf.FieldDescriptorProto extension = 6; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_extension_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_extension_size()); i < n; i++) { + const auto& repfield = this->_internal_extension(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(6, this->_internal_extension(i), target, stream); + InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream); } // optional .google.protobuf.MessageOptions options = 7; if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 7, _Internal::options(this), target, stream); + InternalWriteMessage(7, _Internal::options(this), + _Internal::options(this).GetCachedSize(), target, stream); } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_oneof_decl_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_oneof_decl_size()); i < n; i++) { + const auto& repfield = this->_internal_oneof_decl(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(8, this->_internal_oneof_decl(i), target, stream); + InternalWriteMessage(8, repfield, repfield.GetCachedSize(), target, stream); } // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_reserved_range_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_reserved_range_size()); i < n; i++) { + const auto& repfield = this->_internal_reserved_range(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(9, this->_internal_reserved_range(i), target, stream); + InternalWriteMessage(9, repfield, repfield.GetCachedSize(), target, stream); } // repeated string reserved_name = 10; @@ -3031,7 +3110,7 @@ uint8_t* DescriptorProto::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto) @@ -3048,62 +3127,62 @@ size_t DescriptorProto::ByteSizeLong() const { // repeated .google.protobuf.FieldDescriptorProto field = 2; total_size += 1UL * this->_internal_field_size(); - for (const auto& msg : this->field_) { + for (const auto& msg : this->_impl_.field_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.DescriptorProto nested_type = 3; total_size += 1UL * this->_internal_nested_type_size(); - for (const auto& msg : this->nested_type_) { + for (const auto& msg : this->_impl_.nested_type_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; total_size += 1UL * this->_internal_enum_type_size(); - for (const auto& msg : this->enum_type_) { + for (const auto& msg : this->_impl_.enum_type_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; total_size += 1UL * this->_internal_extension_range_size(); - for (const auto& msg : this->extension_range_) { + for (const auto& msg : this->_impl_.extension_range_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.FieldDescriptorProto extension = 6; total_size += 1UL * this->_internal_extension_size(); - for (const auto& msg : this->extension_) { + for (const auto& msg : this->_impl_.extension_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; total_size += 1UL * this->_internal_oneof_decl_size(); - for (const auto& msg : this->oneof_decl_) { + for (const auto& msg : this->_impl_.oneof_decl_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; total_size += 1UL * this->_internal_reserved_range_size(); - for (const auto& msg : this->reserved_range_) { + for (const auto& msg : this->_impl_.reserved_range_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated string reserved_name = 10; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(reserved_name_.size()); - for (int i = 0, n = reserved_name_.size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.reserved_name_.size()); + for (int i = 0, n = _impl_.reserved_name_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - reserved_name_.Get(i)); + _impl_.reserved_name_.Get(i)); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { // optional string name = 1; if (cached_has_bits & 0x00000001u) { @@ -3116,50 +3195,47 @@ size_t DescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *options_); + *_impl_.options_); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DescriptorProto::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, DescriptorProto::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DescriptorProto::GetClassData() const { return &_class_data_; } -void DescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<DescriptorProto *>(to)->MergeFrom( - static_cast<const DescriptorProto &>(from)); -} - -void DescriptorProto::MergeFrom(const DescriptorProto& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto) - GOOGLE_DCHECK_NE(&from, this); +void DescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<DescriptorProto*>(&to_msg); + auto& from = static_cast<const DescriptorProto&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - field_.MergeFrom(from.field_); - nested_type_.MergeFrom(from.nested_type_); - enum_type_.MergeFrom(from.enum_type_); - extension_range_.MergeFrom(from.extension_range_); - extension_.MergeFrom(from.extension_); - oneof_decl_.MergeFrom(from.oneof_decl_); - reserved_range_.MergeFrom(from.reserved_range_); - reserved_name_.MergeFrom(from.reserved_name_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.field_.MergeFrom(from._impl_.field_); + _this->_impl_.nested_type_.MergeFrom(from._impl_.nested_type_); + _this->_impl_.enum_type_.MergeFrom(from._impl_.enum_type_); + _this->_impl_.extension_range_.MergeFrom(from._impl_.extension_range_); + _this->_impl_.extension_.MergeFrom(from._impl_.extension_); + _this->_impl_.oneof_decl_.MergeFrom(from._impl_.oneof_decl_); + _this->_impl_.reserved_range_.MergeFrom(from._impl_.reserved_range_); + _this->_impl_.reserved_name_.MergeFrom(from._impl_.reserved_name_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - _internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::MessageOptions::MergeFrom(from._internal_options()); + _this->_internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::MessageOptions::MergeFrom( + from._internal_options()); } } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void DescriptorProto::CopyFrom(const DescriptorProto& from) { @@ -3170,20 +3246,20 @@ void DescriptorProto::CopyFrom(const DescriptorProto& from) { } bool DescriptorProto::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(field_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.field_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(nested_type_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.nested_type_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(enum_type_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.enum_type_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(extension_range_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.extension_range_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(extension_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.extension_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(oneof_decl_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.oneof_decl_)) return false; if (_internal_has_options()) { - if (!options_->IsInitialized()) return false; + if (!_impl_.options_->IsInitialized()) return false; } return true; } @@ -3193,25 +3269,24 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - field_.InternalSwap(&other->field_); - nested_type_.InternalSwap(&other->nested_type_); - enum_type_.InternalSwap(&other->enum_type_); - extension_range_.InternalSwap(&other->extension_range_); - extension_.InternalSwap(&other->extension_); - oneof_decl_.InternalSwap(&other->oneof_decl_); - reserved_range_.InternalSwap(&other->reserved_range_); - reserved_name_.InternalSwap(&other->reserved_name_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.field_.InternalSwap(&other->_impl_.field_); + _impl_.nested_type_.InternalSwap(&other->_impl_.nested_type_); + _impl_.enum_type_.InternalSwap(&other->_impl_.enum_type_); + _impl_.extension_range_.InternalSwap(&other->_impl_.extension_range_); + _impl_.extension_.InternalSwap(&other->_impl_.extension_); + _impl_.oneof_decl_.InternalSwap(&other->_impl_.oneof_decl_); + _impl_.reserved_range_.InternalSwap(&other->_impl_.reserved_range_); + _impl_.reserved_name_.InternalSwap(&other->_impl_.reserved_name_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); - swap(options_, other->options_); + swap(_impl_.options_, other->_impl_.options_); } ::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[4]); } @@ -3224,45 +3299,51 @@ class ExtensionRangeOptions::_Internal { ExtensionRangeOptions::ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - _extensions_(arena), - uninterpreted_option_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.ExtensionRangeOptions) } ExtensionRangeOptions::ExtensionRangeOptions(const ExtensionRangeOptions& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - uninterpreted_option_(from.uninterpreted_option_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + ExtensionRangeOptions* const _this = this; (void)_this; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{} + , decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); + _impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); // @@protoc_insertion_point(copy_constructor:google.protobuf.ExtensionRangeOptions) } -inline void ExtensionRangeOptions::SharedCtor() { +inline void ExtensionRangeOptions::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena} + , decltype(_impl_.uninterpreted_option_){arena} + , /*decltype(_impl_._cached_size_)*/{} + }; } ExtensionRangeOptions::~ExtensionRangeOptions() { // @@protoc_insertion_point(destructor:google.protobuf.ExtensionRangeOptions) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void ExtensionRangeOptions::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_._extensions_.~ExtensionSet(); + _impl_.uninterpreted_option_.~RepeatedPtrField(); } -void ExtensionRangeOptions::ArenaDtor(void* object) { - ExtensionRangeOptions* _this = reinterpret_cast< ExtensionRangeOptions* >(object); - (void)_this; -} -void ExtensionRangeOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void ExtensionRangeOptions::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void ExtensionRangeOptions::Clear() { @@ -3271,16 +3352,16 @@ void ExtensionRangeOptions::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _extensions_.Clear(); - uninterpreted_option_.Clear(); + _impl_._extensions_.Clear(); + _impl_.uninterpreted_option_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* ExtensionRangeOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* ExtensionRangeOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: @@ -3305,7 +3386,7 @@ const char* ExtensionRangeOptions::_InternalParse(const char* ptr, ::PROTOBUF_NA goto message_done; } if ((8000u <= tag)) { - ptr = _extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); + ptr = _impl_._extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); CHK_(ptr != nullptr); continue; } @@ -3330,19 +3411,19 @@ uint8_t* ExtensionRangeOptions::_InternalSerialize( (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) { + const auto& repfield = this->_internal_uninterpreted_option(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream); + InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream); } // Extension range [1000, 536870912) - target = _extensions_._InternalSerialize( + target = _impl_._extensions_._InternalSerialize( internal_default_instance(), 1000, 536870912, target, stream); if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ExtensionRangeOptions) @@ -3353,7 +3434,7 @@ size_t ExtensionRangeOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ExtensionRangeOptions) size_t total_size = 0; - total_size += _extensions_.ByteSize(); + total_size += _impl_._extensions_.ByteSize(); uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused @@ -3361,36 +3442,32 @@ size_t ExtensionRangeOptions::ByteSizeLong() const { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2UL * this->_internal_uninterpreted_option_size(); - for (const auto& msg : this->uninterpreted_option_) { + for (const auto& msg : this->_impl_.uninterpreted_option_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ExtensionRangeOptions::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, ExtensionRangeOptions::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ExtensionRangeOptions::GetClassData() const { return &_class_data_; } -void ExtensionRangeOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<ExtensionRangeOptions *>(to)->MergeFrom( - static_cast<const ExtensionRangeOptions &>(from)); -} - -void ExtensionRangeOptions::MergeFrom(const ExtensionRangeOptions& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ExtensionRangeOptions) - GOOGLE_DCHECK_NE(&from, this); +void ExtensionRangeOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<ExtensionRangeOptions*>(&to_msg); + auto& from = static_cast<const ExtensionRangeOptions&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ExtensionRangeOptions) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_); + _this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void ExtensionRangeOptions::CopyFrom(const ExtensionRangeOptions& from) { @@ -3401,24 +3478,24 @@ void ExtensionRangeOptions::CopyFrom(const ExtensionRangeOptions& from) { } bool ExtensionRangeOptions::IsInitialized() const { - if (!_extensions_.IsInitialized()) { + if (!_impl_._extensions_.IsInitialized()) { return false; } - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(uninterpreted_option_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.uninterpreted_option_)) return false; return true; } void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) { using std::swap; - _extensions_.InternalSwap(&other->_extensions_); + _impl_._extensions_.InternalSwap(&other->_impl_._extensions_); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); + _impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_); } ::PROTOBUF_NAMESPACE_ID::Metadata ExtensionRangeOptions::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[5]); } @@ -3427,7 +3504,7 @@ void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) { class FieldDescriptorProto::_Internal { public: - using HasBits = decltype(std::declval<FieldDescriptorProto>()._has_bits_); + using HasBits = decltype(std::declval<FieldDescriptorProto>()._impl_._has_bits_); static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -3466,126 +3543,144 @@ class FieldDescriptorProto::_Internal { const ::PROTOBUF_NAMESPACE_ID::FieldOptions& FieldDescriptorProto::_Internal::options(const FieldDescriptorProto* msg) { - return *msg->options_; + return *msg->_impl_.options_; } FieldDescriptorProto::FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.FieldDescriptorProto) } FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + FieldDescriptorProto* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_){} + , decltype(_impl_.extendee_){} + , decltype(_impl_.type_name_){} + , decltype(_impl_.default_value_){} + , decltype(_impl_.json_name_){} + , decltype(_impl_.options_){nullptr} + , decltype(_impl_.number_){} + , decltype(_impl_.oneof_index_){} + , decltype(_impl_.proto3_optional_){} + , decltype(_impl_.label_){} + , decltype(_impl_.type_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } - extendee_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.extendee_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.extendee_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_extendee()) { - extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_extendee(), - GetArenaForAllocation()); + _this->_impl_.extendee_.Set(from._internal_extendee(), + _this->GetArenaForAllocation()); } - type_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.type_name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.type_name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_type_name()) { - type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_name(), - GetArenaForAllocation()); + _this->_impl_.type_name_.Set(from._internal_type_name(), + _this->GetArenaForAllocation()); } - default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.default_value_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.default_value_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_default_value()) { - default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_default_value(), - GetArenaForAllocation()); + _this->_impl_.default_value_.Set(from._internal_default_value(), + _this->GetArenaForAllocation()); } - json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.json_name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.json_name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_json_name()) { - json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_json_name(), - GetArenaForAllocation()); + _this->_impl_.json_name_.Set(from._internal_json_name(), + _this->GetArenaForAllocation()); } if (from._internal_has_options()) { - options_ = new ::PROTOBUF_NAMESPACE_ID::FieldOptions(*from.options_); - } else { - options_ = nullptr; + _this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::FieldOptions(*from._impl_.options_); } - ::memcpy(&number_, &from.number_, - static_cast<size_t>(reinterpret_cast<char*>(&type_) - - reinterpret_cast<char*>(&number_)) + sizeof(type_)); + ::memcpy(&_impl_.number_, &from._impl_.number_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.type_) - + reinterpret_cast<char*>(&_impl_.number_)) + sizeof(_impl_.type_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldDescriptorProto) } -inline void FieldDescriptorProto::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -extendee_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -type_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&proto3_optional_) - - reinterpret_cast<char*>(&options_)) + sizeof(proto3_optional_)); -label_ = 1; -type_ = 1; +inline void FieldDescriptorProto::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_){} + , decltype(_impl_.extendee_){} + , decltype(_impl_.type_name_){} + , decltype(_impl_.default_value_){} + , decltype(_impl_.json_name_){} + , decltype(_impl_.options_){nullptr} + , decltype(_impl_.number_){0} + , decltype(_impl_.oneof_index_){0} + , decltype(_impl_.proto3_optional_){false} + , decltype(_impl_.label_){1} + , decltype(_impl_.type_){1} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.extendee_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.extendee_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.type_name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.type_name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.default_value_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.default_value_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.json_name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.json_name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } FieldDescriptorProto::~FieldDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.FieldDescriptorProto) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void FieldDescriptorProto::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - extendee_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - type_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - default_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - json_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete options_; + _impl_.name_.Destroy(); + _impl_.extendee_.Destroy(); + _impl_.type_name_.Destroy(); + _impl_.default_value_.Destroy(); + _impl_.json_name_.Destroy(); + if (this != internal_default_instance()) delete _impl_.options_; } -void FieldDescriptorProto::ArenaDtor(void* object) { - FieldDescriptorProto* _this = reinterpret_cast< FieldDescriptorProto* >(object); - (void)_this; -} -void FieldDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void FieldDescriptorProto::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void FieldDescriptorProto::Clear() { @@ -3594,58 +3689,58 @@ void FieldDescriptorProto::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000003fu) { if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - extendee_.ClearNonDefaultToEmpty(); + _impl_.extendee_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - type_name_.ClearNonDefaultToEmpty(); + _impl_.type_name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000008u) { - default_value_.ClearNonDefaultToEmpty(); + _impl_.default_value_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000010u) { - json_name_.ClearNonDefaultToEmpty(); + _impl_.json_name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000020u) { - GOOGLE_DCHECK(options_ != nullptr); - options_->Clear(); + GOOGLE_DCHECK(_impl_.options_ != nullptr); + _impl_.options_->Clear(); } } if (cached_has_bits & 0x000000c0u) { - ::memset(&number_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&oneof_index_) - - reinterpret_cast<char*>(&number_)) + sizeof(oneof_index_)); + ::memset(&_impl_.number_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.oneof_index_) - + reinterpret_cast<char*>(&_impl_.number_)) + sizeof(_impl_.oneof_index_)); } if (cached_has_bits & 0x00000700u) { - proto3_optional_ = false; - label_ = 1; - type_ = 1; + _impl_.proto3_optional_ = false; + _impl_.label_ = 1; + _impl_.type_ = 1; } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -3653,11 +3748,11 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_extendee(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.extendee"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.extendee"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -3665,7 +3760,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) { _Internal::set_has_number(&has_bits); - number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -3700,11 +3795,11 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM case 6: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) { auto str = _internal_mutable_type_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.type_name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.type_name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -3712,11 +3807,11 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM case 7: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) { auto str = _internal_mutable_default_value(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.default_value"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.default_value"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -3732,7 +3827,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM case 9: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 72)) { _Internal::set_has_oneof_index(&has_bits); - oneof_index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.oneof_index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -3741,11 +3836,11 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM case 10: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 82)) { auto str = _internal_mutable_json_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.json_name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FieldDescriptorProto.json_name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -3753,7 +3848,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM case 17: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 136)) { _Internal::set_has_proto3_optional(&has_bits); - proto3_optional_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.proto3_optional_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -3774,7 +3869,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -3788,7 +3883,7 @@ uint8_t* FieldDescriptorProto::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -3812,20 +3907,20 @@ uint8_t* FieldDescriptorProto::_InternalSerialize( // optional int32 number = 3; if (cached_has_bits & 0x00000040u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_number(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_number(), target); } // optional .google.protobuf.FieldDescriptorProto.Label label = 4; if (cached_has_bits & 0x00000200u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 4, this->_internal_label(), target); } // optional .google.protobuf.FieldDescriptorProto.Type type = 5; if (cached_has_bits & 0x00000400u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 5, this->_internal_type(), target); } @@ -3851,16 +3946,15 @@ uint8_t* FieldDescriptorProto::_InternalSerialize( // optional .google.protobuf.FieldOptions options = 8; if (cached_has_bits & 0x00000020u) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 8, _Internal::options(this), target, stream); + InternalWriteMessage(8, _Internal::options(this), + _Internal::options(this).GetCachedSize(), target, stream); } // optional int32 oneof_index = 9; if (cached_has_bits & 0x00000080u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(9, this->_internal_oneof_index(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(9, this->_internal_oneof_index(), target); } // optional string json_name = 10; @@ -3876,11 +3970,11 @@ uint8_t* FieldDescriptorProto::_InternalSerialize( // optional bool proto3_optional = 17; if (cached_has_bits & 0x00000100u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(17, this->_internal_proto3_optional(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(17, this->_internal_proto3_optional(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldDescriptorProto) @@ -3895,7 +3989,7 @@ size_t FieldDescriptorProto::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x000000ffu) { // optional string name = 1; if (cached_has_bits & 0x00000001u) { @@ -3936,17 +4030,17 @@ size_t FieldDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000020u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *options_); + *_impl_.options_); } // optional int32 number = 3; if (cached_has_bits & 0x00000040u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_number()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_number()); } // optional int32 oneof_index = 9; if (cached_has_bits & 0x00000080u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_oneof_index()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_oneof_index()); } } @@ -3959,79 +4053,76 @@ size_t FieldDescriptorProto::ByteSizeLong() const { // optional .google.protobuf.FieldDescriptorProto.Label label = 4; if (cached_has_bits & 0x00000200u) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_label()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_label()); } // optional .google.protobuf.FieldDescriptorProto.Type type = 5; if (cached_has_bits & 0x00000400u) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_type()); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FieldDescriptorProto::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, FieldDescriptorProto::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FieldDescriptorProto::GetClassData() const { return &_class_data_; } -void FieldDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<FieldDescriptorProto *>(to)->MergeFrom( - static_cast<const FieldDescriptorProto &>(from)); -} - -void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto) - GOOGLE_DCHECK_NE(&from, this); +void FieldDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<FieldDescriptorProto*>(&to_msg); + auto& from = static_cast<const FieldDescriptorProto&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - _internal_set_extendee(from._internal_extendee()); + _this->_internal_set_extendee(from._internal_extendee()); } if (cached_has_bits & 0x00000004u) { - _internal_set_type_name(from._internal_type_name()); + _this->_internal_set_type_name(from._internal_type_name()); } if (cached_has_bits & 0x00000008u) { - _internal_set_default_value(from._internal_default_value()); + _this->_internal_set_default_value(from._internal_default_value()); } if (cached_has_bits & 0x00000010u) { - _internal_set_json_name(from._internal_json_name()); + _this->_internal_set_json_name(from._internal_json_name()); } if (cached_has_bits & 0x00000020u) { - _internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::FieldOptions::MergeFrom(from._internal_options()); + _this->_internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::FieldOptions::MergeFrom( + from._internal_options()); } if (cached_has_bits & 0x00000040u) { - number_ = from.number_; + _this->_impl_.number_ = from._impl_.number_; } if (cached_has_bits & 0x00000080u) { - oneof_index_ = from.oneof_index_; + _this->_impl_.oneof_index_ = from._impl_.oneof_index_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } if (cached_has_bits & 0x00000700u) { if (cached_has_bits & 0x00000100u) { - proto3_optional_ = from.proto3_optional_; + _this->_impl_.proto3_optional_ = from._impl_.proto3_optional_; } if (cached_has_bits & 0x00000200u) { - label_ = from.label_; + _this->_impl_.label_ = from._impl_.label_; } if (cached_has_bits & 0x00000400u) { - type_ = from.type_; + _this->_impl_.type_ = from._impl_.type_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void FieldDescriptorProto::CopyFrom(const FieldDescriptorProto& from) { @@ -4043,7 +4134,7 @@ void FieldDescriptorProto::CopyFrom(const FieldDescriptorProto& from) { bool FieldDescriptorProto::IsInitialized() const { if (_internal_has_options()) { - if (!options_->IsInitialized()) return false; + if (!_impl_.options_->IsInitialized()) return false; } return true; } @@ -4053,44 +4144,39 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &extendee_, lhs_arena, - &other->extendee_, rhs_arena + &_impl_.extendee_, lhs_arena, + &other->_impl_.extendee_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &type_name_, lhs_arena, - &other->type_name_, rhs_arena + &_impl_.type_name_, lhs_arena, + &other->_impl_.type_name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &default_value_, lhs_arena, - &other->default_value_, rhs_arena + &_impl_.default_value_, lhs_arena, + &other->_impl_.default_value_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &json_name_, lhs_arena, - &other->json_name_, rhs_arena + &_impl_.json_name_, lhs_arena, + &other->_impl_.json_name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, proto3_optional_) - + sizeof(FieldDescriptorProto::proto3_optional_) - - PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, options_)>( - reinterpret_cast<char*>(&options_), - reinterpret_cast<char*>(&other->options_)); - swap(label_, other->label_); - swap(type_, other->type_); + PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, _impl_.proto3_optional_) + + sizeof(FieldDescriptorProto::_impl_.proto3_optional_) + - PROTOBUF_FIELD_OFFSET(FieldDescriptorProto, _impl_.options_)>( + reinterpret_cast<char*>(&_impl_.options_), + reinterpret_cast<char*>(&other->_impl_.options_)); + swap(_impl_.label_, other->_impl_.label_); + swap(_impl_.type_, other->_impl_.type_); } ::PROTOBUF_NAMESPACE_ID::Metadata FieldDescriptorProto::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[6]); } @@ -4099,7 +4185,7 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) { class OneofDescriptorProto::_Internal { public: - using HasBits = decltype(std::declval<OneofDescriptorProto>()._has_bits_); + using HasBits = decltype(std::declval<OneofDescriptorProto>()._impl_._has_bits_); static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -4111,66 +4197,71 @@ class OneofDescriptorProto::_Internal { const ::PROTOBUF_NAMESPACE_ID::OneofOptions& OneofDescriptorProto::_Internal::options(const OneofDescriptorProto* msg) { - return *msg->options_; + return *msg->_impl_.options_; } OneofDescriptorProto::OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.OneofDescriptorProto) } OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + OneofDescriptorProto* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_){} + , decltype(_impl_.options_){nullptr}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } if (from._internal_has_options()) { - options_ = new ::PROTOBUF_NAMESPACE_ID::OneofOptions(*from.options_); - } else { - options_ = nullptr; + _this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::OneofOptions(*from._impl_.options_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofDescriptorProto) } -inline void OneofDescriptorProto::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -options_ = nullptr; +inline void OneofDescriptorProto::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_){} + , decltype(_impl_.options_){nullptr} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } OneofDescriptorProto::~OneofDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.OneofDescriptorProto) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void OneofDescriptorProto::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete options_; + _impl_.name_.Destroy(); + if (this != internal_default_instance()) delete _impl_.options_; } -void OneofDescriptorProto::ArenaDtor(void* object) { - OneofDescriptorProto* _this = reinterpret_cast< OneofDescriptorProto* >(object); - (void)_this; -} -void OneofDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void OneofDescriptorProto::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void OneofDescriptorProto::Clear() { @@ -4179,36 +4270,36 @@ void OneofDescriptorProto::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(options_ != nullptr); - options_->Clear(); + GOOGLE_DCHECK(_impl_.options_ != nullptr); + _impl_.options_->Clear(); } } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* OneofDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* OneofDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.OneofDescriptorProto.name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.OneofDescriptorProto.name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -4236,7 +4327,7 @@ const char* OneofDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -4250,7 +4341,7 @@ uint8_t* OneofDescriptorProto::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4263,14 +4354,13 @@ uint8_t* OneofDescriptorProto::_InternalSerialize( // optional .google.protobuf.OneofOptions options = 2; if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 2, _Internal::options(this), target, stream); + InternalWriteMessage(2, _Internal::options(this), + _Internal::options(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.OneofDescriptorProto) @@ -4285,7 +4375,7 @@ size_t OneofDescriptorProto::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { // optional string name = 1; if (cached_has_bits & 0x00000001u) { @@ -4298,42 +4388,39 @@ size_t OneofDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *options_); + *_impl_.options_); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData OneofDescriptorProto::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, OneofDescriptorProto::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*OneofDescriptorProto::GetClassData() const { return &_class_data_; } -void OneofDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<OneofDescriptorProto *>(to)->MergeFrom( - static_cast<const OneofDescriptorProto &>(from)); -} - -void OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto) - GOOGLE_DCHECK_NE(&from, this); +void OneofDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<OneofDescriptorProto*>(&to_msg); + auto& from = static_cast<const OneofDescriptorProto&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - _internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::OneofOptions::MergeFrom(from._internal_options()); + _this->_internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::OneofOptions::MergeFrom( + from._internal_options()); } } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void OneofDescriptorProto::CopyFrom(const OneofDescriptorProto& from) { @@ -4345,7 +4432,7 @@ void OneofDescriptorProto::CopyFrom(const OneofDescriptorProto& from) { bool OneofDescriptorProto::IsInitialized() const { if (_internal_has_options()) { - if (!options_->IsInitialized()) return false; + if (!_impl_.options_->IsInitialized()) return false; } return true; } @@ -4355,17 +4442,16 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); - swap(options_, other->options_); + swap(_impl_.options_, other->_impl_.options_); } ::PROTOBUF_NAMESPACE_ID::Metadata OneofDescriptorProto::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[7]); } @@ -4374,7 +4460,7 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) { class EnumDescriptorProto_EnumReservedRange::_Internal { public: - using HasBits = decltype(std::declval<EnumDescriptorProto_EnumReservedRange>()._has_bits_); + using HasBits = decltype(std::declval<EnumDescriptorProto_EnumReservedRange>()._impl_._has_bits_); static void set_has_start(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -4386,48 +4472,52 @@ class EnumDescriptorProto_EnumReservedRange::_Internal { EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumDescriptorProto.EnumReservedRange) } EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange(const EnumDescriptorProto_EnumReservedRange& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + EnumDescriptorProto_EnumReservedRange* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.start_){} + , decltype(_impl_.end_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::memcpy(&start_, &from.start_, - static_cast<size_t>(reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_)) + sizeof(end_)); + ::memcpy(&_impl_.start_, &from._impl_.start_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.end_) - + reinterpret_cast<char*>(&_impl_.start_)) + sizeof(_impl_.end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto.EnumReservedRange) } -inline void EnumDescriptorProto_EnumReservedRange::SharedCtor() { -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&start_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_)) + sizeof(end_)); +inline void EnumDescriptorProto_EnumReservedRange::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.start_){0} + , decltype(_impl_.end_){0} + }; } EnumDescriptorProto_EnumReservedRange::~EnumDescriptorProto_EnumReservedRange() { // @@protoc_insertion_point(destructor:google.protobuf.EnumDescriptorProto.EnumReservedRange) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void EnumDescriptorProto_EnumReservedRange::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } -void EnumDescriptorProto_EnumReservedRange::ArenaDtor(void* object) { - EnumDescriptorProto_EnumReservedRange* _this = reinterpret_cast< EnumDescriptorProto_EnumReservedRange* >(object); - (void)_this; -} -void EnumDescriptorProto_EnumReservedRange::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void EnumDescriptorProto_EnumReservedRange::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void EnumDescriptorProto_EnumReservedRange::Clear() { @@ -4436,28 +4526,28 @@ void EnumDescriptorProto_EnumReservedRange::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { - ::memset(&start_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&start_)) + sizeof(end_)); + ::memset(&_impl_.start_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.end_) - + reinterpret_cast<char*>(&_impl_.start_)) + sizeof(_impl_.end_)); } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional int32 start = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { _Internal::set_has_start(&has_bits); - start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -4466,7 +4556,7 @@ const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* pt case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { _Internal::set_has_end(&has_bits); - end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -4487,7 +4577,7 @@ const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* pt CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -4501,21 +4591,21 @@ uint8_t* EnumDescriptorProto_EnumReservedRange::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional int32 start = 1; if (cached_has_bits & 0x00000001u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target); } // optional int32 end = 2; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumDescriptorProto.EnumReservedRange) @@ -4530,52 +4620,48 @@ size_t EnumDescriptorProto_EnumReservedRange::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { // optional int32 start = 1; if (cached_has_bits & 0x00000001u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_start()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_start()); } // optional int32 end = 2; if (cached_has_bits & 0x00000002u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_end()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_end()); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData EnumDescriptorProto_EnumReservedRange::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, EnumDescriptorProto_EnumReservedRange::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*EnumDescriptorProto_EnumReservedRange::GetClassData() const { return &_class_data_; } -void EnumDescriptorProto_EnumReservedRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<EnumDescriptorProto_EnumReservedRange *>(to)->MergeFrom( - static_cast<const EnumDescriptorProto_EnumReservedRange &>(from)); -} - -void EnumDescriptorProto_EnumReservedRange::MergeFrom(const EnumDescriptorProto_EnumReservedRange& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) - GOOGLE_DCHECK_NE(&from, this); +void EnumDescriptorProto_EnumReservedRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<EnumDescriptorProto_EnumReservedRange*>(&to_msg); + auto& from = static_cast<const EnumDescriptorProto_EnumReservedRange&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - start_ = from.start_; + _this->_impl_.start_ = from._impl_.start_; } if (cached_has_bits & 0x00000002u) { - end_ = from.end_; + _this->_impl_.end_ = from._impl_.end_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void EnumDescriptorProto_EnumReservedRange::CopyFrom(const EnumDescriptorProto_EnumReservedRange& from) { @@ -4592,17 +4678,17 @@ bool EnumDescriptorProto_EnumReservedRange::IsInitialized() const { void EnumDescriptorProto_EnumReservedRange::InternalSwap(EnumDescriptorProto_EnumReservedRange* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(EnumDescriptorProto_EnumReservedRange, end_) - + sizeof(EnumDescriptorProto_EnumReservedRange::end_) - - PROTOBUF_FIELD_OFFSET(EnumDescriptorProto_EnumReservedRange, start_)>( - reinterpret_cast<char*>(&start_), - reinterpret_cast<char*>(&other->start_)); + PROTOBUF_FIELD_OFFSET(EnumDescriptorProto_EnumReservedRange, _impl_.end_) + + sizeof(EnumDescriptorProto_EnumReservedRange::_impl_.end_) + - PROTOBUF_FIELD_OFFSET(EnumDescriptorProto_EnumReservedRange, _impl_.start_)>( + reinterpret_cast<char*>(&_impl_.start_), + reinterpret_cast<char*>(&other->_impl_.start_)); } ::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto_EnumReservedRange::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[8]); } @@ -4611,7 +4697,7 @@ void EnumDescriptorProto_EnumReservedRange::InternalSwap(EnumDescriptorProto_Enu class EnumDescriptorProto::_Internal { public: - using HasBits = decltype(std::declval<EnumDescriptorProto>()._has_bits_); + using HasBits = decltype(std::declval<EnumDescriptorProto>()._impl_._has_bits_); static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -4623,72 +4709,80 @@ class EnumDescriptorProto::_Internal { const ::PROTOBUF_NAMESPACE_ID::EnumOptions& EnumDescriptorProto::_Internal::options(const EnumDescriptorProto* msg) { - return *msg->options_; + return *msg->_impl_.options_; } EnumDescriptorProto::EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - value_(arena), - reserved_range_(arena), - reserved_name_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumDescriptorProto) } EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - value_(from.value_), - reserved_range_(from.reserved_range_), - reserved_name_(from.reserved_name_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + EnumDescriptorProto* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.value_){from._impl_.value_} + , decltype(_impl_.reserved_range_){from._impl_.reserved_range_} + , decltype(_impl_.reserved_name_){from._impl_.reserved_name_} + , decltype(_impl_.name_){} + , decltype(_impl_.options_){nullptr}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } if (from._internal_has_options()) { - options_ = new ::PROTOBUF_NAMESPACE_ID::EnumOptions(*from.options_); - } else { - options_ = nullptr; + _this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::EnumOptions(*from._impl_.options_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto) } -inline void EnumDescriptorProto::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -options_ = nullptr; +inline void EnumDescriptorProto::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.value_){arena} + , decltype(_impl_.reserved_range_){arena} + , decltype(_impl_.reserved_name_){arena} + , decltype(_impl_.name_){} + , decltype(_impl_.options_){nullptr} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } EnumDescriptorProto::~EnumDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.EnumDescriptorProto) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void EnumDescriptorProto::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete options_; + _impl_.value_.~RepeatedPtrField(); + _impl_.reserved_range_.~RepeatedPtrField(); + _impl_.reserved_name_.~RepeatedPtrField(); + _impl_.name_.Destroy(); + if (this != internal_default_instance()) delete _impl_.options_; } -void EnumDescriptorProto::ArenaDtor(void* object) { - EnumDescriptorProto* _this = reinterpret_cast< EnumDescriptorProto* >(object); - (void)_this; -} -void EnumDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void EnumDescriptorProto::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void EnumDescriptorProto::Clear() { @@ -4697,39 +4791,39 @@ void EnumDescriptorProto::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - value_.Clear(); - reserved_range_.Clear(); - reserved_name_.Clear(); - cached_has_bits = _has_bits_[0]; + _impl_.value_.Clear(); + _impl_.reserved_range_.Clear(); + _impl_.reserved_name_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(options_ != nullptr); - options_->Clear(); + GOOGLE_DCHECK(_impl_.options_ != nullptr); + _impl_.options_->Clear(); } } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.EnumDescriptorProto.name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.EnumDescriptorProto.name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -4774,11 +4868,11 @@ const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME do { ptr += 1; auto str = _internal_add_reserved_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.EnumDescriptorProto.reserved_name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.EnumDescriptorProto.reserved_name"); + #endif // !NDEBUG if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); } else @@ -4800,7 +4894,7 @@ const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -4814,7 +4908,7 @@ uint8_t* EnumDescriptorProto::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4826,27 +4920,26 @@ uint8_t* EnumDescriptorProto::_InternalSerialize( } // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_value_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_value_size()); i < n; i++) { + const auto& repfield = this->_internal_value(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, this->_internal_value(i), target, stream); + InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream); } // optional .google.protobuf.EnumOptions options = 3; if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 3, _Internal::options(this), target, stream); + InternalWriteMessage(3, _Internal::options(this), + _Internal::options(this).GetCachedSize(), target, stream); } // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_reserved_range_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_reserved_range_size()); i < n; i++) { + const auto& repfield = this->_internal_reserved_range(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(4, this->_internal_reserved_range(i), target, stream); + InternalWriteMessage(4, repfield, repfield.GetCachedSize(), target, stream); } // repeated string reserved_name = 5; @@ -4860,7 +4953,7 @@ uint8_t* EnumDescriptorProto::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumDescriptorProto) @@ -4877,27 +4970,27 @@ size_t EnumDescriptorProto::ByteSizeLong() const { // repeated .google.protobuf.EnumValueDescriptorProto value = 2; total_size += 1UL * this->_internal_value_size(); - for (const auto& msg : this->value_) { + for (const auto& msg : this->_impl_.value_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; total_size += 1UL * this->_internal_reserved_range_size(); - for (const auto& msg : this->reserved_range_) { + for (const auto& msg : this->_impl_.reserved_range_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated string reserved_name = 5; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(reserved_name_.size()); - for (int i = 0, n = reserved_name_.size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.reserved_name_.size()); + for (int i = 0, n = _impl_.reserved_name_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - reserved_name_.Get(i)); + _impl_.reserved_name_.Get(i)); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { // optional string name = 1; if (cached_has_bits & 0x00000001u) { @@ -4910,45 +5003,42 @@ size_t EnumDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *options_); + *_impl_.options_); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData EnumDescriptorProto::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, EnumDescriptorProto::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*EnumDescriptorProto::GetClassData() const { return &_class_data_; } -void EnumDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<EnumDescriptorProto *>(to)->MergeFrom( - static_cast<const EnumDescriptorProto &>(from)); -} - -void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto) - GOOGLE_DCHECK_NE(&from, this); +void EnumDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<EnumDescriptorProto*>(&to_msg); + auto& from = static_cast<const EnumDescriptorProto&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - value_.MergeFrom(from.value_); - reserved_range_.MergeFrom(from.reserved_range_); - reserved_name_.MergeFrom(from.reserved_name_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.value_.MergeFrom(from._impl_.value_); + _this->_impl_.reserved_range_.MergeFrom(from._impl_.reserved_range_); + _this->_impl_.reserved_name_.MergeFrom(from._impl_.reserved_name_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - _internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::EnumOptions::MergeFrom(from._internal_options()); + _this->_internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::EnumOptions::MergeFrom( + from._internal_options()); } } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void EnumDescriptorProto::CopyFrom(const EnumDescriptorProto& from) { @@ -4959,10 +5049,10 @@ void EnumDescriptorProto::CopyFrom(const EnumDescriptorProto& from) { } bool EnumDescriptorProto::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(value_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.value_)) return false; if (_internal_has_options()) { - if (!options_->IsInitialized()) return false; + if (!_impl_.options_->IsInitialized()) return false; } return true; } @@ -4972,20 +5062,19 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - value_.InternalSwap(&other->value_); - reserved_range_.InternalSwap(&other->reserved_range_); - reserved_name_.InternalSwap(&other->reserved_name_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.value_.InternalSwap(&other->_impl_.value_); + _impl_.reserved_range_.InternalSwap(&other->_impl_.reserved_range_); + _impl_.reserved_name_.InternalSwap(&other->_impl_.reserved_name_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); - swap(options_, other->options_); + swap(_impl_.options_, other->_impl_.options_); } ::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[9]); } @@ -4994,7 +5083,7 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) { class EnumValueDescriptorProto::_Internal { public: - using HasBits = decltype(std::declval<EnumValueDescriptorProto>()._has_bits_); + using HasBits = decltype(std::declval<EnumValueDescriptorProto>()._impl_._has_bits_); static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -5009,70 +5098,74 @@ class EnumValueDescriptorProto::_Internal { const ::PROTOBUF_NAMESPACE_ID::EnumValueOptions& EnumValueDescriptorProto::_Internal::options(const EnumValueDescriptorProto* msg) { - return *msg->options_; + return *msg->_impl_.options_; } EnumValueDescriptorProto::EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValueDescriptorProto) } EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + EnumValueDescriptorProto* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_){} + , decltype(_impl_.options_){nullptr} + , decltype(_impl_.number_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } if (from._internal_has_options()) { - options_ = new ::PROTOBUF_NAMESPACE_ID::EnumValueOptions(*from.options_); - } else { - options_ = nullptr; + _this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::EnumValueOptions(*from._impl_.options_); } - number_ = from.number_; + _this->_impl_.number_ = from._impl_.number_; // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueDescriptorProto) } -inline void EnumValueDescriptorProto::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&number_) - - reinterpret_cast<char*>(&options_)) + sizeof(number_)); +inline void EnumValueDescriptorProto::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_){} + , decltype(_impl_.options_){nullptr} + , decltype(_impl_.number_){0} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } EnumValueDescriptorProto::~EnumValueDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.EnumValueDescriptorProto) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void EnumValueDescriptorProto::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete options_; + _impl_.name_.Destroy(); + if (this != internal_default_instance()) delete _impl_.options_; } -void EnumValueDescriptorProto::ArenaDtor(void* object) { - EnumValueDescriptorProto* _this = reinterpret_cast< EnumValueDescriptorProto* >(object); - (void)_this; -} -void EnumValueDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void EnumValueDescriptorProto::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void EnumValueDescriptorProto::Clear() { @@ -5081,37 +5174,37 @@ void EnumValueDescriptorProto::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(options_ != nullptr); - options_->Clear(); + GOOGLE_DCHECK(_impl_.options_ != nullptr); + _impl_.options_->Clear(); } } - number_ = 0; - _has_bits_.Clear(); + _impl_.number_ = 0; + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.EnumValueDescriptorProto.name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.EnumValueDescriptorProto.name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -5119,7 +5212,7 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { _Internal::set_has_number(&has_bits); - number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -5148,7 +5241,7 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -5162,7 +5255,7 @@ uint8_t* EnumValueDescriptorProto::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -5176,19 +5269,18 @@ uint8_t* EnumValueDescriptorProto::_InternalSerialize( // optional int32 number = 2; if (cached_has_bits & 0x00000004u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_number(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_number(), target); } // optional .google.protobuf.EnumValueOptions options = 3; if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 3, _Internal::options(this), target, stream); + InternalWriteMessage(3, _Internal::options(this), + _Internal::options(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValueDescriptorProto) @@ -5203,7 +5295,7 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000007u) { // optional string name = 1; if (cached_has_bits & 0x00000001u) { @@ -5216,51 +5308,48 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *options_); + *_impl_.options_); } // optional int32 number = 2; if (cached_has_bits & 0x00000004u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_number()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_number()); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData EnumValueDescriptorProto::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, EnumValueDescriptorProto::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*EnumValueDescriptorProto::GetClassData() const { return &_class_data_; } -void EnumValueDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<EnumValueDescriptorProto *>(to)->MergeFrom( - static_cast<const EnumValueDescriptorProto &>(from)); -} - -void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto) - GOOGLE_DCHECK_NE(&from, this); +void EnumValueDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<EnumValueDescriptorProto*>(&to_msg); + auto& from = static_cast<const EnumValueDescriptorProto&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - _internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::EnumValueOptions::MergeFrom(from._internal_options()); + _this->_internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::EnumValueOptions::MergeFrom( + from._internal_options()); } if (cached_has_bits & 0x00000004u) { - number_ = from.number_; + _this->_impl_.number_ = from._impl_.number_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void EnumValueDescriptorProto::CopyFrom(const EnumValueDescriptorProto& from) { @@ -5272,7 +5361,7 @@ void EnumValueDescriptorProto::CopyFrom(const EnumValueDescriptorProto& from) { bool EnumValueDescriptorProto::IsInitialized() const { if (_internal_has_options()) { - if (!options_->IsInitialized()) return false; + if (!_impl_.options_->IsInitialized()) return false; } return true; } @@ -5282,22 +5371,21 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(EnumValueDescriptorProto, number_) - + sizeof(EnumValueDescriptorProto::number_) - - PROTOBUF_FIELD_OFFSET(EnumValueDescriptorProto, options_)>( - reinterpret_cast<char*>(&options_), - reinterpret_cast<char*>(&other->options_)); + PROTOBUF_FIELD_OFFSET(EnumValueDescriptorProto, _impl_.number_) + + sizeof(EnumValueDescriptorProto::_impl_.number_) + - PROTOBUF_FIELD_OFFSET(EnumValueDescriptorProto, _impl_.options_)>( + reinterpret_cast<char*>(&_impl_.options_), + reinterpret_cast<char*>(&other->_impl_.options_)); } ::PROTOBUF_NAMESPACE_ID::Metadata EnumValueDescriptorProto::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[10]); } @@ -5306,7 +5394,7 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) { class ServiceDescriptorProto::_Internal { public: - using HasBits = decltype(std::declval<ServiceDescriptorProto>()._has_bits_); + using HasBits = decltype(std::declval<ServiceDescriptorProto>()._impl_._has_bits_); static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -5318,68 +5406,74 @@ class ServiceDescriptorProto::_Internal { const ::PROTOBUF_NAMESPACE_ID::ServiceOptions& ServiceDescriptorProto::_Internal::options(const ServiceDescriptorProto* msg) { - return *msg->options_; + return *msg->_impl_.options_; } ServiceDescriptorProto::ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - method_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.ServiceDescriptorProto) } ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - method_(from.method_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + ServiceDescriptorProto* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.method_){from._impl_.method_} + , decltype(_impl_.name_){} + , decltype(_impl_.options_){nullptr}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } if (from._internal_has_options()) { - options_ = new ::PROTOBUF_NAMESPACE_ID::ServiceOptions(*from.options_); - } else { - options_ = nullptr; + _this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::ServiceOptions(*from._impl_.options_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceDescriptorProto) } -inline void ServiceDescriptorProto::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -options_ = nullptr; +inline void ServiceDescriptorProto::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.method_){arena} + , decltype(_impl_.name_){} + , decltype(_impl_.options_){nullptr} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } ServiceDescriptorProto::~ServiceDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.ServiceDescriptorProto) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void ServiceDescriptorProto::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete options_; + _impl_.method_.~RepeatedPtrField(); + _impl_.name_.Destroy(); + if (this != internal_default_instance()) delete _impl_.options_; } -void ServiceDescriptorProto::ArenaDtor(void* object) { - ServiceDescriptorProto* _this = reinterpret_cast< ServiceDescriptorProto* >(object); - (void)_this; -} -void ServiceDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void ServiceDescriptorProto::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void ServiceDescriptorProto::Clear() { @@ -5388,37 +5482,37 @@ void ServiceDescriptorProto::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - method_.Clear(); - cached_has_bits = _has_bits_[0]; + _impl_.method_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(options_ != nullptr); - options_->Clear(); + GOOGLE_DCHECK(_impl_.options_ != nullptr); + _impl_.options_->Clear(); } } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.ServiceDescriptorProto.name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.ServiceDescriptorProto.name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -5459,7 +5553,7 @@ const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_N CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -5473,7 +5567,7 @@ uint8_t* ServiceDescriptorProto::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -5485,23 +5579,22 @@ uint8_t* ServiceDescriptorProto::_InternalSerialize( } // repeated .google.protobuf.MethodDescriptorProto method = 2; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_method_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_method_size()); i < n; i++) { + const auto& repfield = this->_internal_method(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, this->_internal_method(i), target, stream); + InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream); } // optional .google.protobuf.ServiceOptions options = 3; if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 3, _Internal::options(this), target, stream); + InternalWriteMessage(3, _Internal::options(this), + _Internal::options(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ServiceDescriptorProto) @@ -5518,12 +5611,12 @@ size_t ServiceDescriptorProto::ByteSizeLong() const { // repeated .google.protobuf.MethodDescriptorProto method = 2; total_size += 1UL * this->_internal_method_size(); - for (const auto& msg : this->method_) { + for (const auto& msg : this->_impl_.method_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { // optional string name = 1; if (cached_has_bits & 0x00000001u) { @@ -5536,43 +5629,40 @@ size_t ServiceDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *options_); + *_impl_.options_); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ServiceDescriptorProto::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, ServiceDescriptorProto::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ServiceDescriptorProto::GetClassData() const { return &_class_data_; } -void ServiceDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<ServiceDescriptorProto *>(to)->MergeFrom( - static_cast<const ServiceDescriptorProto &>(from)); -} - -void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto) - GOOGLE_DCHECK_NE(&from, this); +void ServiceDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<ServiceDescriptorProto*>(&to_msg); + auto& from = static_cast<const ServiceDescriptorProto&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - method_.MergeFrom(from.method_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.method_.MergeFrom(from._impl_.method_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - _internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::ServiceOptions::MergeFrom(from._internal_options()); + _this->_internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::ServiceOptions::MergeFrom( + from._internal_options()); } } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void ServiceDescriptorProto::CopyFrom(const ServiceDescriptorProto& from) { @@ -5583,10 +5673,10 @@ void ServiceDescriptorProto::CopyFrom(const ServiceDescriptorProto& from) { } bool ServiceDescriptorProto::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(method_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.method_)) return false; if (_internal_has_options()) { - if (!options_->IsInitialized()) return false; + if (!_impl_.options_->IsInitialized()) return false; } return true; } @@ -5596,18 +5686,17 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - method_.InternalSwap(&other->method_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.method_.InternalSwap(&other->_impl_.method_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); - swap(options_, other->options_); + swap(_impl_.options_, other->_impl_.options_); } ::PROTOBUF_NAMESPACE_ID::Metadata ServiceDescriptorProto::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[11]); } @@ -5616,7 +5705,7 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) { class MethodDescriptorProto::_Internal { public: - using HasBits = decltype(std::declval<MethodDescriptorProto>()._has_bits_); + using HasBits = decltype(std::declval<MethodDescriptorProto>()._impl_._has_bits_); static void set_has_name(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -5640,98 +5729,108 @@ class MethodDescriptorProto::_Internal { const ::PROTOBUF_NAMESPACE_ID::MethodOptions& MethodDescriptorProto::_Internal::options(const MethodDescriptorProto* msg) { - return *msg->options_; + return *msg->_impl_.options_; } MethodDescriptorProto::MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.MethodDescriptorProto) } MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + MethodDescriptorProto* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_){} + , decltype(_impl_.input_type_){} + , decltype(_impl_.output_type_){} + , decltype(_impl_.options_){nullptr} + , decltype(_impl_.client_streaming_){} + , decltype(_impl_.server_streaming_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } - input_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.input_type_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.input_type_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_input_type()) { - input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_input_type(), - GetArenaForAllocation()); + _this->_impl_.input_type_.Set(from._internal_input_type(), + _this->GetArenaForAllocation()); } - output_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.output_type_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.output_type_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_output_type()) { - output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_output_type(), - GetArenaForAllocation()); + _this->_impl_.output_type_.Set(from._internal_output_type(), + _this->GetArenaForAllocation()); } if (from._internal_has_options()) { - options_ = new ::PROTOBUF_NAMESPACE_ID::MethodOptions(*from.options_); - } else { - options_ = nullptr; + _this->_impl_.options_ = new ::PROTOBUF_NAMESPACE_ID::MethodOptions(*from._impl_.options_); } - ::memcpy(&client_streaming_, &from.client_streaming_, - static_cast<size_t>(reinterpret_cast<char*>(&server_streaming_) - - reinterpret_cast<char*>(&client_streaming_)) + sizeof(server_streaming_)); + ::memcpy(&_impl_.client_streaming_, &from._impl_.client_streaming_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.server_streaming_) - + reinterpret_cast<char*>(&_impl_.client_streaming_)) + sizeof(_impl_.server_streaming_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodDescriptorProto) } -inline void MethodDescriptorProto::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -input_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -output_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&options_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&server_streaming_) - - reinterpret_cast<char*>(&options_)) + sizeof(server_streaming_)); +inline void MethodDescriptorProto::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_){} + , decltype(_impl_.input_type_){} + , decltype(_impl_.output_type_){} + , decltype(_impl_.options_){nullptr} + , decltype(_impl_.client_streaming_){false} + , decltype(_impl_.server_streaming_){false} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.input_type_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.input_type_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.output_type_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.output_type_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } MethodDescriptorProto::~MethodDescriptorProto() { // @@protoc_insertion_point(destructor:google.protobuf.MethodDescriptorProto) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void MethodDescriptorProto::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - input_type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - output_type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete options_; + _impl_.name_.Destroy(); + _impl_.input_type_.Destroy(); + _impl_.output_type_.Destroy(); + if (this != internal_default_instance()) delete _impl_.options_; } -void MethodDescriptorProto::ArenaDtor(void* object) { - MethodDescriptorProto* _this = reinterpret_cast< MethodDescriptorProto* >(object); - (void)_this; -} -void MethodDescriptorProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void MethodDescriptorProto::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void MethodDescriptorProto::Clear() { @@ -5740,45 +5839,45 @@ void MethodDescriptorProto::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); + _impl_.name_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - input_type_.ClearNonDefaultToEmpty(); + _impl_.input_type_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - output_type_.ClearNonDefaultToEmpty(); + _impl_.output_type_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000008u) { - GOOGLE_DCHECK(options_ != nullptr); - options_->Clear(); + GOOGLE_DCHECK(_impl_.options_ != nullptr); + _impl_.options_->Clear(); } } - ::memset(&client_streaming_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&server_streaming_) - - reinterpret_cast<char*>(&client_streaming_)) + sizeof(server_streaming_)); - _has_bits_.Clear(); + ::memset(&_impl_.client_streaming_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.server_streaming_) - + reinterpret_cast<char*>(&_impl_.client_streaming_)) + sizeof(_impl_.server_streaming_)); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.name"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.name"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -5786,11 +5885,11 @@ const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NA case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_input_type(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.input_type"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.input_type"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -5798,11 +5897,11 @@ const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NA case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) { auto str = _internal_mutable_output_type(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.output_type"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.MethodDescriptorProto.output_type"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -5818,7 +5917,7 @@ const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NA case 5: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) { _Internal::set_has_client_streaming(&has_bits); - client_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.client_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -5827,7 +5926,7 @@ const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NA case 6: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 48)) { _Internal::set_has_server_streaming(&has_bits); - server_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.server_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -5848,7 +5947,7 @@ const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NA CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -5862,7 +5961,7 @@ uint8_t* MethodDescriptorProto::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -5895,26 +5994,25 @@ uint8_t* MethodDescriptorProto::_InternalSerialize( // optional .google.protobuf.MethodOptions options = 4; if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 4, _Internal::options(this), target, stream); + InternalWriteMessage(4, _Internal::options(this), + _Internal::options(this).GetCachedSize(), target, stream); } // optional bool client_streaming = 5 [default = false]; if (cached_has_bits & 0x00000010u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_client_streaming(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_client_streaming(), target); } // optional bool server_streaming = 6 [default = false]; if (cached_has_bits & 0x00000020u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(6, this->_internal_server_streaming(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(6, this->_internal_server_streaming(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MethodDescriptorProto) @@ -5929,7 +6027,7 @@ size_t MethodDescriptorProto::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000003fu) { // optional string name = 1; if (cached_has_bits & 0x00000001u) { @@ -5956,7 +6054,7 @@ size_t MethodDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000008u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *options_); + *_impl_.options_); } // optional bool client_streaming = 5 [default = false]; @@ -5970,51 +6068,48 @@ size_t MethodDescriptorProto::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData MethodDescriptorProto::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, MethodDescriptorProto::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*MethodDescriptorProto::GetClassData() const { return &_class_data_; } -void MethodDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<MethodDescriptorProto *>(to)->MergeFrom( - static_cast<const MethodDescriptorProto &>(from)); -} - -void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto) - GOOGLE_DCHECK_NE(&from, this); +void MethodDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<MethodDescriptorProto*>(&to_msg); + auto& from = static_cast<const MethodDescriptorProto&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x0000003fu) { if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - _internal_set_input_type(from._internal_input_type()); + _this->_internal_set_input_type(from._internal_input_type()); } if (cached_has_bits & 0x00000004u) { - _internal_set_output_type(from._internal_output_type()); + _this->_internal_set_output_type(from._internal_output_type()); } if (cached_has_bits & 0x00000008u) { - _internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::MethodOptions::MergeFrom(from._internal_options()); + _this->_internal_mutable_options()->::PROTOBUF_NAMESPACE_ID::MethodOptions::MergeFrom( + from._internal_options()); } if (cached_has_bits & 0x00000010u) { - client_streaming_ = from.client_streaming_; + _this->_impl_.client_streaming_ = from._impl_.client_streaming_; } if (cached_has_bits & 0x00000020u) { - server_streaming_ = from.server_streaming_; + _this->_impl_.server_streaming_ = from._impl_.server_streaming_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void MethodDescriptorProto::CopyFrom(const MethodDescriptorProto& from) { @@ -6026,7 +6121,7 @@ void MethodDescriptorProto::CopyFrom(const MethodDescriptorProto& from) { bool MethodDescriptorProto::IsInitialized() const { if (_internal_has_options()) { - if (!options_->IsInitialized()) return false; + if (!_impl_.options_->IsInitialized()) return false; } return true; } @@ -6036,32 +6131,29 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &input_type_, lhs_arena, - &other->input_type_, rhs_arena + &_impl_.input_type_, lhs_arena, + &other->_impl_.input_type_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &output_type_, lhs_arena, - &other->output_type_, rhs_arena + &_impl_.output_type_, lhs_arena, + &other->_impl_.output_type_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(MethodDescriptorProto, server_streaming_) - + sizeof(MethodDescriptorProto::server_streaming_) - - PROTOBUF_FIELD_OFFSET(MethodDescriptorProto, options_)>( - reinterpret_cast<char*>(&options_), - reinterpret_cast<char*>(&other->options_)); + PROTOBUF_FIELD_OFFSET(MethodDescriptorProto, _impl_.server_streaming_) + + sizeof(MethodDescriptorProto::_impl_.server_streaming_) + - PROTOBUF_FIELD_OFFSET(MethodDescriptorProto, _impl_.options_)>( + reinterpret_cast<char*>(&_impl_.options_), + reinterpret_cast<char*>(&other->_impl_.options_)); } ::PROTOBUF_NAMESPACE_ID::Metadata MethodDescriptorProto::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[12]); } @@ -6070,7 +6162,7 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) { class FileOptions::_Internal { public: - using HasBits = decltype(std::declval<FileOptions>()._has_bits_); + using HasBits = decltype(std::declval<FileOptions>()._impl_._has_bits_); static void set_has_java_package(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -6135,185 +6227,226 @@ class FileOptions::_Internal { FileOptions::FileOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - _extensions_(arena), - uninterpreted_option_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.FileOptions) } FileOptions::FileOptions(const FileOptions& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - uninterpreted_option_(from.uninterpreted_option_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + FileOptions* const _this = this; (void)_this; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{} + , decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_} + , decltype(_impl_.java_package_){} + , decltype(_impl_.java_outer_classname_){} + , decltype(_impl_.go_package_){} + , decltype(_impl_.objc_class_prefix_){} + , decltype(_impl_.csharp_namespace_){} + , decltype(_impl_.swift_prefix_){} + , decltype(_impl_.php_class_prefix_){} + , decltype(_impl_.php_namespace_){} + , decltype(_impl_.php_metadata_namespace_){} + , decltype(_impl_.ruby_package_){} + , decltype(_impl_.java_multiple_files_){} + , decltype(_impl_.java_generate_equals_and_hash_){} + , decltype(_impl_.java_string_check_utf8_){} + , decltype(_impl_.cc_generic_services_){} + , decltype(_impl_.java_generic_services_){} + , decltype(_impl_.py_generic_services_){} + , decltype(_impl_.php_generic_services_){} + , decltype(_impl_.deprecated_){} + , decltype(_impl_.optimize_for_){} + , decltype(_impl_.cc_enable_arenas_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - java_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + _impl_.java_package_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.java_package_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_java_package()) { - java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_java_package(), - GetArenaForAllocation()); + _this->_impl_.java_package_.Set(from._internal_java_package(), + _this->GetArenaForAllocation()); } - java_outer_classname_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.java_outer_classname_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.java_outer_classname_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_java_outer_classname()) { - java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_java_outer_classname(), - GetArenaForAllocation()); + _this->_impl_.java_outer_classname_.Set(from._internal_java_outer_classname(), + _this->GetArenaForAllocation()); } - go_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.go_package_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.go_package_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_go_package()) { - go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_go_package(), - GetArenaForAllocation()); + _this->_impl_.go_package_.Set(from._internal_go_package(), + _this->GetArenaForAllocation()); } - objc_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.objc_class_prefix_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.objc_class_prefix_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_objc_class_prefix()) { - objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_objc_class_prefix(), - GetArenaForAllocation()); + _this->_impl_.objc_class_prefix_.Set(from._internal_objc_class_prefix(), + _this->GetArenaForAllocation()); } - csharp_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.csharp_namespace_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.csharp_namespace_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_csharp_namespace()) { - csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_csharp_namespace(), - GetArenaForAllocation()); + _this->_impl_.csharp_namespace_.Set(from._internal_csharp_namespace(), + _this->GetArenaForAllocation()); } - swift_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.swift_prefix_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.swift_prefix_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_swift_prefix()) { - swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_swift_prefix(), - GetArenaForAllocation()); + _this->_impl_.swift_prefix_.Set(from._internal_swift_prefix(), + _this->GetArenaForAllocation()); } - php_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.php_class_prefix_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.php_class_prefix_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_php_class_prefix()) { - php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_php_class_prefix(), - GetArenaForAllocation()); + _this->_impl_.php_class_prefix_.Set(from._internal_php_class_prefix(), + _this->GetArenaForAllocation()); } - php_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.php_namespace_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.php_namespace_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_php_namespace()) { - php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_php_namespace(), - GetArenaForAllocation()); + _this->_impl_.php_namespace_.Set(from._internal_php_namespace(), + _this->GetArenaForAllocation()); } - php_metadata_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.php_metadata_namespace_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_php_metadata_namespace()) { - php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_php_metadata_namespace(), - GetArenaForAllocation()); + _this->_impl_.php_metadata_namespace_.Set(from._internal_php_metadata_namespace(), + _this->GetArenaForAllocation()); } - ruby_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.ruby_package_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.ruby_package_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_ruby_package()) { - ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_ruby_package(), - GetArenaForAllocation()); + _this->_impl_.ruby_package_.Set(from._internal_ruby_package(), + _this->GetArenaForAllocation()); } - ::memcpy(&java_multiple_files_, &from.java_multiple_files_, - static_cast<size_t>(reinterpret_cast<char*>(&cc_enable_arenas_) - - reinterpret_cast<char*>(&java_multiple_files_)) + sizeof(cc_enable_arenas_)); + ::memcpy(&_impl_.java_multiple_files_, &from._impl_.java_multiple_files_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.cc_enable_arenas_) - + reinterpret_cast<char*>(&_impl_.java_multiple_files_)) + sizeof(_impl_.cc_enable_arenas_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions) } -inline void FileOptions::SharedCtor() { -java_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -java_outer_classname_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -go_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -objc_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -csharp_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -swift_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -php_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -php_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -php_metadata_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -ruby_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&java_multiple_files_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&deprecated_) - - reinterpret_cast<char*>(&java_multiple_files_)) + sizeof(deprecated_)); -optimize_for_ = 1; -cc_enable_arenas_ = true; +inline void FileOptions::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena} + , decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){arena} + , decltype(_impl_.java_package_){} + , decltype(_impl_.java_outer_classname_){} + , decltype(_impl_.go_package_){} + , decltype(_impl_.objc_class_prefix_){} + , decltype(_impl_.csharp_namespace_){} + , decltype(_impl_.swift_prefix_){} + , decltype(_impl_.php_class_prefix_){} + , decltype(_impl_.php_namespace_){} + , decltype(_impl_.php_metadata_namespace_){} + , decltype(_impl_.ruby_package_){} + , decltype(_impl_.java_multiple_files_){false} + , decltype(_impl_.java_generate_equals_and_hash_){false} + , decltype(_impl_.java_string_check_utf8_){false} + , decltype(_impl_.cc_generic_services_){false} + , decltype(_impl_.java_generic_services_){false} + , decltype(_impl_.py_generic_services_){false} + , decltype(_impl_.php_generic_services_){false} + , decltype(_impl_.deprecated_){false} + , decltype(_impl_.optimize_for_){1} + , decltype(_impl_.cc_enable_arenas_){true} + }; + _impl_.java_package_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.java_package_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.java_outer_classname_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.java_outer_classname_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.go_package_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.go_package_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.objc_class_prefix_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.objc_class_prefix_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.csharp_namespace_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.csharp_namespace_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.swift_prefix_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.swift_prefix_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.php_class_prefix_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.php_class_prefix_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.php_namespace_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.php_namespace_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.php_metadata_namespace_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.ruby_package_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.ruby_package_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } FileOptions::~FileOptions() { // @@protoc_insertion_point(destructor:google.protobuf.FileOptions) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void FileOptions::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - java_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - java_outer_classname_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - go_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - objc_class_prefix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - csharp_namespace_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - swift_prefix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - php_class_prefix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - php_namespace_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - php_metadata_namespace_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ruby_package_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_._extensions_.~ExtensionSet(); + _impl_.uninterpreted_option_.~RepeatedPtrField(); + _impl_.java_package_.Destroy(); + _impl_.java_outer_classname_.Destroy(); + _impl_.go_package_.Destroy(); + _impl_.objc_class_prefix_.Destroy(); + _impl_.csharp_namespace_.Destroy(); + _impl_.swift_prefix_.Destroy(); + _impl_.php_class_prefix_.Destroy(); + _impl_.php_namespace_.Destroy(); + _impl_.php_metadata_namespace_.Destroy(); + _impl_.ruby_package_.Destroy(); } -void FileOptions::ArenaDtor(void* object) { - FileOptions* _this = reinterpret_cast< FileOptions* >(object); - (void)_this; -} -void FileOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void FileOptions::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void FileOptions::Clear() { @@ -6322,75 +6455,75 @@ void FileOptions::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _extensions_.Clear(); - uninterpreted_option_.Clear(); - cached_has_bits = _has_bits_[0]; + _impl_._extensions_.Clear(); + _impl_.uninterpreted_option_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - java_package_.ClearNonDefaultToEmpty(); + _impl_.java_package_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - java_outer_classname_.ClearNonDefaultToEmpty(); + _impl_.java_outer_classname_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - go_package_.ClearNonDefaultToEmpty(); + _impl_.go_package_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000008u) { - objc_class_prefix_.ClearNonDefaultToEmpty(); + _impl_.objc_class_prefix_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000010u) { - csharp_namespace_.ClearNonDefaultToEmpty(); + _impl_.csharp_namespace_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000020u) { - swift_prefix_.ClearNonDefaultToEmpty(); + _impl_.swift_prefix_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000040u) { - php_class_prefix_.ClearNonDefaultToEmpty(); + _impl_.php_class_prefix_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000080u) { - php_namespace_.ClearNonDefaultToEmpty(); + _impl_.php_namespace_.ClearNonDefaultToEmpty(); } } if (cached_has_bits & 0x00000300u) { if (cached_has_bits & 0x00000100u) { - php_metadata_namespace_.ClearNonDefaultToEmpty(); + _impl_.php_metadata_namespace_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000200u) { - ruby_package_.ClearNonDefaultToEmpty(); + _impl_.ruby_package_.ClearNonDefaultToEmpty(); } } if (cached_has_bits & 0x0000fc00u) { - ::memset(&java_multiple_files_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&py_generic_services_) - - reinterpret_cast<char*>(&java_multiple_files_)) + sizeof(py_generic_services_)); + ::memset(&_impl_.java_multiple_files_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.py_generic_services_) - + reinterpret_cast<char*>(&_impl_.java_multiple_files_)) + sizeof(_impl_.py_generic_services_)); } if (cached_has_bits & 0x000f0000u) { - ::memset(&php_generic_services_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&deprecated_) - - reinterpret_cast<char*>(&php_generic_services_)) + sizeof(deprecated_)); - optimize_for_ = 1; - cc_enable_arenas_ = true; + ::memset(&_impl_.php_generic_services_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.deprecated_) - + reinterpret_cast<char*>(&_impl_.php_generic_services_)) + sizeof(_impl_.deprecated_)); + _impl_.optimize_for_ = 1; + _impl_.cc_enable_arenas_ = true; } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* FileOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional string java_package = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_java_package(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.java_package"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.java_package"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6398,11 +6531,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 8: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 66)) { auto str = _internal_mutable_java_outer_classname(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.java_outer_classname"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.java_outer_classname"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6423,7 +6556,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 10: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 80)) { _Internal::set_has_java_multiple_files(&has_bits); - java_multiple_files_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.java_multiple_files_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -6432,11 +6565,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 11: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 90)) { auto str = _internal_mutable_go_package(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.go_package"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.go_package"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6444,7 +6577,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 16: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 128)) { _Internal::set_has_cc_generic_services(&has_bits); - cc_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.cc_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -6453,7 +6586,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 17: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 136)) { _Internal::set_has_java_generic_services(&has_bits); - java_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.java_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -6462,7 +6595,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 18: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 144)) { _Internal::set_has_py_generic_services(&has_bits); - py_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.py_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -6471,7 +6604,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 20: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 160)) { _Internal::set_has_java_generate_equals_and_hash(&has_bits); - java_generate_equals_and_hash_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.java_generate_equals_and_hash_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -6480,7 +6613,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 23: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 184)) { _Internal::set_has_deprecated(&has_bits); - deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -6489,7 +6622,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 27: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 216)) { _Internal::set_has_java_string_check_utf8(&has_bits); - java_string_check_utf8_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.java_string_check_utf8_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -6498,7 +6631,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 31: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 248)) { _Internal::set_has_cc_enable_arenas(&has_bits); - cc_enable_arenas_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.cc_enable_arenas_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -6507,11 +6640,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 36: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) { auto str = _internal_mutable_objc_class_prefix(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.objc_class_prefix"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.objc_class_prefix"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6519,11 +6652,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 37: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) { auto str = _internal_mutable_csharp_namespace(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.csharp_namespace"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.csharp_namespace"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6531,11 +6664,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 39: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) { auto str = _internal_mutable_swift_prefix(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.swift_prefix"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.swift_prefix"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6543,11 +6676,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 40: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 66)) { auto str = _internal_mutable_php_class_prefix(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.php_class_prefix"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.php_class_prefix"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6555,11 +6688,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 41: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 74)) { auto str = _internal_mutable_php_namespace(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.php_namespace"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.php_namespace"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6567,7 +6700,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 42: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 80)) { _Internal::set_has_php_generic_services(&has_bits); - php_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.php_generic_services_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -6576,11 +6709,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 44: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 98)) { auto str = _internal_mutable_php_metadata_namespace(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.php_metadata_namespace"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.php_metadata_namespace"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6588,11 +6721,11 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 45: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 106)) { auto str = _internal_mutable_ruby_package(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FileOptions.ruby_package"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.FileOptions.ruby_package"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -6619,7 +6752,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID goto message_done; } if ((8000u <= tag)) { - ptr = _extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); + ptr = _impl_._extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); CHK_(ptr != nullptr); continue; } @@ -6630,7 +6763,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -6644,7 +6777,7 @@ uint8_t* FileOptions::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string java_package = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -6668,14 +6801,14 @@ uint8_t* FileOptions::_InternalSerialize( // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; if (cached_has_bits & 0x00040000u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 9, this->_internal_optimize_for(), target); } // optional bool java_multiple_files = 10 [default = false]; if (cached_has_bits & 0x00000400u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(10, this->_internal_java_multiple_files(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(10, this->_internal_java_multiple_files(), target); } // optional string go_package = 11; @@ -6691,43 +6824,43 @@ uint8_t* FileOptions::_InternalSerialize( // optional bool cc_generic_services = 16 [default = false]; if (cached_has_bits & 0x00002000u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(16, this->_internal_cc_generic_services(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(16, this->_internal_cc_generic_services(), target); } // optional bool java_generic_services = 17 [default = false]; if (cached_has_bits & 0x00004000u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(17, this->_internal_java_generic_services(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(17, this->_internal_java_generic_services(), target); } // optional bool py_generic_services = 18 [default = false]; if (cached_has_bits & 0x00008000u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(18, this->_internal_py_generic_services(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(18, this->_internal_py_generic_services(), target); } // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; if (cached_has_bits & 0x00000800u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(20, this->_internal_java_generate_equals_and_hash(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(20, this->_internal_java_generate_equals_and_hash(), target); } // optional bool deprecated = 23 [default = false]; if (cached_has_bits & 0x00020000u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(23, this->_internal_deprecated(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(23, this->_internal_deprecated(), target); } // optional bool java_string_check_utf8 = 27 [default = false]; if (cached_has_bits & 0x00001000u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(27, this->_internal_java_string_check_utf8(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(27, this->_internal_java_string_check_utf8(), target); } // optional bool cc_enable_arenas = 31 [default = true]; if (cached_has_bits & 0x00080000u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(31, this->_internal_cc_enable_arenas(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(31, this->_internal_cc_enable_arenas(), target); } // optional string objc_class_prefix = 36; @@ -6783,7 +6916,7 @@ uint8_t* FileOptions::_InternalSerialize( // optional bool php_generic_services = 42 [default = false]; if (cached_has_bits & 0x00010000u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(42, this->_internal_php_generic_services(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(42, this->_internal_php_generic_services(), target); } // optional string php_metadata_namespace = 44; @@ -6807,19 +6940,19 @@ uint8_t* FileOptions::_InternalSerialize( } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) { + const auto& repfield = this->_internal_uninterpreted_option(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream); + InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream); } // Extension range [1000, 536870912) - target = _extensions_._InternalSerialize( + target = _impl_._extensions_._InternalSerialize( internal_default_instance(), 1000, 536870912, target, stream); if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileOptions) @@ -6830,7 +6963,7 @@ size_t FileOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileOptions) size_t total_size = 0; - total_size += _extensions_.ByteSize(); + total_size += _impl_._extensions_.ByteSize(); uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused @@ -6838,12 +6971,12 @@ size_t FileOptions::ByteSizeLong() const { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2UL * this->_internal_uninterpreted_option_size(); - for (const auto& msg : this->uninterpreted_option_) { + for (const auto& msg : this->_impl_.uninterpreted_option_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x000000ffu) { // optional string java_package = 1; if (cached_has_bits & 0x00000001u) { @@ -6962,7 +7095,7 @@ size_t FileOptions::ByteSizeLong() const { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; if (cached_has_bits & 0x00040000u) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_optimize_for()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_optimize_for()); } // optional bool cc_enable_arenas = 31 [default = true]; @@ -6971,100 +7104,96 @@ size_t FileOptions::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FileOptions::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, FileOptions::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FileOptions::GetClassData() const { return &_class_data_; } -void FileOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<FileOptions *>(to)->MergeFrom( - static_cast<const FileOptions &>(from)); -} - -void FileOptions::MergeFrom(const FileOptions& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions) - GOOGLE_DCHECK_NE(&from, this); +void FileOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<FileOptions*>(&to_msg); + auto& from = static_cast<const FileOptions&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - _internal_set_java_package(from._internal_java_package()); + _this->_internal_set_java_package(from._internal_java_package()); } if (cached_has_bits & 0x00000002u) { - _internal_set_java_outer_classname(from._internal_java_outer_classname()); + _this->_internal_set_java_outer_classname(from._internal_java_outer_classname()); } if (cached_has_bits & 0x00000004u) { - _internal_set_go_package(from._internal_go_package()); + _this->_internal_set_go_package(from._internal_go_package()); } if (cached_has_bits & 0x00000008u) { - _internal_set_objc_class_prefix(from._internal_objc_class_prefix()); + _this->_internal_set_objc_class_prefix(from._internal_objc_class_prefix()); } if (cached_has_bits & 0x00000010u) { - _internal_set_csharp_namespace(from._internal_csharp_namespace()); + _this->_internal_set_csharp_namespace(from._internal_csharp_namespace()); } if (cached_has_bits & 0x00000020u) { - _internal_set_swift_prefix(from._internal_swift_prefix()); + _this->_internal_set_swift_prefix(from._internal_swift_prefix()); } if (cached_has_bits & 0x00000040u) { - _internal_set_php_class_prefix(from._internal_php_class_prefix()); + _this->_internal_set_php_class_prefix(from._internal_php_class_prefix()); } if (cached_has_bits & 0x00000080u) { - _internal_set_php_namespace(from._internal_php_namespace()); + _this->_internal_set_php_namespace(from._internal_php_namespace()); } } if (cached_has_bits & 0x0000ff00u) { if (cached_has_bits & 0x00000100u) { - _internal_set_php_metadata_namespace(from._internal_php_metadata_namespace()); + _this->_internal_set_php_metadata_namespace(from._internal_php_metadata_namespace()); } if (cached_has_bits & 0x00000200u) { - _internal_set_ruby_package(from._internal_ruby_package()); + _this->_internal_set_ruby_package(from._internal_ruby_package()); } if (cached_has_bits & 0x00000400u) { - java_multiple_files_ = from.java_multiple_files_; + _this->_impl_.java_multiple_files_ = from._impl_.java_multiple_files_; } if (cached_has_bits & 0x00000800u) { - java_generate_equals_and_hash_ = from.java_generate_equals_and_hash_; + _this->_impl_.java_generate_equals_and_hash_ = from._impl_.java_generate_equals_and_hash_; } if (cached_has_bits & 0x00001000u) { - java_string_check_utf8_ = from.java_string_check_utf8_; + _this->_impl_.java_string_check_utf8_ = from._impl_.java_string_check_utf8_; } if (cached_has_bits & 0x00002000u) { - cc_generic_services_ = from.cc_generic_services_; + _this->_impl_.cc_generic_services_ = from._impl_.cc_generic_services_; } if (cached_has_bits & 0x00004000u) { - java_generic_services_ = from.java_generic_services_; + _this->_impl_.java_generic_services_ = from._impl_.java_generic_services_; } if (cached_has_bits & 0x00008000u) { - py_generic_services_ = from.py_generic_services_; + _this->_impl_.py_generic_services_ = from._impl_.py_generic_services_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } if (cached_has_bits & 0x000f0000u) { if (cached_has_bits & 0x00010000u) { - php_generic_services_ = from.php_generic_services_; + _this->_impl_.php_generic_services_ = from._impl_.php_generic_services_; } if (cached_has_bits & 0x00020000u) { - deprecated_ = from.deprecated_; + _this->_impl_.deprecated_ = from._impl_.deprecated_; } if (cached_has_bits & 0x00040000u) { - optimize_for_ = from.optimize_for_; + _this->_impl_.optimize_for_ = from._impl_.optimize_for_; } if (cached_has_bits & 0x00080000u) { - cc_enable_arenas_ = from.cc_enable_arenas_; + _this->_impl_.cc_enable_arenas_ = from._impl_.cc_enable_arenas_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void FileOptions::CopyFrom(const FileOptions& from) { @@ -7075,85 +7204,75 @@ void FileOptions::CopyFrom(const FileOptions& from) { } bool FileOptions::IsInitialized() const { - if (!_extensions_.IsInitialized()) { + if (!_impl_._extensions_.IsInitialized()) { return false; } - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(uninterpreted_option_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.uninterpreted_option_)) return false; return true; } void FileOptions::InternalSwap(FileOptions* other) { using std::swap; - _extensions_.InternalSwap(&other->_extensions_); + _impl_._extensions_.InternalSwap(&other->_impl_._extensions_); auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &java_package_, lhs_arena, - &other->java_package_, rhs_arena + &_impl_.java_package_, lhs_arena, + &other->_impl_.java_package_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &java_outer_classname_, lhs_arena, - &other->java_outer_classname_, rhs_arena + &_impl_.java_outer_classname_, lhs_arena, + &other->_impl_.java_outer_classname_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &go_package_, lhs_arena, - &other->go_package_, rhs_arena + &_impl_.go_package_, lhs_arena, + &other->_impl_.go_package_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &objc_class_prefix_, lhs_arena, - &other->objc_class_prefix_, rhs_arena + &_impl_.objc_class_prefix_, lhs_arena, + &other->_impl_.objc_class_prefix_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &csharp_namespace_, lhs_arena, - &other->csharp_namespace_, rhs_arena + &_impl_.csharp_namespace_, lhs_arena, + &other->_impl_.csharp_namespace_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &swift_prefix_, lhs_arena, - &other->swift_prefix_, rhs_arena + &_impl_.swift_prefix_, lhs_arena, + &other->_impl_.swift_prefix_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &php_class_prefix_, lhs_arena, - &other->php_class_prefix_, rhs_arena + &_impl_.php_class_prefix_, lhs_arena, + &other->_impl_.php_class_prefix_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &php_namespace_, lhs_arena, - &other->php_namespace_, rhs_arena + &_impl_.php_namespace_, lhs_arena, + &other->_impl_.php_namespace_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &php_metadata_namespace_, lhs_arena, - &other->php_metadata_namespace_, rhs_arena + &_impl_.php_metadata_namespace_, lhs_arena, + &other->_impl_.php_metadata_namespace_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &ruby_package_, lhs_arena, - &other->ruby_package_, rhs_arena + &_impl_.ruby_package_, lhs_arena, + &other->_impl_.ruby_package_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(FileOptions, deprecated_) - + sizeof(FileOptions::deprecated_) - - PROTOBUF_FIELD_OFFSET(FileOptions, java_multiple_files_)>( - reinterpret_cast<char*>(&java_multiple_files_), - reinterpret_cast<char*>(&other->java_multiple_files_)); - swap(optimize_for_, other->optimize_for_); - swap(cc_enable_arenas_, other->cc_enable_arenas_); + PROTOBUF_FIELD_OFFSET(FileOptions, _impl_.deprecated_) + + sizeof(FileOptions::_impl_.deprecated_) + - PROTOBUF_FIELD_OFFSET(FileOptions, _impl_.java_multiple_files_)>( + reinterpret_cast<char*>(&_impl_.java_multiple_files_), + reinterpret_cast<char*>(&other->_impl_.java_multiple_files_)); + swap(_impl_.optimize_for_, other->_impl_.optimize_for_); + swap(_impl_.cc_enable_arenas_, other->_impl_.cc_enable_arenas_); } ::PROTOBUF_NAMESPACE_ID::Metadata FileOptions::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[13]); } @@ -7162,7 +7281,7 @@ void FileOptions::InternalSwap(FileOptions* other) { class MessageOptions::_Internal { public: - using HasBits = decltype(std::declval<MessageOptions>()._has_bits_); + using HasBits = decltype(std::declval<MessageOptions>()._impl_._has_bits_); static void set_has_message_set_wire_format(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -7179,53 +7298,64 @@ class MessageOptions::_Internal { MessageOptions::MessageOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - _extensions_(arena), - uninterpreted_option_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.MessageOptions) } MessageOptions::MessageOptions(const MessageOptions& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - uninterpreted_option_(from.uninterpreted_option_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + MessageOptions* const _this = this; (void)_this; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{} + , decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_} + , decltype(_impl_.message_set_wire_format_){} + , decltype(_impl_.no_standard_descriptor_accessor_){} + , decltype(_impl_.deprecated_){} + , decltype(_impl_.map_entry_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - ::memcpy(&message_set_wire_format_, &from.message_set_wire_format_, - static_cast<size_t>(reinterpret_cast<char*>(&map_entry_) - - reinterpret_cast<char*>(&message_set_wire_format_)) + sizeof(map_entry_)); + _impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + ::memcpy(&_impl_.message_set_wire_format_, &from._impl_.message_set_wire_format_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.map_entry_) - + reinterpret_cast<char*>(&_impl_.message_set_wire_format_)) + sizeof(_impl_.map_entry_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.MessageOptions) } -inline void MessageOptions::SharedCtor() { -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&message_set_wire_format_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&map_entry_) - - reinterpret_cast<char*>(&message_set_wire_format_)) + sizeof(map_entry_)); +inline void MessageOptions::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena} + , decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){arena} + , decltype(_impl_.message_set_wire_format_){false} + , decltype(_impl_.no_standard_descriptor_accessor_){false} + , decltype(_impl_.deprecated_){false} + , decltype(_impl_.map_entry_){false} + }; } MessageOptions::~MessageOptions() { // @@protoc_insertion_point(destructor:google.protobuf.MessageOptions) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void MessageOptions::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_._extensions_.~ExtensionSet(); + _impl_.uninterpreted_option_.~RepeatedPtrField(); } -void MessageOptions::ArenaDtor(void* object) { - MessageOptions* _this = reinterpret_cast< MessageOptions* >(object); - (void)_this; -} -void MessageOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void MessageOptions::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void MessageOptions::Clear() { @@ -7234,27 +7364,27 @@ void MessageOptions::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _extensions_.Clear(); - uninterpreted_option_.Clear(); - ::memset(&message_set_wire_format_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&map_entry_) - - reinterpret_cast<char*>(&message_set_wire_format_)) + sizeof(map_entry_)); - _has_bits_.Clear(); + _impl_._extensions_.Clear(); + _impl_.uninterpreted_option_.Clear(); + ::memset(&_impl_.message_set_wire_format_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.map_entry_) - + reinterpret_cast<char*>(&_impl_.message_set_wire_format_)) + sizeof(_impl_.map_entry_)); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* MessageOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional bool message_set_wire_format = 1 [default = false]; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { _Internal::set_has_message_set_wire_format(&has_bits); - message_set_wire_format_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.message_set_wire_format_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -7263,7 +7393,7 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { _Internal::set_has_no_standard_descriptor_accessor(&has_bits); - no_standard_descriptor_accessor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.no_standard_descriptor_accessor_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -7272,7 +7402,7 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) { _Internal::set_has_deprecated(&has_bits); - deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -7281,7 +7411,7 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE case 7: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 56)) { _Internal::set_has_map_entry(&has_bits); - map_entry_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.map_entry_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -7309,7 +7439,7 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE goto message_done; } if ((8000u <= tag)) { - ptr = _extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); + ptr = _impl_._extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); CHK_(ptr != nullptr); continue; } @@ -7320,7 +7450,7 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -7334,45 +7464,45 @@ uint8_t* MessageOptions::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional bool message_set_wire_format = 1 [default = false]; if (cached_has_bits & 0x00000001u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(1, this->_internal_message_set_wire_format(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(1, this->_internal_message_set_wire_format(), target); } // optional bool no_standard_descriptor_accessor = 2 [default = false]; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(2, this->_internal_no_standard_descriptor_accessor(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_no_standard_descriptor_accessor(), target); } // optional bool deprecated = 3 [default = false]; if (cached_has_bits & 0x00000004u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target); } // optional bool map_entry = 7; if (cached_has_bits & 0x00000008u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(7, this->_internal_map_entry(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(7, this->_internal_map_entry(), target); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) { + const auto& repfield = this->_internal_uninterpreted_option(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream); + InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream); } // Extension range [1000, 536870912) - target = _extensions_._InternalSerialize( + target = _impl_._extensions_._InternalSerialize( internal_default_instance(), 1000, 536870912, target, stream); if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MessageOptions) @@ -7383,7 +7513,7 @@ size_t MessageOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MessageOptions) size_t total_size = 0; - total_size += _extensions_.ByteSize(); + total_size += _impl_._extensions_.ByteSize(); uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused @@ -7391,12 +7521,12 @@ size_t MessageOptions::ByteSizeLong() const { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2UL * this->_internal_uninterpreted_option_size(); - for (const auto& msg : this->uninterpreted_option_) { + for (const auto& msg : this->_impl_.uninterpreted_option_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { // optional bool message_set_wire_format = 1 [default = false]; if (cached_has_bits & 0x00000001u) { @@ -7419,47 +7549,43 @@ size_t MessageOptions::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData MessageOptions::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, MessageOptions::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*MessageOptions::GetClassData() const { return &_class_data_; } -void MessageOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<MessageOptions *>(to)->MergeFrom( - static_cast<const MessageOptions &>(from)); -} - -void MessageOptions::MergeFrom(const MessageOptions& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions) - GOOGLE_DCHECK_NE(&from, this); +void MessageOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<MessageOptions*>(&to_msg); + auto& from = static_cast<const MessageOptions&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { - message_set_wire_format_ = from.message_set_wire_format_; + _this->_impl_.message_set_wire_format_ = from._impl_.message_set_wire_format_; } if (cached_has_bits & 0x00000002u) { - no_standard_descriptor_accessor_ = from.no_standard_descriptor_accessor_; + _this->_impl_.no_standard_descriptor_accessor_ = from._impl_.no_standard_descriptor_accessor_; } if (cached_has_bits & 0x00000004u) { - deprecated_ = from.deprecated_; + _this->_impl_.deprecated_ = from._impl_.deprecated_; } if (cached_has_bits & 0x00000008u) { - map_entry_ = from.map_entry_; + _this->_impl_.map_entry_ = from._impl_.map_entry_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void MessageOptions::CopyFrom(const MessageOptions& from) { @@ -7470,31 +7596,31 @@ void MessageOptions::CopyFrom(const MessageOptions& from) { } bool MessageOptions::IsInitialized() const { - if (!_extensions_.IsInitialized()) { + if (!_impl_._extensions_.IsInitialized()) { return false; } - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(uninterpreted_option_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.uninterpreted_option_)) return false; return true; } void MessageOptions::InternalSwap(MessageOptions* other) { using std::swap; - _extensions_.InternalSwap(&other->_extensions_); + _impl_._extensions_.InternalSwap(&other->_impl_._extensions_); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(MessageOptions, map_entry_) - + sizeof(MessageOptions::map_entry_) - - PROTOBUF_FIELD_OFFSET(MessageOptions, message_set_wire_format_)>( - reinterpret_cast<char*>(&message_set_wire_format_), - reinterpret_cast<char*>(&other->message_set_wire_format_)); + PROTOBUF_FIELD_OFFSET(MessageOptions, _impl_.map_entry_) + + sizeof(MessageOptions::_impl_.map_entry_) + - PROTOBUF_FIELD_OFFSET(MessageOptions, _impl_.message_set_wire_format_)>( + reinterpret_cast<char*>(&_impl_.message_set_wire_format_), + reinterpret_cast<char*>(&other->_impl_.message_set_wire_format_)); } ::PROTOBUF_NAMESPACE_ID::Metadata MessageOptions::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[14]); } @@ -7503,76 +7629,96 @@ void MessageOptions::InternalSwap(MessageOptions* other) { class FieldOptions::_Internal { public: - using HasBits = decltype(std::declval<FieldOptions>()._has_bits_); + using HasBits = decltype(std::declval<FieldOptions>()._impl_._has_bits_); static void set_has_ctype(HasBits* has_bits) { (*has_bits)[0] |= 1u; } static void set_has_packed(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static void set_has_jstype(HasBits* has_bits) { - (*has_bits)[0] |= 32u; - } - static void set_has_lazy(HasBits* has_bits) { (*has_bits)[0] |= 4u; } - static void set_has_deprecated(HasBits* has_bits) { + static void set_has_jstype(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_lazy(HasBits* has_bits) { (*has_bits)[0] |= 8u; } - static void set_has_weak(HasBits* has_bits) { + static void set_has_unverified_lazy(HasBits* has_bits) { (*has_bits)[0] |= 16u; } + static void set_has_deprecated(HasBits* has_bits) { + (*has_bits)[0] |= 32u; + } + static void set_has_weak(HasBits* has_bits) { + (*has_bits)[0] |= 64u; + } }; FieldOptions::FieldOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - _extensions_(arena), - uninterpreted_option_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.FieldOptions) } FieldOptions::FieldOptions(const FieldOptions& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - uninterpreted_option_(from.uninterpreted_option_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + FieldOptions* const _this = this; (void)_this; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{} + , decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_} + , decltype(_impl_.ctype_){} + , decltype(_impl_.jstype_){} + , decltype(_impl_.packed_){} + , decltype(_impl_.lazy_){} + , decltype(_impl_.unverified_lazy_){} + , decltype(_impl_.deprecated_){} + , decltype(_impl_.weak_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - ::memcpy(&ctype_, &from.ctype_, - static_cast<size_t>(reinterpret_cast<char*>(&jstype_) - - reinterpret_cast<char*>(&ctype_)) + sizeof(jstype_)); + _impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + ::memcpy(&_impl_.ctype_, &from._impl_.ctype_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.weak_) - + reinterpret_cast<char*>(&_impl_.ctype_)) + sizeof(_impl_.weak_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions) } -inline void FieldOptions::SharedCtor() { -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&ctype_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&jstype_) - - reinterpret_cast<char*>(&ctype_)) + sizeof(jstype_)); +inline void FieldOptions::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena} + , decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){arena} + , decltype(_impl_.ctype_){0} + , decltype(_impl_.jstype_){0} + , decltype(_impl_.packed_){false} + , decltype(_impl_.lazy_){false} + , decltype(_impl_.unverified_lazy_){false} + , decltype(_impl_.deprecated_){false} + , decltype(_impl_.weak_){false} + }; } FieldOptions::~FieldOptions() { // @@protoc_insertion_point(destructor:google.protobuf.FieldOptions) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void FieldOptions::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_._extensions_.~ExtensionSet(); + _impl_.uninterpreted_option_.~RepeatedPtrField(); } -void FieldOptions::ArenaDtor(void* object) { - FieldOptions* _this = reinterpret_cast< FieldOptions* >(object); - (void)_this; -} -void FieldOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void FieldOptions::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void FieldOptions::Clear() { @@ -7581,24 +7727,24 @@ void FieldOptions::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _extensions_.Clear(); - uninterpreted_option_.Clear(); - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x0000003fu) { - ::memset(&ctype_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&jstype_) - - reinterpret_cast<char*>(&ctype_)) + sizeof(jstype_)); + _impl_._extensions_.Clear(); + _impl_.uninterpreted_option_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x0000007fu) { + ::memset(&_impl_.ctype_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.weak_) - + reinterpret_cast<char*>(&_impl_.ctype_)) + sizeof(_impl_.weak_)); } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* FieldOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; case 1: @@ -7617,7 +7763,7 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { _Internal::set_has_packed(&has_bits); - packed_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.packed_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -7626,7 +7772,7 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) { _Internal::set_has_deprecated(&has_bits); - deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -7635,7 +7781,7 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I case 5: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) { _Internal::set_has_lazy(&has_bits); - lazy_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.lazy_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -7657,7 +7803,16 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I case 10: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 80)) { _Internal::set_has_weak(&has_bits); - weak_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.weak_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional bool unverified_lazy = 15 [default = false]; + case 15: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 120)) { + _Internal::set_has_unverified_lazy(&has_bits); + _impl_.unverified_lazy_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -7685,7 +7840,7 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I goto message_done; } if ((8000u <= tag)) { - ptr = _extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); + ptr = _impl_._extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); CHK_(ptr != nullptr); continue; } @@ -7696,7 +7851,7 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -7710,59 +7865,65 @@ uint8_t* FieldOptions::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; if (cached_has_bits & 0x00000001u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 1, this->_internal_ctype(), target); } // optional bool packed = 2; - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000004u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(2, this->_internal_packed(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_packed(), target); } // optional bool deprecated = 3 [default = false]; - if (cached_has_bits & 0x00000008u) { + if (cached_has_bits & 0x00000020u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target); } // optional bool lazy = 5 [default = false]; - if (cached_has_bits & 0x00000004u) { + if (cached_has_bits & 0x00000008u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_lazy(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_lazy(), target); } // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; - if (cached_has_bits & 0x00000020u) { + if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 6, this->_internal_jstype(), target); } // optional bool weak = 10 [default = false]; + if (cached_has_bits & 0x00000040u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(10, this->_internal_weak(), target); + } + + // optional bool unverified_lazy = 15 [default = false]; if (cached_has_bits & 0x00000010u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(10, this->_internal_weak(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(15, this->_internal_unverified_lazy(), target); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) { + const auto& repfield = this->_internal_uninterpreted_option(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream); + InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream); } // Extension range [1000, 536870912) - target = _extensions_._InternalSerialize( + target = _impl_._extensions_._InternalSerialize( internal_default_instance(), 1000, 536870912, target, stream); if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldOptions) @@ -7773,7 +7934,7 @@ size_t FieldOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldOptions) size_t total_size = 0; - total_size += _extensions_.ByteSize(); + total_size += _impl_._extensions_.ByteSize(); uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused @@ -7781,93 +7942,97 @@ size_t FieldOptions::ByteSizeLong() const { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2UL * this->_internal_uninterpreted_option_size(); - for (const auto& msg : this->uninterpreted_option_) { + for (const auto& msg : this->_impl_.uninterpreted_option_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x0000003fu) { + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x0000007fu) { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; if (cached_has_bits & 0x00000001u) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_ctype()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_ctype()); + } + + // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_jstype()); } // optional bool packed = 2; - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000004u) { total_size += 1 + 1; } // optional bool lazy = 5 [default = false]; - if (cached_has_bits & 0x00000004u) { + if (cached_has_bits & 0x00000008u) { + total_size += 1 + 1; + } + + // optional bool unverified_lazy = 15 [default = false]; + if (cached_has_bits & 0x00000010u) { total_size += 1 + 1; } // optional bool deprecated = 3 [default = false]; - if (cached_has_bits & 0x00000008u) { + if (cached_has_bits & 0x00000020u) { total_size += 1 + 1; } // optional bool weak = 10 [default = false]; - if (cached_has_bits & 0x00000010u) { + if (cached_has_bits & 0x00000040u) { total_size += 1 + 1; } - // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; - if (cached_has_bits & 0x00000020u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_jstype()); - } - } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FieldOptions::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, FieldOptions::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FieldOptions::GetClassData() const { return &_class_data_; } -void FieldOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<FieldOptions *>(to)->MergeFrom( - static_cast<const FieldOptions &>(from)); -} - -void FieldOptions::MergeFrom(const FieldOptions& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions) - GOOGLE_DCHECK_NE(&from, this); +void FieldOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<FieldOptions*>(&to_msg); + auto& from = static_cast<const FieldOptions&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x0000003fu) { + _this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_); + cached_has_bits = from._impl_._has_bits_[0]; + if (cached_has_bits & 0x0000007fu) { if (cached_has_bits & 0x00000001u) { - ctype_ = from.ctype_; + _this->_impl_.ctype_ = from._impl_.ctype_; } if (cached_has_bits & 0x00000002u) { - packed_ = from.packed_; + _this->_impl_.jstype_ = from._impl_.jstype_; } if (cached_has_bits & 0x00000004u) { - lazy_ = from.lazy_; + _this->_impl_.packed_ = from._impl_.packed_; } if (cached_has_bits & 0x00000008u) { - deprecated_ = from.deprecated_; + _this->_impl_.lazy_ = from._impl_.lazy_; } if (cached_has_bits & 0x00000010u) { - weak_ = from.weak_; + _this->_impl_.unverified_lazy_ = from._impl_.unverified_lazy_; } if (cached_has_bits & 0x00000020u) { - jstype_ = from.jstype_; + _this->_impl_.deprecated_ = from._impl_.deprecated_; } - _has_bits_[0] |= cached_has_bits; + if (cached_has_bits & 0x00000040u) { + _this->_impl_.weak_ = from._impl_.weak_; + } + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void FieldOptions::CopyFrom(const FieldOptions& from) { @@ -7878,31 +8043,31 @@ void FieldOptions::CopyFrom(const FieldOptions& from) { } bool FieldOptions::IsInitialized() const { - if (!_extensions_.IsInitialized()) { + if (!_impl_._extensions_.IsInitialized()) { return false; } - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(uninterpreted_option_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.uninterpreted_option_)) return false; return true; } void FieldOptions::InternalSwap(FieldOptions* other) { using std::swap; - _extensions_.InternalSwap(&other->_extensions_); + _impl_._extensions_.InternalSwap(&other->_impl_._extensions_); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(FieldOptions, jstype_) - + sizeof(FieldOptions::jstype_) - - PROTOBUF_FIELD_OFFSET(FieldOptions, ctype_)>( - reinterpret_cast<char*>(&ctype_), - reinterpret_cast<char*>(&other->ctype_)); + PROTOBUF_FIELD_OFFSET(FieldOptions, _impl_.weak_) + + sizeof(FieldOptions::_impl_.weak_) + - PROTOBUF_FIELD_OFFSET(FieldOptions, _impl_.ctype_)>( + reinterpret_cast<char*>(&_impl_.ctype_), + reinterpret_cast<char*>(&other->_impl_.ctype_)); } ::PROTOBUF_NAMESPACE_ID::Metadata FieldOptions::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[15]); } @@ -7915,45 +8080,51 @@ class OneofOptions::_Internal { OneofOptions::OneofOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - _extensions_(arena), - uninterpreted_option_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.OneofOptions) } OneofOptions::OneofOptions(const OneofOptions& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - uninterpreted_option_(from.uninterpreted_option_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + OneofOptions* const _this = this; (void)_this; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{} + , decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); + _impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofOptions) } -inline void OneofOptions::SharedCtor() { +inline void OneofOptions::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena} + , decltype(_impl_.uninterpreted_option_){arena} + , /*decltype(_impl_._cached_size_)*/{} + }; } OneofOptions::~OneofOptions() { // @@protoc_insertion_point(destructor:google.protobuf.OneofOptions) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void OneofOptions::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_._extensions_.~ExtensionSet(); + _impl_.uninterpreted_option_.~RepeatedPtrField(); } -void OneofOptions::ArenaDtor(void* object) { - OneofOptions* _this = reinterpret_cast< OneofOptions* >(object); - (void)_this; -} -void OneofOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void OneofOptions::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void OneofOptions::Clear() { @@ -7962,16 +8133,16 @@ void OneofOptions::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _extensions_.Clear(); - uninterpreted_option_.Clear(); + _impl_._extensions_.Clear(); + _impl_.uninterpreted_option_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* OneofOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* OneofOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: @@ -7996,7 +8167,7 @@ const char* OneofOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I goto message_done; } if ((8000u <= tag)) { - ptr = _extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); + ptr = _impl_._extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); CHK_(ptr != nullptr); continue; } @@ -8021,19 +8192,19 @@ uint8_t* OneofOptions::_InternalSerialize( (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) { + const auto& repfield = this->_internal_uninterpreted_option(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream); + InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream); } // Extension range [1000, 536870912) - target = _extensions_._InternalSerialize( + target = _impl_._extensions_._InternalSerialize( internal_default_instance(), 1000, 536870912, target, stream); if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.OneofOptions) @@ -8044,7 +8215,7 @@ size_t OneofOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofOptions) size_t total_size = 0; - total_size += _extensions_.ByteSize(); + total_size += _impl_._extensions_.ByteSize(); uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused @@ -8052,36 +8223,32 @@ size_t OneofOptions::ByteSizeLong() const { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2UL * this->_internal_uninterpreted_option_size(); - for (const auto& msg : this->uninterpreted_option_) { + for (const auto& msg : this->_impl_.uninterpreted_option_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData OneofOptions::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, OneofOptions::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*OneofOptions::GetClassData() const { return &_class_data_; } -void OneofOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<OneofOptions *>(to)->MergeFrom( - static_cast<const OneofOptions &>(from)); -} - -void OneofOptions::MergeFrom(const OneofOptions& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions) - GOOGLE_DCHECK_NE(&from, this); +void OneofOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<OneofOptions*>(&to_msg); + auto& from = static_cast<const OneofOptions&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_); + _this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void OneofOptions::CopyFrom(const OneofOptions& from) { @@ -8092,24 +8259,24 @@ void OneofOptions::CopyFrom(const OneofOptions& from) { } bool OneofOptions::IsInitialized() const { - if (!_extensions_.IsInitialized()) { + if (!_impl_._extensions_.IsInitialized()) { return false; } - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(uninterpreted_option_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.uninterpreted_option_)) return false; return true; } void OneofOptions::InternalSwap(OneofOptions* other) { using std::swap; - _extensions_.InternalSwap(&other->_extensions_); + _impl_._extensions_.InternalSwap(&other->_impl_._extensions_); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); + _impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_); } ::PROTOBUF_NAMESPACE_ID::Metadata OneofOptions::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[16]); } @@ -8118,7 +8285,7 @@ void OneofOptions::InternalSwap(OneofOptions* other) { class EnumOptions::_Internal { public: - using HasBits = decltype(std::declval<EnumOptions>()._has_bits_); + using HasBits = decltype(std::declval<EnumOptions>()._impl_._has_bits_); static void set_has_allow_alias(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -8129,53 +8296,60 @@ class EnumOptions::_Internal { EnumOptions::EnumOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - _extensions_(arena), - uninterpreted_option_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumOptions) } EnumOptions::EnumOptions(const EnumOptions& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - uninterpreted_option_(from.uninterpreted_option_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + EnumOptions* const _this = this; (void)_this; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{} + , decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_} + , decltype(_impl_.allow_alias_){} + , decltype(_impl_.deprecated_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - ::memcpy(&allow_alias_, &from.allow_alias_, - static_cast<size_t>(reinterpret_cast<char*>(&deprecated_) - - reinterpret_cast<char*>(&allow_alias_)) + sizeof(deprecated_)); + _impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + ::memcpy(&_impl_.allow_alias_, &from._impl_.allow_alias_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.deprecated_) - + reinterpret_cast<char*>(&_impl_.allow_alias_)) + sizeof(_impl_.deprecated_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumOptions) } -inline void EnumOptions::SharedCtor() { -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&allow_alias_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&deprecated_) - - reinterpret_cast<char*>(&allow_alias_)) + sizeof(deprecated_)); +inline void EnumOptions::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena} + , decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){arena} + , decltype(_impl_.allow_alias_){false} + , decltype(_impl_.deprecated_){false} + }; } EnumOptions::~EnumOptions() { // @@protoc_insertion_point(destructor:google.protobuf.EnumOptions) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void EnumOptions::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_._extensions_.~ExtensionSet(); + _impl_.uninterpreted_option_.~RepeatedPtrField(); } -void EnumOptions::ArenaDtor(void* object) { - EnumOptions* _this = reinterpret_cast< EnumOptions* >(object); - (void)_this; -} -void EnumOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void EnumOptions::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void EnumOptions::Clear() { @@ -8184,27 +8358,27 @@ void EnumOptions::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _extensions_.Clear(); - uninterpreted_option_.Clear(); - ::memset(&allow_alias_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&deprecated_) - - reinterpret_cast<char*>(&allow_alias_)) + sizeof(deprecated_)); - _has_bits_.Clear(); + _impl_._extensions_.Clear(); + _impl_.uninterpreted_option_.Clear(); + ::memset(&_impl_.allow_alias_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.deprecated_) - + reinterpret_cast<char*>(&_impl_.allow_alias_)) + sizeof(_impl_.deprecated_)); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* EnumOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* EnumOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional bool allow_alias = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { _Internal::set_has_allow_alias(&has_bits); - allow_alias_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.allow_alias_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8213,7 +8387,7 @@ const char* EnumOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) { _Internal::set_has_deprecated(&has_bits); - deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8241,7 +8415,7 @@ const char* EnumOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID goto message_done; } if ((8000u <= tag)) { - ptr = _extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); + ptr = _impl_._extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); CHK_(ptr != nullptr); continue; } @@ -8252,7 +8426,7 @@ const char* EnumOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -8266,33 +8440,33 @@ uint8_t* EnumOptions::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional bool allow_alias = 2; if (cached_has_bits & 0x00000001u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(2, this->_internal_allow_alias(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_allow_alias(), target); } // optional bool deprecated = 3 [default = false]; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_deprecated(), target); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) { + const auto& repfield = this->_internal_uninterpreted_option(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream); + InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream); } // Extension range [1000, 536870912) - target = _extensions_._InternalSerialize( + target = _impl_._extensions_._InternalSerialize( internal_default_instance(), 1000, 536870912, target, stream); if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumOptions) @@ -8303,7 +8477,7 @@ size_t EnumOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumOptions) size_t total_size = 0; - total_size += _extensions_.ByteSize(); + total_size += _impl_._extensions_.ByteSize(); uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused @@ -8311,12 +8485,12 @@ size_t EnumOptions::ByteSizeLong() const { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2UL * this->_internal_uninterpreted_option_size(); - for (const auto& msg : this->uninterpreted_option_) { + for (const auto& msg : this->_impl_.uninterpreted_option_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { // optional bool allow_alias = 2; if (cached_has_bits & 0x00000001u) { @@ -8329,41 +8503,37 @@ size_t EnumOptions::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData EnumOptions::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, EnumOptions::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*EnumOptions::GetClassData() const { return &_class_data_; } -void EnumOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<EnumOptions *>(to)->MergeFrom( - static_cast<const EnumOptions &>(from)); -} - -void EnumOptions::MergeFrom(const EnumOptions& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions) - GOOGLE_DCHECK_NE(&from, this); +void EnumOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<EnumOptions*>(&to_msg); + auto& from = static_cast<const EnumOptions&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - allow_alias_ = from.allow_alias_; + _this->_impl_.allow_alias_ = from._impl_.allow_alias_; } if (cached_has_bits & 0x00000002u) { - deprecated_ = from.deprecated_; + _this->_impl_.deprecated_ = from._impl_.deprecated_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void EnumOptions::CopyFrom(const EnumOptions& from) { @@ -8374,31 +8544,31 @@ void EnumOptions::CopyFrom(const EnumOptions& from) { } bool EnumOptions::IsInitialized() const { - if (!_extensions_.IsInitialized()) { + if (!_impl_._extensions_.IsInitialized()) { return false; } - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(uninterpreted_option_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.uninterpreted_option_)) return false; return true; } void EnumOptions::InternalSwap(EnumOptions* other) { using std::swap; - _extensions_.InternalSwap(&other->_extensions_); + _impl_._extensions_.InternalSwap(&other->_impl_._extensions_); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(EnumOptions, deprecated_) - + sizeof(EnumOptions::deprecated_) - - PROTOBUF_FIELD_OFFSET(EnumOptions, allow_alias_)>( - reinterpret_cast<char*>(&allow_alias_), - reinterpret_cast<char*>(&other->allow_alias_)); + PROTOBUF_FIELD_OFFSET(EnumOptions, _impl_.deprecated_) + + sizeof(EnumOptions::_impl_.deprecated_) + - PROTOBUF_FIELD_OFFSET(EnumOptions, _impl_.allow_alias_)>( + reinterpret_cast<char*>(&_impl_.allow_alias_), + reinterpret_cast<char*>(&other->_impl_.allow_alias_)); } ::PROTOBUF_NAMESPACE_ID::Metadata EnumOptions::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[17]); } @@ -8407,7 +8577,7 @@ void EnumOptions::InternalSwap(EnumOptions* other) { class EnumValueOptions::_Internal { public: - using HasBits = decltype(std::declval<EnumValueOptions>()._has_bits_); + using HasBits = decltype(std::declval<EnumValueOptions>()._impl_._has_bits_); static void set_has_deprecated(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -8415,48 +8585,56 @@ class EnumValueOptions::_Internal { EnumValueOptions::EnumValueOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - _extensions_(arena), - uninterpreted_option_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValueOptions) } EnumValueOptions::EnumValueOptions(const EnumValueOptions& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - uninterpreted_option_(from.uninterpreted_option_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + EnumValueOptions* const _this = this; (void)_this; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{} + , decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_} + , decltype(_impl_.deprecated_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - deprecated_ = from.deprecated_; + _impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + _this->_impl_.deprecated_ = from._impl_.deprecated_; // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueOptions) } -inline void EnumValueOptions::SharedCtor() { -deprecated_ = false; +inline void EnumValueOptions::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena} + , decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){arena} + , decltype(_impl_.deprecated_){false} + }; } EnumValueOptions::~EnumValueOptions() { // @@protoc_insertion_point(destructor:google.protobuf.EnumValueOptions) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void EnumValueOptions::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_._extensions_.~ExtensionSet(); + _impl_.uninterpreted_option_.~RepeatedPtrField(); } -void EnumValueOptions::ArenaDtor(void* object) { - EnumValueOptions* _this = reinterpret_cast< EnumValueOptions* >(object); - (void)_this; -} -void EnumValueOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void EnumValueOptions::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void EnumValueOptions::Clear() { @@ -8465,25 +8643,25 @@ void EnumValueOptions::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _extensions_.Clear(); - uninterpreted_option_.Clear(); - deprecated_ = false; - _has_bits_.Clear(); + _impl_._extensions_.Clear(); + _impl_.uninterpreted_option_.Clear(); + _impl_.deprecated_ = false; + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* EnumValueOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* EnumValueOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional bool deprecated = 1 [default = false]; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { _Internal::set_has_deprecated(&has_bits); - deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8511,7 +8689,7 @@ const char* EnumValueOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPA goto message_done; } if ((8000u <= tag)) { - ptr = _extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); + ptr = _impl_._extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); CHK_(ptr != nullptr); continue; } @@ -8522,7 +8700,7 @@ const char* EnumValueOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPA CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -8536,27 +8714,27 @@ uint8_t* EnumValueOptions::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional bool deprecated = 1 [default = false]; if (cached_has_bits & 0x00000001u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(1, this->_internal_deprecated(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(1, this->_internal_deprecated(), target); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) { + const auto& repfield = this->_internal_uninterpreted_option(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream); + InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream); } // Extension range [1000, 536870912) - target = _extensions_._InternalSerialize( + target = _impl_._extensions_._InternalSerialize( internal_default_instance(), 1000, 536870912, target, stream); if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValueOptions) @@ -8567,7 +8745,7 @@ size_t EnumValueOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueOptions) size_t total_size = 0; - total_size += _extensions_.ByteSize(); + total_size += _impl_._extensions_.ByteSize(); uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused @@ -8575,45 +8753,41 @@ size_t EnumValueOptions::ByteSizeLong() const { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2UL * this->_internal_uninterpreted_option_size(); - for (const auto& msg : this->uninterpreted_option_) { + for (const auto& msg : this->_impl_.uninterpreted_option_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // optional bool deprecated = 1 [default = false]; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000001u) { total_size += 1 + 1; } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData EnumValueOptions::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, EnumValueOptions::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*EnumValueOptions::GetClassData() const { return &_class_data_; } -void EnumValueOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<EnumValueOptions *>(to)->MergeFrom( - static_cast<const EnumValueOptions &>(from)); -} - -void EnumValueOptions::MergeFrom(const EnumValueOptions& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions) - GOOGLE_DCHECK_NE(&from, this); +void EnumValueOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<EnumValueOptions*>(&to_msg); + auto& from = static_cast<const EnumValueOptions&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); + _this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_); if (from._internal_has_deprecated()) { - _internal_set_deprecated(from._internal_deprecated()); + _this->_internal_set_deprecated(from._internal_deprecated()); } - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void EnumValueOptions::CopyFrom(const EnumValueOptions& from) { @@ -8624,26 +8798,26 @@ void EnumValueOptions::CopyFrom(const EnumValueOptions& from) { } bool EnumValueOptions::IsInitialized() const { - if (!_extensions_.IsInitialized()) { + if (!_impl_._extensions_.IsInitialized()) { return false; } - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(uninterpreted_option_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.uninterpreted_option_)) return false; return true; } void EnumValueOptions::InternalSwap(EnumValueOptions* other) { using std::swap; - _extensions_.InternalSwap(&other->_extensions_); + _impl_._extensions_.InternalSwap(&other->_impl_._extensions_); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - swap(deprecated_, other->deprecated_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_); + swap(_impl_.deprecated_, other->_impl_.deprecated_); } ::PROTOBUF_NAMESPACE_ID::Metadata EnumValueOptions::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[18]); } @@ -8652,7 +8826,7 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) { class ServiceOptions::_Internal { public: - using HasBits = decltype(std::declval<ServiceOptions>()._has_bits_); + using HasBits = decltype(std::declval<ServiceOptions>()._impl_._has_bits_); static void set_has_deprecated(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -8660,48 +8834,56 @@ class ServiceOptions::_Internal { ServiceOptions::ServiceOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - _extensions_(arena), - uninterpreted_option_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.ServiceOptions) } ServiceOptions::ServiceOptions(const ServiceOptions& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - uninterpreted_option_(from.uninterpreted_option_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + ServiceOptions* const _this = this; (void)_this; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{} + , decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_} + , decltype(_impl_.deprecated_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - deprecated_ = from.deprecated_; + _impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + _this->_impl_.deprecated_ = from._impl_.deprecated_; // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceOptions) } -inline void ServiceOptions::SharedCtor() { -deprecated_ = false; +inline void ServiceOptions::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena} + , decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){arena} + , decltype(_impl_.deprecated_){false} + }; } ServiceOptions::~ServiceOptions() { // @@protoc_insertion_point(destructor:google.protobuf.ServiceOptions) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void ServiceOptions::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_._extensions_.~ExtensionSet(); + _impl_.uninterpreted_option_.~RepeatedPtrField(); } -void ServiceOptions::ArenaDtor(void* object) { - ServiceOptions* _this = reinterpret_cast< ServiceOptions* >(object); - (void)_this; -} -void ServiceOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void ServiceOptions::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void ServiceOptions::Clear() { @@ -8710,25 +8892,25 @@ void ServiceOptions::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _extensions_.Clear(); - uninterpreted_option_.Clear(); - deprecated_ = false; - _has_bits_.Clear(); + _impl_._extensions_.Clear(); + _impl_.uninterpreted_option_.Clear(); + _impl_.deprecated_ = false; + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* ServiceOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* ServiceOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional bool deprecated = 33 [default = false]; case 33: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { _Internal::set_has_deprecated(&has_bits); - deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -8756,7 +8938,7 @@ const char* ServiceOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE goto message_done; } if ((8000u <= tag)) { - ptr = _extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); + ptr = _impl_._extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); CHK_(ptr != nullptr); continue; } @@ -8767,7 +8949,7 @@ const char* ServiceOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -8781,27 +8963,27 @@ uint8_t* ServiceOptions::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional bool deprecated = 33 [default = false]; if (cached_has_bits & 0x00000001u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(33, this->_internal_deprecated(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(33, this->_internal_deprecated(), target); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) { + const auto& repfield = this->_internal_uninterpreted_option(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream); + InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream); } // Extension range [1000, 536870912) - target = _extensions_._InternalSerialize( + target = _impl_._extensions_._InternalSerialize( internal_default_instance(), 1000, 536870912, target, stream); if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ServiceOptions) @@ -8812,7 +8994,7 @@ size_t ServiceOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceOptions) size_t total_size = 0; - total_size += _extensions_.ByteSize(); + total_size += _impl_._extensions_.ByteSize(); uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused @@ -8820,45 +9002,41 @@ size_t ServiceOptions::ByteSizeLong() const { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2UL * this->_internal_uninterpreted_option_size(); - for (const auto& msg : this->uninterpreted_option_) { + for (const auto& msg : this->_impl_.uninterpreted_option_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // optional bool deprecated = 33 [default = false]; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000001u) { total_size += 2 + 1; } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ServiceOptions::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, ServiceOptions::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ServiceOptions::GetClassData() const { return &_class_data_; } -void ServiceOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<ServiceOptions *>(to)->MergeFrom( - static_cast<const ServiceOptions &>(from)); -} - -void ServiceOptions::MergeFrom(const ServiceOptions& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions) - GOOGLE_DCHECK_NE(&from, this); +void ServiceOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<ServiceOptions*>(&to_msg); + auto& from = static_cast<const ServiceOptions&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); + _this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_); if (from._internal_has_deprecated()) { - _internal_set_deprecated(from._internal_deprecated()); + _this->_internal_set_deprecated(from._internal_deprecated()); } - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void ServiceOptions::CopyFrom(const ServiceOptions& from) { @@ -8869,26 +9047,26 @@ void ServiceOptions::CopyFrom(const ServiceOptions& from) { } bool ServiceOptions::IsInitialized() const { - if (!_extensions_.IsInitialized()) { + if (!_impl_._extensions_.IsInitialized()) { return false; } - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(uninterpreted_option_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.uninterpreted_option_)) return false; return true; } void ServiceOptions::InternalSwap(ServiceOptions* other) { using std::swap; - _extensions_.InternalSwap(&other->_extensions_); + _impl_._extensions_.InternalSwap(&other->_impl_._extensions_); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); - swap(deprecated_, other->deprecated_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_); + swap(_impl_.deprecated_, other->_impl_.deprecated_); } ::PROTOBUF_NAMESPACE_ID::Metadata ServiceOptions::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[19]); } @@ -8897,7 +9075,7 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) { class MethodOptions::_Internal { public: - using HasBits = decltype(std::declval<MethodOptions>()._has_bits_); + using HasBits = decltype(std::declval<MethodOptions>()._impl_._has_bits_); static void set_has_deprecated(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -8908,53 +9086,60 @@ class MethodOptions::_Internal { MethodOptions::MethodOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - _extensions_(arena), - uninterpreted_option_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.MethodOptions) } MethodOptions::MethodOptions(const MethodOptions& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - uninterpreted_option_(from.uninterpreted_option_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + MethodOptions* const _this = this; (void)_this; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{} + , decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){from._impl_.uninterpreted_option_} + , decltype(_impl_.deprecated_){} + , decltype(_impl_.idempotency_level_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - ::memcpy(&deprecated_, &from.deprecated_, - static_cast<size_t>(reinterpret_cast<char*>(&idempotency_level_) - - reinterpret_cast<char*>(&deprecated_)) + sizeof(idempotency_level_)); + _impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + ::memcpy(&_impl_.deprecated_, &from._impl_.deprecated_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.idempotency_level_) - + reinterpret_cast<char*>(&_impl_.deprecated_)) + sizeof(_impl_.idempotency_level_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodOptions) } -inline void MethodOptions::SharedCtor() { -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&deprecated_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&idempotency_level_) - - reinterpret_cast<char*>(&deprecated_)) + sizeof(idempotency_level_)); +inline void MethodOptions::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_._extensions_)*/{::_pbi::ArenaInitialized(), arena} + , decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.uninterpreted_option_){arena} + , decltype(_impl_.deprecated_){false} + , decltype(_impl_.idempotency_level_){0} + }; } MethodOptions::~MethodOptions() { // @@protoc_insertion_point(destructor:google.protobuf.MethodOptions) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void MethodOptions::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_._extensions_.~ExtensionSet(); + _impl_.uninterpreted_option_.~RepeatedPtrField(); } -void MethodOptions::ArenaDtor(void* object) { - MethodOptions* _this = reinterpret_cast< MethodOptions* >(object); - (void)_this; -} -void MethodOptions::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void MethodOptions::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void MethodOptions::Clear() { @@ -8963,30 +9148,30 @@ void MethodOptions::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - _extensions_.Clear(); - uninterpreted_option_.Clear(); - cached_has_bits = _has_bits_[0]; + _impl_._extensions_.Clear(); + _impl_.uninterpreted_option_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { - ::memset(&deprecated_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&idempotency_level_) - - reinterpret_cast<char*>(&deprecated_)) + sizeof(idempotency_level_)); + ::memset(&_impl_.deprecated_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.idempotency_level_) - + reinterpret_cast<char*>(&_impl_.deprecated_)) + sizeof(_impl_.idempotency_level_)); } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* MethodOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* MethodOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // optional bool deprecated = 33 [default = false]; case 33: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { _Internal::set_has_deprecated(&has_bits); - deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.deprecated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -9027,7 +9212,7 @@ const char* MethodOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ goto message_done; } if ((8000u <= tag)) { - ptr = _extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); + ptr = _impl_._extensions_.ParseField(tag, ptr, internal_default_instance(), &_internal_metadata_, ctx); CHK_(ptr != nullptr); continue; } @@ -9038,7 +9223,7 @@ const char* MethodOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -9052,34 +9237,34 @@ uint8_t* MethodOptions::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional bool deprecated = 33 [default = false]; if (cached_has_bits & 0x00000001u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(33, this->_internal_deprecated(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(33, this->_internal_deprecated(), target); } // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 34, this->_internal_idempotency_level(), target); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_uninterpreted_option_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) { + const auto& repfield = this->_internal_uninterpreted_option(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(999, this->_internal_uninterpreted_option(i), target, stream); + InternalWriteMessage(999, repfield, repfield.GetCachedSize(), target, stream); } // Extension range [1000, 536870912) - target = _extensions_._InternalSerialize( + target = _impl_._extensions_._InternalSerialize( internal_default_instance(), 1000, 536870912, target, stream); if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MethodOptions) @@ -9090,7 +9275,7 @@ size_t MethodOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodOptions) size_t total_size = 0; - total_size += _extensions_.ByteSize(); + total_size += _impl_._extensions_.ByteSize(); uint32_t cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused @@ -9098,12 +9283,12 @@ size_t MethodOptions::ByteSizeLong() const { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2UL * this->_internal_uninterpreted_option_size(); - for (const auto& msg : this->uninterpreted_option_) { + for (const auto& msg : this->_impl_.uninterpreted_option_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { // optional bool deprecated = 33 [default = false]; if (cached_has_bits & 0x00000001u) { @@ -9113,45 +9298,41 @@ size_t MethodOptions::ByteSizeLong() const { // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; if (cached_has_bits & 0x00000002u) { total_size += 2 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_idempotency_level()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_idempotency_level()); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData MethodOptions::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, MethodOptions::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*MethodOptions::GetClassData() const { return &_class_data_; } -void MethodOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<MethodOptions *>(to)->MergeFrom( - static_cast<const MethodOptions &>(from)); -} - -void MethodOptions::MergeFrom(const MethodOptions& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions) - GOOGLE_DCHECK_NE(&from, this); +void MethodOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<MethodOptions*>(&to_msg); + auto& from = static_cast<const MethodOptions&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - deprecated_ = from.deprecated_; + _this->_impl_.deprecated_ = from._impl_.deprecated_; } if (cached_has_bits & 0x00000002u) { - idempotency_level_ = from.idempotency_level_; + _this->_impl_.idempotency_level_ = from._impl_.idempotency_level_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _extensions_.MergeFrom(internal_default_instance(), from._extensions_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void MethodOptions::CopyFrom(const MethodOptions& from) { @@ -9162,31 +9343,31 @@ void MethodOptions::CopyFrom(const MethodOptions& from) { } bool MethodOptions::IsInitialized() const { - if (!_extensions_.IsInitialized()) { + if (!_impl_._extensions_.IsInitialized()) { return false; } - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(uninterpreted_option_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.uninterpreted_option_)) return false; return true; } void MethodOptions::InternalSwap(MethodOptions* other) { using std::swap; - _extensions_.InternalSwap(&other->_extensions_); + _impl_._extensions_.InternalSwap(&other->_impl_._extensions_); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(MethodOptions, idempotency_level_) - + sizeof(MethodOptions::idempotency_level_) - - PROTOBUF_FIELD_OFFSET(MethodOptions, deprecated_)>( - reinterpret_cast<char*>(&deprecated_), - reinterpret_cast<char*>(&other->deprecated_)); + PROTOBUF_FIELD_OFFSET(MethodOptions, _impl_.idempotency_level_) + + sizeof(MethodOptions::_impl_.idempotency_level_) + - PROTOBUF_FIELD_OFFSET(MethodOptions, _impl_.deprecated_)>( + reinterpret_cast<char*>(&_impl_.deprecated_), + reinterpret_cast<char*>(&other->_impl_.deprecated_)); } ::PROTOBUF_NAMESPACE_ID::Metadata MethodOptions::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[20]); } @@ -9195,7 +9376,7 @@ void MethodOptions::InternalSwap(MethodOptions* other) { class UninterpretedOption_NamePart::_Internal { public: - using HasBits = decltype(std::declval<UninterpretedOption_NamePart>()._has_bits_); + using HasBits = decltype(std::declval<UninterpretedOption_NamePart>()._impl_._has_bits_); static void set_has_name_part(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -9210,56 +9391,63 @@ class UninterpretedOption_NamePart::_Internal { UninterpretedOption_NamePart::UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.UninterpretedOption.NamePart) } UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + UninterpretedOption_NamePart* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_part_){} + , decltype(_impl_.is_extension_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_part_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_part_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_part_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_name_part()) { - name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name_part(), - GetArenaForAllocation()); + _this->_impl_.name_part_.Set(from._internal_name_part(), + _this->GetArenaForAllocation()); } - is_extension_ = from.is_extension_; + _this->_impl_.is_extension_ = from._impl_.is_extension_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart) } -inline void UninterpretedOption_NamePart::SharedCtor() { -name_part_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -is_extension_ = false; +inline void UninterpretedOption_NamePart::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_part_){} + , decltype(_impl_.is_extension_){false} + }; + _impl_.name_part_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_part_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } UninterpretedOption_NamePart::~UninterpretedOption_NamePart() { // @@protoc_insertion_point(destructor:google.protobuf.UninterpretedOption.NamePart) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void UninterpretedOption_NamePart::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_part_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_part_.Destroy(); } -void UninterpretedOption_NamePart::ArenaDtor(void* object) { - UninterpretedOption_NamePart* _this = reinterpret_cast< UninterpretedOption_NamePart* >(object); - (void)_this; -} -void UninterpretedOption_NamePart::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void UninterpretedOption_NamePart::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void UninterpretedOption_NamePart::Clear() { @@ -9268,31 +9456,31 @@ void UninterpretedOption_NamePart::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000001u) { - name_part_.ClearNonDefaultToEmpty(); + _impl_.name_part_.ClearNonDefaultToEmpty(); } - is_extension_ = false; - _has_bits_.Clear(); + _impl_.is_extension_ = false; + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // required string name_part = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name_part(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.UninterpretedOption.NamePart.name_part"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.UninterpretedOption.NamePart.name_part"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -9300,7 +9488,7 @@ const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::PROT case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { _Internal::set_has_is_extension(&has_bits); - is_extension_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.is_extension_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -9321,7 +9509,7 @@ const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::PROT CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -9335,7 +9523,7 @@ uint8_t* UninterpretedOption_NamePart::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // required string name_part = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -9349,11 +9537,11 @@ uint8_t* UninterpretedOption_NamePart::_InternalSerialize( // required bool is_extension = 2; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(2, this->_internal_is_extension(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_is_extension(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UninterpretedOption.NamePart) @@ -9382,7 +9570,7 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption.NamePart) size_t total_size = 0; - if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + if (((_impl_._has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. // required string name_part = 1; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( @@ -9398,39 +9586,35 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData UninterpretedOption_NamePart::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, UninterpretedOption_NamePart::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*UninterpretedOption_NamePart::GetClassData() const { return &_class_data_; } -void UninterpretedOption_NamePart::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<UninterpretedOption_NamePart *>(to)->MergeFrom( - static_cast<const UninterpretedOption_NamePart &>(from)); -} - -void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart) - GOOGLE_DCHECK_NE(&from, this); +void UninterpretedOption_NamePart::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<UninterpretedOption_NamePart*>(&to_msg); + auto& from = static_cast<const UninterpretedOption_NamePart&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _internal_set_name_part(from._internal_name_part()); + _this->_internal_set_name_part(from._internal_name_part()); } if (cached_has_bits & 0x00000002u) { - is_extension_ = from.is_extension_; + _this->_impl_.is_extension_ = from._impl_.is_extension_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void UninterpretedOption_NamePart::CopyFrom(const UninterpretedOption_NamePart& from) { @@ -9441,7 +9625,7 @@ void UninterpretedOption_NamePart::CopyFrom(const UninterpretedOption_NamePart& } bool UninterpretedOption_NamePart::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; return true; } @@ -9450,17 +9634,16 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_part_, lhs_arena, - &other->name_part_, rhs_arena + &_impl_.name_part_, lhs_arena, + &other->_impl_.name_part_, rhs_arena ); - swap(is_extension_, other->is_extension_); + swap(_impl_.is_extension_, other->_impl_.is_extension_); } ::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption_NamePart::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[21]); } @@ -9469,7 +9652,7 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot class UninterpretedOption::_Internal { public: - using HasBits = decltype(std::declval<UninterpretedOption>()._has_bits_); + using HasBits = decltype(std::declval<UninterpretedOption>()._impl_._has_bits_); static void set_has_identifier_value(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -9492,90 +9675,103 @@ class UninterpretedOption::_Internal { UninterpretedOption::UninterpretedOption(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - name_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.UninterpretedOption) } UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - name_(from.name_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + UninterpretedOption* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_){from._impl_.name_} + , decltype(_impl_.identifier_value_){} + , decltype(_impl_.string_value_){} + , decltype(_impl_.aggregate_value_){} + , decltype(_impl_.positive_int_value_){} + , decltype(_impl_.negative_int_value_){} + , decltype(_impl_.double_value_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - identifier_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.identifier_value_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.identifier_value_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_identifier_value()) { - identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_identifier_value(), - GetArenaForAllocation()); + _this->_impl_.identifier_value_.Set(from._internal_identifier_value(), + _this->GetArenaForAllocation()); } - string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.string_value_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.string_value_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_string_value()) { - string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_string_value(), - GetArenaForAllocation()); + _this->_impl_.string_value_.Set(from._internal_string_value(), + _this->GetArenaForAllocation()); } - aggregate_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.aggregate_value_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.aggregate_value_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_aggregate_value()) { - aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_aggregate_value(), - GetArenaForAllocation()); + _this->_impl_.aggregate_value_.Set(from._internal_aggregate_value(), + _this->GetArenaForAllocation()); } - ::memcpy(&positive_int_value_, &from.positive_int_value_, - static_cast<size_t>(reinterpret_cast<char*>(&double_value_) - - reinterpret_cast<char*>(&positive_int_value_)) + sizeof(double_value_)); + ::memcpy(&_impl_.positive_int_value_, &from._impl_.positive_int_value_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.double_value_) - + reinterpret_cast<char*>(&_impl_.positive_int_value_)) + sizeof(_impl_.double_value_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption) } -inline void UninterpretedOption::SharedCtor() { -identifier_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -aggregate_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&positive_int_value_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&double_value_) - - reinterpret_cast<char*>(&positive_int_value_)) + sizeof(double_value_)); +inline void UninterpretedOption::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.name_){arena} + , decltype(_impl_.identifier_value_){} + , decltype(_impl_.string_value_){} + , decltype(_impl_.aggregate_value_){} + , decltype(_impl_.positive_int_value_){uint64_t{0u}} + , decltype(_impl_.negative_int_value_){int64_t{0}} + , decltype(_impl_.double_value_){0} + }; + _impl_.identifier_value_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.identifier_value_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.string_value_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.string_value_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.aggregate_value_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.aggregate_value_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } UninterpretedOption::~UninterpretedOption() { // @@protoc_insertion_point(destructor:google.protobuf.UninterpretedOption) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void UninterpretedOption::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - identifier_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - string_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - aggregate_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.~RepeatedPtrField(); + _impl_.identifier_value_.Destroy(); + _impl_.string_value_.Destroy(); + _impl_.aggregate_value_.Destroy(); } -void UninterpretedOption::ArenaDtor(void* object) { - UninterpretedOption* _this = reinterpret_cast< UninterpretedOption* >(object); - (void)_this; -} -void UninterpretedOption::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void UninterpretedOption::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void UninterpretedOption::Clear() { @@ -9584,34 +9780,34 @@ void UninterpretedOption::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - name_.Clear(); - cached_has_bits = _has_bits_[0]; + _impl_.name_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - identifier_value_.ClearNonDefaultToEmpty(); + _impl_.identifier_value_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - string_value_.ClearNonDefaultToEmpty(); + _impl_.string_value_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000004u) { - aggregate_value_.ClearNonDefaultToEmpty(); + _impl_.aggregate_value_.ClearNonDefaultToEmpty(); } } if (cached_has_bits & 0x00000038u) { - ::memset(&positive_int_value_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&double_value_) - - reinterpret_cast<char*>(&positive_int_value_)) + sizeof(double_value_)); + ::memset(&_impl_.positive_int_value_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.double_value_) - + reinterpret_cast<char*>(&_impl_.positive_int_value_)) + sizeof(_impl_.double_value_)); } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* UninterpretedOption::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; case 2: @@ -9630,11 +9826,11 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) { auto str = _internal_mutable_identifier_value(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.UninterpretedOption.identifier_value"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.UninterpretedOption.identifier_value"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -9642,7 +9838,7 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 32)) { _Internal::set_has_positive_int_value(&has_bits); - positive_int_value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.positive_int_value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -9651,7 +9847,7 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME case 5: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) { _Internal::set_has_negative_int_value(&has_bits); - negative_int_value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.negative_int_value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -9660,7 +9856,7 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME case 6: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 49)) { _Internal::set_has_double_value(&has_bits); - double_value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr); + _impl_.double_value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr); ptr += sizeof(double); } else goto handle_unusual; @@ -9669,7 +9865,7 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME case 7: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 58)) { auto str = _internal_mutable_string_value(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; @@ -9678,11 +9874,11 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME case 8: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 66)) { auto str = _internal_mutable_aggregate_value(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.UninterpretedOption.aggregate_value"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.UninterpretedOption.aggregate_value"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -9702,7 +9898,7 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -9717,14 +9913,14 @@ uint8_t* UninterpretedOption::_InternalSerialize( (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_name_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_name_size()); i < n; i++) { + const auto& repfield = this->_internal_name(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, this->_internal_name(i), target, stream); + InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string identifier_value = 3; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -9738,19 +9934,19 @@ uint8_t* UninterpretedOption::_InternalSerialize( // optional uint64 positive_int_value = 4; if (cached_has_bits & 0x00000008u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(4, this->_internal_positive_int_value(), target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(4, this->_internal_positive_int_value(), target); } // optional int64 negative_int_value = 5; if (cached_has_bits & 0x00000010u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(5, this->_internal_negative_int_value(), target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(5, this->_internal_negative_int_value(), target); } // optional double double_value = 6; if (cached_has_bits & 0x00000020u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(6, this->_internal_double_value(), target); + target = ::_pbi::WireFormatLite::WriteDoubleToArray(6, this->_internal_double_value(), target); } // optional bytes string_value = 7; @@ -9770,7 +9966,7 @@ uint8_t* UninterpretedOption::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UninterpretedOption) @@ -9787,12 +9983,12 @@ size_t UninterpretedOption::ByteSizeLong() const { // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; total_size += 1UL * this->_internal_name_size(); - for (const auto& msg : this->name_) { + for (const auto& msg : this->_impl_.name_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x0000003fu) { // optional string identifier_value = 3; if (cached_has_bits & 0x00000001u) { @@ -9817,12 +10013,12 @@ size_t UninterpretedOption::ByteSizeLong() const { // optional uint64 positive_int_value = 4; if (cached_has_bits & 0x00000008u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64SizePlusOne(this->_internal_positive_int_value()); + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_positive_int_value()); } // optional int64 negative_int_value = 5; if (cached_has_bits & 0x00000010u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64SizePlusOne(this->_internal_negative_int_value()); + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_negative_int_value()); } // optional double double_value = 6; @@ -9831,52 +10027,48 @@ size_t UninterpretedOption::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData UninterpretedOption::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, UninterpretedOption::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*UninterpretedOption::GetClassData() const { return &_class_data_; } -void UninterpretedOption::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<UninterpretedOption *>(to)->MergeFrom( - static_cast<const UninterpretedOption &>(from)); -} - -void UninterpretedOption::MergeFrom(const UninterpretedOption& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption) - GOOGLE_DCHECK_NE(&from, this); +void UninterpretedOption::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<UninterpretedOption*>(&to_msg); + auto& from = static_cast<const UninterpretedOption&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - name_.MergeFrom(from.name_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.name_.MergeFrom(from._impl_.name_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x0000003fu) { if (cached_has_bits & 0x00000001u) { - _internal_set_identifier_value(from._internal_identifier_value()); + _this->_internal_set_identifier_value(from._internal_identifier_value()); } if (cached_has_bits & 0x00000002u) { - _internal_set_string_value(from._internal_string_value()); + _this->_internal_set_string_value(from._internal_string_value()); } if (cached_has_bits & 0x00000004u) { - _internal_set_aggregate_value(from._internal_aggregate_value()); + _this->_internal_set_aggregate_value(from._internal_aggregate_value()); } if (cached_has_bits & 0x00000008u) { - positive_int_value_ = from.positive_int_value_; + _this->_impl_.positive_int_value_ = from._impl_.positive_int_value_; } if (cached_has_bits & 0x00000010u) { - negative_int_value_ = from.negative_int_value_; + _this->_impl_.negative_int_value_ = from._impl_.negative_int_value_; } if (cached_has_bits & 0x00000020u) { - double_value_ = from.double_value_; + _this->_impl_.double_value_ = from._impl_.double_value_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void UninterpretedOption::CopyFrom(const UninterpretedOption& from) { @@ -9887,7 +10079,7 @@ void UninterpretedOption::CopyFrom(const UninterpretedOption& from) { } bool UninterpretedOption::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(name_)) + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(_impl_.name_)) return false; return true; } @@ -9897,33 +10089,30 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - name_.InternalSwap(&other->name_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.name_.InternalSwap(&other->_impl_.name_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &identifier_value_, lhs_arena, - &other->identifier_value_, rhs_arena + &_impl_.identifier_value_, lhs_arena, + &other->_impl_.identifier_value_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &string_value_, lhs_arena, - &other->string_value_, rhs_arena + &_impl_.string_value_, lhs_arena, + &other->_impl_.string_value_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &aggregate_value_, lhs_arena, - &other->aggregate_value_, rhs_arena + &_impl_.aggregate_value_, lhs_arena, + &other->_impl_.aggregate_value_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(UninterpretedOption, double_value_) - + sizeof(UninterpretedOption::double_value_) - - PROTOBUF_FIELD_OFFSET(UninterpretedOption, positive_int_value_)>( - reinterpret_cast<char*>(&positive_int_value_), - reinterpret_cast<char*>(&other->positive_int_value_)); + PROTOBUF_FIELD_OFFSET(UninterpretedOption, _impl_.double_value_) + + sizeof(UninterpretedOption::_impl_.double_value_) + - PROTOBUF_FIELD_OFFSET(UninterpretedOption, _impl_.positive_int_value_)>( + reinterpret_cast<char*>(&_impl_.positive_int_value_), + reinterpret_cast<char*>(&other->_impl_.positive_int_value_)); } ::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[22]); } @@ -9932,7 +10121,7 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) { class SourceCodeInfo_Location::_Internal { public: - using HasBits = decltype(std::declval<SourceCodeInfo_Location>()._has_bits_); + using HasBits = decltype(std::declval<SourceCodeInfo_Location>()._impl_._has_bits_); static void set_has_leading_comments(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -9943,74 +10132,89 @@ class SourceCodeInfo_Location::_Internal { SourceCodeInfo_Location::SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - path_(arena), - span_(arena), - leading_detached_comments_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.SourceCodeInfo.Location) } SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - path_(from.path_), - span_(from.span_), - leading_detached_comments_(from.leading_detached_comments_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + SourceCodeInfo_Location* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.path_){from._impl_.path_} + , /*decltype(_impl_._path_cached_byte_size_)*/{0} + , decltype(_impl_.span_){from._impl_.span_} + , /*decltype(_impl_._span_cached_byte_size_)*/{0} + , decltype(_impl_.leading_detached_comments_){from._impl_.leading_detached_comments_} + , decltype(_impl_.leading_comments_){} + , decltype(_impl_.trailing_comments_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - leading_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.leading_comments_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.leading_comments_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_leading_comments()) { - leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_leading_comments(), - GetArenaForAllocation()); + _this->_impl_.leading_comments_.Set(from._internal_leading_comments(), + _this->GetArenaForAllocation()); } - trailing_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.trailing_comments_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.trailing_comments_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_trailing_comments()) { - trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_trailing_comments(), - GetArenaForAllocation()); + _this->_impl_.trailing_comments_.Set(from._internal_trailing_comments(), + _this->GetArenaForAllocation()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location) } -inline void SourceCodeInfo_Location::SharedCtor() { -leading_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -trailing_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +inline void SourceCodeInfo_Location::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.path_){arena} + , /*decltype(_impl_._path_cached_byte_size_)*/{0} + , decltype(_impl_.span_){arena} + , /*decltype(_impl_._span_cached_byte_size_)*/{0} + , decltype(_impl_.leading_detached_comments_){arena} + , decltype(_impl_.leading_comments_){} + , decltype(_impl_.trailing_comments_){} + }; + _impl_.leading_comments_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.leading_comments_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.trailing_comments_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.trailing_comments_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } SourceCodeInfo_Location::~SourceCodeInfo_Location() { // @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo.Location) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void SourceCodeInfo_Location::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - leading_comments_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - trailing_comments_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.path_.~RepeatedField(); + _impl_.span_.~RepeatedField(); + _impl_.leading_detached_comments_.~RepeatedPtrField(); + _impl_.leading_comments_.Destroy(); + _impl_.trailing_comments_.Destroy(); } -void SourceCodeInfo_Location::ArenaDtor(void* object) { - SourceCodeInfo_Location* _this = reinterpret_cast< SourceCodeInfo_Location* >(object); - (void)_this; -} -void SourceCodeInfo_Location::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void SourceCodeInfo_Location::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void SourceCodeInfo_Location::Clear() { @@ -10019,28 +10223,28 @@ void SourceCodeInfo_Location::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - path_.Clear(); - span_.Clear(); - leading_detached_comments_.Clear(); - cached_has_bits = _has_bits_[0]; + _impl_.path_.Clear(); + _impl_.span_.Clear(); + _impl_.leading_detached_comments_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - leading_comments_.ClearNonDefaultToEmpty(); + _impl_.leading_comments_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { - trailing_comments_.ClearNonDefaultToEmpty(); + _impl_.trailing_comments_.ClearNonDefaultToEmpty(); } } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // repeated int32 path = 1 [packed = true]; case 1: @@ -10068,11 +10272,11 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_ case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) { auto str = _internal_mutable_leading_comments(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.leading_comments"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.leading_comments"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -10080,11 +10284,11 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_ case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) { auto str = _internal_mutable_trailing_comments(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.trailing_comments"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.trailing_comments"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -10095,11 +10299,11 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_ do { ptr += 1; auto str = _internal_add_leading_detached_comments(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.leading_detached_comments"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.SourceCodeInfo.Location.leading_detached_comments"); + #endif // !NDEBUG if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); } else @@ -10121,7 +10325,7 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_ CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -10137,7 +10341,7 @@ uint8_t* SourceCodeInfo_Location::_InternalSerialize( // repeated int32 path = 1 [packed = true]; { - int byte_size = _path_cached_byte_size_.load(std::memory_order_relaxed); + int byte_size = _impl_._path_cached_byte_size_.load(std::memory_order_relaxed); if (byte_size > 0) { target = stream->WriteInt32Packed( 1, _internal_path(), byte_size, target); @@ -10146,14 +10350,14 @@ uint8_t* SourceCodeInfo_Location::_InternalSerialize( // repeated int32 span = 2 [packed = true]; { - int byte_size = _span_cached_byte_size_.load(std::memory_order_relaxed); + int byte_size = _impl_._span_cached_byte_size_.load(std::memory_order_relaxed); if (byte_size > 0) { target = stream->WriteInt32Packed( 2, _internal_span(), byte_size, target); } } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string leading_comments = 3; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -10185,7 +10389,7 @@ uint8_t* SourceCodeInfo_Location::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo.Location) @@ -10202,43 +10406,41 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { // repeated int32 path = 1 [packed = true]; { - size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - Int32Size(this->path_); + size_t data_size = ::_pbi::WireFormatLite:: + Int32Size(this->_impl_.path_); if (data_size > 0) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - static_cast<int32_t>(data_size)); + ::_pbi::WireFormatLite::Int32Size(static_cast<int32_t>(data_size)); } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(data_size); - _path_cached_byte_size_.store(cached_size, + int cached_size = ::_pbi::ToCachedSize(data_size); + _impl_._path_cached_byte_size_.store(cached_size, std::memory_order_relaxed); total_size += data_size; } // repeated int32 span = 2 [packed = true]; { - size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - Int32Size(this->span_); + size_t data_size = ::_pbi::WireFormatLite:: + Int32Size(this->_impl_.span_); if (data_size > 0) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - static_cast<int32_t>(data_size)); + ::_pbi::WireFormatLite::Int32Size(static_cast<int32_t>(data_size)); } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(data_size); - _span_cached_byte_size_.store(cached_size, + int cached_size = ::_pbi::ToCachedSize(data_size); + _impl_._span_cached_byte_size_.store(cached_size, std::memory_order_relaxed); total_size += data_size; } // repeated string leading_detached_comments = 6; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(leading_detached_comments_.size()); - for (int i = 0, n = leading_detached_comments_.size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.leading_detached_comments_.size()); + for (int i = 0, n = _impl_.leading_detached_comments_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - leading_detached_comments_.Get(i)); + _impl_.leading_detached_comments_.Get(i)); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { // optional string leading_comments = 3; if (cached_has_bits & 0x00000001u) { @@ -10255,41 +10457,37 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SourceCodeInfo_Location::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, SourceCodeInfo_Location::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SourceCodeInfo_Location::GetClassData() const { return &_class_data_; } -void SourceCodeInfo_Location::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<SourceCodeInfo_Location *>(to)->MergeFrom( - static_cast<const SourceCodeInfo_Location &>(from)); -} - -void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location) - GOOGLE_DCHECK_NE(&from, this); +void SourceCodeInfo_Location::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<SourceCodeInfo_Location*>(&to_msg); + auto& from = static_cast<const SourceCodeInfo_Location&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - path_.MergeFrom(from.path_); - span_.MergeFrom(from.span_); - leading_detached_comments_.MergeFrom(from.leading_detached_comments_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.path_.MergeFrom(from._impl_.path_); + _this->_impl_.span_.MergeFrom(from._impl_.span_); + _this->_impl_.leading_detached_comments_.MergeFrom(from._impl_.leading_detached_comments_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _internal_set_leading_comments(from._internal_leading_comments()); + _this->_internal_set_leading_comments(from._internal_leading_comments()); } if (cached_has_bits & 0x00000002u) { - _internal_set_trailing_comments(from._internal_trailing_comments()); + _this->_internal_set_trailing_comments(from._internal_trailing_comments()); } } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void SourceCodeInfo_Location::CopyFrom(const SourceCodeInfo_Location& from) { @@ -10308,24 +10506,22 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - path_.InternalSwap(&other->path_); - span_.InternalSwap(&other->span_); - leading_detached_comments_.InternalSwap(&other->leading_detached_comments_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.path_.InternalSwap(&other->_impl_.path_); + _impl_.span_.InternalSwap(&other->_impl_.span_); + _impl_.leading_detached_comments_.InternalSwap(&other->_impl_.leading_detached_comments_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &leading_comments_, lhs_arena, - &other->leading_comments_, rhs_arena + &_impl_.leading_comments_, lhs_arena, + &other->_impl_.leading_comments_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &trailing_comments_, lhs_arena, - &other->trailing_comments_, rhs_arena + &_impl_.trailing_comments_, lhs_arena, + &other->_impl_.trailing_comments_, rhs_arena ); } ::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo_Location::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[23]); } @@ -10338,43 +10534,47 @@ class SourceCodeInfo::_Internal { SourceCodeInfo::SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - location_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.SourceCodeInfo) } SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - location_(from.location_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + SourceCodeInfo* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.location_){from._impl_.location_} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo) } -inline void SourceCodeInfo::SharedCtor() { +inline void SourceCodeInfo::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.location_){arena} + , /*decltype(_impl_._cached_size_)*/{} + }; } SourceCodeInfo::~SourceCodeInfo() { // @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void SourceCodeInfo::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.location_.~RepeatedPtrField(); } -void SourceCodeInfo::ArenaDtor(void* object) { - SourceCodeInfo* _this = reinterpret_cast< SourceCodeInfo* >(object); - (void)_this; -} -void SourceCodeInfo::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void SourceCodeInfo::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void SourceCodeInfo::Clear() { @@ -10383,15 +10583,15 @@ void SourceCodeInfo::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - location_.Clear(); + _impl_.location_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* SourceCodeInfo::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* SourceCodeInfo::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // repeated .google.protobuf.SourceCodeInfo.Location location = 1; case 1: @@ -10436,15 +10636,15 @@ uint8_t* SourceCodeInfo::_InternalSerialize( (void) cached_has_bits; // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_location_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_location_size()); i < n; i++) { + const auto& repfield = this->_internal_location(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, this->_internal_location(i), target, stream); + InternalWriteMessage(1, repfield, repfield.GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo) @@ -10461,35 +10661,31 @@ size_t SourceCodeInfo::ByteSizeLong() const { // repeated .google.protobuf.SourceCodeInfo.Location location = 1; total_size += 1UL * this->_internal_location_size(); - for (const auto& msg : this->location_) { + for (const auto& msg : this->_impl_.location_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SourceCodeInfo::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, SourceCodeInfo::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SourceCodeInfo::GetClassData() const { return &_class_data_; } -void SourceCodeInfo::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<SourceCodeInfo *>(to)->MergeFrom( - static_cast<const SourceCodeInfo &>(from)); -} - -void SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo) - GOOGLE_DCHECK_NE(&from, this); +void SourceCodeInfo::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<SourceCodeInfo*>(&to_msg); + auto& from = static_cast<const SourceCodeInfo&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - location_.MergeFrom(from.location_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.location_.MergeFrom(from._impl_.location_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void SourceCodeInfo::CopyFrom(const SourceCodeInfo& from) { @@ -10506,11 +10702,11 @@ bool SourceCodeInfo::IsInitialized() const { void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - location_.InternalSwap(&other->location_); + _impl_.location_.InternalSwap(&other->_impl_.location_); } ::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[24]); } @@ -10519,7 +10715,7 @@ void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) { class GeneratedCodeInfo_Annotation::_Internal { public: - using HasBits = decltype(std::declval<GeneratedCodeInfo_Annotation>()._has_bits_); + using HasBits = decltype(std::declval<GeneratedCodeInfo_Annotation>()._impl_._has_bits_); static void set_has_source_file(HasBits* has_bits) { (*has_bits)[0] |= 1u; } @@ -10533,64 +10729,73 @@ class GeneratedCodeInfo_Annotation::_Internal { GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - path_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.GeneratedCodeInfo.Annotation) } GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - path_(from.path_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + GeneratedCodeInfo_Annotation* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.path_){from._impl_.path_} + , /*decltype(_impl_._path_cached_byte_size_)*/{0} + , decltype(_impl_.source_file_){} + , decltype(_impl_.begin_){} + , decltype(_impl_.end_){}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - source_file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.source_file_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.source_file_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (from._internal_has_source_file()) { - source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_source_file(), - GetArenaForAllocation()); + _this->_impl_.source_file_.Set(from._internal_source_file(), + _this->GetArenaForAllocation()); } - ::memcpy(&begin_, &from.begin_, - static_cast<size_t>(reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&begin_)) + sizeof(end_)); + ::memcpy(&_impl_.begin_, &from._impl_.begin_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.end_) - + reinterpret_cast<char*>(&_impl_.begin_)) + sizeof(_impl_.end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo.Annotation) } -inline void GeneratedCodeInfo_Annotation::SharedCtor() { -source_file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&begin_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&begin_)) + sizeof(end_)); +inline void GeneratedCodeInfo_Annotation::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , decltype(_impl_.path_){arena} + , /*decltype(_impl_._path_cached_byte_size_)*/{0} + , decltype(_impl_.source_file_){} + , decltype(_impl_.begin_){0} + , decltype(_impl_.end_){0} + }; + _impl_.source_file_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.source_file_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } GeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() { // @@protoc_insertion_point(destructor:google.protobuf.GeneratedCodeInfo.Annotation) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void GeneratedCodeInfo_Annotation::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - source_file_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.path_.~RepeatedField(); + _impl_.source_file_.Destroy(); } -void GeneratedCodeInfo_Annotation::ArenaDtor(void* object) { - GeneratedCodeInfo_Annotation* _this = reinterpret_cast< GeneratedCodeInfo_Annotation* >(object); - (void)_this; -} -void GeneratedCodeInfo_Annotation::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void GeneratedCodeInfo_Annotation::Clear() { @@ -10599,26 +10804,26 @@ void GeneratedCodeInfo_Annotation::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - path_.Clear(); - cached_has_bits = _has_bits_[0]; + _impl_.path_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000001u) { - source_file_.ClearNonDefaultToEmpty(); + _impl_.source_file_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000006u) { - ::memset(&begin_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&end_) - - reinterpret_cast<char*>(&begin_)) + sizeof(end_)); + ::memset(&_impl_.begin_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.end_) - + reinterpret_cast<char*>(&_impl_.begin_)) + sizeof(_impl_.end_)); } - _has_bits_.Clear(); + _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // repeated int32 path = 1 [packed = true]; case 1: @@ -10635,11 +10840,11 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROT case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { auto str = _internal_mutable_source_file(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.GeneratedCodeInfo.Annotation.source_file"); - #endif // !NDEBUG + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + #ifndef NDEBUG + ::_pbi::VerifyUTF8(str, "google.protobuf.GeneratedCodeInfo.Annotation.source_file"); + #endif // !NDEBUG } else goto handle_unusual; continue; @@ -10647,7 +10852,7 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROT case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) { _Internal::set_has_begin(&has_bits); - begin_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.begin_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -10656,7 +10861,7 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROT case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 32)) { _Internal::set_has_end(&has_bits); - end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -10677,7 +10882,7 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROT CHK_(ptr != nullptr); } // while message_done: - _has_bits_.Or(has_bits); + _impl_._has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; @@ -10693,14 +10898,14 @@ uint8_t* GeneratedCodeInfo_Annotation::_InternalSerialize( // repeated int32 path = 1 [packed = true]; { - int byte_size = _path_cached_byte_size_.load(std::memory_order_relaxed); + int byte_size = _impl_._path_cached_byte_size_.load(std::memory_order_relaxed); if (byte_size > 0) { target = stream->WriteInt32Packed( 1, _internal_path(), byte_size, target); } } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; // optional string source_file = 2; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( @@ -10714,17 +10919,17 @@ uint8_t* GeneratedCodeInfo_Annotation::_InternalSerialize( // optional int32 begin = 3; if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_begin(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_begin(), target); } // optional int32 end = 4; if (cached_has_bits & 0x00000004u) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_end(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(4, this->_internal_end(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.GeneratedCodeInfo.Annotation) @@ -10741,20 +10946,19 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { // repeated int32 path = 1 [packed = true]; { - size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - Int32Size(this->path_); + size_t data_size = ::_pbi::WireFormatLite:: + Int32Size(this->_impl_.path_); if (data_size > 0) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - static_cast<int32_t>(data_size)); + ::_pbi::WireFormatLite::Int32Size(static_cast<int32_t>(data_size)); } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(data_size); - _path_cached_byte_size_.store(cached_size, + int cached_size = ::_pbi::ToCachedSize(data_size); + _impl_._path_cached_byte_size_.store(cached_size, std::memory_order_relaxed); total_size += data_size; } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000007u) { // optional string source_file = 2; if (cached_has_bits & 0x00000001u) { @@ -10765,52 +10969,48 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { // optional int32 begin = 3; if (cached_has_bits & 0x00000002u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_begin()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_begin()); } // optional int32 end = 4; if (cached_has_bits & 0x00000004u) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_end()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_end()); } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GeneratedCodeInfo_Annotation::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, GeneratedCodeInfo_Annotation::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GeneratedCodeInfo_Annotation::GetClassData() const { return &_class_data_; } -void GeneratedCodeInfo_Annotation::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<GeneratedCodeInfo_Annotation *>(to)->MergeFrom( - static_cast<const GeneratedCodeInfo_Annotation &>(from)); -} - -void GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation) - GOOGLE_DCHECK_NE(&from, this); +void GeneratedCodeInfo_Annotation::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<GeneratedCodeInfo_Annotation*>(&to_msg); + auto& from = static_cast<const GeneratedCodeInfo_Annotation&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - path_.MergeFrom(from.path_); - cached_has_bits = from._has_bits_[0]; + _this->_impl_.path_.MergeFrom(from._impl_.path_); + cached_has_bits = from._impl_._has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - _internal_set_source_file(from._internal_source_file()); + _this->_internal_set_source_file(from._internal_source_file()); } if (cached_has_bits & 0x00000002u) { - begin_ = from.begin_; + _this->_impl_.begin_ = from._impl_.begin_; } if (cached_has_bits & 0x00000004u) { - end_ = from.end_; + _this->_impl_.end_ = from._impl_.end_; } - _has_bits_[0] |= cached_has_bits; + _this->_impl_._has_bits_[0] |= cached_has_bits; } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void GeneratedCodeInfo_Annotation::CopyFrom(const GeneratedCodeInfo_Annotation& from) { @@ -10829,23 +11029,22 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - path_.InternalSwap(&other->path_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.path_.InternalSwap(&other->_impl_.path_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &source_file_, lhs_arena, - &other->source_file_, rhs_arena + &_impl_.source_file_, lhs_arena, + &other->_impl_.source_file_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, end_) - + sizeof(GeneratedCodeInfo_Annotation::end_) - - PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, begin_)>( - reinterpret_cast<char*>(&begin_), - reinterpret_cast<char*>(&other->begin_)); + PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _impl_.end_) + + sizeof(GeneratedCodeInfo_Annotation::_impl_.end_) + - PROTOBUF_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _impl_.begin_)>( + reinterpret_cast<char*>(&_impl_.begin_), + reinterpret_cast<char*>(&other->_impl_.begin_)); } ::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[25]); } @@ -10858,43 +11057,47 @@ class GeneratedCodeInfo::_Internal { GeneratedCodeInfo::GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - annotation_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.GeneratedCodeInfo) } GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - annotation_(from.annotation_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + GeneratedCodeInfo* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.annotation_){from._impl_.annotation_} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo) } -inline void GeneratedCodeInfo::SharedCtor() { +inline void GeneratedCodeInfo::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.annotation_){arena} + , /*decltype(_impl_._cached_size_)*/{} + }; } GeneratedCodeInfo::~GeneratedCodeInfo() { // @@protoc_insertion_point(destructor:google.protobuf.GeneratedCodeInfo) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void GeneratedCodeInfo::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.annotation_.~RepeatedPtrField(); } -void GeneratedCodeInfo::ArenaDtor(void* object) { - GeneratedCodeInfo* _this = reinterpret_cast< GeneratedCodeInfo* >(object); - (void)_this; -} -void GeneratedCodeInfo::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void GeneratedCodeInfo::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void GeneratedCodeInfo::Clear() { @@ -10903,15 +11106,15 @@ void GeneratedCodeInfo::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - annotation_.Clear(); + _impl_.annotation_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* GeneratedCodeInfo::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* GeneratedCodeInfo::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; case 1: @@ -10956,15 +11159,15 @@ uint8_t* GeneratedCodeInfo::_InternalSerialize( (void) cached_has_bits; // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_annotation_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_annotation_size()); i < n; i++) { + const auto& repfield = this->_internal_annotation(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, this->_internal_annotation(i), target, stream); + InternalWriteMessage(1, repfield, repfield.GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.GeneratedCodeInfo) @@ -10981,35 +11184,31 @@ size_t GeneratedCodeInfo::ByteSizeLong() const { // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; total_size += 1UL * this->_internal_annotation_size(); - for (const auto& msg : this->annotation_) { + for (const auto& msg : this->_impl_.annotation_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData GeneratedCodeInfo::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, GeneratedCodeInfo::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GeneratedCodeInfo::GetClassData() const { return &_class_data_; } -void GeneratedCodeInfo::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<GeneratedCodeInfo *>(to)->MergeFrom( - static_cast<const GeneratedCodeInfo &>(from)); -} - -void GeneratedCodeInfo::MergeFrom(const GeneratedCodeInfo& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo) - GOOGLE_DCHECK_NE(&from, this); +void GeneratedCodeInfo::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<GeneratedCodeInfo*>(&to_msg); + auto& from = static_cast<const GeneratedCodeInfo&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - annotation_.MergeFrom(from.annotation_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.annotation_.MergeFrom(from._impl_.annotation_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void GeneratedCodeInfo::CopyFrom(const GeneratedCodeInfo& from) { @@ -11026,11 +11225,11 @@ bool GeneratedCodeInfo::IsInitialized() const { void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - annotation_.InternalSwap(&other->annotation_); + _impl_.annotation_.InternalSwap(&other->_impl_.annotation_); } ::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[26]); } @@ -11038,85 +11237,112 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) { // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DescriptorProto* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileOptions >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FileOptions* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FileOptions >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FileOptions >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::MessageOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::MessageOptions >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::MessageOptions* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::MessageOptions >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::MessageOptions >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FieldOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldOptions >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FieldOptions* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldOptions >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FieldOptions >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::OneofOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::OneofOptions >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::OneofOptions* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::OneofOptions >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::OneofOptions >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumOptions >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumOptions* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumOptions >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::EnumOptions >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumValueOptions >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumValueOptions >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::EnumValueOptions >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ServiceOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ServiceOptions >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ServiceOptions* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ServiceOptions >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::ServiceOptions >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::MethodOptions* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::MethodOptions >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::MethodOptions* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::MethodOptions >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::MethodOptions >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/thirdparty/protobuf/descriptor.pb.h b/r5dev/thirdparty/protobuf/descriptor.pb.h index 064b8a4b..62c9d679 100644 --- a/r5dev/thirdparty/protobuf/descriptor.pb.h +++ b/r5dev/thirdparty/protobuf/descriptor.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/generated_message_reflection.h> @@ -43,14 +42,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fdescriptor_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[27] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto; @@ -334,7 +325,7 @@ class PROTOBUF_EXPORT FileDescriptorSet final : public: inline FileDescriptorSet() : FileDescriptorSet(nullptr) {} ~FileDescriptorSet() override; - explicit constexpr FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FileDescriptorSet(const FileDescriptorSet& from); FileDescriptorSet(FileDescriptorSet&& from) noexcept @@ -416,9 +407,11 @@ class PROTOBUF_EXPORT FileDescriptorSet final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const FileDescriptorSet& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const FileDescriptorSet& from); + void MergeFrom( const FileDescriptorSet& from) { + FileDescriptorSet::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -427,10 +420,10 @@ class PROTOBUF_EXPORT FileDescriptorSet final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(FileDescriptorSet* other); @@ -443,9 +436,6 @@ class PROTOBUF_EXPORT FileDescriptorSet final : protected: explicit FileDescriptorSet(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -485,8 +475,11 @@ class PROTOBUF_EXPORT FileDescriptorSet final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto > file_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto > file_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -496,7 +489,7 @@ class PROTOBUF_EXPORT FileDescriptorProto final : public: inline FileDescriptorProto() : FileDescriptorProto(nullptr) {} ~FileDescriptorProto() override; - explicit constexpr FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FileDescriptorProto(const FileDescriptorProto& from); FileDescriptorProto(FileDescriptorProto&& from) noexcept @@ -578,9 +571,11 @@ class PROTOBUF_EXPORT FileDescriptorProto final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const FileDescriptorProto& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const FileDescriptorProto& from); + void MergeFrom( const FileDescriptorProto& from) { + FileDescriptorProto::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -589,10 +584,10 @@ class PROTOBUF_EXPORT FileDescriptorProto final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(FileDescriptorProto* other); @@ -605,9 +600,6 @@ class PROTOBUF_EXPORT FileDescriptorProto final : protected: explicit FileDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -870,20 +862,23 @@ class PROTOBUF_EXPORT FileDescriptorProto final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> dependency_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto > message_type_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto > enum_type_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto > service_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto > extension_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t > public_dependency_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t > weak_dependency_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr package_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr syntax_; - ::PROTOBUF_NAMESPACE_ID::FileOptions* options_; - ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* source_code_info_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> dependency_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto > message_type_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto > enum_type_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto > service_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto > extension_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t > public_dependency_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t > weak_dependency_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr package_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr syntax_; + ::PROTOBUF_NAMESPACE_ID::FileOptions* options_; + ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* source_code_info_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -893,7 +888,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : public: inline DescriptorProto_ExtensionRange() : DescriptorProto_ExtensionRange(nullptr) {} ~DescriptorProto_ExtensionRange() override; - explicit constexpr DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from); DescriptorProto_ExtensionRange(DescriptorProto_ExtensionRange&& from) noexcept @@ -975,9 +970,11 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const DescriptorProto_ExtensionRange& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const DescriptorProto_ExtensionRange& from); + void MergeFrom( const DescriptorProto_ExtensionRange& from) { + DescriptorProto_ExtensionRange::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -986,10 +983,10 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(DescriptorProto_ExtensionRange* other); @@ -1002,9 +999,6 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : protected: explicit DescriptorProto_ExtensionRange(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -1072,11 +1066,14 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* options_; - int32_t start_; - int32_t end_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* options_; + int32_t start_; + int32_t end_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -1086,7 +1083,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : public: inline DescriptorProto_ReservedRange() : DescriptorProto_ReservedRange(nullptr) {} ~DescriptorProto_ReservedRange() override; - explicit constexpr DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from); DescriptorProto_ReservedRange(DescriptorProto_ReservedRange&& from) noexcept @@ -1168,9 +1165,11 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const DescriptorProto_ReservedRange& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const DescriptorProto_ReservedRange& from); + void MergeFrom( const DescriptorProto_ReservedRange& from) { + DescriptorProto_ReservedRange::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1179,10 +1178,10 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(DescriptorProto_ReservedRange* other); @@ -1195,9 +1194,6 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : protected: explicit DescriptorProto_ReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -1246,10 +1242,13 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - int32_t start_; - int32_t end_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + int32_t start_; + int32_t end_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -1259,7 +1258,7 @@ class PROTOBUF_EXPORT DescriptorProto final : public: inline DescriptorProto() : DescriptorProto(nullptr) {} ~DescriptorProto() override; - explicit constexpr DescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR DescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); DescriptorProto(const DescriptorProto& from); DescriptorProto(DescriptorProto&& from) noexcept @@ -1341,9 +1340,11 @@ class PROTOBUF_EXPORT DescriptorProto final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const DescriptorProto& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const DescriptorProto& from); + void MergeFrom( const DescriptorProto& from) { + DescriptorProto::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1352,10 +1353,10 @@ class PROTOBUF_EXPORT DescriptorProto final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(DescriptorProto* other); @@ -1368,9 +1369,6 @@ class PROTOBUF_EXPORT DescriptorProto final : protected: explicit DescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -1590,18 +1588,21 @@ class PROTOBUF_EXPORT DescriptorProto final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto > field_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto > nested_type_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto > enum_type_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange > extension_range_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto > extension_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto > oneof_decl_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange > reserved_range_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> reserved_name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::MessageOptions* options_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto > field_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto > nested_type_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto > enum_type_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange > extension_range_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto > extension_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto > oneof_decl_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange > reserved_range_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> reserved_name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::MessageOptions* options_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -1611,7 +1612,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : public: inline ExtensionRangeOptions() : ExtensionRangeOptions(nullptr) {} ~ExtensionRangeOptions() override; - explicit constexpr ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ExtensionRangeOptions(const ExtensionRangeOptions& from); ExtensionRangeOptions(ExtensionRangeOptions&& from) noexcept @@ -1693,9 +1694,11 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const ExtensionRangeOptions& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const ExtensionRangeOptions& from); + void MergeFrom( const ExtensionRangeOptions& from) { + ExtensionRangeOptions::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1704,10 +1707,10 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(ExtensionRangeOptions* other); @@ -1720,9 +1723,6 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : protected: explicit ExtensionRangeOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -1763,7 +1763,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.Has(id.number()); + return _impl_._extensions_.Has(id.number()); } template <typename _proto_TypeTraits, @@ -1772,7 +1772,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : inline void ClearExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { - _extensions_.ClearExtension(id.number()); + _impl_._extensions_.ClearExtension(id.number()); } @@ -1783,7 +1783,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.ExtensionSize(id.number()); + return _impl_._extensions_.ExtensionSize(id.number()); } template <typename _proto_TypeTraits, @@ -1793,7 +1793,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value()); } @@ -1805,7 +1805,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Mutable(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -1815,7 +1815,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::ConstType value) { - _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_); } @@ -1827,7 +1827,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::SetAllocated(id.number(), _field_type, value, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -1838,7 +1838,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type, - value, &_extensions_); + value, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -1851,7 +1851,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Release(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, @@ -1862,7 +1862,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -1873,7 +1873,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, index); + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index); } template <typename _proto_TypeTraits, @@ -1884,7 +1884,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) { - return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); + return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -1894,7 +1894,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index, typename _proto_TypeTraits::Repeated::ConstType value) { - _proto_TypeTraits::Set(id.number(), index, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_); } @@ -1905,7 +1905,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { typename _proto_TypeTraits::Repeated::MutableType to_add = - _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); + _proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_); return to_add; } @@ -1918,7 +1918,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Repeated::ConstType value) { _proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value, - &_extensions_); + &_impl_._extensions_); } @@ -1930,7 +1930,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::GetRepeated(id.number(), _extensions_); + return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_); } template <typename _proto_TypeTraits, @@ -1942,20 +1942,23 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : ExtensionRangeOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::MutableRepeated(id.number(), _field_type, - _is_packed, &_extensions_); + _is_packed, &_impl_._extensions_); } // @@protoc_insertion_point(class_scope:google.protobuf.ExtensionRangeOptions) private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; + + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -1965,7 +1968,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : public: inline FieldDescriptorProto() : FieldDescriptorProto(nullptr) {} ~FieldDescriptorProto() override; - explicit constexpr FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FieldDescriptorProto(const FieldDescriptorProto& from); FieldDescriptorProto(FieldDescriptorProto&& from) noexcept @@ -2047,9 +2050,11 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const FieldDescriptorProto& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const FieldDescriptorProto& from); + void MergeFrom( const FieldDescriptorProto& from) { + FieldDescriptorProto::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2058,10 +2063,10 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(FieldDescriptorProto* other); @@ -2074,9 +2079,6 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : protected: explicit FieldDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -2375,19 +2377,22 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr extendee_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr default_value_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr json_name_; - ::PROTOBUF_NAMESPACE_ID::FieldOptions* options_; - int32_t number_; - int32_t oneof_index_; - bool proto3_optional_; - int label_; - int type_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr extendee_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr default_value_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr json_name_; + ::PROTOBUF_NAMESPACE_ID::FieldOptions* options_; + int32_t number_; + int32_t oneof_index_; + bool proto3_optional_; + int label_; + int type_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -2397,7 +2402,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : public: inline OneofDescriptorProto() : OneofDescriptorProto(nullptr) {} ~OneofDescriptorProto() override; - explicit constexpr OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); OneofDescriptorProto(const OneofDescriptorProto& from); OneofDescriptorProto(OneofDescriptorProto&& from) noexcept @@ -2479,9 +2484,11 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const OneofDescriptorProto& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const OneofDescriptorProto& from); + void MergeFrom( const OneofDescriptorProto& from) { + OneofDescriptorProto::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2490,10 +2497,10 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(OneofDescriptorProto* other); @@ -2506,9 +2513,6 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : protected: explicit OneofDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -2567,10 +2571,13 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::OneofOptions* options_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::OneofOptions* options_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -2580,7 +2587,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : public: inline EnumDescriptorProto_EnumReservedRange() : EnumDescriptorProto_EnumReservedRange(nullptr) {} ~EnumDescriptorProto_EnumReservedRange() override; - explicit constexpr EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumDescriptorProto_EnumReservedRange(const EnumDescriptorProto_EnumReservedRange& from); EnumDescriptorProto_EnumReservedRange(EnumDescriptorProto_EnumReservedRange&& from) noexcept @@ -2662,9 +2669,11 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const EnumDescriptorProto_EnumReservedRange& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const EnumDescriptorProto_EnumReservedRange& from); + void MergeFrom( const EnumDescriptorProto_EnumReservedRange& from) { + EnumDescriptorProto_EnumReservedRange::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2673,10 +2682,10 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(EnumDescriptorProto_EnumReservedRange* other); @@ -2689,9 +2698,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : protected: explicit EnumDescriptorProto_EnumReservedRange(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -2740,10 +2746,13 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - int32_t start_; - int32_t end_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + int32_t start_; + int32_t end_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -2753,7 +2762,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : public: inline EnumDescriptorProto() : EnumDescriptorProto(nullptr) {} ~EnumDescriptorProto() override; - explicit constexpr EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumDescriptorProto(const EnumDescriptorProto& from); EnumDescriptorProto(EnumDescriptorProto&& from) noexcept @@ -2835,9 +2844,11 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const EnumDescriptorProto& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const EnumDescriptorProto& from); + void MergeFrom( const EnumDescriptorProto& from) { + EnumDescriptorProto::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -2846,10 +2857,10 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(EnumDescriptorProto* other); @@ -2862,9 +2873,6 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : protected: explicit EnumDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -2988,13 +2996,16 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto > value_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange > reserved_range_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> reserved_name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::EnumOptions* options_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto > value_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange > reserved_range_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> reserved_name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::EnumOptions* options_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -3004,7 +3015,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : public: inline EnumValueDescriptorProto() : EnumValueDescriptorProto(nullptr) {} ~EnumValueDescriptorProto() override; - explicit constexpr EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumValueDescriptorProto(const EnumValueDescriptorProto& from); EnumValueDescriptorProto(EnumValueDescriptorProto&& from) noexcept @@ -3086,9 +3097,11 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const EnumValueDescriptorProto& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const EnumValueDescriptorProto& from); + void MergeFrom( const EnumValueDescriptorProto& from) { + EnumValueDescriptorProto::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3097,10 +3110,10 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(EnumValueDescriptorProto* other); @@ -3113,9 +3126,6 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : protected: explicit EnumValueDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -3188,11 +3198,14 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* options_; - int32_t number_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* options_; + int32_t number_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -3202,7 +3215,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : public: inline ServiceDescriptorProto() : ServiceDescriptorProto(nullptr) {} ~ServiceDescriptorProto() override; - explicit constexpr ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ServiceDescriptorProto(const ServiceDescriptorProto& from); ServiceDescriptorProto(ServiceDescriptorProto&& from) noexcept @@ -3284,9 +3297,11 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const ServiceDescriptorProto& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const ServiceDescriptorProto& from); + void MergeFrom( const ServiceDescriptorProto& from) { + ServiceDescriptorProto::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3295,10 +3310,10 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(ServiceDescriptorProto* other); @@ -3311,9 +3326,6 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : protected: explicit ServiceDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -3391,11 +3403,14 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto > method_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::ServiceOptions* options_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto > method_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::ServiceOptions* options_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -3405,7 +3420,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : public: inline MethodDescriptorProto() : MethodDescriptorProto(nullptr) {} ~MethodDescriptorProto() override; - explicit constexpr MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); MethodDescriptorProto(const MethodDescriptorProto& from); MethodDescriptorProto(MethodDescriptorProto&& from) noexcept @@ -3487,9 +3502,11 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const MethodDescriptorProto& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const MethodDescriptorProto& from); + void MergeFrom( const MethodDescriptorProto& from) { + MethodDescriptorProto::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3498,10 +3515,10 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(MethodDescriptorProto* other); @@ -3514,9 +3531,6 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : protected: explicit MethodDescriptorProto(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -3641,14 +3655,17 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr input_type_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr output_type_; - ::PROTOBUF_NAMESPACE_ID::MethodOptions* options_; - bool client_streaming_; - bool server_streaming_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr input_type_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr output_type_; + ::PROTOBUF_NAMESPACE_ID::MethodOptions* options_; + bool client_streaming_; + bool server_streaming_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -3658,7 +3675,7 @@ class PROTOBUF_EXPORT FileOptions final : public: inline FileOptions() : FileOptions(nullptr) {} ~FileOptions() override; - explicit constexpr FileOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR FileOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FileOptions(const FileOptions& from); FileOptions(FileOptions&& from) noexcept @@ -3740,9 +3757,11 @@ class PROTOBUF_EXPORT FileOptions final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const FileOptions& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const FileOptions& from); + void MergeFrom( const FileOptions& from) { + FileOptions::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -3751,10 +3770,10 @@ class PROTOBUF_EXPORT FileOptions final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(FileOptions* other); @@ -3767,9 +3786,6 @@ class PROTOBUF_EXPORT FileOptions final : protected: explicit FileOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -4172,7 +4188,7 @@ class PROTOBUF_EXPORT FileOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.Has(id.number()); + return _impl_._extensions_.Has(id.number()); } template <typename _proto_TypeTraits, @@ -4181,7 +4197,7 @@ class PROTOBUF_EXPORT FileOptions final : inline void ClearExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { - _extensions_.ClearExtension(id.number()); + _impl_._extensions_.ClearExtension(id.number()); } @@ -4192,7 +4208,7 @@ class PROTOBUF_EXPORT FileOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.ExtensionSize(id.number()); + return _impl_._extensions_.ExtensionSize(id.number()); } template <typename _proto_TypeTraits, @@ -4202,7 +4218,7 @@ class PROTOBUF_EXPORT FileOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value()); } @@ -4214,7 +4230,7 @@ class PROTOBUF_EXPORT FileOptions final : FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Mutable(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -4224,7 +4240,7 @@ class PROTOBUF_EXPORT FileOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::ConstType value) { - _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_); } @@ -4236,7 +4252,7 @@ class PROTOBUF_EXPORT FileOptions final : FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::SetAllocated(id.number(), _field_type, value, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -4247,7 +4263,7 @@ class PROTOBUF_EXPORT FileOptions final : FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type, - value, &_extensions_); + value, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -4260,7 +4276,7 @@ class PROTOBUF_EXPORT FileOptions final : FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Release(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, @@ -4271,7 +4287,7 @@ class PROTOBUF_EXPORT FileOptions final : FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -4282,7 +4298,7 @@ class PROTOBUF_EXPORT FileOptions final : FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, index); + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index); } template <typename _proto_TypeTraits, @@ -4293,7 +4309,7 @@ class PROTOBUF_EXPORT FileOptions final : FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) { - return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); + return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -4303,7 +4319,7 @@ class PROTOBUF_EXPORT FileOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index, typename _proto_TypeTraits::Repeated::ConstType value) { - _proto_TypeTraits::Set(id.number(), index, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_); } @@ -4314,7 +4330,7 @@ class PROTOBUF_EXPORT FileOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { typename _proto_TypeTraits::Repeated::MutableType to_add = - _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); + _proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_); return to_add; } @@ -4327,7 +4343,7 @@ class PROTOBUF_EXPORT FileOptions final : FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Repeated::ConstType value) { _proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value, - &_extensions_); + &_impl_._extensions_); } @@ -4339,7 +4355,7 @@ class PROTOBUF_EXPORT FileOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::GetRepeated(id.number(), _extensions_); + return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_); } template <typename _proto_TypeTraits, @@ -4351,41 +4367,44 @@ class PROTOBUF_EXPORT FileOptions final : FileOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::MutableRepeated(id.number(), _field_type, - _is_packed, &_extensions_); + _is_packed, &_impl_._extensions_); } // @@protoc_insertion_point(class_scope:google.protobuf.FileOptions) private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr java_package_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr java_outer_classname_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr go_package_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr objc_class_prefix_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr csharp_namespace_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr swift_prefix_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr php_class_prefix_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr php_namespace_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr php_metadata_namespace_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr ruby_package_; - bool java_multiple_files_; - bool java_generate_equals_and_hash_; - bool java_string_check_utf8_; - bool cc_generic_services_; - bool java_generic_services_; - bool py_generic_services_; - bool php_generic_services_; - bool deprecated_; - int optimize_for_; - bool cc_enable_arenas_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; + + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr java_package_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr java_outer_classname_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr go_package_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr objc_class_prefix_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr csharp_namespace_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr swift_prefix_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr php_class_prefix_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr php_namespace_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr php_metadata_namespace_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr ruby_package_; + bool java_multiple_files_; + bool java_generate_equals_and_hash_; + bool java_string_check_utf8_; + bool cc_generic_services_; + bool java_generic_services_; + bool py_generic_services_; + bool php_generic_services_; + bool deprecated_; + int optimize_for_; + bool cc_enable_arenas_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -4395,7 +4414,7 @@ class PROTOBUF_EXPORT MessageOptions final : public: inline MessageOptions() : MessageOptions(nullptr) {} ~MessageOptions() override; - explicit constexpr MessageOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR MessageOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); MessageOptions(const MessageOptions& from); MessageOptions(MessageOptions&& from) noexcept @@ -4477,9 +4496,11 @@ class PROTOBUF_EXPORT MessageOptions final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const MessageOptions& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const MessageOptions& from); + void MergeFrom( const MessageOptions& from) { + MessageOptions::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -4488,10 +4509,10 @@ class PROTOBUF_EXPORT MessageOptions final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(MessageOptions* other); @@ -4504,9 +4525,6 @@ class PROTOBUF_EXPORT MessageOptions final : protected: explicit MessageOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -4603,7 +4621,7 @@ class PROTOBUF_EXPORT MessageOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.Has(id.number()); + return _impl_._extensions_.Has(id.number()); } template <typename _proto_TypeTraits, @@ -4612,7 +4630,7 @@ class PROTOBUF_EXPORT MessageOptions final : inline void ClearExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { - _extensions_.ClearExtension(id.number()); + _impl_._extensions_.ClearExtension(id.number()); } @@ -4623,7 +4641,7 @@ class PROTOBUF_EXPORT MessageOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.ExtensionSize(id.number()); + return _impl_._extensions_.ExtensionSize(id.number()); } template <typename _proto_TypeTraits, @@ -4633,7 +4651,7 @@ class PROTOBUF_EXPORT MessageOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value()); } @@ -4645,7 +4663,7 @@ class PROTOBUF_EXPORT MessageOptions final : MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Mutable(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -4655,7 +4673,7 @@ class PROTOBUF_EXPORT MessageOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::ConstType value) { - _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_); } @@ -4667,7 +4685,7 @@ class PROTOBUF_EXPORT MessageOptions final : MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::SetAllocated(id.number(), _field_type, value, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -4678,7 +4696,7 @@ class PROTOBUF_EXPORT MessageOptions final : MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type, - value, &_extensions_); + value, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -4691,7 +4709,7 @@ class PROTOBUF_EXPORT MessageOptions final : MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Release(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, @@ -4702,7 +4720,7 @@ class PROTOBUF_EXPORT MessageOptions final : MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -4713,7 +4731,7 @@ class PROTOBUF_EXPORT MessageOptions final : MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, index); + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index); } template <typename _proto_TypeTraits, @@ -4724,7 +4742,7 @@ class PROTOBUF_EXPORT MessageOptions final : MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) { - return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); + return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -4734,7 +4752,7 @@ class PROTOBUF_EXPORT MessageOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index, typename _proto_TypeTraits::Repeated::ConstType value) { - _proto_TypeTraits::Set(id.number(), index, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_); } @@ -4745,7 +4763,7 @@ class PROTOBUF_EXPORT MessageOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { typename _proto_TypeTraits::Repeated::MutableType to_add = - _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); + _proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_); return to_add; } @@ -4758,7 +4776,7 @@ class PROTOBUF_EXPORT MessageOptions final : MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Repeated::ConstType value) { _proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value, - &_extensions_); + &_impl_._extensions_); } @@ -4770,7 +4788,7 @@ class PROTOBUF_EXPORT MessageOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::GetRepeated(id.number(), _extensions_); + return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_); } template <typename _proto_TypeTraits, @@ -4782,25 +4800,28 @@ class PROTOBUF_EXPORT MessageOptions final : MessageOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::MutableRepeated(id.number(), _field_type, - _is_packed, &_extensions_); + _is_packed, &_impl_._extensions_); } // @@protoc_insertion_point(class_scope:google.protobuf.MessageOptions) private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; - bool message_set_wire_format_; - bool no_standard_descriptor_accessor_; - bool deprecated_; - bool map_entry_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; + + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; + bool message_set_wire_format_; + bool no_standard_descriptor_accessor_; + bool deprecated_; + bool map_entry_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -4810,7 +4831,7 @@ class PROTOBUF_EXPORT FieldOptions final : public: inline FieldOptions() : FieldOptions(nullptr) {} ~FieldOptions() override; - explicit constexpr FieldOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR FieldOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FieldOptions(const FieldOptions& from); FieldOptions(FieldOptions&& from) noexcept @@ -4892,9 +4913,11 @@ class PROTOBUF_EXPORT FieldOptions final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const FieldOptions& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const FieldOptions& from); + void MergeFrom( const FieldOptions& from) { + FieldOptions::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -4903,10 +4926,10 @@ class PROTOBUF_EXPORT FieldOptions final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(FieldOptions* other); @@ -4919,9 +4942,6 @@ class PROTOBUF_EXPORT FieldOptions final : protected: explicit FieldOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -5000,11 +5020,12 @@ class PROTOBUF_EXPORT FieldOptions final : enum : int { kUninterpretedOptionFieldNumber = 999, kCtypeFieldNumber = 1, + kJstypeFieldNumber = 6, kPackedFieldNumber = 2, kLazyFieldNumber = 5, + kUnverifiedLazyFieldNumber = 15, kDeprecatedFieldNumber = 3, kWeakFieldNumber = 10, - kJstypeFieldNumber = 6, }; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; @@ -5037,6 +5058,19 @@ class PROTOBUF_EXPORT FieldOptions final : void _internal_set_ctype(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType value); public: + // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; + bool has_jstype() const; + private: + bool _internal_has_jstype() const; + public: + void clear_jstype(); + ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType jstype() const; + void set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value); + private: + ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType _internal_jstype() const; + void _internal_set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value); + public: + // optional bool packed = 2; bool has_packed() const; private: @@ -5063,6 +5097,19 @@ class PROTOBUF_EXPORT FieldOptions final : void _internal_set_lazy(bool value); public: + // optional bool unverified_lazy = 15 [default = false]; + bool has_unverified_lazy() const; + private: + bool _internal_has_unverified_lazy() const; + public: + void clear_unverified_lazy(); + bool unverified_lazy() const; + void set_unverified_lazy(bool value); + private: + bool _internal_unverified_lazy() const; + void _internal_set_unverified_lazy(bool value); + public: + // optional bool deprecated = 3 [default = false]; bool has_deprecated() const; private: @@ -5089,19 +5136,6 @@ class PROTOBUF_EXPORT FieldOptions final : void _internal_set_weak(bool value); public: - // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; - bool has_jstype() const; - private: - bool _internal_has_jstype() const; - public: - void clear_jstype(); - ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType jstype() const; - void set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value); - private: - ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType _internal_jstype() const; - void _internal_set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value); - public: - template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, @@ -5110,7 +5144,7 @@ class PROTOBUF_EXPORT FieldOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.Has(id.number()); + return _impl_._extensions_.Has(id.number()); } template <typename _proto_TypeTraits, @@ -5119,7 +5153,7 @@ class PROTOBUF_EXPORT FieldOptions final : inline void ClearExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { - _extensions_.ClearExtension(id.number()); + _impl_._extensions_.ClearExtension(id.number()); } @@ -5130,7 +5164,7 @@ class PROTOBUF_EXPORT FieldOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.ExtensionSize(id.number()); + return _impl_._extensions_.ExtensionSize(id.number()); } template <typename _proto_TypeTraits, @@ -5140,7 +5174,7 @@ class PROTOBUF_EXPORT FieldOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value()); } @@ -5152,7 +5186,7 @@ class PROTOBUF_EXPORT FieldOptions final : FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Mutable(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5162,7 +5196,7 @@ class PROTOBUF_EXPORT FieldOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::ConstType value) { - _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_); } @@ -5174,7 +5208,7 @@ class PROTOBUF_EXPORT FieldOptions final : FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::SetAllocated(id.number(), _field_type, value, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5185,7 +5219,7 @@ class PROTOBUF_EXPORT FieldOptions final : FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type, - value, &_extensions_); + value, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5198,7 +5232,7 @@ class PROTOBUF_EXPORT FieldOptions final : FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Release(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, @@ -5209,7 +5243,7 @@ class PROTOBUF_EXPORT FieldOptions final : FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5220,7 +5254,7 @@ class PROTOBUF_EXPORT FieldOptions final : FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, index); + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index); } template <typename _proto_TypeTraits, @@ -5231,7 +5265,7 @@ class PROTOBUF_EXPORT FieldOptions final : FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) { - return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); + return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5241,7 +5275,7 @@ class PROTOBUF_EXPORT FieldOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index, typename _proto_TypeTraits::Repeated::ConstType value) { - _proto_TypeTraits::Set(id.number(), index, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_); } @@ -5252,7 +5286,7 @@ class PROTOBUF_EXPORT FieldOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { typename _proto_TypeTraits::Repeated::MutableType to_add = - _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); + _proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_); return to_add; } @@ -5265,7 +5299,7 @@ class PROTOBUF_EXPORT FieldOptions final : FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Repeated::ConstType value) { _proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value, - &_extensions_); + &_impl_._extensions_); } @@ -5277,7 +5311,7 @@ class PROTOBUF_EXPORT FieldOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::GetRepeated(id.number(), _extensions_); + return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5289,27 +5323,31 @@ class PROTOBUF_EXPORT FieldOptions final : FieldOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::MutableRepeated(id.number(), _field_type, - _is_packed, &_extensions_); + _is_packed, &_impl_._extensions_); } // @@protoc_insertion_point(class_scope:google.protobuf.FieldOptions) private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; - int ctype_; - bool packed_; - bool lazy_; - bool deprecated_; - bool weak_; - int jstype_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; + + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; + int ctype_; + int jstype_; + bool packed_; + bool lazy_; + bool unverified_lazy_; + bool deprecated_; + bool weak_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -5319,7 +5357,7 @@ class PROTOBUF_EXPORT OneofOptions final : public: inline OneofOptions() : OneofOptions(nullptr) {} ~OneofOptions() override; - explicit constexpr OneofOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR OneofOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); OneofOptions(const OneofOptions& from); OneofOptions(OneofOptions&& from) noexcept @@ -5401,9 +5439,11 @@ class PROTOBUF_EXPORT OneofOptions final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const OneofOptions& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const OneofOptions& from); + void MergeFrom( const OneofOptions& from) { + OneofOptions::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -5412,10 +5452,10 @@ class PROTOBUF_EXPORT OneofOptions final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(OneofOptions* other); @@ -5428,9 +5468,6 @@ class PROTOBUF_EXPORT OneofOptions final : protected: explicit OneofOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -5471,7 +5508,7 @@ class PROTOBUF_EXPORT OneofOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.Has(id.number()); + return _impl_._extensions_.Has(id.number()); } template <typename _proto_TypeTraits, @@ -5480,7 +5517,7 @@ class PROTOBUF_EXPORT OneofOptions final : inline void ClearExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { - _extensions_.ClearExtension(id.number()); + _impl_._extensions_.ClearExtension(id.number()); } @@ -5491,7 +5528,7 @@ class PROTOBUF_EXPORT OneofOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.ExtensionSize(id.number()); + return _impl_._extensions_.ExtensionSize(id.number()); } template <typename _proto_TypeTraits, @@ -5501,7 +5538,7 @@ class PROTOBUF_EXPORT OneofOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value()); } @@ -5513,7 +5550,7 @@ class PROTOBUF_EXPORT OneofOptions final : OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Mutable(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5523,7 +5560,7 @@ class PROTOBUF_EXPORT OneofOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::ConstType value) { - _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_); } @@ -5535,7 +5572,7 @@ class PROTOBUF_EXPORT OneofOptions final : OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::SetAllocated(id.number(), _field_type, value, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5546,7 +5583,7 @@ class PROTOBUF_EXPORT OneofOptions final : OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type, - value, &_extensions_); + value, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5559,7 +5596,7 @@ class PROTOBUF_EXPORT OneofOptions final : OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Release(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, @@ -5570,7 +5607,7 @@ class PROTOBUF_EXPORT OneofOptions final : OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5581,7 +5618,7 @@ class PROTOBUF_EXPORT OneofOptions final : OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, index); + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index); } template <typename _proto_TypeTraits, @@ -5592,7 +5629,7 @@ class PROTOBUF_EXPORT OneofOptions final : OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) { - return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); + return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5602,7 +5639,7 @@ class PROTOBUF_EXPORT OneofOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index, typename _proto_TypeTraits::Repeated::ConstType value) { - _proto_TypeTraits::Set(id.number(), index, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_); } @@ -5613,7 +5650,7 @@ class PROTOBUF_EXPORT OneofOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { typename _proto_TypeTraits::Repeated::MutableType to_add = - _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); + _proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_); return to_add; } @@ -5626,7 +5663,7 @@ class PROTOBUF_EXPORT OneofOptions final : OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Repeated::ConstType value) { _proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value, - &_extensions_); + &_impl_._extensions_); } @@ -5638,7 +5675,7 @@ class PROTOBUF_EXPORT OneofOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::GetRepeated(id.number(), _extensions_); + return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5650,20 +5687,23 @@ class PROTOBUF_EXPORT OneofOptions final : OneofOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::MutableRepeated(id.number(), _field_type, - _is_packed, &_extensions_); + _is_packed, &_impl_._extensions_); } // @@protoc_insertion_point(class_scope:google.protobuf.OneofOptions) private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; + + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -5673,7 +5713,7 @@ class PROTOBUF_EXPORT EnumOptions final : public: inline EnumOptions() : EnumOptions(nullptr) {} ~EnumOptions() override; - explicit constexpr EnumOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR EnumOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumOptions(const EnumOptions& from); EnumOptions(EnumOptions&& from) noexcept @@ -5755,9 +5795,11 @@ class PROTOBUF_EXPORT EnumOptions final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const EnumOptions& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const EnumOptions& from); + void MergeFrom( const EnumOptions& from) { + EnumOptions::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -5766,10 +5808,10 @@ class PROTOBUF_EXPORT EnumOptions final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(EnumOptions* other); @@ -5782,9 +5824,6 @@ class PROTOBUF_EXPORT EnumOptions final : protected: explicit EnumOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -5853,7 +5892,7 @@ class PROTOBUF_EXPORT EnumOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.Has(id.number()); + return _impl_._extensions_.Has(id.number()); } template <typename _proto_TypeTraits, @@ -5862,7 +5901,7 @@ class PROTOBUF_EXPORT EnumOptions final : inline void ClearExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { - _extensions_.ClearExtension(id.number()); + _impl_._extensions_.ClearExtension(id.number()); } @@ -5873,7 +5912,7 @@ class PROTOBUF_EXPORT EnumOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.ExtensionSize(id.number()); + return _impl_._extensions_.ExtensionSize(id.number()); } template <typename _proto_TypeTraits, @@ -5883,7 +5922,7 @@ class PROTOBUF_EXPORT EnumOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value()); } @@ -5895,7 +5934,7 @@ class PROTOBUF_EXPORT EnumOptions final : EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Mutable(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5905,7 +5944,7 @@ class PROTOBUF_EXPORT EnumOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::ConstType value) { - _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_); } @@ -5917,7 +5956,7 @@ class PROTOBUF_EXPORT EnumOptions final : EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::SetAllocated(id.number(), _field_type, value, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5928,7 +5967,7 @@ class PROTOBUF_EXPORT EnumOptions final : EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type, - value, &_extensions_); + value, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5941,7 +5980,7 @@ class PROTOBUF_EXPORT EnumOptions final : EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Release(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, @@ -5952,7 +5991,7 @@ class PROTOBUF_EXPORT EnumOptions final : EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5963,7 +6002,7 @@ class PROTOBUF_EXPORT EnumOptions final : EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, index); + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index); } template <typename _proto_TypeTraits, @@ -5974,7 +6013,7 @@ class PROTOBUF_EXPORT EnumOptions final : EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) { - return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); + return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -5984,7 +6023,7 @@ class PROTOBUF_EXPORT EnumOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index, typename _proto_TypeTraits::Repeated::ConstType value) { - _proto_TypeTraits::Set(id.number(), index, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_); } @@ -5995,7 +6034,7 @@ class PROTOBUF_EXPORT EnumOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { typename _proto_TypeTraits::Repeated::MutableType to_add = - _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); + _proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_); return to_add; } @@ -6008,7 +6047,7 @@ class PROTOBUF_EXPORT EnumOptions final : EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Repeated::ConstType value) { _proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value, - &_extensions_); + &_impl_._extensions_); } @@ -6020,7 +6059,7 @@ class PROTOBUF_EXPORT EnumOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::GetRepeated(id.number(), _extensions_); + return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6032,23 +6071,26 @@ class PROTOBUF_EXPORT EnumOptions final : EnumOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::MutableRepeated(id.number(), _field_type, - _is_packed, &_extensions_); + _is_packed, &_impl_._extensions_); } // @@protoc_insertion_point(class_scope:google.protobuf.EnumOptions) private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; - bool allow_alias_; - bool deprecated_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; + + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; + bool allow_alias_; + bool deprecated_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -6058,7 +6100,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : public: inline EnumValueOptions() : EnumValueOptions(nullptr) {} ~EnumValueOptions() override; - explicit constexpr EnumValueOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR EnumValueOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumValueOptions(const EnumValueOptions& from); EnumValueOptions(EnumValueOptions&& from) noexcept @@ -6140,9 +6182,11 @@ class PROTOBUF_EXPORT EnumValueOptions final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const EnumValueOptions& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const EnumValueOptions& from); + void MergeFrom( const EnumValueOptions& from) { + EnumValueOptions::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -6151,10 +6195,10 @@ class PROTOBUF_EXPORT EnumValueOptions final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(EnumValueOptions* other); @@ -6167,9 +6211,6 @@ class PROTOBUF_EXPORT EnumValueOptions final : protected: explicit EnumValueOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -6224,7 +6265,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.Has(id.number()); + return _impl_._extensions_.Has(id.number()); } template <typename _proto_TypeTraits, @@ -6233,7 +6274,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : inline void ClearExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { - _extensions_.ClearExtension(id.number()); + _impl_._extensions_.ClearExtension(id.number()); } @@ -6244,7 +6285,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.ExtensionSize(id.number()); + return _impl_._extensions_.ExtensionSize(id.number()); } template <typename _proto_TypeTraits, @@ -6254,7 +6295,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value()); } @@ -6266,7 +6307,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Mutable(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6276,7 +6317,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::ConstType value) { - _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_); } @@ -6288,7 +6329,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::SetAllocated(id.number(), _field_type, value, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6299,7 +6340,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type, - value, &_extensions_); + value, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6312,7 +6353,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Release(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, @@ -6323,7 +6364,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6334,7 +6375,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, index); + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index); } template <typename _proto_TypeTraits, @@ -6345,7 +6386,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) { - return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); + return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6355,7 +6396,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index, typename _proto_TypeTraits::Repeated::ConstType value) { - _proto_TypeTraits::Set(id.number(), index, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_); } @@ -6366,7 +6407,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { typename _proto_TypeTraits::Repeated::MutableType to_add = - _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); + _proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_); return to_add; } @@ -6379,7 +6420,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Repeated::ConstType value) { _proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value, - &_extensions_); + &_impl_._extensions_); } @@ -6391,7 +6432,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::GetRepeated(id.number(), _extensions_); + return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6403,22 +6444,25 @@ class PROTOBUF_EXPORT EnumValueOptions final : EnumValueOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::MutableRepeated(id.number(), _field_type, - _is_packed, &_extensions_); + _is_packed, &_impl_._extensions_); } // @@protoc_insertion_point(class_scope:google.protobuf.EnumValueOptions) private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; - bool deprecated_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; + + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; + bool deprecated_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -6428,7 +6472,7 @@ class PROTOBUF_EXPORT ServiceOptions final : public: inline ServiceOptions() : ServiceOptions(nullptr) {} ~ServiceOptions() override; - explicit constexpr ServiceOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR ServiceOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ServiceOptions(const ServiceOptions& from); ServiceOptions(ServiceOptions&& from) noexcept @@ -6510,9 +6554,11 @@ class PROTOBUF_EXPORT ServiceOptions final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const ServiceOptions& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const ServiceOptions& from); + void MergeFrom( const ServiceOptions& from) { + ServiceOptions::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -6521,10 +6567,10 @@ class PROTOBUF_EXPORT ServiceOptions final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(ServiceOptions* other); @@ -6537,9 +6583,6 @@ class PROTOBUF_EXPORT ServiceOptions final : protected: explicit ServiceOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -6594,7 +6637,7 @@ class PROTOBUF_EXPORT ServiceOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.Has(id.number()); + return _impl_._extensions_.Has(id.number()); } template <typename _proto_TypeTraits, @@ -6603,7 +6646,7 @@ class PROTOBUF_EXPORT ServiceOptions final : inline void ClearExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { - _extensions_.ClearExtension(id.number()); + _impl_._extensions_.ClearExtension(id.number()); } @@ -6614,7 +6657,7 @@ class PROTOBUF_EXPORT ServiceOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.ExtensionSize(id.number()); + return _impl_._extensions_.ExtensionSize(id.number()); } template <typename _proto_TypeTraits, @@ -6624,7 +6667,7 @@ class PROTOBUF_EXPORT ServiceOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value()); } @@ -6636,7 +6679,7 @@ class PROTOBUF_EXPORT ServiceOptions final : ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Mutable(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6646,7 +6689,7 @@ class PROTOBUF_EXPORT ServiceOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::ConstType value) { - _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_); } @@ -6658,7 +6701,7 @@ class PROTOBUF_EXPORT ServiceOptions final : ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::SetAllocated(id.number(), _field_type, value, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6669,7 +6712,7 @@ class PROTOBUF_EXPORT ServiceOptions final : ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type, - value, &_extensions_); + value, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6682,7 +6725,7 @@ class PROTOBUF_EXPORT ServiceOptions final : ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Release(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, @@ -6693,7 +6736,7 @@ class PROTOBUF_EXPORT ServiceOptions final : ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6704,7 +6747,7 @@ class PROTOBUF_EXPORT ServiceOptions final : ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, index); + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index); } template <typename _proto_TypeTraits, @@ -6715,7 +6758,7 @@ class PROTOBUF_EXPORT ServiceOptions final : ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) { - return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); + return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6725,7 +6768,7 @@ class PROTOBUF_EXPORT ServiceOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index, typename _proto_TypeTraits::Repeated::ConstType value) { - _proto_TypeTraits::Set(id.number(), index, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_); } @@ -6736,7 +6779,7 @@ class PROTOBUF_EXPORT ServiceOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { typename _proto_TypeTraits::Repeated::MutableType to_add = - _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); + _proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_); return to_add; } @@ -6749,7 +6792,7 @@ class PROTOBUF_EXPORT ServiceOptions final : ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Repeated::ConstType value) { _proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value, - &_extensions_); + &_impl_._extensions_); } @@ -6761,7 +6804,7 @@ class PROTOBUF_EXPORT ServiceOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::GetRepeated(id.number(), _extensions_); + return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_); } template <typename _proto_TypeTraits, @@ -6773,22 +6816,25 @@ class PROTOBUF_EXPORT ServiceOptions final : ServiceOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::MutableRepeated(id.number(), _field_type, - _is_packed, &_extensions_); + _is_packed, &_impl_._extensions_); } // @@protoc_insertion_point(class_scope:google.protobuf.ServiceOptions) private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; - bool deprecated_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; + + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; + bool deprecated_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -6798,7 +6844,7 @@ class PROTOBUF_EXPORT MethodOptions final : public: inline MethodOptions() : MethodOptions(nullptr) {} ~MethodOptions() override; - explicit constexpr MethodOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR MethodOptions(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); MethodOptions(const MethodOptions& from); MethodOptions(MethodOptions&& from) noexcept @@ -6880,9 +6926,11 @@ class PROTOBUF_EXPORT MethodOptions final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const MethodOptions& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const MethodOptions& from); + void MergeFrom( const MethodOptions& from) { + MethodOptions::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -6891,10 +6939,10 @@ class PROTOBUF_EXPORT MethodOptions final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(MethodOptions* other); @@ -6907,9 +6955,6 @@ class PROTOBUF_EXPORT MethodOptions final : protected: explicit MethodOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -7010,7 +7055,7 @@ class PROTOBUF_EXPORT MethodOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.Has(id.number()); + return _impl_._extensions_.Has(id.number()); } template <typename _proto_TypeTraits, @@ -7019,7 +7064,7 @@ class PROTOBUF_EXPORT MethodOptions final : inline void ClearExtension( const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { - _extensions_.ClearExtension(id.number()); + _impl_._extensions_.ClearExtension(id.number()); } @@ -7030,7 +7075,7 @@ class PROTOBUF_EXPORT MethodOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _extensions_.ExtensionSize(id.number()); + return _impl_._extensions_.ExtensionSize(id.number()); } template <typename _proto_TypeTraits, @@ -7040,7 +7085,7 @@ class PROTOBUF_EXPORT MethodOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, id.default_value()); } @@ -7052,7 +7097,7 @@ class PROTOBUF_EXPORT MethodOptions final : MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Mutable(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -7062,7 +7107,7 @@ class PROTOBUF_EXPORT MethodOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::ConstType value) { - _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), _field_type, value, &_impl_._extensions_); } @@ -7074,7 +7119,7 @@ class PROTOBUF_EXPORT MethodOptions final : MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::SetAllocated(id.number(), _field_type, value, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -7085,7 +7130,7 @@ class PROTOBUF_EXPORT MethodOptions final : MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Singular::MutableType value) { _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type, - value, &_extensions_); + value, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -7098,7 +7143,7 @@ class PROTOBUF_EXPORT MethodOptions final : MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::Release(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, @@ -7109,7 +7154,7 @@ class PROTOBUF_EXPORT MethodOptions final : MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type, - &_extensions_); + &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -7120,7 +7165,7 @@ class PROTOBUF_EXPORT MethodOptions final : MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) const { - return _proto_TypeTraits::Get(id.number(), _extensions_, index); + return _proto_TypeTraits::Get(id.number(), _impl_._extensions_, index); } template <typename _proto_TypeTraits, @@ -7131,7 +7176,7 @@ class PROTOBUF_EXPORT MethodOptions final : MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index) { - return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); + return _proto_TypeTraits::Mutable(id.number(), index, &_impl_._extensions_); } template <typename _proto_TypeTraits, @@ -7141,7 +7186,7 @@ class PROTOBUF_EXPORT MethodOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id, int index, typename _proto_TypeTraits::Repeated::ConstType value) { - _proto_TypeTraits::Set(id.number(), index, value, &_extensions_); + _proto_TypeTraits::Set(id.number(), index, value, &_impl_._extensions_); } @@ -7152,7 +7197,7 @@ class PROTOBUF_EXPORT MethodOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { typename _proto_TypeTraits::Repeated::MutableType to_add = - _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); + _proto_TypeTraits::Add(id.number(), _field_type, &_impl_._extensions_); return to_add; } @@ -7165,7 +7210,7 @@ class PROTOBUF_EXPORT MethodOptions final : MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id, typename _proto_TypeTraits::Repeated::ConstType value) { _proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value, - &_extensions_); + &_impl_._extensions_); } @@ -7177,7 +7222,7 @@ class PROTOBUF_EXPORT MethodOptions final : const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) const { - return _proto_TypeTraits::GetRepeated(id.number(), _extensions_); + return _proto_TypeTraits::GetRepeated(id.number(), _impl_._extensions_); } template <typename _proto_TypeTraits, @@ -7189,23 +7234,26 @@ class PROTOBUF_EXPORT MethodOptions final : MethodOptions, _proto_TypeTraits, _field_type, _is_packed>& id) { return _proto_TypeTraits::MutableRepeated(id.number(), _field_type, - _is_packed, &_extensions_); + _is_packed, &_impl_._extensions_); } // @@protoc_insertion_point(class_scope:google.protobuf.MethodOptions) private: class _Internal; - ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; - template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; - bool deprecated_; - int idempotency_level_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_; + + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption > uninterpreted_option_; + bool deprecated_; + int idempotency_level_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -7215,7 +7263,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : public: inline UninterpretedOption_NamePart() : UninterpretedOption_NamePart(nullptr) {} ~UninterpretedOption_NamePart() override; - explicit constexpr UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from); UninterpretedOption_NamePart(UninterpretedOption_NamePart&& from) noexcept @@ -7297,9 +7345,11 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const UninterpretedOption_NamePart& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const UninterpretedOption_NamePart& from); + void MergeFrom( const UninterpretedOption_NamePart& from) { + UninterpretedOption_NamePart::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -7308,10 +7358,10 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(UninterpretedOption_NamePart* other); @@ -7324,9 +7374,6 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : protected: explicit UninterpretedOption_NamePart(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -7383,10 +7430,13 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_part_; - bool is_extension_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_part_; + bool is_extension_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -7396,7 +7446,7 @@ class PROTOBUF_EXPORT UninterpretedOption final : public: inline UninterpretedOption() : UninterpretedOption(nullptr) {} ~UninterpretedOption() override; - explicit constexpr UninterpretedOption(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR UninterpretedOption(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); UninterpretedOption(const UninterpretedOption& from); UninterpretedOption(UninterpretedOption&& from) noexcept @@ -7478,9 +7528,11 @@ class PROTOBUF_EXPORT UninterpretedOption final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const UninterpretedOption& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const UninterpretedOption& from); + void MergeFrom( const UninterpretedOption& from) { + UninterpretedOption::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -7489,10 +7541,10 @@ class PROTOBUF_EXPORT UninterpretedOption final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(UninterpretedOption* other); @@ -7505,9 +7557,6 @@ class PROTOBUF_EXPORT UninterpretedOption final : protected: explicit UninterpretedOption(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -7648,15 +7697,18 @@ class PROTOBUF_EXPORT UninterpretedOption final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart > name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr identifier_value_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr string_value_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr aggregate_value_; - uint64_t positive_int_value_; - int64_t negative_int_value_; - double double_value_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart > name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr identifier_value_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr string_value_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr aggregate_value_; + uint64_t positive_int_value_; + int64_t negative_int_value_; + double double_value_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -7666,7 +7718,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : public: inline SourceCodeInfo_Location() : SourceCodeInfo_Location(nullptr) {} ~SourceCodeInfo_Location() override; - explicit constexpr SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); SourceCodeInfo_Location(const SourceCodeInfo_Location& from); SourceCodeInfo_Location(SourceCodeInfo_Location&& from) noexcept @@ -7748,9 +7800,11 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const SourceCodeInfo_Location& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const SourceCodeInfo_Location& from); + void MergeFrom( const SourceCodeInfo_Location& from) { + SourceCodeInfo_Location::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -7759,10 +7813,10 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(SourceCodeInfo_Location* other); @@ -7775,9 +7829,6 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : protected: explicit SourceCodeInfo_Location(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -7907,15 +7958,18 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t > path_; - mutable std::atomic<int> _path_cached_byte_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t > span_; - mutable std::atomic<int> _span_cached_byte_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> leading_detached_comments_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr leading_comments_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr trailing_comments_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t > path_; + mutable std::atomic<int> _path_cached_byte_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t > span_; + mutable std::atomic<int> _span_cached_byte_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> leading_detached_comments_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr leading_comments_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr trailing_comments_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -7925,7 +7979,7 @@ class PROTOBUF_EXPORT SourceCodeInfo final : public: inline SourceCodeInfo() : SourceCodeInfo(nullptr) {} ~SourceCodeInfo() override; - explicit constexpr SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); SourceCodeInfo(const SourceCodeInfo& from); SourceCodeInfo(SourceCodeInfo&& from) noexcept @@ -8007,9 +8061,11 @@ class PROTOBUF_EXPORT SourceCodeInfo final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const SourceCodeInfo& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const SourceCodeInfo& from); + void MergeFrom( const SourceCodeInfo& from) { + SourceCodeInfo::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -8018,10 +8074,10 @@ class PROTOBUF_EXPORT SourceCodeInfo final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(SourceCodeInfo* other); @@ -8034,9 +8090,6 @@ class PROTOBUF_EXPORT SourceCodeInfo final : protected: explicit SourceCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -8078,8 +8131,11 @@ class PROTOBUF_EXPORT SourceCodeInfo final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location > location_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location > location_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -8089,7 +8145,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : public: inline GeneratedCodeInfo_Annotation() : GeneratedCodeInfo_Annotation(nullptr) {} ~GeneratedCodeInfo_Annotation() override; - explicit constexpr GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from); GeneratedCodeInfo_Annotation(GeneratedCodeInfo_Annotation&& from) noexcept @@ -8171,9 +8227,11 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const GeneratedCodeInfo_Annotation& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const GeneratedCodeInfo_Annotation& from); + void MergeFrom( const GeneratedCodeInfo_Annotation& from) { + GeneratedCodeInfo_Annotation::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -8182,10 +8240,10 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(GeneratedCodeInfo_Annotation* other); @@ -8198,9 +8256,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : protected: explicit GeneratedCodeInfo_Annotation(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -8291,13 +8346,16 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t > path_; - mutable std::atomic<int> _path_cached_byte_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr source_file_; - int32_t begin_; - int32_t end_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t > path_; + mutable std::atomic<int> _path_cached_byte_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr source_file_; + int32_t begin_; + int32_t end_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // ------------------------------------------------------------------- @@ -8307,7 +8365,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : public: inline GeneratedCodeInfo() : GeneratedCodeInfo(nullptr) {} ~GeneratedCodeInfo() override; - explicit constexpr GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); GeneratedCodeInfo(const GeneratedCodeInfo& from); GeneratedCodeInfo(GeneratedCodeInfo&& from) noexcept @@ -8389,9 +8447,11 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const GeneratedCodeInfo& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const GeneratedCodeInfo& from); + void MergeFrom( const GeneratedCodeInfo& from) { + GeneratedCodeInfo::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -8400,10 +8460,10 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(GeneratedCodeInfo* other); @@ -8416,9 +8476,6 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : protected: explicit GeneratedCodeInfo(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -8460,8 +8517,11 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation > annotation_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation > annotation_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; }; // =================================================================== @@ -8477,32 +8537,32 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : // repeated .google.protobuf.FileDescriptorProto file = 1; inline int FileDescriptorSet::_internal_file_size() const { - return file_.size(); + return _impl_.file_.size(); } inline int FileDescriptorSet::file_size() const { return _internal_file_size(); } inline void FileDescriptorSet::clear_file() { - file_.Clear(); + _impl_.file_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* FileDescriptorSet::mutable_file(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorSet.file) - return file_.Mutable(index); + return _impl_.file_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >* FileDescriptorSet::mutable_file() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorSet.file) - return &file_; + return &_impl_.file_; } inline const ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto& FileDescriptorSet::_internal_file(int index) const { - return file_.Get(index); + return _impl_.file_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto& FileDescriptorSet::file(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorSet.file) return _internal_file(index); } inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* FileDescriptorSet::_internal_add_file() { - return file_.Add(); + return _impl_.file_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* FileDescriptorSet::add_file() { ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* _add = _internal_add_file(); @@ -8512,7 +8572,7 @@ inline ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* FileDescriptorSet::add_file inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto >& FileDescriptorSet::file() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorSet.file) - return file_; + return _impl_.file_; } // ------------------------------------------------------------------- @@ -8521,15 +8581,15 @@ FileDescriptorSet::file() const { // optional string name = 1; inline bool FileDescriptorProto::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool FileDescriptorProto::has_name() const { return _internal_has_name(); } inline void FileDescriptorProto::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.name_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& FileDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name) @@ -8538,8 +8598,8 @@ inline const std::string& FileDescriptorProto::name() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name) } inline std::string* FileDescriptorProto::mutable_name() { @@ -8548,41 +8608,40 @@ inline std::string* FileDescriptorProto::mutable_name() { return _s; } inline const std::string& FileDescriptorProto::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void FileDescriptorProto::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* FileDescriptorProto::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* FileDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.name) if (!_internal_has_name()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.name) @@ -8590,15 +8649,15 @@ inline void FileDescriptorProto::set_allocated_name(std::string* name) { // optional string package = 2; inline bool FileDescriptorProto::_internal_has_package() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool FileDescriptorProto::has_package() const { return _internal_has_package(); } inline void FileDescriptorProto::clear_package() { - package_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; + _impl_.package_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const std::string& FileDescriptorProto::package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package) @@ -8607,8 +8666,8 @@ inline const std::string& FileDescriptorProto::package() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileDescriptorProto::set_package(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000002u; - package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.package_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package) } inline std::string* FileDescriptorProto::mutable_package() { @@ -8617,41 +8676,40 @@ inline std::string* FileDescriptorProto::mutable_package() { return _s; } inline const std::string& FileDescriptorProto::_internal_package() const { - return package_.Get(); + return _impl_.package_.Get(); } inline void FileDescriptorProto::_internal_set_package(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.package_.Set(value, GetArenaForAllocation()); } inline std::string* FileDescriptorProto::_internal_mutable_package() { - _has_bits_[0] |= 0x00000002u; - return package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.package_.Mutable(GetArenaForAllocation()); } inline std::string* FileDescriptorProto::release_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.package) if (!_internal_has_package()) { return nullptr; } - _has_bits_[0] &= ~0x00000002u; - auto* p = package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.package_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.package_.IsDefault()) { + _impl_.package_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileDescriptorProto::set_allocated_package(std::string* package) { if (package != nullptr) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), package, - GetArenaForAllocation()); + _impl_.package_.SetAllocated(package, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.package_.IsDefault()) { + _impl_.package_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.package) @@ -8659,13 +8717,13 @@ inline void FileDescriptorProto::set_allocated_package(std::string* package) { // repeated string dependency = 3; inline int FileDescriptorProto::_internal_dependency_size() const { - return dependency_.size(); + return _impl_.dependency_.size(); } inline int FileDescriptorProto::dependency_size() const { return _internal_dependency_size(); } inline void FileDescriptorProto::clear_dependency() { - dependency_.Clear(); + _impl_.dependency_.Clear(); } inline std::string* FileDescriptorProto::add_dependency() { std::string* _s = _internal_add_dependency(); @@ -8673,7 +8731,7 @@ inline std::string* FileDescriptorProto::add_dependency() { return _s; } inline const std::string& FileDescriptorProto::_internal_dependency(int index) const { - return dependency_.Get(index); + return _impl_.dependency_.Get(index); } inline const std::string& FileDescriptorProto::dependency(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.dependency) @@ -8681,80 +8739,80 @@ inline const std::string& FileDescriptorProto::dependency(int index) const { } inline std::string* FileDescriptorProto::mutable_dependency(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.dependency) - return dependency_.Mutable(index); + return _impl_.dependency_.Mutable(index); } inline void FileDescriptorProto::set_dependency(int index, const std::string& value) { - dependency_.Mutable(index)->assign(value); + _impl_.dependency_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) } inline void FileDescriptorProto::set_dependency(int index, std::string&& value) { - dependency_.Mutable(index)->assign(std::move(value)); + _impl_.dependency_.Mutable(index)->assign(std::move(value)); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency) } inline void FileDescriptorProto::set_dependency(int index, const char* value) { GOOGLE_DCHECK(value != nullptr); - dependency_.Mutable(index)->assign(value); + _impl_.dependency_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency) } inline void FileDescriptorProto::set_dependency(int index, const char* value, size_t size) { - dependency_.Mutable(index)->assign( + _impl_.dependency_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.dependency) } inline std::string* FileDescriptorProto::_internal_add_dependency() { - return dependency_.Add(); + return _impl_.dependency_.Add(); } inline void FileDescriptorProto::add_dependency(const std::string& value) { - dependency_.Add()->assign(value); + _impl_.dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) } inline void FileDescriptorProto::add_dependency(std::string&& value) { - dependency_.Add(std::move(value)); + _impl_.dependency_.Add(std::move(value)); // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency) } inline void FileDescriptorProto::add_dependency(const char* value) { GOOGLE_DCHECK(value != nullptr); - dependency_.Add()->assign(value); + _impl_.dependency_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency) } inline void FileDescriptorProto::add_dependency(const char* value, size_t size) { - dependency_.Add()->assign(reinterpret_cast<const char*>(value), size); + _impl_.dependency_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.FileDescriptorProto.dependency) } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>& FileDescriptorProto::dependency() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.dependency) - return dependency_; + return _impl_.dependency_; } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>* FileDescriptorProto::mutable_dependency() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.dependency) - return &dependency_; + return &_impl_.dependency_; } // repeated int32 public_dependency = 10; inline int FileDescriptorProto::_internal_public_dependency_size() const { - return public_dependency_.size(); + return _impl_.public_dependency_.size(); } inline int FileDescriptorProto::public_dependency_size() const { return _internal_public_dependency_size(); } inline void FileDescriptorProto::clear_public_dependency() { - public_dependency_.Clear(); + _impl_.public_dependency_.Clear(); } inline int32_t FileDescriptorProto::_internal_public_dependency(int index) const { - return public_dependency_.Get(index); + return _impl_.public_dependency_.Get(index); } inline int32_t FileDescriptorProto::public_dependency(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.public_dependency) return _internal_public_dependency(index); } inline void FileDescriptorProto::set_public_dependency(int index, int32_t value) { - public_dependency_.Set(index, value); + _impl_.public_dependency_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.public_dependency) } inline void FileDescriptorProto::_internal_add_public_dependency(int32_t value) { - public_dependency_.Add(value); + _impl_.public_dependency_.Add(value); } inline void FileDescriptorProto::add_public_dependency(int32_t value) { _internal_add_public_dependency(value); @@ -8762,7 +8820,7 @@ inline void FileDescriptorProto::add_public_dependency(int32_t value) { } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >& FileDescriptorProto::_internal_public_dependency() const { - return public_dependency_; + return _impl_.public_dependency_; } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >& FileDescriptorProto::public_dependency() const { @@ -8771,7 +8829,7 @@ FileDescriptorProto::public_dependency() const { } inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >* FileDescriptorProto::_internal_mutable_public_dependency() { - return &public_dependency_; + return &_impl_.public_dependency_; } inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >* FileDescriptorProto::mutable_public_dependency() { @@ -8781,27 +8839,27 @@ FileDescriptorProto::mutable_public_dependency() { // repeated int32 weak_dependency = 11; inline int FileDescriptorProto::_internal_weak_dependency_size() const { - return weak_dependency_.size(); + return _impl_.weak_dependency_.size(); } inline int FileDescriptorProto::weak_dependency_size() const { return _internal_weak_dependency_size(); } inline void FileDescriptorProto::clear_weak_dependency() { - weak_dependency_.Clear(); + _impl_.weak_dependency_.Clear(); } inline int32_t FileDescriptorProto::_internal_weak_dependency(int index) const { - return weak_dependency_.Get(index); + return _impl_.weak_dependency_.Get(index); } inline int32_t FileDescriptorProto::weak_dependency(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.weak_dependency) return _internal_weak_dependency(index); } inline void FileDescriptorProto::set_weak_dependency(int index, int32_t value) { - weak_dependency_.Set(index, value); + _impl_.weak_dependency_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.weak_dependency) } inline void FileDescriptorProto::_internal_add_weak_dependency(int32_t value) { - weak_dependency_.Add(value); + _impl_.weak_dependency_.Add(value); } inline void FileDescriptorProto::add_weak_dependency(int32_t value) { _internal_add_weak_dependency(value); @@ -8809,7 +8867,7 @@ inline void FileDescriptorProto::add_weak_dependency(int32_t value) { } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >& FileDescriptorProto::_internal_weak_dependency() const { - return weak_dependency_; + return _impl_.weak_dependency_; } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >& FileDescriptorProto::weak_dependency() const { @@ -8818,7 +8876,7 @@ FileDescriptorProto::weak_dependency() const { } inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >* FileDescriptorProto::_internal_mutable_weak_dependency() { - return &weak_dependency_; + return &_impl_.weak_dependency_; } inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >* FileDescriptorProto::mutable_weak_dependency() { @@ -8828,32 +8886,32 @@ FileDescriptorProto::mutable_weak_dependency() { // repeated .google.protobuf.DescriptorProto message_type = 4; inline int FileDescriptorProto::_internal_message_type_size() const { - return message_type_.size(); + return _impl_.message_type_.size(); } inline int FileDescriptorProto::message_type_size() const { return _internal_message_type_size(); } inline void FileDescriptorProto::clear_message_type() { - message_type_.Clear(); + _impl_.message_type_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto* FileDescriptorProto::mutable_message_type(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.message_type) - return message_type_.Mutable(index); + return _impl_.message_type_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >* FileDescriptorProto::mutable_message_type() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.message_type) - return &message_type_; + return &_impl_.message_type_; } inline const ::PROTOBUF_NAMESPACE_ID::DescriptorProto& FileDescriptorProto::_internal_message_type(int index) const { - return message_type_.Get(index); + return _impl_.message_type_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::DescriptorProto& FileDescriptorProto::message_type(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.message_type) return _internal_message_type(index); } inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto* FileDescriptorProto::_internal_add_message_type() { - return message_type_.Add(); + return _impl_.message_type_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto* FileDescriptorProto::add_message_type() { ::PROTOBUF_NAMESPACE_ID::DescriptorProto* _add = _internal_add_message_type(); @@ -8863,37 +8921,37 @@ inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto* FileDescriptorProto::add_messag inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >& FileDescriptorProto::message_type() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.message_type) - return message_type_; + return _impl_.message_type_; } // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; inline int FileDescriptorProto::_internal_enum_type_size() const { - return enum_type_.size(); + return _impl_.enum_type_.size(); } inline int FileDescriptorProto::enum_type_size() const { return _internal_enum_type_size(); } inline void FileDescriptorProto::clear_enum_type() { - enum_type_.Clear(); + _impl_.enum_type_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* FileDescriptorProto::mutable_enum_type(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.enum_type) - return enum_type_.Mutable(index); + return _impl_.enum_type_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >* FileDescriptorProto::mutable_enum_type() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.enum_type) - return &enum_type_; + return &_impl_.enum_type_; } inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto& FileDescriptorProto::_internal_enum_type(int index) const { - return enum_type_.Get(index); + return _impl_.enum_type_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto& FileDescriptorProto::enum_type(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.enum_type) return _internal_enum_type(index); } inline ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* FileDescriptorProto::_internal_add_enum_type() { - return enum_type_.Add(); + return _impl_.enum_type_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* FileDescriptorProto::add_enum_type() { ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* _add = _internal_add_enum_type(); @@ -8903,37 +8961,37 @@ inline ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* FileDescriptorProto::add_en inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >& FileDescriptorProto::enum_type() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.enum_type) - return enum_type_; + return _impl_.enum_type_; } // repeated .google.protobuf.ServiceDescriptorProto service = 6; inline int FileDescriptorProto::_internal_service_size() const { - return service_.size(); + return _impl_.service_.size(); } inline int FileDescriptorProto::service_size() const { return _internal_service_size(); } inline void FileDescriptorProto::clear_service() { - service_.Clear(); + _impl_.service_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* FileDescriptorProto::mutable_service(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.service) - return service_.Mutable(index); + return _impl_.service_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto >* FileDescriptorProto::mutable_service() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.service) - return &service_; + return &_impl_.service_; } inline const ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto& FileDescriptorProto::_internal_service(int index) const { - return service_.Get(index); + return _impl_.service_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto& FileDescriptorProto::service(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.service) return _internal_service(index); } inline ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* FileDescriptorProto::_internal_add_service() { - return service_.Add(); + return _impl_.service_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* FileDescriptorProto::add_service() { ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* _add = _internal_add_service(); @@ -8943,37 +9001,37 @@ inline ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* FileDescriptorProto::add inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto >& FileDescriptorProto::service() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.service) - return service_; + return _impl_.service_; } // repeated .google.protobuf.FieldDescriptorProto extension = 7; inline int FileDescriptorProto::_internal_extension_size() const { - return extension_.size(); + return _impl_.extension_.size(); } inline int FileDescriptorProto::extension_size() const { return _internal_extension_size(); } inline void FileDescriptorProto::clear_extension() { - extension_.Clear(); + _impl_.extension_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* FileDescriptorProto::mutable_extension(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.extension) - return extension_.Mutable(index); + return _impl_.extension_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >* FileDescriptorProto::mutable_extension() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.extension) - return &extension_; + return &_impl_.extension_; } inline const ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto& FileDescriptorProto::_internal_extension(int index) const { - return extension_.Get(index); + return _impl_.extension_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto& FileDescriptorProto::extension(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.extension) return _internal_extension(index); } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* FileDescriptorProto::_internal_add_extension() { - return extension_.Add(); + return _impl_.extension_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* FileDescriptorProto::add_extension() { ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* _add = _internal_add_extension(); @@ -8983,24 +9041,24 @@ inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* FileDescriptorProto::add_e inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >& FileDescriptorProto::extension() const { // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.extension) - return extension_; + return _impl_.extension_; } // optional .google.protobuf.FileOptions options = 8; inline bool FileDescriptorProto::_internal_has_options() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; - PROTOBUF_ASSUME(!value || options_ != nullptr); + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr); return value; } inline bool FileDescriptorProto::has_options() const { return _internal_has_options(); } inline void FileDescriptorProto::clear_options() { - if (options_ != nullptr) options_->Clear(); - _has_bits_[0] &= ~0x00000008u; + if (_impl_.options_ != nullptr) _impl_.options_->Clear(); + _impl_._has_bits_[0] &= ~0x00000008u; } inline const ::PROTOBUF_NAMESPACE_ID::FileOptions& FileDescriptorProto::_internal_options() const { - const ::PROTOBUF_NAMESPACE_ID::FileOptions* p = options_; + const ::PROTOBUF_NAMESPACE_ID::FileOptions* p = _impl_.options_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::FileOptions&>( ::PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_); } @@ -9011,20 +9069,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::FileOptions& FileDescriptorProto::options( inline void FileDescriptorProto::unsafe_arena_set_allocated_options( ::PROTOBUF_NAMESPACE_ID::FileOptions* options) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.options_); } - options_ = options; + _impl_.options_ = options; if (options) { - _has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000008u; } else { - _has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000008u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.options) } inline ::PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::release_options() { - _has_bits_[0] &= ~0x00000008u; - ::PROTOBUF_NAMESPACE_ID::FileOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000008u; + ::PROTOBUF_NAMESPACE_ID::FileOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -9038,18 +9096,18 @@ inline ::PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::release_option } inline ::PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::unsafe_arena_release_options() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.options) - _has_bits_[0] &= ~0x00000008u; - ::PROTOBUF_NAMESPACE_ID::FileOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000008u; + ::PROTOBUF_NAMESPACE_ID::FileOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::_internal_mutable_options() { - _has_bits_[0] |= 0x00000008u; - if (options_ == nullptr) { + _impl_._has_bits_[0] |= 0x00000008u; + if (_impl_.options_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileOptions>(GetArenaForAllocation()); - options_ = p; + _impl_.options_ = p; } - return options_; + return _impl_.options_; } inline ::PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::mutable_options() { ::PROTOBUF_NAMESPACE_ID::FileOptions* _msg = _internal_mutable_options(); @@ -9059,38 +9117,38 @@ inline ::PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::mutable_option inline void FileDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID::FileOptions* options) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete options_; + delete _impl_.options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::FileOptions>::GetOwningArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); } - _has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000008u; } else { - _has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000008u; } - options_ = options; + _impl_.options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.options) } // optional .google.protobuf.SourceCodeInfo source_code_info = 9; inline bool FileDescriptorProto::_internal_has_source_code_info() const { - bool value = (_has_bits_[0] & 0x00000010u) != 0; - PROTOBUF_ASSUME(!value || source_code_info_ != nullptr); + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + PROTOBUF_ASSUME(!value || _impl_.source_code_info_ != nullptr); return value; } inline bool FileDescriptorProto::has_source_code_info() const { return _internal_has_source_code_info(); } inline void FileDescriptorProto::clear_source_code_info() { - if (source_code_info_ != nullptr) source_code_info_->Clear(); - _has_bits_[0] &= ~0x00000010u; + if (_impl_.source_code_info_ != nullptr) _impl_.source_code_info_->Clear(); + _impl_._has_bits_[0] &= ~0x00000010u; } inline const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo& FileDescriptorProto::_internal_source_code_info() const { - const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* p = source_code_info_; + const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* p = _impl_.source_code_info_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo&>( ::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_); } @@ -9101,20 +9159,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo& FileDescriptorProto::sourc inline void FileDescriptorProto::unsafe_arena_set_allocated_source_code_info( ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* source_code_info) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_code_info_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.source_code_info_); } - source_code_info_ = source_code_info; + _impl_.source_code_info_ = source_code_info; if (source_code_info) { - _has_bits_[0] |= 0x00000010u; + _impl_._has_bits_[0] |= 0x00000010u; } else { - _has_bits_[0] &= ~0x00000010u; + _impl_._has_bits_[0] &= ~0x00000010u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FileDescriptorProto.source_code_info) } inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::release_source_code_info() { - _has_bits_[0] &= ~0x00000010u; - ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* temp = source_code_info_; - source_code_info_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000010u; + ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* temp = _impl_.source_code_info_; + _impl_.source_code_info_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -9128,18 +9186,18 @@ inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::release_sou } inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::unsafe_arena_release_source_code_info() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.source_code_info) - _has_bits_[0] &= ~0x00000010u; - ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* temp = source_code_info_; - source_code_info_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000010u; + ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* temp = _impl_.source_code_info_; + _impl_.source_code_info_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::_internal_mutable_source_code_info() { - _has_bits_[0] |= 0x00000010u; - if (source_code_info_ == nullptr) { + _impl_._has_bits_[0] |= 0x00000010u; + if (_impl_.source_code_info_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo>(GetArenaForAllocation()); - source_code_info_ = p; + _impl_.source_code_info_ = p; } - return source_code_info_; + return _impl_.source_code_info_; } inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::mutable_source_code_info() { ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* _msg = _internal_mutable_source_code_info(); @@ -9149,34 +9207,34 @@ inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::mutable_sou inline void FileDescriptorProto::set_allocated_source_code_info(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* source_code_info) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete source_code_info_; + delete _impl_.source_code_info_; } if (source_code_info) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo>::GetOwningArena(source_code_info); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(source_code_info); if (message_arena != submessage_arena) { source_code_info = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, source_code_info, submessage_arena); } - _has_bits_[0] |= 0x00000010u; + _impl_._has_bits_[0] |= 0x00000010u; } else { - _has_bits_[0] &= ~0x00000010u; + _impl_._has_bits_[0] &= ~0x00000010u; } - source_code_info_ = source_code_info; + _impl_.source_code_info_ = source_code_info; // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.source_code_info) } // optional string syntax = 12; inline bool FileDescriptorProto::_internal_has_syntax() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool FileDescriptorProto::has_syntax() const { return _internal_has_syntax(); } inline void FileDescriptorProto::clear_syntax() { - syntax_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000004u; + _impl_.syntax_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; } inline const std::string& FileDescriptorProto::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax) @@ -9185,8 +9243,8 @@ inline const std::string& FileDescriptorProto::syntax() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileDescriptorProto::set_syntax(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000004u; - syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.syntax_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax) } inline std::string* FileDescriptorProto::mutable_syntax() { @@ -9195,41 +9253,40 @@ inline std::string* FileDescriptorProto::mutable_syntax() { return _s; } inline const std::string& FileDescriptorProto::_internal_syntax() const { - return syntax_.Get(); + return _impl_.syntax_.Get(); } inline void FileDescriptorProto::_internal_set_syntax(const std::string& value) { - _has_bits_[0] |= 0x00000004u; - syntax_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.syntax_.Set(value, GetArenaForAllocation()); } inline std::string* FileDescriptorProto::_internal_mutable_syntax() { - _has_bits_[0] |= 0x00000004u; - return syntax_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.syntax_.Mutable(GetArenaForAllocation()); } inline std::string* FileDescriptorProto::release_syntax() { // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.syntax) if (!_internal_has_syntax()) { return nullptr; } - _has_bits_[0] &= ~0x00000004u; - auto* p = syntax_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.syntax_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (syntax_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.syntax_.IsDefault()) { + _impl_.syntax_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileDescriptorProto::set_allocated_syntax(std::string* syntax) { if (syntax != nullptr) { - _has_bits_[0] |= 0x00000004u; + _impl_._has_bits_[0] |= 0x00000004u; } else { - _has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000004u; } - syntax_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), syntax, - GetArenaForAllocation()); + _impl_.syntax_.SetAllocated(syntax, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (syntax_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.syntax_.IsDefault()) { + _impl_.syntax_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax) @@ -9241,26 +9298,26 @@ inline void FileDescriptorProto::set_allocated_syntax(std::string* syntax) { // optional int32 start = 1; inline bool DescriptorProto_ExtensionRange::_internal_has_start() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool DescriptorProto_ExtensionRange::has_start() const { return _internal_has_start(); } inline void DescriptorProto_ExtensionRange::clear_start() { - start_ = 0; - _has_bits_[0] &= ~0x00000002u; + _impl_.start_ = 0; + _impl_._has_bits_[0] &= ~0x00000002u; } inline int32_t DescriptorProto_ExtensionRange::_internal_start() const { - return start_; + return _impl_.start_; } inline int32_t DescriptorProto_ExtensionRange::start() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.start) return _internal_start(); } inline void DescriptorProto_ExtensionRange::_internal_set_start(int32_t value) { - _has_bits_[0] |= 0x00000002u; - start_ = value; + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.start_ = value; } inline void DescriptorProto_ExtensionRange::set_start(int32_t value) { _internal_set_start(value); @@ -9269,26 +9326,26 @@ inline void DescriptorProto_ExtensionRange::set_start(int32_t value) { // optional int32 end = 2; inline bool DescriptorProto_ExtensionRange::_internal_has_end() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool DescriptorProto_ExtensionRange::has_end() const { return _internal_has_end(); } inline void DescriptorProto_ExtensionRange::clear_end() { - end_ = 0; - _has_bits_[0] &= ~0x00000004u; + _impl_.end_ = 0; + _impl_._has_bits_[0] &= ~0x00000004u; } inline int32_t DescriptorProto_ExtensionRange::_internal_end() const { - return end_; + return _impl_.end_; } inline int32_t DescriptorProto_ExtensionRange::end() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.end) return _internal_end(); } inline void DescriptorProto_ExtensionRange::_internal_set_end(int32_t value) { - _has_bits_[0] |= 0x00000004u; - end_ = value; + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.end_ = value; } inline void DescriptorProto_ExtensionRange::set_end(int32_t value) { _internal_set_end(value); @@ -9297,19 +9354,19 @@ inline void DescriptorProto_ExtensionRange::set_end(int32_t value) { // optional .google.protobuf.ExtensionRangeOptions options = 3; inline bool DescriptorProto_ExtensionRange::_internal_has_options() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - PROTOBUF_ASSUME(!value || options_ != nullptr); + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr); return value; } inline bool DescriptorProto_ExtensionRange::has_options() const { return _internal_has_options(); } inline void DescriptorProto_ExtensionRange::clear_options() { - if (options_ != nullptr) options_->Clear(); - _has_bits_[0] &= ~0x00000001u; + if (_impl_.options_ != nullptr) _impl_.options_->Clear(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& DescriptorProto_ExtensionRange::_internal_options() const { - const ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* p = options_; + const ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* p = _impl_.options_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions&>( ::PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_); } @@ -9320,20 +9377,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& DescriptorProto_Ext inline void DescriptorProto_ExtensionRange::unsafe_arena_set_allocated_options( ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* options) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.options_); } - options_ = options; + _impl_.options_ = options; if (options) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.DescriptorProto.ExtensionRange.options) } inline ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRange::release_options() { - _has_bits_[0] &= ~0x00000001u; - ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000001u; + ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -9347,18 +9404,18 @@ inline ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_Extension } inline ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRange::unsafe_arena_release_options() { // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.ExtensionRange.options) - _has_bits_[0] &= ~0x00000001u; - ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000001u; + ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRange::_internal_mutable_options() { - _has_bits_[0] |= 0x00000001u; - if (options_ == nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + if (_impl_.options_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions>(GetArenaForAllocation()); - options_ = p; + _impl_.options_ = p; } - return options_; + return _impl_.options_; } inline ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRange::mutable_options() { ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* _msg = _internal_mutable_options(); @@ -9368,20 +9425,20 @@ inline ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_Extension inline void DescriptorProto_ExtensionRange::set_allocated_options(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* options) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete options_; + delete _impl_.options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions>::GetOwningArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); } - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - options_ = options; + _impl_.options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.ExtensionRange.options) } @@ -9391,26 +9448,26 @@ inline void DescriptorProto_ExtensionRange::set_allocated_options(::PROTOBUF_NAM // optional int32 start = 1; inline bool DescriptorProto_ReservedRange::_internal_has_start() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool DescriptorProto_ReservedRange::has_start() const { return _internal_has_start(); } inline void DescriptorProto_ReservedRange::clear_start() { - start_ = 0; - _has_bits_[0] &= ~0x00000001u; + _impl_.start_ = 0; + _impl_._has_bits_[0] &= ~0x00000001u; } inline int32_t DescriptorProto_ReservedRange::_internal_start() const { - return start_; + return _impl_.start_; } inline int32_t DescriptorProto_ReservedRange::start() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.start) return _internal_start(); } inline void DescriptorProto_ReservedRange::_internal_set_start(int32_t value) { - _has_bits_[0] |= 0x00000001u; - start_ = value; + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.start_ = value; } inline void DescriptorProto_ReservedRange::set_start(int32_t value) { _internal_set_start(value); @@ -9419,26 +9476,26 @@ inline void DescriptorProto_ReservedRange::set_start(int32_t value) { // optional int32 end = 2; inline bool DescriptorProto_ReservedRange::_internal_has_end() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool DescriptorProto_ReservedRange::has_end() const { return _internal_has_end(); } inline void DescriptorProto_ReservedRange::clear_end() { - end_ = 0; - _has_bits_[0] &= ~0x00000002u; + _impl_.end_ = 0; + _impl_._has_bits_[0] &= ~0x00000002u; } inline int32_t DescriptorProto_ReservedRange::_internal_end() const { - return end_; + return _impl_.end_; } inline int32_t DescriptorProto_ReservedRange::end() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.end) return _internal_end(); } inline void DescriptorProto_ReservedRange::_internal_set_end(int32_t value) { - _has_bits_[0] |= 0x00000002u; - end_ = value; + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.end_ = value; } inline void DescriptorProto_ReservedRange::set_end(int32_t value) { _internal_set_end(value); @@ -9451,15 +9508,15 @@ inline void DescriptorProto_ReservedRange::set_end(int32_t value) { // optional string name = 1; inline bool DescriptorProto::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool DescriptorProto::has_name() const { return _internal_has_name(); } inline void DescriptorProto::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.name_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& DescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name) @@ -9468,8 +9525,8 @@ inline const std::string& DescriptorProto::name() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void DescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name) } inline std::string* DescriptorProto::mutable_name() { @@ -9478,41 +9535,40 @@ inline std::string* DescriptorProto::mutable_name() { return _s; } inline const std::string& DescriptorProto::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void DescriptorProto::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* DescriptorProto::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* DescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.name) if (!_internal_has_name()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void DescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.name) @@ -9520,32 +9576,32 @@ inline void DescriptorProto::set_allocated_name(std::string* name) { // repeated .google.protobuf.FieldDescriptorProto field = 2; inline int DescriptorProto::_internal_field_size() const { - return field_.size(); + return _impl_.field_.size(); } inline int DescriptorProto::field_size() const { return _internal_field_size(); } inline void DescriptorProto::clear_field() { - field_.Clear(); + _impl_.field_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* DescriptorProto::mutable_field(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.field) - return field_.Mutable(index); + return _impl_.field_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >* DescriptorProto::mutable_field() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.field) - return &field_; + return &_impl_.field_; } inline const ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto& DescriptorProto::_internal_field(int index) const { - return field_.Get(index); + return _impl_.field_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto& DescriptorProto::field(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.field) return _internal_field(index); } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* DescriptorProto::_internal_add_field() { - return field_.Add(); + return _impl_.field_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* DescriptorProto::add_field() { ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* _add = _internal_add_field(); @@ -9555,37 +9611,37 @@ inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* DescriptorProto::add_field inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >& DescriptorProto::field() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.field) - return field_; + return _impl_.field_; } // repeated .google.protobuf.FieldDescriptorProto extension = 6; inline int DescriptorProto::_internal_extension_size() const { - return extension_.size(); + return _impl_.extension_.size(); } inline int DescriptorProto::extension_size() const { return _internal_extension_size(); } inline void DescriptorProto::clear_extension() { - extension_.Clear(); + _impl_.extension_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* DescriptorProto::mutable_extension(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension) - return extension_.Mutable(index); + return _impl_.extension_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >* DescriptorProto::mutable_extension() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension) - return &extension_; + return &_impl_.extension_; } inline const ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto& DescriptorProto::_internal_extension(int index) const { - return extension_.Get(index); + return _impl_.extension_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto& DescriptorProto::extension(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension) return _internal_extension(index); } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* DescriptorProto::_internal_add_extension() { - return extension_.Add(); + return _impl_.extension_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* DescriptorProto::add_extension() { ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* _add = _internal_add_extension(); @@ -9595,37 +9651,37 @@ inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* DescriptorProto::add_exten inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto >& DescriptorProto::extension() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension) - return extension_; + return _impl_.extension_; } // repeated .google.protobuf.DescriptorProto nested_type = 3; inline int DescriptorProto::_internal_nested_type_size() const { - return nested_type_.size(); + return _impl_.nested_type_.size(); } inline int DescriptorProto::nested_type_size() const { return _internal_nested_type_size(); } inline void DescriptorProto::clear_nested_type() { - nested_type_.Clear(); + _impl_.nested_type_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto* DescriptorProto::mutable_nested_type(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.nested_type) - return nested_type_.Mutable(index); + return _impl_.nested_type_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >* DescriptorProto::mutable_nested_type() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.nested_type) - return &nested_type_; + return &_impl_.nested_type_; } inline const ::PROTOBUF_NAMESPACE_ID::DescriptorProto& DescriptorProto::_internal_nested_type(int index) const { - return nested_type_.Get(index); + return _impl_.nested_type_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::DescriptorProto& DescriptorProto::nested_type(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.nested_type) return _internal_nested_type(index); } inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto* DescriptorProto::_internal_add_nested_type() { - return nested_type_.Add(); + return _impl_.nested_type_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto* DescriptorProto::add_nested_type() { ::PROTOBUF_NAMESPACE_ID::DescriptorProto* _add = _internal_add_nested_type(); @@ -9635,37 +9691,37 @@ inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto* DescriptorProto::add_nested_typ inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto >& DescriptorProto::nested_type() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.nested_type) - return nested_type_; + return _impl_.nested_type_; } // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; inline int DescriptorProto::_internal_enum_type_size() const { - return enum_type_.size(); + return _impl_.enum_type_.size(); } inline int DescriptorProto::enum_type_size() const { return _internal_enum_type_size(); } inline void DescriptorProto::clear_enum_type() { - enum_type_.Clear(); + _impl_.enum_type_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* DescriptorProto::mutable_enum_type(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.enum_type) - return enum_type_.Mutable(index); + return _impl_.enum_type_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >* DescriptorProto::mutable_enum_type() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.enum_type) - return &enum_type_; + return &_impl_.enum_type_; } inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto& DescriptorProto::_internal_enum_type(int index) const { - return enum_type_.Get(index); + return _impl_.enum_type_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto& DescriptorProto::enum_type(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.enum_type) return _internal_enum_type(index); } inline ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* DescriptorProto::_internal_add_enum_type() { - return enum_type_.Add(); + return _impl_.enum_type_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* DescriptorProto::add_enum_type() { ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* _add = _internal_add_enum_type(); @@ -9675,37 +9731,37 @@ inline ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* DescriptorProto::add_enum_t inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto >& DescriptorProto::enum_type() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.enum_type) - return enum_type_; + return _impl_.enum_type_; } // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; inline int DescriptorProto::_internal_extension_range_size() const { - return extension_range_.size(); + return _impl_.extension_range_.size(); } inline int DescriptorProto::extension_range_size() const { return _internal_extension_range_size(); } inline void DescriptorProto::clear_extension_range() { - extension_range_.Clear(); + _impl_.extension_range_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* DescriptorProto::mutable_extension_range(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension_range) - return extension_range_.Mutable(index); + return _impl_.extension_range_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange >* DescriptorProto::mutable_extension_range() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension_range) - return &extension_range_; + return &_impl_.extension_range_; } inline const ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange& DescriptorProto::_internal_extension_range(int index) const { - return extension_range_.Get(index); + return _impl_.extension_range_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange& DescriptorProto::extension_range(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension_range) return _internal_extension_range(index); } inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* DescriptorProto::_internal_add_extension_range() { - return extension_range_.Add(); + return _impl_.extension_range_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* DescriptorProto::add_extension_range() { ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* _add = _internal_add_extension_range(); @@ -9715,37 +9771,37 @@ inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* DescriptorProto: inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange >& DescriptorProto::extension_range() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension_range) - return extension_range_; + return _impl_.extension_range_; } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; inline int DescriptorProto::_internal_oneof_decl_size() const { - return oneof_decl_.size(); + return _impl_.oneof_decl_.size(); } inline int DescriptorProto::oneof_decl_size() const { return _internal_oneof_decl_size(); } inline void DescriptorProto::clear_oneof_decl() { - oneof_decl_.Clear(); + _impl_.oneof_decl_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* DescriptorProto::mutable_oneof_decl(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.oneof_decl) - return oneof_decl_.Mutable(index); + return _impl_.oneof_decl_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto >* DescriptorProto::mutable_oneof_decl() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.oneof_decl) - return &oneof_decl_; + return &_impl_.oneof_decl_; } inline const ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto& DescriptorProto::_internal_oneof_decl(int index) const { - return oneof_decl_.Get(index); + return _impl_.oneof_decl_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto& DescriptorProto::oneof_decl(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.oneof_decl) return _internal_oneof_decl(index); } inline ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* DescriptorProto::_internal_add_oneof_decl() { - return oneof_decl_.Add(); + return _impl_.oneof_decl_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* DescriptorProto::add_oneof_decl() { ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* _add = _internal_add_oneof_decl(); @@ -9755,24 +9811,24 @@ inline ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* DescriptorProto::add_oneof inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto >& DescriptorProto::oneof_decl() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.oneof_decl) - return oneof_decl_; + return _impl_.oneof_decl_; } // optional .google.protobuf.MessageOptions options = 7; inline bool DescriptorProto::_internal_has_options() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || options_ != nullptr); + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr); return value; } inline bool DescriptorProto::has_options() const { return _internal_has_options(); } inline void DescriptorProto::clear_options() { - if (options_ != nullptr) options_->Clear(); - _has_bits_[0] &= ~0x00000002u; + if (_impl_.options_ != nullptr) _impl_.options_->Clear(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const ::PROTOBUF_NAMESPACE_ID::MessageOptions& DescriptorProto::_internal_options() const { - const ::PROTOBUF_NAMESPACE_ID::MessageOptions* p = options_; + const ::PROTOBUF_NAMESPACE_ID::MessageOptions* p = _impl_.options_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::MessageOptions&>( ::PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_); } @@ -9783,20 +9839,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::MessageOptions& DescriptorProto::options() inline void DescriptorProto::unsafe_arena_set_allocated_options( ::PROTOBUF_NAMESPACE_ID::MessageOptions* options) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.options_); } - options_ = options; + _impl_.options_ = options; if (options) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.DescriptorProto.options) } inline ::PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::release_options() { - _has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::MessageOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000002u; + ::PROTOBUF_NAMESPACE_ID::MessageOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -9810,18 +9866,18 @@ inline ::PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::release_options } inline ::PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::unsafe_arena_release_options() { // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.options) - _has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::MessageOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000002u; + ::PROTOBUF_NAMESPACE_ID::MessageOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::_internal_mutable_options() { - _has_bits_[0] |= 0x00000002u; - if (options_ == nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.options_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MessageOptions>(GetArenaForAllocation()); - options_ = p; + _impl_.options_ = p; } - return options_; + return _impl_.options_; } inline ::PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::mutable_options() { ::PROTOBUF_NAMESPACE_ID::MessageOptions* _msg = _internal_mutable_options(); @@ -9831,51 +9887,51 @@ inline ::PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::mutable_options inline void DescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID::MessageOptions* options) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete options_; + delete _impl_.options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::MessageOptions>::GetOwningArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); } - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - options_ = options; + _impl_.options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.options) } // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; inline int DescriptorProto::_internal_reserved_range_size() const { - return reserved_range_.size(); + return _impl_.reserved_range_.size(); } inline int DescriptorProto::reserved_range_size() const { return _internal_reserved_range_size(); } inline void DescriptorProto::clear_reserved_range() { - reserved_range_.Clear(); + _impl_.reserved_range_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* DescriptorProto::mutable_reserved_range(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_range) - return reserved_range_.Mutable(index); + return _impl_.reserved_range_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange >* DescriptorProto::mutable_reserved_range() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_range) - return &reserved_range_; + return &_impl_.reserved_range_; } inline const ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange& DescriptorProto::_internal_reserved_range(int index) const { - return reserved_range_.Get(index); + return _impl_.reserved_range_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange& DescriptorProto::reserved_range(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_range) return _internal_reserved_range(index); } inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* DescriptorProto::_internal_add_reserved_range() { - return reserved_range_.Add(); + return _impl_.reserved_range_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* DescriptorProto::add_reserved_range() { ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* _add = _internal_add_reserved_range(); @@ -9885,18 +9941,18 @@ inline ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* DescriptorProto:: inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange >& DescriptorProto::reserved_range() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_range) - return reserved_range_; + return _impl_.reserved_range_; } // repeated string reserved_name = 10; inline int DescriptorProto::_internal_reserved_name_size() const { - return reserved_name_.size(); + return _impl_.reserved_name_.size(); } inline int DescriptorProto::reserved_name_size() const { return _internal_reserved_name_size(); } inline void DescriptorProto::clear_reserved_name() { - reserved_name_.Clear(); + _impl_.reserved_name_.Clear(); } inline std::string* DescriptorProto::add_reserved_name() { std::string* _s = _internal_add_reserved_name(); @@ -9904,7 +9960,7 @@ inline std::string* DescriptorProto::add_reserved_name() { return _s; } inline const std::string& DescriptorProto::_internal_reserved_name(int index) const { - return reserved_name_.Get(index); + return _impl_.reserved_name_.Get(index); } inline const std::string& DescriptorProto::reserved_name(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_name) @@ -9912,55 +9968,55 @@ inline const std::string& DescriptorProto::reserved_name(int index) const { } inline std::string* DescriptorProto::mutable_reserved_name(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_name) - return reserved_name_.Mutable(index); + return _impl_.reserved_name_.Mutable(index); } inline void DescriptorProto::set_reserved_name(int index, const std::string& value) { - reserved_name_.Mutable(index)->assign(value); + _impl_.reserved_name_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) } inline void DescriptorProto::set_reserved_name(int index, std::string&& value) { - reserved_name_.Mutable(index)->assign(std::move(value)); + _impl_.reserved_name_.Mutable(index)->assign(std::move(value)); // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name) } inline void DescriptorProto::set_reserved_name(int index, const char* value) { GOOGLE_DCHECK(value != nullptr); - reserved_name_.Mutable(index)->assign(value); + _impl_.reserved_name_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name) } inline void DescriptorProto::set_reserved_name(int index, const char* value, size_t size) { - reserved_name_.Mutable(index)->assign( + _impl_.reserved_name_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.reserved_name) } inline std::string* DescriptorProto::_internal_add_reserved_name() { - return reserved_name_.Add(); + return _impl_.reserved_name_.Add(); } inline void DescriptorProto::add_reserved_name(const std::string& value) { - reserved_name_.Add()->assign(value); + _impl_.reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) } inline void DescriptorProto::add_reserved_name(std::string&& value) { - reserved_name_.Add(std::move(value)); + _impl_.reserved_name_.Add(std::move(value)); // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name) } inline void DescriptorProto::add_reserved_name(const char* value) { GOOGLE_DCHECK(value != nullptr); - reserved_name_.Add()->assign(value); + _impl_.reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name) } inline void DescriptorProto::add_reserved_name(const char* value, size_t size) { - reserved_name_.Add()->assign(reinterpret_cast<const char*>(value), size); + _impl_.reserved_name_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.DescriptorProto.reserved_name) } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>& DescriptorProto::reserved_name() const { // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_name) - return reserved_name_; + return _impl_.reserved_name_; } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>* DescriptorProto::mutable_reserved_name() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_name) - return &reserved_name_; + return &_impl_.reserved_name_; } // ------------------------------------------------------------------- @@ -9969,32 +10025,32 @@ DescriptorProto::mutable_reserved_name() { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int ExtensionRangeOptions::_internal_uninterpreted_option_size() const { - return uninterpreted_option_.size(); + return _impl_.uninterpreted_option_.size(); } inline int ExtensionRangeOptions::uninterpreted_option_size() const { return _internal_uninterpreted_option_size(); } inline void ExtensionRangeOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); + _impl_.uninterpreted_option_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* ExtensionRangeOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.ExtensionRangeOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); + return _impl_.uninterpreted_option_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >* ExtensionRangeOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.ExtensionRangeOptions.uninterpreted_option) - return &uninterpreted_option_; + return &_impl_.uninterpreted_option_; } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& ExtensionRangeOptions::_internal_uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); + return _impl_.uninterpreted_option_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& ExtensionRangeOptions::uninterpreted_option(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.ExtensionRangeOptions.uninterpreted_option) return _internal_uninterpreted_option(index); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* ExtensionRangeOptions::_internal_add_uninterpreted_option() { - return uninterpreted_option_.Add(); + return _impl_.uninterpreted_option_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* ExtensionRangeOptions::add_uninterpreted_option() { ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* _add = _internal_add_uninterpreted_option(); @@ -10004,7 +10060,7 @@ inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* ExtensionRangeOptions::add_ inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >& ExtensionRangeOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.ExtensionRangeOptions.uninterpreted_option) - return uninterpreted_option_; + return _impl_.uninterpreted_option_; } // ------------------------------------------------------------------- @@ -10013,15 +10069,15 @@ ExtensionRangeOptions::uninterpreted_option() const { // optional string name = 1; inline bool FieldDescriptorProto::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool FieldDescriptorProto::has_name() const { return _internal_has_name(); } inline void FieldDescriptorProto::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.name_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& FieldDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name) @@ -10030,8 +10086,8 @@ inline const std::string& FieldDescriptorProto::name() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FieldDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name) } inline std::string* FieldDescriptorProto::mutable_name() { @@ -10040,41 +10096,40 @@ inline std::string* FieldDescriptorProto::mutable_name() { return _s; } inline const std::string& FieldDescriptorProto::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void FieldDescriptorProto::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.name) if (!_internal_has_name()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FieldDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.name) @@ -10082,26 +10137,26 @@ inline void FieldDescriptorProto::set_allocated_name(std::string* name) { // optional int32 number = 3; inline bool FieldDescriptorProto::_internal_has_number() const { - bool value = (_has_bits_[0] & 0x00000040u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; return value; } inline bool FieldDescriptorProto::has_number() const { return _internal_has_number(); } inline void FieldDescriptorProto::clear_number() { - number_ = 0; - _has_bits_[0] &= ~0x00000040u; + _impl_.number_ = 0; + _impl_._has_bits_[0] &= ~0x00000040u; } inline int32_t FieldDescriptorProto::_internal_number() const { - return number_; + return _impl_.number_; } inline int32_t FieldDescriptorProto::number() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.number) return _internal_number(); } inline void FieldDescriptorProto::_internal_set_number(int32_t value) { - _has_bits_[0] |= 0x00000040u; - number_ = value; + _impl_._has_bits_[0] |= 0x00000040u; + _impl_.number_ = value; } inline void FieldDescriptorProto::set_number(int32_t value) { _internal_set_number(value); @@ -10110,18 +10165,18 @@ inline void FieldDescriptorProto::set_number(int32_t value) { // optional .google.protobuf.FieldDescriptorProto.Label label = 4; inline bool FieldDescriptorProto::_internal_has_label() const { - bool value = (_has_bits_[0] & 0x00000200u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; return value; } inline bool FieldDescriptorProto::has_label() const { return _internal_has_label(); } inline void FieldDescriptorProto::clear_label() { - label_ = 1; - _has_bits_[0] &= ~0x00000200u; + _impl_.label_ = 1; + _impl_._has_bits_[0] &= ~0x00000200u; } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label FieldDescriptorProto::_internal_label() const { - return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label >(label_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label >(_impl_.label_); } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label FieldDescriptorProto::label() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.label) @@ -10129,8 +10184,8 @@ inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label FieldDescriptorProto: } inline void FieldDescriptorProto::_internal_set_label(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label value) { assert(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label_IsValid(value)); - _has_bits_[0] |= 0x00000200u; - label_ = value; + _impl_._has_bits_[0] |= 0x00000200u; + _impl_.label_ = value; } inline void FieldDescriptorProto::set_label(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label value) { _internal_set_label(value); @@ -10139,18 +10194,18 @@ inline void FieldDescriptorProto::set_label(::PROTOBUF_NAMESPACE_ID::FieldDescri // optional .google.protobuf.FieldDescriptorProto.Type type = 5; inline bool FieldDescriptorProto::_internal_has_type() const { - bool value = (_has_bits_[0] & 0x00000400u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; return value; } inline bool FieldDescriptorProto::has_type() const { return _internal_has_type(); } inline void FieldDescriptorProto::clear_type() { - type_ = 1; - _has_bits_[0] &= ~0x00000400u; + _impl_.type_ = 1; + _impl_._has_bits_[0] &= ~0x00000400u; } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type FieldDescriptorProto::_internal_type() const { - return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type >(type_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type >(_impl_.type_); } inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type FieldDescriptorProto::type() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type) @@ -10158,8 +10213,8 @@ inline ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type FieldDescriptorProto:: } inline void FieldDescriptorProto::_internal_set_type(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type value) { assert(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type_IsValid(value)); - _has_bits_[0] |= 0x00000400u; - type_ = value; + _impl_._has_bits_[0] |= 0x00000400u; + _impl_.type_ = value; } inline void FieldDescriptorProto::set_type(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type value) { _internal_set_type(value); @@ -10168,15 +10223,15 @@ inline void FieldDescriptorProto::set_type(::PROTOBUF_NAMESPACE_ID::FieldDescrip // optional string type_name = 6; inline bool FieldDescriptorProto::_internal_has_type_name() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool FieldDescriptorProto::has_type_name() const { return _internal_has_type_name(); } inline void FieldDescriptorProto::clear_type_name() { - type_name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000004u; + _impl_.type_name_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; } inline const std::string& FieldDescriptorProto::type_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name) @@ -10185,8 +10240,8 @@ inline const std::string& FieldDescriptorProto::type_name() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FieldDescriptorProto::set_type_name(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000004u; - type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.type_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name) } inline std::string* FieldDescriptorProto::mutable_type_name() { @@ -10195,41 +10250,40 @@ inline std::string* FieldDescriptorProto::mutable_type_name() { return _s; } inline const std::string& FieldDescriptorProto::_internal_type_name() const { - return type_name_.Get(); + return _impl_.type_name_.Get(); } inline void FieldDescriptorProto::_internal_set_type_name(const std::string& value) { - _has_bits_[0] |= 0x00000004u; - type_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.type_name_.Set(value, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::_internal_mutable_type_name() { - _has_bits_[0] |= 0x00000004u; - return type_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.type_name_.Mutable(GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::release_type_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.type_name) if (!_internal_has_type_name()) { return nullptr; } - _has_bits_[0] &= ~0x00000004u; - auto* p = type_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.type_name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (type_name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.type_name_.IsDefault()) { + _impl_.type_name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FieldDescriptorProto::set_allocated_type_name(std::string* type_name) { if (type_name != nullptr) { - _has_bits_[0] |= 0x00000004u; + _impl_._has_bits_[0] |= 0x00000004u; } else { - _has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000004u; } - type_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_name, - GetArenaForAllocation()); + _impl_.type_name_.SetAllocated(type_name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (type_name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.type_name_.IsDefault()) { + _impl_.type_name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.type_name) @@ -10237,15 +10291,15 @@ inline void FieldDescriptorProto::set_allocated_type_name(std::string* type_name // optional string extendee = 2; inline bool FieldDescriptorProto::_internal_has_extendee() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool FieldDescriptorProto::has_extendee() const { return _internal_has_extendee(); } inline void FieldDescriptorProto::clear_extendee() { - extendee_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; + _impl_.extendee_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const std::string& FieldDescriptorProto::extendee() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee) @@ -10254,8 +10308,8 @@ inline const std::string& FieldDescriptorProto::extendee() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FieldDescriptorProto::set_extendee(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000002u; - extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.extendee_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee) } inline std::string* FieldDescriptorProto::mutable_extendee() { @@ -10264,41 +10318,40 @@ inline std::string* FieldDescriptorProto::mutable_extendee() { return _s; } inline const std::string& FieldDescriptorProto::_internal_extendee() const { - return extendee_.Get(); + return _impl_.extendee_.Get(); } inline void FieldDescriptorProto::_internal_set_extendee(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - extendee_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.extendee_.Set(value, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::_internal_mutable_extendee() { - _has_bits_[0] |= 0x00000002u; - return extendee_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.extendee_.Mutable(GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::release_extendee() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.extendee) if (!_internal_has_extendee()) { return nullptr; } - _has_bits_[0] &= ~0x00000002u; - auto* p = extendee_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.extendee_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (extendee_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.extendee_.IsDefault()) { + _impl_.extendee_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FieldDescriptorProto::set_allocated_extendee(std::string* extendee) { if (extendee != nullptr) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - extendee_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), extendee, - GetArenaForAllocation()); + _impl_.extendee_.SetAllocated(extendee, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (extendee_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.extendee_.IsDefault()) { + _impl_.extendee_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.extendee) @@ -10306,15 +10359,15 @@ inline void FieldDescriptorProto::set_allocated_extendee(std::string* extendee) // optional string default_value = 7; inline bool FieldDescriptorProto::_internal_has_default_value() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } inline bool FieldDescriptorProto::has_default_value() const { return _internal_has_default_value(); } inline void FieldDescriptorProto::clear_default_value() { - default_value_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000008u; + _impl_.default_value_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000008u; } inline const std::string& FieldDescriptorProto::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value) @@ -10323,8 +10376,8 @@ inline const std::string& FieldDescriptorProto::default_value() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FieldDescriptorProto::set_default_value(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000008u; - default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.default_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value) } inline std::string* FieldDescriptorProto::mutable_default_value() { @@ -10333,41 +10386,40 @@ inline std::string* FieldDescriptorProto::mutable_default_value() { return _s; } inline const std::string& FieldDescriptorProto::_internal_default_value() const { - return default_value_.Get(); + return _impl_.default_value_.Get(); } inline void FieldDescriptorProto::_internal_set_default_value(const std::string& value) { - _has_bits_[0] |= 0x00000008u; - default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.default_value_.Set(value, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::_internal_mutable_default_value() { - _has_bits_[0] |= 0x00000008u; - return default_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000008u; + return _impl_.default_value_.Mutable(GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::release_default_value() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.default_value) if (!_internal_has_default_value()) { return nullptr; } - _has_bits_[0] &= ~0x00000008u; - auto* p = default_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000008u; + auto* p = _impl_.default_value_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (default_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.default_value_.IsDefault()) { + _impl_.default_value_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FieldDescriptorProto::set_allocated_default_value(std::string* default_value) { if (default_value != nullptr) { - _has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000008u; } else { - _has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000008u; } - default_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), default_value, - GetArenaForAllocation()); + _impl_.default_value_.SetAllocated(default_value, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (default_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.default_value_.IsDefault()) { + _impl_.default_value_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.default_value) @@ -10375,26 +10427,26 @@ inline void FieldDescriptorProto::set_allocated_default_value(std::string* defau // optional int32 oneof_index = 9; inline bool FieldDescriptorProto::_internal_has_oneof_index() const { - bool value = (_has_bits_[0] & 0x00000080u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; return value; } inline bool FieldDescriptorProto::has_oneof_index() const { return _internal_has_oneof_index(); } inline void FieldDescriptorProto::clear_oneof_index() { - oneof_index_ = 0; - _has_bits_[0] &= ~0x00000080u; + _impl_.oneof_index_ = 0; + _impl_._has_bits_[0] &= ~0x00000080u; } inline int32_t FieldDescriptorProto::_internal_oneof_index() const { - return oneof_index_; + return _impl_.oneof_index_; } inline int32_t FieldDescriptorProto::oneof_index() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.oneof_index) return _internal_oneof_index(); } inline void FieldDescriptorProto::_internal_set_oneof_index(int32_t value) { - _has_bits_[0] |= 0x00000080u; - oneof_index_ = value; + _impl_._has_bits_[0] |= 0x00000080u; + _impl_.oneof_index_ = value; } inline void FieldDescriptorProto::set_oneof_index(int32_t value) { _internal_set_oneof_index(value); @@ -10403,15 +10455,15 @@ inline void FieldDescriptorProto::set_oneof_index(int32_t value) { // optional string json_name = 10; inline bool FieldDescriptorProto::_internal_has_json_name() const { - bool value = (_has_bits_[0] & 0x00000010u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; return value; } inline bool FieldDescriptorProto::has_json_name() const { return _internal_has_json_name(); } inline void FieldDescriptorProto::clear_json_name() { - json_name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000010u; + _impl_.json_name_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000010u; } inline const std::string& FieldDescriptorProto::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name) @@ -10420,8 +10472,8 @@ inline const std::string& FieldDescriptorProto::json_name() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FieldDescriptorProto::set_json_name(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000010u; - json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.json_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name) } inline std::string* FieldDescriptorProto::mutable_json_name() { @@ -10430,41 +10482,40 @@ inline std::string* FieldDescriptorProto::mutable_json_name() { return _s; } inline const std::string& FieldDescriptorProto::_internal_json_name() const { - return json_name_.Get(); + return _impl_.json_name_.Get(); } inline void FieldDescriptorProto::_internal_set_json_name(const std::string& value) { - _has_bits_[0] |= 0x00000010u; - json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.json_name_.Set(value, GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::_internal_mutable_json_name() { - _has_bits_[0] |= 0x00000010u; - return json_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000010u; + return _impl_.json_name_.Mutable(GetArenaForAllocation()); } inline std::string* FieldDescriptorProto::release_json_name() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.json_name) if (!_internal_has_json_name()) { return nullptr; } - _has_bits_[0] &= ~0x00000010u; - auto* p = json_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000010u; + auto* p = _impl_.json_name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (json_name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.json_name_.IsDefault()) { + _impl_.json_name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FieldDescriptorProto::set_allocated_json_name(std::string* json_name) { if (json_name != nullptr) { - _has_bits_[0] |= 0x00000010u; + _impl_._has_bits_[0] |= 0x00000010u; } else { - _has_bits_[0] &= ~0x00000010u; + _impl_._has_bits_[0] &= ~0x00000010u; } - json_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), json_name, - GetArenaForAllocation()); + _impl_.json_name_.SetAllocated(json_name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (json_name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.json_name_.IsDefault()) { + _impl_.json_name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.json_name) @@ -10472,19 +10523,19 @@ inline void FieldDescriptorProto::set_allocated_json_name(std::string* json_name // optional .google.protobuf.FieldOptions options = 8; inline bool FieldDescriptorProto::_internal_has_options() const { - bool value = (_has_bits_[0] & 0x00000020u) != 0; - PROTOBUF_ASSUME(!value || options_ != nullptr); + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; + PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr); return value; } inline bool FieldDescriptorProto::has_options() const { return _internal_has_options(); } inline void FieldDescriptorProto::clear_options() { - if (options_ != nullptr) options_->Clear(); - _has_bits_[0] &= ~0x00000020u; + if (_impl_.options_ != nullptr) _impl_.options_->Clear(); + _impl_._has_bits_[0] &= ~0x00000020u; } inline const ::PROTOBUF_NAMESPACE_ID::FieldOptions& FieldDescriptorProto::_internal_options() const { - const ::PROTOBUF_NAMESPACE_ID::FieldOptions* p = options_; + const ::PROTOBUF_NAMESPACE_ID::FieldOptions* p = _impl_.options_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::FieldOptions&>( ::PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_); } @@ -10495,20 +10546,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::FieldOptions& FieldDescriptorProto::option inline void FieldDescriptorProto::unsafe_arena_set_allocated_options( ::PROTOBUF_NAMESPACE_ID::FieldOptions* options) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.options_); } - options_ = options; + _impl_.options_ = options; if (options) { - _has_bits_[0] |= 0x00000020u; + _impl_._has_bits_[0] |= 0x00000020u; } else { - _has_bits_[0] &= ~0x00000020u; + _impl_._has_bits_[0] &= ~0x00000020u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.FieldDescriptorProto.options) } inline ::PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::release_options() { - _has_bits_[0] &= ~0x00000020u; - ::PROTOBUF_NAMESPACE_ID::FieldOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000020u; + ::PROTOBUF_NAMESPACE_ID::FieldOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -10522,18 +10573,18 @@ inline ::PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::release_opti } inline ::PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::unsafe_arena_release_options() { // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.options) - _has_bits_[0] &= ~0x00000020u; - ::PROTOBUF_NAMESPACE_ID::FieldOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000020u; + ::PROTOBUF_NAMESPACE_ID::FieldOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::_internal_mutable_options() { - _has_bits_[0] |= 0x00000020u; - if (options_ == nullptr) { + _impl_._has_bits_[0] |= 0x00000020u; + if (_impl_.options_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldOptions>(GetArenaForAllocation()); - options_ = p; + _impl_.options_ = p; } - return options_; + return _impl_.options_; } inline ::PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::mutable_options() { ::PROTOBUF_NAMESPACE_ID::FieldOptions* _msg = _internal_mutable_options(); @@ -10543,45 +10594,45 @@ inline ::PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::mutable_opti inline void FieldDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID::FieldOptions* options) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete options_; + delete _impl_.options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::FieldOptions>::GetOwningArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); } - _has_bits_[0] |= 0x00000020u; + _impl_._has_bits_[0] |= 0x00000020u; } else { - _has_bits_[0] &= ~0x00000020u; + _impl_._has_bits_[0] &= ~0x00000020u; } - options_ = options; + _impl_.options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options) } // optional bool proto3_optional = 17; inline bool FieldDescriptorProto::_internal_has_proto3_optional() const { - bool value = (_has_bits_[0] & 0x00000100u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; return value; } inline bool FieldDescriptorProto::has_proto3_optional() const { return _internal_has_proto3_optional(); } inline void FieldDescriptorProto::clear_proto3_optional() { - proto3_optional_ = false; - _has_bits_[0] &= ~0x00000100u; + _impl_.proto3_optional_ = false; + _impl_._has_bits_[0] &= ~0x00000100u; } inline bool FieldDescriptorProto::_internal_proto3_optional() const { - return proto3_optional_; + return _impl_.proto3_optional_; } inline bool FieldDescriptorProto::proto3_optional() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.proto3_optional) return _internal_proto3_optional(); } inline void FieldDescriptorProto::_internal_set_proto3_optional(bool value) { - _has_bits_[0] |= 0x00000100u; - proto3_optional_ = value; + _impl_._has_bits_[0] |= 0x00000100u; + _impl_.proto3_optional_ = value; } inline void FieldDescriptorProto::set_proto3_optional(bool value) { _internal_set_proto3_optional(value); @@ -10594,15 +10645,15 @@ inline void FieldDescriptorProto::set_proto3_optional(bool value) { // optional string name = 1; inline bool OneofDescriptorProto::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool OneofDescriptorProto::has_name() const { return _internal_has_name(); } inline void OneofDescriptorProto::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.name_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& OneofDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name) @@ -10611,8 +10662,8 @@ inline const std::string& OneofDescriptorProto::name() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void OneofDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name) } inline std::string* OneofDescriptorProto::mutable_name() { @@ -10621,41 +10672,40 @@ inline std::string* OneofDescriptorProto::mutable_name() { return _s; } inline const std::string& OneofDescriptorProto::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void OneofDescriptorProto::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* OneofDescriptorProto::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* OneofDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.name) if (!_internal_has_name()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void OneofDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.name) @@ -10663,19 +10713,19 @@ inline void OneofDescriptorProto::set_allocated_name(std::string* name) { // optional .google.protobuf.OneofOptions options = 2; inline bool OneofDescriptorProto::_internal_has_options() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || options_ != nullptr); + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr); return value; } inline bool OneofDescriptorProto::has_options() const { return _internal_has_options(); } inline void OneofDescriptorProto::clear_options() { - if (options_ != nullptr) options_->Clear(); - _has_bits_[0] &= ~0x00000002u; + if (_impl_.options_ != nullptr) _impl_.options_->Clear(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const ::PROTOBUF_NAMESPACE_ID::OneofOptions& OneofDescriptorProto::_internal_options() const { - const ::PROTOBUF_NAMESPACE_ID::OneofOptions* p = options_; + const ::PROTOBUF_NAMESPACE_ID::OneofOptions* p = _impl_.options_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::OneofOptions&>( ::PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_); } @@ -10686,20 +10736,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::OneofOptions& OneofDescriptorProto::option inline void OneofDescriptorProto::unsafe_arena_set_allocated_options( ::PROTOBUF_NAMESPACE_ID::OneofOptions* options) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.options_); } - options_ = options; + _impl_.options_ = options; if (options) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.OneofDescriptorProto.options) } inline ::PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::release_options() { - _has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::OneofOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000002u; + ::PROTOBUF_NAMESPACE_ID::OneofOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -10713,18 +10763,18 @@ inline ::PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::release_opti } inline ::PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::unsafe_arena_release_options() { // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.options) - _has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::OneofOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000002u; + ::PROTOBUF_NAMESPACE_ID::OneofOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::_internal_mutable_options() { - _has_bits_[0] |= 0x00000002u; - if (options_ == nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.options_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofOptions>(GetArenaForAllocation()); - options_ = p; + _impl_.options_ = p; } - return options_; + return _impl_.options_; } inline ::PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::mutable_options() { ::PROTOBUF_NAMESPACE_ID::OneofOptions* _msg = _internal_mutable_options(); @@ -10734,20 +10784,20 @@ inline ::PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::mutable_opti inline void OneofDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID::OneofOptions* options) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete options_; + delete _impl_.options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::OneofOptions>::GetOwningArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); } - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - options_ = options; + _impl_.options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.options) } @@ -10757,26 +10807,26 @@ inline void OneofDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID: // optional int32 start = 1; inline bool EnumDescriptorProto_EnumReservedRange::_internal_has_start() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool EnumDescriptorProto_EnumReservedRange::has_start() const { return _internal_has_start(); } inline void EnumDescriptorProto_EnumReservedRange::clear_start() { - start_ = 0; - _has_bits_[0] &= ~0x00000001u; + _impl_.start_ = 0; + _impl_._has_bits_[0] &= ~0x00000001u; } inline int32_t EnumDescriptorProto_EnumReservedRange::_internal_start() const { - return start_; + return _impl_.start_; } inline int32_t EnumDescriptorProto_EnumReservedRange::start() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.EnumReservedRange.start) return _internal_start(); } inline void EnumDescriptorProto_EnumReservedRange::_internal_set_start(int32_t value) { - _has_bits_[0] |= 0x00000001u; - start_ = value; + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.start_ = value; } inline void EnumDescriptorProto_EnumReservedRange::set_start(int32_t value) { _internal_set_start(value); @@ -10785,26 +10835,26 @@ inline void EnumDescriptorProto_EnumReservedRange::set_start(int32_t value) { // optional int32 end = 2; inline bool EnumDescriptorProto_EnumReservedRange::_internal_has_end() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool EnumDescriptorProto_EnumReservedRange::has_end() const { return _internal_has_end(); } inline void EnumDescriptorProto_EnumReservedRange::clear_end() { - end_ = 0; - _has_bits_[0] &= ~0x00000002u; + _impl_.end_ = 0; + _impl_._has_bits_[0] &= ~0x00000002u; } inline int32_t EnumDescriptorProto_EnumReservedRange::_internal_end() const { - return end_; + return _impl_.end_; } inline int32_t EnumDescriptorProto_EnumReservedRange::end() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.EnumReservedRange.end) return _internal_end(); } inline void EnumDescriptorProto_EnumReservedRange::_internal_set_end(int32_t value) { - _has_bits_[0] |= 0x00000002u; - end_ = value; + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.end_ = value; } inline void EnumDescriptorProto_EnumReservedRange::set_end(int32_t value) { _internal_set_end(value); @@ -10817,15 +10867,15 @@ inline void EnumDescriptorProto_EnumReservedRange::set_end(int32_t value) { // optional string name = 1; inline bool EnumDescriptorProto::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool EnumDescriptorProto::has_name() const { return _internal_has_name(); } inline void EnumDescriptorProto::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.name_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& EnumDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name) @@ -10834,8 +10884,8 @@ inline const std::string& EnumDescriptorProto::name() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void EnumDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name) } inline std::string* EnumDescriptorProto::mutable_name() { @@ -10844,41 +10894,40 @@ inline std::string* EnumDescriptorProto::mutable_name() { return _s; } inline const std::string& EnumDescriptorProto::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void EnumDescriptorProto::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* EnumDescriptorProto::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* EnumDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.name) if (!_internal_has_name()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void EnumDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.name) @@ -10886,32 +10935,32 @@ inline void EnumDescriptorProto::set_allocated_name(std::string* name) { // repeated .google.protobuf.EnumValueDescriptorProto value = 2; inline int EnumDescriptorProto::_internal_value_size() const { - return value_.size(); + return _impl_.value_.size(); } inline int EnumDescriptorProto::value_size() const { return _internal_value_size(); } inline void EnumDescriptorProto::clear_value() { - value_.Clear(); + _impl_.value_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* EnumDescriptorProto::mutable_value(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.value) - return value_.Mutable(index); + return _impl_.value_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto >* EnumDescriptorProto::mutable_value() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.value) - return &value_; + return &_impl_.value_; } inline const ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto& EnumDescriptorProto::_internal_value(int index) const { - return value_.Get(index); + return _impl_.value_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto& EnumDescriptorProto::value(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.value) return _internal_value(index); } inline ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* EnumDescriptorProto::_internal_add_value() { - return value_.Add(); + return _impl_.value_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* EnumDescriptorProto::add_value() { ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* _add = _internal_add_value(); @@ -10921,24 +10970,24 @@ inline ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* EnumDescriptorProto::a inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto >& EnumDescriptorProto::value() const { // @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.value) - return value_; + return _impl_.value_; } // optional .google.protobuf.EnumOptions options = 3; inline bool EnumDescriptorProto::_internal_has_options() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || options_ != nullptr); + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr); return value; } inline bool EnumDescriptorProto::has_options() const { return _internal_has_options(); } inline void EnumDescriptorProto::clear_options() { - if (options_ != nullptr) options_->Clear(); - _has_bits_[0] &= ~0x00000002u; + if (_impl_.options_ != nullptr) _impl_.options_->Clear(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const ::PROTOBUF_NAMESPACE_ID::EnumOptions& EnumDescriptorProto::_internal_options() const { - const ::PROTOBUF_NAMESPACE_ID::EnumOptions* p = options_; + const ::PROTOBUF_NAMESPACE_ID::EnumOptions* p = _impl_.options_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::EnumOptions&>( ::PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_); } @@ -10949,20 +10998,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::EnumOptions& EnumDescriptorProto::options( inline void EnumDescriptorProto::unsafe_arena_set_allocated_options( ::PROTOBUF_NAMESPACE_ID::EnumOptions* options) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.options_); } - options_ = options; + _impl_.options_ = options; if (options) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumDescriptorProto.options) } inline ::PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::release_options() { - _has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::EnumOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000002u; + ::PROTOBUF_NAMESPACE_ID::EnumOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -10976,18 +11025,18 @@ inline ::PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::release_option } inline ::PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::unsafe_arena_release_options() { // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.options) - _has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::EnumOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000002u; + ::PROTOBUF_NAMESPACE_ID::EnumOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::_internal_mutable_options() { - _has_bits_[0] |= 0x00000002u; - if (options_ == nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.options_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumOptions>(GetArenaForAllocation()); - options_ = p; + _impl_.options_ = p; } - return options_; + return _impl_.options_; } inline ::PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::mutable_options() { ::PROTOBUF_NAMESPACE_ID::EnumOptions* _msg = _internal_mutable_options(); @@ -10997,51 +11046,51 @@ inline ::PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::mutable_option inline void EnumDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID::EnumOptions* options) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete options_; + delete _impl_.options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::EnumOptions>::GetOwningArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); } - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - options_ = options; + _impl_.options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.options) } // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; inline int EnumDescriptorProto::_internal_reserved_range_size() const { - return reserved_range_.size(); + return _impl_.reserved_range_.size(); } inline int EnumDescriptorProto::reserved_range_size() const { return _internal_reserved_range_size(); } inline void EnumDescriptorProto::clear_reserved_range() { - reserved_range_.Clear(); + _impl_.reserved_range_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* EnumDescriptorProto::mutable_reserved_range(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.reserved_range) - return reserved_range_.Mutable(index); + return _impl_.reserved_range_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange >* EnumDescriptorProto::mutable_reserved_range() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.reserved_range) - return &reserved_range_; + return &_impl_.reserved_range_; } inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange& EnumDescriptorProto::_internal_reserved_range(int index) const { - return reserved_range_.Get(index); + return _impl_.reserved_range_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange& EnumDescriptorProto::reserved_range(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.reserved_range) return _internal_reserved_range(index); } inline ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* EnumDescriptorProto::_internal_add_reserved_range() { - return reserved_range_.Add(); + return _impl_.reserved_range_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* EnumDescriptorProto::add_reserved_range() { ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* _add = _internal_add_reserved_range(); @@ -11051,18 +11100,18 @@ inline ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* EnumDescr inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange >& EnumDescriptorProto::reserved_range() const { // @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.reserved_range) - return reserved_range_; + return _impl_.reserved_range_; } // repeated string reserved_name = 5; inline int EnumDescriptorProto::_internal_reserved_name_size() const { - return reserved_name_.size(); + return _impl_.reserved_name_.size(); } inline int EnumDescriptorProto::reserved_name_size() const { return _internal_reserved_name_size(); } inline void EnumDescriptorProto::clear_reserved_name() { - reserved_name_.Clear(); + _impl_.reserved_name_.Clear(); } inline std::string* EnumDescriptorProto::add_reserved_name() { std::string* _s = _internal_add_reserved_name(); @@ -11070,7 +11119,7 @@ inline std::string* EnumDescriptorProto::add_reserved_name() { return _s; } inline const std::string& EnumDescriptorProto::_internal_reserved_name(int index) const { - return reserved_name_.Get(index); + return _impl_.reserved_name_.Get(index); } inline const std::string& EnumDescriptorProto::reserved_name(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.reserved_name) @@ -11078,55 +11127,55 @@ inline const std::string& EnumDescriptorProto::reserved_name(int index) const { } inline std::string* EnumDescriptorProto::mutable_reserved_name(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.reserved_name) - return reserved_name_.Mutable(index); + return _impl_.reserved_name_.Mutable(index); } inline void EnumDescriptorProto::set_reserved_name(int index, const std::string& value) { - reserved_name_.Mutable(index)->assign(value); + _impl_.reserved_name_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.reserved_name) } inline void EnumDescriptorProto::set_reserved_name(int index, std::string&& value) { - reserved_name_.Mutable(index)->assign(std::move(value)); + _impl_.reserved_name_.Mutable(index)->assign(std::move(value)); // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.reserved_name) } inline void EnumDescriptorProto::set_reserved_name(int index, const char* value) { GOOGLE_DCHECK(value != nullptr); - reserved_name_.Mutable(index)->assign(value); + _impl_.reserved_name_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.EnumDescriptorProto.reserved_name) } inline void EnumDescriptorProto::set_reserved_name(int index, const char* value, size_t size) { - reserved_name_.Mutable(index)->assign( + _impl_.reserved_name_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.reserved_name) } inline std::string* EnumDescriptorProto::_internal_add_reserved_name() { - return reserved_name_.Add(); + return _impl_.reserved_name_.Add(); } inline void EnumDescriptorProto::add_reserved_name(const std::string& value) { - reserved_name_.Add()->assign(value); + _impl_.reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.reserved_name) } inline void EnumDescriptorProto::add_reserved_name(std::string&& value) { - reserved_name_.Add(std::move(value)); + _impl_.reserved_name_.Add(std::move(value)); // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.reserved_name) } inline void EnumDescriptorProto::add_reserved_name(const char* value) { GOOGLE_DCHECK(value != nullptr); - reserved_name_.Add()->assign(value); + _impl_.reserved_name_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.EnumDescriptorProto.reserved_name) } inline void EnumDescriptorProto::add_reserved_name(const char* value, size_t size) { - reserved_name_.Add()->assign(reinterpret_cast<const char*>(value), size); + _impl_.reserved_name_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.EnumDescriptorProto.reserved_name) } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>& EnumDescriptorProto::reserved_name() const { // @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.reserved_name) - return reserved_name_; + return _impl_.reserved_name_; } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>* EnumDescriptorProto::mutable_reserved_name() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.reserved_name) - return &reserved_name_; + return &_impl_.reserved_name_; } // ------------------------------------------------------------------- @@ -11135,15 +11184,15 @@ EnumDescriptorProto::mutable_reserved_name() { // optional string name = 1; inline bool EnumValueDescriptorProto::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool EnumValueDescriptorProto::has_name() const { return _internal_has_name(); } inline void EnumValueDescriptorProto::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.name_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& EnumValueDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name) @@ -11152,8 +11201,8 @@ inline const std::string& EnumValueDescriptorProto::name() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void EnumValueDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name) } inline std::string* EnumValueDescriptorProto::mutable_name() { @@ -11162,41 +11211,40 @@ inline std::string* EnumValueDescriptorProto::mutable_name() { return _s; } inline const std::string& EnumValueDescriptorProto::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void EnumValueDescriptorProto::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* EnumValueDescriptorProto::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* EnumValueDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.name) if (!_internal_has_name()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void EnumValueDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.name) @@ -11204,26 +11252,26 @@ inline void EnumValueDescriptorProto::set_allocated_name(std::string* name) { // optional int32 number = 2; inline bool EnumValueDescriptorProto::_internal_has_number() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool EnumValueDescriptorProto::has_number() const { return _internal_has_number(); } inline void EnumValueDescriptorProto::clear_number() { - number_ = 0; - _has_bits_[0] &= ~0x00000004u; + _impl_.number_ = 0; + _impl_._has_bits_[0] &= ~0x00000004u; } inline int32_t EnumValueDescriptorProto::_internal_number() const { - return number_; + return _impl_.number_; } inline int32_t EnumValueDescriptorProto::number() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.number) return _internal_number(); } inline void EnumValueDescriptorProto::_internal_set_number(int32_t value) { - _has_bits_[0] |= 0x00000004u; - number_ = value; + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.number_ = value; } inline void EnumValueDescriptorProto::set_number(int32_t value) { _internal_set_number(value); @@ -11232,19 +11280,19 @@ inline void EnumValueDescriptorProto::set_number(int32_t value) { // optional .google.protobuf.EnumValueOptions options = 3; inline bool EnumValueDescriptorProto::_internal_has_options() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || options_ != nullptr); + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr); return value; } inline bool EnumValueDescriptorProto::has_options() const { return _internal_has_options(); } inline void EnumValueDescriptorProto::clear_options() { - if (options_ != nullptr) options_->Clear(); - _has_bits_[0] &= ~0x00000002u; + if (_impl_.options_ != nullptr) _impl_.options_->Clear(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const ::PROTOBUF_NAMESPACE_ID::EnumValueOptions& EnumValueDescriptorProto::_internal_options() const { - const ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* p = options_; + const ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* p = _impl_.options_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::EnumValueOptions&>( ::PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_); } @@ -11255,20 +11303,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::EnumValueOptions& EnumValueDescriptorProto inline void EnumValueDescriptorProto::unsafe_arena_set_allocated_options( ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* options) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.options_); } - options_ = options; + _impl_.options_ = options; if (options) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValueDescriptorProto.options) } inline ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::release_options() { - _has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000002u; + ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -11282,18 +11330,18 @@ inline ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::rele } inline ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::unsafe_arena_release_options() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.options) - _has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000002u; + ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::_internal_mutable_options() { - _has_bits_[0] |= 0x00000002u; - if (options_ == nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.options_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueOptions>(GetArenaForAllocation()); - options_ = p; + _impl_.options_ = p; } - return options_; + return _impl_.options_; } inline ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::mutable_options() { ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* _msg = _internal_mutable_options(); @@ -11303,20 +11351,20 @@ inline ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::muta inline void EnumValueDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID::EnumValueOptions* options) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete options_; + delete _impl_.options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::EnumValueOptions>::GetOwningArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); } - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - options_ = options; + _impl_.options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.options) } @@ -11326,15 +11374,15 @@ inline void EnumValueDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE // optional string name = 1; inline bool ServiceDescriptorProto::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool ServiceDescriptorProto::has_name() const { return _internal_has_name(); } inline void ServiceDescriptorProto::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.name_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& ServiceDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name) @@ -11343,8 +11391,8 @@ inline const std::string& ServiceDescriptorProto::name() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void ServiceDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name) } inline std::string* ServiceDescriptorProto::mutable_name() { @@ -11353,41 +11401,40 @@ inline std::string* ServiceDescriptorProto::mutable_name() { return _s; } inline const std::string& ServiceDescriptorProto::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void ServiceDescriptorProto::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* ServiceDescriptorProto::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* ServiceDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.name) if (!_internal_has_name()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void ServiceDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.name) @@ -11395,32 +11442,32 @@ inline void ServiceDescriptorProto::set_allocated_name(std::string* name) { // repeated .google.protobuf.MethodDescriptorProto method = 2; inline int ServiceDescriptorProto::_internal_method_size() const { - return method_.size(); + return _impl_.method_.size(); } inline int ServiceDescriptorProto::method_size() const { return _internal_method_size(); } inline void ServiceDescriptorProto::clear_method() { - method_.Clear(); + _impl_.method_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* ServiceDescriptorProto::mutable_method(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.method) - return method_.Mutable(index); + return _impl_.method_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto >* ServiceDescriptorProto::mutable_method() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceDescriptorProto.method) - return &method_; + return &_impl_.method_; } inline const ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto& ServiceDescriptorProto::_internal_method(int index) const { - return method_.Get(index); + return _impl_.method_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto& ServiceDescriptorProto::method(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.method) return _internal_method(index); } inline ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* ServiceDescriptorProto::_internal_add_method() { - return method_.Add(); + return _impl_.method_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* ServiceDescriptorProto::add_method() { ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* _add = _internal_add_method(); @@ -11430,24 +11477,24 @@ inline ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* ServiceDescriptorProto::a inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto >& ServiceDescriptorProto::method() const { // @@protoc_insertion_point(field_list:google.protobuf.ServiceDescriptorProto.method) - return method_; + return _impl_.method_; } // optional .google.protobuf.ServiceOptions options = 3; inline bool ServiceDescriptorProto::_internal_has_options() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || options_ != nullptr); + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr); return value; } inline bool ServiceDescriptorProto::has_options() const { return _internal_has_options(); } inline void ServiceDescriptorProto::clear_options() { - if (options_ != nullptr) options_->Clear(); - _has_bits_[0] &= ~0x00000002u; + if (_impl_.options_ != nullptr) _impl_.options_->Clear(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const ::PROTOBUF_NAMESPACE_ID::ServiceOptions& ServiceDescriptorProto::_internal_options() const { - const ::PROTOBUF_NAMESPACE_ID::ServiceOptions* p = options_; + const ::PROTOBUF_NAMESPACE_ID::ServiceOptions* p = _impl_.options_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::ServiceOptions&>( ::PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_); } @@ -11458,20 +11505,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::ServiceOptions& ServiceDescriptorProto::op inline void ServiceDescriptorProto::unsafe_arena_set_allocated_options( ::PROTOBUF_NAMESPACE_ID::ServiceOptions* options) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.options_); } - options_ = options; + _impl_.options_ = options; if (options) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.ServiceDescriptorProto.options) } inline ::PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::release_options() { - _has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::ServiceOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000002u; + ::PROTOBUF_NAMESPACE_ID::ServiceOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -11485,18 +11532,18 @@ inline ::PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::release_ } inline ::PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::unsafe_arena_release_options() { // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.options) - _has_bits_[0] &= ~0x00000002u; - ::PROTOBUF_NAMESPACE_ID::ServiceOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000002u; + ::PROTOBUF_NAMESPACE_ID::ServiceOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::_internal_mutable_options() { - _has_bits_[0] |= 0x00000002u; - if (options_ == nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + if (_impl_.options_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceOptions>(GetArenaForAllocation()); - options_ = p; + _impl_.options_ = p; } - return options_; + return _impl_.options_; } inline ::PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::mutable_options() { ::PROTOBUF_NAMESPACE_ID::ServiceOptions* _msg = _internal_mutable_options(); @@ -11506,20 +11553,20 @@ inline ::PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::mutable_ inline void ServiceDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID::ServiceOptions* options) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete options_; + delete _impl_.options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::ServiceOptions>::GetOwningArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); } - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - options_ = options; + _impl_.options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.options) } @@ -11529,15 +11576,15 @@ inline void ServiceDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_I // optional string name = 1; inline bool MethodDescriptorProto::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool MethodDescriptorProto::has_name() const { return _internal_has_name(); } inline void MethodDescriptorProto::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.name_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& MethodDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name) @@ -11546,8 +11593,8 @@ inline const std::string& MethodDescriptorProto::name() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void MethodDescriptorProto::set_name(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name) } inline std::string* MethodDescriptorProto::mutable_name() { @@ -11556,41 +11603,40 @@ inline std::string* MethodDescriptorProto::mutable_name() { return _s; } inline const std::string& MethodDescriptorProto::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void MethodDescriptorProto::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* MethodDescriptorProto::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* MethodDescriptorProto::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.name) if (!_internal_has_name()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.name_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void MethodDescriptorProto::set_allocated_name(std::string* name) { if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.name) @@ -11598,15 +11644,15 @@ inline void MethodDescriptorProto::set_allocated_name(std::string* name) { // optional string input_type = 2; inline bool MethodDescriptorProto::_internal_has_input_type() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool MethodDescriptorProto::has_input_type() const { return _internal_has_input_type(); } inline void MethodDescriptorProto::clear_input_type() { - input_type_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; + _impl_.input_type_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const std::string& MethodDescriptorProto::input_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type) @@ -11615,8 +11661,8 @@ inline const std::string& MethodDescriptorProto::input_type() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void MethodDescriptorProto::set_input_type(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000002u; - input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.input_type_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type) } inline std::string* MethodDescriptorProto::mutable_input_type() { @@ -11625,41 +11671,40 @@ inline std::string* MethodDescriptorProto::mutable_input_type() { return _s; } inline const std::string& MethodDescriptorProto::_internal_input_type() const { - return input_type_.Get(); + return _impl_.input_type_.Get(); } inline void MethodDescriptorProto::_internal_set_input_type(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - input_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.input_type_.Set(value, GetArenaForAllocation()); } inline std::string* MethodDescriptorProto::_internal_mutable_input_type() { - _has_bits_[0] |= 0x00000002u; - return input_type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.input_type_.Mutable(GetArenaForAllocation()); } inline std::string* MethodDescriptorProto::release_input_type() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.input_type) if (!_internal_has_input_type()) { return nullptr; } - _has_bits_[0] &= ~0x00000002u; - auto* p = input_type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.input_type_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (input_type_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.input_type_.IsDefault()) { + _impl_.input_type_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void MethodDescriptorProto::set_allocated_input_type(std::string* input_type) { if (input_type != nullptr) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - input_type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), input_type, - GetArenaForAllocation()); + _impl_.input_type_.SetAllocated(input_type, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (input_type_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.input_type_.IsDefault()) { + _impl_.input_type_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.input_type) @@ -11667,15 +11712,15 @@ inline void MethodDescriptorProto::set_allocated_input_type(std::string* input_t // optional string output_type = 3; inline bool MethodDescriptorProto::_internal_has_output_type() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool MethodDescriptorProto::has_output_type() const { return _internal_has_output_type(); } inline void MethodDescriptorProto::clear_output_type() { - output_type_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000004u; + _impl_.output_type_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; } inline const std::string& MethodDescriptorProto::output_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type) @@ -11684,8 +11729,8 @@ inline const std::string& MethodDescriptorProto::output_type() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void MethodDescriptorProto::set_output_type(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000004u; - output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.output_type_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type) } inline std::string* MethodDescriptorProto::mutable_output_type() { @@ -11694,41 +11739,40 @@ inline std::string* MethodDescriptorProto::mutable_output_type() { return _s; } inline const std::string& MethodDescriptorProto::_internal_output_type() const { - return output_type_.Get(); + return _impl_.output_type_.Get(); } inline void MethodDescriptorProto::_internal_set_output_type(const std::string& value) { - _has_bits_[0] |= 0x00000004u; - output_type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.output_type_.Set(value, GetArenaForAllocation()); } inline std::string* MethodDescriptorProto::_internal_mutable_output_type() { - _has_bits_[0] |= 0x00000004u; - return output_type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.output_type_.Mutable(GetArenaForAllocation()); } inline std::string* MethodDescriptorProto::release_output_type() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.output_type) if (!_internal_has_output_type()) { return nullptr; } - _has_bits_[0] &= ~0x00000004u; - auto* p = output_type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.output_type_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (output_type_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.output_type_.IsDefault()) { + _impl_.output_type_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void MethodDescriptorProto::set_allocated_output_type(std::string* output_type) { if (output_type != nullptr) { - _has_bits_[0] |= 0x00000004u; + _impl_._has_bits_[0] |= 0x00000004u; } else { - _has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000004u; } - output_type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), output_type, - GetArenaForAllocation()); + _impl_.output_type_.SetAllocated(output_type, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (output_type_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.output_type_.IsDefault()) { + _impl_.output_type_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.output_type) @@ -11736,19 +11780,19 @@ inline void MethodDescriptorProto::set_allocated_output_type(std::string* output // optional .google.protobuf.MethodOptions options = 4; inline bool MethodDescriptorProto::_internal_has_options() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; - PROTOBUF_ASSUME(!value || options_ != nullptr); + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + PROTOBUF_ASSUME(!value || _impl_.options_ != nullptr); return value; } inline bool MethodDescriptorProto::has_options() const { return _internal_has_options(); } inline void MethodDescriptorProto::clear_options() { - if (options_ != nullptr) options_->Clear(); - _has_bits_[0] &= ~0x00000008u; + if (_impl_.options_ != nullptr) _impl_.options_->Clear(); + _impl_._has_bits_[0] &= ~0x00000008u; } inline const ::PROTOBUF_NAMESPACE_ID::MethodOptions& MethodDescriptorProto::_internal_options() const { - const ::PROTOBUF_NAMESPACE_ID::MethodOptions* p = options_; + const ::PROTOBUF_NAMESPACE_ID::MethodOptions* p = _impl_.options_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::MethodOptions&>( ::PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_); } @@ -11759,20 +11803,20 @@ inline const ::PROTOBUF_NAMESPACE_ID::MethodOptions& MethodDescriptorProto::opti inline void MethodDescriptorProto::unsafe_arena_set_allocated_options( ::PROTOBUF_NAMESPACE_ID::MethodOptions* options) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(options_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.options_); } - options_ = options; + _impl_.options_ = options; if (options) { - _has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000008u; } else { - _has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000008u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.MethodDescriptorProto.options) } inline ::PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::release_options() { - _has_bits_[0] &= ~0x00000008u; - ::PROTOBUF_NAMESPACE_ID::MethodOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000008u; + ::PROTOBUF_NAMESPACE_ID::MethodOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -11786,18 +11830,18 @@ inline ::PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::release_op } inline ::PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::unsafe_arena_release_options() { // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.options) - _has_bits_[0] &= ~0x00000008u; - ::PROTOBUF_NAMESPACE_ID::MethodOptions* temp = options_; - options_ = nullptr; + _impl_._has_bits_[0] &= ~0x00000008u; + ::PROTOBUF_NAMESPACE_ID::MethodOptions* temp = _impl_.options_; + _impl_.options_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::_internal_mutable_options() { - _has_bits_[0] |= 0x00000008u; - if (options_ == nullptr) { + _impl_._has_bits_[0] |= 0x00000008u; + if (_impl_.options_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodOptions>(GetArenaForAllocation()); - options_ = p; + _impl_.options_ = p; } - return options_; + return _impl_.options_; } inline ::PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::mutable_options() { ::PROTOBUF_NAMESPACE_ID::MethodOptions* _msg = _internal_mutable_options(); @@ -11807,45 +11851,45 @@ inline ::PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::mutable_op inline void MethodDescriptorProto::set_allocated_options(::PROTOBUF_NAMESPACE_ID::MethodOptions* options) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete options_; + delete _impl_.options_; } if (options) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::MethodOptions>::GetOwningArena(options); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(options); if (message_arena != submessage_arena) { options = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, options, submessage_arena); } - _has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000008u; } else { - _has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000008u; } - options_ = options; + _impl_.options_ = options; // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.options) } // optional bool client_streaming = 5 [default = false]; inline bool MethodDescriptorProto::_internal_has_client_streaming() const { - bool value = (_has_bits_[0] & 0x00000010u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; return value; } inline bool MethodDescriptorProto::has_client_streaming() const { return _internal_has_client_streaming(); } inline void MethodDescriptorProto::clear_client_streaming() { - client_streaming_ = false; - _has_bits_[0] &= ~0x00000010u; + _impl_.client_streaming_ = false; + _impl_._has_bits_[0] &= ~0x00000010u; } inline bool MethodDescriptorProto::_internal_client_streaming() const { - return client_streaming_; + return _impl_.client_streaming_; } inline bool MethodDescriptorProto::client_streaming() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.client_streaming) return _internal_client_streaming(); } inline void MethodDescriptorProto::_internal_set_client_streaming(bool value) { - _has_bits_[0] |= 0x00000010u; - client_streaming_ = value; + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.client_streaming_ = value; } inline void MethodDescriptorProto::set_client_streaming(bool value) { _internal_set_client_streaming(value); @@ -11854,26 +11898,26 @@ inline void MethodDescriptorProto::set_client_streaming(bool value) { // optional bool server_streaming = 6 [default = false]; inline bool MethodDescriptorProto::_internal_has_server_streaming() const { - bool value = (_has_bits_[0] & 0x00000020u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; return value; } inline bool MethodDescriptorProto::has_server_streaming() const { return _internal_has_server_streaming(); } inline void MethodDescriptorProto::clear_server_streaming() { - server_streaming_ = false; - _has_bits_[0] &= ~0x00000020u; + _impl_.server_streaming_ = false; + _impl_._has_bits_[0] &= ~0x00000020u; } inline bool MethodDescriptorProto::_internal_server_streaming() const { - return server_streaming_; + return _impl_.server_streaming_; } inline bool MethodDescriptorProto::server_streaming() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.server_streaming) return _internal_server_streaming(); } inline void MethodDescriptorProto::_internal_set_server_streaming(bool value) { - _has_bits_[0] |= 0x00000020u; - server_streaming_ = value; + _impl_._has_bits_[0] |= 0x00000020u; + _impl_.server_streaming_ = value; } inline void MethodDescriptorProto::set_server_streaming(bool value) { _internal_set_server_streaming(value); @@ -11886,15 +11930,15 @@ inline void MethodDescriptorProto::set_server_streaming(bool value) { // optional string java_package = 1; inline bool FileOptions::_internal_has_java_package() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool FileOptions::has_java_package() const { return _internal_has_java_package(); } inline void FileOptions::clear_java_package() { - java_package_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.java_package_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& FileOptions::java_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package) @@ -11903,8 +11947,8 @@ inline const std::string& FileOptions::java_package() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_java_package(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.java_package_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package) } inline std::string* FileOptions::mutable_java_package() { @@ -11913,41 +11957,40 @@ inline std::string* FileOptions::mutable_java_package() { return _s; } inline const std::string& FileOptions::_internal_java_package() const { - return java_package_.Get(); + return _impl_.java_package_.Get(); } inline void FileOptions::_internal_set_java_package(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - java_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.java_package_.Set(value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_java_package() { - _has_bits_[0] |= 0x00000001u; - return java_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.java_package_.Mutable(GetArenaForAllocation()); } inline std::string* FileOptions::release_java_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_package) if (!_internal_has_java_package()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = java_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.java_package_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (java_package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.java_package_.IsDefault()) { + _impl_.java_package_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileOptions::set_allocated_java_package(std::string* java_package) { if (java_package != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - java_package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), java_package, - GetArenaForAllocation()); + _impl_.java_package_.SetAllocated(java_package, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (java_package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.java_package_.IsDefault()) { + _impl_.java_package_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_package) @@ -11955,15 +11998,15 @@ inline void FileOptions::set_allocated_java_package(std::string* java_package) { // optional string java_outer_classname = 8; inline bool FileOptions::_internal_has_java_outer_classname() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool FileOptions::has_java_outer_classname() const { return _internal_has_java_outer_classname(); } inline void FileOptions::clear_java_outer_classname() { - java_outer_classname_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; + _impl_.java_outer_classname_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const std::string& FileOptions::java_outer_classname() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname) @@ -11972,8 +12015,8 @@ inline const std::string& FileOptions::java_outer_classname() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_java_outer_classname(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000002u; - java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.java_outer_classname_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname) } inline std::string* FileOptions::mutable_java_outer_classname() { @@ -11982,41 +12025,40 @@ inline std::string* FileOptions::mutable_java_outer_classname() { return _s; } inline const std::string& FileOptions::_internal_java_outer_classname() const { - return java_outer_classname_.Get(); + return _impl_.java_outer_classname_.Get(); } inline void FileOptions::_internal_set_java_outer_classname(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - java_outer_classname_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.java_outer_classname_.Set(value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_java_outer_classname() { - _has_bits_[0] |= 0x00000002u; - return java_outer_classname_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.java_outer_classname_.Mutable(GetArenaForAllocation()); } inline std::string* FileOptions::release_java_outer_classname() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_outer_classname) if (!_internal_has_java_outer_classname()) { return nullptr; } - _has_bits_[0] &= ~0x00000002u; - auto* p = java_outer_classname_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.java_outer_classname_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (java_outer_classname_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.java_outer_classname_.IsDefault()) { + _impl_.java_outer_classname_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileOptions::set_allocated_java_outer_classname(std::string* java_outer_classname) { if (java_outer_classname != nullptr) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - java_outer_classname_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), java_outer_classname, - GetArenaForAllocation()); + _impl_.java_outer_classname_.SetAllocated(java_outer_classname, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (java_outer_classname_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.java_outer_classname_.IsDefault()) { + _impl_.java_outer_classname_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_outer_classname) @@ -12024,26 +12066,26 @@ inline void FileOptions::set_allocated_java_outer_classname(std::string* java_ou // optional bool java_multiple_files = 10 [default = false]; inline bool FileOptions::_internal_has_java_multiple_files() const { - bool value = (_has_bits_[0] & 0x00000400u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; return value; } inline bool FileOptions::has_java_multiple_files() const { return _internal_has_java_multiple_files(); } inline void FileOptions::clear_java_multiple_files() { - java_multiple_files_ = false; - _has_bits_[0] &= ~0x00000400u; + _impl_.java_multiple_files_ = false; + _impl_._has_bits_[0] &= ~0x00000400u; } inline bool FileOptions::_internal_java_multiple_files() const { - return java_multiple_files_; + return _impl_.java_multiple_files_; } inline bool FileOptions::java_multiple_files() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_multiple_files) return _internal_java_multiple_files(); } inline void FileOptions::_internal_set_java_multiple_files(bool value) { - _has_bits_[0] |= 0x00000400u; - java_multiple_files_ = value; + _impl_._has_bits_[0] |= 0x00000400u; + _impl_.java_multiple_files_ = value; } inline void FileOptions::set_java_multiple_files(bool value) { _internal_set_java_multiple_files(value); @@ -12052,26 +12094,26 @@ inline void FileOptions::set_java_multiple_files(bool value) { // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; inline bool FileOptions::_internal_has_java_generate_equals_and_hash() const { - bool value = (_has_bits_[0] & 0x00000800u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000800u) != 0; return value; } inline bool FileOptions::has_java_generate_equals_and_hash() const { return _internal_has_java_generate_equals_and_hash(); } inline void FileOptions::clear_java_generate_equals_and_hash() { - java_generate_equals_and_hash_ = false; - _has_bits_[0] &= ~0x00000800u; + _impl_.java_generate_equals_and_hash_ = false; + _impl_._has_bits_[0] &= ~0x00000800u; } inline bool FileOptions::_internal_java_generate_equals_and_hash() const { - return java_generate_equals_and_hash_; + return _impl_.java_generate_equals_and_hash_; } inline bool FileOptions::java_generate_equals_and_hash() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generate_equals_and_hash) return _internal_java_generate_equals_and_hash(); } inline void FileOptions::_internal_set_java_generate_equals_and_hash(bool value) { - _has_bits_[0] |= 0x00000800u; - java_generate_equals_and_hash_ = value; + _impl_._has_bits_[0] |= 0x00000800u; + _impl_.java_generate_equals_and_hash_ = value; } inline void FileOptions::set_java_generate_equals_and_hash(bool value) { _internal_set_java_generate_equals_and_hash(value); @@ -12080,26 +12122,26 @@ inline void FileOptions::set_java_generate_equals_and_hash(bool value) { // optional bool java_string_check_utf8 = 27 [default = false]; inline bool FileOptions::_internal_has_java_string_check_utf8() const { - bool value = (_has_bits_[0] & 0x00001000u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00001000u) != 0; return value; } inline bool FileOptions::has_java_string_check_utf8() const { return _internal_has_java_string_check_utf8(); } inline void FileOptions::clear_java_string_check_utf8() { - java_string_check_utf8_ = false; - _has_bits_[0] &= ~0x00001000u; + _impl_.java_string_check_utf8_ = false; + _impl_._has_bits_[0] &= ~0x00001000u; } inline bool FileOptions::_internal_java_string_check_utf8() const { - return java_string_check_utf8_; + return _impl_.java_string_check_utf8_; } inline bool FileOptions::java_string_check_utf8() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_string_check_utf8) return _internal_java_string_check_utf8(); } inline void FileOptions::_internal_set_java_string_check_utf8(bool value) { - _has_bits_[0] |= 0x00001000u; - java_string_check_utf8_ = value; + _impl_._has_bits_[0] |= 0x00001000u; + _impl_.java_string_check_utf8_ = value; } inline void FileOptions::set_java_string_check_utf8(bool value) { _internal_set_java_string_check_utf8(value); @@ -12108,18 +12150,18 @@ inline void FileOptions::set_java_string_check_utf8(bool value) { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; inline bool FileOptions::_internal_has_optimize_for() const { - bool value = (_has_bits_[0] & 0x00040000u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00040000u) != 0; return value; } inline bool FileOptions::has_optimize_for() const { return _internal_has_optimize_for(); } inline void FileOptions::clear_optimize_for() { - optimize_for_ = 1; - _has_bits_[0] &= ~0x00040000u; + _impl_.optimize_for_ = 1; + _impl_._has_bits_[0] &= ~0x00040000u; } inline ::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode FileOptions::_internal_optimize_for() const { - return static_cast< ::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode >(optimize_for_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode >(_impl_.optimize_for_); } inline ::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode FileOptions::optimize_for() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.optimize_for) @@ -12127,8 +12169,8 @@ inline ::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode FileOptions::optimize_f } inline void FileOptions::_internal_set_optimize_for(::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode value) { assert(::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode_IsValid(value)); - _has_bits_[0] |= 0x00040000u; - optimize_for_ = value; + _impl_._has_bits_[0] |= 0x00040000u; + _impl_.optimize_for_ = value; } inline void FileOptions::set_optimize_for(::PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode value) { _internal_set_optimize_for(value); @@ -12137,15 +12179,15 @@ inline void FileOptions::set_optimize_for(::PROTOBUF_NAMESPACE_ID::FileOptions_O // optional string go_package = 11; inline bool FileOptions::_internal_has_go_package() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool FileOptions::has_go_package() const { return _internal_has_go_package(); } inline void FileOptions::clear_go_package() { - go_package_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000004u; + _impl_.go_package_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; } inline const std::string& FileOptions::go_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package) @@ -12154,8 +12196,8 @@ inline const std::string& FileOptions::go_package() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_go_package(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000004u; - go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.go_package_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package) } inline std::string* FileOptions::mutable_go_package() { @@ -12164,41 +12206,40 @@ inline std::string* FileOptions::mutable_go_package() { return _s; } inline const std::string& FileOptions::_internal_go_package() const { - return go_package_.Get(); + return _impl_.go_package_.Get(); } inline void FileOptions::_internal_set_go_package(const std::string& value) { - _has_bits_[0] |= 0x00000004u; - go_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.go_package_.Set(value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_go_package() { - _has_bits_[0] |= 0x00000004u; - return go_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.go_package_.Mutable(GetArenaForAllocation()); } inline std::string* FileOptions::release_go_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.go_package) if (!_internal_has_go_package()) { return nullptr; } - _has_bits_[0] &= ~0x00000004u; - auto* p = go_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.go_package_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (go_package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.go_package_.IsDefault()) { + _impl_.go_package_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileOptions::set_allocated_go_package(std::string* go_package) { if (go_package != nullptr) { - _has_bits_[0] |= 0x00000004u; + _impl_._has_bits_[0] |= 0x00000004u; } else { - _has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000004u; } - go_package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), go_package, - GetArenaForAllocation()); + _impl_.go_package_.SetAllocated(go_package, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (go_package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.go_package_.IsDefault()) { + _impl_.go_package_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.go_package) @@ -12206,26 +12247,26 @@ inline void FileOptions::set_allocated_go_package(std::string* go_package) { // optional bool cc_generic_services = 16 [default = false]; inline bool FileOptions::_internal_has_cc_generic_services() const { - bool value = (_has_bits_[0] & 0x00002000u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00002000u) != 0; return value; } inline bool FileOptions::has_cc_generic_services() const { return _internal_has_cc_generic_services(); } inline void FileOptions::clear_cc_generic_services() { - cc_generic_services_ = false; - _has_bits_[0] &= ~0x00002000u; + _impl_.cc_generic_services_ = false; + _impl_._has_bits_[0] &= ~0x00002000u; } inline bool FileOptions::_internal_cc_generic_services() const { - return cc_generic_services_; + return _impl_.cc_generic_services_; } inline bool FileOptions::cc_generic_services() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_generic_services) return _internal_cc_generic_services(); } inline void FileOptions::_internal_set_cc_generic_services(bool value) { - _has_bits_[0] |= 0x00002000u; - cc_generic_services_ = value; + _impl_._has_bits_[0] |= 0x00002000u; + _impl_.cc_generic_services_ = value; } inline void FileOptions::set_cc_generic_services(bool value) { _internal_set_cc_generic_services(value); @@ -12234,26 +12275,26 @@ inline void FileOptions::set_cc_generic_services(bool value) { // optional bool java_generic_services = 17 [default = false]; inline bool FileOptions::_internal_has_java_generic_services() const { - bool value = (_has_bits_[0] & 0x00004000u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00004000u) != 0; return value; } inline bool FileOptions::has_java_generic_services() const { return _internal_has_java_generic_services(); } inline void FileOptions::clear_java_generic_services() { - java_generic_services_ = false; - _has_bits_[0] &= ~0x00004000u; + _impl_.java_generic_services_ = false; + _impl_._has_bits_[0] &= ~0x00004000u; } inline bool FileOptions::_internal_java_generic_services() const { - return java_generic_services_; + return _impl_.java_generic_services_; } inline bool FileOptions::java_generic_services() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generic_services) return _internal_java_generic_services(); } inline void FileOptions::_internal_set_java_generic_services(bool value) { - _has_bits_[0] |= 0x00004000u; - java_generic_services_ = value; + _impl_._has_bits_[0] |= 0x00004000u; + _impl_.java_generic_services_ = value; } inline void FileOptions::set_java_generic_services(bool value) { _internal_set_java_generic_services(value); @@ -12262,26 +12303,26 @@ inline void FileOptions::set_java_generic_services(bool value) { // optional bool py_generic_services = 18 [default = false]; inline bool FileOptions::_internal_has_py_generic_services() const { - bool value = (_has_bits_[0] & 0x00008000u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00008000u) != 0; return value; } inline bool FileOptions::has_py_generic_services() const { return _internal_has_py_generic_services(); } inline void FileOptions::clear_py_generic_services() { - py_generic_services_ = false; - _has_bits_[0] &= ~0x00008000u; + _impl_.py_generic_services_ = false; + _impl_._has_bits_[0] &= ~0x00008000u; } inline bool FileOptions::_internal_py_generic_services() const { - return py_generic_services_; + return _impl_.py_generic_services_; } inline bool FileOptions::py_generic_services() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.py_generic_services) return _internal_py_generic_services(); } inline void FileOptions::_internal_set_py_generic_services(bool value) { - _has_bits_[0] |= 0x00008000u; - py_generic_services_ = value; + _impl_._has_bits_[0] |= 0x00008000u; + _impl_.py_generic_services_ = value; } inline void FileOptions::set_py_generic_services(bool value) { _internal_set_py_generic_services(value); @@ -12290,26 +12331,26 @@ inline void FileOptions::set_py_generic_services(bool value) { // optional bool php_generic_services = 42 [default = false]; inline bool FileOptions::_internal_has_php_generic_services() const { - bool value = (_has_bits_[0] & 0x00010000u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00010000u) != 0; return value; } inline bool FileOptions::has_php_generic_services() const { return _internal_has_php_generic_services(); } inline void FileOptions::clear_php_generic_services() { - php_generic_services_ = false; - _has_bits_[0] &= ~0x00010000u; + _impl_.php_generic_services_ = false; + _impl_._has_bits_[0] &= ~0x00010000u; } inline bool FileOptions::_internal_php_generic_services() const { - return php_generic_services_; + return _impl_.php_generic_services_; } inline bool FileOptions::php_generic_services() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_generic_services) return _internal_php_generic_services(); } inline void FileOptions::_internal_set_php_generic_services(bool value) { - _has_bits_[0] |= 0x00010000u; - php_generic_services_ = value; + _impl_._has_bits_[0] |= 0x00010000u; + _impl_.php_generic_services_ = value; } inline void FileOptions::set_php_generic_services(bool value) { _internal_set_php_generic_services(value); @@ -12318,26 +12359,26 @@ inline void FileOptions::set_php_generic_services(bool value) { // optional bool deprecated = 23 [default = false]; inline bool FileOptions::_internal_has_deprecated() const { - bool value = (_has_bits_[0] & 0x00020000u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00020000u) != 0; return value; } inline bool FileOptions::has_deprecated() const { return _internal_has_deprecated(); } inline void FileOptions::clear_deprecated() { - deprecated_ = false; - _has_bits_[0] &= ~0x00020000u; + _impl_.deprecated_ = false; + _impl_._has_bits_[0] &= ~0x00020000u; } inline bool FileOptions::_internal_deprecated() const { - return deprecated_; + return _impl_.deprecated_; } inline bool FileOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.deprecated) return _internal_deprecated(); } inline void FileOptions::_internal_set_deprecated(bool value) { - _has_bits_[0] |= 0x00020000u; - deprecated_ = value; + _impl_._has_bits_[0] |= 0x00020000u; + _impl_.deprecated_ = value; } inline void FileOptions::set_deprecated(bool value) { _internal_set_deprecated(value); @@ -12346,26 +12387,26 @@ inline void FileOptions::set_deprecated(bool value) { // optional bool cc_enable_arenas = 31 [default = true]; inline bool FileOptions::_internal_has_cc_enable_arenas() const { - bool value = (_has_bits_[0] & 0x00080000u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00080000u) != 0; return value; } inline bool FileOptions::has_cc_enable_arenas() const { return _internal_has_cc_enable_arenas(); } inline void FileOptions::clear_cc_enable_arenas() { - cc_enable_arenas_ = true; - _has_bits_[0] &= ~0x00080000u; + _impl_.cc_enable_arenas_ = true; + _impl_._has_bits_[0] &= ~0x00080000u; } inline bool FileOptions::_internal_cc_enable_arenas() const { - return cc_enable_arenas_; + return _impl_.cc_enable_arenas_; } inline bool FileOptions::cc_enable_arenas() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_enable_arenas) return _internal_cc_enable_arenas(); } inline void FileOptions::_internal_set_cc_enable_arenas(bool value) { - _has_bits_[0] |= 0x00080000u; - cc_enable_arenas_ = value; + _impl_._has_bits_[0] |= 0x00080000u; + _impl_.cc_enable_arenas_ = value; } inline void FileOptions::set_cc_enable_arenas(bool value) { _internal_set_cc_enable_arenas(value); @@ -12374,15 +12415,15 @@ inline void FileOptions::set_cc_enable_arenas(bool value) { // optional string objc_class_prefix = 36; inline bool FileOptions::_internal_has_objc_class_prefix() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } inline bool FileOptions::has_objc_class_prefix() const { return _internal_has_objc_class_prefix(); } inline void FileOptions::clear_objc_class_prefix() { - objc_class_prefix_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000008u; + _impl_.objc_class_prefix_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000008u; } inline const std::string& FileOptions::objc_class_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix) @@ -12391,8 +12432,8 @@ inline const std::string& FileOptions::objc_class_prefix() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_objc_class_prefix(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000008u; - objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.objc_class_prefix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix) } inline std::string* FileOptions::mutable_objc_class_prefix() { @@ -12401,41 +12442,40 @@ inline std::string* FileOptions::mutable_objc_class_prefix() { return _s; } inline const std::string& FileOptions::_internal_objc_class_prefix() const { - return objc_class_prefix_.Get(); + return _impl_.objc_class_prefix_.Get(); } inline void FileOptions::_internal_set_objc_class_prefix(const std::string& value) { - _has_bits_[0] |= 0x00000008u; - objc_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.objc_class_prefix_.Set(value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_objc_class_prefix() { - _has_bits_[0] |= 0x00000008u; - return objc_class_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000008u; + return _impl_.objc_class_prefix_.Mutable(GetArenaForAllocation()); } inline std::string* FileOptions::release_objc_class_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.objc_class_prefix) if (!_internal_has_objc_class_prefix()) { return nullptr; } - _has_bits_[0] &= ~0x00000008u; - auto* p = objc_class_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000008u; + auto* p = _impl_.objc_class_prefix_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (objc_class_prefix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.objc_class_prefix_.IsDefault()) { + _impl_.objc_class_prefix_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileOptions::set_allocated_objc_class_prefix(std::string* objc_class_prefix) { if (objc_class_prefix != nullptr) { - _has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000008u; } else { - _has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000008u; } - objc_class_prefix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), objc_class_prefix, - GetArenaForAllocation()); + _impl_.objc_class_prefix_.SetAllocated(objc_class_prefix, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (objc_class_prefix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.objc_class_prefix_.IsDefault()) { + _impl_.objc_class_prefix_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.objc_class_prefix) @@ -12443,15 +12483,15 @@ inline void FileOptions::set_allocated_objc_class_prefix(std::string* objc_class // optional string csharp_namespace = 37; inline bool FileOptions::_internal_has_csharp_namespace() const { - bool value = (_has_bits_[0] & 0x00000010u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; return value; } inline bool FileOptions::has_csharp_namespace() const { return _internal_has_csharp_namespace(); } inline void FileOptions::clear_csharp_namespace() { - csharp_namespace_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000010u; + _impl_.csharp_namespace_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000010u; } inline const std::string& FileOptions::csharp_namespace() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace) @@ -12460,8 +12500,8 @@ inline const std::string& FileOptions::csharp_namespace() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_csharp_namespace(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000010u; - csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.csharp_namespace_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) } inline std::string* FileOptions::mutable_csharp_namespace() { @@ -12470,41 +12510,40 @@ inline std::string* FileOptions::mutable_csharp_namespace() { return _s; } inline const std::string& FileOptions::_internal_csharp_namespace() const { - return csharp_namespace_.Get(); + return _impl_.csharp_namespace_.Get(); } inline void FileOptions::_internal_set_csharp_namespace(const std::string& value) { - _has_bits_[0] |= 0x00000010u; - csharp_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.csharp_namespace_.Set(value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_csharp_namespace() { - _has_bits_[0] |= 0x00000010u; - return csharp_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000010u; + return _impl_.csharp_namespace_.Mutable(GetArenaForAllocation()); } inline std::string* FileOptions::release_csharp_namespace() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.csharp_namespace) if (!_internal_has_csharp_namespace()) { return nullptr; } - _has_bits_[0] &= ~0x00000010u; - auto* p = csharp_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000010u; + auto* p = _impl_.csharp_namespace_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (csharp_namespace_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.csharp_namespace_.IsDefault()) { + _impl_.csharp_namespace_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileOptions::set_allocated_csharp_namespace(std::string* csharp_namespace) { if (csharp_namespace != nullptr) { - _has_bits_[0] |= 0x00000010u; + _impl_._has_bits_[0] |= 0x00000010u; } else { - _has_bits_[0] &= ~0x00000010u; + _impl_._has_bits_[0] &= ~0x00000010u; } - csharp_namespace_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), csharp_namespace, - GetArenaForAllocation()); + _impl_.csharp_namespace_.SetAllocated(csharp_namespace, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (csharp_namespace_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.csharp_namespace_.IsDefault()) { + _impl_.csharp_namespace_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) @@ -12512,15 +12551,15 @@ inline void FileOptions::set_allocated_csharp_namespace(std::string* csharp_name // optional string swift_prefix = 39; inline bool FileOptions::_internal_has_swift_prefix() const { - bool value = (_has_bits_[0] & 0x00000020u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; return value; } inline bool FileOptions::has_swift_prefix() const { return _internal_has_swift_prefix(); } inline void FileOptions::clear_swift_prefix() { - swift_prefix_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000020u; + _impl_.swift_prefix_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000020u; } inline const std::string& FileOptions::swift_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix) @@ -12529,8 +12568,8 @@ inline const std::string& FileOptions::swift_prefix() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_swift_prefix(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000020u; - swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000020u; + _impl_.swift_prefix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix) } inline std::string* FileOptions::mutable_swift_prefix() { @@ -12539,41 +12578,40 @@ inline std::string* FileOptions::mutable_swift_prefix() { return _s; } inline const std::string& FileOptions::_internal_swift_prefix() const { - return swift_prefix_.Get(); + return _impl_.swift_prefix_.Get(); } inline void FileOptions::_internal_set_swift_prefix(const std::string& value) { - _has_bits_[0] |= 0x00000020u; - swift_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000020u; + _impl_.swift_prefix_.Set(value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_swift_prefix() { - _has_bits_[0] |= 0x00000020u; - return swift_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000020u; + return _impl_.swift_prefix_.Mutable(GetArenaForAllocation()); } inline std::string* FileOptions::release_swift_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix) if (!_internal_has_swift_prefix()) { return nullptr; } - _has_bits_[0] &= ~0x00000020u; - auto* p = swift_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000020u; + auto* p = _impl_.swift_prefix_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (swift_prefix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.swift_prefix_.IsDefault()) { + _impl_.swift_prefix_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileOptions::set_allocated_swift_prefix(std::string* swift_prefix) { if (swift_prefix != nullptr) { - _has_bits_[0] |= 0x00000020u; + _impl_._has_bits_[0] |= 0x00000020u; } else { - _has_bits_[0] &= ~0x00000020u; + _impl_._has_bits_[0] &= ~0x00000020u; } - swift_prefix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), swift_prefix, - GetArenaForAllocation()); + _impl_.swift_prefix_.SetAllocated(swift_prefix, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (swift_prefix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.swift_prefix_.IsDefault()) { + _impl_.swift_prefix_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix) @@ -12581,15 +12619,15 @@ inline void FileOptions::set_allocated_swift_prefix(std::string* swift_prefix) { // optional string php_class_prefix = 40; inline bool FileOptions::_internal_has_php_class_prefix() const { - bool value = (_has_bits_[0] & 0x00000040u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; return value; } inline bool FileOptions::has_php_class_prefix() const { return _internal_has_php_class_prefix(); } inline void FileOptions::clear_php_class_prefix() { - php_class_prefix_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000040u; + _impl_.php_class_prefix_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000040u; } inline const std::string& FileOptions::php_class_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_class_prefix) @@ -12598,8 +12636,8 @@ inline const std::string& FileOptions::php_class_prefix() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_php_class_prefix(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000040u; - php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000040u; + _impl_.php_class_prefix_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_class_prefix) } inline std::string* FileOptions::mutable_php_class_prefix() { @@ -12608,41 +12646,40 @@ inline std::string* FileOptions::mutable_php_class_prefix() { return _s; } inline const std::string& FileOptions::_internal_php_class_prefix() const { - return php_class_prefix_.Get(); + return _impl_.php_class_prefix_.Get(); } inline void FileOptions::_internal_set_php_class_prefix(const std::string& value) { - _has_bits_[0] |= 0x00000040u; - php_class_prefix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000040u; + _impl_.php_class_prefix_.Set(value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_php_class_prefix() { - _has_bits_[0] |= 0x00000040u; - return php_class_prefix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000040u; + return _impl_.php_class_prefix_.Mutable(GetArenaForAllocation()); } inline std::string* FileOptions::release_php_class_prefix() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_class_prefix) if (!_internal_has_php_class_prefix()) { return nullptr; } - _has_bits_[0] &= ~0x00000040u; - auto* p = php_class_prefix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000040u; + auto* p = _impl_.php_class_prefix_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (php_class_prefix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.php_class_prefix_.IsDefault()) { + _impl_.php_class_prefix_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileOptions::set_allocated_php_class_prefix(std::string* php_class_prefix) { if (php_class_prefix != nullptr) { - _has_bits_[0] |= 0x00000040u; + _impl_._has_bits_[0] |= 0x00000040u; } else { - _has_bits_[0] &= ~0x00000040u; + _impl_._has_bits_[0] &= ~0x00000040u; } - php_class_prefix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), php_class_prefix, - GetArenaForAllocation()); + _impl_.php_class_prefix_.SetAllocated(php_class_prefix, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (php_class_prefix_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.php_class_prefix_.IsDefault()) { + _impl_.php_class_prefix_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_class_prefix) @@ -12650,15 +12687,15 @@ inline void FileOptions::set_allocated_php_class_prefix(std::string* php_class_p // optional string php_namespace = 41; inline bool FileOptions::_internal_has_php_namespace() const { - bool value = (_has_bits_[0] & 0x00000080u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; return value; } inline bool FileOptions::has_php_namespace() const { return _internal_has_php_namespace(); } inline void FileOptions::clear_php_namespace() { - php_namespace_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000080u; + _impl_.php_namespace_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000080u; } inline const std::string& FileOptions::php_namespace() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_namespace) @@ -12667,8 +12704,8 @@ inline const std::string& FileOptions::php_namespace() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_php_namespace(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000080u; - php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000080u; + _impl_.php_namespace_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_namespace) } inline std::string* FileOptions::mutable_php_namespace() { @@ -12677,41 +12714,40 @@ inline std::string* FileOptions::mutable_php_namespace() { return _s; } inline const std::string& FileOptions::_internal_php_namespace() const { - return php_namespace_.Get(); + return _impl_.php_namespace_.Get(); } inline void FileOptions::_internal_set_php_namespace(const std::string& value) { - _has_bits_[0] |= 0x00000080u; - php_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000080u; + _impl_.php_namespace_.Set(value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_php_namespace() { - _has_bits_[0] |= 0x00000080u; - return php_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000080u; + return _impl_.php_namespace_.Mutable(GetArenaForAllocation()); } inline std::string* FileOptions::release_php_namespace() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_namespace) if (!_internal_has_php_namespace()) { return nullptr; } - _has_bits_[0] &= ~0x00000080u; - auto* p = php_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000080u; + auto* p = _impl_.php_namespace_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (php_namespace_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.php_namespace_.IsDefault()) { + _impl_.php_namespace_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileOptions::set_allocated_php_namespace(std::string* php_namespace) { if (php_namespace != nullptr) { - _has_bits_[0] |= 0x00000080u; + _impl_._has_bits_[0] |= 0x00000080u; } else { - _has_bits_[0] &= ~0x00000080u; + _impl_._has_bits_[0] &= ~0x00000080u; } - php_namespace_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), php_namespace, - GetArenaForAllocation()); + _impl_.php_namespace_.SetAllocated(php_namespace, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (php_namespace_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.php_namespace_.IsDefault()) { + _impl_.php_namespace_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_namespace) @@ -12719,15 +12755,15 @@ inline void FileOptions::set_allocated_php_namespace(std::string* php_namespace) // optional string php_metadata_namespace = 44; inline bool FileOptions::_internal_has_php_metadata_namespace() const { - bool value = (_has_bits_[0] & 0x00000100u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000100u) != 0; return value; } inline bool FileOptions::has_php_metadata_namespace() const { return _internal_has_php_metadata_namespace(); } inline void FileOptions::clear_php_metadata_namespace() { - php_metadata_namespace_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000100u; + _impl_.php_metadata_namespace_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000100u; } inline const std::string& FileOptions::php_metadata_namespace() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_metadata_namespace) @@ -12736,8 +12772,8 @@ inline const std::string& FileOptions::php_metadata_namespace() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_php_metadata_namespace(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000100u; - php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000100u; + _impl_.php_metadata_namespace_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_metadata_namespace) } inline std::string* FileOptions::mutable_php_metadata_namespace() { @@ -12746,41 +12782,40 @@ inline std::string* FileOptions::mutable_php_metadata_namespace() { return _s; } inline const std::string& FileOptions::_internal_php_metadata_namespace() const { - return php_metadata_namespace_.Get(); + return _impl_.php_metadata_namespace_.Get(); } inline void FileOptions::_internal_set_php_metadata_namespace(const std::string& value) { - _has_bits_[0] |= 0x00000100u; - php_metadata_namespace_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000100u; + _impl_.php_metadata_namespace_.Set(value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_php_metadata_namespace() { - _has_bits_[0] |= 0x00000100u; - return php_metadata_namespace_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000100u; + return _impl_.php_metadata_namespace_.Mutable(GetArenaForAllocation()); } inline std::string* FileOptions::release_php_metadata_namespace() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_metadata_namespace) if (!_internal_has_php_metadata_namespace()) { return nullptr; } - _has_bits_[0] &= ~0x00000100u; - auto* p = php_metadata_namespace_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000100u; + auto* p = _impl_.php_metadata_namespace_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (php_metadata_namespace_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.php_metadata_namespace_.IsDefault()) { + _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileOptions::set_allocated_php_metadata_namespace(std::string* php_metadata_namespace) { if (php_metadata_namespace != nullptr) { - _has_bits_[0] |= 0x00000100u; + _impl_._has_bits_[0] |= 0x00000100u; } else { - _has_bits_[0] &= ~0x00000100u; + _impl_._has_bits_[0] &= ~0x00000100u; } - php_metadata_namespace_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), php_metadata_namespace, - GetArenaForAllocation()); + _impl_.php_metadata_namespace_.SetAllocated(php_metadata_namespace, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (php_metadata_namespace_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.php_metadata_namespace_.IsDefault()) { + _impl_.php_metadata_namespace_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_metadata_namespace) @@ -12788,15 +12823,15 @@ inline void FileOptions::set_allocated_php_metadata_namespace(std::string* php_m // optional string ruby_package = 45; inline bool FileOptions::_internal_has_ruby_package() const { - bool value = (_has_bits_[0] & 0x00000200u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000200u) != 0; return value; } inline bool FileOptions::has_ruby_package() const { return _internal_has_ruby_package(); } inline void FileOptions::clear_ruby_package() { - ruby_package_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000200u; + _impl_.ruby_package_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000200u; } inline const std::string& FileOptions::ruby_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.ruby_package) @@ -12805,8 +12840,8 @@ inline const std::string& FileOptions::ruby_package() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void FileOptions::set_ruby_package(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000200u; - ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000200u; + _impl_.ruby_package_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.ruby_package) } inline std::string* FileOptions::mutable_ruby_package() { @@ -12815,41 +12850,40 @@ inline std::string* FileOptions::mutable_ruby_package() { return _s; } inline const std::string& FileOptions::_internal_ruby_package() const { - return ruby_package_.Get(); + return _impl_.ruby_package_.Get(); } inline void FileOptions::_internal_set_ruby_package(const std::string& value) { - _has_bits_[0] |= 0x00000200u; - ruby_package_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000200u; + _impl_.ruby_package_.Set(value, GetArenaForAllocation()); } inline std::string* FileOptions::_internal_mutable_ruby_package() { - _has_bits_[0] |= 0x00000200u; - return ruby_package_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000200u; + return _impl_.ruby_package_.Mutable(GetArenaForAllocation()); } inline std::string* FileOptions::release_ruby_package() { // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.ruby_package) if (!_internal_has_ruby_package()) { return nullptr; } - _has_bits_[0] &= ~0x00000200u; - auto* p = ruby_package_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000200u; + auto* p = _impl_.ruby_package_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (ruby_package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.ruby_package_.IsDefault()) { + _impl_.ruby_package_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void FileOptions::set_allocated_ruby_package(std::string* ruby_package) { if (ruby_package != nullptr) { - _has_bits_[0] |= 0x00000200u; + _impl_._has_bits_[0] |= 0x00000200u; } else { - _has_bits_[0] &= ~0x00000200u; + _impl_._has_bits_[0] &= ~0x00000200u; } - ruby_package_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ruby_package, - GetArenaForAllocation()); + _impl_.ruby_package_.SetAllocated(ruby_package, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (ruby_package_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.ruby_package_.IsDefault()) { + _impl_.ruby_package_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.ruby_package) @@ -12857,32 +12891,32 @@ inline void FileOptions::set_allocated_ruby_package(std::string* ruby_package) { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int FileOptions::_internal_uninterpreted_option_size() const { - return uninterpreted_option_.size(); + return _impl_.uninterpreted_option_.size(); } inline int FileOptions::uninterpreted_option_size() const { return _internal_uninterpreted_option_size(); } inline void FileOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); + _impl_.uninterpreted_option_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* FileOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); + return _impl_.uninterpreted_option_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >* FileOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileOptions.uninterpreted_option) - return &uninterpreted_option_; + return &_impl_.uninterpreted_option_; } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& FileOptions::_internal_uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); + return _impl_.uninterpreted_option_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& FileOptions::uninterpreted_option(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.uninterpreted_option) return _internal_uninterpreted_option(index); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* FileOptions::_internal_add_uninterpreted_option() { - return uninterpreted_option_.Add(); + return _impl_.uninterpreted_option_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* FileOptions::add_uninterpreted_option() { ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* _add = _internal_add_uninterpreted_option(); @@ -12892,7 +12926,7 @@ inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* FileOptions::add_uninterpre inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >& FileOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.FileOptions.uninterpreted_option) - return uninterpreted_option_; + return _impl_.uninterpreted_option_; } // ------------------------------------------------------------------- @@ -12901,26 +12935,26 @@ FileOptions::uninterpreted_option() const { // optional bool message_set_wire_format = 1 [default = false]; inline bool MessageOptions::_internal_has_message_set_wire_format() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool MessageOptions::has_message_set_wire_format() const { return _internal_has_message_set_wire_format(); } inline void MessageOptions::clear_message_set_wire_format() { - message_set_wire_format_ = false; - _has_bits_[0] &= ~0x00000001u; + _impl_.message_set_wire_format_ = false; + _impl_._has_bits_[0] &= ~0x00000001u; } inline bool MessageOptions::_internal_message_set_wire_format() const { - return message_set_wire_format_; + return _impl_.message_set_wire_format_; } inline bool MessageOptions::message_set_wire_format() const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.message_set_wire_format) return _internal_message_set_wire_format(); } inline void MessageOptions::_internal_set_message_set_wire_format(bool value) { - _has_bits_[0] |= 0x00000001u; - message_set_wire_format_ = value; + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.message_set_wire_format_ = value; } inline void MessageOptions::set_message_set_wire_format(bool value) { _internal_set_message_set_wire_format(value); @@ -12929,26 +12963,26 @@ inline void MessageOptions::set_message_set_wire_format(bool value) { // optional bool no_standard_descriptor_accessor = 2 [default = false]; inline bool MessageOptions::_internal_has_no_standard_descriptor_accessor() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool MessageOptions::has_no_standard_descriptor_accessor() const { return _internal_has_no_standard_descriptor_accessor(); } inline void MessageOptions::clear_no_standard_descriptor_accessor() { - no_standard_descriptor_accessor_ = false; - _has_bits_[0] &= ~0x00000002u; + _impl_.no_standard_descriptor_accessor_ = false; + _impl_._has_bits_[0] &= ~0x00000002u; } inline bool MessageOptions::_internal_no_standard_descriptor_accessor() const { - return no_standard_descriptor_accessor_; + return _impl_.no_standard_descriptor_accessor_; } inline bool MessageOptions::no_standard_descriptor_accessor() const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.no_standard_descriptor_accessor) return _internal_no_standard_descriptor_accessor(); } inline void MessageOptions::_internal_set_no_standard_descriptor_accessor(bool value) { - _has_bits_[0] |= 0x00000002u; - no_standard_descriptor_accessor_ = value; + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.no_standard_descriptor_accessor_ = value; } inline void MessageOptions::set_no_standard_descriptor_accessor(bool value) { _internal_set_no_standard_descriptor_accessor(value); @@ -12957,26 +12991,26 @@ inline void MessageOptions::set_no_standard_descriptor_accessor(bool value) { // optional bool deprecated = 3 [default = false]; inline bool MessageOptions::_internal_has_deprecated() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool MessageOptions::has_deprecated() const { return _internal_has_deprecated(); } inline void MessageOptions::clear_deprecated() { - deprecated_ = false; - _has_bits_[0] &= ~0x00000004u; + _impl_.deprecated_ = false; + _impl_._has_bits_[0] &= ~0x00000004u; } inline bool MessageOptions::_internal_deprecated() const { - return deprecated_; + return _impl_.deprecated_; } inline bool MessageOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.deprecated) return _internal_deprecated(); } inline void MessageOptions::_internal_set_deprecated(bool value) { - _has_bits_[0] |= 0x00000004u; - deprecated_ = value; + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.deprecated_ = value; } inline void MessageOptions::set_deprecated(bool value) { _internal_set_deprecated(value); @@ -12985,26 +13019,26 @@ inline void MessageOptions::set_deprecated(bool value) { // optional bool map_entry = 7; inline bool MessageOptions::_internal_has_map_entry() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } inline bool MessageOptions::has_map_entry() const { return _internal_has_map_entry(); } inline void MessageOptions::clear_map_entry() { - map_entry_ = false; - _has_bits_[0] &= ~0x00000008u; + _impl_.map_entry_ = false; + _impl_._has_bits_[0] &= ~0x00000008u; } inline bool MessageOptions::_internal_map_entry() const { - return map_entry_; + return _impl_.map_entry_; } inline bool MessageOptions::map_entry() const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.map_entry) return _internal_map_entry(); } inline void MessageOptions::_internal_set_map_entry(bool value) { - _has_bits_[0] |= 0x00000008u; - map_entry_ = value; + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.map_entry_ = value; } inline void MessageOptions::set_map_entry(bool value) { _internal_set_map_entry(value); @@ -13013,32 +13047,32 @@ inline void MessageOptions::set_map_entry(bool value) { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int MessageOptions::_internal_uninterpreted_option_size() const { - return uninterpreted_option_.size(); + return _impl_.uninterpreted_option_.size(); } inline int MessageOptions::uninterpreted_option_size() const { return _internal_uninterpreted_option_size(); } inline void MessageOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); + _impl_.uninterpreted_option_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* MessageOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.MessageOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); + return _impl_.uninterpreted_option_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >* MessageOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.MessageOptions.uninterpreted_option) - return &uninterpreted_option_; + return &_impl_.uninterpreted_option_; } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& MessageOptions::_internal_uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); + return _impl_.uninterpreted_option_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& MessageOptions::uninterpreted_option(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.uninterpreted_option) return _internal_uninterpreted_option(index); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* MessageOptions::_internal_add_uninterpreted_option() { - return uninterpreted_option_.Add(); + return _impl_.uninterpreted_option_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* MessageOptions::add_uninterpreted_option() { ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* _add = _internal_add_uninterpreted_option(); @@ -13048,7 +13082,7 @@ inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* MessageOptions::add_uninter inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >& MessageOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.MessageOptions.uninterpreted_option) - return uninterpreted_option_; + return _impl_.uninterpreted_option_; } // ------------------------------------------------------------------- @@ -13057,18 +13091,18 @@ MessageOptions::uninterpreted_option() const { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; inline bool FieldOptions::_internal_has_ctype() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool FieldOptions::has_ctype() const { return _internal_has_ctype(); } inline void FieldOptions::clear_ctype() { - ctype_ = 0; - _has_bits_[0] &= ~0x00000001u; + _impl_.ctype_ = 0; + _impl_._has_bits_[0] &= ~0x00000001u; } inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_CType FieldOptions::_internal_ctype() const { - return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldOptions_CType >(ctype_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldOptions_CType >(_impl_.ctype_); } inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_CType FieldOptions::ctype() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.ctype) @@ -13076,8 +13110,8 @@ inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_CType FieldOptions::ctype() const { } inline void FieldOptions::_internal_set_ctype(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType value) { assert(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType_IsValid(value)); - _has_bits_[0] |= 0x00000001u; - ctype_ = value; + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.ctype_ = value; } inline void FieldOptions::set_ctype(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType value) { _internal_set_ctype(value); @@ -13086,26 +13120,26 @@ inline void FieldOptions::set_ctype(::PROTOBUF_NAMESPACE_ID::FieldOptions_CType // optional bool packed = 2; inline bool FieldOptions::_internal_has_packed() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool FieldOptions::has_packed() const { return _internal_has_packed(); } inline void FieldOptions::clear_packed() { - packed_ = false; - _has_bits_[0] &= ~0x00000002u; + _impl_.packed_ = false; + _impl_._has_bits_[0] &= ~0x00000004u; } inline bool FieldOptions::_internal_packed() const { - return packed_; + return _impl_.packed_; } inline bool FieldOptions::packed() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.packed) return _internal_packed(); } inline void FieldOptions::_internal_set_packed(bool value) { - _has_bits_[0] |= 0x00000002u; - packed_ = value; + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.packed_ = value; } inline void FieldOptions::set_packed(bool value) { _internal_set_packed(value); @@ -13114,18 +13148,18 @@ inline void FieldOptions::set_packed(bool value) { // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; inline bool FieldOptions::_internal_has_jstype() const { - bool value = (_has_bits_[0] & 0x00000020u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool FieldOptions::has_jstype() const { return _internal_has_jstype(); } inline void FieldOptions::clear_jstype() { - jstype_ = 0; - _has_bits_[0] &= ~0x00000020u; + _impl_.jstype_ = 0; + _impl_._has_bits_[0] &= ~0x00000002u; } inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType FieldOptions::_internal_jstype() const { - return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType >(jstype_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType >(_impl_.jstype_); } inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType FieldOptions::jstype() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.jstype) @@ -13133,8 +13167,8 @@ inline ::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType FieldOptions::jstype() const } inline void FieldOptions::_internal_set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value) { assert(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType_IsValid(value)); - _has_bits_[0] |= 0x00000020u; - jstype_ = value; + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.jstype_ = value; } inline void FieldOptions::set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value) { _internal_set_jstype(value); @@ -13143,54 +13177,82 @@ inline void FieldOptions::set_jstype(::PROTOBUF_NAMESPACE_ID::FieldOptions_JSTyp // optional bool lazy = 5 [default = false]; inline bool FieldOptions::_internal_has_lazy() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } inline bool FieldOptions::has_lazy() const { return _internal_has_lazy(); } inline void FieldOptions::clear_lazy() { - lazy_ = false; - _has_bits_[0] &= ~0x00000004u; + _impl_.lazy_ = false; + _impl_._has_bits_[0] &= ~0x00000008u; } inline bool FieldOptions::_internal_lazy() const { - return lazy_; + return _impl_.lazy_; } inline bool FieldOptions::lazy() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.lazy) return _internal_lazy(); } inline void FieldOptions::_internal_set_lazy(bool value) { - _has_bits_[0] |= 0x00000004u; - lazy_ = value; + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.lazy_ = value; } inline void FieldOptions::set_lazy(bool value) { _internal_set_lazy(value); // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.lazy) } +// optional bool unverified_lazy = 15 [default = false]; +inline bool FieldOptions::_internal_has_unverified_lazy() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + return value; +} +inline bool FieldOptions::has_unverified_lazy() const { + return _internal_has_unverified_lazy(); +} +inline void FieldOptions::clear_unverified_lazy() { + _impl_.unverified_lazy_ = false; + _impl_._has_bits_[0] &= ~0x00000010u; +} +inline bool FieldOptions::_internal_unverified_lazy() const { + return _impl_.unverified_lazy_; +} +inline bool FieldOptions::unverified_lazy() const { + // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.unverified_lazy) + return _internal_unverified_lazy(); +} +inline void FieldOptions::_internal_set_unverified_lazy(bool value) { + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.unverified_lazy_ = value; +} +inline void FieldOptions::set_unverified_lazy(bool value) { + _internal_set_unverified_lazy(value); + // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.unverified_lazy) +} + // optional bool deprecated = 3 [default = false]; inline bool FieldOptions::_internal_has_deprecated() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; return value; } inline bool FieldOptions::has_deprecated() const { return _internal_has_deprecated(); } inline void FieldOptions::clear_deprecated() { - deprecated_ = false; - _has_bits_[0] &= ~0x00000008u; + _impl_.deprecated_ = false; + _impl_._has_bits_[0] &= ~0x00000020u; } inline bool FieldOptions::_internal_deprecated() const { - return deprecated_; + return _impl_.deprecated_; } inline bool FieldOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.deprecated) return _internal_deprecated(); } inline void FieldOptions::_internal_set_deprecated(bool value) { - _has_bits_[0] |= 0x00000008u; - deprecated_ = value; + _impl_._has_bits_[0] |= 0x00000020u; + _impl_.deprecated_ = value; } inline void FieldOptions::set_deprecated(bool value) { _internal_set_deprecated(value); @@ -13199,26 +13261,26 @@ inline void FieldOptions::set_deprecated(bool value) { // optional bool weak = 10 [default = false]; inline bool FieldOptions::_internal_has_weak() const { - bool value = (_has_bits_[0] & 0x00000010u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; return value; } inline bool FieldOptions::has_weak() const { return _internal_has_weak(); } inline void FieldOptions::clear_weak() { - weak_ = false; - _has_bits_[0] &= ~0x00000010u; + _impl_.weak_ = false; + _impl_._has_bits_[0] &= ~0x00000040u; } inline bool FieldOptions::_internal_weak() const { - return weak_; + return _impl_.weak_; } inline bool FieldOptions::weak() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.weak) return _internal_weak(); } inline void FieldOptions::_internal_set_weak(bool value) { - _has_bits_[0] |= 0x00000010u; - weak_ = value; + _impl_._has_bits_[0] |= 0x00000040u; + _impl_.weak_ = value; } inline void FieldOptions::set_weak(bool value) { _internal_set_weak(value); @@ -13227,32 +13289,32 @@ inline void FieldOptions::set_weak(bool value) { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int FieldOptions::_internal_uninterpreted_option_size() const { - return uninterpreted_option_.size(); + return _impl_.uninterpreted_option_.size(); } inline int FieldOptions::uninterpreted_option_size() const { return _internal_uninterpreted_option_size(); } inline void FieldOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); + _impl_.uninterpreted_option_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* FieldOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FieldOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); + return _impl_.uninterpreted_option_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >* FieldOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldOptions.uninterpreted_option) - return &uninterpreted_option_; + return &_impl_.uninterpreted_option_; } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& FieldOptions::_internal_uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); + return _impl_.uninterpreted_option_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& FieldOptions::uninterpreted_option(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.uninterpreted_option) return _internal_uninterpreted_option(index); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* FieldOptions::_internal_add_uninterpreted_option() { - return uninterpreted_option_.Add(); + return _impl_.uninterpreted_option_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* FieldOptions::add_uninterpreted_option() { ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* _add = _internal_add_uninterpreted_option(); @@ -13262,7 +13324,7 @@ inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* FieldOptions::add_uninterpr inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >& FieldOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.FieldOptions.uninterpreted_option) - return uninterpreted_option_; + return _impl_.uninterpreted_option_; } // ------------------------------------------------------------------- @@ -13271,32 +13333,32 @@ FieldOptions::uninterpreted_option() const { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int OneofOptions::_internal_uninterpreted_option_size() const { - return uninterpreted_option_.size(); + return _impl_.uninterpreted_option_.size(); } inline int OneofOptions::uninterpreted_option_size() const { return _internal_uninterpreted_option_size(); } inline void OneofOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); + _impl_.uninterpreted_option_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* OneofOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.OneofOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); + return _impl_.uninterpreted_option_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >* OneofOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.OneofOptions.uninterpreted_option) - return &uninterpreted_option_; + return &_impl_.uninterpreted_option_; } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& OneofOptions::_internal_uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); + return _impl_.uninterpreted_option_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& OneofOptions::uninterpreted_option(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.OneofOptions.uninterpreted_option) return _internal_uninterpreted_option(index); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* OneofOptions::_internal_add_uninterpreted_option() { - return uninterpreted_option_.Add(); + return _impl_.uninterpreted_option_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* OneofOptions::add_uninterpreted_option() { ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* _add = _internal_add_uninterpreted_option(); @@ -13306,7 +13368,7 @@ inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* OneofOptions::add_uninterpr inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >& OneofOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.OneofOptions.uninterpreted_option) - return uninterpreted_option_; + return _impl_.uninterpreted_option_; } // ------------------------------------------------------------------- @@ -13315,26 +13377,26 @@ OneofOptions::uninterpreted_option() const { // optional bool allow_alias = 2; inline bool EnumOptions::_internal_has_allow_alias() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool EnumOptions::has_allow_alias() const { return _internal_has_allow_alias(); } inline void EnumOptions::clear_allow_alias() { - allow_alias_ = false; - _has_bits_[0] &= ~0x00000001u; + _impl_.allow_alias_ = false; + _impl_._has_bits_[0] &= ~0x00000001u; } inline bool EnumOptions::_internal_allow_alias() const { - return allow_alias_; + return _impl_.allow_alias_; } inline bool EnumOptions::allow_alias() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.allow_alias) return _internal_allow_alias(); } inline void EnumOptions::_internal_set_allow_alias(bool value) { - _has_bits_[0] |= 0x00000001u; - allow_alias_ = value; + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.allow_alias_ = value; } inline void EnumOptions::set_allow_alias(bool value) { _internal_set_allow_alias(value); @@ -13343,26 +13405,26 @@ inline void EnumOptions::set_allow_alias(bool value) { // optional bool deprecated = 3 [default = false]; inline bool EnumOptions::_internal_has_deprecated() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool EnumOptions::has_deprecated() const { return _internal_has_deprecated(); } inline void EnumOptions::clear_deprecated() { - deprecated_ = false; - _has_bits_[0] &= ~0x00000002u; + _impl_.deprecated_ = false; + _impl_._has_bits_[0] &= ~0x00000002u; } inline bool EnumOptions::_internal_deprecated() const { - return deprecated_; + return _impl_.deprecated_; } inline bool EnumOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.deprecated) return _internal_deprecated(); } inline void EnumOptions::_internal_set_deprecated(bool value) { - _has_bits_[0] |= 0x00000002u; - deprecated_ = value; + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.deprecated_ = value; } inline void EnumOptions::set_deprecated(bool value) { _internal_set_deprecated(value); @@ -13371,32 +13433,32 @@ inline void EnumOptions::set_deprecated(bool value) { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int EnumOptions::_internal_uninterpreted_option_size() const { - return uninterpreted_option_.size(); + return _impl_.uninterpreted_option_.size(); } inline int EnumOptions::uninterpreted_option_size() const { return _internal_uninterpreted_option_size(); } inline void EnumOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); + _impl_.uninterpreted_option_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* EnumOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); + return _impl_.uninterpreted_option_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >* EnumOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumOptions.uninterpreted_option) - return &uninterpreted_option_; + return &_impl_.uninterpreted_option_; } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& EnumOptions::_internal_uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); + return _impl_.uninterpreted_option_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& EnumOptions::uninterpreted_option(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.uninterpreted_option) return _internal_uninterpreted_option(index); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* EnumOptions::_internal_add_uninterpreted_option() { - return uninterpreted_option_.Add(); + return _impl_.uninterpreted_option_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* EnumOptions::add_uninterpreted_option() { ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* _add = _internal_add_uninterpreted_option(); @@ -13406,7 +13468,7 @@ inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* EnumOptions::add_uninterpre inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >& EnumOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.EnumOptions.uninterpreted_option) - return uninterpreted_option_; + return _impl_.uninterpreted_option_; } // ------------------------------------------------------------------- @@ -13415,26 +13477,26 @@ EnumOptions::uninterpreted_option() const { // optional bool deprecated = 1 [default = false]; inline bool EnumValueOptions::_internal_has_deprecated() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool EnumValueOptions::has_deprecated() const { return _internal_has_deprecated(); } inline void EnumValueOptions::clear_deprecated() { - deprecated_ = false; - _has_bits_[0] &= ~0x00000001u; + _impl_.deprecated_ = false; + _impl_._has_bits_[0] &= ~0x00000001u; } inline bool EnumValueOptions::_internal_deprecated() const { - return deprecated_; + return _impl_.deprecated_; } inline bool EnumValueOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.deprecated) return _internal_deprecated(); } inline void EnumValueOptions::_internal_set_deprecated(bool value) { - _has_bits_[0] |= 0x00000001u; - deprecated_ = value; + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.deprecated_ = value; } inline void EnumValueOptions::set_deprecated(bool value) { _internal_set_deprecated(value); @@ -13443,32 +13505,32 @@ inline void EnumValueOptions::set_deprecated(bool value) { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int EnumValueOptions::_internal_uninterpreted_option_size() const { - return uninterpreted_option_.size(); + return _impl_.uninterpreted_option_.size(); } inline int EnumValueOptions::uninterpreted_option_size() const { return _internal_uninterpreted_option_size(); } inline void EnumValueOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); + _impl_.uninterpreted_option_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* EnumValueOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); + return _impl_.uninterpreted_option_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >* EnumValueOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValueOptions.uninterpreted_option) - return &uninterpreted_option_; + return &_impl_.uninterpreted_option_; } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& EnumValueOptions::_internal_uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); + return _impl_.uninterpreted_option_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& EnumValueOptions::uninterpreted_option(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.uninterpreted_option) return _internal_uninterpreted_option(index); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* EnumValueOptions::_internal_add_uninterpreted_option() { - return uninterpreted_option_.Add(); + return _impl_.uninterpreted_option_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* EnumValueOptions::add_uninterpreted_option() { ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* _add = _internal_add_uninterpreted_option(); @@ -13478,7 +13540,7 @@ inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* EnumValueOptions::add_unint inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >& EnumValueOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.EnumValueOptions.uninterpreted_option) - return uninterpreted_option_; + return _impl_.uninterpreted_option_; } // ------------------------------------------------------------------- @@ -13487,26 +13549,26 @@ EnumValueOptions::uninterpreted_option() const { // optional bool deprecated = 33 [default = false]; inline bool ServiceOptions::_internal_has_deprecated() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool ServiceOptions::has_deprecated() const { return _internal_has_deprecated(); } inline void ServiceOptions::clear_deprecated() { - deprecated_ = false; - _has_bits_[0] &= ~0x00000001u; + _impl_.deprecated_ = false; + _impl_._has_bits_[0] &= ~0x00000001u; } inline bool ServiceOptions::_internal_deprecated() const { - return deprecated_; + return _impl_.deprecated_; } inline bool ServiceOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.deprecated) return _internal_deprecated(); } inline void ServiceOptions::_internal_set_deprecated(bool value) { - _has_bits_[0] |= 0x00000001u; - deprecated_ = value; + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.deprecated_ = value; } inline void ServiceOptions::set_deprecated(bool value) { _internal_set_deprecated(value); @@ -13515,32 +13577,32 @@ inline void ServiceOptions::set_deprecated(bool value) { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int ServiceOptions::_internal_uninterpreted_option_size() const { - return uninterpreted_option_.size(); + return _impl_.uninterpreted_option_.size(); } inline int ServiceOptions::uninterpreted_option_size() const { return _internal_uninterpreted_option_size(); } inline void ServiceOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); + _impl_.uninterpreted_option_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* ServiceOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); + return _impl_.uninterpreted_option_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >* ServiceOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceOptions.uninterpreted_option) - return &uninterpreted_option_; + return &_impl_.uninterpreted_option_; } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& ServiceOptions::_internal_uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); + return _impl_.uninterpreted_option_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& ServiceOptions::uninterpreted_option(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.uninterpreted_option) return _internal_uninterpreted_option(index); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* ServiceOptions::_internal_add_uninterpreted_option() { - return uninterpreted_option_.Add(); + return _impl_.uninterpreted_option_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* ServiceOptions::add_uninterpreted_option() { ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* _add = _internal_add_uninterpreted_option(); @@ -13550,7 +13612,7 @@ inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* ServiceOptions::add_uninter inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >& ServiceOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.ServiceOptions.uninterpreted_option) - return uninterpreted_option_; + return _impl_.uninterpreted_option_; } // ------------------------------------------------------------------- @@ -13559,26 +13621,26 @@ ServiceOptions::uninterpreted_option() const { // optional bool deprecated = 33 [default = false]; inline bool MethodOptions::_internal_has_deprecated() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool MethodOptions::has_deprecated() const { return _internal_has_deprecated(); } inline void MethodOptions::clear_deprecated() { - deprecated_ = false; - _has_bits_[0] &= ~0x00000001u; + _impl_.deprecated_ = false; + _impl_._has_bits_[0] &= ~0x00000001u; } inline bool MethodOptions::_internal_deprecated() const { - return deprecated_; + return _impl_.deprecated_; } inline bool MethodOptions::deprecated() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.deprecated) return _internal_deprecated(); } inline void MethodOptions::_internal_set_deprecated(bool value) { - _has_bits_[0] |= 0x00000001u; - deprecated_ = value; + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.deprecated_ = value; } inline void MethodOptions::set_deprecated(bool value) { _internal_set_deprecated(value); @@ -13587,18 +13649,18 @@ inline void MethodOptions::set_deprecated(bool value) { // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; inline bool MethodOptions::_internal_has_idempotency_level() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool MethodOptions::has_idempotency_level() const { return _internal_has_idempotency_level(); } inline void MethodOptions::clear_idempotency_level() { - idempotency_level_ = 0; - _has_bits_[0] &= ~0x00000002u; + _impl_.idempotency_level_ = 0; + _impl_._has_bits_[0] &= ~0x00000002u; } inline ::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel MethodOptions::_internal_idempotency_level() const { - return static_cast< ::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel >(idempotency_level_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel >(_impl_.idempotency_level_); } inline ::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel MethodOptions::idempotency_level() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.idempotency_level) @@ -13606,8 +13668,8 @@ inline ::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel MethodOptions::id } inline void MethodOptions::_internal_set_idempotency_level(::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel value) { assert(::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel_IsValid(value)); - _has_bits_[0] |= 0x00000002u; - idempotency_level_ = value; + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.idempotency_level_ = value; } inline void MethodOptions::set_idempotency_level(::PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel value) { _internal_set_idempotency_level(value); @@ -13616,32 +13678,32 @@ inline void MethodOptions::set_idempotency_level(::PROTOBUF_NAMESPACE_ID::Method // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int MethodOptions::_internal_uninterpreted_option_size() const { - return uninterpreted_option_.size(); + return _impl_.uninterpreted_option_.size(); } inline int MethodOptions::uninterpreted_option_size() const { return _internal_uninterpreted_option_size(); } inline void MethodOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); + _impl_.uninterpreted_option_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* MethodOptions::mutable_uninterpreted_option(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.MethodOptions.uninterpreted_option) - return uninterpreted_option_.Mutable(index); + return _impl_.uninterpreted_option_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >* MethodOptions::mutable_uninterpreted_option() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.MethodOptions.uninterpreted_option) - return &uninterpreted_option_; + return &_impl_.uninterpreted_option_; } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& MethodOptions::_internal_uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); + return _impl_.uninterpreted_option_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption& MethodOptions::uninterpreted_option(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.uninterpreted_option) return _internal_uninterpreted_option(index); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* MethodOptions::_internal_add_uninterpreted_option() { - return uninterpreted_option_.Add(); + return _impl_.uninterpreted_option_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* MethodOptions::add_uninterpreted_option() { ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* _add = _internal_add_uninterpreted_option(); @@ -13651,7 +13713,7 @@ inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* MethodOptions::add_uninterp inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption >& MethodOptions::uninterpreted_option() const { // @@protoc_insertion_point(field_list:google.protobuf.MethodOptions.uninterpreted_option) - return uninterpreted_option_; + return _impl_.uninterpreted_option_; } // ------------------------------------------------------------------- @@ -13660,15 +13722,15 @@ MethodOptions::uninterpreted_option() const { // required string name_part = 1; inline bool UninterpretedOption_NamePart::_internal_has_name_part() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool UninterpretedOption_NamePart::has_name_part() const { return _internal_has_name_part(); } inline void UninterpretedOption_NamePart::clear_name_part() { - name_part_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.name_part_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& UninterpretedOption_NamePart::name_part() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part) @@ -13677,8 +13739,8 @@ inline const std::string& UninterpretedOption_NamePart::name_part() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void UninterpretedOption_NamePart::set_name_part(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_part_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part) } inline std::string* UninterpretedOption_NamePart::mutable_name_part() { @@ -13687,41 +13749,40 @@ inline std::string* UninterpretedOption_NamePart::mutable_name_part() { return _s; } inline const std::string& UninterpretedOption_NamePart::_internal_name_part() const { - return name_part_.Get(); + return _impl_.name_part_.Get(); } inline void UninterpretedOption_NamePart::_internal_set_name_part(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_part_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.name_part_.Set(value, GetArenaForAllocation()); } inline std::string* UninterpretedOption_NamePart::_internal_mutable_name_part() { - _has_bits_[0] |= 0x00000001u; - return name_part_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.name_part_.Mutable(GetArenaForAllocation()); } inline std::string* UninterpretedOption_NamePart::release_name_part() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part) if (!_internal_has_name_part()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = name_part_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.name_part_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_part_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_part_.IsDefault()) { + _impl_.name_part_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void UninterpretedOption_NamePart::set_allocated_name_part(std::string* name_part) { if (name_part != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - name_part_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name_part, - GetArenaForAllocation()); + _impl_.name_part_.SetAllocated(name_part, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_part_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_part_.IsDefault()) { + _impl_.name_part_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part) @@ -13729,26 +13790,26 @@ inline void UninterpretedOption_NamePart::set_allocated_name_part(std::string* n // required bool is_extension = 2; inline bool UninterpretedOption_NamePart::_internal_has_is_extension() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool UninterpretedOption_NamePart::has_is_extension() const { return _internal_has_is_extension(); } inline void UninterpretedOption_NamePart::clear_is_extension() { - is_extension_ = false; - _has_bits_[0] &= ~0x00000002u; + _impl_.is_extension_ = false; + _impl_._has_bits_[0] &= ~0x00000002u; } inline bool UninterpretedOption_NamePart::_internal_is_extension() const { - return is_extension_; + return _impl_.is_extension_; } inline bool UninterpretedOption_NamePart::is_extension() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.is_extension) return _internal_is_extension(); } inline void UninterpretedOption_NamePart::_internal_set_is_extension(bool value) { - _has_bits_[0] |= 0x00000002u; - is_extension_ = value; + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.is_extension_ = value; } inline void UninterpretedOption_NamePart::set_is_extension(bool value) { _internal_set_is_extension(value); @@ -13761,32 +13822,32 @@ inline void UninterpretedOption_NamePart::set_is_extension(bool value) { // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; inline int UninterpretedOption::_internal_name_size() const { - return name_.size(); + return _impl_.name_.size(); } inline int UninterpretedOption::name_size() const { return _internal_name_size(); } inline void UninterpretedOption::clear_name() { - name_.Clear(); + _impl_.name_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* UninterpretedOption::mutable_name(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.name) - return name_.Mutable(index); + return _impl_.name_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart >* UninterpretedOption::mutable_name() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.UninterpretedOption.name) - return &name_; + return &_impl_.name_; } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart& UninterpretedOption::_internal_name(int index) const { - return name_.Get(index); + return _impl_.name_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart& UninterpretedOption::name(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.name) return _internal_name(index); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* UninterpretedOption::_internal_add_name() { - return name_.Add(); + return _impl_.name_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* UninterpretedOption::add_name() { ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* _add = _internal_add_name(); @@ -13796,20 +13857,20 @@ inline ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* UninterpretedOptio inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart >& UninterpretedOption::name() const { // @@protoc_insertion_point(field_list:google.protobuf.UninterpretedOption.name) - return name_; + return _impl_.name_; } // optional string identifier_value = 3; inline bool UninterpretedOption::_internal_has_identifier_value() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool UninterpretedOption::has_identifier_value() const { return _internal_has_identifier_value(); } inline void UninterpretedOption::clear_identifier_value() { - identifier_value_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.identifier_value_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& UninterpretedOption::identifier_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value) @@ -13818,8 +13879,8 @@ inline const std::string& UninterpretedOption::identifier_value() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void UninterpretedOption::set_identifier_value(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.identifier_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value) } inline std::string* UninterpretedOption::mutable_identifier_value() { @@ -13828,41 +13889,40 @@ inline std::string* UninterpretedOption::mutable_identifier_value() { return _s; } inline const std::string& UninterpretedOption::_internal_identifier_value() const { - return identifier_value_.Get(); + return _impl_.identifier_value_.Get(); } inline void UninterpretedOption::_internal_set_identifier_value(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - identifier_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.identifier_value_.Set(value, GetArenaForAllocation()); } inline std::string* UninterpretedOption::_internal_mutable_identifier_value() { - _has_bits_[0] |= 0x00000001u; - return identifier_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.identifier_value_.Mutable(GetArenaForAllocation()); } inline std::string* UninterpretedOption::release_identifier_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.identifier_value) if (!_internal_has_identifier_value()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = identifier_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.identifier_value_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (identifier_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.identifier_value_.IsDefault()) { + _impl_.identifier_value_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void UninterpretedOption::set_allocated_identifier_value(std::string* identifier_value) { if (identifier_value != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - identifier_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), identifier_value, - GetArenaForAllocation()); + _impl_.identifier_value_.SetAllocated(identifier_value, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (identifier_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.identifier_value_.IsDefault()) { + _impl_.identifier_value_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.identifier_value) @@ -13870,26 +13930,26 @@ inline void UninterpretedOption::set_allocated_identifier_value(std::string* ide // optional uint64 positive_int_value = 4; inline bool UninterpretedOption::_internal_has_positive_int_value() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } inline bool UninterpretedOption::has_positive_int_value() const { return _internal_has_positive_int_value(); } inline void UninterpretedOption::clear_positive_int_value() { - positive_int_value_ = uint64_t{0u}; - _has_bits_[0] &= ~0x00000008u; + _impl_.positive_int_value_ = uint64_t{0u}; + _impl_._has_bits_[0] &= ~0x00000008u; } inline uint64_t UninterpretedOption::_internal_positive_int_value() const { - return positive_int_value_; + return _impl_.positive_int_value_; } inline uint64_t UninterpretedOption::positive_int_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.positive_int_value) return _internal_positive_int_value(); } inline void UninterpretedOption::_internal_set_positive_int_value(uint64_t value) { - _has_bits_[0] |= 0x00000008u; - positive_int_value_ = value; + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.positive_int_value_ = value; } inline void UninterpretedOption::set_positive_int_value(uint64_t value) { _internal_set_positive_int_value(value); @@ -13898,26 +13958,26 @@ inline void UninterpretedOption::set_positive_int_value(uint64_t value) { // optional int64 negative_int_value = 5; inline bool UninterpretedOption::_internal_has_negative_int_value() const { - bool value = (_has_bits_[0] & 0x00000010u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; return value; } inline bool UninterpretedOption::has_negative_int_value() const { return _internal_has_negative_int_value(); } inline void UninterpretedOption::clear_negative_int_value() { - negative_int_value_ = int64_t{0}; - _has_bits_[0] &= ~0x00000010u; + _impl_.negative_int_value_ = int64_t{0}; + _impl_._has_bits_[0] &= ~0x00000010u; } inline int64_t UninterpretedOption::_internal_negative_int_value() const { - return negative_int_value_; + return _impl_.negative_int_value_; } inline int64_t UninterpretedOption::negative_int_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.negative_int_value) return _internal_negative_int_value(); } inline void UninterpretedOption::_internal_set_negative_int_value(int64_t value) { - _has_bits_[0] |= 0x00000010u; - negative_int_value_ = value; + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.negative_int_value_ = value; } inline void UninterpretedOption::set_negative_int_value(int64_t value) { _internal_set_negative_int_value(value); @@ -13926,26 +13986,26 @@ inline void UninterpretedOption::set_negative_int_value(int64_t value) { // optional double double_value = 6; inline bool UninterpretedOption::_internal_has_double_value() const { - bool value = (_has_bits_[0] & 0x00000020u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; return value; } inline bool UninterpretedOption::has_double_value() const { return _internal_has_double_value(); } inline void UninterpretedOption::clear_double_value() { - double_value_ = 0; - _has_bits_[0] &= ~0x00000020u; + _impl_.double_value_ = 0; + _impl_._has_bits_[0] &= ~0x00000020u; } inline double UninterpretedOption::_internal_double_value() const { - return double_value_; + return _impl_.double_value_; } inline double UninterpretedOption::double_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.double_value) return _internal_double_value(); } inline void UninterpretedOption::_internal_set_double_value(double value) { - _has_bits_[0] |= 0x00000020u; - double_value_ = value; + _impl_._has_bits_[0] |= 0x00000020u; + _impl_.double_value_ = value; } inline void UninterpretedOption::set_double_value(double value) { _internal_set_double_value(value); @@ -13954,15 +14014,15 @@ inline void UninterpretedOption::set_double_value(double value) { // optional bytes string_value = 7; inline bool UninterpretedOption::_internal_has_string_value() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool UninterpretedOption::has_string_value() const { return _internal_has_string_value(); } inline void UninterpretedOption::clear_string_value() { - string_value_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; + _impl_.string_value_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const std::string& UninterpretedOption::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value) @@ -13971,8 +14031,8 @@ inline const std::string& UninterpretedOption::string_value() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void UninterpretedOption::set_string_value(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000002u; - string_value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.string_value_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value) } inline std::string* UninterpretedOption::mutable_string_value() { @@ -13981,41 +14041,40 @@ inline std::string* UninterpretedOption::mutable_string_value() { return _s; } inline const std::string& UninterpretedOption::_internal_string_value() const { - return string_value_.Get(); + return _impl_.string_value_.Get(); } inline void UninterpretedOption::_internal_set_string_value(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.string_value_.Set(value, GetArenaForAllocation()); } inline std::string* UninterpretedOption::_internal_mutable_string_value() { - _has_bits_[0] |= 0x00000002u; - return string_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.string_value_.Mutable(GetArenaForAllocation()); } inline std::string* UninterpretedOption::release_string_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.string_value) if (!_internal_has_string_value()) { return nullptr; } - _has_bits_[0] &= ~0x00000002u; - auto* p = string_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.string_value_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (string_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.string_value_.IsDefault()) { + _impl_.string_value_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void UninterpretedOption::set_allocated_string_value(std::string* string_value) { if (string_value != nullptr) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - string_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), string_value, - GetArenaForAllocation()); + _impl_.string_value_.SetAllocated(string_value, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (string_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.string_value_.IsDefault()) { + _impl_.string_value_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.string_value) @@ -14023,15 +14082,15 @@ inline void UninterpretedOption::set_allocated_string_value(std::string* string_ // optional string aggregate_value = 8; inline bool UninterpretedOption::_internal_has_aggregate_value() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool UninterpretedOption::has_aggregate_value() const { return _internal_has_aggregate_value(); } inline void UninterpretedOption::clear_aggregate_value() { - aggregate_value_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000004u; + _impl_.aggregate_value_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; } inline const std::string& UninterpretedOption::aggregate_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value) @@ -14040,8 +14099,8 @@ inline const std::string& UninterpretedOption::aggregate_value() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void UninterpretedOption::set_aggregate_value(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000004u; - aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.aggregate_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value) } inline std::string* UninterpretedOption::mutable_aggregate_value() { @@ -14050,41 +14109,40 @@ inline std::string* UninterpretedOption::mutable_aggregate_value() { return _s; } inline const std::string& UninterpretedOption::_internal_aggregate_value() const { - return aggregate_value_.Get(); + return _impl_.aggregate_value_.Get(); } inline void UninterpretedOption::_internal_set_aggregate_value(const std::string& value) { - _has_bits_[0] |= 0x00000004u; - aggregate_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.aggregate_value_.Set(value, GetArenaForAllocation()); } inline std::string* UninterpretedOption::_internal_mutable_aggregate_value() { - _has_bits_[0] |= 0x00000004u; - return aggregate_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.aggregate_value_.Mutable(GetArenaForAllocation()); } inline std::string* UninterpretedOption::release_aggregate_value() { // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.aggregate_value) if (!_internal_has_aggregate_value()) { return nullptr; } - _has_bits_[0] &= ~0x00000004u; - auto* p = aggregate_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.aggregate_value_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (aggregate_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.aggregate_value_.IsDefault()) { + _impl_.aggregate_value_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void UninterpretedOption::set_allocated_aggregate_value(std::string* aggregate_value) { if (aggregate_value != nullptr) { - _has_bits_[0] |= 0x00000004u; + _impl_._has_bits_[0] |= 0x00000004u; } else { - _has_bits_[0] &= ~0x00000004u; + _impl_._has_bits_[0] &= ~0x00000004u; } - aggregate_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), aggregate_value, - GetArenaForAllocation()); + _impl_.aggregate_value_.SetAllocated(aggregate_value, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (aggregate_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.aggregate_value_.IsDefault()) { + _impl_.aggregate_value_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value) @@ -14096,27 +14154,27 @@ inline void UninterpretedOption::set_allocated_aggregate_value(std::string* aggr // repeated int32 path = 1 [packed = true]; inline int SourceCodeInfo_Location::_internal_path_size() const { - return path_.size(); + return _impl_.path_.size(); } inline int SourceCodeInfo_Location::path_size() const { return _internal_path_size(); } inline void SourceCodeInfo_Location::clear_path() { - path_.Clear(); + _impl_.path_.Clear(); } inline int32_t SourceCodeInfo_Location::_internal_path(int index) const { - return path_.Get(index); + return _impl_.path_.Get(index); } inline int32_t SourceCodeInfo_Location::path(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.path) return _internal_path(index); } inline void SourceCodeInfo_Location::set_path(int index, int32_t value) { - path_.Set(index, value); + _impl_.path_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.path) } inline void SourceCodeInfo_Location::_internal_add_path(int32_t value) { - path_.Add(value); + _impl_.path_.Add(value); } inline void SourceCodeInfo_Location::add_path(int32_t value) { _internal_add_path(value); @@ -14124,7 +14182,7 @@ inline void SourceCodeInfo_Location::add_path(int32_t value) { } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >& SourceCodeInfo_Location::_internal_path() const { - return path_; + return _impl_.path_; } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >& SourceCodeInfo_Location::path() const { @@ -14133,7 +14191,7 @@ SourceCodeInfo_Location::path() const { } inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >* SourceCodeInfo_Location::_internal_mutable_path() { - return &path_; + return &_impl_.path_; } inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >* SourceCodeInfo_Location::mutable_path() { @@ -14143,27 +14201,27 @@ SourceCodeInfo_Location::mutable_path() { // repeated int32 span = 2 [packed = true]; inline int SourceCodeInfo_Location::_internal_span_size() const { - return span_.size(); + return _impl_.span_.size(); } inline int SourceCodeInfo_Location::span_size() const { return _internal_span_size(); } inline void SourceCodeInfo_Location::clear_span() { - span_.Clear(); + _impl_.span_.Clear(); } inline int32_t SourceCodeInfo_Location::_internal_span(int index) const { - return span_.Get(index); + return _impl_.span_.Get(index); } inline int32_t SourceCodeInfo_Location::span(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.span) return _internal_span(index); } inline void SourceCodeInfo_Location::set_span(int index, int32_t value) { - span_.Set(index, value); + _impl_.span_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.span) } inline void SourceCodeInfo_Location::_internal_add_span(int32_t value) { - span_.Add(value); + _impl_.span_.Add(value); } inline void SourceCodeInfo_Location::add_span(int32_t value) { _internal_add_span(value); @@ -14171,7 +14229,7 @@ inline void SourceCodeInfo_Location::add_span(int32_t value) { } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >& SourceCodeInfo_Location::_internal_span() const { - return span_; + return _impl_.span_; } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >& SourceCodeInfo_Location::span() const { @@ -14180,7 +14238,7 @@ SourceCodeInfo_Location::span() const { } inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >* SourceCodeInfo_Location::_internal_mutable_span() { - return &span_; + return &_impl_.span_; } inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >* SourceCodeInfo_Location::mutable_span() { @@ -14190,15 +14248,15 @@ SourceCodeInfo_Location::mutable_span() { // optional string leading_comments = 3; inline bool SourceCodeInfo_Location::_internal_has_leading_comments() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool SourceCodeInfo_Location::has_leading_comments() const { return _internal_has_leading_comments(); } inline void SourceCodeInfo_Location::clear_leading_comments() { - leading_comments_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.leading_comments_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& SourceCodeInfo_Location::leading_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments) @@ -14207,8 +14265,8 @@ inline const std::string& SourceCodeInfo_Location::leading_comments() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void SourceCodeInfo_Location::set_leading_comments(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.leading_comments_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments) } inline std::string* SourceCodeInfo_Location::mutable_leading_comments() { @@ -14217,41 +14275,40 @@ inline std::string* SourceCodeInfo_Location::mutable_leading_comments() { return _s; } inline const std::string& SourceCodeInfo_Location::_internal_leading_comments() const { - return leading_comments_.Get(); + return _impl_.leading_comments_.Get(); } inline void SourceCodeInfo_Location::_internal_set_leading_comments(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - leading_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.leading_comments_.Set(value, GetArenaForAllocation()); } inline std::string* SourceCodeInfo_Location::_internal_mutable_leading_comments() { - _has_bits_[0] |= 0x00000001u; - return leading_comments_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.leading_comments_.Mutable(GetArenaForAllocation()); } inline std::string* SourceCodeInfo_Location::release_leading_comments() { // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.leading_comments) if (!_internal_has_leading_comments()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = leading_comments_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.leading_comments_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (leading_comments_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.leading_comments_.IsDefault()) { + _impl_.leading_comments_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void SourceCodeInfo_Location::set_allocated_leading_comments(std::string* leading_comments) { if (leading_comments != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - leading_comments_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), leading_comments, - GetArenaForAllocation()); + _impl_.leading_comments_.SetAllocated(leading_comments, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (leading_comments_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.leading_comments_.IsDefault()) { + _impl_.leading_comments_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.leading_comments) @@ -14259,15 +14316,15 @@ inline void SourceCodeInfo_Location::set_allocated_leading_comments(std::string* // optional string trailing_comments = 4; inline bool SourceCodeInfo_Location::_internal_has_trailing_comments() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool SourceCodeInfo_Location::has_trailing_comments() const { return _internal_has_trailing_comments(); } inline void SourceCodeInfo_Location::clear_trailing_comments() { - trailing_comments_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; + _impl_.trailing_comments_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; } inline const std::string& SourceCodeInfo_Location::trailing_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments) @@ -14276,8 +14333,8 @@ inline const std::string& SourceCodeInfo_Location::trailing_comments() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void SourceCodeInfo_Location::set_trailing_comments(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000002u; - trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.trailing_comments_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments) } inline std::string* SourceCodeInfo_Location::mutable_trailing_comments() { @@ -14286,41 +14343,40 @@ inline std::string* SourceCodeInfo_Location::mutable_trailing_comments() { return _s; } inline const std::string& SourceCodeInfo_Location::_internal_trailing_comments() const { - return trailing_comments_.Get(); + return _impl_.trailing_comments_.Get(); } inline void SourceCodeInfo_Location::_internal_set_trailing_comments(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - trailing_comments_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.trailing_comments_.Set(value, GetArenaForAllocation()); } inline std::string* SourceCodeInfo_Location::_internal_mutable_trailing_comments() { - _has_bits_[0] |= 0x00000002u; - return trailing_comments_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.trailing_comments_.Mutable(GetArenaForAllocation()); } inline std::string* SourceCodeInfo_Location::release_trailing_comments() { // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.trailing_comments) if (!_internal_has_trailing_comments()) { return nullptr; } - _has_bits_[0] &= ~0x00000002u; - auto* p = trailing_comments_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.trailing_comments_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (trailing_comments_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.trailing_comments_.IsDefault()) { + _impl_.trailing_comments_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void SourceCodeInfo_Location::set_allocated_trailing_comments(std::string* trailing_comments) { if (trailing_comments != nullptr) { - _has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000002u; } - trailing_comments_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), trailing_comments, - GetArenaForAllocation()); + _impl_.trailing_comments_.SetAllocated(trailing_comments, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (trailing_comments_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.trailing_comments_.IsDefault()) { + _impl_.trailing_comments_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.trailing_comments) @@ -14328,13 +14384,13 @@ inline void SourceCodeInfo_Location::set_allocated_trailing_comments(std::string // repeated string leading_detached_comments = 6; inline int SourceCodeInfo_Location::_internal_leading_detached_comments_size() const { - return leading_detached_comments_.size(); + return _impl_.leading_detached_comments_.size(); } inline int SourceCodeInfo_Location::leading_detached_comments_size() const { return _internal_leading_detached_comments_size(); } inline void SourceCodeInfo_Location::clear_leading_detached_comments() { - leading_detached_comments_.Clear(); + _impl_.leading_detached_comments_.Clear(); } inline std::string* SourceCodeInfo_Location::add_leading_detached_comments() { std::string* _s = _internal_add_leading_detached_comments(); @@ -14342,7 +14398,7 @@ inline std::string* SourceCodeInfo_Location::add_leading_detached_comments() { return _s; } inline const std::string& SourceCodeInfo_Location::_internal_leading_detached_comments(int index) const { - return leading_detached_comments_.Get(index); + return _impl_.leading_detached_comments_.Get(index); } inline const std::string& SourceCodeInfo_Location::leading_detached_comments(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) @@ -14350,55 +14406,55 @@ inline const std::string& SourceCodeInfo_Location::leading_detached_comments(int } inline std::string* SourceCodeInfo_Location::mutable_leading_detached_comments(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) - return leading_detached_comments_.Mutable(index); + return _impl_.leading_detached_comments_.Mutable(index); } inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const std::string& value) { - leading_detached_comments_.Mutable(index)->assign(value); + _impl_.leading_detached_comments_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, std::string&& value) { - leading_detached_comments_.Mutable(index)->assign(std::move(value)); + _impl_.leading_detached_comments_.Mutable(index)->assign(std::move(value)); // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) { GOOGLE_DCHECK(value != nullptr); - leading_detached_comments_.Mutable(index)->assign(value); + _impl_.leading_detached_comments_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value, size_t size) { - leading_detached_comments_.Mutable(index)->assign( + _impl_.leading_detached_comments_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } inline std::string* SourceCodeInfo_Location::_internal_add_leading_detached_comments() { - return leading_detached_comments_.Add(); + return _impl_.leading_detached_comments_.Add(); } inline void SourceCodeInfo_Location::add_leading_detached_comments(const std::string& value) { - leading_detached_comments_.Add()->assign(value); + _impl_.leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } inline void SourceCodeInfo_Location::add_leading_detached_comments(std::string&& value) { - leading_detached_comments_.Add(std::move(value)); + _impl_.leading_detached_comments_.Add(std::move(value)); // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } inline void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) { GOOGLE_DCHECK(value != nullptr); - leading_detached_comments_.Add()->assign(value); + _impl_.leading_detached_comments_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } inline void SourceCodeInfo_Location::add_leading_detached_comments(const char* value, size_t size) { - leading_detached_comments_.Add()->assign(reinterpret_cast<const char*>(value), size); + _impl_.leading_detached_comments_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>& SourceCodeInfo_Location::leading_detached_comments() const { // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) - return leading_detached_comments_; + return _impl_.leading_detached_comments_; } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>* SourceCodeInfo_Location::mutable_leading_detached_comments() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) - return &leading_detached_comments_; + return &_impl_.leading_detached_comments_; } // ------------------------------------------------------------------- @@ -14407,32 +14463,32 @@ SourceCodeInfo_Location::mutable_leading_detached_comments() { // repeated .google.protobuf.SourceCodeInfo.Location location = 1; inline int SourceCodeInfo::_internal_location_size() const { - return location_.size(); + return _impl_.location_.size(); } inline int SourceCodeInfo::location_size() const { return _internal_location_size(); } inline void SourceCodeInfo::clear_location() { - location_.Clear(); + _impl_.location_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* SourceCodeInfo::mutable_location(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.location) - return location_.Mutable(index); + return _impl_.location_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location >* SourceCodeInfo::mutable_location() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.location) - return &location_; + return &_impl_.location_; } inline const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location& SourceCodeInfo::_internal_location(int index) const { - return location_.Get(index); + return _impl_.location_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location& SourceCodeInfo::location(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.location) return _internal_location(index); } inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* SourceCodeInfo::_internal_add_location() { - return location_.Add(); + return _impl_.location_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* SourceCodeInfo::add_location() { ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* _add = _internal_add_location(); @@ -14442,7 +14498,7 @@ inline ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* SourceCodeInfo::add_loc inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location >& SourceCodeInfo::location() const { // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.location) - return location_; + return _impl_.location_; } // ------------------------------------------------------------------- @@ -14451,27 +14507,27 @@ SourceCodeInfo::location() const { // repeated int32 path = 1 [packed = true]; inline int GeneratedCodeInfo_Annotation::_internal_path_size() const { - return path_.size(); + return _impl_.path_.size(); } inline int GeneratedCodeInfo_Annotation::path_size() const { return _internal_path_size(); } inline void GeneratedCodeInfo_Annotation::clear_path() { - path_.Clear(); + _impl_.path_.Clear(); } inline int32_t GeneratedCodeInfo_Annotation::_internal_path(int index) const { - return path_.Get(index); + return _impl_.path_.Get(index); } inline int32_t GeneratedCodeInfo_Annotation::path(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.path) return _internal_path(index); } inline void GeneratedCodeInfo_Annotation::set_path(int index, int32_t value) { - path_.Set(index, value); + _impl_.path_.Set(index, value); // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path) } inline void GeneratedCodeInfo_Annotation::_internal_add_path(int32_t value) { - path_.Add(value); + _impl_.path_.Add(value); } inline void GeneratedCodeInfo_Annotation::add_path(int32_t value) { _internal_add_path(value); @@ -14479,7 +14535,7 @@ inline void GeneratedCodeInfo_Annotation::add_path(int32_t value) { } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >& GeneratedCodeInfo_Annotation::_internal_path() const { - return path_; + return _impl_.path_; } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >& GeneratedCodeInfo_Annotation::path() const { @@ -14488,7 +14544,7 @@ GeneratedCodeInfo_Annotation::path() const { } inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >* GeneratedCodeInfo_Annotation::_internal_mutable_path() { - return &path_; + return &_impl_.path_; } inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< int32_t >* GeneratedCodeInfo_Annotation::mutable_path() { @@ -14498,15 +14554,15 @@ GeneratedCodeInfo_Annotation::mutable_path() { // optional string source_file = 2; inline bool GeneratedCodeInfo_Annotation::_internal_has_source_file() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } inline bool GeneratedCodeInfo_Annotation::has_source_file() const { return _internal_has_source_file(); } inline void GeneratedCodeInfo_Annotation::clear_source_file() { - source_file_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _impl_.source_file_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; } inline const std::string& GeneratedCodeInfo_Annotation::source_file() const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file) @@ -14515,8 +14571,8 @@ inline const std::string& GeneratedCodeInfo_Annotation::source_file() const { template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void GeneratedCodeInfo_Annotation::set_source_file(ArgT0&& arg0, ArgT... args) { - _has_bits_[0] |= 0x00000001u; - source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.source_file_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } inline std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { @@ -14525,41 +14581,40 @@ inline std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { return _s; } inline const std::string& GeneratedCodeInfo_Annotation::_internal_source_file() const { - return source_file_.Get(); + return _impl_.source_file_.Get(); } inline void GeneratedCodeInfo_Annotation::_internal_set_source_file(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - source_file_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.source_file_.Set(value, GetArenaForAllocation()); } inline std::string* GeneratedCodeInfo_Annotation::_internal_mutable_source_file() { - _has_bits_[0] |= 0x00000001u; - return source_file_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.source_file_.Mutable(GetArenaForAllocation()); } inline std::string* GeneratedCodeInfo_Annotation::release_source_file() { // @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file) if (!_internal_has_source_file()) { return nullptr; } - _has_bits_[0] &= ~0x00000001u; - auto* p = source_file_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.source_file_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (source_file_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.source_file_.IsDefault()) { + _impl_.source_file_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(std::string* source_file) { if (source_file != nullptr) { - _has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000001u; } else { - _has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000001u; } - source_file_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), source_file, - GetArenaForAllocation()); + _impl_.source_file_.SetAllocated(source_file, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (source_file_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.source_file_.IsDefault()) { + _impl_.source_file_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file) @@ -14567,26 +14622,26 @@ inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(std::string* // optional int32 begin = 3; inline bool GeneratedCodeInfo_Annotation::_internal_has_begin() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; } inline bool GeneratedCodeInfo_Annotation::has_begin() const { return _internal_has_begin(); } inline void GeneratedCodeInfo_Annotation::clear_begin() { - begin_ = 0; - _has_bits_[0] &= ~0x00000002u; + _impl_.begin_ = 0; + _impl_._has_bits_[0] &= ~0x00000002u; } inline int32_t GeneratedCodeInfo_Annotation::_internal_begin() const { - return begin_; + return _impl_.begin_; } inline int32_t GeneratedCodeInfo_Annotation::begin() const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.begin) return _internal_begin(); } inline void GeneratedCodeInfo_Annotation::_internal_set_begin(int32_t value) { - _has_bits_[0] |= 0x00000002u; - begin_ = value; + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.begin_ = value; } inline void GeneratedCodeInfo_Annotation::set_begin(int32_t value) { _internal_set_begin(value); @@ -14595,26 +14650,26 @@ inline void GeneratedCodeInfo_Annotation::set_begin(int32_t value) { // optional int32 end = 4; inline bool GeneratedCodeInfo_Annotation::_internal_has_end() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool GeneratedCodeInfo_Annotation::has_end() const { return _internal_has_end(); } inline void GeneratedCodeInfo_Annotation::clear_end() { - end_ = 0; - _has_bits_[0] &= ~0x00000004u; + _impl_.end_ = 0; + _impl_._has_bits_[0] &= ~0x00000004u; } inline int32_t GeneratedCodeInfo_Annotation::_internal_end() const { - return end_; + return _impl_.end_; } inline int32_t GeneratedCodeInfo_Annotation::end() const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.end) return _internal_end(); } inline void GeneratedCodeInfo_Annotation::_internal_set_end(int32_t value) { - _has_bits_[0] |= 0x00000004u; - end_ = value; + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.end_ = value; } inline void GeneratedCodeInfo_Annotation::set_end(int32_t value) { _internal_set_end(value); @@ -14627,32 +14682,32 @@ inline void GeneratedCodeInfo_Annotation::set_end(int32_t value) { // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; inline int GeneratedCodeInfo::_internal_annotation_size() const { - return annotation_.size(); + return _impl_.annotation_.size(); } inline int GeneratedCodeInfo::annotation_size() const { return _internal_annotation_size(); } inline void GeneratedCodeInfo::clear_annotation() { - annotation_.Clear(); + _impl_.annotation_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::mutable_annotation(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.annotation) - return annotation_.Mutable(index); + return _impl_.annotation_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation >* GeneratedCodeInfo::mutable_annotation() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.annotation) - return &annotation_; + return &_impl_.annotation_; } inline const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation& GeneratedCodeInfo::_internal_annotation(int index) const { - return annotation_.Get(index); + return _impl_.annotation_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation& GeneratedCodeInfo::annotation(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.annotation) return _internal_annotation(index); } inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::_internal_add_annotation() { - return annotation_.Add(); + return _impl_.annotation_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::add_annotation() { ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* _add = _internal_add_annotation(); @@ -14662,7 +14717,7 @@ inline ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* GeneratedCodeInfo: inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation >& GeneratedCodeInfo::annotation() const { // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.annotation) - return annotation_; + return _impl_.annotation_; } #ifdef __GNUC__ diff --git a/r5dev/thirdparty/protobuf/descriptor.proto b/r5dev/thirdparty/protobuf/descriptor.proto index 156e410a..f8eb216c 100644 --- a/r5dev/thirdparty/protobuf/descriptor.proto +++ b/r5dev/thirdparty/protobuf/descriptor.proto @@ -199,7 +199,6 @@ message FieldDescriptorProto { // For booleans, "true" or "false". // For strings, contains the default text contents (not escaped in any way). // For bytes, contains the C escaped value. All bytes >= 128 are escaped. - // TODO(kenton): Base-64 encode? optional string default_value = 7; // If set, gives the index of a oneof in the containing type's oneof_decl @@ -604,8 +603,19 @@ message FieldOptions { // implementation must either *always* check its required fields, or *never* // check its required fields, regardless of whether or not the message has // been parsed. + // + // As of 2021, lazy does no correctness checks on the byte stream during + // parsing. This may lead to crashes if and when an invalid byte stream is + // finally parsed upon access. + // + // TODO(b/211906113): Enable validation on lazy fields. optional bool lazy = 5 [default = false]; + // unverified_lazy does no correctness checks on the byte stream. This should + // only be used where lazy with verification is prohibitive for performance + // reasons. + optional bool unverified_lazy = 15 [default = false]; + // Is this field deprecated? // Depending on the target platform, this can emit Deprecated annotations // for accessors, or it will be completely ignored; in the very least, this @@ -730,8 +740,8 @@ message UninterpretedOption { // The name of the uninterpreted option. Each string represents a segment in // a dot-separated name. is_extension is true iff a segment represents an // extension (denoted with parentheses in options specs in .proto files). - // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents - // "foo.(bar.baz).qux". + // E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents + // "foo.(bar.baz).moo". message NamePart { required string name_part = 1; required bool is_extension = 2; @@ -803,8 +813,8 @@ message SourceCodeInfo { // location. // // Each element is a field number or an index. They form a path from - // the root FileDescriptorProto to the place where the definition. For - // example, this path: + // the root FileDescriptorProto to the place where the definition occurs. + // For example, this path: // [ 4, 3, 2, 7, 1 ] // refers to: // file.message_type(3) // 4, 3 @@ -858,13 +868,13 @@ message SourceCodeInfo { // // Comment attached to baz. // // Another line attached to baz. // - // // Comment attached to qux. + // // Comment attached to moo. // // - // // Another line attached to qux. - // optional double qux = 4; + // // Another line attached to moo. + // optional double moo = 4; // // // Detached comment for corge. This is not leading or trailing comments - // // to qux or corge because there are blank lines separating it from + // // to moo or corge because there are blank lines separating it from // // both. // // // Detached comment for corge paragraph 2. diff --git a/r5dev/thirdparty/protobuf/descriptor_database.cc b/r5dev/thirdparty/protobuf/descriptor_database.cc index 4a854887..bc634593 100644 --- a/r5dev/thirdparty/protobuf/descriptor_database.cc +++ b/r5dev/thirdparty/protobuf/descriptor_database.cc @@ -34,6 +34,7 @@ #include <thirdparty/protobuf/descriptor_database.h> +#include <algorithm> #include <set> #include <thirdparty/protobuf/descriptor.pb.h> @@ -1027,5 +1028,21 @@ bool MergedDescriptorDatabase::FindAllExtensionNumbers( } +bool MergedDescriptorDatabase::FindAllFileNames( + std::vector<std::string>* output) { + bool implemented = false; + for (DescriptorDatabase* source : sources_) { + std::vector<std::string> source_output; + if (source->FindAllFileNames(&source_output)) { + output->reserve(output->size() + source_output.size()); + for (auto& source : source_output) { + output->push_back(std::move(source)); + } + implemented = true; + } + } + return implemented; +} + } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/descriptor_database.h b/r5dev/thirdparty/protobuf/descriptor_database.h index 8e732902..e9e54d3c 100644 --- a/r5dev/thirdparty/protobuf/descriptor_database.h +++ b/r5dev/thirdparty/protobuf/descriptor_database.h @@ -37,13 +37,16 @@ #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__ #define GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__ + #include <map> #include <string> #include <utility> #include <vector> + #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/descriptor.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG @@ -378,6 +381,10 @@ class PROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase { std::vector<int>* output) override; + // This function is best-effort. Returns true if at least one underlying + // DescriptorDatabase returns true. + bool FindAllFileNames(std::vector<std::string>* output) override; + private: std::vector<DescriptorDatabase*> sources_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase); diff --git a/r5dev/thirdparty/protobuf/descriptor_database_unittest.cc b/r5dev/thirdparty/protobuf/descriptor_database_unittest.cc index 295b57c7..d567cbd1 100644 --- a/r5dev/thirdparty/protobuf/descriptor_database_unittest.cc +++ b/r5dev/thirdparty/protobuf/descriptor_database_unittest.cc @@ -580,7 +580,7 @@ class MergedDescriptorDatabaseTest : public testing::Test { : forward_merged_(&database1_, &database2_), reverse_merged_(&database2_, &database1_) {} - virtual void SetUp() { + void SetUp() override { AddToDatabase( &database1_, "name: \"foo.proto\" " @@ -799,6 +799,13 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { } } +TEST_F(MergedDescriptorDatabaseTest, FindAllFileNames) { + std::vector<std::string> files; + EXPECT_TRUE(forward_merged_.FindAllFileNames(&files)); + EXPECT_THAT(files, ::testing::UnorderedElementsAre("foo.proto", "bar.proto", + "baz.proto", "baz.proto")); +} + } // anonymous namespace } // namespace protobuf diff --git a/r5dev/thirdparty/protobuf/descriptor_unittest.cc b/r5dev/thirdparty/protobuf/descriptor_unittest.cc index f4a6383a..a25d8f6e 100644 --- a/r5dev/thirdparty/protobuf/descriptor_unittest.cc +++ b/r5dev/thirdparty/protobuf/descriptor_unittest.cc @@ -63,8 +63,11 @@ #include <thirdparty/protobuf/stubs/substitute.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> +using ::testing::AnyOf; + namespace google { namespace protobuf { @@ -198,7 +201,7 @@ void AddEmptyEnum(FileDescriptorProto* file, const std::string& name) { class MockErrorCollector : public DescriptorPool::ErrorCollector { public: MockErrorCollector() {} - ~MockErrorCollector() {} + ~MockErrorCollector() override {} std::string text_; std::string warning_text_; @@ -625,7 +628,7 @@ class DescriptorTest : public testing::Test { // required string foo = 1; // optional TestEnum bar = 6; // repeated TestForeign baz = 500000000; - // optional group qux = 15 {} + // optional group moo = 15 {} // } // // // in "bar.proto" @@ -633,7 +636,7 @@ class DescriptorTest : public testing::Test { // message TestMessage2 { // required string foo = 1; // required string bar = 2; - // required string quux = 6; + // required string mooo = 6; // } // // // in "map.proto" @@ -651,7 +654,7 @@ class DescriptorTest : public testing::Test { // optional int32 field_name6 = 6 [json_name = "@type"]; // } // - // We cheat and use TestForeign as the type for qux rather than create + // We cheat and use TestForeign as the type for moo rather than create // an actual nested type. // // Since all primitive types (including string) use the same building @@ -675,7 +678,7 @@ class DescriptorTest : public testing::Test { AddField(message, "baz", 500000000, FieldDescriptorProto::LABEL_REPEATED, FieldDescriptorProto::TYPE_MESSAGE) ->set_type_name("TestForeign"); - AddField(message, "qux", 15, FieldDescriptorProto::LABEL_OPTIONAL, + AddField(message, "moo", 15, FieldDescriptorProto::LABEL_OPTIONAL, FieldDescriptorProto::TYPE_GROUP) ->set_type_name("TestForeign"); @@ -688,7 +691,7 @@ class DescriptorTest : public testing::Test { FieldDescriptorProto::TYPE_STRING); AddField(message2, "bar", 2, FieldDescriptorProto::LABEL_REQUIRED, FieldDescriptorProto::TYPE_STRING); - AddField(message2, "quux", 6, FieldDescriptorProto::LABEL_REQUIRED, + AddField(message2, "mooo", 6, FieldDescriptorProto::LABEL_REQUIRED, FieldDescriptorProto::TYPE_STRING); FileDescriptorProto map_file; @@ -751,7 +754,7 @@ class DescriptorTest : public testing::Test { foo_ = message_->field(0); bar_ = message_->field(1); baz_ = message_->field(2); - qux_ = message_->field(3); + moo_ = message_->field(3); ASSERT_EQ(1, bar_file_->message_type_count()); message2_ = bar_file_->message_type(0); @@ -759,7 +762,7 @@ class DescriptorTest : public testing::Test { ASSERT_EQ(3, message2_->field_count()); foo2_ = message2_->field(0); bar2_ = message2_->field(1); - quux2_ = message2_->field(2); + mooo2_ = message2_->field(2); ASSERT_EQ(1, map_file_->message_type_count()); message3_ = map_file_->message_type(0); @@ -798,11 +801,11 @@ class DescriptorTest : public testing::Test { const FieldDescriptor* foo_; const FieldDescriptor* bar_; const FieldDescriptor* baz_; - const FieldDescriptor* qux_; + const FieldDescriptor* moo_; const FieldDescriptor* foo2_; const FieldDescriptor* bar2_; - const FieldDescriptor* quux2_; + const FieldDescriptor* mooo2_; const FieldDescriptor* map_; }; @@ -862,12 +865,28 @@ TEST_F(DescriptorTest, FieldNamesDedup) { ElementsAre("fieldname7")); } +TEST_F(DescriptorTest, FieldNameDedupJsonEqFull) { + // Test a regression where json_name == full_name + FileDescriptorProto proto; + proto.set_name("file"); + auto* message = AddMessage(&proto, "Name1"); + auto* field = + AddField(message, "Name2", 1, FieldDescriptorProto::LABEL_OPTIONAL, + FieldDescriptorProto::TYPE_INT32); + field->set_json_name("Name1.Name2"); + auto* file = pool_.BuildFile(proto); + EXPECT_EQ(file->message_type(0)->name(), "Name1"); + EXPECT_EQ(file->message_type(0)->field(0)->name(), "Name2"); + EXPECT_EQ(file->message_type(0)->field(0)->full_name(), "Name1.Name2"); + EXPECT_EQ(file->message_type(0)->field(0)->json_name(), "Name1.Name2"); +} + TEST_F(DescriptorTest, FieldsByIndex) { ASSERT_EQ(4, message_->field_count()); EXPECT_EQ(foo_, message_->field(0)); EXPECT_EQ(bar_, message_->field(1)); EXPECT_EQ(baz_, message_->field(2)); - EXPECT_EQ(qux_, message_->field(3)); + EXPECT_EQ(moo_, message_->field(3)); } TEST_F(DescriptorTest, FindFieldByName) { @@ -879,28 +898,28 @@ TEST_F(DescriptorTest, FindFieldByName) { EXPECT_EQ(foo_, message_->FindFieldByName("foo")); EXPECT_EQ(bar_, message_->FindFieldByName("bar")); EXPECT_EQ(baz_, message_->FindFieldByName("baz")); - EXPECT_EQ(qux_, message_->FindFieldByName("qux")); + EXPECT_EQ(moo_, message_->FindFieldByName("moo")); EXPECT_TRUE(message_->FindFieldByName("no_such_field") == nullptr); - EXPECT_TRUE(message_->FindFieldByName("quux") == nullptr); + EXPECT_TRUE(message_->FindFieldByName("mooo") == nullptr); EXPECT_EQ(foo2_, message2_->FindFieldByName("foo")); EXPECT_EQ(bar2_, message2_->FindFieldByName("bar")); - EXPECT_EQ(quux2_, message2_->FindFieldByName("quux")); + EXPECT_EQ(mooo2_, message2_->FindFieldByName("mooo")); EXPECT_TRUE(message2_->FindFieldByName("baz") == nullptr); - EXPECT_TRUE(message2_->FindFieldByName("qux") == nullptr); + EXPECT_TRUE(message2_->FindFieldByName("moo") == nullptr); } TEST_F(DescriptorTest, FindFieldByNumber) { EXPECT_EQ(foo_, message_->FindFieldByNumber(1)); EXPECT_EQ(bar_, message_->FindFieldByNumber(6)); EXPECT_EQ(baz_, message_->FindFieldByNumber(500000000)); - EXPECT_EQ(qux_, message_->FindFieldByNumber(15)); + EXPECT_EQ(moo_, message_->FindFieldByNumber(15)); EXPECT_TRUE(message_->FindFieldByNumber(837592) == nullptr); EXPECT_TRUE(message_->FindFieldByNumber(2) == nullptr); EXPECT_EQ(foo2_, message2_->FindFieldByNumber(1)); EXPECT_EQ(bar2_, message2_->FindFieldByNumber(2)); - EXPECT_EQ(quux2_, message2_->FindFieldByNumber(6)); + EXPECT_EQ(mooo2_, message2_->FindFieldByNumber(6)); EXPECT_TRUE(message2_->FindFieldByNumber(15) == nullptr); EXPECT_TRUE(message2_->FindFieldByNumber(500000000) == nullptr); } @@ -909,32 +928,32 @@ TEST_F(DescriptorTest, FieldName) { EXPECT_EQ("foo", foo_->name()); EXPECT_EQ("bar", bar_->name()); EXPECT_EQ("baz", baz_->name()); - EXPECT_EQ("qux", qux_->name()); + EXPECT_EQ("moo", moo_->name()); } TEST_F(DescriptorTest, FieldFullName) { EXPECT_EQ("TestMessage.foo", foo_->full_name()); EXPECT_EQ("TestMessage.bar", bar_->full_name()); EXPECT_EQ("TestMessage.baz", baz_->full_name()); - EXPECT_EQ("TestMessage.qux", qux_->full_name()); + EXPECT_EQ("TestMessage.moo", moo_->full_name()); EXPECT_EQ("corge.grault.TestMessage2.foo", foo2_->full_name()); EXPECT_EQ("corge.grault.TestMessage2.bar", bar2_->full_name()); - EXPECT_EQ("corge.grault.TestMessage2.quux", quux2_->full_name()); + EXPECT_EQ("corge.grault.TestMessage2.mooo", mooo2_->full_name()); } TEST_F(DescriptorTest, PrintableNameIsFullNameForNonExtensionFields) { EXPECT_EQ("TestMessage.foo", foo_->PrintableNameForExtension()); EXPECT_EQ("TestMessage.bar", bar_->PrintableNameForExtension()); EXPECT_EQ("TestMessage.baz", baz_->PrintableNameForExtension()); - EXPECT_EQ("TestMessage.qux", qux_->PrintableNameForExtension()); + EXPECT_EQ("TestMessage.moo", moo_->PrintableNameForExtension()); EXPECT_EQ("corge.grault.TestMessage2.foo", foo2_->PrintableNameForExtension()); EXPECT_EQ("corge.grault.TestMessage2.bar", bar2_->PrintableNameForExtension()); - EXPECT_EQ("corge.grault.TestMessage2.quux", - quux2_->PrintableNameForExtension()); + EXPECT_EQ("corge.grault.TestMessage2.mooo", + mooo2_->PrintableNameForExtension()); } TEST_F(DescriptorTest, PrintableNameIsFullNameForNonMessageSetExtension) { @@ -997,39 +1016,39 @@ TEST_F(DescriptorTest, FieldFile) { EXPECT_EQ(foo_file_, foo_->file()); EXPECT_EQ(foo_file_, bar_->file()); EXPECT_EQ(foo_file_, baz_->file()); - EXPECT_EQ(foo_file_, qux_->file()); + EXPECT_EQ(foo_file_, moo_->file()); EXPECT_EQ(bar_file_, foo2_->file()); EXPECT_EQ(bar_file_, bar2_->file()); - EXPECT_EQ(bar_file_, quux2_->file()); + EXPECT_EQ(bar_file_, mooo2_->file()); } TEST_F(DescriptorTest, FieldIndex) { EXPECT_EQ(0, foo_->index()); EXPECT_EQ(1, bar_->index()); EXPECT_EQ(2, baz_->index()); - EXPECT_EQ(3, qux_->index()); + EXPECT_EQ(3, moo_->index()); } TEST_F(DescriptorTest, FieldNumber) { EXPECT_EQ(1, foo_->number()); EXPECT_EQ(6, bar_->number()); EXPECT_EQ(500000000, baz_->number()); - EXPECT_EQ(15, qux_->number()); + EXPECT_EQ(15, moo_->number()); } TEST_F(DescriptorTest, FieldType) { EXPECT_EQ(FieldDescriptor::TYPE_STRING, foo_->type()); EXPECT_EQ(FieldDescriptor::TYPE_ENUM, bar_->type()); EXPECT_EQ(FieldDescriptor::TYPE_MESSAGE, baz_->type()); - EXPECT_EQ(FieldDescriptor::TYPE_GROUP, qux_->type()); + EXPECT_EQ(FieldDescriptor::TYPE_GROUP, moo_->type()); } TEST_F(DescriptorTest, FieldLabel) { EXPECT_EQ(FieldDescriptor::LABEL_REQUIRED, foo_->label()); EXPECT_EQ(FieldDescriptor::LABEL_OPTIONAL, bar_->label()); EXPECT_EQ(FieldDescriptor::LABEL_REPEATED, baz_->label()); - EXPECT_EQ(FieldDescriptor::LABEL_OPTIONAL, qux_->label()); + EXPECT_EQ(FieldDescriptor::LABEL_OPTIONAL, moo_->label()); EXPECT_TRUE(foo_->is_required()); EXPECT_FALSE(foo_->is_optional()); @@ -1070,18 +1089,18 @@ TEST_F(DescriptorTest, FieldHasDefault) { EXPECT_FALSE(foo_->has_default_value()); EXPECT_FALSE(bar_->has_default_value()); EXPECT_FALSE(baz_->has_default_value()); - EXPECT_FALSE(qux_->has_default_value()); + EXPECT_FALSE(moo_->has_default_value()); } TEST_F(DescriptorTest, FieldContainingType) { EXPECT_EQ(message_, foo_->containing_type()); EXPECT_EQ(message_, bar_->containing_type()); EXPECT_EQ(message_, baz_->containing_type()); - EXPECT_EQ(message_, qux_->containing_type()); + EXPECT_EQ(message_, moo_->containing_type()); EXPECT_EQ(message2_, foo2_->containing_type()); EXPECT_EQ(message2_, bar2_->containing_type()); - EXPECT_EQ(message2_, quux2_->containing_type()); + EXPECT_EQ(message2_, mooo2_->containing_type()); } TEST_F(DescriptorTest, FieldMessageType) { @@ -1089,13 +1108,13 @@ TEST_F(DescriptorTest, FieldMessageType) { EXPECT_TRUE(bar_->message_type() == nullptr); EXPECT_EQ(foreign_, baz_->message_type()); - EXPECT_EQ(foreign_, qux_->message_type()); + EXPECT_EQ(foreign_, moo_->message_type()); } TEST_F(DescriptorTest, FieldEnumType) { EXPECT_TRUE(foo_->enum_type() == nullptr); EXPECT_TRUE(baz_->enum_type() == nullptr); - EXPECT_TRUE(qux_->enum_type() == nullptr); + EXPECT_TRUE(moo_->enum_type() == nullptr); EXPECT_EQ(enum_, bar_->enum_type()); } @@ -1306,7 +1325,8 @@ TEST_F(StylizedFieldNamesTest, CamelcaseName) { TEST_F(StylizedFieldNamesTest, FindByLowercaseName) { EXPECT_EQ(message_->field(0), message_->FindFieldByLowercaseName("foo_foo")); - EXPECT_EQ(message_->field(1), message_->FindFieldByLowercaseName("foobar")); + EXPECT_THAT(message_->FindFieldByLowercaseName("foobar"), + AnyOf(message_->field(1), message_->field(4))); EXPECT_EQ(message_->field(2), message_->FindFieldByLowercaseName("foobaz")); EXPECT_TRUE(message_->FindFieldByLowercaseName("FooBar") == nullptr); EXPECT_TRUE(message_->FindFieldByLowercaseName("fooBaz") == nullptr); @@ -1315,8 +1335,8 @@ TEST_F(StylizedFieldNamesTest, FindByLowercaseName) { EXPECT_EQ(message_->extension(0), message_->FindExtensionByLowercaseName("bar_foo")); - EXPECT_EQ(message_->extension(1), - message_->FindExtensionByLowercaseName("barbar")); + EXPECT_THAT(message_->FindExtensionByLowercaseName("barbar"), + AnyOf(message_->extension(1), message_->extension(4))); EXPECT_EQ(message_->extension(2), message_->FindExtensionByLowercaseName("barbaz")); EXPECT_TRUE(message_->FindExtensionByLowercaseName("BarBar") == nullptr); @@ -1326,7 +1346,8 @@ TEST_F(StylizedFieldNamesTest, FindByLowercaseName) { EXPECT_EQ(file_->extension(0), file_->FindExtensionByLowercaseName("baz_foo")); - EXPECT_EQ(file_->extension(1), file_->FindExtensionByLowercaseName("bazbar")); + EXPECT_THAT(file_->FindExtensionByLowercaseName("bazbar"), + AnyOf(file_->extension(1), file_->extension(4))); EXPECT_EQ(file_->extension(2), file_->FindExtensionByLowercaseName("bazbaz")); EXPECT_TRUE(file_->FindExtensionByLowercaseName("BazBar") == nullptr); EXPECT_TRUE(file_->FindExtensionByLowercaseName("bazBaz") == nullptr); @@ -1334,7 +1355,8 @@ TEST_F(StylizedFieldNamesTest, FindByLowercaseName) { } TEST_F(StylizedFieldNamesTest, FindByCamelcaseName) { - EXPECT_EQ(message_->field(0), message_->FindFieldByCamelcaseName("fooFoo")); + EXPECT_THAT(message_->FindFieldByCamelcaseName("fooFoo"), + AnyOf(message_->field(0), message_->field(3))); EXPECT_EQ(message_->field(1), message_->FindFieldByCamelcaseName("fooBar")); EXPECT_EQ(message_->field(2), message_->FindFieldByCamelcaseName("fooBaz")); EXPECT_TRUE(message_->FindFieldByCamelcaseName("foo_foo") == nullptr); @@ -1342,8 +1364,8 @@ TEST_F(StylizedFieldNamesTest, FindByCamelcaseName) { EXPECT_TRUE(message_->FindFieldByCamelcaseName("barFoo") == nullptr); EXPECT_TRUE(message_->FindFieldByCamelcaseName("nosuchfield") == nullptr); - EXPECT_EQ(message_->extension(0), - message_->FindExtensionByCamelcaseName("barFoo")); + EXPECT_THAT(message_->FindExtensionByCamelcaseName("barFoo"), + AnyOf(message_->extension(0), message_->extension(3))); EXPECT_EQ(message_->extension(1), message_->FindExtensionByCamelcaseName("barBar")); EXPECT_EQ(message_->extension(2), @@ -1353,7 +1375,8 @@ TEST_F(StylizedFieldNamesTest, FindByCamelcaseName) { EXPECT_TRUE(message_->FindExtensionByCamelcaseName("fooFoo") == nullptr); EXPECT_TRUE(message_->FindExtensionByCamelcaseName("nosuchfield") == nullptr); - EXPECT_EQ(file_->extension(0), file_->FindExtensionByCamelcaseName("bazFoo")); + EXPECT_THAT(file_->FindExtensionByCamelcaseName("bazFoo"), + AnyOf(file_->extension(0), file_->extension(3))); EXPECT_EQ(file_->extension(1), file_->FindExtensionByCamelcaseName("bazBar")); EXPECT_EQ(file_->extension(2), file_->FindExtensionByCamelcaseName("bazBaz")); EXPECT_TRUE(file_->FindExtensionByCamelcaseName("baz_foo") == nullptr); @@ -1645,7 +1668,6 @@ TEST_F(ServiceDescriptorTest, MethodName) { EXPECT_EQ("Foo", foo_->name()); EXPECT_EQ("Bar", bar_->name()); } - TEST_F(ServiceDescriptorTest, MethodFullName) { EXPECT_EQ("TestService.Foo", foo_->full_name()); EXPECT_EQ("TestService.Bar", bar_->full_name()); @@ -1686,7 +1708,7 @@ class NestedDescriptorTest : public testing::Test { // message Foo {} // message Bar {} // enum Baz { A = 1; } - // enum Qux { B = 1; } + // enum Moo { B = 1; } // } // // // in "bar.proto" @@ -1694,8 +1716,8 @@ class NestedDescriptorTest : public testing::Test { // message TestMessage2 { // message Foo {} // message Baz {} - // enum Qux { A = 1; } - // enum Quux { C = 1; } + // enum Moo { A = 1; } + // enum Mooo { C = 1; } // } // // TestMessage2 is primarily here to test FindNestedTypeByName and friends. @@ -1713,8 +1735,8 @@ class NestedDescriptorTest : public testing::Test { AddNestedMessage(message, "Bar"); EnumDescriptorProto* baz = AddNestedEnum(message, "Baz"); AddEnumValue(baz, "A", 1); - EnumDescriptorProto* qux = AddNestedEnum(message, "Qux"); - AddEnumValue(qux, "B", 1); + EnumDescriptorProto* moo = AddNestedEnum(message, "Moo"); + AddEnumValue(moo, "B", 1); FileDescriptorProto bar_file; bar_file.set_name("bar.proto"); @@ -1723,10 +1745,10 @@ class NestedDescriptorTest : public testing::Test { DescriptorProto* message2 = AddMessage(&bar_file, "TestMessage2"); AddNestedMessage(message2, "Foo"); AddNestedMessage(message2, "Baz"); - EnumDescriptorProto* qux2 = AddNestedEnum(message2, "Qux"); - AddEnumValue(qux2, "A", 1); - EnumDescriptorProto* quux2 = AddNestedEnum(message2, "Quux"); - AddEnumValue(quux2, "C", 1); + EnumDescriptorProto* moo2 = AddNestedEnum(message2, "Moo"); + AddEnumValue(moo2, "A", 1); + EnumDescriptorProto* mooo2 = AddNestedEnum(message2, "Mooo"); + AddEnumValue(mooo2, "C", 1); // Build the descriptors and get the pointers. foo_file_ = pool_.BuildFile(foo_file); @@ -1744,12 +1766,12 @@ class NestedDescriptorTest : public testing::Test { ASSERT_EQ(2, message_->enum_type_count()); baz_ = message_->enum_type(0); - qux_ = message_->enum_type(1); + moo_ = message_->enum_type(1); ASSERT_EQ(1, baz_->value_count()); a_ = baz_->value(0); - ASSERT_EQ(1, qux_->value_count()); - b_ = qux_->value(0); + ASSERT_EQ(1, moo_->value_count()); + b_ = moo_->value(0); ASSERT_EQ(1, bar_file_->message_type_count()); message2_ = bar_file_->message_type(0); @@ -1759,13 +1781,13 @@ class NestedDescriptorTest : public testing::Test { baz2_ = message2_->nested_type(1); ASSERT_EQ(2, message2_->enum_type_count()); - qux2_ = message2_->enum_type(0); - quux2_ = message2_->enum_type(1); + moo2_ = message2_->enum_type(0); + mooo2_ = message2_->enum_type(1); - ASSERT_EQ(1, qux2_->value_count()); - a2_ = qux2_->value(0); - ASSERT_EQ(1, quux2_->value_count()); - c2_ = quux2_->value(0); + ASSERT_EQ(1, moo2_->value_count()); + a2_ = moo2_->value(0); + ASSERT_EQ(1, mooo2_->value_count()); + c2_ = mooo2_->value(0); } DescriptorPool pool_; @@ -1779,14 +1801,14 @@ class NestedDescriptorTest : public testing::Test { const Descriptor* foo_; const Descriptor* bar_; const EnumDescriptor* baz_; - const EnumDescriptor* qux_; + const EnumDescriptor* moo_; const EnumValueDescriptor* a_; const EnumValueDescriptor* b_; const Descriptor* foo2_; const Descriptor* baz2_; - const EnumDescriptor* qux2_; - const EnumDescriptor* quux2_; + const EnumDescriptor* moo2_; + const EnumDescriptor* mooo2_; const EnumValueDescriptor* a2_; const EnumValueDescriptor* c2_; }; @@ -1818,9 +1840,9 @@ TEST_F(NestedDescriptorTest, NestedMessagesByIndex) { TEST_F(NestedDescriptorTest, FindFieldByNameDoesntFindNestedTypes) { EXPECT_TRUE(message_->FindFieldByName("Foo") == nullptr); - EXPECT_TRUE(message_->FindFieldByName("Qux") == nullptr); + EXPECT_TRUE(message_->FindFieldByName("Moo") == nullptr); EXPECT_TRUE(message_->FindExtensionByName("Foo") == nullptr); - EXPECT_TRUE(message_->FindExtensionByName("Qux") == nullptr); + EXPECT_TRUE(message_->FindExtensionByName("Moo") == nullptr); } TEST_F(NestedDescriptorTest, FindNestedTypeByName) { @@ -1833,26 +1855,26 @@ TEST_F(NestedDescriptorTest, FindNestedTypeByName) { EXPECT_TRUE(message_->FindNestedTypeByName("Baz") == nullptr); EXPECT_TRUE(message2_->FindNestedTypeByName("Bar") == nullptr); - EXPECT_TRUE(message_->FindNestedTypeByName("Qux") == nullptr); + EXPECT_TRUE(message_->FindNestedTypeByName("Moo") == nullptr); } TEST_F(NestedDescriptorTest, EnumName) { EXPECT_EQ("Baz", baz_->name()); - EXPECT_EQ("Qux", qux_->name()); - EXPECT_EQ("Qux", qux2_->name()); - EXPECT_EQ("Quux", quux2_->name()); + EXPECT_EQ("Moo", moo_->name()); + EXPECT_EQ("Moo", moo2_->name()); + EXPECT_EQ("Mooo", mooo2_->name()); EXPECT_EQ("TestMessage.Baz", baz_->full_name()); - EXPECT_EQ("TestMessage.Qux", qux_->full_name()); - EXPECT_EQ("corge.grault.TestMessage2.Qux", qux2_->full_name()); - EXPECT_EQ("corge.grault.TestMessage2.Quux", quux2_->full_name()); + EXPECT_EQ("TestMessage.Moo", moo_->full_name()); + EXPECT_EQ("corge.grault.TestMessage2.Moo", moo2_->full_name()); + EXPECT_EQ("corge.grault.TestMessage2.Mooo", mooo2_->full_name()); } TEST_F(NestedDescriptorTest, EnumContainingType) { EXPECT_EQ(message_, baz_->containing_type()); - EXPECT_EQ(message_, qux_->containing_type()); - EXPECT_EQ(message2_, qux2_->containing_type()); - EXPECT_EQ(message2_, quux2_->containing_type()); + EXPECT_EQ(message_, moo_->containing_type()); + EXPECT_EQ(message2_, moo2_->containing_type()); + EXPECT_EQ(message2_, mooo2_->containing_type()); } TEST_F(NestedDescriptorTest, NestedEnumsByIndex) { @@ -1863,12 +1885,12 @@ TEST_F(NestedDescriptorTest, NestedEnumsByIndex) { TEST_F(NestedDescriptorTest, FindEnumTypeByName) { EXPECT_EQ(baz_, message_->FindEnumTypeByName("Baz")); - EXPECT_EQ(qux_, message_->FindEnumTypeByName("Qux")); - EXPECT_EQ(qux2_, message2_->FindEnumTypeByName("Qux")); - EXPECT_EQ(quux2_, message2_->FindEnumTypeByName("Quux")); + EXPECT_EQ(moo_, message_->FindEnumTypeByName("Moo")); + EXPECT_EQ(moo2_, message2_->FindEnumTypeByName("Moo")); + EXPECT_EQ(mooo2_, message2_->FindEnumTypeByName("Mooo")); EXPECT_TRUE(message_->FindEnumTypeByName("NoSuchType") == nullptr); - EXPECT_TRUE(message_->FindEnumTypeByName("Quux") == nullptr); + EXPECT_TRUE(message_->FindEnumTypeByName("Mooo") == nullptr); EXPECT_TRUE(message2_->FindEnumTypeByName("Baz") == nullptr); EXPECT_TRUE(message_->FindEnumTypeByName("Foo") == nullptr); @@ -1896,7 +1918,7 @@ class ExtensionDescriptorTest : public testing::Test { // Build descriptors for the following definitions: // // enum Baz {} - // message Qux {} + // message Moo {} // // message Foo { // extensions 10 to 19; @@ -1911,8 +1933,8 @@ class ExtensionDescriptorTest : public testing::Test { // message Bar { // optional int32 non_ext_int32 = 1; // extend Foo { - // optional Qux foo_message = 30; - // repeated Qux foo_group = 39; // (but internally set to TYPE_GROUP) + // optional Moo foo_message = 30; + // repeated Moo foo_group = 39; // (but internally set to TYPE_GROUP) // } // } @@ -1920,7 +1942,7 @@ class ExtensionDescriptorTest : public testing::Test { foo_file.set_name("foo.proto"); AddEmptyEnum(&foo_file, "Baz"); - AddMessage(&foo_file, "Qux"); + AddMessage(&foo_file, "Moo"); DescriptorProto* foo = AddMessage(&foo_file, "Foo"); AddExtensionRange(foo, 10, 20); @@ -1940,11 +1962,11 @@ class ExtensionDescriptorTest : public testing::Test { AddNestedExtension(bar, "Foo", "foo_message", 30, FieldDescriptorProto::LABEL_OPTIONAL, FieldDescriptorProto::TYPE_MESSAGE) - ->set_type_name("Qux"); + ->set_type_name("Moo"); AddNestedExtension(bar, "Foo", "foo_group", 39, FieldDescriptorProto::LABEL_REPEATED, FieldDescriptorProto::TYPE_GROUP) - ->set_type_name("Qux"); + ->set_type_name("Moo"); // Build the descriptors and get the pointers. foo_file_ = pool_.BuildFile(foo_file); @@ -1954,7 +1976,7 @@ class ExtensionDescriptorTest : public testing::Test { baz_ = foo_file_->enum_type(0); ASSERT_EQ(3, foo_file_->message_type_count()); - qux_ = foo_file_->message_type(0); + moo_ = foo_file_->message_type(0); foo_ = foo_file_->message_type(1); bar_ = foo_file_->message_type(2); } @@ -1966,7 +1988,7 @@ class ExtensionDescriptorTest : public testing::Test { const Descriptor* foo_; const Descriptor* bar_; const EnumDescriptor* baz_; - const Descriptor* qux_; + const Descriptor* moo_; }; TEST_F(ExtensionDescriptorTest, ExtensionRanges) { @@ -2006,8 +2028,8 @@ TEST_F(ExtensionDescriptorTest, Extensions) { EXPECT_EQ(FieldDescriptor::TYPE_GROUP, bar_->extension(1)->type()); EXPECT_EQ(baz_, foo_file_->extension(1)->enum_type()); - EXPECT_EQ(qux_, bar_->extension(0)->message_type()); - EXPECT_EQ(qux_, bar_->extension(1)->message_type()); + EXPECT_EQ(moo_, bar_->extension(0)->message_type()); + EXPECT_EQ(moo_, bar_->extension(1)->message_type()); EXPECT_EQ(FieldDescriptor::LABEL_OPTIONAL, foo_file_->extension(0)->label()); EXPECT_EQ(FieldDescriptor::LABEL_REPEATED, foo_file_->extension(1)->label()); @@ -2738,9 +2760,9 @@ TEST_F(MiscTest, DefaultValues) { ASSERT_TRUE(message->field(10)->has_default_value()); EXPECT_EQ(-1, message->field(0)->default_value_int32()); - EXPECT_EQ(int64{-1000000000000}, message->field(1)->default_value_int64()); + EXPECT_EQ(int64_t{-1000000000000}, message->field(1)->default_value_int64()); EXPECT_EQ(42, message->field(2)->default_value_uint32()); - EXPECT_EQ(uint64{2000000000000}, message->field(3)->default_value_uint64()); + EXPECT_EQ(uint64_t{2000000000000}, message->field(3)->default_value_uint64()); EXPECT_EQ(4.5, message->field(4)->default_value_float()); EXPECT_EQ(10e100, message->field(5)->default_value_double()); EXPECT_TRUE(message->field(6)->default_value_bool()); @@ -2841,8 +2863,8 @@ class AllowUnknownDependenciesTest " name: 'Foo'" " field { name:'bar' number:1 label:LABEL_OPTIONAL type_name:'Bar' }" " field { name:'baz' number:2 label:LABEL_OPTIONAL type_name:'Baz' }" - " field { name:'qux' number:3 label:LABEL_OPTIONAL" - " type_name: '.corge.Qux'" + " field { name:'moo' number:3 label:LABEL_OPTIONAL" + " type_name: '.corge.Moo'" " type: TYPE_ENUM" " options {" " uninterpreted_option {" @@ -2880,7 +2902,7 @@ class AllowUnknownDependenciesTest ASSERT_EQ(3, foo_type_->field_count()); bar_field_ = foo_type_->field(0); baz_field_ = foo_type_->field(1); - qux_field_ = foo_type_->field(2); + moo_field_ = foo_type_->field(2); } const FileDescriptor* BuildFile(const FileDescriptorProto& proto) { @@ -2903,7 +2925,7 @@ class AllowUnknownDependenciesTest const Descriptor* foo_type_; const FieldDescriptor* bar_field_; const FieldDescriptor* baz_field_; - const FieldDescriptor* qux_field_; + const FieldDescriptor* moo_field_; SimpleDescriptorDatabase db_; // used if in FALLBACK_DATABASE mode. std::unique_ptr<DescriptorPool> pool_; @@ -2942,18 +2964,18 @@ TEST_P(AllowUnknownDependenciesTest, PlaceholderTypes) { EXPECT_EQ(0, baz_type->extension_range_count()); EXPECT_TRUE(baz_type->is_placeholder()); - ASSERT_EQ(FieldDescriptor::TYPE_ENUM, qux_field_->type()); - const EnumDescriptor* qux_type = qux_field_->enum_type(); - EXPECT_EQ("Qux", qux_type->name()); - EXPECT_EQ("corge.Qux", qux_type->full_name()); - EXPECT_TRUE(qux_type->is_placeholder()); + ASSERT_EQ(FieldDescriptor::TYPE_ENUM, moo_field_->type()); + const EnumDescriptor* moo_type = moo_field_->enum_type(); + EXPECT_EQ("Moo", moo_type->name()); + EXPECT_EQ("corge.Moo", moo_type->full_name()); + EXPECT_TRUE(moo_type->is_placeholder()); // Placeholder enum values should not be findable. - EXPECT_EQ(qux_type->FindValueByNumber(0), nullptr); + EXPECT_EQ(moo_type->FindValueByNumber(0), nullptr); // Placeholder types should not be findable. EXPECT_EQ(bar_type_, pool_->FindMessageTypeByName(bar_type_->full_name())); EXPECT_TRUE(pool_->FindMessageTypeByName(baz_type->full_name()) == nullptr); - EXPECT_TRUE(pool_->FindEnumTypeByName(qux_type->full_name()) == nullptr); + EXPECT_TRUE(pool_->FindEnumTypeByName(moo_type->full_name()) == nullptr); } TEST_P(AllowUnknownDependenciesTest, CopyTo) { @@ -2972,18 +2994,18 @@ TEST_P(AllowUnknownDependenciesTest, CopyTo) { EXPECT_EQ("Baz", proto.type_name()); EXPECT_FALSE(proto.has_type()); - // Qux is a fully-qualified placeholder. + // Moo is a fully-qualified placeholder. proto.Clear(); - qux_field_->CopyTo(&proto); - EXPECT_EQ(".corge.Qux", proto.type_name()); + moo_field_->CopyTo(&proto); + EXPECT_EQ(".corge.Moo", proto.type_name()); EXPECT_EQ(FieldDescriptorProto::TYPE_ENUM, proto.type()); } TEST_P(AllowUnknownDependenciesTest, CustomOptions) { - // Qux should still have the uninterpreted option attached. - ASSERT_EQ(1, qux_field_->options().uninterpreted_option_size()); + // Moo should still have the uninterpreted option attached. + ASSERT_EQ(1, moo_field_->options().uninterpreted_option_size()); const UninterpretedOption& option = - qux_field_->options().uninterpreted_option(0); + moo_field_->options().uninterpreted_option(0); ASSERT_EQ(1, option.name_size()); EXPECT_EQ("grault", option.name(0).name_part()); } @@ -3081,12 +3103,12 @@ TEST_P(AllowUnknownDependenciesTest, "name: \"invalid_file_as_undeclared_dep.proto\" " "package: \"undeclared\" " "message_type: { " - " name: \"Quux\" " + " name: \"Mooo\" " " field { " - " name:'qux' number:1 label:LABEL_OPTIONAL type: TYPE_INT32 " + " name:'moo' number:1 label:LABEL_OPTIONAL type: TYPE_INT32 " " }" " field { " - " name:'quux' number:1 label:LABEL_OPTIONAL type: TYPE_INT64 " + " name:'mooo' number:1 label:LABEL_OPTIONAL type: TYPE_INT64 " " }" "}", &undeclared_dep_proto)); @@ -3110,8 +3132,8 @@ TEST_P(AllowUnknownDependenciesTest, "message_type: { " " name: \"Corge\" " " field { " - " name:'quux' number:1 label: LABEL_OPTIONAL " - " type_name:'undeclared.Quux' type: TYPE_MESSAGE " + " name:'mooo' number:1 label: LABEL_OPTIONAL " + " type_name:'undeclared.Mooo' type: TYPE_MESSAGE " " }" "}", &test_proto)); @@ -3127,13 +3149,13 @@ TEST_P(AllowUnknownDependenciesTest, ASSERT_EQ(1, corge_desc->field_count()); EXPECT_FALSE(corge_desc->is_placeholder()); - const FieldDescriptor* quux_field = corge_desc->field(0); - ASSERT_EQ(FieldDescriptor::TYPE_MESSAGE, quux_field->type()); - ASSERT_EQ("Quux", quux_field->message_type()->name()); - ASSERT_EQ("undeclared.Quux", quux_field->message_type()->full_name()); - EXPECT_TRUE(quux_field->message_type()->is_placeholder()); + const FieldDescriptor* mooo_field = corge_desc->field(0); + ASSERT_EQ(FieldDescriptor::TYPE_MESSAGE, mooo_field->type()); + ASSERT_EQ("Mooo", mooo_field->message_type()->name()); + ASSERT_EQ("undeclared.Mooo", mooo_field->message_type()->full_name()); + EXPECT_TRUE(mooo_field->message_type()->is_placeholder()); // The place holder type should not be findable. - ASSERT_TRUE(pool_->FindMessageTypeByName("undeclared.Quux") == nullptr); + ASSERT_TRUE(pool_->FindMessageTypeByName("undeclared.Mooo") == nullptr); } INSTANTIATE_TEST_SUITE_P(DatabaseSource, AllowUnknownDependenciesTest, @@ -3156,11 +3178,11 @@ TEST(CustomOptions, OptionLocations) { file->FindServiceByName("TestServiceWithCustomOptions"); const MethodDescriptor* method = service->FindMethodByName("Foo"); - EXPECT_EQ(int64{9876543210}, + EXPECT_EQ(int64_t{9876543210}, file->options().GetExtension(protobuf_unittest::file_opt1)); EXPECT_EQ(-56, message->options().GetExtension(protobuf_unittest::message_opt1)); - EXPECT_EQ(int64{8765432109}, + EXPECT_EQ(int64_t{8765432109}, field->options().GetExtension(protobuf_unittest::field_opt1)); EXPECT_EQ(42, // Check that we get the default for an option we don't set. field->options().GetExtension(protobuf_unittest::field_opt2)); @@ -3170,7 +3192,7 @@ TEST(CustomOptions, OptionLocations) { EXPECT_EQ(-789, enm->options().GetExtension(protobuf_unittest::enum_opt1)); EXPECT_EQ(123, enm->value(1)->options().GetExtension( protobuf_unittest::enum_value_opt1)); - EXPECT_EQ(int64{-9876543210}, + EXPECT_EQ(int64_t{-9876543210}, service->options().GetExtension(protobuf_unittest::service_opt1)); EXPECT_EQ(protobuf_unittest::METHODOPT1_VAL2, method->options().GetExtension(protobuf_unittest::method_opt1)); @@ -3249,11 +3271,11 @@ TEST(CustomOptions, ComplexExtensionOptions) { &protobuf_unittest::VariousComplexOptions::descriptor()->options(); EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt1).foo(), 42); EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt1) - .GetExtension(protobuf_unittest::quux), + .GetExtension(protobuf_unittest::mooo), 324); EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt1) .GetExtension(protobuf_unittest::corge) - .qux(), + .moo(), 876); EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).baz(), 987); EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2) @@ -3263,12 +3285,12 @@ TEST(CustomOptions, ComplexExtensionOptions) { 743); EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2) .bar() - .GetExtension(protobuf_unittest::quux), + .GetExtension(protobuf_unittest::mooo), 1999); EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2) .bar() .GetExtension(protobuf_unittest::corge) - .qux(), + .moo(), 2008); EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2) .GetExtension(protobuf_unittest::garply) @@ -3276,12 +3298,12 @@ TEST(CustomOptions, ComplexExtensionOptions) { 741); EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2) .GetExtension(protobuf_unittest::garply) - .GetExtension(protobuf_unittest::quux), + .GetExtension(protobuf_unittest::mooo), 1998); EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2) .GetExtension(protobuf_unittest::garply) .GetExtension(protobuf_unittest::corge) - .qux(), + .moo(), 2121); EXPECT_EQ(options ->GetExtension(protobuf_unittest::ComplexOptionType2:: @@ -3290,7 +3312,7 @@ TEST(CustomOptions, ComplexExtensionOptions) { 1971); EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).fred().waldo(), 321); - EXPECT_EQ(9, options->GetExtension(protobuf_unittest::complex_opt3).qux()); + EXPECT_EQ(9, options->GetExtension(protobuf_unittest::complex_opt3).moo()); EXPECT_EQ(22, options->GetExtension(protobuf_unittest::complex_opt3) .complexoptiontype5() .plugh()); @@ -3982,14 +4004,10 @@ TEST_F(ValidationErrorTest, NullCharSymbolName) { "} " "}", STATIC_STR("bar.proto: foo.\0\x1\v.Bar: NAME: \"\0\x1\v.Bar\" is not a " - "valid identifier.\nbar.proto: foo.\0\x1\v.Bar: NAME: " - "\"\0\x1\v.Bar\" is not a valid identifier.\nbar.proto: " - "foo.\0\x1\v.Bar: NAME: \"\0\x1\v.Bar\" is not a valid " - "identifier.\nbar.proto: foo.\0\x1\v.Bar: NAME: " - "\"\0\x1\v.Bar\" is not a valid identifier.\nbar.proto: " - "foo.\0\x1\v.Bar.foo: NAME: \"foo.\0\x1\v.Bar.foo\" contains " - "null character.\nbar.proto: foo.\0\x1\v.Bar: NAME: " - "\"foo.\0\x1\v.Bar\" contains null character.\n")); + "valid identifier.\nbar.proto: foo.\0\x1\v.Bar.foo: NAME: " + "\"foo.\0\x1\v.Bar.foo\" contains null character.\nbar.proto: " + "foo.\0\x1\v.Bar: NAME: \"foo.\0\x1\v.Bar\" contains null " + "character.\n")); } TEST_F(ValidationErrorTest, NullCharFileName) { @@ -4096,7 +4114,7 @@ TEST_F(ValidationErrorTest, FieldInExtensionRange) { "}" " field { name: \"baz\" number: 19 label:LABEL_OPTIONAL type:TYPE_INT32 " "}" - " field { name: \"qux\" number: 20 label:LABEL_OPTIONAL type:TYPE_INT32 " + " field { name: \"moo\" number: 20 label:LABEL_OPTIONAL type:TYPE_INT32 " "}" " extension_range { start: 10 end: 20 }" "}", @@ -4104,7 +4122,8 @@ TEST_F(ValidationErrorTest, FieldInExtensionRange) { "foo.proto: Foo.bar: NUMBER: Extension range 10 to 19 includes field " "\"bar\" (10).\n" "foo.proto: Foo.baz: NUMBER: Extension range 10 to 19 includes field " - "\"baz\" (19).\n"); + "\"baz\" (19).\n" + "foo.proto: Foo: NUMBER: Suggested field numbers for Foo: 1, 2\n"); } TEST_F(ValidationErrorTest, OverlappingExtensionRanges) { @@ -4133,7 +4152,8 @@ TEST_F(ValidationErrorTest, ReservedFieldError) { " reserved_range { start: 10 end: 20 }" "}", - "foo.proto: Foo.foo: NUMBER: Field \"foo\" uses reserved number 15.\n"); + "foo.proto: Foo.foo: NUMBER: Field \"foo\" uses reserved number 15.\n" + "foo.proto: Foo: NUMBER: Suggested field numbers for Foo: 1\n"); } TEST_F(ValidationErrorTest, ReservedExtensionRangeError) { @@ -4428,13 +4448,13 @@ TEST_F(ValidationErrorTest, InvalidDefaults) { " default_value: \"abc\" }" // Messages can't have defaults. - " field { name: \"qux\" number: 4 label: LABEL_OPTIONAL type: " + " field { name: \"moo\" number: 4 label: LABEL_OPTIONAL type: " "TYPE_MESSAGE" " default_value: \"abc\" type_name: \"Foo\" }" // Same thing, but we don't know that this field has message type until // we look up the type name. - " field { name: \"quux\" number: 5 label: LABEL_OPTIONAL" + " field { name: \"mooo\" number: 5 label: LABEL_OPTIONAL" " default_value: \"abc\" type_name: \"Foo\" }" // Repeateds can't have defaults. @@ -4448,12 +4468,12 @@ TEST_F(ValidationErrorTest, InvalidDefaults) { "foo.proto: Foo.bar: DEFAULT_VALUE: Couldn't parse default value \"\".\n" "foo.proto: Foo.baz: DEFAULT_VALUE: Boolean default must be true or " "false.\n" - "foo.proto: Foo.qux: DEFAULT_VALUE: Messages can't have default values.\n" + "foo.proto: Foo.moo: DEFAULT_VALUE: Messages can't have default values.\n" "foo.proto: Foo.corge: DEFAULT_VALUE: Repeated fields can't have default " "values.\n" // This ends up being reported later because the error is detected at // cross-linking time. - "foo.proto: Foo.quux: DEFAULT_VALUE: Messages can't have default " + "foo.proto: Foo.mooo: DEFAULT_VALUE: Messages can't have default " "values.\n"); } @@ -4466,7 +4486,8 @@ TEST_F(ValidationErrorTest, NegativeFieldNumber) { "}" "}", - "foo.proto: Foo.foo: NUMBER: Field numbers must be positive integers.\n"); + "foo.proto: Foo.foo: NUMBER: Field numbers must be positive integers.\n" + "foo.proto: Foo: NUMBER: Suggested field numbers for Foo: 1\n"); } TEST_F(ValidationErrorTest, HugeFieldNumber) { @@ -4479,7 +4500,8 @@ TEST_F(ValidationErrorTest, HugeFieldNumber) { "}", "foo.proto: Foo.foo: NUMBER: Field numbers cannot be greater than " - "536870911.\n"); + "536870911.\n" + "foo.proto: Foo: NUMBER: Suggested field numbers for Foo: 1\n"); } TEST_F(ValidationErrorTest, ReservedFieldNumber) { @@ -4493,14 +4515,15 @@ TEST_F(ValidationErrorTest, ReservedFieldNumber) { "type:TYPE_INT32 }" " field {name:\"baz\" number: 19999 label:LABEL_OPTIONAL " "type:TYPE_INT32 }" - " field {name:\"qux\" number: 20000 label:LABEL_OPTIONAL " + " field {name:\"moo\" number: 20000 label:LABEL_OPTIONAL " "type:TYPE_INT32 }" "}", "foo.proto: Foo.bar: NUMBER: Field numbers 19000 through 19999 are " "reserved for the protocol buffer library implementation.\n" "foo.proto: Foo.baz: NUMBER: Field numbers 19000 through 19999 are " - "reserved for the protocol buffer library implementation.\n"); + "reserved for the protocol buffer library implementation.\n" + "foo.proto: Foo: NUMBER: Suggested field numbers for Foo: 1, 2\n"); } TEST_F(ValidationErrorTest, ExtensionMissingExtendee) { @@ -5090,7 +5113,7 @@ TEST_F(ValidationErrorTest, PackageOriginallyDeclaredInTransitiveDependent) { // baz.proto: // package foo; // import "bar.proto" - // message Baz { optional bar.Bar qux = 1; } + // message Baz { optional bar.Bar moo = 1; } // // When validating baz.proto, we will look up "bar.Bar". As part of this // lookup, we first lookup "bar" then try to find "Bar" within it. "bar" @@ -5114,7 +5137,7 @@ TEST_F(ValidationErrorTest, PackageOriginallyDeclaredInTransitiveDependent) { "dependency: \"bar.proto\" " "message_type { " " name: \"Baz\" " - " field { name:\"qux\" number:1 label:LABEL_OPTIONAL " + " field { name:\"moo\" number:1 label:LABEL_OPTIONAL " " type_name:\"bar.Bar\" }" "}"); } @@ -5454,12 +5477,12 @@ TEST_F(ValidationErrorTest, ResolveUndefinedOption) { // message Bar { optional int32 foo = 1; } // extend FileOptions { optional Bar bar = 7672757; } // - // qux.proto: - // package qux.baz + // moo.proto: + // package moo.baz // option (baz.bar).foo = 1; // // Although "baz.bar" is already defined, the lookup code will try - // "qux.baz.bar", since it's the match from the innermost scope, which will + // "moo.baz.bar", since it's the match from the innermost scope, which will // cause a symbol not defined error. BuildDescriptorMessagesInTestPool(); @@ -5475,16 +5498,16 @@ TEST_F(ValidationErrorTest, ResolveUndefinedOption) { " extendee: \"google.protobuf.FileOptions\" }"); BuildFileWithErrors( - "name: \"qux.proto\" " - "package: \"qux.baz\" " + "name: \"moo.proto\" " + "package: \"moo.baz\" " "options { uninterpreted_option { name { name_part: \"baz.bar\" " " is_extension: true } " " name { name_part: \"foo\" " " is_extension: false } " " positive_int_value: 1 } }", - "qux.proto: qux.proto: OPTION_NAME: Option \"(baz.bar)\" is resolved to " - "\"(qux.baz.bar)\"," + "moo.proto: moo.proto: OPTION_NAME: Option \"(baz.bar)\" is resolved to " + "\"(moo.baz.bar)\"," " which is not defined. The innermost scope is searched first in name " "resolution. Consider using a leading '.'(i.e., \"(.baz.bar)\") to start " "from the outermost scope.\n"); @@ -5492,15 +5515,15 @@ TEST_F(ValidationErrorTest, ResolveUndefinedOption) { TEST_F(ValidationErrorTest, UnknownOption) { BuildFileWithErrors( - "name: \"qux.proto\" " - "package: \"qux.baz\" " + "name: \"moo.proto\" " + "package: \"moo.baz\" " "options { uninterpreted_option { name { name_part: \"baaz.bar\" " " is_extension: true } " " name { name_part: \"foo\" " " is_extension: false } " " positive_int_value: 1 } }", - "qux.proto: qux.proto: OPTION_NAME: Option \"(baaz.bar)\" unknown. " + "moo.proto: moo.proto: OPTION_NAME: Option \"(baaz.bar)\" unknown. " "Ensure " "that your proto definition file imports the proto which defines the " "option.\n"); @@ -5714,7 +5737,7 @@ TEST_F(ValidationErrorTest, EnumOptionValueIsNotIdentifier) { " extendee: \"google.protobuf.FileOptions\" }" "options { uninterpreted_option { name { name_part: \"foo\" " " is_extension: true } " - " string_value: \"QUUX\" } }", + " string_value: \"MOOO\" } }", "foo.proto: foo.proto: OPTION_VALUE: Value must be identifier for " "enum-valued option \"foo\".\n"); @@ -5733,10 +5756,10 @@ TEST_F(ValidationErrorTest, EnumOptionValueIsNotEnumValueName) { " extendee: \"google.protobuf.FileOptions\" }" "options { uninterpreted_option { name { name_part: \"foo\" " " is_extension: true } " - " identifier_value: \"QUUX\" } }", + " identifier_value: \"MOOO\" } }", "foo.proto: foo.proto: OPTION_VALUE: Enum type \"FooEnum\" has no value " - "named \"QUUX\" for option \"foo\".\n"); + "named \"MOOO\" for option \"foo\".\n"); } TEST_F(ValidationErrorTest, EnumOptionValueIsSiblingEnumValueName) { @@ -5747,17 +5770,17 @@ TEST_F(ValidationErrorTest, EnumOptionValueIsSiblingEnumValueName) { "dependency: \"google/protobuf/descriptor.proto\" " "enum_type { name: \"FooEnum1\" value { name: \"BAR\" number: 1 } " " value { name: \"BAZ\" number: 2 } }" - "enum_type { name: \"FooEnum2\" value { name: \"QUX\" number: 1 } " - " value { name: \"QUUX\" number: 2 } }" + "enum_type { name: \"FooEnum2\" value { name: \"MOO\" number: 1 } " + " value { name: \"MOOO\" number: 2 } }" "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " " type: TYPE_ENUM type_name: \"FooEnum1\" " " extendee: \"google.protobuf.FileOptions\" }" "options { uninterpreted_option { name { name_part: \"foo\" " " is_extension: true } " - " identifier_value: \"QUUX\" } }", + " identifier_value: \"MOOO\" } }", "foo.proto: foo.proto: OPTION_VALUE: Enum type \"FooEnum1\" has no value " - "named \"QUUX\" for option \"foo\". This appears to be a value from a " + "named \"MOOO\" for option \"foo\". This appears to be a value from a " "sibling type.\n"); } @@ -5771,7 +5794,7 @@ TEST_F(ValidationErrorTest, StringOptionValueIsNotString) { " type: TYPE_STRING extendee: \"google.protobuf.FileOptions\" }" "options { uninterpreted_option { name { name_part: \"foo\" " " is_extension: true } " - " identifier_value: \"QUUX\" } }", + " identifier_value: \"MOOO\" } }", "foo.proto: foo.proto: OPTION_VALUE: Value must be quoted string " "for " @@ -6713,16 +6736,64 @@ TEST_F(ValidationErrorTest, ValidateProto3Extension) { ASSERT_TRUE(pool.BuildFile(file_proto) != nullptr); // Add "foo.proto": // import "google/protobuf/descriptor.proto"; + // extend google.protobuf.FileOptions { + // optional string test_file_opt = 1001; + // } + // extend google.protobuf.MessageOptions { + // optional string test_msg_opt = 1002; + // } // extend google.protobuf.FieldOptions { - // optional int32 option1 = 1000; + // optional string test_field_opt = 1003; + // } + // extend google.protobuf.EnumOptions { + // repeated int32 test_enum_opt = 1004; + // } + // extend google.protobuf.EnumValueOptions { + // optional int32 test_enumval_opt = 1005; + // } + // extend google.protobuf.ServiceOptions { + // repeated int32 test_svc_opt = 1006; + // } + // extend google.protobuf.MethodOptions { + // optional string test_method_opt = 1007; + // } + // extend google.protobuf.OneofOptions { + // optional string test_oneof_opt = 1008; + // } + // extend google.protobuf.ExtensionRangeOptions { + // optional string test_ext_opt = 1009; // } file_proto.Clear(); file_proto.set_name("foo.proto"); file_proto.set_syntax("proto3"); file_proto.add_dependency("google/protobuf/descriptor.proto"); - AddExtension(&file_proto, "google.protobuf.FieldOptions", "option1", 1000, + AddExtension(&file_proto, "google.protobuf.FileOptions", "test_file_opt", 1001, + FieldDescriptorProto::LABEL_OPTIONAL, + FieldDescriptorProto::TYPE_STRING); + AddExtension(&file_proto, "google.protobuf.MessageOptions", "test_msg_opt", 1001, + FieldDescriptorProto::LABEL_OPTIONAL, + FieldDescriptorProto::TYPE_STRING); + AddExtension(&file_proto, "google.protobuf.FieldOptions", "test_field_opt", 1003, + FieldDescriptorProto::LABEL_OPTIONAL, + FieldDescriptorProto::TYPE_STRING); + AddExtension(&file_proto, "google.protobuf.EnumOptions", "test_enum_opt", 1004, + FieldDescriptorProto::LABEL_REPEATED, + FieldDescriptorProto::TYPE_INT32); + AddExtension(&file_proto, "google.protobuf.EnumValueOptions", "test_enumval_opt", 1005, FieldDescriptorProto::LABEL_OPTIONAL, FieldDescriptorProto::TYPE_INT32); + AddExtension(&file_proto, "google.protobuf.ServiceOptions", "test_svc_opt", 1006, + FieldDescriptorProto::LABEL_REPEATED, + FieldDescriptorProto::TYPE_INT32); + AddExtension(&file_proto, "google.protobuf.MethodOptions", "test_method_opt", 1007, + FieldDescriptorProto::LABEL_OPTIONAL, + FieldDescriptorProto::TYPE_STRING); + AddExtension(&file_proto, "google.protobuf.OneofOptions", "test_oneof_opt", 1008, + FieldDescriptorProto::LABEL_OPTIONAL, + FieldDescriptorProto::TYPE_STRING); + AddExtension(&file_proto, "google.protobuf.ExtensionRangeOptions", "test_ext_opt", + 1009, FieldDescriptorProto::LABEL_OPTIONAL, + FieldDescriptorProto::TYPE_STRING); ASSERT_TRUE(pool.BuildFile(file_proto) != nullptr); // Copy and change the package of the descriptor.proto @@ -6793,6 +6864,30 @@ TEST_F(ValidationErrorTest, UnusedImportWithOtherError) { } +TEST_F(ValidationErrorTest, PackageTooLong) { + BuildFileWithErrors( + "name: \"foo.proto\" " + "syntax: \"proto3\" " + "package: " + "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaa\"", + "foo.proto: " + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaa: NAME: Package name is too long\n"); +} + // =================================================================== // DescriptorDatabase @@ -6837,7 +6932,7 @@ class DatabaseBackedPoolTest : public testing::Test { class ErrorDescriptorDatabase : public DescriptorDatabase { public: ErrorDescriptorDatabase() {} - ~ErrorDescriptorDatabase() {} + ~ErrorDescriptorDatabase() override {} // implements DescriptorDatabase --------------------------------- bool FindFileByName(const std::string& filename, @@ -6876,7 +6971,7 @@ class DatabaseBackedPoolTest : public testing::Test { : wrapped_db_(wrapped_db) { Clear(); } - ~CallCountingDatabase() {} + ~CallCountingDatabase() override {} DescriptorDatabase* wrapped_db_; @@ -6911,7 +7006,7 @@ class DatabaseBackedPoolTest : public testing::Test { public: FalsePositiveDatabase(DescriptorDatabase* wrapped_db) : wrapped_db_(wrapped_db) {} - ~FalsePositiveDatabase() {} + ~FalsePositiveDatabase() override {} DescriptorDatabase* wrapped_db_; @@ -7198,7 +7293,7 @@ TEST_F(DatabaseBackedPoolTest, DoesntReloadFilesUncesessarily) { class ExponentialErrorDatabase : public DescriptorDatabase { public: ExponentialErrorDatabase() {} - ~ExponentialErrorDatabase() {} + ~ExponentialErrorDatabase() override {} // implements DescriptorDatabase --------------------------------- bool FindFileByName(const std::string& filename, @@ -7482,7 +7577,6 @@ TEST_F(SourceLocationTest, GetSourceLocation) { const MethodDescriptor* m_desc = s_desc->FindMethodByName("Method"); EXPECT_TRUE(m_desc->GetSourceLocation(&loc)); EXPECT_EQ("29:3-29:31", PrintSourceLocation(loc)); - } TEST_F(SourceLocationTest, ExtensionSourceLocation) { diff --git a/r5dev/thirdparty/protobuf/drop_unknown_fields_test.cc b/r5dev/thirdparty/protobuf/drop_unknown_fields_test.cc index 67303b11..3faf3135 100644 --- a/r5dev/thirdparty/protobuf/drop_unknown_fields_test.cc +++ b/r5dev/thirdparty/protobuf/drop_unknown_fields_test.cc @@ -44,19 +44,19 @@ namespace protobuf { TEST(DropUnknownFieldsTest, GeneratedMessage) { FooWithExtraFields foo_with_extra_fields; foo_with_extra_fields.set_int32_value(1); - foo_with_extra_fields.set_enum_value(FooWithExtraFields::QUX); + foo_with_extra_fields.set_enum_value(FooWithExtraFields::MOO); foo_with_extra_fields.set_extra_int32_value(2); Foo foo; ASSERT_TRUE(foo.ParseFromString(foo_with_extra_fields.SerializeAsString())); EXPECT_EQ(1, foo.int32_value()); - EXPECT_EQ(static_cast<int>(FooWithExtraFields::QUX), + EXPECT_EQ(static_cast<int>(FooWithExtraFields::MOO), static_cast<int>(foo.enum_value())); EXPECT_FALSE(foo.GetReflection()->GetUnknownFields(foo).empty()); ASSERT_TRUE(foo_with_extra_fields.ParseFromString(foo.SerializeAsString())); EXPECT_EQ(1, foo_with_extra_fields.int32_value()); - EXPECT_EQ(FooWithExtraFields::QUX, foo_with_extra_fields.enum_value()); + EXPECT_EQ(FooWithExtraFields::MOO, foo_with_extra_fields.enum_value()); // The "extra_int32_value" field should not be lost. EXPECT_EQ(2, foo_with_extra_fields.extra_int32_value()); } @@ -64,7 +64,7 @@ TEST(DropUnknownFieldsTest, GeneratedMessage) { TEST(DropUnknownFieldsTest, DynamicMessage) { FooWithExtraFields foo_with_extra_fields; foo_with_extra_fields.set_int32_value(1); - foo_with_extra_fields.set_enum_value(FooWithExtraFields::QUX); + foo_with_extra_fields.set_enum_value(FooWithExtraFields::MOO); foo_with_extra_fields.set_extra_int32_value(2); DynamicMessageFactory factory; @@ -74,7 +74,7 @@ TEST(DropUnknownFieldsTest, DynamicMessage) { ASSERT_TRUE(foo_with_extra_fields.ParseFromString(foo->SerializeAsString())); EXPECT_EQ(1, foo_with_extra_fields.int32_value()); - EXPECT_EQ(FooWithExtraFields::QUX, foo_with_extra_fields.enum_value()); + EXPECT_EQ(FooWithExtraFields::MOO, foo_with_extra_fields.enum_value()); // The "extra_int32_value" field should not be lost. EXPECT_EQ(2, foo_with_extra_fields.extra_int32_value()); } diff --git a/r5dev/thirdparty/protobuf/duration.pb.cc b/r5dev/thirdparty/protobuf/duration.pb.cc index 53fe8090..579b0f40 100644 --- a/r5dev/thirdparty/protobuf/duration.pb.cc +++ b/r5dev/thirdparty/protobuf/duration.pb.cc @@ -16,24 +16,29 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + PROTOBUF_NAMESPACE_OPEN -constexpr Duration::Duration( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : seconds_(int64_t{0}) - , nanos_(0){} +PROTOBUF_CONSTEXPR Duration::Duration( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.seconds_)*/int64_t{0} + , /*decltype(_impl_.nanos_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} struct DurationDefaultTypeInternal { - constexpr DurationDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR DurationDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~DurationDefaultTypeInternal() {} union { Duration _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DurationDefaultTypeInternal _Duration_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DurationDefaultTypeInternal _Duration_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fduration_2eproto[1]; -static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr; +static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fduration_2eproto[1]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr; const uint32_t TableStruct_google_2fprotobuf_2fduration_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ @@ -42,15 +47,15 @@ const uint32_t TableStruct_google_2fprotobuf_2fduration_2eproto::offsets[] PROTO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, seconds_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, nanos_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, _impl_.seconds_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Duration, _impl_.nanos_), }; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Duration)}, }; -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Duration_default_instance_), +static const ::_pb::Message* const file_default_instances[] = { + &::PROTOBUF_NAMESPACE_ID::_Duration_default_instance_._instance, }; const char descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = @@ -61,19 +66,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto[] PROT "uf/types/known/durationpb\370\001\001\242\002\003GPB\252\002\036Goo" "gle.Protobuf.WellKnownTypesb\006proto3" ; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fduration_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto = { - false, false, 235, descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto, "google/protobuf/duration.proto", - &descriptor_table_google_2fprotobuf_2fduration_2eproto_once, nullptr, 0, 1, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fduration_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fduration_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto, file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto, +static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fduration_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto = { + false, false, 235, descriptor_table_protodef_google_2fprotobuf_2fduration_2eproto, + "google/protobuf/duration.proto", + &descriptor_table_google_2fprotobuf_2fduration_2eproto_once, nullptr, 0, 1, + schemas, file_default_instances, TableStruct_google_2fprotobuf_2fduration_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fduration_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto, + file_level_service_descriptors_google_2fprotobuf_2fduration_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fduration_2eproto_getter() { +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fduration_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fduration_2eproto; } // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fduration_2eproto(&descriptor_table_google_2fprotobuf_2fduration_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fduration_2eproto(&descriptor_table_google_2fprotobuf_2fduration_2eproto); PROTOBUF_NAMESPACE_OPEN // =================================================================== @@ -85,47 +92,50 @@ class Duration::_Internal { Duration::Duration(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Duration) } Duration::Duration(const Duration& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + Duration* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.seconds_){} + , decltype(_impl_.nanos_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::memcpy(&seconds_, &from.seconds_, - static_cast<size_t>(reinterpret_cast<char*>(&nanos_) - - reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_)); + ::memcpy(&_impl_.seconds_, &from._impl_.seconds_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.nanos_) - + reinterpret_cast<char*>(&_impl_.seconds_)) + sizeof(_impl_.nanos_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Duration) } -inline void Duration::SharedCtor() { -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&seconds_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&nanos_) - - reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_)); +inline void Duration::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.seconds_){int64_t{0}} + , decltype(_impl_.nanos_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; } Duration::~Duration() { // @@protoc_insertion_point(destructor:google.protobuf.Duration) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Duration::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } -void Duration::ArenaDtor(void* object) { - Duration* _this = reinterpret_cast< Duration* >(object); - (void)_this; -} -void Duration::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Duration::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Duration::Clear() { @@ -134,22 +144,22 @@ void Duration::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - ::memset(&seconds_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&nanos_) - - reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_)); + ::memset(&_impl_.seconds_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.nanos_) - + reinterpret_cast<char*>(&_impl_.seconds_)) + sizeof(_impl_.nanos_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Duration::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Duration::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // int64 seconds = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { - seconds_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.seconds_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -157,7 +167,7 @@ const char* Duration::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::i // int32 nanos = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { - nanos_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.nanos_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -194,17 +204,17 @@ uint8_t* Duration::_InternalSerialize( // int64 seconds = 1; if (this->_internal_seconds() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(1, this->_internal_seconds(), target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(1, this->_internal_seconds(), target); } // int32 nanos = 2; if (this->_internal_nanos() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_nanos(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_nanos(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Duration) @@ -221,43 +231,39 @@ size_t Duration::ByteSizeLong() const { // int64 seconds = 1; if (this->_internal_seconds() != 0) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64SizePlusOne(this->_internal_seconds()); + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_seconds()); } // int32 nanos = 2; if (this->_internal_nanos() != 0) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_nanos()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_nanos()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Duration::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Duration::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Duration::GetClassData() const { return &_class_data_; } -void Duration::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Duration *>(to)->MergeFrom( - static_cast<const Duration &>(from)); -} - -void Duration::MergeFrom(const Duration& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Duration) - GOOGLE_DCHECK_NE(&from, this); +void Duration::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Duration*>(&to_msg); + auto& from = static_cast<const Duration&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Duration) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_seconds() != 0) { - _internal_set_seconds(from._internal_seconds()); + _this->_internal_set_seconds(from._internal_seconds()); } if (from._internal_nanos() != 0) { - _internal_set_nanos(from._internal_nanos()); + _this->_internal_set_nanos(from._internal_nanos()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Duration::CopyFrom(const Duration& from) { @@ -275,15 +281,15 @@ void Duration::InternalSwap(Duration* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Duration, nanos_) - + sizeof(Duration::nanos_) - - PROTOBUF_FIELD_OFFSET(Duration, seconds_)>( - reinterpret_cast<char*>(&seconds_), - reinterpret_cast<char*>(&other->seconds_)); + PROTOBUF_FIELD_OFFSET(Duration, _impl_.nanos_) + + sizeof(Duration::_impl_.nanos_) + - PROTOBUF_FIELD_OFFSET(Duration, _impl_.seconds_)>( + reinterpret_cast<char*>(&_impl_.seconds_), + reinterpret_cast<char*>(&other->_impl_.seconds_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Duration::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fduration_2eproto_getter, &descriptor_table_google_2fprotobuf_2fduration_2eproto_once, file_level_metadata_google_2fprotobuf_2fduration_2eproto[0]); } @@ -291,7 +297,8 @@ void Duration::InternalSwap(Duration* other) { // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Duration* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Duration >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Duration* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Duration >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Duration >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/thirdparty/protobuf/duration.pb.h b/r5dev/thirdparty/protobuf/duration.pb.h index 06462d71..8e0053bc 100644 --- a/r5dev/thirdparty/protobuf/duration.pb.h +++ b/r5dev/thirdparty/protobuf/duration.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/generated_message_reflection.h> @@ -42,14 +41,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fduration_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fduration_2eproto; @@ -70,7 +61,7 @@ class PROTOBUF_EXPORT Duration final : public: inline Duration() : Duration(nullptr) {} ~Duration() override; - explicit constexpr Duration(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Duration(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Duration(const Duration& from); Duration(Duration&& from) noexcept @@ -145,9 +136,11 @@ class PROTOBUF_EXPORT Duration final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Duration& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Duration& from); + void MergeFrom( const Duration& from) { + Duration::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -156,10 +149,10 @@ class PROTOBUF_EXPORT Duration final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Duration* other); @@ -172,9 +165,6 @@ class PROTOBUF_EXPORT Duration final : protected: explicit Duration(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -215,9 +205,12 @@ class PROTOBUF_EXPORT Duration final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - int64_t seconds_; - int32_t nanos_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + int64_t seconds_; + int32_t nanos_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fduration_2eproto; }; // =================================================================== @@ -233,10 +226,10 @@ class PROTOBUF_EXPORT Duration final : // int64 seconds = 1; inline void Duration::clear_seconds() { - seconds_ = int64_t{0}; + _impl_.seconds_ = int64_t{0}; } inline int64_t Duration::_internal_seconds() const { - return seconds_; + return _impl_.seconds_; } inline int64_t Duration::seconds() const { // @@protoc_insertion_point(field_get:google.protobuf.Duration.seconds) @@ -244,7 +237,7 @@ inline int64_t Duration::seconds() const { } inline void Duration::_internal_set_seconds(int64_t value) { - seconds_ = value; + _impl_.seconds_ = value; } inline void Duration::set_seconds(int64_t value) { _internal_set_seconds(value); @@ -253,10 +246,10 @@ inline void Duration::set_seconds(int64_t value) { // int32 nanos = 2; inline void Duration::clear_nanos() { - nanos_ = 0; + _impl_.nanos_ = 0; } inline int32_t Duration::_internal_nanos() const { - return nanos_; + return _impl_.nanos_; } inline int32_t Duration::nanos() const { // @@protoc_insertion_point(field_get:google.protobuf.Duration.nanos) @@ -264,7 +257,7 @@ inline int32_t Duration::nanos() const { } inline void Duration::_internal_set_nanos(int32_t value) { - nanos_ = value; + _impl_.nanos_ = value; } inline void Duration::set_nanos(int32_t value) { _internal_set_nanos(value); diff --git a/r5dev/thirdparty/protobuf/dynamic_message.cc b/r5dev/thirdparty/protobuf/dynamic_message.cc index 8d7ad5be..2ba3ffec 100644 --- a/r5dev/thirdparty/protobuf/dynamic_message.cc +++ b/r5dev/thirdparty/protobuf/dynamic_message.cc @@ -70,8 +70,8 @@ #include <new> #include <unordered_map> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/generated_message_reflection.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/unknown_field_set.h> @@ -85,7 +85,8 @@ #include <thirdparty/protobuf/repeated_field.h> #include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/port_def.inc> // NOLINT +// Must be included last. +#include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { @@ -100,14 +101,6 @@ using internal::ArenaStringPtr; // =================================================================== // Some helper tables and functions... -class DynamicMessageReflectionHelper { - public: - static bool IsLazyField(const Reflection* reflection, - const FieldDescriptor* field) { - return reflection->IsLazyField(field); - } -}; - namespace { bool IsMapFieldInApi(const FieldDescriptor* field) { return field->is_map(); } @@ -232,7 +225,7 @@ class DynamicMessage : public Message { // This should only be used by GetPrototypeNoLock() to avoid dead lock. DynamicMessage(DynamicMessageFactory::TypeInfo* type_info, bool lock_factory); - ~DynamicMessage(); + ~DynamicMessage() override; // Called on the prototype after construction to initialize message fields. // Cross linking the default instances allows for fast reflection access of @@ -277,13 +270,6 @@ class DynamicMessage : public Message { bool is_prototype() const; - inline int OffsetValue(int v, FieldDescriptor::Type type) const { - if (type == FieldDescriptor::TYPE_MESSAGE) { - return v & ~0x1u; - } - return v; - } - inline void* OffsetToPointer(int offset) { return reinterpret_cast<uint8_t*>(this) + offset; } @@ -355,23 +341,20 @@ DynamicMessage::DynamicMessage(DynamicMessageFactory::TypeInfo* type_info, } inline void* DynamicMessage::MutableRaw(int i) { - return OffsetToPointer( - OffsetValue(type_info_->offsets[i], type_info_->type->field(i)->type())); + return OffsetToPointer(type_info_->offsets[i]); } -void* DynamicMessage::MutableExtensionsRaw() { +inline void* DynamicMessage::MutableExtensionsRaw() { return OffsetToPointer(type_info_->extensions_offset); } -void* DynamicMessage::MutableWeakFieldMapRaw() { +inline void* DynamicMessage::MutableWeakFieldMapRaw() { return OffsetToPointer(type_info_->weak_field_map_offset); } -void* DynamicMessage::MutableOneofCaseRaw(int i) { +inline void* DynamicMessage::MutableOneofCaseRaw(int i) { return OffsetToPointer(type_info_->oneof_case_offset + sizeof(uint32_t) * i); } -void* DynamicMessage::MutableOneofFieldRaw(const FieldDescriptor* f) { - return OffsetToPointer( - OffsetValue(type_info_->offsets[type_info_->type->field_count() + - f->containing_oneof()->index()], - f->type())); +inline void* DynamicMessage::MutableOneofFieldRaw(const FieldDescriptor* f) { + return OffsetToPointer(type_info_->offsets[type_info_->type->field_count() + + f->containing_oneof()->index()]); } void DynamicMessage::SharedCtor(bool lock_factory) { @@ -433,12 +416,8 @@ void DynamicMessage::SharedCtor(bool lock_factory) { default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: if (!field->is_repeated()) { - const std::string* default_value = - field->default_value_string().empty() - ? &internal::GetEmptyStringAlreadyInited() - : nullptr; ArenaStringPtr* asp = new (field_ptr) ArenaStringPtr(); - asp->UnsafeSetDefault(default_value); + asp->InitDefault(); } else { new (field_ptr) RepeatedPtrField<std::string>(GetArenaForAllocation()); @@ -539,13 +518,7 @@ DynamicMessage::~DynamicMessage() { switch (field->options().ctype()) { default: case FieldOptions::STRING: { - // Oneof string fields are never set as a default instance. - // We just need to pass some arbitrary default string to make it - // work. This allows us to not have the real default accessible - // from reflection. - const std::string* default_value = nullptr; - reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy( - default_value, nullptr); + reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(); break; } } @@ -599,13 +572,7 @@ DynamicMessage::~DynamicMessage() { switch (field->options().ctype()) { default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: { - const std::string* default_value = - reinterpret_cast<const ArenaStringPtr*>( - type_info_->prototype->OffsetToPointer( - type_info_->offsets[i])) - ->GetPointer(); - reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(default_value, - nullptr); + reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(); break; } } diff --git a/r5dev/thirdparty/protobuf/dynamic_message.h b/r5dev/thirdparty/protobuf/dynamic_message.h index cfcae374..c6ae8680 100644 --- a/r5dev/thirdparty/protobuf/dynamic_message.h +++ b/r5dev/thirdparty/protobuf/dynamic_message.h @@ -38,14 +38,15 @@ #ifndef GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ #define GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ + #include <algorithm> #include <memory> #include <unordered_map> #include <vector> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/stubs/mutex.h> +#include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/reflection.h> #include <thirdparty/protobuf/repeated_field.h> @@ -53,6 +54,7 @@ #error "You cannot SWIG proto headers" #endif +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -94,7 +96,7 @@ class PROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory { // the zero-arg constructor. DynamicMessageFactory(const DescriptorPool* pool); - ~DynamicMessageFactory(); + ~DynamicMessageFactory() override; // Call this to tell the DynamicMessageFactory that if it is given a // Descriptor d for which: diff --git a/r5dev/thirdparty/protobuf/dynamic_message_unittest.cc b/r5dev/thirdparty/protobuf/dynamic_message_unittest.cc index bc813a97..f2918d06 100644 --- a/r5dev/thirdparty/protobuf/dynamic_message_unittest.cc +++ b/r5dev/thirdparty/protobuf/dynamic_message_unittest.cc @@ -40,19 +40,19 @@ // reflection_ops_unittest, cover the rest of the functionality used by // DynamicMessage. +#include <thirdparty/protobuf/dynamic_message.h> + #include <memory> -#include <thirdparty/protobuf/test_util.h> +#include <thirdparty/protobuf/stubs/logging.h> +#include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/unittest.pb.h> #include <thirdparty/protobuf/unittest_no_field_presence.pb.h> #include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/dynamic_message.h> - -#include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> +#include <thirdparty/protobuf/test_util.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/empty.pb.cc b/r5dev/thirdparty/protobuf/empty.pb.cc index 67cbc28d..6105f30e 100644 --- a/r5dev/thirdparty/protobuf/empty.pb.cc +++ b/r5dev/thirdparty/protobuf/empty.pb.cc @@ -16,22 +16,26 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + PROTOBUF_NAMESPACE_OPEN -constexpr Empty::Empty( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized){} +PROTOBUF_CONSTEXPR Empty::Empty( + ::_pbi::ConstantInitialized) {} struct EmptyDefaultTypeInternal { - constexpr EmptyDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EmptyDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~EmptyDefaultTypeInternal() {} union { Empty _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EmptyDefaultTypeInternal _Empty_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EmptyDefaultTypeInternal _Empty_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fempty_2eproto[1]; -static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr; +static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fempty_2eproto[1]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr; const uint32_t TableStruct_google_2fprotobuf_2fempty_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ @@ -41,12 +45,12 @@ const uint32_t TableStruct_google_2fprotobuf_2fempty_2eproto::offsets[] PROTOBUF ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ }; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Empty)}, }; -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Empty_default_instance_), +static const ::_pb::Message* const file_default_instances[] = { + &::PROTOBUF_NAMESPACE_ID::_Empty_default_instance_._instance, }; const char descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = @@ -56,19 +60,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto[] PROTOBU "/types/known/emptypb\370\001\001\242\002\003GPB\252\002\036Google.P" "rotobuf.WellKnownTypesb\006proto3" ; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fempty_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto = { - false, false, 190, descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto, "google/protobuf/empty.proto", - &descriptor_table_google_2fprotobuf_2fempty_2eproto_once, nullptr, 0, 1, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fempty_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fempty_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto, file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto, +static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fempty_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto = { + false, false, 190, descriptor_table_protodef_google_2fprotobuf_2fempty_2eproto, + "google/protobuf/empty.proto", + &descriptor_table_google_2fprotobuf_2fempty_2eproto_once, nullptr, 0, 1, + schemas, file_default_instances, TableStruct_google_2fprotobuf_2fempty_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fempty_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto, + file_level_service_descriptors_google_2fprotobuf_2fempty_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fempty_2eproto_getter() { +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fempty_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fempty_2eproto; } // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fempty_2eproto(&descriptor_table_google_2fprotobuf_2fempty_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fempty_2eproto(&descriptor_table_google_2fprotobuf_2fempty_2eproto); PROTOBUF_NAMESPACE_OPEN // =================================================================== @@ -84,6 +90,7 @@ Empty::Empty(::PROTOBUF_NAMESPACE_ID::Arena* arena, } Empty::Empty(const Empty& from) : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase() { + Empty* const _this = this; (void)_this; _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.Empty) } @@ -105,7 +112,7 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Empty::GetClassData() const { ::PROTOBUF_NAMESPACE_ID::Metadata Empty::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fempty_2eproto_getter, &descriptor_table_google_2fprotobuf_2fempty_2eproto_once, file_level_metadata_google_2fprotobuf_2fempty_2eproto[0]); } @@ -113,7 +120,8 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Empty::GetClassData() const { // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Empty* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Empty >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Empty* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Empty >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Empty >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/thirdparty/protobuf/empty.pb.h b/r5dev/thirdparty/protobuf/empty.pb.h index 507e5a3e..2bd7f8aa 100644 --- a/r5dev/thirdparty/protobuf/empty.pb.h +++ b/r5dev/thirdparty/protobuf/empty.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -24,7 +24,6 @@ #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> #include <thirdparty/protobuf/generated_message_bases.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/generated_message_reflection.h> @@ -43,14 +42,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fempty_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fempty_2eproto; @@ -70,7 +61,7 @@ class PROTOBUF_EXPORT Empty final : public ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ { public: inline Empty() : Empty(nullptr) {} - explicit constexpr Empty(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Empty(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Empty(const Empty& from); Empty(Empty&& from) noexcept @@ -144,11 +135,11 @@ class PROTOBUF_EXPORT Empty final : } using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyFrom; inline void CopyFrom(const Empty& from) { - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl(this, from); + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl(*this, from); } using ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeFrom; void MergeFrom(const Empty& from) { - ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl(this, from); + ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl(*this, from); } public: @@ -160,7 +151,6 @@ class PROTOBUF_EXPORT Empty final : protected: explicit Empty(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: public: static const ClassData _class_data_; @@ -179,7 +169,8 @@ class PROTOBUF_EXPORT Empty final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + }; friend struct ::TableStruct_google_2fprotobuf_2fempty_2eproto; }; // =================================================================== diff --git a/r5dev/thirdparty/protobuf/empty.proto b/r5dev/thirdparty/protobuf/empty.proto index 5f992de9..22274621 100644 --- a/r5dev/thirdparty/protobuf/empty.proto +++ b/r5dev/thirdparty/protobuf/empty.proto @@ -48,5 +48,4 @@ option cc_enable_arenas = true; // rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); // } // -// The JSON representation for `Empty` is empty JSON object `{}`. message Empty {} diff --git a/r5dev/thirdparty/protobuf/endian.h b/r5dev/thirdparty/protobuf/endian.h new file mode 100644 index 00000000..ced73bf8 --- /dev/null +++ b/r5dev/thirdparty/protobuf/endian.h @@ -0,0 +1,198 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef GOOGLE_PROTOBUF_ENDIAN_H__ +#define GOOGLE_PROTOBUF_ENDIAN_H__ + +#if defined(_MSC_VER) +#include <stdlib.h> +#endif + +#include <cstdint> + +// Must be included last. +#include <thirdparty/protobuf/port_def.inc> + +namespace google { +namespace protobuf { +namespace internal { + +inline uint64_t BSwap64(uint64_t host_int) { +#if defined(PROTOBUF_BUILTIN_BSWAP64) + return PROTOBUF_BUILTIN_BSWAP64(host_int); +#elif defined(_MSC_VER) + return _byteswap_uint64(host_int); +#else + return (((host_int & uint64_t{0xFF}) << 56) | + ((host_int & uint64_t{0xFF00}) << 40) | + ((host_int & uint64_t{0xFF0000}) << 24) | + ((host_int & uint64_t{0xFF000000}) << 8) | + ((host_int & uint64_t{0xFF00000000}) >> 8) | + ((host_int & uint64_t{0xFF0000000000}) >> 24) | + ((host_int & uint64_t{0xFF000000000000}) >> 40) | + ((host_int & uint64_t{0xFF00000000000000}) >> 56)); +#endif +} + +inline uint32_t BSwap32(uint32_t host_int) { +#if defined(PROTOBUF_BUILTIN_BSWAP32) + return PROTOBUF_BUILTIN_BSWAP32(host_int); +#elif defined(_MSC_VER) + return _byteswap_ulong(host_int); +#else + return (((host_int & uint32_t{0xFF}) << 24) | + ((host_int & uint32_t{0xFF00}) << 8) | + ((host_int & uint32_t{0xFF0000}) >> 8) | + ((host_int & uint32_t{0xFF000000}) >> 24)); +#endif +} + +inline uint16_t BSwap16(uint16_t host_int) { +#if defined(PROTOBUF_BUILTIN_BSWAP16) + return PROTOBUF_BUILTIN_BSWAP16(host_int); +#elif defined(_MSC_VER) + return _byteswap_ushort(host_int); +#else + return (((host_int & uint16_t{0xFF}) << 8) | + ((host_int & uint16_t{0xFF00}) >> 8)); +#endif +} + +namespace little_endian { + +inline uint16_t FromHost(uint16_t value) { +#if defined(PROTOBUF_BIG_ENDIAN) + return BSwap16(value); +#else + return value; +#endif +} + +inline uint32_t FromHost(uint32_t value) { +#if defined(PROTOBUF_BIG_ENDIAN) + return BSwap32(value); +#else + return value; +#endif +} + +inline uint64_t FromHost(uint64_t value) { +#if defined(PROTOBUF_BIG_ENDIAN) + return BSwap64(value); +#else + return value; +#endif +} + +inline uint16_t ToHost(uint16_t value) { +#if defined(PROTOBUF_BIG_ENDIAN) + return BSwap16(value); +#else + return value; +#endif +} + +inline uint32_t ToHost(uint32_t value) { +#if defined(PROTOBUF_BIG_ENDIAN) + return BSwap32(value); +#else + return value; +#endif +} + +inline uint64_t ToHost(uint64_t value) { +#if defined(PROTOBUF_BIG_ENDIAN) + return BSwap64(value); +#else + return value; +#endif +} + +} // namespace little_endian + +namespace big_endian { + +inline uint16_t FromHost(uint16_t value) { +#if defined(PROTOBUF_BIG_ENDIAN) + return value; +#else + return BSwap16(value); +#endif +} + +inline uint32_t FromHost(uint32_t value) { +#if defined(PROTOBUF_BIG_ENDIAN) + return value; +#else + return BSwap32(value); +#endif +} + +inline uint64_t FromHost(uint64_t value) { +#if defined(PROTOBUF_BIG_ENDIAN) + return value; +#else + return BSwap64(value); +#endif +} + +inline uint16_t ToHost(uint16_t value) { +#if defined(PROTOBUF_BIG_ENDIAN) + return value; +#else + return BSwap16(value); +#endif +} + +inline uint32_t ToHost(uint32_t value) { +#if defined(PROTOBUF_BIG_ENDIAN) + return value; +#else + return BSwap32(value); +#endif +} + +inline uint64_t ToHost(uint64_t value) { +#if defined(PROTOBUF_BIG_ENDIAN) + return value; +#else + return BSwap64(value); +#endif +} + +} // namespace big_endian + +} // namespace internal +} // namespace protobuf +} // namespace google + +#include <thirdparty/protobuf/port_undef.inc> + +#endif // GOOGLE_PROTOBUF_ENDIAN_H__ diff --git a/r5dev/thirdparty/protobuf/explicitly_constructed.h b/r5dev/thirdparty/protobuf/explicitly_constructed.h index a38ffde2..7d6f958d 100644 --- a/r5dev/thirdparty/protobuf/explicitly_constructed.h +++ b/r5dev/thirdparty/protobuf/explicitly_constructed.h @@ -59,7 +59,7 @@ namespace internal { // 3. Call get() and get_mutable() only if the object is initialized. // 4. Call Destruct() only if the object is initialized. // After the call, the object becomes uninitialized. -template <typename T> +template <typename T, size_t min_align = 1> class ExplicitlyConstructed { public: void DefaultConstruct() { new (&union_) T(); } @@ -76,12 +76,18 @@ class ExplicitlyConstructed { private: union AlignedUnion { - alignas(T) char space[sizeof(T)]; + alignas(min_align > alignof(T) ? min_align + : alignof(T)) char space[sizeof(T)]; int64_t align_to_int64; void* align_to_ptr; } union_; }; +// ArenaStringPtr compatible explicitly constructed string type. +// This empty string type is aligned with a minimum alignment of 8 bytes +// which is the minimum requirement of ArenaStringPtr +using ExplicitlyConstructedArenaString = ExplicitlyConstructed<std::string, 8>; + } // namespace internal } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/extension_set.cc b/r5dev/thirdparty/protobuf/extension_set.cc index 79dbe90d..a85bf39d 100644 --- a/r5dev/thirdparty/protobuf/extension_set.cc +++ b/r5dev/thirdparty/protobuf/extension_set.cc @@ -39,13 +39,14 @@ #include <utility> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/extension_set_inl.h> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> #include <thirdparty/protobuf/arena.h> +#include <thirdparty/protobuf/extension_set_inl.h> #include <thirdparty/protobuf/message_lite.h> #include <thirdparty/protobuf/metadata_lite.h> +#include <thirdparty/protobuf/parse_context.h> +#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/repeated_field.h> #include <thirdparty/protobuf/stubs/map_util.h> #include <thirdparty/protobuf/stubs/hash.h> @@ -68,24 +69,6 @@ inline WireFormatLite::CppType cpp_type(FieldType type) { return WireFormatLite::FieldTypeToCppType(real_type(type)); } -inline bool is_packable(WireFormatLite::WireType type) { - switch (type) { - case WireFormatLite::WIRETYPE_VARINT: - case WireFormatLite::WIRETYPE_FIXED64: - case WireFormatLite::WIRETYPE_FIXED32: - return true; - case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: - case WireFormatLite::WIRETYPE_START_GROUP: - case WireFormatLite::WIRETYPE_END_GROUP: - return false; - - // Do not add a default statement. Let the compiler complain when someone - // adds a new wire type. - } - GOOGLE_LOG(FATAL) << "can't reach here."; - return false; -} - // Registry stuff. // Note that we cannot use hetererogeneous lookup for std containers since we @@ -138,8 +121,6 @@ const ExtensionInfo* FindRegisteredExtension(const MessageLite* extendee, } // namespace -ExtensionFinder::~ExtensionFinder() {} - bool GeneratedExtensionFinder::Find(int number, ExtensionInfo* output) { const ExtensionInfo* extension = FindRegisteredExtension(extendee_, number); if (extension == nullptr) { @@ -152,11 +133,13 @@ bool GeneratedExtensionFinder::Find(int number, ExtensionInfo* output) { void ExtensionSet::RegisterExtension(const MessageLite* extendee, int number, FieldType type, bool is_repeated, - bool is_packed) { + bool is_packed, + LazyEagerVerifyFnType verify_func) { GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_ENUM); GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_MESSAGE); GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_GROUP); - ExtensionInfo info(extendee, number, type, is_repeated, is_packed); + ExtensionInfo info(extendee, number, type, is_repeated, is_packed, + verify_func); Register(info); } @@ -178,7 +161,7 @@ void ExtensionSet::RegisterEnumExtension(const MessageLite* extendee, bool is_repeated, bool is_packed, EnumValidityFunc* is_valid) { GOOGLE_CHECK_EQ(type, WireFormatLite::TYPE_ENUM); - ExtensionInfo info(extendee, number, type, is_repeated, is_packed); + ExtensionInfo info(extendee, number, type, is_repeated, is_packed, nullptr); info.enum_validity_check.func = CallNoArgValidityFunc; // See comment in CallNoArgValidityFunc() about why we use a c-style cast. info.enum_validity_check.arg = (void*)is_valid; @@ -188,10 +171,12 @@ void ExtensionSet::RegisterEnumExtension(const MessageLite* extendee, void ExtensionSet::RegisterMessageExtension(const MessageLite* extendee, int number, FieldType type, bool is_repeated, bool is_packed, - const MessageLite* prototype) { + const MessageLite* prototype, + LazyEagerVerifyFnType verify_func) { GOOGLE_CHECK(type == WireFormatLite::TYPE_MESSAGE || type == WireFormatLite::TYPE_GROUP); - ExtensionInfo info(extendee, number, type, is_repeated, is_packed); + ExtensionInfo info(extendee, number, type, is_repeated, is_packed, + verify_func); info.message_info = {prototype}; Register(info); } @@ -221,18 +206,14 @@ ExtensionSet::~ExtensionSet() { void ExtensionSet::DeleteFlatMap(const ExtensionSet::KeyValue* flat, uint16_t flat_capacity) { -#ifdef __cpp_sized_deallocation // Arena::CreateArray already requires a trivially destructible type, but // ensure this constraint is not violated in the future. static_assert(std::is_trivially_destructible<KeyValue>::value, "CreateArray requires a trivially destructible type"); // A const-cast is needed, but this is safe as we are about to deallocate the // array. - ::operator delete[](const_cast<ExtensionSet::KeyValue*>(flat), - sizeof(*flat) * flat_capacity); -#else // !__cpp_sized_deallocation - delete[] flat; -#endif // !__cpp_sized_deallocation + internal::SizedArrayDelete(const_cast<KeyValue*>(flat), + sizeof(*flat) * flat_capacity); } // Defined in extension_set_heavy.cc. @@ -948,23 +929,35 @@ void ExtensionSet::Clear() { } namespace { -// Computes the size of a std::set_union without constructing the union. +// Computes the size of an ExtensionSet union without actually constructing the +// union. Note that we do not count cleared extensions from the source to be +// part of the total, because there is no need to allocate space for those. We +// do include cleared extensions in the destination, though, because those are +// already allocated and will not be going away. template <typename ItX, typename ItY> -size_t SizeOfUnion(ItX it_xs, ItX end_xs, ItY it_ys, ItY end_ys) { +size_t SizeOfUnion(ItX it_dest, ItX end_dest, ItY it_source, ItY end_source) { size_t result = 0; - while (it_xs != end_xs && it_ys != end_ys) { - ++result; - if (it_xs->first < it_ys->first) { - ++it_xs; - } else if (it_xs->first == it_ys->first) { - ++it_xs; - ++it_ys; + while (it_dest != end_dest && it_source != end_source) { + if (it_dest->first < it_source->first) { + ++result; + ++it_dest; + } else if (it_dest->first == it_source->first) { + ++result; + ++it_dest; + ++it_source; } else { - ++it_ys; + if (!it_source->second.is_cleared) { + ++result; + } + ++it_source; + } + } + result += std::distance(it_dest, end_dest); + for (; it_source != end_source; ++it_source) { + if (!it_source->second.is_cleared) { + ++result; } } - result += std::distance(it_xs, end_xs); - result += std::distance(it_ys, end_ys); return result; } } // namespace @@ -1234,55 +1227,6 @@ bool ExtensionSet::IsInitialized() const { return true; } -bool ExtensionSet::FindExtensionInfoFromTag(uint32_t tag, - ExtensionFinder* extension_finder, - int* field_number, - ExtensionInfo* extension, - bool* was_packed_on_wire) { - *field_number = WireFormatLite::GetTagFieldNumber(tag); - WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag); - return FindExtensionInfoFromFieldNumber(wire_type, *field_number, - extension_finder, extension, - was_packed_on_wire); -} - -bool ExtensionSet::FindExtensionInfoFromFieldNumber( - int wire_type, int field_number, ExtensionFinder* extension_finder, - ExtensionInfo* extension, bool* was_packed_on_wire) const { - if (!extension_finder->Find(field_number, extension)) { - return false; - } - - WireFormatLite::WireType expected_wire_type = - WireFormatLite::WireTypeForFieldType(real_type(extension->type)); - - // Check if this is a packed field. - *was_packed_on_wire = false; - if (extension->is_repeated && - wire_type == WireFormatLite::WIRETYPE_LENGTH_DELIMITED && - is_packable(expected_wire_type)) { - *was_packed_on_wire = true; - return true; - } - // Otherwise the wire type must match. - return expected_wire_type == wire_type; -} - -bool ExtensionSet::ParseField(uint32_t tag, io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper) { - int number; - bool was_packed_on_wire; - ExtensionInfo extension; - if (!FindExtensionInfoFromTag(tag, extension_finder, &number, &extension, - &was_packed_on_wire)) { - return field_skipper->SkipField(input, tag); - } else { - return ParseFieldWithExtensionInfo(number, was_packed_on_wire, extension, - input, field_skipper); - } -} - const char* ExtensionSet::ParseField(uint64_t tag, const char* ptr, const MessageLite* extendee, internal::InternalMetadata* metadata, @@ -1307,249 +1251,6 @@ const char* ExtensionSet::ParseMessageSetItem( metadata, ctx); } -bool ExtensionSet::ParseFieldWithExtensionInfo(int number, - bool was_packed_on_wire, - const ExtensionInfo& extension, - io::CodedInputStream* input, - FieldSkipper* field_skipper) { - // Explicitly not read extension.is_packed, instead check whether the field - // was encoded in packed form on the wire. - if (was_packed_on_wire) { - uint32_t size; - if (!input->ReadVarint32(&size)) return false; - io::CodedInputStream::Limit limit = input->PushLimit(size); - - switch (extension.type) { -#define HANDLE_TYPE(UPPERCASE, CPP_CAMELCASE, CPP_LOWERCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: \ - while (input->BytesUntilLimit() > 0) { \ - CPP_LOWERCASE value; \ - if (!WireFormatLite::ReadPrimitive<CPP_LOWERCASE, \ - WireFormatLite::TYPE_##UPPERCASE>( \ - input, &value)) \ - return false; \ - Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \ - extension.is_packed, value, extension.descriptor); \ - } \ - break - - HANDLE_TYPE(INT32, Int32, int32_t); - HANDLE_TYPE(INT64, Int64, int64_t); - HANDLE_TYPE(UINT32, UInt32, uint32_t); - HANDLE_TYPE(UINT64, UInt64, uint64_t); - HANDLE_TYPE(SINT32, Int32, int32_t); - HANDLE_TYPE(SINT64, Int64, int64_t); - HANDLE_TYPE(FIXED32, UInt32, uint32_t); - HANDLE_TYPE(FIXED64, UInt64, uint64_t); - HANDLE_TYPE(SFIXED32, Int32, int32_t); - HANDLE_TYPE(SFIXED64, Int64, int64_t); - HANDLE_TYPE(FLOAT, Float, float); - HANDLE_TYPE(DOUBLE, Double, double); - HANDLE_TYPE(BOOL, Bool, bool); -#undef HANDLE_TYPE - - case WireFormatLite::TYPE_ENUM: - while (input->BytesUntilLimit() > 0) { - int value; - if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>( - input, &value)) - return false; - if (extension.enum_validity_check.func( - extension.enum_validity_check.arg, value)) { - AddEnum(number, WireFormatLite::TYPE_ENUM, extension.is_packed, - value, extension.descriptor); - } else { - // Invalid value. Treat as unknown. - field_skipper->SkipUnknownEnum(number, value); - } - } - break; - - case WireFormatLite::TYPE_STRING: - case WireFormatLite::TYPE_BYTES: - case WireFormatLite::TYPE_GROUP: - case WireFormatLite::TYPE_MESSAGE: - GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed."; - break; - } - - input->PopLimit(limit); - } else { - switch (extension.type) { -#define HANDLE_TYPE(UPPERCASE, CPP_CAMELCASE, CPP_LOWERCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: { \ - CPP_LOWERCASE value; \ - if (!WireFormatLite::ReadPrimitive<CPP_LOWERCASE, \ - WireFormatLite::TYPE_##UPPERCASE>( \ - input, &value)) \ - return false; \ - if (extension.is_repeated) { \ - Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \ - extension.is_packed, value, extension.descriptor); \ - } else { \ - Set##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, value, \ - extension.descriptor); \ - } \ - } break - - HANDLE_TYPE(INT32, Int32, int32_t); - HANDLE_TYPE(INT64, Int64, int64_t); - HANDLE_TYPE(UINT32, UInt32, uint32_t); - HANDLE_TYPE(UINT64, UInt64, uint64_t); - HANDLE_TYPE(SINT32, Int32, int32_t); - HANDLE_TYPE(SINT64, Int64, int64_t); - HANDLE_TYPE(FIXED32, UInt32, uint32_t); - HANDLE_TYPE(FIXED64, UInt64, uint64_t); - HANDLE_TYPE(SFIXED32, Int32, int32_t); - HANDLE_TYPE(SFIXED64, Int64, int64_t); - HANDLE_TYPE(FLOAT, Float, float); - HANDLE_TYPE(DOUBLE, Double, double); - HANDLE_TYPE(BOOL, Bool, bool); -#undef HANDLE_TYPE - - case WireFormatLite::TYPE_ENUM: { - int value; - if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>( - input, &value)) - return false; - - if (!extension.enum_validity_check.func( - extension.enum_validity_check.arg, value)) { - // Invalid value. Treat as unknown. - field_skipper->SkipUnknownEnum(number, value); - } else if (extension.is_repeated) { - AddEnum(number, WireFormatLite::TYPE_ENUM, extension.is_packed, value, - extension.descriptor); - } else { - SetEnum(number, WireFormatLite::TYPE_ENUM, value, - extension.descriptor); - } - break; - } - - case WireFormatLite::TYPE_STRING: { - std::string* value = - extension.is_repeated - ? AddString(number, WireFormatLite::TYPE_STRING, - extension.descriptor) - : MutableString(number, WireFormatLite::TYPE_STRING, - extension.descriptor); - if (!WireFormatLite::ReadString(input, value)) return false; - break; - } - - case WireFormatLite::TYPE_BYTES: { - std::string* value = - extension.is_repeated - ? AddString(number, WireFormatLite::TYPE_BYTES, - extension.descriptor) - : MutableString(number, WireFormatLite::TYPE_BYTES, - extension.descriptor); - if (!WireFormatLite::ReadBytes(input, value)) return false; - break; - } - - case WireFormatLite::TYPE_GROUP: { - MessageLite* value = - extension.is_repeated - ? AddMessage(number, WireFormatLite::TYPE_GROUP, - *extension.message_info.prototype, - extension.descriptor) - : MutableMessage(number, WireFormatLite::TYPE_GROUP, - *extension.message_info.prototype, - extension.descriptor); - if (!WireFormatLite::ReadGroup(number, input, value)) return false; - break; - } - - case WireFormatLite::TYPE_MESSAGE: { - MessageLite* value = - extension.is_repeated - ? AddMessage(number, WireFormatLite::TYPE_MESSAGE, - *extension.message_info.prototype, - extension.descriptor) - : MutableMessage(number, WireFormatLite::TYPE_MESSAGE, - *extension.message_info.prototype, - extension.descriptor); - if (!WireFormatLite::ReadMessage(input, value)) return false; - break; - } - } - } - - return true; -} - -bool ExtensionSet::ParseField(uint32_t tag, io::CodedInputStream* input, - const MessageLite* extendee) { - FieldSkipper skipper; - GeneratedExtensionFinder finder(extendee); - return ParseField(tag, input, &finder, &skipper); -} - -bool ExtensionSet::ParseField(uint32_t tag, io::CodedInputStream* input, - const MessageLite* extendee, - io::CodedOutputStream* unknown_fields) { - CodedOutputStreamFieldSkipper skipper(unknown_fields); - GeneratedExtensionFinder finder(extendee); - return ParseField(tag, input, &finder, &skipper); -} - -bool ExtensionSet::ParseMessageSetLite(io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper) { - while (true) { - const uint32_t tag = input->ReadTag(); - switch (tag) { - case 0: - return true; - case WireFormatLite::kMessageSetItemStartTag: - if (!ParseMessageSetItemLite(input, extension_finder, field_skipper)) { - return false; - } - break; - default: - if (!ParseField(tag, input, extension_finder, field_skipper)) { - return false; - } - break; - } - } -} - -bool ExtensionSet::ParseMessageSetItemLite(io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper) { - struct MSLite { - bool ParseField(int type_id, io::CodedInputStream* input) { - return me->ParseField( - WireFormatLite::WIRETYPE_LENGTH_DELIMITED + 8 * type_id, input, - extension_finder, field_skipper); - } - - bool SkipField(uint32_t tag, io::CodedInputStream* input) { - return field_skipper->SkipField(input, tag); - } - - ExtensionSet* me; - ExtensionFinder* extension_finder; - FieldSkipper* field_skipper; - }; - - return ParseMessageSetItemImpl(input, - MSLite{this, extension_finder, field_skipper}); -} - -bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input, - const MessageLite* extendee, - std::string* unknown_fields) { - io::StringOutputStream zcis(unknown_fields); - io::CodedOutputStream output(&zcis); - CodedOutputStreamFieldSkipper skipper(&output); - GeneratedExtensionFinder finder(extendee); - return ParseMessageSetLite(input, &finder, &skipper); -} - uint8_t* ExtensionSet::_InternalSerializeImpl( const MessageLite* extendee, int start_field_number, int end_field_number, uint8_t* target, io::EpsCopyOutputStream* stream) const { @@ -2093,18 +1794,20 @@ uint8_t* ExtensionSet::Extension::InternalSerializeFieldWithCachedSizesToArray( HANDLE_TYPE(STRING, String, string); HANDLE_TYPE(BYTES, Bytes, string); #undef HANDLE_TYPE -#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: \ - for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \ - target = stream->EnsureSpace(target); \ - target = WireFormatLite::InternalWrite##CAMELCASE( \ - number, repeated_##LOWERCASE##_value->Get(i), target, stream); \ - } \ - break - - HANDLE_TYPE(GROUP, Group, message); - HANDLE_TYPE(MESSAGE, Message, message); -#undef HANDLE_TYPE + case WireFormatLite::TYPE_GROUP: + for (int i = 0; i < repeated_message_value->size(); i++) { + target = stream->EnsureSpace(target); + target = WireFormatLite::InternalWriteGroup( + number, repeated_message_value->Get(i), target, stream); + } + break; + case WireFormatLite::TYPE_MESSAGE: + for (int i = 0; i < repeated_message_value->size(); i++) { + auto& msg = repeated_message_value->Get(i); + target = WireFormatLite::InternalWriteMessage( + number, msg, msg.GetCachedSize(), target, stream); + } + break; } } } else if (!is_cleared) { @@ -2150,9 +1853,9 @@ uint8_t* ExtensionSet::Extension::InternalSerializeFieldWithCachedSizesToArray( target = lazymessage_value->WriteMessageToArray(prototype, number, target, stream); } else { - target = stream->EnsureSpace(target); - target = WireFormatLite::InternalWriteMessage(number, *message_value, - target, stream); + target = WireFormatLite::InternalWriteMessage( + number, *message_value, message_value->GetCachedSize(), target, + stream); } break; } @@ -2201,8 +1904,8 @@ ExtensionSet::Extension::InternalSerializeMessageSetItemWithCachedSizesToArray( prototype, WireFormatLite::kMessageSetMessageNumber, target, stream); } else { target = WireFormatLite::InternalWriteMessage( - WireFormatLite::kMessageSetMessageNumber, *message_value, target, - stream); + WireFormatLite::kMessageSetMessageNumber, *message_value, + message_value->GetCachedSize(), target, stream); } // End group. target = stream->EnsureSpace(target); @@ -2247,6 +1950,15 @@ size_t ExtensionSet::MessageSetByteSize() const { return total_size; } +LazyEagerVerifyFnType FindExtensionLazyEagerVerifyFn( + const MessageLite* extendee, int number) { + const ExtensionInfo* registered = FindRegisteredExtension(extendee, number); + if (registered != nullptr) { + return registered->lazy_eager_verify_func; + } + return nullptr; +} + } // namespace internal } // namespace protobuf diff --git a/r5dev/thirdparty/protobuf/extension_set.h b/r5dev/thirdparty/protobuf/extension_set.h index 25b2eeaa..824552f5 100644 --- a/r5dev/thirdparty/protobuf/extension_set.h +++ b/r5dev/thirdparty/protobuf/extension_set.h @@ -38,6 +38,7 @@ #ifndef GOOGLE_PROTOBUF_EXTENSION_SET_H__ #define GOOGLE_PROTOBUF_EXTENSION_SET_H__ + #include <algorithm> #include <cassert> #include <map> @@ -47,9 +48,9 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/port.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/repeated_field.h> #include <thirdparty/protobuf/wire_format_lite.h> @@ -74,6 +75,7 @@ class Reflection; // message.h class UnknownFieldSet; // unknown_field_set.h namespace internal { class FieldSkipper; // wire_format_lite.h +enum class LazyVerifyOption; } // namespace internal } // namespace protobuf } // namespace google @@ -103,13 +105,15 @@ typedef bool EnumValidityFuncWithArg(const void* arg, int number); struct ExtensionInfo { constexpr ExtensionInfo() : enum_validity_check() {} constexpr ExtensionInfo(const MessageLite* extendee, int param_number, - FieldType type_param, bool isrepeated, bool ispacked) + FieldType type_param, bool isrepeated, bool ispacked, + LazyEagerVerifyFnType verify_func) : message(extendee), number(param_number), type(type_param), is_repeated(isrepeated), is_packed(ispacked), - enum_validity_check() {} + enum_validity_check(), + lazy_eager_verify_func(verify_func) {} const MessageLite* message = nullptr; int number = 0; @@ -136,36 +140,32 @@ struct ExtensionInfo { // nullptr. Must not be nullptr if the descriptor for the extension does not // live in the same pool as the descriptor for the containing type. const FieldDescriptor* descriptor = nullptr; + + // If this field is potentially lazy this function can be used as a cheap + // verification of the raw bytes. + // If nullptr then no verification is performed. + LazyEagerVerifyFnType lazy_eager_verify_func = nullptr; }; -// Abstract interface for an object which looks up extension definitions. Used -// when parsing. -class PROTOBUF_EXPORT ExtensionFinder { - public: - virtual ~ExtensionFinder(); +// An ExtensionFinder is an object which looks up extension definitions. It +// must implement this method: +// +// bool Find(int number, ExtensionInfo* output); - // Find the extension with the given containing type and number. - virtual bool Find(int number, ExtensionInfo* output) = 0; -}; - -// Implementation of ExtensionFinder which finds extensions defined in .proto -// files which have been compiled into the binary. -class PROTOBUF_EXPORT GeneratedExtensionFinder : public ExtensionFinder { +// GeneratedExtensionFinder is an ExtensionFinder which finds extensions +// defined in .proto files which have been compiled into the binary. +class PROTOBUF_EXPORT GeneratedExtensionFinder { public: explicit GeneratedExtensionFinder(const MessageLite* extendee) : extendee_(extendee) {} - ~GeneratedExtensionFinder() override {} // Returns true and fills in *output if found, otherwise returns false. - bool Find(int number, ExtensionInfo* output) override; + bool Find(int number, ExtensionInfo* output); private: const MessageLite* extendee_; }; -// A FieldSkipper used for parsing MessageSet. -class MessageSetFieldSkipper; - // Note: extension_set_heavy.cc defines DescriptorPoolExtensionFinder for // finding extensions from a DescriptorPool. @@ -184,6 +184,7 @@ class PROTOBUF_EXPORT ExtensionSet { public: constexpr ExtensionSet(); explicit ExtensionSet(Arena* arena); + ExtensionSet(ArenaInitialized, Arena* arena) : ExtensionSet(arena) {} ~ExtensionSet(); // These are called at startup by protocol-compiler-generated code to @@ -193,14 +194,16 @@ class PROTOBUF_EXPORT ExtensionSet { // methods do. static void RegisterExtension(const MessageLite* extendee, int number, FieldType type, bool is_repeated, - bool is_packed); + bool is_packed, + LazyEagerVerifyFnType verify_func); static void RegisterEnumExtension(const MessageLite* extendee, int number, FieldType type, bool is_repeated, bool is_packed, EnumValidityFunc* is_valid); static void RegisterMessageExtension(const MessageLite* extendee, int number, FieldType type, bool is_repeated, bool is_packed, - const MessageLite* prototype); + const MessageLite* prototype, + LazyEagerVerifyFnType verify_func); // ================================================================= @@ -368,9 +371,6 @@ class PROTOBUF_EXPORT ExtensionSet { MessageLite* UnsafeArenaReleaseLast(int number); void SwapElements(int number, int index1, int index2); - // ----------------------------------------------------------------- - // TODO(kenton): Hardcore memory management accessors - // ================================================================= // convenience methods for implementing methods of Message // @@ -386,26 +386,6 @@ class PROTOBUF_EXPORT ExtensionSet { void UnsafeShallowSwapExtension(ExtensionSet* other, int number); bool IsInitialized() const; - // Parses a single extension from the input. The input should start out - // positioned immediately after the tag. - bool ParseField(uint32_t tag, io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper); - - // Specific versions for lite or full messages (constructs the appropriate - // FieldSkipper automatically). |extendee| is the default - // instance for the containing message; it is used only to look up the - // extension by number. See RegisterExtension(), above. Unlike the other - // methods of ExtensionSet, this only works for generated message types -- - // it looks up extensions registered using RegisterExtension(). - bool ParseField(uint32_t tag, io::CodedInputStream* input, - const MessageLite* extendee); - bool ParseField(uint32_t tag, io::CodedInputStream* input, - const Message* extendee, UnknownFieldSet* unknown_fields); - bool ParseField(uint32_t tag, io::CodedInputStream* input, - const MessageLite* extendee, - io::CodedOutputStream* unknown_fields); - // Lite parser const char* ParseField(uint64_t tag, const char* ptr, const MessageLite* extendee, @@ -446,22 +426,6 @@ class PROTOBUF_EXPORT ExtensionSet { return ptr; } - // Parse an entire message in MessageSet format. Such messages have no - // fields, only extensions. - bool ParseMessageSetLite(io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper); - bool ParseMessageSet(io::CodedInputStream* input, - ExtensionFinder* extension_finder, - MessageSetFieldSkipper* field_skipper); - - // Specific versions for lite or full messages (constructs the appropriate - // FieldSkipper automatically). - bool ParseMessageSet(io::CodedInputStream* input, const MessageLite* extendee, - std::string* unknown_fields); - bool ParseMessageSet(io::CodedInputStream* input, const Message* extendee, - UnknownFieldSet* unknown_fields); - // Write all extension fields with field numbers in the range // [start_field_number, end_field_number) // to the output stream, using the cached sizes computed when ByteSize() was @@ -601,10 +565,9 @@ class PROTOBUF_EXPORT ExtensionSet { virtual void MergeFromMessage(const MessageLite& msg, Arena* arena) = 0; virtual void Clear() = 0; - virtual bool ReadMessage(const MessageLite& prototype, - io::CodedInputStream* input) = 0; virtual const char* _InternalParse(const Message& prototype, Arena* arena, - const char* ptr, ParseContext* ctx) = 0; + LazyVerifyOption option, const char* ptr, + ParseContext* ctx) = 0; virtual uint8_t* WriteMessageToArray( const MessageLite* prototype, int number, uint8_t* target, io::EpsCopyOutputStream* stream) const = 0; @@ -777,44 +740,77 @@ class PROTOBUF_EXPORT ExtensionSet { const Extension& other_extension, Arena* other_arena); + inline static bool is_packable(WireFormatLite::WireType type) { + switch (type) { + case WireFormatLite::WIRETYPE_VARINT: + case WireFormatLite::WIRETYPE_FIXED64: + case WireFormatLite::WIRETYPE_FIXED32: + return true; + case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: + case WireFormatLite::WIRETYPE_START_GROUP: + case WireFormatLite::WIRETYPE_END_GROUP: + return false; + + // Do not add a default statement. Let the compiler complain when + // someone + // adds a new wire type. + } + PROTOBUF_ASSUME(false); // switch handles all possible enum values + return false; + } + // Returns true and fills field_number and extension if extension is found. // Note to support packed repeated field compatibility, it also fills whether // the tag on wire is packed, which can be different from // extension->is_packed (whether packed=true is specified). + template <typename ExtensionFinder> bool FindExtensionInfoFromTag(uint32_t tag, ExtensionFinder* extension_finder, int* field_number, ExtensionInfo* extension, - bool* was_packed_on_wire); + bool* was_packed_on_wire) { + *field_number = WireFormatLite::GetTagFieldNumber(tag); + WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag); + return FindExtensionInfoFromFieldNumber(wire_type, *field_number, + extension_finder, extension, + was_packed_on_wire); + } // Returns true and fills extension if extension is found. // Note to support packed repeated field compatibility, it also fills whether // the tag on wire is packed, which can be different from // extension->is_packed (whether packed=true is specified). + template <typename ExtensionFinder> bool FindExtensionInfoFromFieldNumber(int wire_type, int field_number, ExtensionFinder* extension_finder, ExtensionInfo* extension, - bool* was_packed_on_wire) const; + bool* was_packed_on_wire) const { + if (!extension_finder->Find(field_number, extension)) { + return false; + } + + GOOGLE_DCHECK(extension->type > 0 && + extension->type <= WireFormatLite::MAX_FIELD_TYPE); + auto real_type = static_cast<WireFormatLite::FieldType>(extension->type); + + WireFormatLite::WireType expected_wire_type = + WireFormatLite::WireTypeForFieldType(real_type); + + // Check if this is a packed field. + *was_packed_on_wire = false; + if (extension->is_repeated && + wire_type == WireFormatLite::WIRETYPE_LENGTH_DELIMITED && + is_packable(expected_wire_type)) { + *was_packed_on_wire = true; + return true; + } + // Otherwise the wire type must match. + return expected_wire_type == wire_type; + } // Find the prototype for a LazyMessage from the extension registry. Returns // null if the extension is not found. const MessageLite* GetPrototypeForLazyMessage(const MessageLite* extendee, int number) const; - // Parses a single extension from the input. The input should start out - // positioned immediately after the wire tag. This method is called in - // ParseField() after field number and was_packed_on_wire is extracted from - // the wire tag and ExtensionInfo is found by the field number. - bool ParseFieldWithExtensionInfo(int field_number, bool was_packed_on_wire, - const ExtensionInfo& extension, - io::CodedInputStream* input, - FieldSkipper* field_skipper); - - // Like ParseField(), but this method may parse singular message extensions - // lazily depending on the value of FLAGS_eagerly_parse_message_sets. - bool ParseFieldMaybeLazily(int wire_type, int field_number, - io::CodedInputStream* input, - ExtensionFinder* extension_finder, - MessageSetFieldSkipper* field_skipper); - // Returns true if extension is present and lazy. bool HasLazy(int number) const; @@ -827,17 +823,6 @@ class PROTOBUF_EXPORT ExtensionSet { // it does not exist. Extension* MaybeNewRepeatedExtension(const FieldDescriptor* descriptor); - // Parse a single MessageSet item -- called just after the item group start - // tag has been read. - bool ParseMessageSetItemLite(io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper); - // Parse a single MessageSet item -- called just after the item group start - // tag has been read. - bool ParseMessageSetItem(io::CodedInputStream* input, - ExtensionFinder* extension_finder, - MessageSetFieldSkipper* field_skipper); - bool FindExtension(int wire_type, uint32_t field, const MessageLite* extendee, const internal::ParseContext* /*ctx*/, ExtensionInfo* extension, bool* was_packed_on_wire) { @@ -1023,9 +1008,10 @@ class PrimitiveTypeTraits { static inline void Set(int number, FieldType field_type, ConstType value, ExtensionSet* set); template <typename ExtendeeT> - static void Register(int number, FieldType type, bool is_packed) { + static void Register(int number, FieldType type, bool is_packed, + LazyEagerVerifyFnType verify_func) { ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number, - type, false, is_packed); + type, false, is_packed, verify_func); } }; @@ -1056,9 +1042,10 @@ class RepeatedPrimitiveTypeTraits { static const RepeatedFieldType* GetDefaultRepeatedField(); template <typename ExtendeeT> - static void Register(int number, FieldType type, bool is_packed) { + static void Register(int number, FieldType type, bool is_packed, + LazyEagerVerifyFnType verify_func) { ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number, - type, true, is_packed); + type, true, is_packed, verify_func); } }; @@ -1178,9 +1165,10 @@ class PROTOBUF_EXPORT StringTypeTraits { return set->MutableString(number, field_type, nullptr); } template <typename ExtendeeT> - static void Register(int number, FieldType type, bool is_packed) { + static void Register(int number, FieldType type, bool is_packed, + LazyEagerVerifyFnType verify_func) { ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number, - type, false, is_packed); + type, false, is_packed, verify_func); } }; @@ -1234,9 +1222,10 @@ class PROTOBUF_EXPORT RepeatedStringTypeTraits { static const RepeatedFieldType* GetDefaultRepeatedField(); template <typename ExtendeeT> - static void Register(int number, FieldType type, bool is_packed) { + static void Register(int number, FieldType type, bool is_packed, + LazyEagerVerifyFnType fn) { ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number, - type, true, is_packed); + type, true, is_packed, fn); } private: @@ -1271,7 +1260,8 @@ class EnumTypeTraits { set->SetEnum(number, field_type, value, nullptr); } template <typename ExtendeeT> - static void Register(int number, FieldType type, bool is_packed) { + static void Register(int number, FieldType type, bool is_packed, + LazyEagerVerifyFnType fn) { ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number, type, false, is_packed, IsValid); } @@ -1336,7 +1326,8 @@ class RepeatedEnumTypeTraits { RepeatedPrimitiveTypeTraits<int32_t>::GetDefaultRepeatedField()); } template <typename ExtendeeT> - static void Register(int number, FieldType type, bool is_packed) { + static void Register(int number, FieldType type, bool is_packed, + LazyEagerVerifyFnType fn) { ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number, type, true, is_packed, IsValid); } @@ -1359,7 +1350,8 @@ class MessageTypeTraits { ConstType default_value) { return static_cast<const Type&>(set.GetMessage(number, default_value)); } - static inline std::nullptr_t GetPtr(int /* number */, const ExtensionSet& /* set */, + static inline std::nullptr_t GetPtr(int /* number */, + const ExtensionSet& /* set */, ConstType /* default_value */) { // Cannot be implemented because of forward declared messages? return nullptr; @@ -1390,13 +1382,18 @@ class MessageTypeTraits { set->UnsafeArenaReleaseMessage(number, Type::default_instance())); } template <typename ExtendeeT> - static void Register(int number, FieldType type, bool is_packed) { + static void Register(int number, FieldType type, bool is_packed, + LazyEagerVerifyFnType fn) { ExtensionSet::RegisterMessageExtension(&ExtendeeT::default_instance(), number, type, false, is_packed, - &Type::default_instance()); + &Type::default_instance(), fn); } }; +// Used by WireFormatVerify to extract the verify function from the registry. +LazyEagerVerifyFnType FindExtensionLazyEagerVerifyFn( + const MessageLite* extendee, int number); + // forward declaration. class RepeatedMessageGenericTypeTraits; @@ -1412,7 +1409,8 @@ class RepeatedMessageTypeTraits { static inline ConstType Get(int number, const ExtensionSet& set, int index) { return static_cast<const Type&>(set.GetRepeatedMessage(number, index)); } - static inline std::nullptr_t GetPtr(int /* number */, const ExtensionSet& /* set */, + static inline std::nullptr_t GetPtr(int /* number */, + const ExtensionSet& /* set */, int /* index */) { // Cannot be implemented because of forward declared messages? return nullptr; @@ -1450,10 +1448,11 @@ class RepeatedMessageTypeTraits { static const RepeatedFieldType* GetDefaultRepeatedField(); template <typename ExtendeeT> - static void Register(int number, FieldType type, bool is_packed) { + static void Register(int number, FieldType type, bool is_packed, + LazyEagerVerifyFnType fn) { ExtensionSet::RegisterMessageExtension(&ExtendeeT::default_instance(), number, type, true, is_packed, - &Type::default_instance()); + &Type::default_instance(), fn); } }; @@ -1490,17 +1489,19 @@ class ExtensionIdentifier { typedef TypeTraitsType TypeTraits; typedef ExtendeeType Extendee; - ExtensionIdentifier(int number, typename TypeTraits::ConstType default_value) + ExtensionIdentifier(int number, typename TypeTraits::ConstType default_value, + LazyEagerVerifyFnType verify_func = nullptr) : number_(number), default_value_(default_value) { - Register(number); + Register(number, verify_func); } inline int number() const { return number_; } typename TypeTraits::ConstType default_value() const { return default_value_; } - static void Register(int number) { - TypeTraits::template Register<ExtendeeType>(number, field_type, is_packed); + static void Register(int number, LazyEagerVerifyFnType verify_func) { + TypeTraits::template Register<ExtendeeType>(number, field_type, is_packed, + verify_func); } typename TypeTraits::ConstType const& default_value_ref() const { diff --git a/r5dev/thirdparty/protobuf/extension_set_heavy.cc b/r5dev/thirdparty/protobuf/extension_set_heavy.cc index 63d2e312..7297ca59 100644 --- a/r5dev/thirdparty/protobuf/extension_set_heavy.cc +++ b/r5dev/thirdparty/protobuf/extension_set_heavy.cc @@ -36,62 +36,39 @@ // lite library because they use descriptors or reflection. #include <thirdparty/protobuf/stubs/casts.h> -#include <thirdparty/protobuf/descriptor.pb.h> -#include <thirdparty/protobuf/extension_set_inl.h> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/extension_set.h> +#include <thirdparty/protobuf/extension_set_inl.h> #include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/message_lite.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/repeated_field.h> #include <thirdparty/protobuf/unknown_field_set.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/wire_format_lite.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { namespace internal { -// A FieldSkipper used to store unknown MessageSet fields into UnknownFieldSet. -class MessageSetFieldSkipper : public UnknownFieldSetFieldSkipper { - public: - explicit MessageSetFieldSkipper(UnknownFieldSet* unknown_fields) - : UnknownFieldSetFieldSkipper(unknown_fields) {} - ~MessageSetFieldSkipper() override {} - - virtual bool SkipMessageSetField(io::CodedInputStream* input, - int field_number); -}; -bool MessageSetFieldSkipper::SkipMessageSetField(io::CodedInputStream* input, - int field_number) { - uint32_t length; - if (!input->ReadVarint32(&length)) return false; - if (unknown_fields_ == nullptr) { - return input->Skip(length); - } else { - return input->ReadString(unknown_fields_->AddLengthDelimited(field_number), - length); - } -} - - // Implementation of ExtensionFinder which finds extensions in a given // DescriptorPool, using the given MessageFactory to construct sub-objects. // This class is implemented in extension_set_heavy.cc. -class DescriptorPoolExtensionFinder : public ExtensionFinder { +class DescriptorPoolExtensionFinder { public: DescriptorPoolExtensionFinder(const DescriptorPool* pool, MessageFactory* factory, const Descriptor* containing_type) : pool_(pool), factory_(factory), containing_type_(containing_type) {} - ~DescriptorPoolExtensionFinder() override {} - bool Find(int number, ExtensionInfo* output) override; + bool Find(int number, ExtensionInfo* output); private: const DescriptorPool* pool_; @@ -376,42 +353,13 @@ const char* ExtensionSet::ParseMessageSetItem( metadata, ctx); } -bool ExtensionSet::ParseField(uint32_t tag, io::CodedInputStream* input, - const Message* containing_type, - UnknownFieldSet* unknown_fields) { - UnknownFieldSetFieldSkipper skipper(unknown_fields); - if (input->GetExtensionPool() == nullptr) { - GeneratedExtensionFinder finder(containing_type); - return ParseField(tag, input, &finder, &skipper); - } else { - DescriptorPoolExtensionFinder finder(input->GetExtensionPool(), - input->GetExtensionFactory(), - containing_type->GetDescriptor()); - return ParseField(tag, input, &finder, &skipper); - } -} - -bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input, - const Message* containing_type, - UnknownFieldSet* unknown_fields) { - MessageSetFieldSkipper skipper(unknown_fields); - if (input->GetExtensionPool() == nullptr) { - GeneratedExtensionFinder finder(containing_type); - return ParseMessageSet(input, &finder, &skipper); - } else { - DescriptorPoolExtensionFinder finder(input->GetExtensionPool(), - input->GetExtensionFactory(), - containing_type->GetDescriptor()); - return ParseMessageSet(input, &finder, &skipper); - } -} - int ExtensionSet::SpaceUsedExcludingSelf() const { return internal::FromIntSize(SpaceUsedExcludingSelfLong()); } size_t ExtensionSet::SpaceUsedExcludingSelfLong() const { - size_t total_size = Size() * sizeof(KeyValue); + size_t total_size = + (is_large() ? map_.large->size() : flat_capacity_) * sizeof(KeyValue); ForEach([&total_size](int /* number */, const Extension& ext) { total_size += ext.SpaceUsedExcludingSelfLong(); }); @@ -485,60 +433,6 @@ uint8_t* ExtensionSet::SerializeMessageSetWithCachedSizesToArray( &stream); } -bool ExtensionSet::ParseFieldMaybeLazily( - int wire_type, int field_number, io::CodedInputStream* input, - ExtensionFinder* extension_finder, MessageSetFieldSkipper* field_skipper) { - return ParseField( - WireFormatLite::MakeTag(field_number, - static_cast<WireFormatLite::WireType>(wire_type)), - input, extension_finder, field_skipper); -} - -bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input, - ExtensionFinder* extension_finder, - MessageSetFieldSkipper* field_skipper) { - while (true) { - const uint32_t tag = input->ReadTag(); - switch (tag) { - case 0: - return true; - case WireFormatLite::kMessageSetItemStartTag: - if (!ParseMessageSetItem(input, extension_finder, field_skipper)) { - return false; - } - break; - default: - if (!ParseField(tag, input, extension_finder, field_skipper)) { - return false; - } - break; - } - } -} - -bool ExtensionSet::ParseMessageSetItem(io::CodedInputStream* input, - ExtensionFinder* extension_finder, - MessageSetFieldSkipper* field_skipper) { - struct MSFull { - bool ParseField(int type_id, io::CodedInputStream* input) { - return me->ParseFieldMaybeLazily( - WireFormatLite::WIRETYPE_LENGTH_DELIMITED, type_id, input, - extension_finder, field_skipper); - } - - bool SkipField(uint32_t tag, io::CodedInputStream* input) { - return field_skipper->SkipField(input, tag); - } - - ExtensionSet* me; - ExtensionFinder* extension_finder; - MessageSetFieldSkipper* field_skipper; - }; - - return ParseMessageSetItemImpl(input, - MSFull{this, extension_finder, field_skipper}); -} - } // namespace internal } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/extension_set_inl.h b/r5dev/thirdparty/protobuf/extension_set_inl.h index 07cfb6d1..26d6b13b 100644 --- a/r5dev/thirdparty/protobuf/extension_set_inl.h +++ b/r5dev/thirdparty/protobuf/extension_set_inl.h @@ -31,9 +31,9 @@ #ifndef GOOGLE_PROTOBUF_EXTENSION_SET_INL_H__ #define GOOGLE_PROTOBUF_EXTENSION_SET_INL_H__ -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/extension_set.h> #include <thirdparty/protobuf/metadata_lite.h> +#include <thirdparty/protobuf/parse_context.h> namespace google { namespace protobuf { @@ -206,16 +206,21 @@ const char* ExtensionSet::ParseMessageSetItemTmpl( const char* ptr, const Msg* extendee, internal::InternalMetadata* metadata, internal::ParseContext* ctx) { std::string payload; - uint32_t type_id = 0; - bool payload_read = false; + uint32_t type_id; + enum class State { kNoTag, kHasType, kHasPayload, kDone }; + State state = State::kNoTag; + while (!ctx->Done(&ptr)) { uint32_t tag = static_cast<uint8_t>(*ptr++); if (tag == WireFormatLite::kMessageSetTypeIdTag) { uint64_t tmp; ptr = ParseBigVarint(ptr, &tmp); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - type_id = tmp; - if (payload_read) { + if (state == State::kNoTag) { + type_id = tmp; + state = State::kHasType; + } else if (state == State::kHasPayload) { + type_id = tmp; ExtensionInfo extension; bool was_packed_on_wire; if (!FindExtension(2, type_id, extendee, ctx, &extension, @@ -241,20 +246,24 @@ const char* ExtensionSet::ParseMessageSetItemTmpl( GOOGLE_PROTOBUF_PARSER_ASSERT(value->_InternalParse(p, &tmp_ctx) && tmp_ctx.EndedAtLimit()); } - type_id = 0; + state = State::kDone; } } else if (tag == WireFormatLite::kMessageSetMessageTag) { - if (type_id != 0) { + if (state == State::kHasType) { ptr = ParseFieldMaybeLazily(static_cast<uint64_t>(type_id) * 8 + 2, ptr, extendee, metadata, ctx); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr); - type_id = 0; + state = State::kDone; } else { + std::string tmp; int32_t size = ReadSize(&ptr); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - ptr = ctx->ReadString(ptr, size, &payload); + ptr = ctx->ReadString(ptr, size, &tmp); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - payload_read = true; + if (state == State::kNoTag) { + payload = std::move(tmp); + state = State::kHasPayload; + } } } else { ptr = ReadTag(ptr - 1, &tag); diff --git a/r5dev/thirdparty/protobuf/extension_set_unittest.cc b/r5dev/thirdparty/protobuf/extension_set_unittest.cc index ef9bf672..55072490 100644 --- a/r5dev/thirdparty/protobuf/extension_set_unittest.cc +++ b/r5dev/thirdparty/protobuf/extension_set_unittest.cc @@ -36,8 +36,6 @@ #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/test_util.h> -#include <thirdparty/protobuf/test_util2.h> #include <thirdparty/protobuf/unittest.pb.h> #include <thirdparty/protobuf/unittest_mset.pb.h> #include <thirdparty/protobuf/io/coded_stream.h> @@ -47,9 +45,12 @@ #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/dynamic_message.h> #include <thirdparty/protobuf/extension_set.h> +#include <thirdparty/protobuf/text_format.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> +#include <thirdparty/protobuf/test_util.h> +#include <thirdparty/protobuf/test_util2.h> #include <thirdparty/protobuf/stubs/stl_util.h> // Must be included last. @@ -63,7 +64,7 @@ namespace { using TestUtil::EqualsToSerialized; -// This test closely mirrors net/proto2/compiler/cpp/internal/unittest.cc +// This test closely mirrors third_party/protobuf/compiler/cpp/unittest.cc // except that it uses extensions rather than regular fields. TEST(ExtensionSetTest, Defaults) { @@ -107,20 +108,6 @@ TEST(ExtensionSetTest, Clear) { message.Clear(); TestUtil::ExpectExtensionsClear(message); - // Unlike with the defaults test, we do NOT expect that requesting embedded - // messages will return a pointer to the default instance. Instead, they - // should return the objects that were created when mutable_blah() was - // called. - EXPECT_NE(&unittest::OptionalGroup_extension::default_instance(), - &message.GetExtension(unittest::optionalgroup_extension)); - EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(), - &message.GetExtension(unittest::optional_nested_message_extension)); - EXPECT_NE( - &unittest::ForeignMessage::default_instance(), - &message.GetExtension(unittest::optional_foreign_message_extension)); - EXPECT_NE(&unittest_import::ImportMessage::default_instance(), - &message.GetExtension(unittest::optional_import_message_extension)); - // Make sure setting stuff again after clearing works. (This takes slightly // different code paths since the objects are reused.) TestUtil::SetAllExtensions(&message); @@ -133,7 +120,7 @@ TEST(ExtensionSetTest, ClearOneField) { unittest::TestAllExtensions message; TestUtil::SetAllExtensions(&message); - int64 original_value = + int64_t original_value = message.GetExtension(unittest::optional_int64_extension); // Clear the field and make sure it shows up as cleared. @@ -414,6 +401,46 @@ TEST(ExtensionSetTest, ArenaMergeFrom) { TestUtil::ExpectAllExtensionsSet(message2); } +TEST(ExtensionSetTest, ArenaMergeFromWithClearedExtensions) { + Arena arena; + { + auto* message1 = Arena::CreateMessage<unittest::TestAllExtensions>(&arena); + auto* message2 = Arena::CreateMessage<unittest::TestAllExtensions>(&arena); + + // Set an extension and then clear it + message1->SetExtension(unittest::optional_int32_extension, 1); + message1->ClearExtension(unittest::optional_int32_extension); + + // Since all extensions in message1 have been cleared, we should be able to + // merge it into message2 without allocating any additional memory. + uint64_t space_used_before_merge = arena.SpaceUsed(); + message2->MergeFrom(*message1); + EXPECT_EQ(space_used_before_merge, arena.SpaceUsed()); + } + { + // As more complicated case, let's have message1 and message2 share some + // uncleared extensions in common. + auto* message1 = Arena::CreateMessage<unittest::TestAllExtensions>(&arena); + auto* message2 = Arena::CreateMessage<unittest::TestAllExtensions>(&arena); + + // Set int32 and uint32 on both messages. + message1->SetExtension(unittest::optional_int32_extension, 1); + message2->SetExtension(unittest::optional_int32_extension, 2); + message1->SetExtension(unittest::optional_uint32_extension, 1); + message2->SetExtension(unittest::optional_uint32_extension, 2); + + // Set and clear int64 and uint64 on message1. + message1->SetExtension(unittest::optional_int64_extension, 0); + message1->ClearExtension(unittest::optional_int64_extension); + message1->SetExtension(unittest::optional_uint64_extension, 0); + message1->ClearExtension(unittest::optional_uint64_extension); + + uint64_t space_used_before_merge = arena.SpaceUsed(); + message2->MergeFrom(*message1); + EXPECT_EQ(space_used_before_merge, arena.SpaceUsed()); + } +} + TEST(ExtensionSetTest, ArenaSetAllocatedMessageAndRelease) { Arena arena; unittest::TestAllExtensions* message = @@ -520,8 +547,8 @@ TEST(ExtensionSetTest, SerializationToArray) { size_t size = source.ByteSizeLong(); std::string data; data.resize(size); - uint8* target = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&data)); - uint8* end = source.SerializeWithCachedSizesToArray(target); + uint8_t* target = reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&data)); + uint8_t* end = source.SerializeWithCachedSizesToArray(target); EXPECT_EQ(size, end - target); EXPECT_TRUE(destination.ParseFromString(data)); TestUtil::ExpectAllFieldsSet(destination); @@ -564,8 +591,8 @@ TEST(ExtensionSetTest, PackedSerializationToArray) { size_t size = source.ByteSizeLong(); std::string data; data.resize(size); - uint8* target = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&data)); - uint8* end = source.SerializeWithCachedSizesToArray(target); + uint8_t* target = reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&data)); + uint8_t* end = source.SerializeWithCachedSizesToArray(target); EXPECT_EQ(size, end - target); EXPECT_TRUE(destination.ParseFromString(data)); TestUtil::ExpectPackedFieldsSet(destination); @@ -800,7 +827,8 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) { // Repeated primitive extensions will increase space used by at least a // RepeatedField<T>, and will cause additional allocations when the array - // gets too big for the initial space. + // gets too big for the initial space. Note, we explicitly allocate on the + // heap to avoid message-owned arenas. // This macro: // - Adds a value to the repeated extension, then clears it, establishing // the base size. @@ -808,46 +836,47 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) { // SpaceUsedLong() // - Adds a large number of values (requiring allocation in the repeated // field), and ensures that that allocation is included in SpaceUsedLong() -#define TEST_REPEATED_EXTENSIONS_SPACE_USED(type, cpptype, value) \ - do { \ - unittest::TestAllExtensions message; \ - const size_t base_size = message.SpaceUsedLong(); \ - size_t min_expected_size = sizeof(RepeatedField<cpptype>) + base_size; \ - message.AddExtension(unittest::repeated_##type##_extension, value); \ - message.ClearExtension(unittest::repeated_##type##_extension); \ - const size_t empty_repeated_field_size = message.SpaceUsedLong(); \ - EXPECT_LE(min_expected_size, empty_repeated_field_size) << #type; \ - message.AddExtension(unittest::repeated_##type##_extension, value); \ - message.AddExtension(unittest::repeated_##type##_extension, value); \ - EXPECT_EQ(empty_repeated_field_size, message.SpaceUsedLong()) << #type; \ - message.ClearExtension(unittest::repeated_##type##_extension); \ - const size_t old_capacity = \ - message.GetRepeatedExtension(unittest::repeated_##type##_extension) \ - .Capacity(); \ - EXPECT_GE(old_capacity, kRepeatedFieldLowerClampLimit); \ - for (int i = 0; i < 16; ++i) { \ - message.AddExtension(unittest::repeated_##type##_extension, value); \ - } \ - int expected_size = \ - sizeof(cpptype) * \ - (message \ - .GetRepeatedExtension(unittest::repeated_##type##_extension) \ - .Capacity() - \ - old_capacity) + \ - empty_repeated_field_size; \ - EXPECT_LE(expected_size, message.SpaceUsedLong()) << #type; \ +#define TEST_REPEATED_EXTENSIONS_SPACE_USED(type, cpptype, value) \ + do { \ + std::unique_ptr<unittest::TestAllExtensions> message( \ + Arena::CreateMessage<unittest::TestAllExtensions>(nullptr)); \ + const size_t base_size = message->SpaceUsedLong(); \ + size_t min_expected_size = sizeof(RepeatedField<cpptype>) + base_size; \ + message->AddExtension(unittest::repeated_##type##_extension, value); \ + message->ClearExtension(unittest::repeated_##type##_extension); \ + const size_t empty_repeated_field_size = message->SpaceUsedLong(); \ + EXPECT_LE(min_expected_size, empty_repeated_field_size) << #type; \ + message->AddExtension(unittest::repeated_##type##_extension, value); \ + EXPECT_EQ(empty_repeated_field_size, message->SpaceUsedLong()) << #type; \ + message->ClearExtension(unittest::repeated_##type##_extension); \ + const size_t old_capacity = \ + message->GetRepeatedExtension(unittest::repeated_##type##_extension) \ + .Capacity(); \ + EXPECT_GE(old_capacity, \ + (RepeatedFieldLowerClampLimit<cpptype, sizeof(void*)>())); \ + for (int i = 0; i < 16; ++i) { \ + message->AddExtension(unittest::repeated_##type##_extension, value); \ + } \ + int expected_size = \ + sizeof(cpptype) * \ + (message \ + ->GetRepeatedExtension(unittest::repeated_##type##_extension) \ + .Capacity() - \ + old_capacity) + \ + empty_repeated_field_size; \ + EXPECT_LE(expected_size, message->SpaceUsedLong()) << #type; \ } while (0) - TEST_REPEATED_EXTENSIONS_SPACE_USED(int32, int32, 101); - TEST_REPEATED_EXTENSIONS_SPACE_USED(int64, int64, 102); - TEST_REPEATED_EXTENSIONS_SPACE_USED(uint32, uint32, 103); - TEST_REPEATED_EXTENSIONS_SPACE_USED(uint64, uint64, 104); - TEST_REPEATED_EXTENSIONS_SPACE_USED(sint32, int32, 105); - TEST_REPEATED_EXTENSIONS_SPACE_USED(sint64, int64, 106); - TEST_REPEATED_EXTENSIONS_SPACE_USED(fixed32, uint32, 107); - TEST_REPEATED_EXTENSIONS_SPACE_USED(fixed64, uint64, 108); - TEST_REPEATED_EXTENSIONS_SPACE_USED(sfixed32, int32, 109); - TEST_REPEATED_EXTENSIONS_SPACE_USED(sfixed64, int64, 110); + TEST_REPEATED_EXTENSIONS_SPACE_USED(int32, int32_t, 101); + TEST_REPEATED_EXTENSIONS_SPACE_USED(int64, int64_t, 102); + TEST_REPEATED_EXTENSIONS_SPACE_USED(uint32, uint32_t, 103); + TEST_REPEATED_EXTENSIONS_SPACE_USED(uint64, uint64_t, 104); + TEST_REPEATED_EXTENSIONS_SPACE_USED(sint32, int32_t, 105); + TEST_REPEATED_EXTENSIONS_SPACE_USED(sint64, int64_t, 106); + TEST_REPEATED_EXTENSIONS_SPACE_USED(fixed32, uint32_t, 107); + TEST_REPEATED_EXTENSIONS_SPACE_USED(fixed64, uint64_t, 108); + TEST_REPEATED_EXTENSIONS_SPACE_USED(sfixed32, int32_t, 109); + TEST_REPEATED_EXTENSIONS_SPACE_USED(sfixed64, int64_t, 110); TEST_REPEATED_EXTENSIONS_SPACE_USED(float, float, 111); TEST_REPEATED_EXTENSIONS_SPACE_USED(double, double, 112); TEST_REPEATED_EXTENSIONS_SPACE_USED(bool, bool, true); @@ -856,8 +885,9 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) { #undef TEST_REPEATED_EXTENSIONS_SPACE_USED // Repeated strings { - unittest::TestAllExtensions message; - const size_t base_size = message.SpaceUsedLong(); + std::unique_ptr<unittest::TestAllExtensions> message( + Arena::CreateMessage<unittest::TestAllExtensions>(nullptr)); + const size_t base_size = message->SpaceUsedLong(); size_t min_expected_size = sizeof(RepeatedPtrField<std::string>) + base_size; const std::string value(256, 'x'); @@ -865,27 +895,30 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) { // without the hardcore memory management accessors there isn't a notion of // the empty repeated field memory usage as there is with primitive types. for (int i = 0; i < 16; ++i) { - message.AddExtension(unittest::repeated_string_extension, value); + message->AddExtension(unittest::repeated_string_extension, value); } min_expected_size += - (sizeof(value) + value.size()) * (16 - kRepeatedFieldLowerClampLimit); - EXPECT_LE(min_expected_size, message.SpaceUsedLong()); + (sizeof(value) + value.size()) * + (16 - RepeatedFieldLowerClampLimit<void*, sizeof(void*)>()); + EXPECT_LE(min_expected_size, message->SpaceUsedLong()); } // Repeated messages { - unittest::TestAllExtensions message; - const size_t base_size = message.SpaceUsedLong(); + std::unique_ptr<unittest::TestAllExtensions> message( + Arena::CreateMessage<unittest::TestAllExtensions>(nullptr)); + const size_t base_size = message->SpaceUsedLong(); size_t min_expected_size = sizeof(RepeatedPtrField<unittest::ForeignMessage>) + base_size; unittest::ForeignMessage prototype; prototype.set_c(2); for (int i = 0; i < 16; ++i) { - message.AddExtension(unittest::repeated_foreign_message_extension) - ->CopyFrom(prototype); + *message->AddExtension(unittest::repeated_foreign_message_extension) = + prototype; } min_expected_size += - (16 - kRepeatedFieldLowerClampLimit) * prototype.SpaceUsedLong(); - EXPECT_LE(min_expected_size, message.SpaceUsedLong()); + (16 - RepeatedFieldLowerClampLimit<void*, sizeof(void*)>()) * + prototype.SpaceUsedLong(); + EXPECT_LE(min_expected_size, message->SpaceUsedLong()); } } @@ -961,52 +994,52 @@ TEST(ExtensionSetTest, RepeatedFields) { message.AddExtension(unittest::repeated_nested_enum_extension, nested_enum); } - ASSERT_EQ(10, SumAllExtensions<int32>(message, - unittest::repeated_int32_extension, 0)); - IncAllExtensions<int32>(&message, unittest::repeated_int32_extension, 1); - ASSERT_EQ(20, SumAllExtensions<int32>(message, - unittest::repeated_int32_extension, 0)); + ASSERT_EQ(10, SumAllExtensions<int32_t>( + message, unittest::repeated_int32_extension, 0)); + IncAllExtensions<int32_t>(&message, unittest::repeated_int32_extension, 1); + ASSERT_EQ(20, SumAllExtensions<int32_t>( + message, unittest::repeated_int32_extension, 0)); - ASSERT_EQ(20, SumAllExtensions<int64>(message, - unittest::repeated_int64_extension, 0)); - IncAllExtensions<int64>(&message, unittest::repeated_int64_extension, 1); - ASSERT_EQ(30, SumAllExtensions<int64>(message, - unittest::repeated_int64_extension, 0)); + ASSERT_EQ(20, SumAllExtensions<int64_t>( + message, unittest::repeated_int64_extension, 0)); + IncAllExtensions<int64_t>(&message, unittest::repeated_int64_extension, 1); + ASSERT_EQ(30, SumAllExtensions<int64_t>( + message, unittest::repeated_int64_extension, 0)); - ASSERT_EQ(30, SumAllExtensions<uint32>( + ASSERT_EQ(30, SumAllExtensions<uint32_t>( message, unittest::repeated_uint32_extension, 0)); - IncAllExtensions<uint32>(&message, unittest::repeated_uint32_extension, 1); - ASSERT_EQ(40, SumAllExtensions<uint32>( + IncAllExtensions<uint32_t>(&message, unittest::repeated_uint32_extension, 1); + ASSERT_EQ(40, SumAllExtensions<uint32_t>( message, unittest::repeated_uint32_extension, 0)); - ASSERT_EQ(40, SumAllExtensions<uint64>( + ASSERT_EQ(40, SumAllExtensions<uint64_t>( message, unittest::repeated_uint64_extension, 0)); - IncAllExtensions<uint64>(&message, unittest::repeated_uint64_extension, 1); - ASSERT_EQ(50, SumAllExtensions<uint64>( + IncAllExtensions<uint64_t>(&message, unittest::repeated_uint64_extension, 1); + ASSERT_EQ(50, SumAllExtensions<uint64_t>( message, unittest::repeated_uint64_extension, 0)); - ASSERT_EQ(50, SumAllExtensions<int32>( + ASSERT_EQ(50, SumAllExtensions<int32_t>( message, unittest::repeated_sint32_extension, 0)); - IncAllExtensions<int32>(&message, unittest::repeated_sint32_extension, 1); - ASSERT_EQ(60, SumAllExtensions<int32>( + IncAllExtensions<int32_t>(&message, unittest::repeated_sint32_extension, 1); + ASSERT_EQ(60, SumAllExtensions<int32_t>( message, unittest::repeated_sint32_extension, 0)); - ASSERT_EQ(60, SumAllExtensions<int64>( + ASSERT_EQ(60, SumAllExtensions<int64_t>( message, unittest::repeated_sint64_extension, 0)); - IncAllExtensions<int64>(&message, unittest::repeated_sint64_extension, 1); - ASSERT_EQ(70, SumAllExtensions<int64>( + IncAllExtensions<int64_t>(&message, unittest::repeated_sint64_extension, 1); + ASSERT_EQ(70, SumAllExtensions<int64_t>( message, unittest::repeated_sint64_extension, 0)); - ASSERT_EQ(70, SumAllExtensions<uint32>( + ASSERT_EQ(70, SumAllExtensions<uint32_t>( message, unittest::repeated_fixed32_extension, 0)); - IncAllExtensions<uint32>(&message, unittest::repeated_fixed32_extension, 1); - ASSERT_EQ(80, SumAllExtensions<uint32>( + IncAllExtensions<uint32_t>(&message, unittest::repeated_fixed32_extension, 1); + ASSERT_EQ(80, SumAllExtensions<uint32_t>( message, unittest::repeated_fixed32_extension, 0)); - ASSERT_EQ(80, SumAllExtensions<uint64>( + ASSERT_EQ(80, SumAllExtensions<uint64_t>( message, unittest::repeated_fixed64_extension, 0)); - IncAllExtensions<uint64>(&message, unittest::repeated_fixed64_extension, 1); - ASSERT_EQ(90, SumAllExtensions<uint64>( + IncAllExtensions<uint64_t>(&message, unittest::repeated_fixed64_extension, 1); + ASSERT_EQ(90, SumAllExtensions<uint64_t>( message, unittest::repeated_fixed64_extension, 0)); // Usually, floating-point arithmetic cannot be trusted to be exact, so it is @@ -1253,6 +1286,8 @@ TEST(ExtensionSetTest, DynamicExtensions) { } // Can we print it? + std::string message_text; + TextFormat::PrintToString(message, &message_text); EXPECT_EQ( "[dynamic_extensions.scalar_extension]: 123\n" "[dynamic_extensions.enum_extension]: FOREIGN_BAR\n" @@ -1271,7 +1306,7 @@ TEST(ExtensionSetTest, DynamicExtensions) { "[dynamic_extensions.packed_extension]: -78\n" "2002: 12345\n" "54321: \"unknown\"\n", - message.DebugString()); + message_text); // Can we serialize it? EXPECT_TRUE( @@ -1322,7 +1357,7 @@ TEST(ExtensionSetTest, DynamicExtensions) { TEST(ExtensionSetTest, BoolExtension) { unittest::TestAllExtensions msg; - uint8 wire_bytes[2] = {13 * 8, 42 /* out of bounds payload for bool */}; + uint8_t wire_bytes[2] = {13 * 8, 42 /* out of bounds payload for bool */}; EXPECT_TRUE(msg.ParseFromArray(wire_bytes, 2)); EXPECT_TRUE(msg.GetExtension(protobuf_unittest::optional_bool_extension)); } @@ -1332,6 +1367,18 @@ TEST(ExtensionSetTest, ConstInit) { EXPECT_EQ(set.NumExtensions(), 0); } +TEST(ExtensionSetTest, ExtensionSetSpaceUsed) { + unittest::TestAllExtensions msg; + size_t l = msg.SpaceUsedLong(); + msg.SetExtension(unittest::optional_int32_extension, 100); + unittest::TestAllExtensions msg2(msg); + size_t l2 = msg2.SpaceUsedLong(); + msg.ClearExtension(unittest::optional_int32_extension); + unittest::TestAllExtensions msg3(msg); + size_t l3 = msg3.SpaceUsedLong(); + EXPECT_TRUE((l2 - l) > (l3 - l)); +} + } // namespace } // namespace internal } // namespace protobuf diff --git a/r5dev/thirdparty/protobuf/field_mask.pb.cc b/r5dev/thirdparty/protobuf/field_mask.pb.cc index 1e9d858e..9d3a5c28 100644 --- a/r5dev/thirdparty/protobuf/field_mask.pb.cc +++ b/r5dev/thirdparty/protobuf/field_mask.pb.cc @@ -16,23 +16,28 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + PROTOBUF_NAMESPACE_OPEN -constexpr FieldMask::FieldMask( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : paths_(){} +PROTOBUF_CONSTEXPR FieldMask::FieldMask( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.paths_)*/{} + , /*decltype(_impl_._cached_size_)*/{}} {} struct FieldMaskDefaultTypeInternal { - constexpr FieldMaskDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FieldMaskDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~FieldMaskDefaultTypeInternal() {} union { FieldMask _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FieldMaskDefaultTypeInternal _FieldMask_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldMaskDefaultTypeInternal _FieldMask_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto[1]; -static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr; +static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto[1]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr; const uint32_t TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ @@ -41,14 +46,14 @@ const uint32_t TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets[] P ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldMask, paths_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldMask, _impl_.paths_), }; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldMask)}, }; -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FieldMask_default_instance_), +static const ::_pb::Message* const file_default_instances[] = { + &::PROTOBUF_NAMESPACE_ID::_FieldMask_default_instance_._instance, }; const char descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = @@ -59,19 +64,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto[] "n/fieldmaskpb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf" ".WellKnownTypesb\006proto3" ; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto = { - false, false, 223, descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto, "google/protobuf/field_mask.proto", - &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once, nullptr, 0, 1, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, +static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto = { + false, false, 223, descriptor_table_protodef_google_2fprotobuf_2ffield_5fmask_2eproto, + "google/protobuf/field_mask.proto", + &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once, nullptr, 0, 1, + schemas, file_default_instances, TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, + file_level_service_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_getter() { +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto; } // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ffield_5fmask_2eproto(&descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ffield_5fmask_2eproto(&descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto); PROTOBUF_NAMESPACE_OPEN // =================================================================== @@ -82,43 +89,47 @@ class FieldMask::_Internal { FieldMask::FieldMask(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - paths_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.FieldMask) } FieldMask::FieldMask(const FieldMask& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - paths_(from.paths_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + FieldMask* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.paths_){from._impl_.paths_} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldMask) } -inline void FieldMask::SharedCtor() { +inline void FieldMask::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.paths_){arena} + , /*decltype(_impl_._cached_size_)*/{} + }; } FieldMask::~FieldMask() { // @@protoc_insertion_point(destructor:google.protobuf.FieldMask) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void FieldMask::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.paths_.~RepeatedPtrField(); } -void FieldMask::ArenaDtor(void* object) { - FieldMask* _this = reinterpret_cast< FieldMask* >(object); - (void)_this; -} -void FieldMask::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void FieldMask::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void FieldMask::Clear() { @@ -127,15 +138,15 @@ void FieldMask::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - paths_.Clear(); + _impl_.paths_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* FieldMask::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* FieldMask::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // repeated string paths = 1; case 1: @@ -144,9 +155,9 @@ const char* FieldMask::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:: do { ptr += 1; auto str = _internal_add_paths(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.FieldMask.paths")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.FieldMask.paths")); if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); } else @@ -192,7 +203,7 @@ uint8_t* FieldMask::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldMask) @@ -209,36 +220,32 @@ size_t FieldMask::ByteSizeLong() const { // repeated string paths = 1; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(paths_.size()); - for (int i = 0, n = paths_.size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.paths_.size()); + for (int i = 0, n = _impl_.paths_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - paths_.Get(i)); + _impl_.paths_.Get(i)); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FieldMask::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, FieldMask::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FieldMask::GetClassData() const { return &_class_data_; } -void FieldMask::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<FieldMask *>(to)->MergeFrom( - static_cast<const FieldMask &>(from)); -} - -void FieldMask::MergeFrom(const FieldMask& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldMask) - GOOGLE_DCHECK_NE(&from, this); +void FieldMask::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<FieldMask*>(&to_msg); + auto& from = static_cast<const FieldMask&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldMask) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - paths_.MergeFrom(from.paths_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.paths_.MergeFrom(from._impl_.paths_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void FieldMask::CopyFrom(const FieldMask& from) { @@ -255,11 +262,11 @@ bool FieldMask::IsInitialized() const { void FieldMask::InternalSwap(FieldMask* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - paths_.InternalSwap(&other->paths_); + _impl_.paths_.InternalSwap(&other->_impl_.paths_); } ::PROTOBUF_NAMESPACE_ID::Metadata FieldMask::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_getter, &descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto_once, file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto[0]); } @@ -267,7 +274,8 @@ void FieldMask::InternalSwap(FieldMask* other) { // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FieldMask* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldMask >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FieldMask* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FieldMask >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FieldMask >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/thirdparty/protobuf/field_mask.pb.h b/r5dev/thirdparty/protobuf/field_mask.pb.h index 71883a8f..f240f44b 100644 --- a/r5dev/thirdparty/protobuf/field_mask.pb.h +++ b/r5dev/thirdparty/protobuf/field_mask.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/generated_message_reflection.h> @@ -42,14 +41,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ffield_5fmask_2eproto; @@ -70,7 +61,7 @@ class PROTOBUF_EXPORT FieldMask final : public: inline FieldMask() : FieldMask(nullptr) {} ~FieldMask() override; - explicit constexpr FieldMask(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR FieldMask(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FieldMask(const FieldMask& from); FieldMask(FieldMask&& from) noexcept @@ -145,9 +136,11 @@ class PROTOBUF_EXPORT FieldMask final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const FieldMask& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const FieldMask& from); + void MergeFrom( const FieldMask& from) { + FieldMask::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -156,10 +149,10 @@ class PROTOBUF_EXPORT FieldMask final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(FieldMask* other); @@ -172,9 +165,6 @@ class PROTOBUF_EXPORT FieldMask final : protected: explicit FieldMask(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -220,8 +210,11 @@ class PROTOBUF_EXPORT FieldMask final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> paths_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> paths_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2ffield_5fmask_2eproto; }; // =================================================================== @@ -237,13 +230,13 @@ class PROTOBUF_EXPORT FieldMask final : // repeated string paths = 1; inline int FieldMask::_internal_paths_size() const { - return paths_.size(); + return _impl_.paths_.size(); } inline int FieldMask::paths_size() const { return _internal_paths_size(); } inline void FieldMask::clear_paths() { - paths_.Clear(); + _impl_.paths_.Clear(); } inline std::string* FieldMask::add_paths() { std::string* _s = _internal_add_paths(); @@ -251,7 +244,7 @@ inline std::string* FieldMask::add_paths() { return _s; } inline const std::string& FieldMask::_internal_paths(int index) const { - return paths_.Get(index); + return _impl_.paths_.Get(index); } inline const std::string& FieldMask::paths(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FieldMask.paths) @@ -259,55 +252,55 @@ inline const std::string& FieldMask::paths(int index) const { } inline std::string* FieldMask::mutable_paths(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.FieldMask.paths) - return paths_.Mutable(index); + return _impl_.paths_.Mutable(index); } inline void FieldMask::set_paths(int index, const std::string& value) { - paths_.Mutable(index)->assign(value); + _impl_.paths_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) } inline void FieldMask::set_paths(int index, std::string&& value) { - paths_.Mutable(index)->assign(std::move(value)); + _impl_.paths_.Mutable(index)->assign(std::move(value)); // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths) } inline void FieldMask::set_paths(int index, const char* value) { GOOGLE_DCHECK(value != nullptr); - paths_.Mutable(index)->assign(value); + _impl_.paths_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths) } inline void FieldMask::set_paths(int index, const char* value, size_t size) { - paths_.Mutable(index)->assign( + _impl_.paths_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldMask.paths) } inline std::string* FieldMask::_internal_add_paths() { - return paths_.Add(); + return _impl_.paths_.Add(); } inline void FieldMask::add_paths(const std::string& value) { - paths_.Add()->assign(value); + _impl_.paths_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) } inline void FieldMask::add_paths(std::string&& value) { - paths_.Add(std::move(value)); + _impl_.paths_.Add(std::move(value)); // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths) } inline void FieldMask::add_paths(const char* value) { GOOGLE_DCHECK(value != nullptr); - paths_.Add()->assign(value); + _impl_.paths_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths) } inline void FieldMask::add_paths(const char* value, size_t size) { - paths_.Add()->assign(reinterpret_cast<const char*>(value), size); + _impl_.paths_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.FieldMask.paths) } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>& FieldMask::paths() const { // @@protoc_insertion_point(field_list:google.protobuf.FieldMask.paths) - return paths_; + return _impl_.paths_; } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>* FieldMask::mutable_paths() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldMask.paths) - return &paths_; + return &_impl_.paths_; } #ifdef __GNUC__ diff --git a/r5dev/thirdparty/protobuf/generated_enum_reflection.h b/r5dev/thirdparty/protobuf/generated_enum_reflection.h index 583b8be0..58931f2f 100644 --- a/r5dev/thirdparty/protobuf/generated_enum_reflection.h +++ b/r5dev/thirdparty/protobuf/generated_enum_reflection.h @@ -39,16 +39,18 @@ #ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__ #define GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__ + #include <string> -#include <thirdparty/protobuf/generated_enum_util.h> #include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/generated_enum_util.h> #ifdef SWIG #error "You cannot SWIG proto headers" #endif +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/generated_enum_util.h b/r5dev/thirdparty/protobuf/generated_enum_util.h index 16bb47c6..3815d345 100644 --- a/r5dev/thirdparty/protobuf/generated_enum_util.h +++ b/r5dev/thirdparty/protobuf/generated_enum_util.h @@ -31,11 +31,13 @@ #ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__ #define GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__ + #include <type_traits> -#include <thirdparty/protobuf/message_lite.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/message_lite.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG diff --git a/r5dev/thirdparty/protobuf/generated_message_bases.cc b/r5dev/thirdparty/protobuf/generated_message_bases.cc index 7f5c3264..4685556c 100644 --- a/r5dev/thirdparty/protobuf/generated_message_bases.cc +++ b/r5dev/thirdparty/protobuf/generated_message_bases.cc @@ -30,9 +30,9 @@ #include <thirdparty/protobuf/generated_message_bases.h> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/unknown_field_set.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/wire_format_lite.h> @@ -52,8 +52,7 @@ void ZeroFieldsBase::Clear() { } ZeroFieldsBase::~ZeroFieldsBase() { - if (GetArenaForAllocation() != nullptr) return; - _internal_metadata_.Delete<UnknownFieldSet>(); + (void)_internal_metadata_.DeleteReturnArena<UnknownFieldSet>(); } size_t ZeroFieldsBase::ByteSizeLong() const { @@ -99,15 +98,15 @@ failure: return target; } -void ZeroFieldsBase::MergeImpl(Message* to_param, const Message& from_param) { - auto* to = static_cast<ZeroFieldsBase*>(to_param); +void ZeroFieldsBase::MergeImpl(Message& to_param, const Message& from_param) { + auto* to = static_cast<ZeroFieldsBase*>(&to_param); const auto* from = static_cast<const ZeroFieldsBase*>(&from_param); GOOGLE_DCHECK_NE(from, to); to->_internal_metadata_.MergeFrom<UnknownFieldSet>(from->_internal_metadata_); } -void ZeroFieldsBase::CopyImpl(Message* to_param, const Message& from_param) { - auto* to = static_cast<ZeroFieldsBase*>(to_param); +void ZeroFieldsBase::CopyImpl(Message& to_param, const Message& from_param) { + auto* to = static_cast<ZeroFieldsBase*>(&to_param); const auto* from = static_cast<const ZeroFieldsBase*>(&from_param); if (from == to) return; to->_internal_metadata_.Clear<UnknownFieldSet>(); diff --git a/r5dev/thirdparty/protobuf/generated_message_bases.h b/r5dev/thirdparty/protobuf/generated_message_bases.h index e33ad0f7..d960d085 100644 --- a/r5dev/thirdparty/protobuf/generated_message_bases.h +++ b/r5dev/thirdparty/protobuf/generated_message_bases.h @@ -35,11 +35,11 @@ #ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__ #define GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__ -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/message.h> +#include <thirdparty/protobuf/parse_context.h> // Must come last: #include <thirdparty/protobuf/port_def.inc> @@ -71,8 +71,8 @@ class PROTOBUF_EXPORT ZeroFieldsBase : public Message { void SetCachedSize(int size) const final { _cached_size_.Set(size); } - static void MergeImpl(Message* to, const Message& from); - static void CopyImpl(Message* to, const Message& from); + static void MergeImpl(Message& to, const Message& from); + static void CopyImpl(Message& to, const Message& from); void InternalSwap(ZeroFieldsBase* other); mutable internal::CachedSize _cached_size_; diff --git a/r5dev/thirdparty/protobuf/generated_message_reflection.cc b/r5dev/thirdparty/protobuf/generated_message_reflection.cc index 495ca290..a6826847 100644 --- a/r5dev/thirdparty/protobuf/generated_message_reflection.cc +++ b/r5dev/thirdparty/protobuf/generated_message_reflection.cc @@ -39,19 +39,18 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/descriptor.pb.h> +#include <thirdparty/protobuf/stubs/mutex.h> +#include <thirdparty/protobuf/stubs/casts.h> +#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/extension_set.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/inlined_string_field.h> #include <thirdparty/protobuf/map_field.h> #include <thirdparty/protobuf/map_field_inl.h> -#include <thirdparty/protobuf/stubs/mutex.h> #include <thirdparty/protobuf/repeated_field.h> #include <thirdparty/protobuf/unknown_field_set.h> -#include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/stubs/casts.h> -#include <thirdparty/protobuf/stubs/strutil.h> // clang-format off @@ -258,7 +257,11 @@ bool Reflection::IsLazyExtension(const Message& message, } bool Reflection::IsLazilyVerifiedLazyField(const FieldDescriptor* field) const { - return field->options().lazy(); + if (field->options().unverified_lazy()) return true; + + // Message fields with [lazy=true] will be eagerly verified + // (go/verified-lazy). + return field->options().lazy() && !IsEagerlyVerifiedLazyField(field); } bool Reflection::IsEagerlyVerifiedLazyField( @@ -279,6 +282,13 @@ size_t Reflection::SpaceUsedLong(const Message& message) const { total_size += GetUnknownFields(message).SpaceUsedExcludingSelfLong(); + // If this message owns an arena, add any unused space that's been allocated. + auto* arena = Arena::InternalGetArenaForAllocation(&message); + if (arena != nullptr && Arena::InternalGetOwningArena(&message) == nullptr && + arena->InternalIsMessageOwnedArena()) { + total_size += arena->SpaceAllocated() - arena->SpaceUsed(); + } + if (schema_.HasExtensionSet()) { total_size += GetExtensionSet(message).SpaceUsedExcludingSelfLong(); } @@ -346,31 +356,26 @@ size_t Reflection::SpaceUsedLong(const Message& message) const { case FieldDescriptor::CPPTYPE_STRING: { switch (field->options().ctype()) { default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: { + case FieldOptions::STRING: if (IsInlined(field)) { const std::string* ptr = &GetField<InlinedStringField>(message, field).GetNoArena(); total_size += StringSpaceUsedExcludingSelfLong(*ptr); - break; - } - - const std::string* ptr = - GetField<ArenaStringPtr>(message, field).GetPointer(); - - // Initially, the string points to the default value stored - // in the prototype. Only count the string if it has been - // changed from the default value. - // Except oneof fields, those never point to a default instance, - // and there is no default instance to point to. - if (schema_.InRealOneof(field) || - ptr != DefaultRaw<ArenaStringPtr>(field).GetPointer()) { - // string fields are represented by just a pointer, so also - // include sizeof(string) as well. - total_size += - sizeof(*ptr) + StringSpaceUsedExcludingSelfLong(*ptr); + } else { + // Initially, the string points to the default value stored + // in the prototype. Only count the string if it has been + // changed from the default value. + // Except oneof fields, those never point to a default instance, + // and there is no default instance to point to. + const auto& str = GetField<ArenaStringPtr>(message, field); + if (!str.IsDefault() || schema_.InRealOneof(field)) { + // string fields are represented by just a pointer, so also + // include sizeof(string) as well. + total_size += sizeof(std::string) + + StringSpaceUsedExcludingSelfLong(str.Get()); + } } break; - } } break; } @@ -478,8 +483,7 @@ class SwapFieldHelper { static void SwapStringField(const Reflection* r, Message* lhs, Message* rhs, const FieldDescriptor* field); - static void SwapArenaStringPtr(const std::string* default_ptr, - ArenaStringPtr* lhs, Arena* lhs_arena, + static void SwapArenaStringPtr(ArenaStringPtr* lhs, Arena* lhs_arena, ArenaStringPtr* rhs, Arena* rhs_arena); template <bool unsafe_shallow_swap> @@ -494,6 +498,10 @@ class SwapFieldHelper { static void SwapMessage(const Reflection* r, Message* lhs, Arena* lhs_arena, Message* rhs, Arena* rhs_arena, const FieldDescriptor* field); + + static void SwapNonMessageNonStringField(const Reflection* r, Message* lhs, + Message* rhs, + const FieldDescriptor* field); }; template <bool unsafe_shallow_swap> @@ -524,21 +532,26 @@ void SwapFieldHelper::SwapInlinedStrings(const Reflection* r, Message* lhs, Arena* rhs_arena = rhs->GetArenaForAllocation(); auto* lhs_string = r->MutableRaw<InlinedStringField>(lhs, field); auto* rhs_string = r->MutableRaw<InlinedStringField>(rhs, field); - const uint32 index = r->schema_.InlinedStringIndex(field); - uint32* lhs_state = &r->MutableInlinedStringDonatedArray(lhs)[index / 32]; - uint32* rhs_state = &r->MutableInlinedStringDonatedArray(rhs)[index / 32]; - const uint32 mask = ~(static_cast<uint32>(1) << (index % 32)); + uint32_t index = r->schema_.InlinedStringIndex(field); + GOOGLE_DCHECK_GT(index, 0); + uint32_t* lhs_array = r->MutableInlinedStringDonatedArray(lhs); + uint32_t* rhs_array = r->MutableInlinedStringDonatedArray(rhs); + uint32_t* lhs_state = &lhs_array[index / 32]; + uint32_t* rhs_state = &rhs_array[index / 32]; + bool lhs_arena_dtor_registered = (lhs_array[0] & 0x1u) == 0; + bool rhs_arena_dtor_registered = (rhs_array[0] & 0x1u) == 0; + const uint32_t mask = ~(static_cast<uint32_t>(1) << (index % 32)); if (unsafe_shallow_swap || lhs_arena == rhs_arena) { - lhs_string->Swap(rhs_string, /*default_value=*/nullptr, lhs_arena, - r->IsInlinedStringDonated(*lhs, field), - r->IsInlinedStringDonated(*rhs, field), - /*donating_states=*/lhs_state, rhs_state, mask); + InlinedStringField::InternalSwap(lhs_string, lhs_arena, + lhs_arena_dtor_registered, lhs, rhs_string, + rhs_arena, rhs_arena_dtor_registered, rhs); } else { const std::string temp = lhs_string->Get(); - lhs_string->Set(nullptr, rhs_string->Get(), lhs_arena, - r->IsInlinedStringDonated(*lhs, field), lhs_state, mask); - rhs_string->Set(nullptr, temp, rhs_arena, - r->IsInlinedStringDonated(*rhs, field), rhs_state, mask); + lhs_string->Set(rhs_string->Get(), lhs_arena, + r->IsInlinedStringDonated(*lhs, field), lhs_state, mask, + lhs); + rhs_string->Set(temp, rhs_arena, r->IsInlinedStringDonated(*rhs, field), + rhs_state, mask, rhs); } } @@ -552,8 +565,7 @@ void SwapFieldHelper::SwapNonInlinedStrings(const Reflection* r, Message* lhs, ArenaStringPtr::UnsafeShallowSwap(lhs_string, rhs_string); } else { SwapFieldHelper::SwapArenaStringPtr( - r->DefaultRaw<ArenaStringPtr>(field).GetPointer(), // - lhs_string, lhs->GetArenaForAllocation(), // + lhs_string, lhs->GetArenaForAllocation(), // rhs_string, rhs->GetArenaForAllocation()); } } @@ -577,28 +589,27 @@ void SwapFieldHelper::SwapStringField(const Reflection* r, Message* lhs, } } -void SwapFieldHelper::SwapArenaStringPtr(const std::string* default_ptr, - ArenaStringPtr* lhs, Arena* lhs_arena, +void SwapFieldHelper::SwapArenaStringPtr(ArenaStringPtr* lhs, Arena* lhs_arena, ArenaStringPtr* rhs, Arena* rhs_arena) { if (lhs_arena == rhs_arena) { - ArenaStringPtr::InternalSwap(default_ptr, lhs, lhs_arena, rhs, rhs_arena); - } else if (lhs->IsDefault(default_ptr) && rhs->IsDefault(default_ptr)) { + ArenaStringPtr::InternalSwap(lhs, lhs_arena, rhs, rhs_arena); + } else if (lhs->IsDefault() && rhs->IsDefault()) { // Nothing to do. - } else if (lhs->IsDefault(default_ptr)) { - lhs->Set(default_ptr, rhs->Get(), lhs_arena); + } else if (lhs->IsDefault()) { + lhs->Set(rhs->Get(), lhs_arena); // rhs needs to be destroyed before overwritten. - rhs->Destroy(default_ptr, rhs_arena); - rhs->UnsafeSetDefault(default_ptr); - } else if (rhs->IsDefault(default_ptr)) { - rhs->Set(default_ptr, lhs->Get(), rhs_arena); + rhs->Destroy(); + rhs->InitDefault(); + } else if (rhs->IsDefault()) { + rhs->Set(lhs->Get(), rhs_arena); // lhs needs to be destroyed before overwritten. - lhs->Destroy(default_ptr, lhs_arena); - lhs->UnsafeSetDefault(default_ptr); + lhs->Destroy(); + lhs->InitDefault(); } else { std::string temp = lhs->Get(); - lhs->Set(default_ptr, rhs->Get(), lhs_arena); - rhs->Set(default_ptr, std::move(temp), rhs_arena); + lhs->Set(rhs->Get(), lhs_arena); + rhs->Set(std::move(temp), rhs_arena); } } @@ -673,6 +684,30 @@ void SwapFieldHelper::SwapMessage(const Reflection* r, Message* lhs, } } +void SwapFieldHelper::SwapNonMessageNonStringField( + const Reflection* r, Message* lhs, Message* rhs, + const FieldDescriptor* field) { + switch (field->cpp_type()) { +#define SWAP_VALUES(CPPTYPE, TYPE) \ + case FieldDescriptor::CPPTYPE_##CPPTYPE: \ + std::swap(*r->MutableRaw<TYPE>(lhs, field), \ + *r->MutableRaw<TYPE>(rhs, field)); \ + break; + + SWAP_VALUES(INT32, int32_t); + SWAP_VALUES(INT64, int64_t); + SWAP_VALUES(UINT32, uint32_t); + SWAP_VALUES(UINT64, uint64_t); + SWAP_VALUES(FLOAT, float); + SWAP_VALUES(DOUBLE, double); + SWAP_VALUES(BOOL, bool); + SWAP_VALUES(ENUM, int); +#undef SWAP_VALUES + default: + GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type(); + } +} + } // namespace internal void Reflection::SwapField(Message* message1, Message* message2, @@ -709,21 +744,6 @@ void Reflection::SwapField(Message* message1, Message* message2, } } else { switch (field->cpp_type()) { -#define SWAP_VALUES(CPPTYPE, TYPE) \ - case FieldDescriptor::CPPTYPE_##CPPTYPE: \ - std::swap(*MutableRaw<TYPE>(message1, field), \ - *MutableRaw<TYPE>(message2, field)); \ - break; - - SWAP_VALUES(INT32, int32_t); - SWAP_VALUES(INT64, int64_t); - SWAP_VALUES(UINT32, uint32_t); - SWAP_VALUES(UINT64, uint64_t); - SWAP_VALUES(FLOAT, float); - SWAP_VALUES(DOUBLE, double); - SWAP_VALUES(BOOL, bool); - SWAP_VALUES(ENUM, int); -#undef SWAP_VALUES case FieldDescriptor::CPPTYPE_MESSAGE: internal::SwapFieldHelper::SwapMessageField<false>(this, message1, message2, field); @@ -733,9 +753,9 @@ void Reflection::SwapField(Message* message1, Message* message2, internal::SwapFieldHelper::SwapStringField<false>(this, message1, message2, field); break; - default: - GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type(); + internal::SwapFieldHelper::SwapNonMessageNonStringField( + this, message1, message2, field); } } } @@ -750,7 +770,8 @@ void Reflection::UnsafeShallowSwapField(Message* message1, Message* message2, internal::SwapFieldHelper::SwapStringField<true>(this, message1, message2, field); } else { - SwapField(message1, message2, field); + internal::SwapFieldHelper::SwapNonMessageNonStringField(this, message1, + message2, field); } return; } @@ -877,8 +898,8 @@ void Reflection::SwapOneofField(Message* lhs, Message* rhs, }; GOOGLE_DCHECK(!oneof_descriptor->is_synthetic()); - uint32 oneof_case_lhs = GetOneofCase(*lhs, oneof_descriptor); - uint32 oneof_case_rhs = GetOneofCase(*rhs, oneof_descriptor); + uint32_t oneof_case_lhs = GetOneofCase(*lhs, oneof_descriptor); + uint32_t oneof_case_rhs = GetOneofCase(*rhs, oneof_descriptor); LocalVarWrapper temp; MessageWrapper lhs_wrapper, rhs_wrapper; @@ -1030,6 +1051,13 @@ void Reflection::SwapFieldsImpl( // may depend on the information in has bits. if (!field->is_repeated()) { SwapBit(message1, message2, field); + if (field->options().ctype() == FieldOptions::STRING && + IsInlined(field)) { + GOOGLE_DCHECK(!unsafe_shallow_swap || + message1->GetArenaForAllocation() == + message2->GetArenaForAllocation()); + SwapInlinedStringDonated(message1, message2, field); + } } } } @@ -1096,8 +1124,8 @@ void Reflection::UnsafeArenaSwap(Message* lhs, Message* rhs) const { // Swapping bits need to happen after swapping fields, because the latter may // depend on the has bit information. if (schema_.HasHasbits()) { - uint32* lhs_has_bits = MutableHasBits(lhs); - uint32* rhs_has_bits = MutableHasBits(rhs); + uint32_t* lhs_has_bits = MutableHasBits(lhs); + uint32_t* rhs_has_bits = MutableHasBits(rhs); int fields_with_has_bits = 0; for (int i = 0; i < descriptor_->field_count(); i++) { @@ -1115,6 +1143,32 @@ void Reflection::UnsafeArenaSwap(Message* lhs, Message* rhs) const { } } + if (schema_.HasInlinedString()) { + uint32_t* lhs_donated_array = MutableInlinedStringDonatedArray(lhs); + uint32_t* rhs_donated_array = MutableInlinedStringDonatedArray(rhs); + int inlined_string_count = 0; + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* field = descriptor_->field(i); + if (field->is_extension() || field->is_repeated() || + schema_.InRealOneof(field) || + field->options().ctype() != FieldOptions::STRING || + !IsInlined(field)) { + continue; + } + inlined_string_count++; + } + + int donated_array_size = inlined_string_count == 0 + ? 0 + // One extra bit for the arena dtor tracking. + : (inlined_string_count + 1 + 31) / 32; + GOOGLE_CHECK_EQ((lhs_donated_array[0] & 0x1u) == 0, + (rhs_donated_array[0] & 0x1u) == 0); + for (int i = 0; i < donated_array_size; i++) { + std::swap(lhs_donated_array[i], rhs_donated_array[i]); + } + } + if (schema_.HasExtensionSet()) { MutableExtensionSet(lhs)->InternalSwap(MutableExtensionSet(rhs)); } @@ -1205,20 +1259,17 @@ void Reflection::ClearField(Message* message, case FieldDescriptor::CPPTYPE_STRING: { switch (field->options().ctype()) { default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: { + case FieldOptions::STRING: if (IsInlined(field)) { // Currently, string with default value can't be inlined. So we // don't have to handle default value here. MutableRaw<InlinedStringField>(message, field)->ClearToEmpty(); - break; + } else { + auto* str = MutableRaw<ArenaStringPtr>(message, field); + str->Destroy(); + str->InitDefault(); } - const std::string* default_ptr = - DefaultRaw<ArenaStringPtr>(field).GetPointer(); - MutableRaw<ArenaStringPtr>(message, field) - ->SetAllocated(default_ptr, nullptr, - message->GetArenaForAllocation()); break; - } } break; } @@ -1597,17 +1648,13 @@ std::string Reflection::GetString(const Message& message, } switch (field->options().ctype()) { default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: { + case FieldOptions::STRING: if (IsInlined(field)) { return GetField<InlinedStringField>(message, field).GetNoArena(); + } else { + const auto& str = GetField<ArenaStringPtr>(message, field); + return str.IsDefault() ? field->default_value_string() : str.Get(); } - - if (auto* value = - GetField<ArenaStringPtr>(message, field).GetPointer()) { - return *value; - } - return field->default_value_string(); - } } } } @@ -1626,17 +1673,13 @@ const std::string& Reflection::GetStringReference(const Message& message, } switch (field->options().ctype()) { default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: { + case FieldOptions::STRING: if (IsInlined(field)) { return GetField<InlinedStringField>(message, field).GetNoArena(); + } else { + const auto& str = GetField<ArenaStringPtr>(message, field); + return str.IsDefault() ? field->default_value_string() : str.Get(); } - - if (auto* value = - GetField<ArenaStringPtr>(message, field).GetPointer()) { - return *value; - } - return field->default_value_string(); - } } } } @@ -1654,12 +1697,14 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field, case FieldOptions::STRING: { if (IsInlined(field)) { const uint32_t index = schema_.InlinedStringIndex(field); + GOOGLE_DCHECK_GT(index, 0); uint32_t* states = &MutableInlinedStringDonatedArray(message)[index / 32]; uint32_t mask = ~(static_cast<uint32_t>(1) << (index % 32)); MutableField<InlinedStringField>(message, field) - ->Set(nullptr, value, message->GetArenaForAllocation(), - IsInlinedStringDonated(*message, field), states, mask); + ->Set(value, message->GetArenaForAllocation(), + IsInlinedStringDonated(*message, field), states, mask, + message); break; } @@ -1667,18 +1712,12 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field, // We just need to pass some arbitrary default string to make it work. // This allows us to not have the real default accessible from // reflection. - const std::string* default_ptr = - schema_.InRealOneof(field) - ? nullptr - : DefaultRaw<ArenaStringPtr>(field).GetPointer(); if (schema_.InRealOneof(field) && !HasOneofField(*message, field)) { ClearOneof(message, field->containing_oneof()); - MutableField<ArenaStringPtr>(message, field) - ->UnsafeSetDefault(default_ptr); + MutableField<ArenaStringPtr>(message, field)->InitDefault(); } MutableField<ArenaStringPtr>(message, field) - ->Set(default_ptr, std::move(value), - message->GetArenaForAllocation()); + ->Set(std::move(value), message->GetArenaForAllocation()); break; } } @@ -2325,7 +2364,7 @@ bool Reflection::InsertOrLookupMapValue(Message* message, MapValueRef* val) const { USAGE_CHECK(IsMapFieldInApi(field), "InsertOrLookupMapValue", "Field is not a map field."); - val->SetType(field->message_type()->FindFieldByName("value")->cpp_type()); + val->SetType(field->message_type()->map_value()->cpp_type()); return MutableRaw<MapFieldBase>(message, field) ->InsertOrLookupMapValue(key, val); } @@ -2335,7 +2374,7 @@ bool Reflection::LookupMapValue(const Message& message, MapValueConstRef* val) const { USAGE_CHECK(IsMapFieldInApi(field), "LookupMapValue", "Field is not a map field."); - val->SetType(field->message_type()->FindFieldByName("value")->cpp_type()); + val->SetType(field->message_type()->map_value()->cpp_type()); return GetRaw<MapFieldBase>(message, field).LookupMapValue(key, val); } @@ -2458,7 +2497,7 @@ const uint32_t* Reflection::GetInlinedStringDonatedArray( } uint32_t* Reflection::MutableInlinedStringDonatedArray(Message* message) const { - GOOGLE_DCHECK(schema_.HasHasbits()); + GOOGLE_DCHECK(schema_.HasInlinedString()); return GetPointerAtOffset<uint32_t>(message, schema_.InlinedStringDonatedOffset()); } @@ -2466,8 +2505,48 @@ uint32_t* Reflection::MutableInlinedStringDonatedArray(Message* message) const { // Simple accessors for manipulating _inlined_string_donated_; bool Reflection::IsInlinedStringDonated(const Message& message, const FieldDescriptor* field) const { - return IsIndexInHasBitSet(GetInlinedStringDonatedArray(message), - schema_.InlinedStringIndex(field)); + uint32_t index = schema_.InlinedStringIndex(field); + GOOGLE_DCHECK_GT(index, 0); + return IsIndexInHasBitSet(GetInlinedStringDonatedArray(message), index); +} + +inline void SetInlinedStringDonated(uint32_t index, uint32_t* array) { + array[index / 32] |= (static_cast<uint32_t>(1) << (index % 32)); +} + +inline void ClearInlinedStringDonated(uint32_t index, uint32_t* array) { + array[index / 32] &= ~(static_cast<uint32_t>(1) << (index % 32)); +} + +void Reflection::SwapInlinedStringDonated(Message* lhs, Message* rhs, + const FieldDescriptor* field) const { + Arena* lhs_arena = lhs->GetArenaForAllocation(); + Arena* rhs_arena = rhs->GetArenaForAllocation(); + // If arenas differ, inined string fields are swapped by copying values. + // Donation status should not be swapped. + if (lhs_arena != rhs_arena) { + return; + } + bool lhs_donated = IsInlinedStringDonated(*lhs, field); + bool rhs_donated = IsInlinedStringDonated(*rhs, field); + if (lhs_donated == rhs_donated) { + return; + } + // If one is undonated, both must have already registered ArenaDtor. + uint32_t* lhs_array = MutableInlinedStringDonatedArray(lhs); + uint32_t* rhs_array = MutableInlinedStringDonatedArray(rhs); + GOOGLE_CHECK_EQ(lhs_array[0] & 0x1u, 0u); + GOOGLE_CHECK_EQ(rhs_array[0] & 0x1u, 0u); + // Swap donation status bit. + uint32_t index = schema_.InlinedStringIndex(field); + GOOGLE_DCHECK_GT(index, 0); + if (rhs_donated) { + SetInlinedStringDonated(index, lhs_array); + ClearInlinedStringDonated(index, rhs_array); + } else { // lhs_donated + ClearInlinedStringDonated(index, lhs_array); + SetInlinedStringDonated(index, rhs_array); + } } // Simple accessors for manipulating has_bits_. @@ -2618,8 +2697,7 @@ void Reflection::ClearOneof(Message* message, // We just need to pass some arbitrary default string to make it // work. This allows us to not have the real default accessible // from reflection. - MutableField<ArenaStringPtr>(message, field) - ->Destroy(nullptr, message->GetArenaForAllocation()); + MutableField<ArenaStringPtr>(message, field)->Destroy(); break; } } @@ -2632,6 +2710,7 @@ void Reflection::ClearOneof(Message* message, default: break; } + } else { } *MutableOneofCase(message, oneof_descriptor) = 0; @@ -3027,13 +3106,61 @@ void UnknownFieldSetSerializer(const uint8_t* base, uint32_t offset, const void* ptr = base + offset; const InternalMetadata* metadata = static_cast<const InternalMetadata*>(ptr); if (metadata->have_unknown_fields()) { - internal::WireFormat::SerializeUnknownFields( - metadata->unknown_fields<UnknownFieldSet>( - UnknownFieldSet::default_instance), - output); + metadata->unknown_fields<UnknownFieldSet>(UnknownFieldSet::default_instance) + .SerializeToCodedStream(output); } } +bool IsDescendant(Message& root, const Message& message) { + const Reflection* reflection = root.GetReflection(); + std::vector<const FieldDescriptor*> fields; + reflection->ListFieldsOmitStripped(root, &fields); + + for (const auto* field : fields) { + // Skip non-message fields. + if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) continue; + + // Optional messages. + if (!field->is_repeated()) { + Message* sub_message = reflection->MutableMessage(&root, field); + if (sub_message == &message || IsDescendant(*sub_message, message)) { + return true; + } + continue; + } + + // Repeated messages. + if (!IsMapFieldInApi(field)) { + int count = reflection->FieldSize(root, field); + for (int i = 0; i < count; i++) { + Message* sub_message = + reflection->MutableRepeatedMessage(&root, field, i); + if (sub_message == &message || IsDescendant(*sub_message, message)) { + return true; + } + } + continue; + } + + // Map field: if accessed as repeated fields, messages are *copied* and + // matching pointer won't work. Must directly access map. + constexpr int kValIdx = 1; + const FieldDescriptor* val_field = field->message_type()->field(kValIdx); + // Skip map fields whose value type is not message. + if (val_field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) continue; + + MapIterator end = reflection->MapEnd(&root, field); + for (auto iter = reflection->MapBegin(&root, field); iter != end; ++iter) { + Message* sub_message = iter.MutableValueRef()->MutableMessageValue(); + if (sub_message == &message || IsDescendant(*sub_message, message)) { + return true; + } + } + } + + return false; +} + } // namespace internal } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/generated_message_reflection.h b/r5dev/thirdparty/protobuf/generated_message_reflection.h index 32b6cdf4..c67fbe9a 100644 --- a/r5dev/thirdparty/protobuf/generated_message_reflection.h +++ b/r5dev/thirdparty/protobuf/generated_message_reflection.h @@ -38,17 +38,16 @@ #ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__ #define GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__ -#include <string> -#include <vector> #include <thirdparty/protobuf/stubs/casts.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/generated_enum_reflection.h> #include <thirdparty/protobuf/stubs/once.h> #include <thirdparty/protobuf/port.h> +#include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/generated_enum_reflection.h> #include <thirdparty/protobuf/unknown_field_set.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG @@ -137,8 +136,8 @@ struct ReflectionSchema { uint32_t GetFieldOffset(const FieldDescriptor* field) const { if (InRealOneof(field)) { size_t offset = - static_cast<size_t>(field->containing_type()->field_count() + - field->containing_oneof()->index()); + static_cast<size_t>(field->containing_type()->field_count()) + + field->containing_oneof()->index(); return OffsetValue(offsets_[offset], field->type()); } else { return GetFieldOffsetNonOneof(field); @@ -225,13 +224,6 @@ struct ReflectionSchema { return false; } - // Returns true if the field's accessor is called by any external code (aka, - // non proto library code). - bool IsFieldUsed(const FieldDescriptor* field) const { - (void)field; - return true; - } - bool IsFieldStripped(const FieldDescriptor* field) const { (void)field; return false; @@ -269,9 +261,9 @@ struct ReflectionSchema { if (type == FieldDescriptor::TYPE_MESSAGE || type == FieldDescriptor::TYPE_STRING || type == FieldDescriptor::TYPE_BYTES) { - return v & 0x7FFFFFFEu; + return v & 0xFFFFFFFEu; } - return v & 0x7FFFFFFFu; + return v; } static bool Inlined(uint32_t v, FieldDescriptor::Type type) { diff --git a/r5dev/thirdparty/protobuf/generated_message_reflection_unittest.cc b/r5dev/thirdparty/protobuf/generated_message_reflection_unittest.cc index 72e1f035..0608b3c8 100644 --- a/r5dev/thirdparty/protobuf/generated_message_reflection_unittest.cc +++ b/r5dev/thirdparty/protobuf/generated_message_reflection_unittest.cc @@ -48,9 +48,7 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/map_test_util.h> #include <thirdparty/protobuf/map_unittest.pb.h> -#include <thirdparty/protobuf/test_util.h> #include <thirdparty/protobuf/unittest.pb.h> #include <thirdparty/protobuf/unittest_mset.pb.h> #include <thirdparty/protobuf/unittest_mset_wire_format.pb.h> @@ -58,6 +56,8 @@ #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> +#include <thirdparty/protobuf/map_test_util.h> +#include <thirdparty/protobuf/test_util.h> // Must be included last. #include <thirdparty/protobuf/port_def.inc> @@ -75,6 +75,17 @@ class GeneratedMessageReflectionTestHelper { static bool IsLazyExtension(const Message& msg, const FieldDescriptor* ext) { return msg.GetReflection()->IsLazyExtension(msg, ext); } + static bool IsLazyField(const Message& msg, const FieldDescriptor* field) { + return msg.GetReflection()->IsLazyField(field); + } + static bool IsEagerlyVerifiedLazyField(const Message& msg, + const FieldDescriptor* field) { + return msg.GetReflection()->IsEagerlyVerifiedLazyField(field); + } + static bool IsLazilyVerifiedLazyField(const Message& msg, + const FieldDescriptor* field) { + return msg.GetReflection()->IsLazilyVerifiedLazyField(field); + } }; namespace { @@ -149,28 +160,6 @@ TEST(GeneratedMessageReflectionTest, GetStringReference) { } -TEST(GeneratedMessageReflectionTest, DefaultsAfterClear) { - // Check that after setting all fields and then clearing, getting an - // embedded message does NOT return the default instance. - unittest::TestAllTypes message; - TestUtil::ReflectionTester reflection_tester( - unittest::TestAllTypes::descriptor()); - - TestUtil::SetAllFields(&message); - message.Clear(); - - const Reflection* reflection = message.GetReflection(); - - EXPECT_NE(&unittest::TestAllTypes::OptionalGroup::default_instance(), - &reflection->GetMessage(message, F("optionalgroup"))); - EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(), - &reflection->GetMessage(message, F("optional_nested_message"))); - EXPECT_NE(&unittest::ForeignMessage::default_instance(), - &reflection->GetMessage(message, F("optional_foreign_message"))); - EXPECT_NE(&unittest_import::ImportMessage::default_instance(), - &reflection->GetMessage(message, F("optional_import_message"))); -} - class GeneratedMessageReflectionSwapTest : public testing::TestWithParam<bool> { protected: void Swap(const Reflection* reflection, Message* lhs, Message* rhs) { @@ -303,53 +292,58 @@ TEST_P(GeneratedMessageReflectionSwapTest, OneofBothSet) { } TEST_P(GeneratedMessageReflectionSwapTest, SwapFields) { - unittest::TestAllTypes lhs, rhs; - lhs.set_optional_double(12.3); - lhs.mutable_repeated_int32()->Add(10); - lhs.mutable_repeated_int32()->Add(20); + std::unique_ptr<unittest::TestAllTypes> lhs( + Arena::CreateMessage<unittest::TestAllTypes>(nullptr)); + std::unique_ptr<unittest::TestAllTypes> rhs( + Arena::CreateMessage<unittest::TestAllTypes>(nullptr)); + lhs->set_optional_double(12.3); + lhs->mutable_repeated_int32()->Add(10); + lhs->mutable_repeated_int32()->Add(20); - rhs.set_optional_string("hello"); - rhs.mutable_repeated_int64()->Add(30); + rhs->set_optional_string("hello"); + rhs->mutable_repeated_int64()->Add(30); std::vector<const FieldDescriptor*> fields; - const Descriptor* descriptor = lhs.GetDescriptor(); + const Descriptor* descriptor = lhs->GetDescriptor(); fields.push_back(descriptor->FindFieldByName("optional_double")); fields.push_back(descriptor->FindFieldByName("repeated_int32")); fields.push_back(descriptor->FindFieldByName("optional_string")); fields.push_back(descriptor->FindFieldByName("optional_uint64")); - SwapFields(lhs.GetReflection(), &lhs, &rhs, fields); + SwapFields(lhs->GetReflection(), lhs.get(), rhs.get(), fields); - EXPECT_FALSE(lhs.has_optional_double()); - EXPECT_EQ(0, lhs.repeated_int32_size()); - EXPECT_TRUE(lhs.has_optional_string()); - EXPECT_EQ("hello", lhs.optional_string()); - EXPECT_EQ(0, lhs.repeated_int64_size()); - EXPECT_FALSE(lhs.has_optional_uint64()); + EXPECT_FALSE(lhs->has_optional_double()); + EXPECT_EQ(0, lhs->repeated_int32_size()); + EXPECT_TRUE(lhs->has_optional_string()); + EXPECT_EQ("hello", lhs->optional_string()); + EXPECT_EQ(0, lhs->repeated_int64_size()); + EXPECT_FALSE(lhs->has_optional_uint64()); - EXPECT_TRUE(rhs.has_optional_double()); - EXPECT_EQ(12.3, rhs.optional_double()); - EXPECT_EQ(2, rhs.repeated_int32_size()); - EXPECT_EQ(10, rhs.repeated_int32(0)); - EXPECT_EQ(20, rhs.repeated_int32(1)); - EXPECT_FALSE(rhs.has_optional_string()); - EXPECT_EQ(1, rhs.repeated_int64_size()); - EXPECT_FALSE(rhs.has_optional_uint64()); + EXPECT_TRUE(rhs->has_optional_double()); + EXPECT_EQ(12.3, rhs->optional_double()); + EXPECT_EQ(2, rhs->repeated_int32_size()); + EXPECT_EQ(10, rhs->repeated_int32(0)); + EXPECT_EQ(20, rhs->repeated_int32(1)); + EXPECT_FALSE(rhs->has_optional_string()); + EXPECT_EQ(1, rhs->repeated_int64_size()); + EXPECT_FALSE(rhs->has_optional_uint64()); } TEST_P(GeneratedMessageReflectionSwapTest, SwapFieldsAll) { - unittest::TestAllTypes lhs; - unittest::TestAllTypes rhs; + std::unique_ptr<unittest::TestAllTypes> lhs( + Arena::CreateMessage<unittest::TestAllTypes>(nullptr)); + std::unique_ptr<unittest::TestAllTypes> rhs( + Arena::CreateMessage<unittest::TestAllTypes>(nullptr)); - TestUtil::SetAllFields(&rhs); + TestUtil::SetAllFields(rhs.get()); std::vector<const FieldDescriptor*> fields; - const Reflection* reflection = lhs.GetReflection(); - reflection->ListFields(rhs, &fields); - SwapFields(reflection, &lhs, &rhs, fields); + const Reflection* reflection = lhs->GetReflection(); + reflection->ListFields(*rhs, &fields); + SwapFields(reflection, lhs.get(), rhs.get(), fields); - TestUtil::ExpectAllFieldsSet(lhs); - TestUtil::ExpectClear(rhs); + TestUtil::ExpectAllFieldsSet(*lhs); + TestUtil::ExpectClear(*rhs); } TEST(GeneratedMessageReflectionTest, SwapFieldsAllOnDifferentArena) { @@ -559,7 +553,7 @@ TEST(GeneratedMessageReflectionTest, auto* message1 = Arena::CreateMessage<unittest::TestOneof2>(&arena); auto* message2 = Arena::CreateMessage<unittest::TestOneof2>(&arena); TestUtil::SetOneof1(message1); - message1->mutable_foo_message()->set_qux_int(1000); + message1->mutable_foo_message()->set_moo_int(1000); auto* kept_foo_ptr = message1->mutable_foo_message(); std::vector<const FieldDescriptor*> fields; @@ -571,7 +565,7 @@ TEST(GeneratedMessageReflectionTest, message1, message2, fields); EXPECT_TRUE(message2->has_foo_message()); - EXPECT_EQ(message2->foo_message().qux_int(), 1000); + EXPECT_EQ(message2->foo_message().moo_int(), 1000); EXPECT_EQ(kept_foo_ptr, message2->mutable_foo_message()); } @@ -1314,6 +1308,66 @@ TEST(GeneratedMessageReflectionTest, UsageErrors) { #endif // PROTOBUF_HAS_DEATH_TEST +using internal::IsDescendant; + +TEST(GeneratedMessageReflection, IsDescendantMessage) { + unittest::TestAllTypes msg1, msg2; + TestUtil::SetAllFields(&msg1); + msg2 = msg1; + + EXPECT_TRUE(IsDescendant(msg1, msg1.optional_nested_message())); + EXPECT_TRUE(IsDescendant(msg1, msg1.repeated_foreign_message(0))); + + EXPECT_FALSE(IsDescendant(msg1, msg2.optional_nested_message())); + EXPECT_FALSE(IsDescendant(msg1, msg2.repeated_foreign_message(0))); +} + +TEST(GeneratedMessageReflection, IsDescendantMap) { + unittest::TestMap msg1, msg2; + (*msg1.mutable_map_int32_foreign_message())[0].set_c(100); + TestUtil::SetAllFields(&(*msg1.mutable_map_int32_all_types())[0]); + msg2 = msg1; + + EXPECT_TRUE(IsDescendant(msg1, msg1.map_int32_foreign_message().at(0))); + EXPECT_TRUE(IsDescendant(msg1, msg1.map_int32_all_types().at(0))); + + EXPECT_FALSE(IsDescendant(msg1, msg2.map_int32_foreign_message().at(0))); + EXPECT_FALSE(IsDescendant(msg1, msg2.map_int32_all_types().at(0))); +} + +TEST(GeneratedMessageReflection, IsDescendantExtension) { + unittest::TestAllExtensions msg1, msg2; + TestUtil::SetAllExtensions(&msg1); + msg2 = msg1; + + EXPECT_TRUE(IsDescendant( + msg1, msg1.GetExtension(unittest::optional_nested_message_extension))); + EXPECT_TRUE(IsDescendant( + msg1, + msg1.GetExtension(unittest::repeated_foreign_message_extension, 0))); + + EXPECT_FALSE(IsDescendant( + msg1, msg2.GetExtension(unittest::optional_nested_message_extension))); + EXPECT_FALSE(IsDescendant( + msg1, + msg2.GetExtension(unittest::repeated_foreign_message_extension, 0))); +} + +TEST(GeneratedMessageReflection, IsDescendantOneof) { + unittest::TestOneof msg1, msg2; + TestUtil::SetAllFields(msg1.mutable_foo_message()); + msg2 = msg1; + + EXPECT_TRUE(IsDescendant(msg1, msg1.foo_message().optional_nested_message())); + EXPECT_TRUE( + IsDescendant(msg1, msg1.foo_message().repeated_foreign_message(0))); + + EXPECT_FALSE( + IsDescendant(msg1, msg2.foo_message().optional_nested_message())); + EXPECT_FALSE( + IsDescendant(msg1, msg2.foo_message().repeated_foreign_message(0))); +} + } // namespace } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/generated_message_table_driven.cc b/r5dev/thirdparty/protobuf/generated_message_table_driven.cc deleted file mode 100644 index 1957ece5..00000000 --- a/r5dev/thirdparty/protobuf/generated_message_table_driven.cc +++ /dev/null @@ -1,103 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include <thirdparty/protobuf/generated_message_table_driven.h> - -#include <type_traits> - -#include <thirdparty/protobuf/stubs/casts.h> -#include <thirdparty/protobuf/generated_message_table_driven_lite.h> -#include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> -#include <thirdparty/protobuf/repeated_field.h> -#include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/wire_format_lite.h> - -namespace google { -namespace protobuf { -namespace internal { - -namespace { - -UnknownFieldSet* MutableUnknownFields(MessageLite* msg, int64_t arena_offset) { - return Raw<InternalMetadata>(msg, arena_offset) - ->mutable_unknown_fields<UnknownFieldSet>(); -} - -struct UnknownFieldHandler { - // TODO(mvels): consider renaming UnknownFieldHandler to (TableDrivenTraits?), - // and conflating InternalMetaData into it, simplifying the template. - static constexpr bool IsLite() { return false; } - - static bool Skip(MessageLite* msg, const ParseTable& table, - io::CodedInputStream* input, int tag) { - GOOGLE_DCHECK(table.unknown_field_set); - - return WireFormat::SkipField(input, tag, - MutableUnknownFields(msg, table.arena_offset)); - } - - static void Varint(MessageLite* msg, const ParseTable& table, int tag, - int value) { - GOOGLE_DCHECK(table.unknown_field_set); - - MutableUnknownFields(msg, table.arena_offset) - ->AddVarint(WireFormatLite::GetTagFieldNumber(tag), value); - } - - static bool ParseExtension(MessageLite* msg, const ParseTable& table, - io::CodedInputStream* input, int tag) { - ExtensionSet* extensions = GetExtensionSet(msg, table.extension_offset); - if (extensions == nullptr) { - return false; - } - - const Message* prototype = - down_cast<const Message*>(table.default_instance()); - - GOOGLE_DCHECK(prototype != nullptr); - GOOGLE_DCHECK(table.unknown_field_set); - UnknownFieldSet* unknown_fields = - MutableUnknownFields(msg, table.arena_offset); - - return extensions->ParseField(tag, input, prototype, unknown_fields); - } -}; - -} // namespace - -bool MergePartialFromCodedStream(MessageLite* msg, const ParseTable& table, - io::CodedInputStream* input) { - return MergePartialFromCodedStreamImpl<UnknownFieldHandler>(msg, table, - input); -} - -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/r5dev/thirdparty/protobuf/generated_message_table_driven.h b/r5dev/thirdparty/protobuf/generated_message_table_driven.h deleted file mode 100644 index e9257f1e..00000000 --- a/r5dev/thirdparty/protobuf/generated_message_table_driven.h +++ /dev/null @@ -1,351 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_H__ -#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_H__ - -#include <thirdparty/protobuf/map.h> -#include <thirdparty/protobuf/map_entry_lite.h> -#include <thirdparty/protobuf/map_field_lite.h> -#include <thirdparty/protobuf/message_lite.h> -#include <thirdparty/protobuf/wire_format_lite.h> - -// We require C++11 and Clang to use constexpr for variables, as GCC 4.8 -// requires constexpr to be consistent between declarations of variables -// unnecessarily (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58541). -// VS 2017 Update 3 also supports this usage of constexpr. -#if defined(__clang__) || (defined(_MSC_VER) && _MSC_VER >= 1911) -#define PROTOBUF_CONSTEXPR_VAR constexpr -#else // !__clang__ -#define PROTOBUF_CONSTEXPR_VAR -#endif // !_clang - -#ifdef SWIG -#error "You cannot SWIG proto headers" -#endif - -#include <thirdparty/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace internal { - -// Processing-type masks. -static constexpr const unsigned char kOneofMask = 0x40; -static constexpr const unsigned char kRepeatedMask = 0x20; -// Mask for the raw type: either a WireFormatLite::FieldType or one of the -// ProcessingTypes below, without the oneof or repeated flag. -static constexpr const unsigned char kTypeMask = 0x1f; - -// Wire type masks. -static constexpr const unsigned char kNotPackedMask = 0x10; -static constexpr const unsigned char kInvalidMask = 0x20; - -enum ProcessingTypes { - TYPE_STRING_CORD = 19, - TYPE_STRING_STRING_PIECE = 20, - TYPE_BYTES_CORD = 21, - TYPE_BYTES_STRING_PIECE = 22, - TYPE_STRING_INLINED = 23, - TYPE_BYTES_INLINED = 24, - TYPE_MAP = 25, -}; - -static_assert(TYPE_MAP < kRepeatedMask, "Invalid enum"); - -struct PROTOBUF_EXPORT FieldMetadata { - uint32_t offset; // offset of this field in the struct - uint32_t tag; // field * 8 + wire_type - // byte offset * 8 + bit_offset; - // if the high bit is set then this is the byte offset of the oneof_case - // for this field. - uint32_t has_offset; - uint32_t type; // the type of this field. - const void* ptr; // auxiliary data - - // From the serializer point of view each fundamental type can occur in - // 4 different ways. For simplicity we treat all combinations as a cartesion - // product although not all combinations are allowed. - enum FieldTypeClass { - kPresence, - kNoPresence, - kRepeated, - kPacked, - kOneOf, - kNumTypeClasses // must be last enum - }; - // C++ protobuf has 20 fundamental types, were we added Cord and StringPiece - // and also distinguish the same types if they have different wire format. - enum { - kCordType = 19, - kStringPieceType = 20, - kInlinedType = 21, - kNumTypes = 21, - kSpecial = kNumTypes * kNumTypeClasses, - }; - - static int CalculateType(int fundamental_type, FieldTypeClass type_class); -}; - -// TODO(ckennelly): Add a static assertion to ensure that these masks do not -// conflict with wiretypes. - -// ParseTableField is kept small to help simplify instructions for computing -// offsets, as we will always need this information to parse a field. -// Additional data, needed for some types, is stored in -// AuxiliaryParseTableField. -struct ParseTableField { - uint32_t offset; - // The presence_index ordinarily represents a has_bit index, but for fields - // inside a oneof it represents the index in _oneof_case_. - uint32_t presence_index; - unsigned char normal_wiretype; - unsigned char packed_wiretype; - - // processing_type is given by: - // (FieldDescriptor->type() << 1) | FieldDescriptor->is_packed() - unsigned char processing_type; - - unsigned char tag_size; -}; - -struct ParseTable; - -union AuxiliaryParseTableField { - typedef bool (*EnumValidator)(int); - - // Enums - struct enum_aux { - EnumValidator validator; - }; - enum_aux enums; - // Group, messages - struct message_aux { - // ExplicitlyInitialized<T> -> T requires a reinterpret_cast, which prevents - // the tables from being constructed as a constexpr. We use void to avoid - // the cast. - const void* default_message_void; - const MessageLite* default_message() const { - return static_cast<const MessageLite*>(default_message_void); - } - }; - message_aux messages; - // Strings - struct string_aux { - const void* default_ptr; - const char* field_name; - }; - string_aux strings; - - struct map_aux { - bool (*parse_map)(io::CodedInputStream*, void*); - }; - map_aux maps; - - AuxiliaryParseTableField() = default; - constexpr AuxiliaryParseTableField(AuxiliaryParseTableField::enum_aux e) - : enums(e) {} - constexpr AuxiliaryParseTableField(AuxiliaryParseTableField::message_aux m) - : messages(m) {} - constexpr AuxiliaryParseTableField(AuxiliaryParseTableField::string_aux s) - : strings(s) {} - constexpr AuxiliaryParseTableField(AuxiliaryParseTableField::map_aux m) - : maps(m) {} -}; - -struct ParseTable { - const ParseTableField* fields; - const AuxiliaryParseTableField* aux; - int max_field_number; - // TODO(ckennelly): Do something with this padding. - - // TODO(ckennelly): Vet these for sign extension. - int64_t has_bits_offset; - int64_t oneof_case_offset; - int64_t extension_offset; - int64_t arena_offset; - - // ExplicitlyInitialized<T> -> T requires a reinterpret_cast, which prevents - // the tables from being constructed as a constexpr. We use void to avoid - // the cast. - const void* default_instance_void; - const MessageLite* default_instance() const { - return static_cast<const MessageLite*>(default_instance_void); - } - - bool unknown_field_set; -}; - -static_assert(sizeof(ParseTableField) <= 16, "ParseTableField is too large"); -// The tables must be composed of POD components to ensure link-time -// initialization. -static_assert(std::is_standard_layout<ParseTableField>::value, ""); -static_assert(std::is_trivial<ParseTableField>::value, ""); -static_assert(std::is_standard_layout<AuxiliaryParseTableField>::value, ""); -static_assert(std::is_trivial<AuxiliaryParseTableField>::value, ""); -static_assert( - std::is_standard_layout<AuxiliaryParseTableField::enum_aux>::value, ""); -static_assert(std::is_trivial<AuxiliaryParseTableField::enum_aux>::value, ""); -static_assert( - std::is_standard_layout<AuxiliaryParseTableField::message_aux>::value, ""); -static_assert(std::is_trivial<AuxiliaryParseTableField::message_aux>::value, - ""); -static_assert( - std::is_standard_layout<AuxiliaryParseTableField::string_aux>::value, ""); -static_assert(std::is_trivial<AuxiliaryParseTableField::string_aux>::value, ""); -static_assert(std::is_standard_layout<ParseTable>::value, ""); -static_assert(std::is_trivial<ParseTable>::value, ""); - -// TODO(ckennelly): Consolidate these implementations into a single one, using -// dynamic dispatch to the appropriate unknown field handler. -bool MergePartialFromCodedStream(MessageLite* msg, const ParseTable& table, - io::CodedInputStream* input); -bool MergePartialFromCodedStreamLite(MessageLite* msg, const ParseTable& table, - io::CodedInputStream* input); - -template <typename Entry> -bool ParseMap(io::CodedInputStream* input, void* map_field) { - typedef typename MapEntryToMapField<Entry>::MapFieldType MapFieldType; - typedef Map<typename Entry::EntryKeyType, typename Entry::EntryValueType> - MapType; - typedef typename Entry::template Parser<MapFieldType, MapType> ParserType; - - ParserType parser(static_cast<MapFieldType*>(map_field)); - return WireFormatLite::ReadMessageNoVirtual(input, &parser); -} - -struct SerializationTable { - int num_fields; - const FieldMetadata* field_table; -}; - -PROTOBUF_EXPORT void SerializeInternal(const uint8_t* base, - const FieldMetadata* table, - int32_t num_fields, - io::CodedOutputStream* output); - -inline void TableSerialize(const MessageLite& msg, - const SerializationTable* table, - io::CodedOutputStream* output) { - const FieldMetadata* field_table = table->field_table; - int num_fields = table->num_fields - 1; - const uint8_t* base = reinterpret_cast<const uint8_t*>(&msg); - // TODO(gerbens) This skips the first test if we could use the fast - // array serialization path, we should make this - // int cached_size = - // *reinterpret_cast<const int32_t*>(base + field_table->offset); - // SerializeWithCachedSize(msg, field_table + 1, num_fields, cached_size, ...) - // But we keep conformance with the old way for now. - SerializeInternal(base, field_table + 1, num_fields, output); -} - -PROTOBUF_EXPORT uint8_t* SerializeInternalToArray(const uint8_t* base, - const FieldMetadata* table, - int32_t num_fields, - bool is_deterministic, - uint8_t* buffer); - -inline uint8_t* TableSerializeToArray(const MessageLite& msg, - const SerializationTable* table, - bool is_deterministic, uint8_t* buffer) { - const uint8_t* base = reinterpret_cast<const uint8_t*>(&msg); - const FieldMetadata* field_table = table->field_table + 1; - int num_fields = table->num_fields - 1; - return SerializeInternalToArray(base, field_table, num_fields, - is_deterministic, buffer); -} - -template <typename T> -struct CompareHelper { - bool operator()(const T& a, const T& b) const { return a < b; } -}; - -template <> -struct CompareHelper<ArenaStringPtr> { - bool operator()(const ArenaStringPtr& a, const ArenaStringPtr& b) const { - return a.Get() < b.Get(); - } -}; - -struct CompareMapKey { - template <typename T> - bool operator()(const MapEntryHelper<T>& a, - const MapEntryHelper<T>& b) const { - return Compare(a.key_, b.key_); - } - template <typename T> - bool Compare(const T& a, const T& b) const { - return CompareHelper<T>()(a, b); - } -}; - -template <typename MapFieldType, const SerializationTable* table> -void MapFieldSerializer(const uint8_t* base, uint32_t offset, uint32_t tag, - uint32_t has_offset, io::CodedOutputStream* output) { - typedef MapEntryHelper<typename MapFieldType::EntryTypeTrait> Entry; - typedef typename MapFieldType::MapType::const_iterator Iter; - - const MapFieldType& map_field = - *reinterpret_cast<const MapFieldType*>(base + offset); - const SerializationTable* t = - table + - has_offset; // has_offset is overloaded for maps to mean table offset - if (!output->IsSerializationDeterministic()) { - for (Iter it = map_field.GetMap().begin(); it != map_field.GetMap().end(); - ++it) { - Entry map_entry(*it); - output->WriteVarint32(tag); - output->WriteVarint32(map_entry._cached_size_); - SerializeInternal(reinterpret_cast<const uint8_t*>(&map_entry), - t->field_table, t->num_fields, output); - } - } else { - std::vector<Entry> v; - for (Iter it = map_field.GetMap().begin(); it != map_field.GetMap().end(); - ++it) { - v.push_back(Entry(*it)); - } - std::sort(v.begin(), v.end(), CompareMapKey()); - for (int i = 0; i < v.size(); i++) { - output->WriteVarint32(tag); - output->WriteVarint32(v[i]._cached_size_); - SerializeInternal(reinterpret_cast<const uint8_t*>(&v[i]), t->field_table, - t->num_fields, output); - } - } -} - -} // namespace internal -} // namespace protobuf -} // namespace google - -#include <thirdparty/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_H__ diff --git a/r5dev/thirdparty/protobuf/generated_message_table_driven_lite.cc b/r5dev/thirdparty/protobuf/generated_message_table_driven_lite.cc deleted file mode 100644 index 2f4535ca..00000000 --- a/r5dev/thirdparty/protobuf/generated_message_table_driven_lite.cc +++ /dev/null @@ -1,106 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include <thirdparty/protobuf/generated_message_table_driven_lite.h> - -#include <type_traits> - -#include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> -#include <thirdparty/protobuf/metadata_lite.h> -#include <thirdparty/protobuf/repeated_field.h> -#include <thirdparty/protobuf/wire_format_lite.h> - -namespace google { -namespace protobuf { -namespace internal { - -namespace { - -std::string* MutableUnknownFields(MessageLite* msg, int64_t arena_offset) { - return Raw<InternalMetadata>(msg, arena_offset) - ->mutable_unknown_fields<std::string>(); -} - -struct UnknownFieldHandlerLite { - // TODO(mvels): consider renaming UnknownFieldHandler to (TableDrivenTraits?), - // and conflating InternalMetaData into it, simplifying the template. - static constexpr bool IsLite() { return true; } - - static bool Skip(MessageLite* msg, const ParseTable& table, - io::CodedInputStream* input, int tag) { - GOOGLE_DCHECK(!table.unknown_field_set); - io::StringOutputStream unknown_fields_string( - MutableUnknownFields(msg, table.arena_offset)); - io::CodedOutputStream unknown_fields_stream(&unknown_fields_string, false); - - return internal::WireFormatLite::SkipField(input, tag, - &unknown_fields_stream); - } - - static void Varint(MessageLite* msg, const ParseTable& table, int tag, - int value) { - GOOGLE_DCHECK(!table.unknown_field_set); - - io::StringOutputStream unknown_fields_string( - MutableUnknownFields(msg, table.arena_offset)); - io::CodedOutputStream unknown_fields_stream(&unknown_fields_string, false); - unknown_fields_stream.WriteVarint32(tag); - unknown_fields_stream.WriteVarint32(value); - } - - static bool ParseExtension(MessageLite* msg, const ParseTable& table, - io::CodedInputStream* input, int tag) { - ExtensionSet* extensions = GetExtensionSet(msg, table.extension_offset); - if (extensions == nullptr) { - return false; - } - - const MessageLite* prototype = table.default_instance(); - - GOOGLE_DCHECK(!table.unknown_field_set); - io::StringOutputStream unknown_fields_string( - MutableUnknownFields(msg, table.arena_offset)); - io::CodedOutputStream unknown_fields_stream(&unknown_fields_string, false); - return extensions->ParseField(tag, input, prototype, - &unknown_fields_stream); - } -}; - -} // namespace - -bool MergePartialFromCodedStreamLite(MessageLite* msg, const ParseTable& table, - io::CodedInputStream* input) { - return MergePartialFromCodedStreamImpl<UnknownFieldHandlerLite>(msg, table, - input); -} - -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/r5dev/thirdparty/protobuf/generated_message_table_driven_lite.h b/r5dev/thirdparty/protobuf/generated_message_table_driven_lite.h deleted file mode 100644 index 74fb5406..00000000 --- a/r5dev/thirdparty/protobuf/generated_message_table_driven_lite.h +++ /dev/null @@ -1,874 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__ -#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__ - -#include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> -#include <thirdparty/protobuf/extension_set.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> -#include <thirdparty/protobuf/implicit_weak_message.h> -#include <thirdparty/protobuf/inlined_string_field.h> -#include <thirdparty/protobuf/repeated_field.h> -#include <thirdparty/protobuf/wire_format_lite.h> -#include <type_traits> - - -#include <thirdparty/protobuf/port_def.inc> - -namespace google { -namespace protobuf { -namespace internal { - - -enum StringType { - StringType_STRING = 0, - StringType_INLINED = 3 -}; - -// Logically a superset of StringType, consisting of all field types that -// require special initialization. -enum ProcessingType { - ProcessingType_STRING = 0, - ProcessingType_CORD = 1, - ProcessingType_STRING_PIECE = 2, - ProcessingType_INLINED = 3, - ProcessingType_MESSAGE = 4, -}; - -enum Cardinality { - Cardinality_SINGULAR = 0, - Cardinality_REPEATED = 1, - Cardinality_ONEOF = 3 -}; - -template <typename Type> -inline Type* Raw(MessageLite* msg, int64_t offset) { - return reinterpret_cast<Type*>(reinterpret_cast<uint8_t*>(msg) + offset); -} - -template <typename Type> -inline const Type* Raw(const MessageLite* msg, int64_t offset) { - return reinterpret_cast<const Type*>(reinterpret_cast<const uint8_t*>(msg) + - offset); -} - -inline ExtensionSet* GetExtensionSet(MessageLite* msg, - int64_t extension_offset) { - if (extension_offset == -1) { - return nullptr; - } - - return Raw<ExtensionSet>(msg, extension_offset); -} - -template <typename Type> -inline Type* AddField(MessageLite* msg, int64_t offset) { - static_assert(std::is_trivial<Type>::value || - std::is_same<Type, InlinedStringField>::value, - "Do not assign"); - - RepeatedField<Type>* repeated = Raw<RepeatedField<Type>>(msg, offset); - return repeated->Add(); -} - -template <> -inline std::string* AddField<std::string>(MessageLite* msg, int64_t offset) { - RepeatedPtrField<std::string>* repeated = - Raw<RepeatedPtrField<std::string>>(msg, offset); - return repeated->Add(); -} - - -template <typename Type> -inline void AddField(MessageLite* msg, int64_t offset, Type value) { - static_assert(std::is_trivial<Type>::value, "Do not assign"); - *AddField<Type>(msg, offset) = value; -} - -inline void SetBit(uint32_t* has_bits, uint32_t has_bit_index) { - GOOGLE_DCHECK(has_bits != nullptr); - - uint32_t mask = static_cast<uint32_t>(1u) << (has_bit_index % 32); - has_bits[has_bit_index / 32u] |= mask; -} - -template <typename Type> -inline Type* MutableField(MessageLite* msg, uint32_t* has_bits, - uint32_t has_bit_index, int64_t offset) { - SetBit(has_bits, has_bit_index); - return Raw<Type>(msg, offset); -} - -template <typename Type> -inline void SetField(MessageLite* msg, uint32_t* has_bits, - uint32_t has_bit_index, int64_t offset, Type value) { - static_assert(std::is_trivial<Type>::value, "Do not assign"); - *MutableField<Type>(msg, has_bits, has_bit_index, offset) = value; -} - -template <typename Type> -inline void SetOneofField(MessageLite* msg, uint32_t* oneof_case, - uint32_t oneof_case_index, int64_t offset, - int field_number, Type value) { - oneof_case[oneof_case_index] = field_number; - *Raw<Type>(msg, offset) = value; -} - -// Clears a oneof field. The field argument should correspond to the particular -// field that is currently set in the oneof. -inline void ClearOneofField(const ParseTableField& field, Arena* arena, - MessageLite* msg) { - switch (field.processing_type & kTypeMask) { - case WireFormatLite::TYPE_MESSAGE: - if (arena == nullptr) { - delete *Raw<MessageLite*>(msg, field.offset); - } - break; - - case WireFormatLite::TYPE_STRING: - case WireFormatLite::TYPE_BYTES: - Raw<ArenaStringPtr>(msg, field.offset) - ->Destroy(ArenaStringPtr::EmptyDefault{}, arena); - break; - - case TYPE_STRING_INLINED: - case TYPE_BYTES_INLINED: - Raw<InlinedStringField>(msg, field.offset)->DestroyNoArena(nullptr); - break; - - default: - // No cleanup needed. - break; - } -} - -// Clears and reinitializes a oneof field as necessary, in preparation for -// parsing a new value with type field_type and field number field_number. -// -// Note: the oneof_case argument should point directly to the _oneof_case_ -// element corresponding to this particular oneof, not to the beginning of the -// _oneof_case_ array. -template <ProcessingType field_type> -inline void ResetOneofField(const ParseTable& table, int field_number, - Arena* arena, MessageLite* msg, - uint32_t* oneof_case, int64_t offset, - const void* default_ptr) { - if (static_cast<int64_t>(*oneof_case) == field_number) { - // The oneof is already set to the right type, so there is no need to clear - // it. - return; - } - - if (*oneof_case != 0) { - ClearOneofField(table.fields[*oneof_case], arena, msg); - } - *oneof_case = field_number; - - switch (field_type) { - case ProcessingType_STRING: - Raw<ArenaStringPtr>(msg, offset) - ->UnsafeSetDefault(static_cast<const std::string*>(default_ptr)); - break; - case ProcessingType_INLINED: - new (Raw<InlinedStringField>(msg, offset)) - InlinedStringField(*static_cast<const std::string*>(default_ptr)); - break; - case ProcessingType_MESSAGE: - MessageLite** submessage = Raw<MessageLite*>(msg, offset); - const MessageLite* prototype = - table.aux[field_number].messages.default_message(); - *submessage = prototype->New(arena); - break; - } -} - -template <typename UnknownFieldHandler, Cardinality cardinality, - bool is_string_type, StringType ctype> -static inline bool HandleString(io::CodedInputStream* input, MessageLite* msg, - Arena* arena, uint32_t* has_bits, - uint32_t has_bit_index, int64_t offset, - const void* default_ptr, - const char* field_name) { - StringPiece utf8_string_data; -#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - constexpr bool kValidateUtf8 = is_string_type; -#else - constexpr bool kValidateUtf8 = false; -#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - - switch (ctype) { - case StringType_INLINED: { - std::string* value = nullptr; - switch (cardinality) { - case Cardinality_SINGULAR: { - // TODO(ckennelly): Is this optimal? - InlinedStringField* s = MutableField<InlinedStringField>( - msg, has_bits, has_bit_index, offset); - value = s->UnsafeMutablePointer(); - } break; - case Cardinality_REPEATED: { - value = AddField<std::string>(msg, offset); - } break; - case Cardinality_ONEOF: { - InlinedStringField* s = Raw<InlinedStringField>(msg, offset); - value = s->UnsafeMutablePointer(); - } break; - } - GOOGLE_DCHECK(value != nullptr); - if (PROTOBUF_PREDICT_FALSE(!WireFormatLite::ReadString(input, value))) { - return false; - } - utf8_string_data = *value; - break; - } - case StringType_STRING: { - switch (cardinality) { - case Cardinality_SINGULAR: { - ArenaStringPtr* field = MutableField<ArenaStringPtr>( - msg, has_bits, has_bit_index, offset); - std::string* value = field->MutableNoCopy( - static_cast<const std::string*>(default_ptr), arena); - if (PROTOBUF_PREDICT_FALSE( - !WireFormatLite::ReadString(input, value))) { - return false; - } - utf8_string_data = field->Get(); - } break; - case Cardinality_REPEATED: { - std::string* value = AddField<std::string>(msg, offset); - if (PROTOBUF_PREDICT_FALSE( - !WireFormatLite::ReadString(input, value))) { - return false; - } - utf8_string_data = *value; - } break; - case Cardinality_ONEOF: { - ArenaStringPtr* field = Raw<ArenaStringPtr>(msg, offset); - std::string* value = field->MutableNoCopy( - static_cast<const std::string*>(default_ptr), arena); - if (PROTOBUF_PREDICT_FALSE( - !WireFormatLite::ReadString(input, value))) { - return false; - } - utf8_string_data = field->Get(); - } break; - default: - PROTOBUF_ASSUME(false); - } - break; - } - default: - PROTOBUF_ASSUME(false); - } - - if (kValidateUtf8) { - // TODO(b/118759213): fail if proto3 - WireFormatLite::VerifyUtf8String(utf8_string_data.data(), - utf8_string_data.length(), - WireFormatLite::PARSE, field_name); - } - return true; -} - -template <typename UnknownFieldHandler, Cardinality cardinality> -inline bool HandleEnum(const ParseTable& table, io::CodedInputStream* input, - MessageLite* msg, uint32_t* presence, - uint32_t presence_index, int64_t offset, uint32_t tag, - int field_number) { - int value; - if (PROTOBUF_PREDICT_FALSE( - (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>( - input, &value)))) { - return false; - } - - AuxiliaryParseTableField::EnumValidator validator = - table.aux[field_number].enums.validator; - if (validator == nullptr || validator(value)) { - switch (cardinality) { - case Cardinality_SINGULAR: - SetField(msg, presence, presence_index, offset, value); - break; - case Cardinality_REPEATED: - AddField(msg, offset, value); - break; - case Cardinality_ONEOF: - ClearOneofField(table.fields[presence[presence_index]], msg->GetArena(), - msg); - SetOneofField(msg, presence, presence_index, offset, field_number, - value); - break; - default: - PROTOBUF_ASSUME(false); - } - } else { - UnknownFieldHandler::Varint(msg, table, tag, value); - } - - return true; -} - -// RepeatedMessageTypeHandler allows us to operate on RepeatedPtrField fields -// without instantiating the specific template. -class RepeatedMessageTypeHandler { - public: - typedef MessageLite Type; - typedef MessageLite WeakType; - static Arena* GetArena(Type* t) { return t->GetArena(); } - static inline Type* NewFromPrototype(const Type* prototype, - Arena* arena = nullptr) { - return prototype->New(arena); - } - static void Delete(Type* t, Arena* arena = nullptr) { - if (arena == nullptr) { - delete t; - } - } -}; - -class MergePartialFromCodedStreamHelper { - public: - static MessageLite* Add(RepeatedPtrFieldBase* field, - const MessageLite* prototype) { - return field->Add<RepeatedMessageTypeHandler>( - const_cast<MessageLite*>(prototype)); - } -}; - -template <typename UnknownFieldHandler, uint32_t kMaxTag> -bool MergePartialFromCodedStreamInlined(MessageLite* msg, - const ParseTable& table, - io::CodedInputStream* input) { - // We require that has_bits are present, as to avoid having to check for them - // for every field. - // - // TODO(ckennelly): Make this a compile-time parameter with templates. - GOOGLE_DCHECK_GE(table.has_bits_offset, 0); - uint32_t* has_bits = Raw<uint32_t>(msg, table.has_bits_offset); - GOOGLE_DCHECK(has_bits != nullptr); - - while (true) { - uint32_t tag = input->ReadTagWithCutoffNoLastTag(kMaxTag).first; - const WireFormatLite::WireType wire_type = - WireFormatLite::GetTagWireType(tag); - const int field_number = WireFormatLite::GetTagFieldNumber(tag); - - if (PROTOBUF_PREDICT_FALSE(field_number > table.max_field_number)) { - // check for possible extensions - if (UnknownFieldHandler::ParseExtension(msg, table, input, tag)) { - // successfully parsed - continue; - } - - if (PROTOBUF_PREDICT_FALSE( - !UnknownFieldHandler::Skip(msg, table, input, tag))) { - return false; - } - - continue; - } - - // We implicitly verify that data points to a valid field as we check the - // wire types. Entries in table.fields[i] that do not correspond to valid - // field numbers have their normal_wiretype and packed_wiretype fields set - // with the kInvalidMask value. As wire_type cannot take on that value, we - // will never match. - const ParseTableField* data = table.fields + field_number; - - // TODO(ckennelly): Avoid sign extension - const int64_t presence_index = data->presence_index; - const int64_t offset = data->offset; - const unsigned char processing_type = data->processing_type; - - if (data->normal_wiretype == static_cast<unsigned char>(wire_type)) { - switch (processing_type) { -#define HANDLE_TYPE(TYPE, CPPTYPE) \ - case (WireFormatLite::TYPE_##TYPE): { \ - CPPTYPE value; \ - if (PROTOBUF_PREDICT_FALSE( \ - (!WireFormatLite::ReadPrimitive< \ - CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \ - return false; \ - } \ - SetField(msg, has_bits, presence_index, offset, value); \ - break; \ - } \ - case (WireFormatLite::TYPE_##TYPE) | kRepeatedMask: { \ - RepeatedField<CPPTYPE>* values = Raw<RepeatedField<CPPTYPE>>(msg, offset); \ - if (PROTOBUF_PREDICT_FALSE((!WireFormatLite::ReadRepeatedPrimitive< \ - CPPTYPE, WireFormatLite::TYPE_##TYPE>( \ - data->tag_size, tag, input, values)))) { \ - return false; \ - } \ - break; \ - } \ - case (WireFormatLite::TYPE_##TYPE) | kOneofMask: { \ - uint32_t* oneof_case = Raw<uint32_t>(msg, table.oneof_case_offset); \ - CPPTYPE value; \ - if (PROTOBUF_PREDICT_FALSE( \ - (!WireFormatLite::ReadPrimitive< \ - CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)))) { \ - return false; \ - } \ - ClearOneofField(table.fields[oneof_case[presence_index]], msg->GetArena(), \ - msg); \ - SetOneofField(msg, oneof_case, presence_index, offset, field_number, \ - value); \ - break; \ - } - - HANDLE_TYPE(INT32, int32_t) - HANDLE_TYPE(INT64, int64_t) - HANDLE_TYPE(SINT32, int32_t) - HANDLE_TYPE(SINT64, int64_t) - HANDLE_TYPE(UINT32, uint32_t) - HANDLE_TYPE(UINT64, uint64_t) - - HANDLE_TYPE(FIXED32, uint32_t) - HANDLE_TYPE(FIXED64, uint64_t) - HANDLE_TYPE(SFIXED32, int32_t) - HANDLE_TYPE(SFIXED64, int64_t) - - HANDLE_TYPE(FLOAT, float) - HANDLE_TYPE(DOUBLE, double) - - HANDLE_TYPE(BOOL, bool) -#undef HANDLE_TYPE - case WireFormatLite::TYPE_BYTES: -#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - case WireFormatLite::TYPE_STRING: -#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - { - Arena* const arena = msg->GetArena(); - const void* default_ptr = table.aux[field_number].strings.default_ptr; - - if (PROTOBUF_PREDICT_FALSE( - (!HandleString<UnknownFieldHandler, Cardinality_SINGULAR, - false, StringType_STRING>( - input, msg, arena, has_bits, presence_index, offset, - default_ptr, nullptr)))) { - return false; - } - break; - } - case TYPE_BYTES_INLINED: -#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - case TYPE_STRING_INLINED: -#endif // !GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - { - Arena* const arena = msg->GetArena(); - const void* default_ptr = table.aux[field_number].strings.default_ptr; - - if (PROTOBUF_PREDICT_FALSE( - (!HandleString<UnknownFieldHandler, Cardinality_SINGULAR, - false, StringType_INLINED>( - input, msg, arena, has_bits, presence_index, offset, - default_ptr, nullptr)))) { - return false; - } - break; - } - case WireFormatLite::TYPE_BYTES | kOneofMask: -#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - case WireFormatLite::TYPE_STRING | kOneofMask: -#endif // !GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - { - Arena* const arena = msg->GetArena(); - uint32_t* oneof_case = Raw<uint32_t>(msg, table.oneof_case_offset); - const void* default_ptr = table.aux[field_number].strings.default_ptr; - - ResetOneofField<ProcessingType_STRING>( - table, field_number, arena, msg, oneof_case + presence_index, - offset, default_ptr); - - if (PROTOBUF_PREDICT_FALSE( - (!HandleString<UnknownFieldHandler, Cardinality_ONEOF, false, - StringType_STRING>(input, msg, arena, has_bits, - presence_index, offset, - default_ptr, nullptr)))) { - return false; - } - break; - } - case (WireFormatLite::TYPE_BYTES) | kRepeatedMask: - case TYPE_BYTES_INLINED | kRepeatedMask: -#ifndef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - case (WireFormatLite::TYPE_STRING) | kRepeatedMask: - case TYPE_STRING_INLINED | kRepeatedMask: -#endif // !GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - { - Arena* const arena = msg->GetArena(); - const void* default_ptr = table.aux[field_number].strings.default_ptr; - - if (PROTOBUF_PREDICT_FALSE( - (!HandleString<UnknownFieldHandler, Cardinality_REPEATED, - false, StringType_STRING>( - input, msg, arena, has_bits, presence_index, offset, - default_ptr, nullptr)))) { - return false; - } - break; - } -#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - case (WireFormatLite::TYPE_STRING): { - Arena* const arena = msg->GetArena(); - const void* default_ptr = table.aux[field_number].strings.default_ptr; - const char* field_name = table.aux[field_number].strings.field_name; - - if (PROTOBUF_PREDICT_FALSE( - (!HandleString<UnknownFieldHandler, Cardinality_SINGULAR, - true, StringType_STRING>( - input, msg, arena, has_bits, presence_index, offset, - default_ptr, field_name)))) { - return false; - } - break; - } - case TYPE_STRING_INLINED | kRepeatedMask: - case (WireFormatLite::TYPE_STRING) | kRepeatedMask: { - Arena* const arena = msg->GetArena(); - const void* default_ptr = table.aux[field_number].strings.default_ptr; - const char* field_name = table.aux[field_number].strings.field_name; - - if (PROTOBUF_PREDICT_FALSE( - (!HandleString<UnknownFieldHandler, Cardinality_REPEATED, - true, StringType_STRING>( - input, msg, arena, has_bits, presence_index, offset, - default_ptr, field_name)))) { - return false; - } - break; - } - case (WireFormatLite::TYPE_STRING) | kOneofMask: { - Arena* const arena = msg->GetArena(); - uint32_t* oneof_case = Raw<uint32_t>(msg, table.oneof_case_offset); - const void* default_ptr = table.aux[field_number].strings.default_ptr; - const char* field_name = table.aux[field_number].strings.field_name; - - ResetOneofField<ProcessingType_STRING>( - table, field_number, arena, msg, oneof_case + presence_index, - offset, default_ptr); - - if (PROTOBUF_PREDICT_FALSE( - (!HandleString<UnknownFieldHandler, Cardinality_ONEOF, true, - StringType_STRING>( - input, msg, arena, has_bits, presence_index, offset, - default_ptr, field_name)))) { - return false; - } - break; - } -#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - case WireFormatLite::TYPE_ENUM: { - if (PROTOBUF_PREDICT_FALSE( - (!HandleEnum<UnknownFieldHandler, Cardinality_SINGULAR>( - table, input, msg, has_bits, presence_index, offset, tag, - field_number)))) { - return false; - } - break; - } - case WireFormatLite::TYPE_ENUM | kRepeatedMask: { - if (PROTOBUF_PREDICT_FALSE( - (!HandleEnum<UnknownFieldHandler, Cardinality_REPEATED>( - table, input, msg, has_bits, presence_index, offset, tag, - field_number)))) { - return false; - } - break; - } - case WireFormatLite::TYPE_ENUM | kOneofMask: { - uint32_t* oneof_case = Raw<uint32_t>(msg, table.oneof_case_offset); - if (PROTOBUF_PREDICT_FALSE( - (!HandleEnum<UnknownFieldHandler, Cardinality_ONEOF>( - table, input, msg, oneof_case, presence_index, offset, - tag, field_number)))) { - return false; - } - break; - } - case WireFormatLite::TYPE_GROUP: { - MessageLite** submsg_holder = - MutableField<MessageLite*>(msg, has_bits, presence_index, offset); - MessageLite* submsg = *submsg_holder; - - if (submsg == nullptr) { - Arena* const arena = msg->GetArena(); - const MessageLite* prototype = - table.aux[field_number].messages.default_message(); - submsg = prototype->New(arena); - *submsg_holder = submsg; - } - - if (PROTOBUF_PREDICT_FALSE( - !WireFormatLite::ReadGroup(field_number, input, submsg))) { - return false; - } - - break; - } - case WireFormatLite::TYPE_GROUP | kRepeatedMask: { - RepeatedPtrFieldBase* field = Raw<RepeatedPtrFieldBase>(msg, offset); - const MessageLite* prototype = - table.aux[field_number].messages.default_message(); - GOOGLE_DCHECK(prototype != nullptr); - - MessageLite* submsg = - MergePartialFromCodedStreamHelper::Add(field, prototype); - - if (PROTOBUF_PREDICT_FALSE( - !WireFormatLite::ReadGroup(field_number, input, submsg))) { - return false; - } - - break; - } - case WireFormatLite::TYPE_MESSAGE: { - MessageLite** submsg_holder = - MutableField<MessageLite*>(msg, has_bits, presence_index, offset); - MessageLite* submsg = *submsg_holder; - - if (submsg == nullptr) { - Arena* const arena = msg->GetArena(); - const MessageLite* prototype = - table.aux[field_number].messages.default_message(); - if (prototype == nullptr) { - prototype = ImplicitWeakMessage::default_instance(); - } - submsg = prototype->New(arena); - *submsg_holder = submsg; - } - - if (PROTOBUF_PREDICT_FALSE( - !WireFormatLite::ReadMessage(input, submsg))) { - return false; - } - - break; - } - // TODO(ckennelly): Adapt ReadMessageNoVirtualNoRecursionDepth and - // manage input->IncrementRecursionDepth() here. - case WireFormatLite::TYPE_MESSAGE | kRepeatedMask: { - RepeatedPtrFieldBase* field = Raw<RepeatedPtrFieldBase>(msg, offset); - const MessageLite* prototype = - table.aux[field_number].messages.default_message(); - if (prototype == nullptr) { - prototype = ImplicitWeakMessage::default_instance(); - } - - MessageLite* submsg = - MergePartialFromCodedStreamHelper::Add(field, prototype); - - if (PROTOBUF_PREDICT_FALSE( - !WireFormatLite::ReadMessage(input, submsg))) { - return false; - } - - break; - } - case WireFormatLite::TYPE_MESSAGE | kOneofMask: { - Arena* const arena = msg->GetArena(); - uint32_t* oneof_case = Raw<uint32_t>(msg, table.oneof_case_offset); - MessageLite** submsg_holder = Raw<MessageLite*>(msg, offset); - ResetOneofField<ProcessingType_MESSAGE>( - table, field_number, arena, msg, oneof_case + presence_index, - offset, nullptr); - MessageLite* submsg = *submsg_holder; - - if (PROTOBUF_PREDICT_FALSE( - !WireFormatLite::ReadMessage(input, submsg))) { - return false; - } - - break; - } -#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - case TYPE_STRING_INLINED: { - Arena* const arena = msg->GetArena(); - const void* default_ptr = table.aux[field_number].strings.default_ptr; - const char* field_name = table.aux[field_number].strings.field_name; - - if (PROTOBUF_PREDICT_FALSE( - (!HandleString<UnknownFieldHandler, Cardinality_SINGULAR, - true, StringType_INLINED>( - input, msg, arena, has_bits, presence_index, offset, - default_ptr, field_name)))) { - return false; - } - break; - } -#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - case TYPE_MAP: { - if (PROTOBUF_PREDICT_FALSE(!(*table.aux[field_number].maps.parse_map)( - input, Raw<void>(msg, offset)))) { - return false; - } - break; - } - case 0: { - // Done. - input->SetLastTag(tag); - return true; - } - default: - PROTOBUF_ASSUME(false); - } - } else if (data->packed_wiretype == static_cast<unsigned char>(wire_type)) { - // Non-packable fields have their packed_wiretype masked with - // kNotPackedMask, which is impossible to match here. - GOOGLE_DCHECK(processing_type & kRepeatedMask); - GOOGLE_DCHECK_NE(processing_type, kRepeatedMask); - GOOGLE_DCHECK_EQ(0, processing_type & kOneofMask); - - GOOGLE_DCHECK_NE(TYPE_BYTES_INLINED | kRepeatedMask, processing_type); - GOOGLE_DCHECK_NE(TYPE_STRING_INLINED | kRepeatedMask, processing_type); - - // Mask out kRepeatedMask bit, allowing the jump table to be smaller. - switch (static_cast<WireFormatLite::FieldType>(processing_type ^ - kRepeatedMask)) { -#define HANDLE_PACKED_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD) \ - case WireFormatLite::TYPE_##TYPE: { \ - RepeatedField<CPPTYPE>* values = Raw<RepeatedField<CPPTYPE>>(msg, offset); \ - if (PROTOBUF_PREDICT_FALSE( \ - (!WireFormatLite::ReadPackedPrimitive< \ - CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, values)))) { \ - return false; \ - } \ - break; \ - } - - HANDLE_PACKED_TYPE(INT32, int32_t, Int32) - HANDLE_PACKED_TYPE(INT64, int64_t, Int64) - HANDLE_PACKED_TYPE(SINT32, int32_t, Int32) - HANDLE_PACKED_TYPE(SINT64, int64_t, Int64) - HANDLE_PACKED_TYPE(UINT32, uint32_t, UInt32) - HANDLE_PACKED_TYPE(UINT64, uint64_t, UInt64) - - HANDLE_PACKED_TYPE(FIXED32, uint32_t, UInt32) - HANDLE_PACKED_TYPE(FIXED64, uint64_t, UInt64) - HANDLE_PACKED_TYPE(SFIXED32, int32_t, Int32) - HANDLE_PACKED_TYPE(SFIXED64, int64_t, Int64) - - HANDLE_PACKED_TYPE(FLOAT, float, Float) - HANDLE_PACKED_TYPE(DOUBLE, double, Double) - - HANDLE_PACKED_TYPE(BOOL, bool, Bool) -#undef HANDLE_PACKED_TYPE - case WireFormatLite::TYPE_ENUM: { - // To avoid unnecessarily calling MutableUnknownFields (which mutates - // InternalMetadata) when all inputs in the repeated series - // are valid, we implement our own parser rather than call - // WireFormat::ReadPackedEnumPreserveUnknowns. - uint32_t length; - if (PROTOBUF_PREDICT_FALSE(!input->ReadVarint32(&length))) { - return false; - } - - AuxiliaryParseTableField::EnumValidator validator = - table.aux[field_number].enums.validator; - RepeatedField<int>* values = Raw<RepeatedField<int>>(msg, offset); - - io::CodedInputStream::Limit limit = input->PushLimit(length); - while (input->BytesUntilLimit() > 0) { - int value; - if (PROTOBUF_PREDICT_FALSE( - (!WireFormatLite::ReadPrimitive< - int, WireFormatLite::TYPE_ENUM>(input, &value)))) { - return false; - } - - if (validator == nullptr || validator(value)) { - values->Add(value); - } else { - // TODO(ckennelly): Consider caching here. - UnknownFieldHandler::Varint(msg, table, tag, value); - } - } - input->PopLimit(limit); - - break; - } - case WireFormatLite::TYPE_STRING: - case WireFormatLite::TYPE_GROUP: - case WireFormatLite::TYPE_MESSAGE: - case WireFormatLite::TYPE_BYTES: - GOOGLE_DCHECK(false); - return false; - default: - PROTOBUF_ASSUME(false); - } - } else { - if (wire_type == WireFormatLite::WIRETYPE_END_GROUP) { - // Must be the end of the message. - input->SetLastTag(tag); - return true; - } - - // check for possible extensions - if (UnknownFieldHandler::ParseExtension(msg, table, input, tag)) { - // successfully parsed - continue; - } - - // process unknown field. - if (PROTOBUF_PREDICT_FALSE( - !UnknownFieldHandler::Skip(msg, table, input, tag))) { - return false; - } - } - } -} // NOLINT(readability/fn_size) - -template <typename UnknownFieldHandler> -bool MergePartialFromCodedStreamImpl(MessageLite* msg, const ParseTable& table, - io::CodedInputStream* input) { - // The main beneficial cutoff values are 1 and 2 byte tags. - // Instantiate calls with the appropriate upper tag range - if (table.max_field_number <= (0x7F >> 3)) { - return MergePartialFromCodedStreamInlined<UnknownFieldHandler, 0x7F>( - msg, table, input); - } else if (table.max_field_number <= (0x3FFF >> 3)) { - return MergePartialFromCodedStreamInlined<UnknownFieldHandler, 0x3FFF>( - msg, table, input); - } else { - return MergePartialFromCodedStreamInlined< - UnknownFieldHandler, std::numeric_limits<uint32_t>::max()>(msg, table, - input); - } -} - -} // namespace internal -} // namespace protobuf -} // namespace google - -#include <thirdparty/protobuf/port_undef.inc> - -#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TABLE_DRIVEN_LITE_H__ diff --git a/r5dev/thirdparty/protobuf/generated_message_tctable_decl.h b/r5dev/thirdparty/protobuf/generated_message_tctable_decl.h index 8f82e749..7f47803f 100644 --- a/r5dev/thirdparty/protobuf/generated_message_tctable_decl.h +++ b/r5dev/thirdparty/protobuf/generated_message_tctable_decl.h @@ -35,11 +35,13 @@ #ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_DECL_H__ #define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_DECL_H__ +#include <array> +#include <cstddef> #include <cstdint> #include <type_traits> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/message_lite.h> +#include <thirdparty/protobuf/parse_context.h> // Must come last: #include <thirdparty/protobuf/port_def.inc> @@ -51,17 +53,53 @@ namespace internal { // Additional information about this field: struct TcFieldData { constexpr TcFieldData() : data(0) {} - constexpr TcFieldData(uint16_t coded_tag, uint8_t hasbit_idx, uint16_t offset) - : data(static_cast<uint64_t>(offset) << 48 | - static_cast<uint64_t>(hasbit_idx) << 16 | coded_tag) {} + + // Fast table entry constructor: + constexpr TcFieldData(uint16_t coded_tag, uint8_t hasbit_idx, uint8_t aux_idx, + uint16_t offset) + : data(uint64_t{offset} << 48 | // + uint64_t{aux_idx} << 24 | // + uint64_t{hasbit_idx} << 16 | // + uint64_t{coded_tag}) {} + + // Fields used in fast table parsing: + // + // Bit: + // +-----------+-------------------+ + // |63 .. 32|31 .. 0| + // +---------------+---------------+ + // : . : . : . 16|=======| [16] coded_tag() + // : . : . : 24|===| . : [ 8] hasbit_idx() + // : . : . 32|===| : . : [ 8] aux_idx() + // : . 48:---.---: . : . : [16] (unused) + // |=======| . : . : . : [16] offset() + // +-----------+-------------------+ + // |63 .. 32|31 .. 0| + // +---------------+---------------+ template <typename TagType = uint16_t> TagType coded_tag() const { return static_cast<TagType>(data); } uint8_t hasbit_idx() const { return static_cast<uint8_t>(data >> 16); } + uint8_t aux_idx() const { return static_cast<uint8_t>(data >> 24); } uint16_t offset() const { return static_cast<uint16_t>(data >> 48); } + // Fields used in mini table parsing: + // + // Bit: + // +-----------+-------------------+ + // |63 .. 32|31 .. 0| + // +---------------+---------------+ + // : . : . |===============| [32] tag() (decoded) + // |===============| . : . : [32] entry_offset() + // +-----------+-------------------+ + // |63 .. 32|31 .. 0| + // +---------------+---------------+ + + uint32_t tag() const { return static_cast<uint32_t>(data); } + uint32_t entry_offset() const { return static_cast<uint32_t>(data >> 32); } + uint64_t data; }; @@ -70,6 +108,12 @@ struct TcParseTableBase; // TailCallParseFunc is the function pointer type used in the tailcall table. typedef const char* (*TailCallParseFunc)(PROTOBUF_TC_PARAM_DECL); +namespace field_layout { +struct Offset { + uint32_t off; +}; +} // namespace field_layout + #if defined(_MSC_VER) && !defined(_WIN64) #pragma warning(push) // TcParseTableBase is intentionally overaligned on 32 bit targets. @@ -83,14 +127,49 @@ struct alignas(uint64_t) TcParseTableBase { uint16_t extension_offset; uint32_t extension_range_low; uint32_t extension_range_high; + uint32_t max_field_number; uint8_t fast_idx_mask; - uint8_t reserved; - uint16_t num_fields; + uint16_t lookup_table_offset; + uint32_t skipmap32; + uint32_t field_entries_offset; + uint16_t num_field_entries; + + uint16_t num_aux_entries; + uint32_t aux_offset; + const MessageLite* default_instance; // Handler for fields which are not handled by table dispatch. TailCallParseFunc fallback; + // This constructor exactly follows the field layout, so it's technically + // not necessary. However, it makes it much much easier to add or re-arrange + // fields, because it can be overloaded with an additional constructor, + // temporarily allowing both old and new protocol buffer headers to be + // compiled. + constexpr TcParseTableBase( + uint16_t has_bits_offset, uint16_t extension_offset, + uint32_t extension_range_low, uint32_t extension_range_high, + uint32_t max_field_number, uint8_t fast_idx_mask, + uint16_t lookup_table_offset, uint32_t skipmap32, + uint32_t field_entries_offset, uint16_t num_field_entries, + uint16_t num_aux_entries, uint32_t aux_offset, + const MessageLite* default_instance, TailCallParseFunc fallback) + : has_bits_offset(has_bits_offset), + extension_offset(extension_offset), + extension_range_low(extension_range_low), + extension_range_high(extension_range_high), + max_field_number(max_field_number), + fast_idx_mask(fast_idx_mask), + lookup_table_offset(lookup_table_offset), + skipmap32(skipmap32), + field_entries_offset(field_entries_offset), + num_field_entries(num_field_entries), + num_aux_entries(num_aux_entries), + aux_offset(aux_offset), + default_instance(default_instance), + fallback(fallback) {} + // Table entry for fast-path tailcall dispatch handling. struct FastFieldEntry { // Target function for dispatch: @@ -102,6 +181,59 @@ struct alignas(uint64_t) TcParseTableBase { const FastFieldEntry* fast_entry(size_t idx) const { return reinterpret_cast<const FastFieldEntry*>(this + 1) + idx; } + + // Returns a begin iterator (pointer) to the start of the field lookup table. + const uint16_t* field_lookup_begin() const { + return reinterpret_cast<const uint16_t*>(reinterpret_cast<uintptr_t>(this) + + lookup_table_offset); + } + + // Field entry for all fields. + struct FieldEntry { + uint32_t offset; // offset in the message object + int32_t has_idx; // has-bit index + uint16_t aux_idx; // index for `field_aux`. + uint16_t type_card; // `FieldType` and `Cardinality` (see _impl.h) + }; + + // Returns a begin iterator (pointer) to the start of the field entries array. + const FieldEntry* field_entries_begin() const { + return reinterpret_cast<const FieldEntry*>( + reinterpret_cast<uintptr_t>(this) + field_entries_offset); + } + + // Auxiliary entries for field types that need extra information. + union FieldAux { + constexpr FieldAux() : message_default(nullptr) {} + constexpr FieldAux(bool (*enum_validator)(int)) + : enum_validator(enum_validator) {} + constexpr FieldAux(field_layout::Offset off) : offset(off.off) {} + constexpr FieldAux(int16_t range_start, uint16_t range_length) + : enum_range{range_start, range_length} {} + constexpr FieldAux(const MessageLite* msg) : message_default(msg) {} + bool (*enum_validator)(int); + struct { + int16_t start; // minimum enum number (if it fits) + uint16_t length; // length of range (i.e., max = start + length - 1) + } enum_range; + uint32_t offset; + const MessageLite* message_default; + }; + const FieldAux* field_aux(uint32_t idx) const { + return reinterpret_cast<const FieldAux*>(reinterpret_cast<uintptr_t>(this) + + aux_offset) + + idx; + } + const FieldAux* field_aux(const FieldEntry* entry) const { + return field_aux(entry->aux_idx); + } + + // Field name data + const char* name_data() const { + return reinterpret_cast<const char*>(reinterpret_cast<uintptr_t>(this) + + aux_offset + + num_aux_entries * sizeof(FieldAux)); + } }; #if defined(_MSC_VER) && !defined(_WIN64) @@ -109,9 +241,13 @@ struct alignas(uint64_t) TcParseTableBase { #endif static_assert(sizeof(TcParseTableBase::FastFieldEntry) <= 16, + "Fast field entry is too big."); +static_assert(sizeof(TcParseTableBase::FieldEntry) <= 16, "Field entry is too big."); -template <size_t kFastTableSizeLog2> +template <size_t kFastTableSizeLog2, size_t kNumFieldEntries = 0, + size_t kNumFieldAux = 0, size_t kNameTableSize = 0, + size_t kFieldLookupSize = 2> struct TcParseTable { TcParseTableBase header; @@ -119,15 +255,52 @@ struct TcParseTable { // // Fields are indexed by the lowest bits of their field number. The field // number is masked to fit inside the table. Note that the parsing logic - // generally calls `TailCallParseTableBase::table()` instead of accessing + // generally calls `TailCallParseTableBase::fast_entry()` instead of accessing // this field directly. - TcParseTableBase::FastFieldEntry entries[(1 << kFastTableSizeLog2)]; + std::array<TcParseTableBase::FastFieldEntry, (1 << kFastTableSizeLog2)> + fast_entries; + + // Just big enough to find all the field entries. + std::array<uint16_t, kFieldLookupSize> field_lookup_table; + // Entries for all fields: + std::array<TcParseTableBase::FieldEntry, kNumFieldEntries> field_entries; + std::array<TcParseTableBase::FieldAux, kNumFieldAux> aux_entries; + std::array<char, kNameTableSize> field_names; +}; + +// Partial specialization: if there are no aux entries, there will be no array. +// In C++, arrays cannot have length 0, but (C++11) std::array<T, 0> is valid. +// However, different implementations have different sizeof(std::array<T, 0>). +// Skipping the member makes offset computations portable. +template <size_t kFastTableSizeLog2, size_t kNumFieldEntries, + size_t kNameTableSize, size_t kFieldLookupSize> +struct TcParseTable<kFastTableSizeLog2, kNumFieldEntries, 0, kNameTableSize, + kFieldLookupSize> { + TcParseTableBase header; + std::array<TcParseTableBase::FastFieldEntry, (1 << kFastTableSizeLog2)> + fast_entries; + std::array<uint16_t, kFieldLookupSize> field_lookup_table; + std::array<TcParseTableBase::FieldEntry, kNumFieldEntries> field_entries; + std::array<char, kNameTableSize> field_names; +}; + +// Partial specialization: if there are no fields at all, then we can save space +// by skipping the field numbers and entries. +template <size_t kNameTableSize, size_t kFieldLookupSize> +struct TcParseTable<0, 0, 0, kNameTableSize, kFieldLookupSize> { + TcParseTableBase header; + // N.B.: the fast entries are sized by log2, so 2**0 fields = 1 entry. + // The fast parsing loop will always use this entry, so it must be present. + std::array<TcParseTableBase::FastFieldEntry, 1> fast_entries; + std::array<uint16_t, kFieldLookupSize> field_lookup_table; + std::array<char, kNameTableSize> field_names; }; static_assert(std::is_standard_layout<TcParseTable<1>>::value, "TcParseTable must be standard layout."); -static_assert(offsetof(TcParseTable<1>, entries) == sizeof(TcParseTableBase), +static_assert(offsetof(TcParseTable<1>, fast_entries) == + sizeof(TcParseTableBase), "Table entries must be laid out after TcParseTableBase."); } // namespace internal diff --git a/r5dev/thirdparty/protobuf/generated_message_tctable_full.cc b/r5dev/thirdparty/protobuf/generated_message_tctable_full.cc index 747d401f..a7643d14 100644 --- a/r5dev/thirdparty/protobuf/generated_message_tctable_full.cc +++ b/r5dev/thirdparty/protobuf/generated_message_tctable_full.cc @@ -30,10 +30,10 @@ #include <cstdint> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/extension_set.h> #include <thirdparty/protobuf/generated_message_tctable_impl.h> #include <thirdparty/protobuf/message.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/unknown_field_set.h> // clang-format off diff --git a/r5dev/thirdparty/protobuf/generated_message_tctable_impl.h b/r5dev/thirdparty/protobuf/generated_message_tctable_impl.h index 7b759026..f35bad58 100644 --- a/r5dev/thirdparty/protobuf/generated_message_tctable_impl.h +++ b/r5dev/thirdparty/protobuf/generated_message_tctable_impl.h @@ -34,12 +34,12 @@ #include <cstdint> #include <type_traits> -#include <thirdparty/protobuf/parse_context.h> +#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/extension_set.h> #include <thirdparty/protobuf/generated_message_tctable_decl.h> #include <thirdparty/protobuf/message_lite.h> #include <thirdparty/protobuf/metadata_lite.h> -#include <thirdparty/protobuf/port.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/wire_format_lite.h> // Must come last: @@ -53,6 +53,189 @@ class UnknownFieldSet; namespace internal { +// Field layout enums. +// +// Structural information about fields is packed into a 16-bit value. The enum +// types below represent bitwise fields, along with their respective widths, +// shifts, and masks. +// +// Bit: +// +-----------------------+-----------------------+ +// |15 .. 8|7 .. 0| +// +-----------------------+-----------------------+ +// : . : . : . : . : . : . : 3|========| [3] FieldType +// : : : : : : 5|=====| : : [2] FieldCardinality +// : . : . : . : . 8|========| : . : . : [3] FieldRep +// : : : 10|=====| : : : : [2] TransformValidation +// : . : .12|=====| . : . : . : . : . : [2] FormatDiscriminator +// +-----------------------+-----------------------+ +// |15 .. 8|7 .. 0| +// +-----------------------+-----------------------+ +// +namespace field_layout { +// clang-format off + +// Field kind (3 bits): +// These values broadly represent a wire type and an in-memory storage class. +enum FieldKind : uint16_t { + kFkShift = 0, + kFkBits = 3, + kFkMask = ((1 << kFkBits) - 1) << kFkShift, + + kFkNone = 0, + kFkVarint, // WT=0 rep=8,32,64 bits + kFkPackedVarint, // WT=2 rep=8,32,64 bits + kFkFixed, // WT=1,5 rep=32,64 bits + kFkPackedFixed, // WT=2 rep=32,64 bits + kFkString, // WT=2 rep=various + kFkMessage, // WT=2,3,4 rep=MessageLite* + // Maps are a special case of Message, but use different parsing logic. + kFkMap, // WT=2 rep=Map(Lite)<various, various> +}; + +static_assert(kFkMap < (1 << kFkBits), "too many types"); + +// Cardinality (2 bits): +// These values determine how many values a field can have and its presence. +// Packed fields are represented in FieldType. +enum Cardinality : uint16_t { + kFcShift = kFkShift + kFkBits, + kFcBits = 2, + kFcMask = ((1 << kFcBits) - 1) << kFcShift, + + kFcSingular = 0, + kFcOptional = 1 << kFcShift, + kFcRepeated = 2 << kFcShift, + kFcOneof = 3 << kFcShift, +}; + +// Field representation (3 bits): +// These values are the specific refinements of storage classes in FieldType. +enum FieldRep : uint16_t { + kRepShift = kFcShift + kFcBits, + kRepBits = 3, + kRepMask = ((1 << kRepBits) - 1) << kRepShift, + + // Numeric types (used for optional and repeated fields): + kRep8Bits = 0, + kRep32Bits = 2 << kRepShift, + kRep64Bits = 3 << kRepShift, + // String types: + kRepAString = 0, // ArenaStringPtr + kRepIString = 1 << kRepShift, // InlinedString + kRepCord = 2 << kRepShift, // absl::Cord + kRepSPiece = 3 << kRepShift, // StringPieceField + kRepSString = 4 << kRepShift, // std::string* + // Message types (WT=2 unless otherwise noted): + kRepMessage = 0, // MessageLite* + kRepGroup = 1 << kRepShift, // MessageLite* (WT=3,4) + kRepLazy = 2 << kRepShift, // LazyField* + kRepIWeak = 3 << kRepShift, // ImplicitWeak +}; + +// Transform/validation (2 bits): +// These values determine transforms or validation to/from wire format. +enum TransformValidation : uint16_t { + kTvShift = kRepShift + kRepBits, + kTvBits = 2, + kTvMask = ((1 << kTvBits) - 1) << kTvShift, + + // Varint fields: + kTvZigZag = 1 << kTvShift, + kTvEnum = 2 << kTvShift, // validate using generated _IsValid() + kTvRange = 3 << kTvShift, // validate using FieldAux::enum_range + // String fields: + kTvUtf8Debug = 1 << kTvShift, // proto2 + kTvUtf8 = 2 << kTvShift, // proto3 +}; + +static_assert((kTvEnum & kTvRange) != 0, + "enum validation types must share a bit"); +static_assert((kTvEnum & kTvRange & kTvZigZag) == 0, + "zigzag encoding is not enum validation"); + +// Format discriminators (2 bits): +enum FormatDiscriminator : uint16_t { + kFmtShift = kTvShift + kTvBits, + kFmtBits = 2, + kFmtMask = ((1 << kFmtBits) - 1) << kFmtShift, + + // Numeric: + kFmtUnsigned = 1 << kFmtShift, // fixed, varint + kFmtSigned = 2 << kFmtShift, // fixed, varint + kFmtFloating = 3 << kFmtShift, // fixed + kFmtEnum = 3 << kFmtShift, // varint + // Strings: + kFmtUtf8 = 1 << kFmtShift, // string (proto3, enforce_utf8=true) + kFmtUtf8Escape = 2 << kFmtShift, // string (proto2, enforce_utf8=false) + // Bytes: + kFmtArray = 1 << kFmtShift, // bytes + // Messages: + kFmtShow = 1 << kFmtShift, // message, map +}; + +// Update this assertion (and comments above) when adding or removing bits: +static_assert(kFmtShift + kFmtBits == 12, "number of bits changed"); + +// This assertion should not change unless the storage width changes: +static_assert(kFmtShift + kFmtBits <= 16, "too many bits"); + +// Convenience aliases (16 bits, with format): +enum FieldType : uint16_t { + // Numeric types: + kBool = kFkVarint | kRep8Bits, + + kFixed32 = kFkFixed | kRep32Bits | kFmtUnsigned, + kUInt32 = kFkVarint | kRep32Bits | kFmtUnsigned, + kSFixed32 = kFkFixed | kRep32Bits | kFmtSigned, + kInt32 = kFkVarint | kRep32Bits | kFmtSigned, + kSInt32 = kFkVarint | kRep32Bits | kFmtSigned | kTvZigZag, + kFloat = kFkFixed | kRep32Bits | kFmtFloating, + kEnum = kFkVarint | kRep32Bits | kFmtEnum | kTvEnum, + kEnumRange = kFkVarint | kRep32Bits | kFmtEnum | kTvRange, + kOpenEnum = kFkVarint | kRep32Bits | kFmtEnum, + + kFixed64 = kFkFixed | kRep64Bits | kFmtUnsigned, + kUInt64 = kFkVarint | kRep64Bits | kFmtUnsigned, + kSFixed64 = kFkFixed | kRep64Bits | kFmtSigned, + kInt64 = kFkVarint | kRep64Bits | kFmtSigned, + kSInt64 = kFkVarint | kRep64Bits | kFmtSigned | kTvZigZag, + kDouble = kFkFixed | kRep64Bits | kFmtFloating, + + kPackedBool = kFkPackedVarint | kRep8Bits, + + kPackedFixed32 = kFkPackedFixed | kRep32Bits | kFmtUnsigned, + kPackedUInt32 = kFkPackedVarint | kRep32Bits | kFmtUnsigned, + kPackedSFixed32 = kFkPackedFixed | kRep32Bits | kFmtSigned, + kPackedInt32 = kFkPackedVarint | kRep32Bits | kFmtSigned, + kPackedSInt32 = kFkPackedVarint | kRep32Bits | kFmtSigned | kTvZigZag, + kPackedFloat = kFkPackedFixed | kRep32Bits | kFmtFloating, + kPackedEnum = kFkPackedVarint | kRep32Bits | kFmtEnum | kTvEnum, + kPackedEnumRange = kFkPackedVarint | kRep32Bits | kFmtEnum | kTvRange, + kPackedOpenEnum = kFkPackedVarint | kRep32Bits | kFmtEnum, + + kPackedFixed64 = kFkPackedFixed | kRep64Bits | kFmtUnsigned, + kPackedUInt64 = kFkPackedVarint | kRep64Bits | kFmtUnsigned, + kPackedSFixed64 = kFkPackedFixed | kRep64Bits | kFmtSigned, + kPackedInt64 = kFkPackedVarint | kRep64Bits | kFmtSigned, + kPackedSInt64 = kFkPackedVarint | kRep64Bits | kFmtSigned | kTvZigZag, + kPackedDouble = kFkPackedFixed | kRep64Bits | kFmtFloating, + + // String types: + kBytes = kFkString | kFmtArray, + kRawString = kFkString | kFmtUtf8 | kTvUtf8Debug, + kUtf8String = kFkString | kFmtUtf8 | kTvUtf8, + + // Message types: + kMessage = kFkMessage, + + // Map types: + kMap = kFkMap, +}; + +// clang-format on +} // namespace field_layout + // PROTOBUF_TC_PARAM_DECL are the parameters for tailcall functions, it is // defined in port_def.inc. // @@ -63,36 +246,6 @@ namespace internal { // PROTOBUF_TC_PARAM_PASS passes values to match PROTOBUF_TC_PARAM_DECL. #define PROTOBUF_TC_PARAM_PASS msg, ptr, ctx, table, hasbits, data -// PROTOBUF_TC_PARSE_* decide which function is used to parse message-typed -// fields. The guard macros are defined in port_def.inc. -#if PROTOBUF_TC_STATIC_PARSE_SINGULAR1 -#define PROTOBUF_TC_PARSE_SINGULAR1(MESSAGE) MESSAGE::Tct_ParseS1 -#else -#define PROTOBUF_TC_PARSE_SINGULAR1(MESSAGE) \ - ::google::protobuf::internal::TcParser::SingularParseMessage<MESSAGE, uint8_t> -#endif // PROTOBUF_TC_STATIC_PARSE_SINGULAR1 - -#if PROTOBUF_TC_STATIC_PARSE_SINGULAR2 -#define PROTOBUF_TC_PARSE_SINGULAR2(MESSAGE) MESSAGE::Tct_ParseS2 -#else -#define PROTOBUF_TC_PARSE_SINGULAR2(MESSAGE) \ - ::google::protobuf::internal::TcParser::SingularParseMessage<MESSAGE, uint16_t> -#endif // PROTOBUF_TC_STATIC_PARSE_SINGULAR2 - -#if PROTOBUF_TC_STATIC_PARSE_REPEATED1 -#define PROTOBUF_TC_PARSE_REPEATED1(MESSAGE) MESSAGE::Tct_ParseR1 -#else -#define PROTOBUF_TC_PARSE_REPEATED1(MESSAGE) \ - ::google::protobuf::internal::TcParser::RepeatedParseMessage<MESSAGE, uint8_t> -#endif // PROTOBUF_TC_STATIC_PARSE_REPEATED1 - -#if PROTOBUF_TC_STATIC_PARSE_REPEATED2 -#define PROTOBUF_TC_PARSE_REPEATED2(MESSAGE) MESSAGE::Tct_ParseR2 -#else -#define PROTOBUF_TC_PARSE_REPEATED2(MESSAGE) \ - ::google::protobuf::internal::TcParser::RepeatedParseMessage<MESSAGE, uint16_t> -#endif // PROTOBUF_TC_STATIC_PARSE_REPEATED2 - #ifndef NDEBUG template <size_t align> #ifndef _MSC_VER @@ -107,105 +260,120 @@ extern template void AlignFail<8>(uintptr_t); #endif // TcParser implements most of the parsing logic for tailcall tables. -class TcParser final { +class PROTOBUF_EXPORT TcParser final { public: static const char* GenericFallback(PROTOBUF_TC_PARAM_DECL); static const char* GenericFallbackLite(PROTOBUF_TC_PARAM_DECL); - // Dispatch to the designated parse function - inline PROTOBUF_ALWAYS_INLINE static const char* TagDispatch( - PROTOBUF_TC_PARAM_DECL) { - const auto coded_tag = UnalignedLoad<uint16_t>(ptr); - const size_t idx = coded_tag & table->fast_idx_mask; - PROTOBUF_ASSUME((idx & 7) == 0); - auto* fast_entry = table->fast_entry(idx >> 3); - data = fast_entry->bits; - data.data ^= coded_tag; - PROTOBUF_MUSTTAIL return fast_entry->target(PROTOBUF_TC_PARAM_PASS); - } - - // We can only safely call from field to next field if the call is optimized - // to a proper tail call. Otherwise we blow through stack. Clang and gcc - // reliably do this optimization in opt mode, but do not perform this in debug - // mode. Luckily the structure of the algorithm is such that it's always - // possible to just return and use the enclosing parse loop as a trampoline. - static const char* ToTagDispatch(PROTOBUF_TC_PARAM_DECL) { - constexpr bool always_return = !PROTOBUF_TAILCALL; - if (always_return || !ctx->DataAvailable(ptr)) { - PROTOBUF_MUSTTAIL return ToParseLoop(PROTOBUF_TC_PARAM_PASS); - } - PROTOBUF_MUSTTAIL return TagDispatch(PROTOBUF_TC_PARAM_PASS); - } - static const char* ParseLoop(MessageLite* msg, const char* ptr, ParseContext* ctx, - const TcParseTableBase* table) { - ScopedArenaSwap saved(msg, ctx); - const uint32_t has_bits_offset = table->has_bits_offset; - while (!ctx->Done(&ptr)) { - uint64_t hasbits = 0; - if (has_bits_offset) hasbits = RefAt<uint32_t>(msg, has_bits_offset); - ptr = TagDispatch(msg, ptr, ctx, table, hasbits, {}); - if (ptr == nullptr) break; - if (ctx->LastTag() != 1) break; // Ended on terminating tag - } - return ptr; - } + const TcParseTableBase* table); - template <typename FieldType, typename TagType> - PROTOBUF_NOINLINE static const char* SingularParseMessage( - PROTOBUF_TC_PARAM_DECL) { - if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { - return table->fallback(PROTOBUF_TC_PARAM_PASS); - } - ptr += sizeof(TagType); - hasbits |= (uint64_t{1} << data.hasbit_idx()); - auto& field = RefAt<FieldType*>(msg, data.offset()); - if (field == nullptr) { - auto arena = ctx->data().arena; - if (Arena::is_arena_constructable<FieldType>::value) { - field = Arena::CreateMessage<FieldType>(arena); - } else { - field = Arena::Create<FieldType>(arena); - } - } - SyncHasbits(msg, hasbits, table); - return ctx->ParseMessage(field, ptr); - } + // Functions referenced by generated fast tables (numeric types): + // F: fixed V: varint Z: zigzag + // 8/32/64: storage type width (bits) + // S: singular R: repeated P: packed + // 1/2: tag length (bytes) - template <typename FieldType, typename TagType> - PROTOBUF_NOINLINE static const char* RepeatedParseMessage( - PROTOBUF_TC_PARAM_DECL) { - if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { - return table->fallback(PROTOBUF_TC_PARAM_PASS); - } - ptr += sizeof(TagType); - auto& field = RefAt<RepeatedPtrField<FieldType>>(msg, data.offset()); - SyncHasbits(msg, hasbits, table); - ptr = ctx->ParseMessage(field.Add(), ptr); - return ptr; - } + // Fixed: + static const char* FastF32S1(PROTOBUF_TC_PARAM_DECL); + static const char* FastF32S2(PROTOBUF_TC_PARAM_DECL); + static const char* FastF32R1(PROTOBUF_TC_PARAM_DECL); + static const char* FastF32R2(PROTOBUF_TC_PARAM_DECL); + static const char* FastF32P1(PROTOBUF_TC_PARAM_DECL); + static const char* FastF32P2(PROTOBUF_TC_PARAM_DECL); + static const char* FastF64S1(PROTOBUF_TC_PARAM_DECL); + static const char* FastF64S2(PROTOBUF_TC_PARAM_DECL); + static const char* FastF64R1(PROTOBUF_TC_PARAM_DECL); + static const char* FastF64R2(PROTOBUF_TC_PARAM_DECL); + static const char* FastF64P1(PROTOBUF_TC_PARAM_DECL); + static const char* FastF64P2(PROTOBUF_TC_PARAM_DECL); - template <typename LayoutType, typename TagType> - static const char* SingularFixed(PROTOBUF_TC_PARAM_DECL); - template <typename LayoutType, typename TagType> - static const char* RepeatedFixed(PROTOBUF_TC_PARAM_DECL); - template <typename LayoutType, typename TagType> - static const char* PackedFixed(PROTOBUF_TC_PARAM_DECL); + // Varint: + static const char* FastV8S1(PROTOBUF_TC_PARAM_DECL); + static const char* FastV8S2(PROTOBUF_TC_PARAM_DECL); + static const char* FastV8R1(PROTOBUF_TC_PARAM_DECL); + static const char* FastV8R2(PROTOBUF_TC_PARAM_DECL); + static const char* FastV8P1(PROTOBUF_TC_PARAM_DECL); + static const char* FastV8P2(PROTOBUF_TC_PARAM_DECL); + static const char* FastV32S1(PROTOBUF_TC_PARAM_DECL); + static const char* FastV32S2(PROTOBUF_TC_PARAM_DECL); + static const char* FastV32R1(PROTOBUF_TC_PARAM_DECL); + static const char* FastV32R2(PROTOBUF_TC_PARAM_DECL); + static const char* FastV32P1(PROTOBUF_TC_PARAM_DECL); + static const char* FastV32P2(PROTOBUF_TC_PARAM_DECL); + static const char* FastV64S1(PROTOBUF_TC_PARAM_DECL); + static const char* FastV64S2(PROTOBUF_TC_PARAM_DECL); + static const char* FastV64R1(PROTOBUF_TC_PARAM_DECL); + static const char* FastV64R2(PROTOBUF_TC_PARAM_DECL); + static const char* FastV64P1(PROTOBUF_TC_PARAM_DECL); + static const char* FastV64P2(PROTOBUF_TC_PARAM_DECL); - enum VarintDecode { kNoConversion = 0, kZigZag = 1 }; - template <typename FieldType, typename TagType, VarintDecode zigzag> - static const char* SingularVarint(PROTOBUF_TC_PARAM_DECL); - template <typename FieldType, typename TagType, VarintDecode zigzag> - static const char* RepeatedVarint(PROTOBUF_TC_PARAM_DECL); - template <typename FieldType, typename TagType, VarintDecode zigzag> - static const char* PackedVarint(PROTOBUF_TC_PARAM_DECL); + // Varint (with zigzag): + static const char* FastZ32S1(PROTOBUF_TC_PARAM_DECL); + static const char* FastZ32S2(PROTOBUF_TC_PARAM_DECL); + static const char* FastZ32R1(PROTOBUF_TC_PARAM_DECL); + static const char* FastZ32R2(PROTOBUF_TC_PARAM_DECL); + static const char* FastZ32P1(PROTOBUF_TC_PARAM_DECL); + static const char* FastZ32P2(PROTOBUF_TC_PARAM_DECL); + static const char* FastZ64S1(PROTOBUF_TC_PARAM_DECL); + static const char* FastZ64S2(PROTOBUF_TC_PARAM_DECL); + static const char* FastZ64R1(PROTOBUF_TC_PARAM_DECL); + static const char* FastZ64R2(PROTOBUF_TC_PARAM_DECL); + static const char* FastZ64P1(PROTOBUF_TC_PARAM_DECL); + static const char* FastZ64P2(PROTOBUF_TC_PARAM_DECL); - enum Utf8Type { kNoUtf8 = 0, kUtf8 = 1, kUtf8ValidateOnly = 2 }; - template <typename TagType, Utf8Type utf8> - static const char* SingularString(PROTOBUF_TC_PARAM_DECL); - template <typename TagType, Utf8Type utf8> - static const char* RepeatedString(PROTOBUF_TC_PARAM_DECL); + // Functions referenced by generated fast tables (closed enum): + // E: closed enum (N.B.: open enums use V32, above) + // r: enum range v: enum validator (_IsValid function) + // S: singular R: repeated + // 1/2: tag length (bytes) + static const char* FastErS1(PROTOBUF_TC_PARAM_DECL); + static const char* FastErS2(PROTOBUF_TC_PARAM_DECL); + static const char* FastErR1(PROTOBUF_TC_PARAM_DECL); + static const char* FastErR2(PROTOBUF_TC_PARAM_DECL); + static const char* FastEvS1(PROTOBUF_TC_PARAM_DECL); + static const char* FastEvS2(PROTOBUF_TC_PARAM_DECL); + static const char* FastEvR1(PROTOBUF_TC_PARAM_DECL); + static const char* FastEvR2(PROTOBUF_TC_PARAM_DECL); + + // Functions referenced by generated fast tables (string types): + // B: bytes S: string U: UTF-8 string + // (empty): ArenaStringPtr i: InlinedString + // S: singular R: repeated + // 1/2: tag length (bytes) + static const char* FastBS1(PROTOBUF_TC_PARAM_DECL); + static const char* FastBS2(PROTOBUF_TC_PARAM_DECL); + static const char* FastBR1(PROTOBUF_TC_PARAM_DECL); + static const char* FastBR2(PROTOBUF_TC_PARAM_DECL); + static const char* FastSS1(PROTOBUF_TC_PARAM_DECL); + static const char* FastSS2(PROTOBUF_TC_PARAM_DECL); + static const char* FastSR1(PROTOBUF_TC_PARAM_DECL); + static const char* FastSR2(PROTOBUF_TC_PARAM_DECL); + static const char* FastUS1(PROTOBUF_TC_PARAM_DECL); + static const char* FastUS2(PROTOBUF_TC_PARAM_DECL); + static const char* FastUR1(PROTOBUF_TC_PARAM_DECL); + static const char* FastUR2(PROTOBUF_TC_PARAM_DECL); + + static const char* FastBiS1(PROTOBUF_TC_PARAM_DECL); + static const char* FastBiS2(PROTOBUF_TC_PARAM_DECL); + static const char* FastSiS1(PROTOBUF_TC_PARAM_DECL); + static const char* FastSiS2(PROTOBUF_TC_PARAM_DECL); + static const char* FastUiS1(PROTOBUF_TC_PARAM_DECL); + static const char* FastUiS2(PROTOBUF_TC_PARAM_DECL); + + // Functions referenced by generated fast tables (message types): + // M: message G: group + // S: singular R: repeated + // 1/2: tag length (bytes) + static const char* FastMS1(PROTOBUF_TC_PARAM_DECL); + static const char* FastMS2(PROTOBUF_TC_PARAM_DECL); + static const char* FastMR1(PROTOBUF_TC_PARAM_DECL); + static const char* FastMR2(PROTOBUF_TC_PARAM_DECL); + static const char* FastGS1(PROTOBUF_TC_PARAM_DECL); + static const char* FastGS2(PROTOBUF_TC_PARAM_DECL); + static const char* FastGR1(PROTOBUF_TC_PARAM_DECL); + static const char* FastGR2(PROTOBUF_TC_PARAM_DECL); template <typename T> static inline T& RefAt(void* x, size_t offset) { @@ -219,6 +387,45 @@ class TcParser final { return *target; } + template <typename T> + static inline const T& RefAt(const void* x, size_t offset) { + const T* target = + reinterpret_cast<const T*>(static_cast<const char*>(x) + offset); +#ifndef NDEBUG + if (PROTOBUF_PREDICT_FALSE( + reinterpret_cast<uintptr_t>(target) % alignof(T) != 0)) { + AlignFail<alignof(T)>(reinterpret_cast<uintptr_t>(target)); + } +#endif + return *target; + } + + template <typename T> + static inline T ReadAt(const void* x, size_t offset) { + T out; + memcpy(&out, static_cast<const char*>(x) + offset, sizeof(T)); + return out; + } + + // Mini parsing: + // + // This function parses a field from incoming data based on metadata stored in + // the message definition. If the field is not defined in the message, it is + // stored in either the ExtensionSet (if applicable) or the UnknownFieldSet. + // + // NOTE: Currently, this function only calls the table-level fallback + // function, so it should only be called as the fallback from fast table + // parsing. + static const char* MiniParse(PROTOBUF_TC_PARAM_DECL); + + private: + friend class GeneratedTcTableLiteTest; + + template <typename TagType, bool group_coding> + static inline const char* SingularParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL); + template <typename TagType, bool group_coding> + static inline const char* RepeatedParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL); + static inline PROTOBUF_ALWAYS_INLINE void SyncHasbits( MessageLite* msg, uint64_t hasbits, const TcParseTableBase* table) { const uint32_t has_bits_offset = table->has_bits_offset; @@ -229,37 +436,14 @@ class TcParser final { } } - protected: - static inline PROTOBUF_ALWAYS_INLINE const char* ToParseLoop( - PROTOBUF_TC_PARAM_DECL) { - (void)data; - (void)ctx; - SyncHasbits(msg, hasbits, table); - return ptr; - } + static const char* TagDispatch(PROTOBUF_TC_PARAM_DECL); + static const char* ToTagDispatch(PROTOBUF_TC_PARAM_DECL); + static const char* ToParseLoop(PROTOBUF_TC_PARAM_DECL); + static const char* Error(PROTOBUF_TC_PARAM_DECL); - static inline PROTOBUF_ALWAYS_INLINE const char* Error( - PROTOBUF_TC_PARAM_DECL) { - (void)data; - (void)ctx; - (void)ptr; - SyncHasbits(msg, hasbits, table); - return nullptr; - } + static const char* FastUnknownEnumFallback(PROTOBUF_TC_PARAM_DECL); - class ScopedArenaSwap final { - public: - ScopedArenaSwap(MessageLite* msg, ParseContext* ctx) - : ctx_(ctx), saved_(ctx->data().arena) { - ctx_->data().arena = msg->GetArenaForAllocation(); - } - ScopedArenaSwap(const ScopedArenaSwap&) = delete; - ~ScopedArenaSwap() { ctx_->data().arena = saved_; } - - private: - ParseContext* const ctx_; - Arena* const saved_; - }; + class ScopedArenaSwap; template <class MessageBaseT, class UnknownFieldsT> static const char* GenericFallbackImpl(PROTOBUF_TC_PARAM_DECL) { @@ -267,14 +451,12 @@ class TcParser final { if (PROTOBUF_PREDICT_FALSE(!(x))) return nullptr /* NOLINT */ SyncHasbits(msg, hasbits, table); - uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); CHK_(ptr); + uint32_t tag = data.tag(); if ((tag & 7) == WireFormatLite::WIRETYPE_END_GROUP || tag == 0) { ctx->SetLastTag(tag); return ptr; } - (void)data; uint32_t num = tag >> 3; if (table->extension_range_low <= num && num <= table->extension_range_high) { @@ -288,10 +470,79 @@ class TcParser final { ptr, ctx); #undef CHK_ } -}; -// Declare helper functions: -#include <thirdparty/protobuf/generated_message_tctable_impl.inc> + // Note: `inline` is needed on template function declarations below to avoid + // -Wattributes diagnostic in GCC. + + // Implementations for fast fixed field parsing functions: + template <typename LayoutType, typename TagType> + static inline const char* SingularFixed(PROTOBUF_TC_PARAM_DECL); + template <typename LayoutType, typename TagType> + static inline const char* RepeatedFixed(PROTOBUF_TC_PARAM_DECL); + template <typename LayoutType, typename TagType> + static inline const char* PackedFixed(PROTOBUF_TC_PARAM_DECL); + + // Implementations for fast varint field parsing functions: + template <typename FieldType, typename TagType, bool zigzag = false> + static inline const char* SingularVarint(PROTOBUF_TC_PARAM_DECL); + template <typename FieldType, typename TagType, bool zigzag = false> + static inline const char* RepeatedVarint(PROTOBUF_TC_PARAM_DECL); + template <typename FieldType, typename TagType, bool zigzag = false> + static inline const char* PackedVarint(PROTOBUF_TC_PARAM_DECL); + + // Helper for ints > 127: + template <typename FieldType, typename TagType, bool zigzag = false> + static const char* SingularVarBigint(PROTOBUF_TC_PARAM_DECL); + + // Implementations for fast enum field parsing functions: + template <typename TagType, uint16_t xform_val> + static inline const char* SingularEnum(PROTOBUF_TC_PARAM_DECL); + template <typename TagType, uint16_t xform_val> + static inline const char* RepeatedEnum(PROTOBUF_TC_PARAM_DECL); + + // Implementations for fast string field parsing functions: + enum Utf8Type { kNoUtf8 = 0, kUtf8 = 1, kUtf8ValidateOnly = 2 }; + template <typename TagType, Utf8Type utf8> + static inline const char* SingularString(PROTOBUF_TC_PARAM_DECL); + template <typename TagType, Utf8Type utf8> + static inline const char* RepeatedString(PROTOBUF_TC_PARAM_DECL); + + // Mini field lookup: + static const TcParseTableBase::FieldEntry* FindFieldEntry( + const TcParseTableBase* table, uint32_t field_num); + static StringPiece MessageName(const TcParseTableBase* table); + static StringPiece FieldName(const TcParseTableBase* table, + const TcParseTableBase::FieldEntry*); + static bool ChangeOneof(const TcParseTableBase* table, + const TcParseTableBase::FieldEntry& entry, + uint32_t field_num, ParseContext* ctx, + MessageLite* msg); + + // UTF-8 validation: + static void ReportFastUtf8Error(uint32_t decoded_tag, + const TcParseTableBase* table); + static bool MpVerifyUtf8(StringPiece wire_bytes, + const TcParseTableBase* table, + const TcParseTableBase::FieldEntry& entry, + uint16_t xform_val); + + // For FindFieldEntry tests: + friend class FindFieldEntryTest; + static constexpr const uint32_t kMtSmallScanSize = 4; + + // Mini parsing: + static const char* MpVarint(PROTOBUF_TC_PARAM_DECL); + static const char* MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL); + static const char* MpPackedVarint(PROTOBUF_TC_PARAM_DECL); + static const char* MpFixed(PROTOBUF_TC_PARAM_DECL); + static const char* MpRepeatedFixed(PROTOBUF_TC_PARAM_DECL); + static const char* MpPackedFixed(PROTOBUF_TC_PARAM_DECL); + static const char* MpString(PROTOBUF_TC_PARAM_DECL); + static const char* MpRepeatedString(PROTOBUF_TC_PARAM_DECL); + static const char* MpMessage(PROTOBUF_TC_PARAM_DECL); + static const char* MpRepeatedMessage(PROTOBUF_TC_PARAM_DECL); + static const char* MpMap(PROTOBUF_TC_PARAM_DECL); +}; } // namespace internal } // namespace protobuf diff --git a/r5dev/thirdparty/protobuf/generated_message_tctable_impl.inc b/r5dev/thirdparty/protobuf/generated_message_tctable_impl.inc deleted file mode 100644 index a6831b53..00000000 --- a/r5dev/thirdparty/protobuf/generated_message_tctable_impl.inc +++ /dev/null @@ -1,92 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// clang-format off -#ifdef PROTOBUF_TCT_SOURCE -#define PROTOBUF_TCT_EXTERN -#else -#define PROTOBUF_TCT_EXTERN extern -#endif -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularFixed<uint64_t, uint8_t>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedFixed<uint64_t, uint8_t>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedFixed<uint64_t, uint8_t>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularFixed<uint32_t, uint8_t>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedFixed<uint32_t, uint8_t>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedFixed<uint32_t, uint8_t>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<uint64_t, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<uint64_t, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<uint64_t, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<uint32_t, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<uint32_t, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<uint32_t, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<int64_t, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<int64_t, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<int64_t, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<int32_t, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<int32_t, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<int32_t, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<bool, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<bool, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<bool, uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularString<uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoUtf8>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedString<uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoUtf8>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularString<uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedString<uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularString<uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8ValidateOnly>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedString<uint8_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8ValidateOnly>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularFixed<uint64_t, uint16_t>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedFixed<uint64_t, uint16_t>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedFixed<uint64_t, uint16_t>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularFixed<uint32_t, uint16_t>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedFixed<uint32_t, uint16_t>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedFixed<uint32_t, uint16_t>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<uint64_t, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<uint64_t, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<uint64_t, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<uint32_t, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<uint32_t, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<uint32_t, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<int64_t, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<int64_t, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<int64_t, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<int32_t, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<int32_t, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<int32_t, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kZigZag>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularVarint<bool, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedVarint<bool, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::PackedVarint<bool, uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoConversion>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularString<uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoUtf8>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedString<uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kNoUtf8>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularString<uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedString<uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::SingularString<uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8ValidateOnly>(PROTOBUF_TC_PARAM_DECL); -PROTOBUF_TCT_EXTERN template const char* TcParser::RepeatedString<uint16_t, ::PROTOBUF_NAMESPACE_ID::internal::TcParser::kUtf8ValidateOnly>(PROTOBUF_TC_PARAM_DECL); -#undef PROTOBUF_TCT_EXTERN -// clang-format on diff --git a/r5dev/thirdparty/protobuf/generated_message_tctable_lite.cc b/r5dev/thirdparty/protobuf/generated_message_tctable_lite.cc index 95484799..a3cd955e 100644 --- a/r5dev/thirdparty/protobuf/generated_message_tctable_lite.cc +++ b/r5dev/thirdparty/protobuf/generated_message_tctable_lite.cc @@ -29,12 +29,14 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <cstdint> +#include <numeric> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/extension_set.h> #include <thirdparty/protobuf/generated_message_tctable_decl.h> #include <thirdparty/protobuf/generated_message_tctable_impl.h> +#include <thirdparty/protobuf/inlined_string_field.h> #include <thirdparty/protobuf/message_lite.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/wire_format_lite.h> // clang-format off @@ -45,6 +47,12 @@ namespace google { namespace protobuf { namespace internal { +using FieldEntry = TcParseTableBase::FieldEntry; + +////////////////////////////////////////////////////////////////////////////// +// Template instantiations: +////////////////////////////////////////////////////////////////////////////// + #ifndef NDEBUG template void AlignFail<4>(uintptr_t); template void AlignFail<8>(uintptr_t); @@ -54,6 +62,285 @@ const char* TcParser::GenericFallbackLite(PROTOBUF_TC_PARAM_DECL) { return GenericFallbackImpl<MessageLite, std::string>(PROTOBUF_TC_PARAM_PASS); } +////////////////////////////////////////////////////////////////////////////// +// Core fast parsing implementation: +////////////////////////////////////////////////////////////////////////////// + +class TcParser::ScopedArenaSwap final { + public: + ScopedArenaSwap(MessageLite* msg, ParseContext* ctx) + : ctx_(ctx), saved_(ctx->data().arena) { + ctx_->data().arena = msg->GetArenaForAllocation(); + } + ScopedArenaSwap(const ScopedArenaSwap&) = delete; + ~ScopedArenaSwap() { ctx_->data().arena = saved_; } + + private: + ParseContext* const ctx_; + Arena* const saved_; +}; + +PROTOBUF_NOINLINE const char* TcParser::ParseLoop( + MessageLite* msg, const char* ptr, ParseContext* ctx, + const TcParseTableBase* table) { + ScopedArenaSwap saved(msg, ctx); + while (!ctx->Done(&ptr)) { + // Unconditionally read has bits, even if we don't have has bits. + // has_bits_offset will be 0 and we will just read something valid. + uint64_t hasbits = ReadAt<uint32_t>(msg, table->has_bits_offset); + ptr = TagDispatch(msg, ptr, ctx, table, hasbits, {}); + if (ptr == nullptr) break; + if (ctx->LastTag() != 1) break; // Ended on terminating tag + } + return ptr; +} + + // Dispatch to the designated parse function +inline PROTOBUF_ALWAYS_INLINE const char* TcParser::TagDispatch( + PROTOBUF_TC_PARAM_DECL) { + const auto coded_tag = UnalignedLoad<uint16_t>(ptr); + const size_t idx = coded_tag & table->fast_idx_mask; + PROTOBUF_ASSUME((idx & 7) == 0); + auto* fast_entry = table->fast_entry(idx >> 3); + data = fast_entry->bits; + data.data ^= coded_tag; + PROTOBUF_MUSTTAIL return fast_entry->target(PROTOBUF_TC_PARAM_PASS); +} + +// We can only safely call from field to next field if the call is optimized +// to a proper tail call. Otherwise we blow through stack. Clang and gcc +// reliably do this optimization in opt mode, but do not perform this in debug +// mode. Luckily the structure of the algorithm is such that it's always +// possible to just return and use the enclosing parse loop as a trampoline. +inline PROTOBUF_ALWAYS_INLINE const char* TcParser::ToTagDispatch( + PROTOBUF_TC_PARAM_DECL) { + constexpr bool always_return = !PROTOBUF_TAILCALL; + if (always_return || !ctx->DataAvailable(ptr)) { + PROTOBUF_MUSTTAIL return ToParseLoop(PROTOBUF_TC_PARAM_PASS); + } + PROTOBUF_MUSTTAIL return TagDispatch(PROTOBUF_TC_PARAM_PASS); +} + +inline PROTOBUF_ALWAYS_INLINE const char* TcParser::ToParseLoop( + PROTOBUF_TC_PARAM_DECL) { + (void)data; + (void)ctx; + SyncHasbits(msg, hasbits, table); + return ptr; +} + +inline PROTOBUF_ALWAYS_INLINE const char* TcParser::Error( + PROTOBUF_TC_PARAM_DECL) { + (void)data; + (void)ctx; + (void)ptr; + SyncHasbits(msg, hasbits, table); + return nullptr; +} + +// On the fast path, a (matching) 1-byte tag already has the decoded value. +static uint32_t FastDecodeTag(uint8_t coded_tag) { + return coded_tag; +} + +// On the fast path, a (matching) 2-byte tag always needs to be decoded. +static uint32_t FastDecodeTag(uint16_t coded_tag) { + uint32_t result = coded_tag; + result += static_cast<int8_t>(coded_tag); + return result >> 1; +} + +////////////////////////////////////////////////////////////////////////////// +// Core mini parsing implementation: +////////////////////////////////////////////////////////////////////////////// + +// Field lookup table layout: +// +// Because it consists of a series of variable-length segments, the lookuup +// table is organized within an array of uint16_t, and each element is either +// a uint16_t or a uint32_t stored little-endian as a pair of uint16_t. +// +// Its fundamental building block maps 16 contiguously ascending field numbers +// to their locations within the field entry table: + +struct SkipEntry16 { + uint16_t skipmap; + uint16_t field_entry_offset; +}; + +// The skipmap is a bitfield of which of those field numbers do NOT have a +// field entry. The lowest bit of the skipmap corresponds to the lowest of +// the 16 field numbers, so if a proto had only fields 1, 2, 3, and 7, the +// skipmap would contain 0b11111111'10111000. +// +// The field lookup table begins with a single 32-bit skipmap that maps the +// field numbers 1 through 32. This is because the majority of proto +// messages only contain fields numbered 1 to 32. +// +// The rest of the lookup table is a repeated series of +// { 32-bit field #, #SkipEntry16s, {SkipEntry16...} } +// That is, the next thing is a pair of uint16_t that form the next +// lowest field number that the lookup table handles. If this number is -1, +// that is the end of the table. Then there is a uint16_t that is +// the number of contiguous SkipEntry16 entries that follow, and then of +// course the SkipEntry16s themselves. + +// Originally developed and tested at https://godbolt.org/z/vbc7enYcf + +// Returns the address of the field for `tag` in the table's field entries. +// Returns nullptr if the field was not found. +const TcParseTableBase::FieldEntry* TcParser::FindFieldEntry( + const TcParseTableBase* table, uint32_t field_num) { + const FieldEntry* const field_entries = table->field_entries_begin(); + + uint32_t fstart = 1; + uint32_t adj_fnum = field_num - fstart; + + if (PROTOBUF_PREDICT_TRUE(adj_fnum < 32)) { + uint32_t skipmap = table->skipmap32; + uint32_t skipbit = 1 << adj_fnum; + if (PROTOBUF_PREDICT_FALSE(skipmap & skipbit)) return nullptr; + skipmap &= skipbit - 1; +#if (__GNUC__ || __clang__) && __POPCNT__ + // Note: here and below, skipmap typically has very few set bits + // (31 in the worst case, but usually zero) so a loop isn't that + // bad, and a compiler-generated popcount is typically only + // worthwhile if the processor itself has hardware popcount support. + adj_fnum -= __builtin_popcount(skipmap); +#else + while (skipmap) { + --adj_fnum; + skipmap &= skipmap - 1; + } +#endif + auto* entry = field_entries + adj_fnum; + PROTOBUF_ASSUME(entry != nullptr); + return entry; + } + const uint16_t* lookup_table = table->field_lookup_begin(); + for (;;) { +#ifdef PROTOBUF_LITTLE_ENDIAN + memcpy(&fstart, lookup_table, sizeof(fstart)); +#else + fstart = lookup_table[0] | (lookup_table[1] << 16); +#endif + lookup_table += sizeof(fstart) / sizeof(*lookup_table); + uint32_t num_skip_entries = *lookup_table++; + if (field_num < fstart) return nullptr; + adj_fnum = field_num - fstart; + uint32_t skip_num = adj_fnum / 16; + if (PROTOBUF_PREDICT_TRUE(skip_num < num_skip_entries)) { + // for each group of 16 fields we have: + // a bitmap of 16 bits + // a 16-bit field-entry offset for the first of them. + auto* skip_data = lookup_table + (adj_fnum / 16) * (sizeof(SkipEntry16) / + sizeof(uint16_t)); + SkipEntry16 se = {skip_data[0], skip_data[1]}; + adj_fnum &= 15; + uint32_t skipmap = se.skipmap; + uint16_t skipbit = 1 << adj_fnum; + if (PROTOBUF_PREDICT_FALSE(skipmap & skipbit)) return nullptr; + skipmap &= skipbit - 1; + adj_fnum += se.field_entry_offset; +#if (__GNUC__ || __clang__) && __POPCNT__ + adj_fnum -= __builtin_popcount(skipmap); +#else + while (skipmap) { + --adj_fnum; + skipmap &= skipmap - 1; + } +#endif + auto* entry = field_entries + adj_fnum; + PROTOBUF_ASSUME(entry != nullptr); + return entry; + } + lookup_table += + num_skip_entries * (sizeof(SkipEntry16) / sizeof(*lookup_table)); + } +} + +// Field names are stored in a format of: +// +// 1) A table of name sizes, one byte each, from 1 to 255 per name. +// `entries` is the size of this first table. +// 1a) padding bytes, so the table of name sizes is a multiple of +// eight bytes in length. They are zero. +// +// 2) All the names, concatenated, with neither separation nor termination. +// +// This is designed to be compact but not particularly fast to retrieve. +// In particular, it takes O(n) to retrieve the name of the n'th field, +// which is usually fine because most protos have fewer than 10 fields. +static StringPiece FindName(const char* name_data, size_t entries, + size_t index) { + // The compiler unrolls these... if this isn't fast enough, + // there's an AVX version at https://godbolt.org/z/eojrjqzfr + // ARM-compatible version at https://godbolt.org/z/n5YT5Ee85 + + // The field name sizes are padded up to a multiple of 8, so we + // must pad them here. + size_t num_sizes = (entries + 7) & -8; + auto* uint8s = reinterpret_cast<const uint8_t*>(name_data); + size_t pos = std::accumulate(uint8s, uint8s + index, num_sizes); + size_t size = name_data[index]; + auto* start = &name_data[pos]; + return {start, size}; +} + +StringPiece TcParser::MessageName(const TcParseTableBase* table) { + return FindName(table->name_data(), table->num_field_entries + 1, 0); +} + +StringPiece TcParser::FieldName(const TcParseTableBase* table, + const FieldEntry* field_entry) { + const FieldEntry* const field_entries = table->field_entries_begin(); + auto field_index = static_cast<size_t>(field_entry - field_entries); + return FindName(table->name_data(), table->num_field_entries + 1, + field_index + 1); +} + +const char* TcParser::MiniParse(PROTOBUF_TC_PARAM_DECL) { + uint32_t tag; + ptr = ReadTagInlined(ptr, &tag); + if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) return nullptr; + + auto* entry = FindFieldEntry(table, tag >> 3); + if (entry == nullptr) { + data.data = tag; + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + + // The handler may need the tag and the entry to resolve fallback logic. Both + // of these are 32 bits, so pack them into (the 64-bit) `data`. Since we can't + // pack the entry pointer itself, just pack its offset from `table`. + uint64_t entry_offset = reinterpret_cast<const char*>(entry) - + reinterpret_cast<const char*>(table); + data.data = entry_offset << 32 | tag; + + using field_layout::FieldKind; + auto field_type = entry->type_card & FieldKind::kFkMask; + switch (field_type) { + case FieldKind::kFkNone: + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + case FieldKind::kFkVarint: + PROTOBUF_MUSTTAIL return MpVarint(PROTOBUF_TC_PARAM_PASS); + case FieldKind::kFkPackedVarint: + PROTOBUF_MUSTTAIL return MpPackedVarint(PROTOBUF_TC_PARAM_PASS); + case FieldKind::kFkFixed: + PROTOBUF_MUSTTAIL return MpFixed(PROTOBUF_TC_PARAM_PASS); + case FieldKind::kFkPackedFixed: + PROTOBUF_MUSTTAIL return MpPackedFixed(PROTOBUF_TC_PARAM_PASS); + case FieldKind::kFkString: + PROTOBUF_MUSTTAIL return MpString(PROTOBUF_TC_PARAM_PASS); + case FieldKind::kFkMessage: + PROTOBUF_MUSTTAIL return MpMessage(PROTOBUF_TC_PARAM_PASS); + case FieldKind::kFkMap: + PROTOBUF_MUSTTAIL return MpMap(PROTOBUF_TC_PARAM_PASS); + default: + return Error(PROTOBUF_TC_PARAM_PASS); + } +} + namespace { // Offset returns the address `offset` bytes after `base`. @@ -71,24 +358,129 @@ inline PROTOBUF_ALWAYS_INLINE void InvertPacked(TcFieldData& data) { } // namespace +////////////////////////////////////////////////////////////////////////////// +// Message fields +////////////////////////////////////////////////////////////////////////////// + +template <typename TagType, bool group_coding> +inline PROTOBUF_ALWAYS_INLINE +const char* TcParser::SingularParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL) { + if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); + } + auto saved_tag = UnalignedLoad<TagType>(ptr); + ptr += sizeof(TagType); + hasbits |= (uint64_t{1} << data.hasbit_idx()); + SyncHasbits(msg, hasbits, table); + auto& field = RefAt<MessageLite*>(msg, data.offset()); + if (field == nullptr) { + const MessageLite* default_instance = + table->field_aux(data.aux_idx())->message_default; + field = default_instance->New(ctx->data().arena); + } + if (group_coding) { + return ctx->ParseGroup(field, ptr, FastDecodeTag(saved_tag)); + } + return ctx->ParseMessage(field, ptr); +} + +const char* TcParser::FastMS1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint8_t, false>( + PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::FastMS2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint16_t, false>( + PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::FastGS1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint8_t, true>( + PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::FastGS2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularParseMessageAuxImpl<uint16_t, true>( + PROTOBUF_TC_PARAM_PASS); +} + +template <typename TagType, bool group_coding> +inline PROTOBUF_ALWAYS_INLINE +const char* TcParser::RepeatedParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL) { + if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); + } + auto saved_tag = UnalignedLoad<TagType>(ptr); + ptr += sizeof(TagType); + SyncHasbits(msg, hasbits, table); + const MessageLite* default_instance = + table->field_aux(data.aux_idx())->message_default; + auto& field = RefAt<RepeatedPtrFieldBase>(msg, data.offset()); + MessageLite* submsg = + field.Add<GenericTypeHandler<MessageLite>>(default_instance); + if (group_coding) { + return ctx->ParseGroup(submsg, ptr, FastDecodeTag(saved_tag)); + } + return ctx->ParseMessage(submsg, ptr); +} + +const char* TcParser::FastMR1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint8_t, false>( + PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::FastMR2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint16_t, false>( + PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::FastGR1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint8_t, true>( + PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::FastGR2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedParseMessageAuxImpl<uint16_t, true>( + PROTOBUF_TC_PARAM_PASS); +} + ////////////////////////////////////////////////////////////////////////////// // Fixed fields ////////////////////////////////////////////////////////////////////////////// template <typename LayoutType, typename TagType> -const char* TcParser::SingularFixed(PROTOBUF_TC_PARAM_DECL) { +PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularFixed( + PROTOBUF_TC_PARAM_DECL) { if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { - return table->fallback(PROTOBUF_TC_PARAM_PASS); + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); } ptr += sizeof(TagType); // Consume tag hasbits |= (uint64_t{1} << data.hasbit_idx()); - std::memcpy(Offset(msg, data.offset()), ptr, sizeof(LayoutType)); + RefAt<LayoutType>(msg, data.offset()) = UnalignedLoad<LayoutType>(ptr); ptr += sizeof(LayoutType); PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS); } +const char* TcParser::FastF32S1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularFixed<uint32_t, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastF32S2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularFixed<uint32_t, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastF64S1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularFixed<uint64_t, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastF64S2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularFixed<uint64_t, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} + template <typename LayoutType, typename TagType> -const char* TcParser::RepeatedFixed(PROTOBUF_TC_PARAM_DECL) { +PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedFixed( + PROTOBUF_TC_PARAM_DECL) { if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { // Check if the field can be parsed as packed repeated: constexpr WireFormatLite::WireType fallback_wt = @@ -98,7 +490,7 @@ const char* TcParser::RepeatedFixed(PROTOBUF_TC_PARAM_DECL) { if (data.coded_tag<TagType>() == 0) { return PackedFixed<LayoutType, TagType>(PROTOBUF_TC_PARAM_PASS); } else { - return table->fallback(PROTOBUF_TC_PARAM_PASS); + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); } } auto& field = RefAt<RepeatedField<LayoutType>>(msg, data.offset()); @@ -109,7 +501,7 @@ const char* TcParser::RepeatedFixed(PROTOBUF_TC_PARAM_DECL) { auto expected_tag = UnalignedLoad<TagType>(ptr); do { ptr += sizeof(TagType); - std::memcpy(elem + (idx++), ptr, sizeof(LayoutType)); + elem[idx++] = UnalignedLoad<LayoutType>(ptr); ptr += sizeof(LayoutType); if (idx >= space) break; if (!ctx->DataAvailable(ptr)) break; @@ -118,18 +510,40 @@ const char* TcParser::RepeatedFixed(PROTOBUF_TC_PARAM_DECL) { return ToParseLoop(PROTOBUF_TC_PARAM_PASS); } +const char* TcParser::FastF32R1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedFixed<uint32_t, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastF32R2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedFixed<uint32_t, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastF64R1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedFixed<uint64_t, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastF64R2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedFixed<uint64_t, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} + +// Note: some versions of GCC will fail with error "function not inlinable" if +// corecursive functions are both marked with PROTOBUF_ALWAYS_INLINE (Clang +// accepts this). We can still apply the attribute to one of the two functions, +// just not both (so we do mark the Repeated variant as always inlined). This +// also applies to PackedVarint, below. template <typename LayoutType, typename TagType> const char* TcParser::PackedFixed(PROTOBUF_TC_PARAM_DECL) { if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { // Try parsing as non-packed repeated: constexpr WireFormatLite::WireType fallback_wt = sizeof(LayoutType) == 4 ? WireFormatLite::WIRETYPE_FIXED32 - : WireFormatLite::WIRETYPE_FIXED64; + : WireFormatLite::WIRETYPE_FIXED64; InvertPacked<fallback_wt>(data); if (data.coded_tag<TagType>() == 0) { return RepeatedFixed<LayoutType, TagType>(PROTOBUF_TC_PARAM_PASS); } else { - return table->fallback(PROTOBUF_TC_PARAM_PASS); + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); } } ptr += sizeof(TagType); @@ -143,12 +557,58 @@ const char* TcParser::PackedFixed(PROTOBUF_TC_PARAM_DECL) { static_cast<RepeatedField<LayoutType>*>(&field)); } +const char* TcParser::FastF32P1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedFixed<uint32_t, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastF32P2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedFixed<uint32_t, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastF64P1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedFixed<uint64_t, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastF64P2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedFixed<uint64_t, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} + ////////////////////////////////////////////////////////////////////////////// // Varint fields ////////////////////////////////////////////////////////////////////////////// namespace { +// Shift "byte" left by n * 7 bits, filling vacated bits with ones. +template <int n> +inline PROTOBUF_ALWAYS_INLINE uint64_t +shift_left_fill_with_ones(uint64_t byte, uint64_t ones) { + return (byte << (n * 7)) | (ones >> (64 - (n * 7))); +} + +// Shift "byte" left by n * 7 bits, filling vacated bits with ones, and +// put the new value in res. Return whether the result was negative. +template <int n> +inline PROTOBUF_ALWAYS_INLINE bool shift_left_fill_with_ones_was_negative( + uint64_t byte, uint64_t ones, int64_t& res) { +#if defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(__x86_64__) + // For the first two rounds (ptr[1] and ptr[2]), micro benchmarks show a + // substantial improvement from capturing the sign from the condition code + // register on x86-64. + bool sign_bit; + asm("shldq %3, %2, %1" + : "=@ccs"(sign_bit), "+r"(byte) + : "r"(ones), "i"(n * 7)); + res = byte; + return sign_bit; +#else + // Generic fallback: + res = (byte << (n * 7)) | (ones >> (64 - (n * 7))); + return static_cast<int64_t>(res) < 0; +#endif +} + inline PROTOBUF_ALWAYS_INLINE std::pair<const char*, uint64_t> Parse64FallbackPair(const char* p, int64_t res1) { auto ptr = reinterpret_cast<const int8_t*>(p); @@ -170,78 +630,42 @@ Parse64FallbackPair(const char* p, int64_t res1) { // has 57 high bits of ones, which is enough for the largest shift done. GOOGLE_DCHECK_EQ(res1 >> 7, -1); uint64_t ones = res1; // save the high 1 bits from res1 (input to SHLD) - uint64_t byte; // the "next" 7-bit chunk, shifted (result from SHLD) int64_t res2, res3; // accumulated result chunks -#define SHLD(n) byte = ((byte << (n * 7)) | (ones >> (64 - (n * 7)))) - int sign_bit; -#if defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(__x86_64__) - // For the first two rounds (ptr[1] and ptr[2]), micro benchmarks show a - // substantial improvement from capturing the sign from the condition code - // register on x86-64. -#define SHLD_SIGN(n) \ - asm("shldq %3, %2, %1" \ - : "=@ccs"(sign_bit), "+r"(byte) \ - : "r"(ones), "i"(n * 7)) -#else - // Generic fallback: -#define SHLD_SIGN(n) \ - do { \ - SHLD(n); \ - sign_bit = static_cast<int64_t>(byte) < 0; \ - } while (0) -#endif - - byte = ptr[1]; - SHLD_SIGN(1); - res2 = byte; - if (!sign_bit) goto done2; - byte = ptr[2]; - SHLD_SIGN(2); - res3 = byte; - if (!sign_bit) goto done3; - -#undef SHLD_SIGN + if (!shift_left_fill_with_ones_was_negative<1>(ptr[1], ones, res2)) + goto done2; + if (!shift_left_fill_with_ones_was_negative<2>(ptr[2], ones, res3)) + goto done3; // For the remainder of the chunks, check the sign of the AND result. - byte = ptr[3]; - SHLD(3); - res1 &= byte; + res1 &= shift_left_fill_with_ones<3>(ptr[3], ones); if (res1 >= 0) goto done4; - byte = ptr[4]; - SHLD(4); - res2 &= byte; + res2 &= shift_left_fill_with_ones<4>(ptr[4], ones); if (res2 >= 0) goto done5; - byte = ptr[5]; - SHLD(5); - res3 &= byte; + res3 &= shift_left_fill_with_ones<5>(ptr[5], ones); if (res3 >= 0) goto done6; - byte = ptr[6]; - SHLD(6); - res1 &= byte; + res1 &= shift_left_fill_with_ones<6>(ptr[6], ones); if (res1 >= 0) goto done7; - byte = ptr[7]; - SHLD(7); - res2 &= byte; + res2 &= shift_left_fill_with_ones<7>(ptr[7], ones); if (res2 >= 0) goto done8; - byte = ptr[8]; - SHLD(8); - res3 &= byte; + res3 &= shift_left_fill_with_ones<8>(ptr[8], ones); if (res3 >= 0) goto done9; -#undef SHLD - // For valid 64bit varints, the 10th byte/ptr[9] should be exactly 1. In this // case, the continuation bit of ptr[8] already set the top bit of res3 // correctly, so all we have to do is check that the expected case is true. - byte = ptr[9]; - if (PROTOBUF_PREDICT_TRUE(byte == 1)) goto done10; + if (PROTOBUF_PREDICT_TRUE(ptr[9] == 1)) goto done10; // A value of 0, however, represents an over-serialized varint. This case // should not happen, but if does (say, due to a nonconforming serializer), // deassert the continuation bit that came from ptr[8]. - if (byte == 0) { + if (ptr[9] == 0) { +#if defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(__x86_64__) + // Use a small instruction since this is an uncommon code path. + asm("btcq $63,%0" : "+r"(res3)); +#else res3 ^= static_cast<uint64_t>(1) << 63; +#endif goto done10; } @@ -249,18 +673,24 @@ Parse64FallbackPair(const char* p, int64_t res1) { // fit in 64 bits. If the continue bit is set, it is an unterminated varint. return {nullptr, 0}; -#define DONE(n) done##n : return {p + n, res1 & res2 & res3}; done2: return {p + 2, res1 & res2}; - DONE(3) - DONE(4) - DONE(5) - DONE(6) - DONE(7) - DONE(8) - DONE(9) - DONE(10) -#undef DONE +done3: + return {p + 3, res1 & res2 & res3}; +done4: + return {p + 4, res1 & res2 & res3}; +done5: + return {p + 5, res1 & res2 & res3}; +done6: + return {p + 6, res1 & res2 & res3}; +done7: + return {p + 7, res1 & res2 & res3}; +done8: + return {p + 8, res1 & res2 & res3}; +done9: + return {p + 9, res1 & res2 & res3}; +done10: + return {p + 10, res1 & res2 & res3}; } inline PROTOBUF_ALWAYS_INLINE const char* ParseVarint(const char* p, @@ -276,36 +706,80 @@ inline PROTOBUF_ALWAYS_INLINE const char* ParseVarint(const char* p, } } -template <typename FieldType, - TcParser::VarintDecode = TcParser::VarintDecode::kNoConversion> -FieldType ZigZagDecodeHelper(uint64_t value) { +template <typename FieldType, bool zigzag = false> +inline FieldType ZigZagDecodeHelper(uint64_t value) { return static_cast<FieldType>(value); } template <> -int32_t ZigZagDecodeHelper<int32_t, TcParser::VarintDecode::kZigZag>( - uint64_t value) { +inline int32_t ZigZagDecodeHelper<int32_t, true>(uint64_t value) { return WireFormatLite::ZigZagDecode32(value); } template <> -int64_t ZigZagDecodeHelper<int64_t, TcParser::VarintDecode::kZigZag>( - uint64_t value) { +inline int64_t ZigZagDecodeHelper<int64_t, true>(uint64_t value) { return WireFormatLite::ZigZagDecode64(value); } +bool EnumIsValidAux(int32_t val, uint16_t xform_val, + TcParseTableBase::FieldAux aux) { + if (xform_val == field_layout::kTvRange) { + auto lo = aux.enum_range.start; + return lo <= val && val < (lo + aux.enum_range.length); + } + return aux.enum_validator(val); +} + } // namespace -template <typename FieldType, typename TagType, TcParser::VarintDecode zigzag> -const char* TcParser::SingularVarint(PROTOBUF_TC_PARAM_DECL) { +template <typename FieldType, typename TagType, bool zigzag> +PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularVarint( + PROTOBUF_TC_PARAM_DECL) { if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { - return table->fallback(PROTOBUF_TC_PARAM_PASS); + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); } ptr += sizeof(TagType); // Consume tag hasbits |= (uint64_t{1} << data.hasbit_idx()); + + // clang isn't smart enough to be able to only conditionally save + // registers to the stack, so we turn the integer-greater-than-128 + // case into a separate routine. + if (PROTOBUF_PREDICT_FALSE(static_cast<int8_t>(*ptr) < 0)) { + PROTOBUF_MUSTTAIL return SingularVarBigint<FieldType, TagType, zigzag>( + PROTOBUF_TC_PARAM_PASS); + } + + RefAt<FieldType>(msg, data.offset()) = + ZigZagDecodeHelper<FieldType, zigzag>(static_cast<uint8_t>(*ptr++)); + PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS); +} + +template <typename FieldType, typename TagType, bool zigzag> +PROTOBUF_NOINLINE const char* TcParser::SingularVarBigint( + PROTOBUF_TC_PARAM_DECL) { + // For some reason clang wants to save 5 registers to the stack here, + // but we only need four for this code, so save the data we don't need + // to the stack. Happily, saving them this way uses regular store + // instructions rather than PUSH/POP, which saves time at the cost of greater + // code size, but for this heavily-used piece of code, that's fine. + struct Spill { + uint64_t field_data; + ::google::protobuf::MessageLite* msg; + const ::google::protobuf::internal::TcParseTableBase* table; + uint64_t hasbits; + }; + volatile Spill spill = {data.data, msg, table, hasbits}; + uint64_t tmp; + PROTOBUF_ASSUME(static_cast<int8_t>(*ptr) < 0); ptr = ParseVarint(ptr, &tmp); - if (ptr == nullptr) { + + data.data = spill.field_data; + msg = spill.msg; + table = spill.table; + hasbits = spill.hasbits; + + if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) { return Error(PROTOBUF_TC_PARAM_PASS); } RefAt<FieldType>(msg, data.offset()) = @@ -313,15 +787,58 @@ const char* TcParser::SingularVarint(PROTOBUF_TC_PARAM_DECL) { PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS); } -template <typename FieldType, typename TagType, TcParser::VarintDecode zigzag> -PROTOBUF_NOINLINE const char* TcParser::RepeatedVarint(PROTOBUF_TC_PARAM_DECL) { +const char* TcParser::FastV8S1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularVarint<bool, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV8S2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularVarint<bool, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV32S1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularVarint<uint32_t, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV32S2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularVarint<uint32_t, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV64S1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularVarint<uint64_t, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV64S2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularVarint<uint64_t, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::FastZ32S1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularVarint<int32_t, uint8_t, true>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastZ32S2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularVarint<int32_t, uint16_t, true>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastZ64S1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularVarint<int64_t, uint8_t, true>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastZ64S2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularVarint<int64_t, uint16_t, true>( + PROTOBUF_TC_PARAM_PASS); +} + +template <typename FieldType, typename TagType, bool zigzag> +PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedVarint( + PROTOBUF_TC_PARAM_DECL) { if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { // Try parsing as non-packed repeated: InvertPacked<WireFormatLite::WIRETYPE_VARINT>(data); if (data.coded_tag<TagType>() == 0) { return PackedVarint<FieldType, TagType, zigzag>(PROTOBUF_TC_PARAM_PASS); } else { - return table->fallback(PROTOBUF_TC_PARAM_PASS); + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); } } auto& field = RefAt<RepeatedField<FieldType>>(msg, data.offset()); @@ -341,14 +858,57 @@ PROTOBUF_NOINLINE const char* TcParser::RepeatedVarint(PROTOBUF_TC_PARAM_DECL) { return ToParseLoop(PROTOBUF_TC_PARAM_PASS); } -template <typename FieldType, typename TagType, TcParser::VarintDecode zigzag> -PROTOBUF_NOINLINE const char* TcParser::PackedVarint(PROTOBUF_TC_PARAM_DECL) { +const char* TcParser::FastV8R1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedVarint<bool, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV8R2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedVarint<bool, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV32R1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedVarint<uint32_t, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV32R2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedVarint<uint32_t, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV64R1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedVarint<uint64_t, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV64R2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedVarint<uint64_t, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::FastZ32R1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedVarint<int32_t, uint8_t, true>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastZ32R2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedVarint<int32_t, uint16_t, true>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastZ64R1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedVarint<int64_t, uint8_t, true>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastZ64R2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedVarint<int64_t, uint16_t, true>( + PROTOBUF_TC_PARAM_PASS); +} + +// See comment on PackedFixed for why this is not PROTOBUF_ALWAYS_INLINE. +template <typename FieldType, typename TagType, bool zigzag> +const char* TcParser::PackedVarint(PROTOBUF_TC_PARAM_DECL) { if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { InvertPacked<WireFormatLite::WIRETYPE_VARINT>(data); if (data.coded_tag<TagType>() == 0) { return RepeatedVarint<FieldType, TagType, zigzag>(PROTOBUF_TC_PARAM_PASS); } else { - return table->fallback(PROTOBUF_TC_PARAM_PASS); + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); } } ptr += sizeof(TagType); @@ -371,14 +931,181 @@ PROTOBUF_NOINLINE const char* TcParser::PackedVarint(PROTOBUF_TC_PARAM_DECL) { }); } +const char* TcParser::FastV8P1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedVarint<bool, uint8_t>(PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV8P2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedVarint<bool, uint16_t>(PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV32P1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedVarint<uint32_t, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV32P2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedVarint<uint32_t, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV64P1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedVarint<uint64_t, uint8_t>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastV64P2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedVarint<uint64_t, uint16_t>( + PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::FastZ32P1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedVarint<int32_t, uint8_t, true>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastZ32P2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedVarint<int32_t, uint16_t, true>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastZ64P1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedVarint<int64_t, uint8_t, true>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastZ64P2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return PackedVarint<int64_t, uint16_t, true>( + PROTOBUF_TC_PARAM_PASS); +} + +////////////////////////////////////////////////////////////////////////////// +// Enum fields +////////////////////////////////////////////////////////////////////////////// + +PROTOBUF_NOINLINE const char* TcParser::FastUnknownEnumFallback( + PROTOBUF_TC_PARAM_DECL) { + (void)msg; + (void)ctx; + (void)hasbits; + + // If we know we want to put this field directly into the unknown field set, + // then we can skip the call to MiniParse and directly call table->fallback. + // However, we first have to update `data` to contain the decoded tag. + uint32_t tag; + ptr = ReadTag(ptr, &tag); + if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) { + return Error(PROTOBUF_TC_PARAM_PASS); + } + data.data = tag; + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); +} + +template <typename TagType, uint16_t xform_val> +PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularEnum( + PROTOBUF_TC_PARAM_DECL) { + if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); + } + const char* ptr2 = ptr; // Save for unknown enum case + ptr += sizeof(TagType); // Consume tag + uint64_t tmp; + ptr = ParseVarint(ptr, &tmp); + if (ptr == nullptr) { + return Error(PROTOBUF_TC_PARAM_PASS); + } + const TcParseTableBase::FieldAux aux = *table->field_aux(data.aux_idx()); + if (PROTOBUF_PREDICT_FALSE( + !EnumIsValidAux(static_cast<int32_t>(tmp), xform_val, aux))) { + ptr = ptr2; + PROTOBUF_MUSTTAIL return FastUnknownEnumFallback(PROTOBUF_TC_PARAM_PASS); + } + hasbits |= (uint64_t{1} << data.hasbit_idx()); + RefAt<int32_t>(msg, data.offset()) = tmp; + PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::FastErS1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularEnum<uint8_t, field_layout::kTvRange>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastErS2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularEnum<uint16_t, field_layout::kTvRange>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastEvS1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularEnum<uint8_t, field_layout::kTvEnum>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastEvS2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularEnum<uint16_t, field_layout::kTvEnum>( + PROTOBUF_TC_PARAM_PASS); +} + +template <typename TagType, uint16_t xform_val> +PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedEnum( + PROTOBUF_TC_PARAM_DECL) { + if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { + InvertPacked<WireFormatLite::WIRETYPE_VARINT>(data); + if (data.coded_tag<TagType>() == 0) { + // Packed parsing is handled by generated fallback. + PROTOBUF_MUSTTAIL return FastUnknownEnumFallback(PROTOBUF_TC_PARAM_PASS); + } else { + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); + } + } + auto& field = RefAt<RepeatedField<int32_t>>(msg, data.offset()); + auto expected_tag = UnalignedLoad<TagType>(ptr); + const TcParseTableBase::FieldAux aux = *table->field_aux(data.aux_idx()); + do { + const char* ptr2 = ptr; // save for unknown enum case + ptr += sizeof(TagType); + uint64_t tmp; + ptr = ParseVarint(ptr, &tmp); + if (ptr == nullptr) { + return Error(PROTOBUF_TC_PARAM_PASS); + } + if (PROTOBUF_PREDICT_FALSE( + !EnumIsValidAux(static_cast<int32_t>(tmp), xform_val, aux))) { + // We can avoid duplicate work in MiniParse by directly calling + // table->fallback. + ptr = ptr2; + PROTOBUF_MUSTTAIL return FastUnknownEnumFallback(PROTOBUF_TC_PARAM_PASS); + } + field.Add(static_cast<int32_t>(tmp)); + if (!ctx->DataAvailable(ptr)) { + break; + } + } while (UnalignedLoad<TagType>(ptr) == expected_tag); + return ToParseLoop(PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::FastErR1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedEnum<uint8_t, field_layout::kTvRange>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastErR2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedEnum<uint16_t, field_layout::kTvRange>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastEvR1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedEnum<uint8_t, field_layout::kTvEnum>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastEvR2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedEnum<uint16_t, field_layout::kTvEnum>( + PROTOBUF_TC_PARAM_PASS); +} + ////////////////////////////////////////////////////////////////////////////// // String/bytes fields ////////////////////////////////////////////////////////////////////////////// // Defined in wire_format_lite.cc -void PrintUTF8ErrorLog(const char* field_name, const char* operation_str, +void PrintUTF8ErrorLog(StringPiece message_name, + StringPiece field_name, const char* operation_str, bool emit_stacktrace); +void TcParser::ReportFastUtf8Error(uint32_t decoded_tag, + const TcParseTableBase* table) { + uint32_t field_num = decoded_tag >> 3; + const auto* entry = FindFieldEntry(table, field_num); + PrintUTF8ErrorLog(MessageName(table), FieldName(table, entry), "parsing", + false); +} + namespace { PROTOBUF_NOINLINE @@ -386,17 +1113,18 @@ const char* SingularStringParserFallback(ArenaStringPtr* s, const char* ptr, EpsCopyInputStream* stream) { int size = ReadSize(&ptr); if (!ptr) return nullptr; - return stream->ReadString( - ptr, size, s->MutableNoArenaNoDefault(&GetEmptyStringAlreadyInited())); + return stream->ReadString(ptr, size, s->MutableNoCopy(nullptr)); } } // namespace template <typename TagType, TcParser::Utf8Type utf8> -const char* TcParser::SingularString(PROTOBUF_TC_PARAM_DECL) { +PROTOBUF_ALWAYS_INLINE const char* TcParser::SingularString( + PROTOBUF_TC_PARAM_DECL) { if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { - return table->fallback(PROTOBUF_TC_PARAM_PASS); + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); } + auto saved_tag = UnalignedLoad<TagType>(ptr); ptr += sizeof(TagType); hasbits |= (uint64_t{1} << data.hasbit_idx()); auto& field = RefAt<ArenaStringPtr>(msg, data.offset()); @@ -417,16 +1145,63 @@ const char* TcParser::SingularString(PROTOBUF_TC_PARAM_DECL) { if (PROTOBUF_PREDICT_TRUE(IsStructurallyValidUTF8(field.Get()))) { return ToParseLoop(PROTOBUF_TC_PARAM_PASS); } - PrintUTF8ErrorLog("unknown", "parsing", false); + ReportFastUtf8Error(FastDecodeTag(saved_tag), table); return utf8 == kUtf8 ? Error(PROTOBUF_TC_PARAM_PASS) : ToParseLoop(PROTOBUF_TC_PARAM_PASS); } } +const char* TcParser::FastBS1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularString<uint8_t, kNoUtf8>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastBS2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularString<uint16_t, kNoUtf8>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastSS1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularString<uint8_t, kUtf8ValidateOnly>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastSS2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularString<uint16_t, kUtf8ValidateOnly>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastUS1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularString<uint8_t, kUtf8>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastUS2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return SingularString<uint16_t, kUtf8>( + PROTOBUF_TC_PARAM_PASS); +} + +// Inlined string variants: + +const char* TcParser::FastBiS1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastBiS2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastSiS1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastSiS2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastUiS1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastUiS2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); +} + template <typename TagType, TcParser::Utf8Type utf8> -const char* TcParser::RepeatedString(PROTOBUF_TC_PARAM_DECL) { +PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedString( + PROTOBUF_TC_PARAM_DECL) { if (PROTOBUF_PREDICT_FALSE(data.coded_tag<TagType>() != 0)) { - return table->fallback(PROTOBUF_TC_PARAM_PASS); + PROTOBUF_MUSTTAIL return MiniParse(PROTOBUF_TC_PARAM_PASS); } auto expected_tag = UnalignedLoad<TagType>(ptr); auto& field = RefAt<RepeatedPtrField<std::string>>(msg, data.offset()); @@ -437,19 +1212,647 @@ const char* TcParser::RepeatedString(PROTOBUF_TC_PARAM_DECL) { if (ptr == nullptr) { return Error(PROTOBUF_TC_PARAM_PASS); } - if (utf8 != kNoUtf8) { - if (PROTOBUF_PREDICT_FALSE(!IsStructurallyValidUTF8(*str))) { - PrintUTF8ErrorLog("unknown", "parsing", false); + switch (utf8) { + case kNoUtf8: +#ifdef NDEBUG + case kUtf8ValidateOnly: +#endif + break; + default: + if (PROTOBUF_PREDICT_TRUE(IsStructurallyValidUTF8(*str))) { + break; + } + ReportFastUtf8Error(FastDecodeTag(expected_tag), table); if (utf8 == kUtf8) return Error(PROTOBUF_TC_PARAM_PASS); - } + break; } if (!ctx->DataAvailable(ptr)) break; } while (UnalignedLoad<TagType>(ptr) == expected_tag); return ToParseLoop(PROTOBUF_TC_PARAM_PASS); } -#define PROTOBUF_TCT_SOURCE -#include <thirdparty/protobuf/generated_message_tctable_impl.inc> +const char* TcParser::FastBR1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedString<uint8_t, kNoUtf8>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastBR2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedString<uint16_t, kNoUtf8>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastSR1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedString<uint8_t, kUtf8ValidateOnly>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastSR2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedString<uint16_t, kUtf8ValidateOnly>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastUR1(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedString<uint8_t, kUtf8>( + PROTOBUF_TC_PARAM_PASS); +} +const char* TcParser::FastUR2(PROTOBUF_TC_PARAM_DECL) { + PROTOBUF_MUSTTAIL return RepeatedString<uint16_t, kUtf8>( + PROTOBUF_TC_PARAM_PASS); +} + +////////////////////////////////////////////////////////////////////////////// +// Mini parsing +////////////////////////////////////////////////////////////////////////////// + +namespace { +inline void SetHas(const TcParseTableBase* table, const FieldEntry& entry, + MessageLite* msg, uint64_t& hasbits) { + int32_t has_idx = entry.has_idx; + if (has_idx < 32) { + hasbits |= uint64_t{1} << has_idx; + } else { + auto* hasblocks = &TcParser::RefAt<uint32_t>(msg, table->has_bits_offset); +#if defined(__x86_64__) && defined(__GNUC__) + asm("bts %1, %0\n" : "+m"(*hasblocks) : "r"(has_idx)); +#else + auto& hasblock = hasblocks[has_idx / 32]; + hasblock |= uint32_t{1} << (has_idx % 32); +#endif + } +} +} // namespace + +// Destroys any existing oneof union member (if necessary). Returns true if the +// caller is responsible for initializing the object, or false if the field +// already has the desired case. +bool TcParser::ChangeOneof(const TcParseTableBase* table, + const TcParseTableBase::FieldEntry& entry, + uint32_t field_num, ParseContext* ctx, + MessageLite* msg) { + // The _oneof_case_ array offset is stored in the first aux entry. + uint32_t oneof_case_offset = table->field_aux(0u)->offset; + // The _oneof_case_ array index is stored in the has-bit index. + uint32_t* oneof_case = + &TcParser::RefAt<uint32_t>(msg, oneof_case_offset) + entry.has_idx; + uint32_t current_case = *oneof_case; + *oneof_case = field_num; + + if (current_case == 0) { + // If the member is empty, we don't have anything to clear. Caller is + // responsible for creating a new member object. + return true; + } + if (current_case == field_num) { + // If the member is already active, then it should be merged. We're done. + return false; + } + // Look up the value that is already stored, and dispose of it if necessary. + const FieldEntry* current_entry = FindFieldEntry(table, current_case); + uint16_t current_kind = current_entry->type_card & field_layout::kFkMask; + uint16_t current_rep = current_entry->type_card & field_layout::kRepMask; + if (current_kind == field_layout::kFkString) { + switch (current_rep) { + case field_layout::kRepAString: { + auto& field = RefAt<ArenaStringPtr>(msg, current_entry->offset); + field.Destroy(); + break; + } + case field_layout::kRepSString: + case field_layout::kRepIString: + default: + GOOGLE_LOG(DFATAL) << "string rep not handled: " + << (current_rep >> field_layout::kRepShift); + return true; + } + } else if (current_kind == field_layout::kFkMessage) { + switch (current_rep) { + case field_layout::kRepMessage: + case field_layout::kRepGroup: + case field_layout::kRepIWeak: { + auto& field = RefAt<MessageLite*>(msg, current_entry->offset); + if (!ctx->data().arena) { + delete field; + } + break; + } + default: + GOOGLE_LOG(DFATAL) << "message rep not handled: " + << (current_rep >> field_layout::kRepShift); + break; + } + } + return true; +} + +const char* TcParser::MpFixed(PROTOBUF_TC_PARAM_DECL) { + const auto& entry = RefAt<FieldEntry>(table, data.entry_offset()); + const uint16_t type_card = entry.type_card; + const uint16_t card = type_card & field_layout::kFcMask; + + // Check for repeated parsing (wiretype fallback is handled there): + if (card == field_layout::kFcRepeated) { + PROTOBUF_MUSTTAIL return MpRepeatedFixed(PROTOBUF_TC_PARAM_PASS); + } + // Check for mismatched wiretype: + const uint16_t rep = type_card & field_layout::kRepMask; + const uint32_t decoded_wiretype = data.tag() & 7; + if (rep == field_layout::kRep64Bits) { + if (decoded_wiretype != WireFormatLite::WIRETYPE_FIXED64) { + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + } else { + GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits)); + if (decoded_wiretype != WireFormatLite::WIRETYPE_FIXED32) { + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + } + // Set the field present: + if (card == field_layout::kFcOptional) { + SetHas(table, entry, msg, hasbits); + } else if (card == field_layout::kFcOneof) { + ChangeOneof(table, entry, data.tag() >> 3, ctx, msg); + } + // Copy the value: + if (rep == field_layout::kRep64Bits) { + RefAt<uint64_t>(msg, entry.offset) = UnalignedLoad<uint64_t>(ptr); + ptr += sizeof(uint64_t); + } else { + RefAt<uint32_t>(msg, entry.offset) = UnalignedLoad<uint32_t>(ptr); + ptr += sizeof(uint32_t); + } + PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::MpRepeatedFixed(PROTOBUF_TC_PARAM_DECL) { + const auto& entry = RefAt<FieldEntry>(table, data.entry_offset()); + const uint32_t decoded_tag = data.tag(); + const uint32_t decoded_wiretype = decoded_tag & 7; + + // Check for packed repeated fallback: + if (decoded_wiretype == WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + PROTOBUF_MUSTTAIL return MpPackedFixed(PROTOBUF_TC_PARAM_PASS); + } + + const uint16_t type_card = entry.type_card; + const uint16_t rep = type_card & field_layout::kRepMask; + if (rep == field_layout::kRep64Bits) { + if (decoded_wiretype != WireFormatLite::WIRETYPE_FIXED64) { + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + auto& field = RefAt<RepeatedField<uint64_t>>(msg, entry.offset); + constexpr auto size = sizeof(uint64_t); + const char* ptr2 = ptr; + uint32_t next_tag; + do { + ptr = ptr2; + *field.Add() = UnalignedLoad<uint64_t>(ptr); + ptr += size; + if (!ctx->DataAvailable(ptr)) break; + ptr2 = ReadTag(ptr, &next_tag); + } while (next_tag == decoded_tag); + } else { + GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits)); + if (decoded_wiretype != WireFormatLite::WIRETYPE_FIXED32) { + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + auto& field = RefAt<RepeatedField<uint32_t>>(msg, entry.offset); + constexpr auto size = sizeof(uint32_t); + const char* ptr2 = ptr; + uint32_t next_tag; + do { + ptr = ptr2; + *field.Add() = UnalignedLoad<uint32_t>(ptr); + ptr += size; + if (!ctx->DataAvailable(ptr)) break; + ptr2 = ReadTag(ptr, &next_tag); + } while (next_tag == decoded_tag); + } + + PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::MpPackedFixed(PROTOBUF_TC_PARAM_DECL) { + const auto& entry = RefAt<FieldEntry>(table, data.entry_offset()); + const uint16_t type_card = entry.type_card; + const uint32_t decoded_wiretype = data.tag() & 7; + + // Check for non-packed repeated fallback: + if (decoded_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + PROTOBUF_MUSTTAIL return MpRepeatedFixed(PROTOBUF_TC_PARAM_PASS); + } + + // Since ctx->ReadPackedFixed does not use TailCall<> or Return<>, sync any + // pending hasbits now: + SyncHasbits(msg, hasbits, table); + + int size = ReadSize(&ptr); + uint16_t rep = type_card & field_layout::kRepMask; + if (rep == field_layout::kRep64Bits) { + auto& field = RefAt<RepeatedField<uint64_t>>(msg, entry.offset); + ptr = ctx->ReadPackedFixed(ptr, size, &field); + } else { + GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits)); + auto& field = RefAt<RepeatedField<uint32_t>>(msg, entry.offset); + ptr = ctx->ReadPackedFixed(ptr, size, &field); + } + + if (ptr == nullptr) { + return Error(PROTOBUF_TC_PARAM_PASS); + } + PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::MpVarint(PROTOBUF_TC_PARAM_DECL) { + const auto& entry = RefAt<FieldEntry>(table, data.entry_offset()); + const uint16_t type_card = entry.type_card; + const uint16_t card = type_card & field_layout::kFcMask; + + // Check for repeated parsing: + if (card == field_layout::kFcRepeated) { + PROTOBUF_MUSTTAIL return MpRepeatedVarint(PROTOBUF_TC_PARAM_PASS); + } + // Check for wire type mismatch: + if ((data.tag() & 7) != WireFormatLite::WIRETYPE_VARINT) { + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + const uint16_t xform_val = type_card & field_layout::kTvMask; + const bool is_zigzag = xform_val == field_layout::kTvZigZag; + const bool is_validated_enum = xform_val & field_layout::kTvEnum; + + // Parse the value: + const char* ptr2 = ptr; // save for unknown enum case + uint64_t tmp; + ptr = ParseVarint(ptr, &tmp); + if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS); + + // Transform and/or validate the value + uint16_t rep = type_card & field_layout::kRepMask; + if (rep == field_layout::kRep64Bits) { + if (is_zigzag) { + tmp = WireFormatLite::ZigZagDecode64(tmp); + } + } else if (rep == field_layout::kRep32Bits) { + if (is_validated_enum) { + if (!EnumIsValidAux(tmp, xform_val, *table->field_aux(&entry))) { + ptr = ptr2; + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + } else if (is_zigzag) { + tmp = WireFormatLite::ZigZagDecode32(static_cast<uint32_t>(tmp)); + } + } + + // Mark the field as present: + const bool is_oneof = card == field_layout::kFcOneof; + if (card == field_layout::kFcOptional) { + SetHas(table, entry, msg, hasbits); + } else if (is_oneof) { + ChangeOneof(table, entry, data.tag() >> 3, ctx, msg); + } + + if (rep == field_layout::kRep64Bits) { + RefAt<uint64_t>(msg, entry.offset) = tmp; + } else if (rep == field_layout::kRep32Bits) { + RefAt<uint32_t>(msg, entry.offset) = static_cast<uint32_t>(tmp); + } else { + GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits)); + RefAt<bool>(msg, entry.offset) = static_cast<bool>(tmp); + } + + PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL) { + const auto& entry = RefAt<FieldEntry>(table, data.entry_offset()); + auto type_card = entry.type_card; + const uint32_t decoded_tag = data.tag(); + auto decoded_wiretype = decoded_tag & 7; + + // Check for packed repeated fallback: + if (decoded_wiretype == WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + PROTOBUF_MUSTTAIL return MpPackedVarint(PROTOBUF_TC_PARAM_PASS); + } + // Check for wire type mismatch: + if (decoded_wiretype != WireFormatLite::WIRETYPE_VARINT) { + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + uint16_t xform_val = (type_card & field_layout::kTvMask); + const bool is_zigzag = xform_val == field_layout::kTvZigZag; + const bool is_validated_enum = xform_val & field_layout::kTvEnum; + + uint16_t rep = type_card & field_layout::kRepMask; + if (rep == field_layout::kRep64Bits) { + auto& field = RefAt<RepeatedField<uint64_t>>(msg, entry.offset); + const char* ptr2 = ptr; + uint32_t next_tag; + do { + uint64_t tmp; + ptr = ParseVarint(ptr2, &tmp); + if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS); + field.Add(is_zigzag ? WireFormatLite::ZigZagDecode64(tmp) : tmp); + if (!ctx->DataAvailable(ptr)) break; + ptr2 = ReadTag(ptr, &next_tag); + } while (next_tag == decoded_tag); + } else if (rep == field_layout::kRep32Bits) { + auto& field = RefAt<RepeatedField<uint32_t>>(msg, entry.offset); + const char* ptr2 = ptr; + uint32_t next_tag; + do { + uint64_t tmp; + ptr = ParseVarint(ptr2, &tmp); + if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS); + if (is_validated_enum) { + if (!EnumIsValidAux(tmp, xform_val, *table->field_aux(&entry))) { + ptr = ptr2; + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + } else if (is_zigzag) { + tmp = WireFormatLite::ZigZagDecode32(tmp); + } + field.Add(tmp); + if (!ctx->DataAvailable(ptr)) break; + ptr2 = ReadTag(ptr, &next_tag); + } while (next_tag == decoded_tag); + } else { + GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits)); + auto& field = RefAt<RepeatedField<bool>>(msg, entry.offset); + const char* ptr2 = ptr; + uint32_t next_tag; + do { + uint64_t tmp; + ptr = ParseVarint(ptr2, &tmp); + if (ptr == nullptr) return Error(PROTOBUF_TC_PARAM_PASS); + field.Add(static_cast<bool>(tmp)); + if (!ctx->DataAvailable(ptr)) break; + ptr2 = ReadTag(ptr, &next_tag); + } while (next_tag == decoded_tag); + } + + PROTOBUF_MUSTTAIL return ToTagDispatch(PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::MpPackedVarint(PROTOBUF_TC_PARAM_DECL) { + const auto& entry = RefAt<FieldEntry>(table, data.entry_offset()); + auto type_card = entry.type_card; + auto decoded_wiretype = data.tag() & 7; + + // Check for non-packed repeated fallback: + if (decoded_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + PROTOBUF_MUSTTAIL return MpRepeatedVarint(PROTOBUF_TC_PARAM_PASS); + } + uint16_t xform_val = (type_card & field_layout::kTvMask); + const bool is_zigzag = xform_val == field_layout::kTvZigZag; + const bool is_validated_enum = xform_val & field_layout::kTvEnum; + if (is_validated_enum) { + // TODO(b/206890171): handle enums + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + + // Since ctx->ReadPackedFixed does not use TailCall<> or Return<>, sync any + // pending hasbits now: + SyncHasbits(msg, hasbits, table); + + uint16_t rep = type_card & field_layout::kRepMask; + if (rep == field_layout::kRep64Bits) { + auto* field = &RefAt<RepeatedField<uint64_t>>(msg, entry.offset); + return ctx->ReadPackedVarint(ptr, [field, is_zigzag](uint64_t value) { + field->Add(is_zigzag ? WireFormatLite::ZigZagDecode64(value) : value); + }); + } else if (rep == field_layout::kRep32Bits) { + auto* field = &RefAt<RepeatedField<uint32_t>>(msg, entry.offset); + return ctx->ReadPackedVarint(ptr, [field, is_zigzag](uint64_t value) { + field->Add(is_zigzag ? WireFormatLite::ZigZagDecode32( + static_cast<uint32_t>(value)) + : value); + }); + } else { + GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits)); + auto* field = &RefAt<RepeatedField<bool>>(msg, entry.offset); + return ctx->ReadPackedVarint( + ptr, [field](uint64_t value) { field->Add(value); }); + } + + return Error(PROTOBUF_TC_PARAM_PASS); +} + +bool TcParser::MpVerifyUtf8(StringPiece wire_bytes, + const TcParseTableBase* table, + const FieldEntry& entry, uint16_t xform_val) { + if (xform_val == field_layout::kTvUtf8) { + if (!IsStructurallyValidUTF8(wire_bytes)) { + PrintUTF8ErrorLog(MessageName(table), FieldName(table, &entry), "parsing", + false); + return false; + } + return true; + } +#ifndef NDEBUG + if (xform_val == field_layout::kTvUtf8Debug) { + if (!IsStructurallyValidUTF8(wire_bytes)) { + PrintUTF8ErrorLog(MessageName(table), FieldName(table, &entry), "parsing", + false); + } + } +#endif // NDEBUG + return true; +} + +const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) { + const auto& entry = RefAt<FieldEntry>(table, data.entry_offset()); + const uint16_t type_card = entry.type_card; + const uint16_t card = type_card & field_layout::kFcMask; + const uint32_t decoded_wiretype = data.tag() & 7; + + if (decoded_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + if (card == field_layout::kFcRepeated) { + PROTOBUF_MUSTTAIL return MpRepeatedString(PROTOBUF_TC_PARAM_PASS); + } + const uint16_t xform_val = type_card & field_layout::kTvMask; + const uint16_t rep = type_card & field_layout::kRepMask; + if (rep == field_layout::kRepIString) { + // TODO(b/198211897): support InilnedStringField. + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + + // Mark the field as present: + const bool is_oneof = card == field_layout::kFcOneof; + bool need_init = false; + if (card == field_layout::kFcOptional) { + SetHas(table, entry, msg, hasbits); + } else if (is_oneof) { + need_init = ChangeOneof(table, entry, data.tag() >> 3, ctx, msg); + } + + bool is_valid = false; + Arena* arena = ctx->data().arena; + switch (rep) { + case field_layout::kRepAString: { + auto& field = RefAt<ArenaStringPtr>(msg, entry.offset); + if (need_init) field.InitDefault(); + if (arena) { + ptr = ctx->ReadArenaString(ptr, &field, arena); + } else { + std::string* str = field.MutableNoCopy(nullptr); + ptr = InlineGreedyStringParser(str, ptr, ctx); + } + if (!ptr) break; + is_valid = MpVerifyUtf8(field.Get(), table, entry, xform_val); + break; + } + + case field_layout::kRepIString: { + break; + } + } + + if (ptr == nullptr || !is_valid) { + return Error(PROTOBUF_TC_PARAM_PASS); + } + return ToParseLoop(PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::MpRepeatedString(PROTOBUF_TC_PARAM_DECL) { + const auto& entry = RefAt<FieldEntry>(table, data.entry_offset()); + const uint16_t type_card = entry.type_card; + const uint32_t decoded_tag = data.tag(); + const uint32_t decoded_wiretype = decoded_tag & 7; + + if (decoded_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + + const uint16_t rep = type_card & field_layout::kRepMask; + const uint16_t xform_val = type_card & field_layout::kTvMask; + switch (rep) { + case field_layout::kRepSString: { + auto& field = RefAt<RepeatedPtrField<std::string>>(msg, entry.offset); + const char* ptr2 = ptr; + uint32_t next_tag; + do { + ptr = ptr2; + std::string* str = field.Add(); + ptr = InlineGreedyStringParser(str, ptr, ctx); + if (PROTOBUF_PREDICT_FALSE( + ptr == nullptr || + !MpVerifyUtf8(*str, table, entry, xform_val))) { + return Error(PROTOBUF_TC_PARAM_PASS); + } + if (!ctx->DataAvailable(ptr)) break; + ptr2 = ReadTag(ptr, &next_tag); + } while (next_tag == decoded_tag); + break; + } + +#ifndef NDEBUG + default: + GOOGLE_LOG(FATAL) << "Unsupported repeated string rep: " << rep; + break; +#endif + } + + return ToParseLoop(PROTOBUF_TC_PARAM_PASS); +} + +const char* TcParser::MpMessage(PROTOBUF_TC_PARAM_DECL) { + const auto& entry = RefAt<FieldEntry>(table, data.entry_offset()); + const uint16_t type_card = entry.type_card; + const uint16_t card = type_card & field_layout::kFcMask; + + // Check for repeated parsing: + if (card == field_layout::kFcRepeated) { + PROTOBUF_MUSTTAIL return MpRepeatedMessage(PROTOBUF_TC_PARAM_PASS); + } + + const uint32_t decoded_tag = data.tag(); + const uint32_t decoded_wiretype = decoded_tag & 7; + const uint16_t rep = type_card & field_layout::kRepMask; + const bool is_group = rep == field_layout::kRepGroup; + + // Validate wiretype: + switch (rep) { + case field_layout::kRepMessage: + if (decoded_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + goto fallback; + } + break; + case field_layout::kRepGroup: + if (decoded_wiretype != WireFormatLite::WIRETYPE_START_GROUP) { + goto fallback; + } + break; + default: { + fallback: + // Lazy and implicit weak fields are handled by generated code: + // TODO(b/210762816): support these. + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + } + + const bool is_oneof = card == field_layout::kFcOneof; + bool need_init = false; + if (card == field_layout::kFcOptional) { + SetHas(table, entry, msg, hasbits); + } else if (is_oneof) { + need_init = ChangeOneof(table, entry, data.tag() >> 3, ctx, msg); + } + MessageLite*& field = RefAt<MessageLite*>(msg, entry.offset); + if (need_init || field == nullptr) { + const MessageLite* default_instance = + table->field_aux(&entry)->message_default; + field = default_instance->New(ctx->data().arena); + } + SyncHasbits(msg, hasbits, table); + if (is_group) { + return ctx->ParseGroup(field, ptr, decoded_tag); + } + return ctx->ParseMessage(field, ptr); +} + +const char* TcParser::MpRepeatedMessage(PROTOBUF_TC_PARAM_DECL) { + const auto& entry = RefAt<FieldEntry>(table, data.entry_offset()); + const uint16_t type_card = entry.type_card; + GOOGLE_DCHECK_EQ(type_card & field_layout::kFcMask, + static_cast<uint16_t>(field_layout::kFcRepeated)); + const uint32_t decoded_tag = data.tag(); + const uint32_t decoded_wiretype = decoded_tag & 7; + const uint16_t rep = type_card & field_layout::kRepMask; + const bool is_group = rep == field_layout::kRepGroup; + + // Validate wiretype: + switch (rep) { + case field_layout::kRepMessage: + if (decoded_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + goto fallback; + } + break; + case field_layout::kRepGroup: + if (decoded_wiretype != WireFormatLite::WIRETYPE_START_GROUP) { + goto fallback; + } + break; + default: { + fallback: + // Lazy and implicit weak fields are handled by generated code: + // TODO(b/210762816): support these. + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + } + + SyncHasbits(msg, hasbits, table); + const MessageLite* default_instance = + table->field_aux(&entry)->message_default; + auto& field = RefAt<RepeatedPtrFieldBase>(msg, entry.offset); + MessageLite* value = + field.Add<GenericTypeHandler<MessageLite>>(default_instance); + if (is_group) { + return ctx->ParseGroup(value, ptr, decoded_tag); + } + return ctx->ParseMessage(value, ptr); +} + +const char* TcParser::MpMap(PROTOBUF_TC_PARAM_DECL) { + const auto& entry = RefAt<FieldEntry>(table, data.entry_offset()); + (void)entry; + PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); +} } // namespace internal } // namespace protobuf diff --git a/r5dev/thirdparty/protobuf/generated_message_tctable_lite_test.cc b/r5dev/thirdparty/protobuf/generated_message_tctable_lite_test.cc new file mode 100644 index 00000000..6643c298 --- /dev/null +++ b/r5dev/thirdparty/protobuf/generated_message_tctable_lite_test.cc @@ -0,0 +1,607 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <cstddef> + +#include <thirdparty/protobuf/generated_message_tctable_impl.h> +#include <thirdparty/protobuf/wire_format_lite.h> +#include <gmock/gmock.h> +#include <gtest/gtest.h> + +namespace google { +namespace protobuf { +namespace internal { + +namespace { + +using ::testing::Eq; +using ::testing::Not; + +MATCHER_P3(IsEntryForFieldNum, table, field_num, field_numbers_table, + StrCat(negation ? "isn't " : "", + "the field entry for field number ", field_num)) { + if (arg == nullptr) { + *result_listener << "which is nullptr"; + return false; + } + // Use the entry's index to compare field numbers. + size_t index = static_cast<const TcParseTableBase::FieldEntry*>(arg) - + &table->field_entries[0]; + uint32_t actual_field_num = field_numbers_table[index]; + if (actual_field_num != field_num) { + *result_listener << "which is the entry for " << actual_field_num; + return false; + } + return true; +} + +TEST(IsEntryForFieldNumTest, Matcher) { + // clang-format off + TcParseTable<0, 3, 0, 0, 2> table = { + // header: + { + 0, 0, 0, 0, // has_bits_offset, extensions + 0, // max_field_number + 0, // fast_idx_mask, + offsetof(decltype(table), field_lookup_table), + 0xFFFFFFFF - 7, // 7 = fields 1, 2, and 3. + offsetof(decltype(table), field_names), + 0, // num_field_entries + 0, 0, // num_aux_entries, aux_offset, + nullptr, // default instance + nullptr, // fallback function + }}; + // clang-format on + int table_field_numbers[] = {1, 2, 3}; + table.field_lookup_table = {65535, 65535}; + + auto& entries = table.field_entries; + EXPECT_THAT(&entries[0], IsEntryForFieldNum(&table, 1, table_field_numbers)); + EXPECT_THAT(&entries[2], IsEntryForFieldNum(&table, 3, table_field_numbers)); + EXPECT_THAT(&entries[1], + Not(IsEntryForFieldNum(&table, 3, table_field_numbers))); + + EXPECT_THAT(nullptr, Not(IsEntryForFieldNum(&table, 1, table_field_numbers))); +} + +} // namespace + +class FindFieldEntryTest : public ::testing::Test { + public: + // Calls the private `FindFieldEntry` function. + template <size_t kFastTableSizeLog2, size_t kNumEntries, size_t kNumFieldAux, + size_t kNameTableSize, size_t kFieldLookupTableSize> + static const TcParseTableBase::FieldEntry* FindFieldEntry( + const TcParseTable<kFastTableSizeLog2, kNumEntries, kNumFieldAux, + kNameTableSize, kFieldLookupTableSize>& table, + uint32_t tag) { + return TcParser::FindFieldEntry(&table.header, tag); + } + + // Calls the private `FieldName` function. + template <size_t kFastTableSizeLog2, size_t kNumEntries, size_t kNumFieldAux, + size_t kNameTableSize, size_t kFieldLookupTableSize> + static StringPiece FieldName( + const TcParseTable<kFastTableSizeLog2, kNumEntries, kNumFieldAux, + kNameTableSize, kFieldLookupTableSize>& table, + const TcParseTableBase::FieldEntry* entry) { + return TcParser::FieldName(&table.header, entry); + } + + // Calls the private `MessageName` function. + template <size_t kFastTableSizeLog2, size_t kNumEntries, size_t kNumFieldAux, + size_t kNameTableSize, size_t kFieldLookupTableSize> + static StringPiece MessageName( + const TcParseTable<kFastTableSizeLog2, kNumEntries, kNumFieldAux, + kNameTableSize, kFieldLookupTableSize>& table) { + return TcParser::MessageName(&table.header); + } + + // Returns the number of fields scanned during a small scan. + static constexpr int small_scan_size() { return TcParser::kMtSmallScanSize; } +}; + +TEST_F(FindFieldEntryTest, SequentialFieldRange) { + // Look up fields that are within the range of `lookup_table_offset`. + // clang-format off + TcParseTable<0, 5, 0, 0, 8> table = { + // header: + { + 0, 0, 0, 0, // has_bits_offset, extensions + 111, // max_field_number + 0, // fast_idx_mask, + offsetof(decltype(table), field_lookup_table), + 0xFFFFFFFF - (1 << 1) - (1 << 2) // fields 2, 3 + - (1 << 3) - (1 << 4), // fields 4, 5 + offsetof(decltype(table), field_entries), + 5, // num_field_entries + 0, 0, // num_aux_entries, aux_offset, + nullptr, // default instance + {}, // fallback function + }, + {}, // fast_entries + // field_lookup_table for 2, 3, 4, 5, 111: + {{ + 111, 0, // field 111 + 1, // 1 skip entry + 0xFFFE, 4, // 1 field, entry 4. + 65535, 65535, // end of table + }}, + }; + // clang-format on + int table_field_numbers[] = {2, 3, 4, 5, 111}; + + for (int i : table_field_numbers) { + EXPECT_THAT(FindFieldEntry(table, i), + IsEntryForFieldNum(&table, i, table_field_numbers)); + } + for (int i : {0, 1, 6, 7, 110, 112, 500000000}) { + GOOGLE_LOG(WARNING) << "Field " << i; + EXPECT_THAT(FindFieldEntry(table, i), Eq(nullptr)); + } +} + +TEST_F(FindFieldEntryTest, SmallScanRange) { + // Look up fields past `lookup_table_offset`, but before binary search. + ASSERT_THAT(small_scan_size(), Eq(4)) << "test needs to be updated"; + // clang-format off + TcParseTable<0, 6, 0, 0, 8> table = { + // header: + { + 0, 0, 0, 0, // has_bits_offset, extensions + 111, // max_field_number + 0, // fast_idx_mask, + offsetof(decltype(table), field_lookup_table), + 0xFFFFFFFF - (1<<0) - (1<<2) - (1<<3) - (1<<4) - (1<<6), // 1,3-5,7 + offsetof(decltype(table), field_entries), + 6, // num_field_entries + 0, 0, // num_aux_entries, aux_offset, + nullptr, // default instance + {}, // fallback function + }, + {}, // fast_entries + // field_lookup_table for 1, 3, 4, 5, 7, 111: + {{ + 111, 0, // field 111 + 1, // 1 skip entry + 0xFFFE, 5, // 1 field, entry 5 + 65535, 65535 // end of table + }}, + }; + // clang-format on + int table_field_numbers[] = {// Sequential entries: + 1, + // Small scan range: + 3, 4, 5, 7, + // Binary search range: + 111}; + + for (int i : table_field_numbers) { + EXPECT_THAT(FindFieldEntry(table, i), + IsEntryForFieldNum(&table, i, table_field_numbers)); + } + for (int i : {0, 2, 6, 8, 9, 110, 112, 500000000}) { + EXPECT_THAT(FindFieldEntry(table, i), Eq(nullptr)); + } +} + +TEST_F(FindFieldEntryTest, BinarySearchRange) { + // Fields after the sequential and small-scan ranges are looked up using + // binary search. + ASSERT_THAT(small_scan_size(), Eq(4)) << "test needs to be updated"; + + // clang-format off + TcParseTable<0, 10, 0, 0, 8> table = { + // header: + { + 0, 0, 0, 0, // has_bits_offset, extensions + 70, // max_field_number + 0, // fast_idx_mask, + offsetof(decltype(table), field_lookup_table), + 0xFFFFFFFF - (1<<0) - (1<<2) - (1<<3) - (1<<4) // 1, 3, 4, 5, 6 + - (1<<5) - (1<<7) - (1<<8) - (1<<10) // 8, 9, 11, 12 + - (1<<11), + offsetof(decltype(table), field_entries), + 10, // num_field_entries + 0, 0, // num_aux_entries, aux_offset, + nullptr, // default instance + {}, // fallback function + }, + {}, // fast_entries + // field_lookup_table for 1, 3, 4, 5, 6, 8, 9, 11, 12, 70 + {{ + 70, 0, // field 70 + 1, // 1 skip entry + 0xFFFE, 9, // 1 field, entry 9 + 65535, 65535 // end of table + }}, + }; + int table_field_numbers[] = { + // Sequential entries: + 1, + // Small scan range: + 3, 4, 5, 6, + // Binary search range: + 8, 9, 11, 12, 70 + }; + // clang-format on + for (int i : table_field_numbers) { + EXPECT_THAT(FindFieldEntry(table, i), + IsEntryForFieldNum(&table, i, table_field_numbers)); + } + for (int i : {0, 2, 7, 10, 13, 69, 71, 112, 500000000}) { + EXPECT_THAT(FindFieldEntry(table, i), Eq(nullptr)); + } +} + +TEST_F(FindFieldEntryTest, OutOfRange) { + // Look up tags that are larger than the maximum in the message. + // clang-format off + TcParseTable<0, 3, 0, 15, 2> table = { + // header: + { + 0, 0, 0, 0, // has_bits_offset, extensions + 3, // max_field_number + 0, // fast_idx_mask, + offsetof(decltype(table), field_lookup_table), + 0xFFFFFFFF - (1<<0) - (1<<1) - (1<<2), // fields 1, 2, 3 + offsetof(decltype(table), field_entries), + 3, // num_field_entries + 0, // num_aux_entries + offsetof(decltype(table), field_names), // no aux_entries + nullptr, // default instance + {}, // fallback function + }, + {}, // fast_entries + {{// field lookup table + 65535, 65535 // end of table + }}, + {}, // "mini" table + // auxiliary entries (none in this test) + {{ // name lengths + "\0\1\2\3\0\0\0\0" + // names + "1" + "02" + "003"}}, + }; + // clang-format on + int table_field_numbers[] = {1, 2, 3}; + + for (int field_num : table_field_numbers) { + auto* entry = FindFieldEntry(table, field_num); + EXPECT_THAT(entry, + IsEntryForFieldNum(&table, field_num, table_field_numbers)); + + StringPiece name = FieldName(table, entry); + EXPECT_EQ(name.length(), field_num); + while (name[0] == '0') name.remove_prefix(1); // strip leading zeores + EXPECT_EQ(name, StrCat(field_num)); + } + for (int field_num : {0, 4, 112, 500000000}) { + EXPECT_THAT(FindFieldEntry(table, field_num), Eq(nullptr)); + } +} + +TEST_F(FindFieldEntryTest, EmptyMessage) { + // Ensure that tables with no fields are handled correctly. + using TableType = TcParseTable<0, 0, 0, 20, 2>; + // clang-format off + TableType table = { + // header: + { + 0, 0, 0, 0, // has_bits_offset, extensions + 0, // max_field_number + 0, // fast_idx_mask, + offsetof(decltype(table), field_lookup_table), + 0xFFFFFFFF, // no fields + offsetof(decltype(table), field_names), // no field_entries + 0, // num_field_entries + 0, // num_aux_entries + offsetof(TableType, field_names), + nullptr, // default instance + nullptr, // fallback function + }, + {}, // fast_entries + {{// empty field lookup table + 65535, 65535 + }}, + {{ + "\13\0\0\0\0\0\0\0" + "MessageName" + }}, + }; + // clang-format on + + for (int i : {0, 4, 112, 500000000}) { + EXPECT_THAT(FindFieldEntry(table, i), Eq(nullptr)); + } + EXPECT_THAT(MessageName(table), Eq("MessageName")); +} + +// Make a monster with lots of field numbers + +int32_t test_all_types_table_field_numbers[] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, // + 11, 12, 13, 14, 15, 18, 19, 21, 22, 24, // + 25, 27, 31, 32, 33, 34, 35, 36, 37, 38, // + 39, 40, 41, 42, 43, 44, 45, 48, 49, 51, // + 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, // + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, // + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, // + 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, // + 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, // + 111, 112, 113, 114, 115, 116, 117, 118, 119, 201, // + 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, // + 251, 252, 253, 254, 255, 321, 322, 401, 402, 403, // + 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, // + 414, 415, 416, 417}; + +// clang-format off +const TcParseTable<5, 134, 5, 2176, 55> test_all_types_table = { + // header: + { + 0, 0, 0, 0, // has_bits_offset, extensions + 418, 248, // max_field_number, fast_idx_mask + offsetof(decltype(test_all_types_table), field_lookup_table), + 977895424, // skipmap for fields 1-15,18-19,21-22,24-25,27,31-32 + offsetof(decltype(test_all_types_table), field_entries), + 135, // num_field_entries + 5, // num_aux_entries + offsetof(decltype(test_all_types_table), aux_entries), + nullptr, // default instance + nullptr, // fallback function + }, + {{ + // tail-call table + }}, + {{ // field lookup table + // + // fields 33-417, over 25 skipmap / offset pairs + 33, 0, 25, + 24576, 24, 18, 38, 0, 52, 0, 68, 16320, 84, + 65408, 92, 65535, 99, 65535, 99, 65535, 99, 65535, 99, + 65279, 99, 65535, 100, 65535, 100, 32768, 100, 65535, 115, + 65535, 115, 65535, 115, 65535, 115, 65532, 115, 65535, 117, + 65535, 117, 65535, 117, 65535, 117, 0, 117, 65532, 133, + // end of table + 65535, 65535 + }}, + {{ + // "mini" table + }}, + {{ // auxiliary entries (not used in this test) + {-1, 4}, + {-1, 4}, + {-1, 4}, + {-1, 4}, + {-1, 4}, + }}, {{ // name lengths + "\1" // message name + "\16\16\17\17\17\17\20\20\21\21\16\17\15\17\16\27\30\24\25\25" + "\15\21\16\16\17\17\17\17\20\20\21\21\16\17\15\17\16\27\30\24" + "\25\25\15\17\17\21\21\21\21\23\23\25\25\17\20\15\21\20\31\32" + "\26\27\14\14\15\15\15\15\16\16\17\17\14\15\13\22\16\16\17\17" + "\17\17\20\20\21\21\16\17\15\24\14\24\14\13\12\14\13\14\12\4" + "\15\15\16\16\16\16\17\17\20\20\15\16\14\16\15\25\25\12\13\14" + "\15\13\15\12\12\13\14\14\14\16\16\15\15\16\0" + // names + "M" + "optional_int32" + "optional_int64" + "optional_uint32" + "optional_uint64" + "optional_sint32" + "optional_sint64" + "optional_fixed32" + "optional_fixed64" + "optional_sfixed32" + "optional_sfixed64" + "optional_float" + "optional_double" + "optional_bool" + "optional_string" + "optional_bytes" + "optional_nested_message" + "optional_foreign_message" + "optional_nested_enum" + "optional_foreign_enum" + "optional_string_piece" + "optional_cord" + "recursive_message" + "repeated_int32" + "repeated_int64" + "repeated_uint32" + "repeated_uint64" + "repeated_sint32" + "repeated_sint64" + "repeated_fixed32" + "repeated_fixed64" + "repeated_sfixed32" + "repeated_sfixed64" + "repeated_float" + "repeated_double" + "repeated_bool" + "repeated_string" + "repeated_bytes" + "repeated_nested_message" + "repeated_foreign_message" + "repeated_nested_enum" + "repeated_foreign_enum" + "repeated_string_piece" + "repeated_cord" + "map_int32_int32" + "map_int64_int64" + "map_uint32_uint32" + "map_uint64_uint64" + "map_sint32_sint32" + "map_sint64_sint64" + "map_fixed32_fixed32" + "map_fixed64_fixed64" + "map_sfixed32_sfixed32" + "map_sfixed64_sfixed64" + "map_int32_float" + "map_int32_double" + "map_bool_bool" + "map_string_string" + "map_string_bytes" + "map_string_nested_message" + "map_string_foreign_message" + "map_string_nested_enum" + "map_string_foreign_enum" + "packed_int32" + "packed_int64" + "packed_uint32" + "packed_uint64" + "packed_sint32" + "packed_sint64" + "packed_fixed32" + "packed_fixed64" + "packed_sfixed32" + "packed_sfixed64" + "packed_float" + "packed_double" + "packed_bool" + "packed_nested_enum" + "unpacked_int32" + "unpacked_int64" + "unpacked_uint32" + "unpacked_uint64" + "unpacked_sint32" + "unpacked_sint64" + "unpacked_fixed32" + "unpacked_fixed64" + "unpacked_sfixed32" + "unpacked_sfixed64" + "unpacked_float" + "unpacked_double" + "unpacked_bool" + "unpacked_nested_enum" + "oneof_uint32" + "oneof_nested_message" + "oneof_string" + "oneof_bytes" + "oneof_bool" + "oneof_uint64" + "oneof_float" + "oneof_double" + "oneof_enum" + "data" + "default_int32" + "default_int64" + "default_uint32" + "default_uint64" + "default_sint32" + "default_sint64" + "default_fixed32" + "default_fixed64" + "default_sfixed32" + "default_sfixed64" + "default_float" + "default_double" + "default_bool" + "default_string" + "default_bytes" + "optional_lazy_message" + "repeated_lazy_message" + "fieldname1" + "field_name2" + "_field_name3" + "field__name4_" + "field0name5" + "field_0_name6" + "fieldName7" + "FieldName8" + "field_Name9" + "Field_Name10" + "FIELD_NAME11" + "FIELD_name12" + "__field_name13" + "__Field_name14" + "field__name15" + "field__Name16" + "field_name17__" + }}, +}; +// clang-format on + +TEST_F(FindFieldEntryTest, BigMessage) { + EXPECT_THAT(MessageName(test_all_types_table), Eq("M")); + for (int field_num : + {1, 12, 31, 42, 57, 68, 79, 90, 101, 119, 249, 402, 412}) { + auto* entry = FindFieldEntry(test_all_types_table, field_num); + StringPiece name = FieldName(test_all_types_table, entry); + switch (field_num) { + case 1: + EXPECT_THAT(name, Eq("optional_int32")); + break; + case 12: + EXPECT_THAT(name, Eq("optional_double")); + break; + case 31: + EXPECT_THAT(name, Eq("repeated_int32")); + break; + case 42: + EXPECT_THAT(name, Eq("repeated_double")); + break; + case 57: + EXPECT_THAT(name, Eq("map_int64_int64")); + break; + case 68: + EXPECT_THAT(name, Eq("map_bool_bool")); + break; + case 79: + EXPECT_THAT(name, Eq("packed_sint32")); + break; + case 90: + EXPECT_THAT(name, Eq("unpacked_int64")); + break; + case 101: + EXPECT_THAT(name, Eq("unpacked_bool")); + break; + case 119: + EXPECT_THAT(name, Eq("oneof_enum")); + break; + case 249: + EXPECT_THAT(name, Eq("default_sfixed32")); + break; + case 402: + EXPECT_THAT(name, Eq("field_name2")); + break; + case 412: + EXPECT_THAT(name, Eq("FIELD_name12")); + break; + } + } +} + +} // namespace internal +} // namespace protobuf +} // namespace google diff --git a/r5dev/thirdparty/protobuf/generated_message_util.cc b/r5dev/thirdparty/protobuf/generated_message_util.cc index e6d01f96..a702f611 100644 --- a/r5dev/thirdparty/protobuf/generated_message_util.cc +++ b/r5dev/thirdparty/protobuf/generated_message_util.cc @@ -42,7 +42,6 @@ #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> #include <thirdparty/protobuf/arenastring.h> #include <thirdparty/protobuf/extension_set.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/message_lite.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/repeated_field.h> @@ -66,7 +65,7 @@ void DestroyString(const void* s) { } PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT - PROTOBUF_ATTRIBUTE_INIT_PRIORITY ExplicitlyConstructed<std::string> + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ExplicitlyConstructedArenaString fixed_address_empty_string{}; // NOLINT @@ -87,7 +86,7 @@ void InitProtobufDefaultsSlow() { // Force the initialization of the empty string. // Normally, registration would do it, but we don't have any guarantee that // there is any object with reflection. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static std::true_type init_empty_string = +PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 static std::true_type init_empty_string = (InitProtobufDefaultsSlow(), std::true_type{}); size_t StringSpaceUsedExcludingSelfLong(const std::string& str) { @@ -253,11 +252,6 @@ template <> struct PrimitiveTypeHelper<WireFormatLite::TYPE_BYTES> : PrimitiveTypeHelper<WireFormatLite::TYPE_STRING> {}; - -template <> -struct PrimitiveTypeHelper<FieldMetadata::kInlinedType> - : PrimitiveTypeHelper<WireFormatLite::TYPE_STRING> {}; - // We want to serialize to both CodedOutputStream and directly into byte arrays // without duplicating the code. In fact we might want extra output channels in // the future. @@ -313,133 +307,6 @@ void SerializeMessageNoTable(const MessageLite* msg, ArrayOutput* output) { output->ptr += o.ByteCount(); } -// Helper to branch to fast path if possible -void SerializeMessageDispatch(const MessageLite& msg, - const FieldMetadata* field_table, int num_fields, - int32_t /*cached_size*/, - io::CodedOutputStream* output) { - const uint8_t* base = reinterpret_cast<const uint8_t*>(&msg); - SerializeInternal(base, field_table, num_fields, output); -} - -// Helper to branch to fast path if possible -void SerializeMessageDispatch(const MessageLite& msg, - const FieldMetadata* field_table, int num_fields, - int32_t /*cached_size*/, ArrayOutput* output) { - const uint8_t* base = reinterpret_cast<const uint8_t*>(&msg); - output->ptr = SerializeInternalToArray(base, field_table, num_fields, - output->is_deterministic, output->ptr); -} - -// Serializing messages is special as it's not a primitive type and needs an -// explicit overload for each output type. -template <typename O> -void SerializeMessageTo(const MessageLite* msg, const void* table_ptr, - O* output) { - const SerializationTable* table = - static_cast<const SerializationTable*>(table_ptr); - if (!table) { - // Proto1 - WriteLengthTo(msg->GetCachedSize(), output); - SerializeMessageNoTable(msg, output); - return; - } - const FieldMetadata* field_table = table->field_table; - const uint8_t* base = reinterpret_cast<const uint8_t*>(msg); - int cached_size = - *reinterpret_cast<const int32_t*>(base + field_table->offset); - WriteLengthTo(cached_size, output); - int num_fields = table->num_fields - 1; - SerializeMessageDispatch(*msg, field_table + 1, num_fields, cached_size, - output); -} - -// Almost the same as above only it doesn't output the length field. -template <typename O> -void SerializeGroupTo(const MessageLite* msg, const void* table_ptr, - O* output) { - const SerializationTable* table = - static_cast<const SerializationTable*>(table_ptr); - if (!table) { - // Proto1 - SerializeMessageNoTable(msg, output); - return; - } - const FieldMetadata* field_table = table->field_table; - const uint8_t* base = reinterpret_cast<const uint8_t*>(msg); - int cached_size = - *reinterpret_cast<const int32_t*>(base + field_table->offset); - int num_fields = table->num_fields - 1; - SerializeMessageDispatch(*msg, field_table + 1, num_fields, cached_size, - output); -} - -template <int type> -struct SingularFieldHelper { - template <typename O> - static void Serialize(const void* field, const FieldMetadata& md, O* output) { - WriteTagTo(md.tag, output); - SerializeTo<type>(field, output); - } -}; - -template <> -struct SingularFieldHelper<WireFormatLite::TYPE_STRING> { - template <typename O> - static void Serialize(const void* field, const FieldMetadata& md, O* output) { - WriteTagTo(md.tag, output); - SerializeTo<WireFormatLite::TYPE_STRING>(&Get<ArenaStringPtr>(field).Get(), - output); - } -}; - -template <> -struct SingularFieldHelper<WireFormatLite::TYPE_BYTES> - : SingularFieldHelper<WireFormatLite::TYPE_STRING> {}; - -template <> -struct SingularFieldHelper<WireFormatLite::TYPE_GROUP> { - template <typename O> - static void Serialize(const void* field, const FieldMetadata& md, O* output) { - WriteTagTo(md.tag, output); - SerializeGroupTo(Get<const MessageLite*>(field), - static_cast<const SerializationTable*>(md.ptr), output); - WriteTagTo(md.tag + 1, output); - } -}; - -template <> -struct SingularFieldHelper<WireFormatLite::TYPE_MESSAGE> { - template <typename O> - static void Serialize(const void* field, const FieldMetadata& md, O* output) { - WriteTagTo(md.tag, output); - SerializeMessageTo(Get<const MessageLite*>(field), - static_cast<const SerializationTable*>(md.ptr), output); - } -}; - -template <> -struct SingularFieldHelper<FieldMetadata::kInlinedType> { - template <typename O> - static void Serialize(const void* field, const FieldMetadata& md, O* output) { - WriteTagTo(md.tag, output); - SerializeTo<FieldMetadata::kInlinedType>(&Get<std::string>(field), output); - } -}; - -template <int type> -struct RepeatedFieldHelper { - template <typename O> - static void Serialize(const void* field, const FieldMetadata& md, O* output) { - typedef typename PrimitiveTypeHelper<type>::Type T; - const RepeatedField<T>& array = Get<RepeatedField<T> >(field); - for (int i = 0; i < array.size(); i++) { - WriteTagTo(md.tag, output); - SerializeTo<type>(&array[i], output); - } - } -}; - // We need to use a helper class to get access to the private members class AccessorHelper { public: @@ -449,118 +316,6 @@ class AccessorHelper { } }; -template <> -struct RepeatedFieldHelper<WireFormatLite::TYPE_STRING> { - template <typename O> - static void Serialize(const void* field, const FieldMetadata& md, O* output) { - const internal::RepeatedPtrFieldBase& array = - Get<internal::RepeatedPtrFieldBase>(field); - for (int i = 0; i < AccessorHelper::Size(array); i++) { - WriteTagTo(md.tag, output); - SerializeTo<WireFormatLite::TYPE_STRING>(AccessorHelper::Get(array, i), - output); - } - } -}; - -template <> -struct RepeatedFieldHelper<WireFormatLite::TYPE_BYTES> - : RepeatedFieldHelper<WireFormatLite::TYPE_STRING> {}; - -template <> -struct RepeatedFieldHelper<WireFormatLite::TYPE_GROUP> { - template <typename O> - static void Serialize(const void* field, const FieldMetadata& md, O* output) { - const internal::RepeatedPtrFieldBase& array = - Get<internal::RepeatedPtrFieldBase>(field); - for (int i = 0; i < AccessorHelper::Size(array); i++) { - WriteTagTo(md.tag, output); - SerializeGroupTo( - static_cast<const MessageLite*>(AccessorHelper::Get(array, i)), - static_cast<const SerializationTable*>(md.ptr), output); - WriteTagTo(md.tag + 1, output); - } - } -}; - -template <> -struct RepeatedFieldHelper<WireFormatLite::TYPE_MESSAGE> { - template <typename O> - static void Serialize(const void* field, const FieldMetadata& md, O* output) { - const internal::RepeatedPtrFieldBase& array = - Get<internal::RepeatedPtrFieldBase>(field); - for (int i = 0; i < AccessorHelper::Size(array); i++) { - WriteTagTo(md.tag, output); - SerializeMessageTo( - static_cast<const MessageLite*>(AccessorHelper::Get(array, i)), - md.ptr, output); - } - } -}; - - -template <> -struct RepeatedFieldHelper<FieldMetadata::kInlinedType> - : RepeatedFieldHelper<WireFormatLite::TYPE_STRING> {}; - -template <int type> -struct PackedFieldHelper { - template <typename O> - static void Serialize(const void* field, const FieldMetadata& md, O* output) { - typedef typename PrimitiveTypeHelper<type>::Type T; - const RepeatedField<T>& array = Get<RepeatedField<T> >(field); - if (array.empty()) return; - WriteTagTo(md.tag, output); - int cached_size = - Get<int>(static_cast<const uint8_t*>(field) + sizeof(RepeatedField<T>)); - WriteLengthTo(cached_size, output); - for (int i = 0; i < array.size(); i++) { - SerializeTo<type>(&array[i], output); - } - } -}; - -template <> -struct PackedFieldHelper<WireFormatLite::TYPE_STRING> { - template <typename O> - static void Serialize(const void* /*field*/, const FieldMetadata& md, - O* /*output*/) { - GOOGLE_LOG(FATAL) << "Not implemented field number " << md.tag << " with type " - << md.type; - } -}; - -template <> -struct PackedFieldHelper<WireFormatLite::TYPE_BYTES> - : PackedFieldHelper<WireFormatLite::TYPE_STRING> {}; -template <> -struct PackedFieldHelper<WireFormatLite::TYPE_GROUP> - : PackedFieldHelper<WireFormatLite::TYPE_STRING> {}; -template <> -struct PackedFieldHelper<WireFormatLite::TYPE_MESSAGE> - : PackedFieldHelper<WireFormatLite::TYPE_STRING> {}; -template <> -struct PackedFieldHelper<FieldMetadata::kInlinedType> - : PackedFieldHelper<WireFormatLite::TYPE_STRING> {}; - -template <int type> -struct OneOfFieldHelper { - template <typename O> - static void Serialize(const void* field, const FieldMetadata& md, O* output) { - SingularFieldHelper<type>::Serialize(field, md, output); - } -}; - - -template <> -struct OneOfFieldHelper<FieldMetadata::kInlinedType> { - template <typename O> - static void Serialize(const void* field, const FieldMetadata& md, O* output) { - SingularFieldHelper<FieldMetadata::kInlinedType>::Serialize( - Get<const std::string*>(field), md, output); - } -}; - void SerializeNotImplemented(int field) { GOOGLE_LOG(FATAL) << "Not implemented field number " << field; } @@ -569,11 +324,6 @@ void SerializeNotImplemented(int field) { #define SERIALIZE_TABLE_OP(type, type_class) \ ((type - 1) + static_cast<int>(type_class) * FieldMetadata::kNumTypes) -int FieldMetadata::CalculateType(int type, - FieldMetadata::FieldTypeClass type_class) { - return SERIALIZE_TABLE_OP(type, type_class); -} - template <int type> bool IsNull(const void* ptr) { return *static_cast<const typename PrimitiveTypeHelper<type>::Type*>(ptr) == @@ -600,125 +350,6 @@ bool IsNull<WireFormatLite::TYPE_MESSAGE>(const void* ptr) { return Get<const MessageLite*>(ptr) == nullptr; } - -template <> -bool IsNull<FieldMetadata::kInlinedType>(const void* ptr) { - return static_cast<const std::string*>(ptr)->empty(); -} - -#define SERIALIZERS_FOR_TYPE(type) \ - case SERIALIZE_TABLE_OP(type, FieldMetadata::kPresence): \ - if (!IsPresent(base, field_metadata.has_offset)) continue; \ - SingularFieldHelper<type>::Serialize(ptr, field_metadata, output); \ - break; \ - case SERIALIZE_TABLE_OP(type, FieldMetadata::kNoPresence): \ - if (IsNull<type>(ptr)) continue; \ - SingularFieldHelper<type>::Serialize(ptr, field_metadata, output); \ - break; \ - case SERIALIZE_TABLE_OP(type, FieldMetadata::kRepeated): \ - RepeatedFieldHelper<type>::Serialize(ptr, field_metadata, output); \ - break; \ - case SERIALIZE_TABLE_OP(type, FieldMetadata::kPacked): \ - PackedFieldHelper<type>::Serialize(ptr, field_metadata, output); \ - break; \ - case SERIALIZE_TABLE_OP(type, FieldMetadata::kOneOf): \ - if (!IsOneofPresent(base, field_metadata.has_offset, field_metadata.tag)) \ - continue; \ - OneOfFieldHelper<type>::Serialize(ptr, field_metadata, output); \ - break - -void SerializeInternal(const uint8_t* base, - const FieldMetadata* field_metadata_table, - int32_t num_fields, io::CodedOutputStream* output) { - SpecialSerializer func = nullptr; - for (int i = 0; i < num_fields; i++) { - const FieldMetadata& field_metadata = field_metadata_table[i]; - const uint8_t* ptr = base + field_metadata.offset; - switch (field_metadata.type) { - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_DOUBLE); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FLOAT); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT64); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT64); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT32); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED64); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED32); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BOOL); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_STRING); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_GROUP); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_MESSAGE); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BYTES); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT32); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_ENUM); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED32); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED64); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT32); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT64); - SERIALIZERS_FOR_TYPE(FieldMetadata::kInlinedType); - - // Special cases - case FieldMetadata::kSpecial: - func = reinterpret_cast<SpecialSerializer>( - const_cast<void*>(field_metadata.ptr)); - func(base, field_metadata.offset, field_metadata.tag, - field_metadata.has_offset, output); - break; - default: - // __builtin_unreachable() - SerializeNotImplemented(field_metadata.type); - } - } -} - -uint8_t* SerializeInternalToArray(const uint8_t* base, - const FieldMetadata* field_metadata_table, - int32_t num_fields, bool is_deterministic, - uint8_t* buffer) { - ArrayOutput array_output = {buffer, is_deterministic}; - ArrayOutput* output = &array_output; - SpecialSerializer func = nullptr; - for (int i = 0; i < num_fields; i++) { - const FieldMetadata& field_metadata = field_metadata_table[i]; - const uint8_t* ptr = base + field_metadata.offset; - switch (field_metadata.type) { - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_DOUBLE); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FLOAT); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT64); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT64); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_INT32); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED64); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_FIXED32); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BOOL); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_STRING); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_GROUP); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_MESSAGE); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_BYTES); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_UINT32); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_ENUM); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED32); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SFIXED64); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT32); - SERIALIZERS_FOR_TYPE(WireFormatLite::TYPE_SINT64); - SERIALIZERS_FOR_TYPE(FieldMetadata::kInlinedType); - // Special cases - case FieldMetadata::kSpecial: { - io::ArrayOutputStream array_stream(array_output.ptr, INT_MAX); - io::CodedOutputStream output_stream(&array_stream); - output_stream.SetSerializationDeterministic(is_deterministic); - func = reinterpret_cast<SpecialSerializer>( - const_cast<void*>(field_metadata.ptr)); - func(base, field_metadata.offset, field_metadata.tag, - field_metadata.has_offset, &output_stream); - array_output.ptr += output_stream.ByteCount(); - } break; - default: - // __builtin_unreachable() - SerializeNotImplemented(field_metadata.type); - } - } - return array_output.ptr; -} -#undef SERIALIZERS_FOR_TYPE - void ExtensionSerializer(const MessageLite* extendee, const uint8_t* ptr, uint32_t offset, uint32_t tag, uint32_t has_offset, io::CodedOutputStream* output) { @@ -758,8 +389,7 @@ void GenericSwap(MessageLite* m1, MessageLite* m2) { MessageLite* GetOwnedMessageInternal(Arena* message_arena, MessageLite* submessage, Arena* submessage_arena) { - GOOGLE_DCHECK(Arena::InternalHelper<MessageLite>::GetOwningArena(submessage) == - submessage_arena); + GOOGLE_DCHECK(Arena::InternalGetOwningArena(submessage) == submessage_arena); GOOGLE_DCHECK(message_arena != submessage_arena); GOOGLE_DCHECK_EQ(submessage_arena, nullptr); if (message_arena != nullptr && submessage_arena == nullptr) { diff --git a/r5dev/thirdparty/protobuf/generated_message_util.h b/r5dev/thirdparty/protobuf/generated_message_util.h index 573fc5f2..950a4b36 100644 --- a/r5dev/thirdparty/protobuf/generated_message_util.h +++ b/r5dev/thirdparty/protobuf/generated_message_util.h @@ -46,17 +46,18 @@ #include <vector> #include <thirdparty/protobuf/stubs/common.h> +#include <thirdparty/protobuf/stubs/once.h> // Add direct dep on port for pb.cc +#include <thirdparty/protobuf/port.h> +#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/any.h> #include <thirdparty/protobuf/has_bits.h> #include <thirdparty/protobuf/implicit_weak_message.h> #include <thirdparty/protobuf/message_lite.h> -#include <thirdparty/protobuf/stubs/once.h> // Add direct dep on port for pb.cc -#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/repeated_field.h> #include <thirdparty/protobuf/wire_format_lite.h> -#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/casts.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG diff --git a/r5dev/thirdparty/protobuf/has_bits.h b/r5dev/thirdparty/protobuf/has_bits.h index 46099266..313543de 100644 --- a/r5dev/thirdparty/protobuf/has_bits.h +++ b/r5dev/thirdparty/protobuf/has_bits.h @@ -34,6 +34,7 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/port.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG diff --git a/r5dev/thirdparty/protobuf/implicit_weak_message.cc b/r5dev/thirdparty/protobuf/implicit_weak_message.cc index a1eeda8c..002f5b56 100644 --- a/r5dev/thirdparty/protobuf/implicit_weak_message.cc +++ b/r5dev/thirdparty/protobuf/implicit_weak_message.cc @@ -30,34 +30,39 @@ #include <thirdparty/protobuf/implicit_weak_message.h> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> -#include <thirdparty/protobuf/stubs/once.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/wire_format_lite.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> +PROTOBUF_PRAGMA_INIT_SEG + namespace google { namespace protobuf { namespace internal { const char* ImplicitWeakMessage::_InternalParse(const char* ptr, ParseContext* ctx) { - return ctx->AppendString(ptr, &data_); + return ctx->AppendString(ptr, data_); } -ExplicitlyConstructed<ImplicitWeakMessage> +struct ImplicitWeakMessageDefaultType { + constexpr ImplicitWeakMessageDefaultType() + : instance(ConstantInitialized{}) {} + ~ImplicitWeakMessageDefaultType() {} + union { + ImplicitWeakMessage instance; + }; +}; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ImplicitWeakMessageDefaultType implicit_weak_message_default_instance; -internal::once_flag implicit_weak_message_once_init_; - -void InitImplicitWeakMessageDefaultInstance() { - implicit_weak_message_default_instance.DefaultConstruct(); -} const ImplicitWeakMessage* ImplicitWeakMessage::default_instance() { - internal::call_once(implicit_weak_message_once_init_, - InitImplicitWeakMessageDefaultInstance); - return &implicit_weak_message_default_instance.get(); + return reinterpret_cast<ImplicitWeakMessage*>( + &implicit_weak_message_default_instance); } } // namespace internal diff --git a/r5dev/thirdparty/protobuf/implicit_weak_message.h b/r5dev/thirdparty/protobuf/implicit_weak_message.h index c3f8027c..b70ef1cb 100644 --- a/r5dev/thirdparty/protobuf/implicit_weak_message.h +++ b/r5dev/thirdparty/protobuf/implicit_weak_message.h @@ -42,6 +42,7 @@ #error "You cannot SWIG proto headers" #endif +// Must be included last. #include <thirdparty/protobuf/port_def.inc> // This file is logically internal-only and should only be used by protobuf @@ -56,8 +57,17 @@ namespace internal { // message type does not get linked into the binary. class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite { public: - ImplicitWeakMessage() {} - explicit ImplicitWeakMessage(Arena* arena) : MessageLite(arena) {} + ImplicitWeakMessage() : data_(new std::string) {} + explicit constexpr ImplicitWeakMessage(ConstantInitialized) + : data_(nullptr) {} + explicit ImplicitWeakMessage(Arena* arena) + : MessageLite(arena), data_(new std::string) {} + + ~ImplicitWeakMessage() override { + // data_ will be null in the default instance, but we can safely call delete + // here because the default instance will never be destroyed. + delete data_; + } static const ImplicitWeakMessage* default_instance(); @@ -67,33 +77,50 @@ class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite { return Arena::CreateMessage<ImplicitWeakMessage>(arena); } - void Clear() override { data_.clear(); } + void Clear() override { data_->clear(); } bool IsInitialized() const override { return true; } void CheckTypeAndMergeFrom(const MessageLite& other) override { - data_.append(static_cast<const ImplicitWeakMessage&>(other).data_); + const std::string* other_data = + static_cast<const ImplicitWeakMessage&>(other).data_; + if (other_data != nullptr) { + data_->append(*other_data); + } } const char* _InternalParse(const char* ptr, ParseContext* ctx) final; - size_t ByteSizeLong() const override { return data_.size(); } + size_t ByteSizeLong() const override { + return data_ == nullptr ? 0 : data_->size(); + } uint8_t* _InternalSerialize(uint8_t* target, io::EpsCopyOutputStream* stream) const final { - return stream->WriteRaw(data_.data(), static_cast<int>(data_.size()), + if (data_ == nullptr) { + return target; + } + return stream->WriteRaw(data_->data(), static_cast<int>(data_->size()), target); } - int GetCachedSize() const override { return static_cast<int>(data_.size()); } + int GetCachedSize() const override { + return data_ == nullptr ? 0 : static_cast<int>(data_->size()); + } typedef void InternalArenaConstructable_; private: - std::string data_; + // This std::string is allocated on the heap, but we use a raw pointer so that + // the default instance can be constant-initialized. In the const methods, we + // have to handle the possibility of data_ being null. + std::string* data_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImplicitWeakMessage); }; +struct ImplicitWeakMessageDefaultType; +extern ImplicitWeakMessageDefaultType implicit_weak_message_default_instance; + // A type handler for use with implicit weak repeated message fields. template <typename ImplicitWeakType> class ImplicitWeakTypeHandler { diff --git a/r5dev/thirdparty/protobuf/inlined_string_field.cc b/r5dev/thirdparty/protobuf/inlined_string_field.cc index ad9060f5..308562ef 100644 --- a/r5dev/thirdparty/protobuf/inlined_string_field.cc +++ b/r5dev/thirdparty/protobuf/inlined_string_field.cc @@ -30,11 +30,11 @@ #include <thirdparty/protobuf/inlined_string_field.h> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/message_lite.h> +#include <thirdparty/protobuf/parse_context.h> // clang-format off #include <thirdparty/protobuf/port_def.inc> @@ -48,54 +48,62 @@ namespace internal { std::string* InlinedStringField::Mutable(const LazyString& /*default_value*/, Arena* arena, bool donated, uint32_t* donating_states, - uint32_t mask) { + uint32_t mask, MessageLite* msg) { if (arena == nullptr || !donated) { return UnsafeMutablePointer(); } - return MutableSlow(arena, donated, donating_states, mask); + return MutableSlow(arena, donated, donating_states, mask, msg); } -std::string* InlinedStringField::Mutable(ArenaStringPtr::EmptyDefault, - Arena* arena, bool donated, +std::string* InlinedStringField::Mutable(Arena* arena, bool donated, uint32_t* donating_states, - uint32_t mask) { + uint32_t mask, MessageLite* msg) { if (arena == nullptr || !donated) { return UnsafeMutablePointer(); } - return MutableSlow(arena, donated, donating_states, mask); + return MutableSlow(arena, donated, donating_states, mask, msg); } std::string* InlinedStringField::MutableSlow(::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, - uint32_t mask) { + uint32_t mask, MessageLite* msg) { + (void)mask; + (void)msg; return UnsafeMutablePointer(); } void InlinedStringField::SetAllocated(const std::string* default_value, std::string* value, Arena* arena, bool donated, uint32_t* donating_states, - uint32_t mask) { + uint32_t mask, MessageLite* msg) { + (void)mask; + (void)msg; SetAllocatedNoArena(default_value, value); } -void InlinedStringField::Set(const std::string* default_value, - std::string&& value, Arena* arena, bool donated, - uint32_t* donating_states, uint32_t mask) { - SetNoArena(default_value, std::move(value)); +void InlinedStringField::Set(std::string&& value, Arena* arena, bool donated, + uint32_t* donating_states, uint32_t mask, + MessageLite* msg) { + (void)donating_states; + (void)mask; + (void)msg; + SetNoArena(std::move(value)); } -std::string* InlinedStringField::Release(const std::string* default_value, - Arena* arena, bool donated) { - if (arena == nullptr && !donated) { - return ReleaseNonDefaultNoArena(default_value); - } - return ReleaseNonDefault(default_value, arena); +std::string* InlinedStringField::Release() { + auto* released = new std::string(std::move(*get_mutable())); + get_mutable()->clear(); + return released; } -std::string* InlinedStringField::ReleaseNonDefault( - const std::string* default_value, Arena* arena) { - return ReleaseNonDefaultNoArena(default_value); +std::string* InlinedStringField::Release(Arena* arena, bool donated) { + // We can not steal donated arena strings. + std::string* released = (arena != nullptr && donated) + ? new std::string(*get_mutable()) + : new std::string(std::move(*get_mutable())); + get_mutable()->clear(); + return released; } void InlinedStringField::ClearToDefault(const LazyString& default_value, diff --git a/r5dev/thirdparty/protobuf/inlined_string_field.h b/r5dev/thirdparty/protobuf/inlined_string_field.h index 8953c3a8..97cb117a 100644 --- a/r5dev/thirdparty/protobuf/inlined_string_field.h +++ b/r5dev/thirdparty/protobuf/inlined_string_field.h @@ -36,10 +36,10 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/message_lite.h> #include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/arenastring.h> +#include <thirdparty/protobuf/message_lite.h> // Must be included last. #include <thirdparty/protobuf/port_def.inc> @@ -130,60 +130,45 @@ class PROTOBUF_EXPORT InlinedStringField { // `donated == ((donating_states & ~mask) != 0)` // // This method never changes the `donating_states`. - void Set(const std::string* default_value, ConstStringParam value, - Arena* arena, bool donated, uint32_t* /*donating_states*/, - uint32_t /*mask*/) { - (void)arena; - (void)donated; - SetNoArena(default_value, value); - } + void Set(ConstStringParam value, Arena* arena, bool donated, + uint32_t* donating_states, uint32_t mask, MessageLite* msg); // Rvalue Set. If this field is donated, this method will undonate this field // by mutating the `donating_states` according to `mask`. - void Set(const std::string* default_value, std::string&& value, Arena* arena, - bool donated, uint32_t* donating_states, uint32_t mask); + void Set(std::string&& value, Arena* arena, bool donated, + uint32_t* donating_states, uint32_t mask, MessageLite* msg); - template <typename FirstParam> - void Set(FirstParam p1, const char* str, ::google::protobuf::Arena* arena, bool donated, - uint32_t* donating_states, uint32_t mask) { - Set(p1, ConstStringParam(str), arena, donated, donating_states, mask); - } + void Set(const char* str, ::google::protobuf::Arena* arena, bool donated, + uint32_t* donating_states, uint32_t mask, MessageLite* msg); - template <typename FirstParam> - void Set(FirstParam p1, const char* str, size_t size, ::google::protobuf::Arena* arena, - bool donated, uint32_t* donating_states, uint32_t mask) { - ConstStringParam sp{str, size}; // for string_view and `const string &` - Set(p1, sp, arena, donated, donating_states, mask); - } + void Set(const char* str, size_t size, ::google::protobuf::Arena* arena, bool donated, + uint32_t* donating_states, uint32_t mask, MessageLite* msg); - template <typename FirstParam, typename RefWrappedType> - void Set(FirstParam p1, - std::reference_wrapper<RefWrappedType> const_string_ref, + template <typename RefWrappedType> + void Set(std::reference_wrapper<RefWrappedType> const_string_ref, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, - uint32_t mask) { - Set(p1, const_string_ref.get(), arena, donated, donating_states, mask); - } + uint32_t mask, MessageLite* msg); - template <typename FirstParam, typename SecondParam> - void SetBytes(FirstParam p1, SecondParam&& p2, ::google::protobuf::Arena* arena, - bool donated, uint32_t* donating_states, uint32_t mask) { - Set(p1, static_cast<SecondParam&&>(p2), arena, donated, donating_states, - mask); - } + void SetBytes(ConstStringParam value, Arena* arena, bool donated, + uint32_t* donating_states, uint32_t mask, MessageLite* msg); - template <typename FirstParam> - void SetBytes(FirstParam p1, const void* str, size_t size, + void SetBytes(std::string&& value, Arena* arena, bool donated, + uint32_t* donating_states, uint32_t mask, MessageLite* msg); + + void SetBytes(const char* str, ::google::protobuf::Arena* arena, bool donated, + uint32_t* donating_states, uint32_t mask, MessageLite* msg); + + void SetBytes(const void* p, size_t size, ::google::protobuf::Arena* arena, + bool donated, uint32_t* donating_states, uint32_t mask, + MessageLite* msg); + + template <typename RefWrappedType> + void SetBytes(std::reference_wrapper<RefWrappedType> const_string_ref, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, - uint32_t mask) { - // Must work whether ConstStringParam is string_view or `const string &` - ConstStringParam sp{static_cast<const char*>(str), size}; - Set(p1, sp, arena, donated, donating_states, mask); - } + uint32_t mask, MessageLite* msg); - PROTOBUF_NDEBUG_INLINE void SetNoArena(const std::string* default_value, - StringPiece value); - PROTOBUF_NDEBUG_INLINE void SetNoArena(const std::string* default_value, - std::string&& value); + PROTOBUF_NDEBUG_INLINE void SetNoArena(StringPiece value); + PROTOBUF_NDEBUG_INLINE void SetNoArena(std::string&& value); // Basic accessors. PROTOBUF_NDEBUG_INLINE const std::string& Get() const { return GetNoArena(); } @@ -193,20 +178,17 @@ class PROTOBUF_EXPORT InlinedStringField { // field is donated, this method undonates this field by mutating the // `donating_states` according to `mask`, and copies the content of the // original string to the returning string. + std::string* Mutable(Arena* arena, bool donated, uint32_t* donating_states, + uint32_t mask, MessageLite* msg); std::string* Mutable(const LazyString& default_value, Arena* arena, - bool donated, uint32_t* donating_states, uint32_t mask); - std::string* Mutable(ArenaStringPtr::EmptyDefault, Arena* arena, bool donated, - uint32_t* donating_states, uint32_t mask); + bool donated, uint32_t* donating_states, uint32_t mask, + MessageLite* msg); - // Release returns a std::string* instance that is heap-allocated and is not - // Own()'d by any arena. If the field is not set, this returns nullptr. The - // caller retains ownership. Clears this field back to nullptr state. Used to - // implement release_<field>() methods on generated classes. - PROTOBUF_NODISCARD std::string* Release(const std::string* default_value, - Arena* arena, bool donated); - PROTOBUF_NODISCARD std::string* ReleaseNonDefault( - const std::string* default_value, Arena* arena); - std::string* ReleaseNonDefaultNoArena(const std::string* default_value); + // Mutable(nullptr_t) is an overload to explicitly support Mutable(nullptr) + // calls used by the internal parser logic. This provides API equivalence with + // ArenaStringPtr, while still protecting against calls with arena pointers. + std::string* Mutable(std::nullptr_t); + std::string* MutableNoCopy(std::nullptr_t); // Takes a std::string that is heap-allocated, and takes ownership. The // std::string's destructor is registered with the arena. Used to implement @@ -216,20 +198,133 @@ class PROTOBUF_EXPORT InlinedStringField { // `donating_states` according to `mask`. void SetAllocated(const std::string* default_value, std::string* value, Arena* arena, bool donated, uint32_t* donating_states, - uint32_t mask); + uint32_t mask, MessageLite* msg); void SetAllocatedNoArena(const std::string* default_value, std::string* value); - // When one of `this` and `from` is donated and the other is not donated, this - // method will undonate the donated one and swap the two heap-allocated - // strings. - PROTOBUF_NDEBUG_INLINE void Swap(InlinedStringField* from, - const std::string* default_value, - Arena* arena, bool donated, - bool from_donated, uint32_t* donating_states, - uint32_t* from_donating_states, - uint32_t mask); + // Release returns a std::string* instance that is heap-allocated and is not + // Own()'d by any arena. If the field is not set, this returns nullptr. The + // caller retains ownership. Clears this field back to nullptr state. Used to + // implement release_<field>() methods on generated classes. + PROTOBUF_NODISCARD std::string* Release(Arena* arena, bool donated); + PROTOBUF_NODISCARD std::string* Release(); + + // -------------------------------------------------------- + // Below functions will be removed in subsequent code change + // -------------------------------------------------------- +#ifdef DEPRECATED_METHODS_TO_BE_DELETED + PROTOBUF_NODISCARD std::string* Release(const std::string*, Arena* arena, + bool donated) { + return Release(arena, donated); + } + + PROTOBUF_NODISCARD std::string* ReleaseNonDefault(const std::string*, + Arena* arena) { + return Release(); + } + + std::string* ReleaseNonDefaultNoArena(const std::string* default_value) { + return Release(); + } + + void Set(const std::string*, ConstStringParam value, Arena* arena, + bool donated, uint32_t* donating_states, uint32_t mask, + MessageLite* msg) { + Set(value, arena, donated, donating_states, mask, msg); + } + + void Set(const std::string*, std::string&& value, Arena* arena, bool donated, + uint32_t* donating_states, uint32_t mask, MessageLite* msg) { + Set(std::move(value), arena, donated, donating_states, mask, msg); + } + + + template <typename FirstParam> + void Set(FirstParam, const char* str, ::google::protobuf::Arena* arena, bool donated, + uint32_t* donating_states, uint32_t mask, MessageLite* msg) { + Set(str, arena, donated, donating_states, mask, msg); + } + + template <typename FirstParam> + void Set(FirstParam p1, const char* str, size_t size, ::google::protobuf::Arena* arena, + bool donated, uint32_t* donating_states, uint32_t mask, + MessageLite* msg) { + Set(str, size, arena, donated, donating_states, mask, msg); + } + + template <typename FirstParam, typename RefWrappedType> + void Set(FirstParam p1, + std::reference_wrapper<RefWrappedType> const_string_ref, + ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, + uint32_t mask, MessageLite* msg) { + Set(const_string_ref, arena, donated, donating_states, mask, msg); + } + + void SetBytes(const std::string*, ConstStringParam value, Arena* arena, + bool donated, uint32_t* donating_states, uint32_t mask, + MessageLite* msg) { + Set(value, arena, donated, donating_states, mask, msg); + } + + + void SetBytes(const std::string*, std::string&& value, Arena* arena, + bool donated, uint32_t* donating_states, uint32_t mask, + MessageLite* msg) { + Set(std::move(value), arena, donated, donating_states, mask, msg); + } + + template <typename FirstParam> + void SetBytes(FirstParam p1, const char* str, ::google::protobuf::Arena* arena, + bool donated, uint32_t* donating_states, uint32_t mask, + MessageLite* msg) { + SetBytes(str, arena, donated, donating_states, mask, msg); + } + + template <typename FirstParam> + void SetBytes(FirstParam p1, const void* p, size_t size, + ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, + uint32_t mask, MessageLite* msg) { + SetBytes(p, size, arena, donated, donating_states, mask, msg); + } + + template <typename FirstParam, typename RefWrappedType> + void SetBytes(FirstParam p1, + std::reference_wrapper<RefWrappedType> const_string_ref, + ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, + uint32_t mask, MessageLite* msg) { + SetBytes(const_string_ref.get(), arena, donated, donating_states, mask, + msg); + } + + void SetNoArena(const std::string*, StringPiece value) { + SetNoArena(value); + } + void SetNoArena(const std::string*, std::string&& value) { + SetNoArena(std::move(value)); + } + + std::string* Mutable(ArenaStringPtr::EmptyDefault, Arena* arena, bool donated, + uint32_t* donating_states, uint32_t mask, + MessageLite* msg) { + return Mutable(arena, donated, donating_states, mask, msg); + } + + PROTOBUF_NDEBUG_INLINE std::string* MutableNoArenaNoDefault( + const std::string* /*default_value*/) { + return MutableNoCopy(nullptr); + } + +#endif // DEPRECATED_METHODS_TO_BE_DELETED + + // Arena-safety semantics: this is guarded by the logic in + // Swap()/UnsafeArenaSwap() at the message level, so this method is + // 'unsafe' if called directly. + inline PROTOBUF_NDEBUG_INLINE static void InternalSwap( + InlinedStringField* lhs, Arena* lhs_arena, bool lhs_arena_dtor_registered, + MessageLite* lhs_msg, // + InlinedStringField* rhs, Arena* rhs_arena, bool rhs_arena_dtor_registered, + MessageLite* rhs_msg); // Frees storage (if not on an arena). PROTOBUF_NDEBUG_INLINE void Destroy(const std::string* default_value, @@ -254,17 +349,13 @@ class PROTOBUF_EXPORT InlinedStringField { void ClearToDefault(const LazyString& default_value, Arena* arena, bool donated); - // Returns a mutable pointer, but doesn't initialize the string to the - // default value. - PROTOBUF_NDEBUG_INLINE std::string* MutableNoArenaNoDefault( - const std::string* /*default_value*/); - // Generated code / reflection only! Returns a mutable pointer to the string. PROTOBUF_NDEBUG_INLINE std::string* UnsafeMutablePointer(); // InlinedStringField doesn't have things like the `default_value` pointer in // ArenaStringPtr. - bool IsDefault(const std::string* /*default_value*/) const { return false; } + static constexpr bool IsDefault() { return false; } + static constexpr bool IsDefault(const std::string*) { return false; } private: void Destruct() { get_mutable()->~basic_string(); } @@ -275,7 +366,8 @@ class PROTOBUF_EXPORT InlinedStringField { alignas(std::string) char value_[sizeof(std::string)]; std::string* MutableSlow(::google::protobuf::Arena* arena, bool donated, - uint32_t* donating_states, uint32_t mask); + uint32_t* donating_states, uint32_t mask, + MessageLite* msg); // When constructed in an Arena, we want our destructor to be skipped. @@ -297,12 +389,8 @@ inline InlinedStringField::InlinedStringField( new (get_mutable()) std::string(default_value); } -inline InlinedStringField::InlinedStringField(Arena* arena) { - Init(); - if (arena != nullptr) { - arena->OwnDestructor(get_mutable()); - } -} + +inline InlinedStringField::InlinedStringField(Arena* /*arena*/) { Init(); } inline const std::string& InlinedStringField::GetNoArena() const { return *get_const(); @@ -325,56 +413,116 @@ inline void InlinedStringField::DestroyNoArena(const std::string*) { this->~InlinedStringField(); } -inline std::string* InlinedStringField::ReleaseNonDefaultNoArena( - const std::string* /*default_value*/) { - // Currently, inlined string field can't have non empty default. - auto* released = new std::string(); - get_mutable()->swap(*released); - return released; -} - -inline void InlinedStringField::SetNoArena(const std::string* /*default_value*/, - StringPiece value) { +inline void InlinedStringField::SetNoArena(StringPiece value) { get_mutable()->assign(value.data(), value.length()); } -inline void InlinedStringField::SetNoArena(const std::string* /*default_value*/, - std::string&& value) { +inline void InlinedStringField::SetNoArena(std::string&& value) { get_mutable()->assign(std::move(value)); } -inline void InlinedStringField::Swap( - InlinedStringField* from, const std::string* /*default_value*/, - Arena* arena, bool donated, bool from_donated, uint32_t* donating_states, - uint32_t* from_donating_states, uint32_t mask) { +// Caller should make sure rhs_arena allocated rhs, and lhs_arena allocated lhs. +inline PROTOBUF_NDEBUG_INLINE void InlinedStringField::InternalSwap( + InlinedStringField* lhs, Arena* lhs_arena, bool lhs_arena_dtor_registered, + MessageLite* lhs_msg, // + InlinedStringField* rhs, Arena* rhs_arena, bool rhs_arena_dtor_registered, + MessageLite* rhs_msg) { #if GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE - // If one is donated and the other is not, undonate the donated one. - if (donated && !from_donated) { - MutableSlow(arena, donated, donating_states, mask); - } else if (!donated && from_donated) { - from->MutableSlow(arena, from_donated, from_donating_states, mask); + lhs->get_mutable()->swap(*rhs->get_mutable()); + if (!lhs_arena_dtor_registered && rhs_arena_dtor_registered) { + lhs_msg->OnDemandRegisterArenaDtor(lhs_arena); + } else if (lhs_arena_dtor_registered && !rhs_arena_dtor_registered) { + rhs_msg->OnDemandRegisterArenaDtor(rhs_arena); } - // Then, swap the two undonated strings. #else - (void)arena; - (void)donated; - (void)from_donated; - (void)donating_states; - (void)from_donating_states; - (void)mask; + (void)lhs_arena; + (void)rhs_arena; + (void)lhs_arena_dtor_registered; + (void)rhs_arena_dtor_registered; + (void)lhs_msg; + (void)rhs_msg; + lhs->get_mutable()->swap(*rhs->get_mutable()); #endif - get_mutable()->swap(*from->get_mutable()); } -inline std::string* InlinedStringField::MutableNoArenaNoDefault( - const std::string*) { - return get_mutable(); +inline void InlinedStringField::Set(ConstStringParam value, Arena* arena, + bool donated, uint32_t* /*donating_states*/, + uint32_t /*mask*/, MessageLite* /*msg*/) { + (void)arena; + (void)donated; + SetNoArena(value); +} + +inline void InlinedStringField::Set(const char* str, ::google::protobuf::Arena* arena, + bool donated, uint32_t* donating_states, + uint32_t mask, MessageLite* msg) { + Set(ConstStringParam(str), arena, donated, donating_states, mask, msg); +} + +inline void InlinedStringField::Set(const char* str, size_t size, + ::google::protobuf::Arena* arena, bool donated, + uint32_t* donating_states, uint32_t mask, + MessageLite* msg) { + Set(ConstStringParam{str, size}, arena, donated, donating_states, mask, msg); +} + +inline void InlinedStringField::SetBytes(ConstStringParam value, Arena* arena, + bool donated, + uint32_t* donating_states, + uint32_t mask, MessageLite* msg) { + Set(value, arena, donated, donating_states, mask, msg); +} + +inline void InlinedStringField::SetBytes(std::string&& value, Arena* arena, + bool donated, + uint32_t* donating_states, + uint32_t mask, MessageLite* msg) { + Set(std::move(value), arena, donated, donating_states, mask, msg); +} + +inline void InlinedStringField::SetBytes(const char* str, + ::google::protobuf::Arena* arena, bool donated, + uint32_t* donating_states, + uint32_t mask, MessageLite* msg) { + Set(str, arena, donated, donating_states, mask, msg); +} + +inline void InlinedStringField::SetBytes(const void* p, size_t size, + ::google::protobuf::Arena* arena, bool donated, + uint32_t* donating_states, + uint32_t mask, MessageLite* msg) { + Set(static_cast<const char*>(p), size, arena, donated, donating_states, mask, + msg); +} + +template <typename RefWrappedType> +inline void InlinedStringField::Set( + std::reference_wrapper<RefWrappedType> const_string_ref, + ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, + uint32_t mask, MessageLite* msg) { + Set(const_string_ref.get(), arena, donated, donating_states, mask, msg); +} + +template <typename RefWrappedType> +inline void InlinedStringField::SetBytes( + std::reference_wrapper<RefWrappedType> const_string_ref, + ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, + uint32_t mask, MessageLite* msg) { + Set(const_string_ref.get(), arena, donated, donating_states, mask, msg); } inline std::string* InlinedStringField::UnsafeMutablePointer() { return get_mutable(); } +inline std::string* InlinedStringField::Mutable(std::nullptr_t) { + return get_mutable(); +} + +inline std::string* InlinedStringField::MutableNoCopy(std::nullptr_t) { + return get_mutable(); +} + } // namespace internal } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/inlined_string_field_unittest.cc b/r5dev/thirdparty/protobuf/inlined_string_field_unittest.cc index a644c2fd..46425be0 100644 --- a/r5dev/thirdparty/protobuf/inlined_string_field_unittest.cc +++ b/r5dev/thirdparty/protobuf/inlined_string_field_unittest.cc @@ -35,6 +35,7 @@ #include <cstring> #include <memory> #include <string> +#include <utility> #include <vector> #include <thirdparty/protobuf/stubs/logging.h> @@ -52,235 +53,7 @@ namespace protobuf { using internal::ArenaStringPtr; using internal::InlinedStringField; -static std::string WrapString(const char* value) { return value; } - namespace { - -const uint32 kMask = ~0x00000001u; -const uint32 kMask1 = ~0x00000004u; -const uint32 kMask2 = ~0x00000020u; - -TEST(InlinedStringFieldTest, SetOnHeap) { - InlinedStringField field; - uint32 donating_states = 0; - const std::string kDefaultValue = "default"; - field.Set(&kDefaultValue, WrapString("Test short"), nullptr, false, - &donating_states, kMask); - EXPECT_EQ(std::string("Test short"), field.Get()); - field.Set(&kDefaultValue, WrapString("Test long long long long value"), - nullptr, false, &donating_states, kMask); - EXPECT_EQ(std::string("Test long long long long value"), field.Get()); -} - -TEST(InlinedStringFieldTest, SetRvalueOnHeap) { - InlinedStringField field; - uint32 donating_states = 0; - std::string string_moved = "Moved long long long long string 1"; - field.Set(nullptr, std::move(string_moved), nullptr, false, &donating_states, - kMask); - EXPECT_EQ("Moved long long long long string 1", field.Get()); - EXPECT_EQ(donating_states & ~kMask1, 0); -} - -TEST(InlinedStringFieldTest, UnsafeMutablePointerThenRelease) { - InlinedStringField field; - const std::string kDefaultValue = "default"; - std::string* mut = field.UnsafeMutablePointer(); - // The address of inlined string doesn't change behind the scene. - EXPECT_EQ(mut, field.UnsafeMutablePointer()); - EXPECT_EQ(mut, &field.Get()); - EXPECT_EQ(std::string(""), *mut); - *mut = "Test long long long long value"; // ensure string allocates - EXPECT_EQ(std::string("Test long long long long value"), field.Get()); - - std::string* released = field.ReleaseNonDefaultNoArena(&kDefaultValue); - EXPECT_EQ("Test long long long long value", *released); - // Default value is ignored. - EXPECT_EQ("", field.Get()); - delete released; -} - -// When donating mechanism is enabled: -// - Initially, the string is donated. -// - After lvalue Set: the string is still donated. -// - After Mutable: the string is undonated. The data buffer of the string is a -// new buffer on the heap. -TEST(InlinedStringFieldTest, ArenaSetThenMutable) { - Arena arena; - auto* field_arena = Arena::CreateMessage<InlinedStringField>(&arena); - uint32 donating_states = ~0u; - const std::string kDefaultValue = "default"; - field_arena->Set(&kDefaultValue, WrapString("Test short"), &arena, - /*donated=*/true, &donating_states, kMask1); - EXPECT_EQ(std::string("Test short"), field_arena->Get()); - field_arena->Set(&kDefaultValue, "Test long long long long value", &arena, - /*donated=*/(donating_states & ~kMask1) != 0, - &donating_states, kMask1); - EXPECT_EQ(std::string("Test long long long long value"), field_arena->Get()); -#if GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE - EXPECT_NE(donating_states & ~kMask1, 0); // donate. -#endif - - const std::string* old_string = &field_arena->Get(); - const char* old_data = old_string->data(); - (void)old_data; - std::string* mut = field_arena->Mutable( - ArenaStringPtr::EmptyDefault{}, &arena, - /*donated=*/(donating_states & ~kMask1) != 0, &donating_states, kMask1); - EXPECT_EQ(old_string, mut); -#if GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE - EXPECT_EQ(donating_states & ~kMask1, 0); - EXPECT_NE(old_data, mut->data()); // The data buffer of the mutated string is - // a new buffer on the heap. -#endif - *mut = "Test an even longer long long long long value"; - EXPECT_EQ(std::string("Test an even longer long long long long value"), - field_arena->Get()); - EXPECT_EQ(&field_arena->Get(), mut); -} - -// Release doesn't change the donating state. -// When donating mechanism is enabled: -// - Initially, the string is donated. -// - Then lvalue Set: the string is still donated. -// - Then Release: the string is cleared, and still donated. -// - Then Mutable: the string is undonated. -// - Then Release: the string is still undonated. -TEST(InlinedStringFieldTest, ArenaRelease) { - Arena arena; - auto* field_arena = Arena::CreateMessage<InlinedStringField>(&arena); - uint32 donating_states = ~0u; - const std::string kDefaultValue = "default"; - field_arena->Set(&kDefaultValue, WrapString("Test short"), &arena, - /*donated=*/true, &donating_states, kMask1); - std::string* released = field_arena->Release( - &kDefaultValue, &arena, /*donated=*/(donating_states & ~kMask1) != 0); - EXPECT_EQ("Test short", *released); - EXPECT_EQ("", field_arena->Get()); - EXPECT_NE(released, &field_arena->Get()); -#if GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE - EXPECT_NE(donating_states & ~kMask1, 0); // still donated. -#endif - delete released; - - std::string* mut = field_arena->Mutable( - ArenaStringPtr::EmptyDefault{}, &arena, - /*donated=*/(donating_states & ~kMask1) != 0u, &donating_states, kMask1); - *mut = "Test long long long long value"; - std::string* released2 = - field_arena->Release(&kDefaultValue, &arena, - /*donated=*/(donating_states & ~kMask1) != 0); - EXPECT_EQ("Test long long long long value", *released2); - EXPECT_EQ("", field_arena->Get()); -#if GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE - EXPECT_EQ(donating_states & ~kMask1, 0); // undonated. -#endif - delete released2; -} - -// Rvalue Set always undoantes a donated string. -TEST(InlinedStringFieldTest, SetRvalueArena) { - Arena arena; - auto* field1_arena = Arena::CreateMessage<InlinedStringField>(&arena); - auto* field2_arena = Arena::CreateMessage<InlinedStringField>(&arena); - uint32 donating_states = ~0u; - const std::string kDefaultValue = "default"; - - std::string string_moved = "Moved long long long long string 1"; - field1_arena->Set(nullptr, std::move(string_moved), &arena, true, - &donating_states, kMask1); - EXPECT_EQ("Moved long long long long string 1", field1_arena->Get()); -#if GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE - EXPECT_EQ(donating_states & ~kMask1, 0); // Undonate. -#endif - - field2_arena->Set(nullptr, std::string("string 2 on heap"), &arena, true, - &donating_states, kMask); - EXPECT_EQ("string 2 on heap", field2_arena->Get()); -#if GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE - EXPECT_EQ(donating_states & ~kMask, 0); // Undonated. -#endif -} - -// Tests SetAllocated for non-arena string fields and arena string fields. -TEST(InlinedStringFieldTest, SetAllocated) { - InlinedStringField field; - Arena arena; - auto* field1_arena = Arena::CreateMessage<InlinedStringField>(&arena); - auto* field2_arena = Arena::CreateMessage<InlinedStringField>(&arena); - uint32 donating_states = ~0u; - const std::string kDefaultValue = "default"; - - // The string in field is on heap. - field.Set(&kDefaultValue, WrapString("String on heap"), nullptr, false, - &donating_states, kMask); - auto* allocated = new std::string("Allocated string on heap"); - field.SetAllocatedNoArena(&kDefaultValue, allocated); - EXPECT_EQ("Allocated string on heap", field.Get()); - - // The string in field1_arena is on arena (aka. donated). - field1_arena->Set(&kDefaultValue, WrapString("String 1 on arena"), &arena, - true, &donating_states, kMask1); - *field1_arena->Mutable(ArenaStringPtr::EmptyDefault{}, &arena, - (donating_states & ~kMask1) != 0, &donating_states, - kMask1) = "Mutated string 1 is now on heap long long"; - // After Mutable, the string is undonated. - allocated = new std::string("Allocated string on heap long long long"); - field1_arena->SetAllocated(&kDefaultValue, allocated, &arena, - (donating_states & ~kMask1) != 0, &donating_states, - kMask1); - EXPECT_EQ("Allocated string on heap long long long", field1_arena->Get()); -#if GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE - EXPECT_EQ(donating_states & ~kMask1, 0); // Still undonated. -#endif - - // The string in field2_arena is on arena (aka. donated). - field2_arena->Set(&kDefaultValue, WrapString("String 2 on arena long long"), - &arena, true, &donating_states, - kMask2); // Still donated. - allocated = new std::string("Allocated string on heap long long long 2"); - field2_arena->SetAllocated(&kDefaultValue, allocated, &arena, true, - &donating_states, kMask2); - EXPECT_EQ("Allocated string on heap long long long 2", field2_arena->Get()); -#if GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE - EXPECT_EQ(donating_states & ~kMask2, 0); // Undonated. -#endif -} - -// Tests Swap for non-arena string fields and arena string fields. -TEST(InlinedStringFieldTest, Swap) { - // Swap should only be called when the from and to are on the same arena. - InlinedStringField field1; - InlinedStringField field2; - uint32 donating_states = 0; - Arena arena; - auto* field1_arena = Arena::CreateMessage<InlinedStringField>(&arena); - auto* field2_arena = Arena::CreateMessage<InlinedStringField>(&arena); - uint32 donating_states_1 = ~0u; - uint32 donating_states_2 = ~0u; - const std::string kDefaultValue = "default"; - - const std::string& string1_heap = "String 1 on heap"; - const std::string& string2_heap = "String 2 on heap long long long long"; - const std::string& string1_arena = "String 1 on arena"; - const std::string& string2_arena = "String 2 on arena long long long long"; - field1.SetNoArena(&kDefaultValue, string1_heap); - field2.SetNoArena(&kDefaultValue, string2_heap); - field1_arena->Set(&kDefaultValue, string1_arena, &arena, true, - &donating_states_1, kMask1); - field2_arena->Set(&kDefaultValue, string2_arena, &arena, true, - &donating_states_2, kMask1); - - field1.Swap(&field2, &kDefaultValue, nullptr, false, false, &donating_states, - &donating_states_2, kMask); - field1_arena->Swap(field2_arena, &kDefaultValue, &arena, true, true, - &donating_states_1, &donating_states_2, kMask1); - EXPECT_EQ(field1.Get(), string2_heap); - EXPECT_EQ(field2.Get(), string1_heap); - EXPECT_EQ(field1_arena->Get(), string2_arena); - EXPECT_EQ(field2_arena->Get(), string1_arena); -} - } // namespace } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/io/coded_stream.cc b/r5dev/thirdparty/protobuf/io/coded_stream.cc index 868158ba..142bd031 100644 --- a/r5dev/thirdparty/protobuf/io/coded_stream.cc +++ b/r5dev/thirdparty/protobuf/io/coded_stream.cc @@ -54,6 +54,7 @@ #include <thirdparty/protobuf/stubs/stl_util.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -196,7 +197,7 @@ void CodedInputStream::PrintTotalBytesLimitError() { << total_bytes_limit_ << " bytes). To increase the limit (or to disable these " "warnings), see CodedInputStream::SetTotalBytesLimit() " - "in third_party/protobuf/src/google/protobuf/io/coded_stream.h."; + "in third_party/protobuf/io/coded_stream.h."; } bool CodedInputStream::SkipFallback(int count, int original_buffer_size) { @@ -391,7 +392,7 @@ inline ::std::pair<bool, const uint8_t*> ReadVarint32FromArray( b = *(ptr++); result += b << 28; if (!(b & 0x80)) goto done; - // "result -= 0x80 << 28" is irrevelant. + // "result -= 0x80 << 28" is irrelevant. // If the input is larger than 32 bits, we still need to read it all // and discard the high-order bits. @@ -704,7 +705,7 @@ int EpsCopyOutputStream::Flush(uint8_t* ptr) { uint8_t* EpsCopyOutputStream::Trim(uint8_t* ptr) { if (had_error_) return ptr; int s = Flush(ptr); - if (s) stream_->BackUp(s); + stream_->BackUp(s); // Reset to initial state (expecting new buffer) buffer_end_ = end_ = buffer_; return buffer_; @@ -929,18 +930,6 @@ uint8_t* EpsCopyOutputStream::WriteStringOutline(uint32_t num, const std::string std::atomic<bool> CodedOutputStream::default_serialization_deterministic_{ false}; -CodedOutputStream::CodedOutputStream(ZeroCopyOutputStream* stream, - bool do_eager_refresh) - : impl_(stream, IsDefaultSerializationDeterministic(), &cur_), - start_count_(stream->ByteCount()) { - if (do_eager_refresh) { - void* data; - int size; - if (!stream->Next(&data, &size) || size == 0) return; - cur_ = impl_.SetInitialBuffer(data, size); - } -} - CodedOutputStream::~CodedOutputStream() { Trim(); } diff --git a/r5dev/thirdparty/protobuf/io/coded_stream.h b/r5dev/thirdparty/protobuf/io/coded_stream.h index 654959c9..59b5f05b 100644 --- a/r5dev/thirdparty/protobuf/io/coded_stream.h +++ b/r5dev/thirdparty/protobuf/io/coded_stream.h @@ -121,36 +121,13 @@ #include <type_traits> #include <utility> -#ifdef _WIN32 -// Assuming windows is always little-endian. -#if !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) -#define PROTOBUF_LITTLE_ENDIAN 1 -#endif #if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER) // If MSVC has "/RTCc" set, it will complain about truncating casts at // runtime. This file contains some intentional truncating casts. #pragma runtime_checks("c", off) #endif -#else -#ifdef __APPLE__ -#include <machine/endian.h> // __BYTE_ORDER -#elif defined(__FreeBSD__) -#include <sys/endian.h> // __BYTE_ORDER -#elif (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__)) -#include <sys/isa_defs.h> // __BYTE_ORDER -#elif defined(_AIX) || defined(__TOS_AIX__) -#include <sys/machine.h> // BYTE_ORDER -#else -#if !defined(__QNX__) -#include <endian.h> // __BYTE_ORDER -#endif -#endif -#if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \ - (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)) && \ - !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) -#define PROTOBUF_LITTLE_ENDIAN 1 -#endif -#endif + + #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/strutil.h> @@ -158,6 +135,7 @@ #include <thirdparty/protobuf/stubs/port.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -848,6 +826,7 @@ class PROTOBUF_EXPORT EpsCopyOutputStream { bool had_error_ = false; bool aliasing_enabled_ = false; // See EnableAliasing(). bool is_serialization_deterministic_; + bool skip_check_consistency = false; uint8_t* EnsureSpaceFallback(uint8_t* ptr); inline uint8_t* Next(); @@ -955,7 +934,8 @@ class PROTOBUF_EXPORT EpsCopyOutputStream { template <int S> uint8_t* WriteRawLittleEndian(const void* data, int size, uint8_t* ptr); -#ifndef PROTOBUF_LITTLE_ENDIAN +#if !defined(PROTOBUF_LITTLE_ENDIAN) || \ + defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) uint8_t* WriteRawLittleEndian32(const void* data, int size, uint8_t* ptr); uint8_t* WriteRawLittleEndian64(const void* data, int size, uint8_t* ptr); #endif @@ -1002,7 +982,8 @@ template <> inline uint8_t* EpsCopyOutputStream::WriteRawLittleEndian<4>(const void* data, int size, uint8_t* ptr) { -#ifdef PROTOBUF_LITTLE_ENDIAN +#if defined(PROTOBUF_LITTLE_ENDIAN) && \ + !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) return WriteRaw(data, size, ptr); #else return WriteRawLittleEndian32(data, size, ptr); @@ -1012,7 +993,8 @@ template <> inline uint8_t* EpsCopyOutputStream::WriteRawLittleEndian<8>(const void* data, int size, uint8_t* ptr) { -#ifdef PROTOBUF_LITTLE_ENDIAN +#if defined(PROTOBUF_LITTLE_ENDIAN) && \ + !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) return WriteRaw(data, size, ptr); #else return WriteRawLittleEndian64(data, size, ptr); @@ -1067,10 +1049,18 @@ inline uint8_t* EpsCopyOutputStream::WriteRawLittleEndian<8>(const void* data, // delete coded_output; class PROTOBUF_EXPORT CodedOutputStream { public: - // Create an CodedOutputStream that writes to the given ZeroCopyOutputStream. - explicit CodedOutputStream(ZeroCopyOutputStream* stream) - : CodedOutputStream(stream, true) {} - CodedOutputStream(ZeroCopyOutputStream* stream, bool do_eager_refresh); + // Creates a CodedOutputStream that writes to the given `stream`. + // The provided stream must publicly derive from `ZeroCopyOutputStream`. + template <class Stream, class = typename std::enable_if<std::is_base_of< + ZeroCopyOutputStream, Stream>::value>::type> + explicit CodedOutputStream(Stream* stream); + + // Creates a CodedOutputStream that writes to the given `stream`, and does + // an 'eager initialization' of the internal state if `eager_init` is true. + // The provided stream must publicly derive from `ZeroCopyOutputStream`. + template <class Stream, class = typename std::enable_if<std::is_base_of< + ZeroCopyOutputStream, Stream>::value>::type> + CodedOutputStream(Stream* stream, bool eager_init); // Destroy the CodedOutputStream and position the underlying // ZeroCopyOutputStream immediately after the last byte written. @@ -1233,7 +1223,7 @@ class PROTOBUF_EXPORT CodedOutputStream { // remains live until all of the data has been consumed from the stream. void EnableAliasing(bool enabled) { impl_.EnableAliasing(enabled); } - // Indicate to the serializer whether the user wants derministic + // Indicate to the serializer whether the user wants deterministic // serialization. The default when this is not called comes from the global // default, controlled by SetDefaultSerializationDeterministic. // @@ -1276,6 +1266,9 @@ class PROTOBUF_EXPORT CodedOutputStream { EpsCopyOutputStream* EpsCopy() { return &impl_; } private: + template <class Stream> + void InitEagerly(Stream* stream); + EpsCopyOutputStream impl_; uint8_t* cur_; int64_t start_count_; @@ -1344,7 +1337,8 @@ inline bool CodedInputStream::ReadVarintSizeAsInt(int* value) { // static inline const uint8_t* CodedInputStream::ReadLittleEndian32FromArray( const uint8_t* buffer, uint32_t* value) { -#if defined(PROTOBUF_LITTLE_ENDIAN) +#if defined(PROTOBUF_LITTLE_ENDIAN) && \ + !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) memcpy(value, buffer, sizeof(*value)); return buffer + sizeof(*value); #else @@ -1358,7 +1352,8 @@ inline const uint8_t* CodedInputStream::ReadLittleEndian32FromArray( // static inline const uint8_t* CodedInputStream::ReadLittleEndian64FromArray( const uint8_t* buffer, uint64_t* value) { -#if defined(PROTOBUF_LITTLE_ENDIAN) +#if defined(PROTOBUF_LITTLE_ENDIAN) && \ + !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) memcpy(value, buffer, sizeof(*value)); return buffer + sizeof(*value); #else @@ -1376,7 +1371,8 @@ inline const uint8_t* CodedInputStream::ReadLittleEndian64FromArray( } inline bool CodedInputStream::ReadLittleEndian32(uint32_t* value) { -#if defined(PROTOBUF_LITTLE_ENDIAN) +#if defined(PROTOBUF_LITTLE_ENDIAN) && \ + !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) if (PROTOBUF_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) { buffer_ = ReadLittleEndian32FromArray(buffer_, value); return true; @@ -1389,7 +1385,8 @@ inline bool CodedInputStream::ReadLittleEndian32(uint32_t* value) { } inline bool CodedInputStream::ReadLittleEndian64(uint64_t* value) { -#if defined(PROTOBUF_LITTLE_ENDIAN) +#if defined(PROTOBUF_LITTLE_ENDIAN) && \ + !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) if (PROTOBUF_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) { buffer_ = ReadLittleEndian64FromArray(buffer_, value); return true; @@ -1620,6 +1617,31 @@ inline bool CodedInputStream::Skip(int count) { return SkipFallback(count, original_buffer_size); } +template <class Stream, class> +inline CodedOutputStream::CodedOutputStream(Stream* stream) + : impl_(stream, IsDefaultSerializationDeterministic(), &cur_), + start_count_(stream->ByteCount()) { + InitEagerly(stream); +} + +template <class Stream, class> +inline CodedOutputStream::CodedOutputStream(Stream* stream, bool eager_init) + : impl_(stream, IsDefaultSerializationDeterministic(), &cur_), + start_count_(stream->ByteCount()) { + if (eager_init) { + InitEagerly(stream); + } +} + +template <class Stream> +inline void CodedOutputStream::InitEagerly(Stream* stream) { + void* data; + int size; + if (PROTOBUF_PREDICT_TRUE(stream->Next(&data, &size) && size > 0)) { + cur_ = impl_.SetInitialBuffer(data, size); + } +} + inline uint8_t* CodedOutputStream::WriteVarint32ToArray(uint32_t value, uint8_t* target) { return EpsCopyOutputStream::UnsafeVarint(value, target); @@ -1651,7 +1673,8 @@ inline uint8_t* CodedOutputStream::WriteVarint32SignExtendedToArray( inline uint8_t* CodedOutputStream::WriteLittleEndian32ToArray(uint32_t value, uint8_t* target) { -#if defined(PROTOBUF_LITTLE_ENDIAN) +#if defined(PROTOBUF_LITTLE_ENDIAN) && \ + !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) memcpy(target, &value, sizeof(value)); #else target[0] = static_cast<uint8_t>(value); @@ -1664,7 +1687,8 @@ inline uint8_t* CodedOutputStream::WriteLittleEndian32ToArray(uint32_t value, inline uint8_t* CodedOutputStream::WriteLittleEndian64ToArray(uint64_t value, uint8_t* target) { -#if defined(PROTOBUF_LITTLE_ENDIAN) +#if defined(PROTOBUF_LITTLE_ENDIAN) && \ + !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) memcpy(target, &value, sizeof(value)); #else uint32_t part0 = static_cast<uint32_t>(value); diff --git a/r5dev/thirdparty/protobuf/io/coded_stream_unittest.cc b/r5dev/thirdparty/protobuf/io/coded_stream_unittest.cc index dd162afd..c75eeac7 100644 --- a/r5dev/thirdparty/protobuf/io/coded_stream_unittest.cc +++ b/r5dev/thirdparty/protobuf/io/coded_stream_unittest.cc @@ -38,7 +38,9 @@ #include <limits.h> +#include <algorithm> #include <memory> +#include <string> #include <vector> #include <thirdparty/protobuf/stubs/common.h> @@ -49,6 +51,7 @@ #include <gtest/gtest.h> #include <thirdparty/protobuf/stubs/casts.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> @@ -89,7 +92,7 @@ namespace { }; \ \ TEST_F(FIXTURE##_##NAME##_DD, NAME) { \ - for (int i = 0; i < GOOGLE_ARRAYSIZE(CASES); i++) { \ + for (size_t i = 0; i < GOOGLE_ARRAYSIZE(CASES); i++) { \ SCOPED_TRACE(testing::Message() \ << #CASES " case #" << i << ": " << CASES[i]); \ DoSingleCase(CASES[i]); \ @@ -108,8 +111,8 @@ namespace { }; \ \ TEST_F(FIXTURE##_##NAME##_DD, NAME) { \ - for (int i = 0; i < GOOGLE_ARRAYSIZE(CASES1); i++) { \ - for (int j = 0; j < GOOGLE_ARRAYSIZE(CASES2); j++) { \ + for (size_t i = 0; i < GOOGLE_ARRAYSIZE(CASES1); i++) { \ + for (size_t j = 0; j < GOOGLE_ARRAYSIZE(CASES2); j++) { \ SCOPED_TRACE(testing::Message() \ << #CASES1 " case #" << i << ": " << CASES1[i] << ", " \ << #CASES2 " case #" << j << ": " << CASES2[j]); \ @@ -128,10 +131,10 @@ class CodedStreamTest : public testing::Test { protected: // Buffer used during most of the tests. This assumes tests run sequentially. static constexpr int kBufferSize = 1024 * 64; - static uint8 buffer_[kBufferSize]; + static uint8_t buffer_[kBufferSize]; }; -uint8 CodedStreamTest::buffer_[CodedStreamTest::kBufferSize]; +uint8_t CodedStreamTest::buffer_[CodedStreamTest::kBufferSize]; // We test each operation over a variety of block sizes to insure that // we test cases where reads or writes cross buffer boundaries, cases @@ -145,9 +148,9 @@ const int kBlockSizes[] = {1, 2, 3, 5, 7, 13, 32, 1024}; // Varint tests. struct VarintCase { - uint8 bytes[10]; // Encoded bytes. - int size; // Encoded size, in bytes. - uint64 value; // Parsed value. + uint8_t bytes[10]; // Encoded bytes. + size_t size; // Encoded size, in bytes. + uint64_t value; // Parsed value. }; inline std::ostream& operator<<(std::ostream& os, const VarintCase& c) { @@ -191,9 +194,9 @@ TEST_2D(CodedStreamTest, ReadVarint32, kVarintCases, kBlockSizes) { { CodedInputStream coded_input(&input); - uint32 value; + uint32_t value; EXPECT_TRUE(coded_input.ReadVarint32(&value)); - EXPECT_EQ(static_cast<uint32>(kVarintCases_case.value), value); + EXPECT_EQ(static_cast<uint32_t>(kVarintCases_case.value), value); } EXPECT_EQ(kVarintCases_case.size, input.ByteCount()); @@ -206,7 +209,7 @@ TEST_2D(CodedStreamTest, ReadTag, kVarintCases, kBlockSizes) { { CodedInputStream coded_input(&input); - uint32 expected_value = static_cast<uint32>(kVarintCases_case.value); + uint32_t expected_value = static_cast<uint32_t>(kVarintCases_case.value); EXPECT_EQ(expected_value, coded_input.ReadTag()); EXPECT_TRUE(coded_input.LastTagWas(expected_value)); @@ -225,7 +228,7 @@ TEST_F(CodedStreamTest, EmptyInputBeforeEos) { private: bool Next(const void** data, int* size) override { - *data = NULL; + *data = nullptr; *size = 0; return count_++ < 2; } @@ -254,11 +257,11 @@ TEST_1D(CodedStreamTest, ExpectTag, kVarintCases) { // Read one byte to force coded_input.Refill() to be called. Otherwise, // ExpectTag() will return a false negative. - uint8 dummy; + uint8_t dummy; coded_input.ReadRaw(&dummy, 1); EXPECT_EQ((uint)'\0', (uint)dummy); - uint32 expected_value = static_cast<uint32>(kVarintCases_case.value); + uint32_t expected_value = static_cast<uint32_t>(kVarintCases_case.value); // ExpectTag() produces false negatives for large values. if (kVarintCases_case.size <= 2) { @@ -279,16 +282,17 @@ TEST_1D(CodedStreamTest, ExpectTag, kVarintCases) { TEST_1D(CodedStreamTest, ExpectTagFromArray, kVarintCases) { memcpy(buffer_, kVarintCases_case.bytes, kVarintCases_case.size); - const uint32 expected_value = static_cast<uint32>(kVarintCases_case.value); + const uint32_t expected_value = + static_cast<uint32_t>(kVarintCases_case.value); // If the expectation succeeds, it should return a pointer past the tag. if (kVarintCases_case.size <= 2) { - EXPECT_TRUE(NULL == CodedInputStream::ExpectTagFromArray( + EXPECT_TRUE(nullptr == CodedInputStream::ExpectTagFromArray( buffer_, expected_value + 1)); EXPECT_TRUE(buffer_ + kVarintCases_case.size == CodedInputStream::ExpectTagFromArray(buffer_, expected_value)); } else { - EXPECT_TRUE(NULL == + EXPECT_TRUE(nullptr == CodedInputStream::ExpectTagFromArray(buffer_, expected_value)); } } @@ -300,7 +304,7 @@ TEST_2D(CodedStreamTest, ReadVarint64, kVarintCases, kBlockSizes) { { CodedInputStream coded_input(&input); - uint64 value; + uint64_t value; EXPECT_TRUE(coded_input.ReadVarint64(&value)); EXPECT_EQ(kVarintCases_case.value, value); } @@ -319,7 +323,7 @@ TEST_2D(CodedStreamTest, WriteVarint32, kVarintCases, kBlockSizes) { { CodedOutputStream coded_output(&output); - coded_output.WriteVarint32(static_cast<uint32>(kVarintCases_case.value)); + coded_output.WriteVarint32(static_cast<uint32_t>(kVarintCases_case.value)); EXPECT_FALSE(coded_output.HadError()); EXPECT_EQ(kVarintCases_case.size, coded_output.ByteCount()); @@ -351,7 +355,7 @@ TEST_2D(CodedStreamTest, WriteVarint64, kVarintCases, kBlockSizes) { // "sorry, unimplemented: `method_call_expr' not supported by dump_expr" #if !defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3) -int32 kSignExtendedVarintCases[] = {0, 1, -1, 1237894, -37895138}; +int32_t kSignExtendedVarintCases[] = {0, 1, -1, 1237894, -37895138}; TEST_2D(CodedStreamTest, WriteVarint32SignExtended, kSignExtendedVarintCases, kBlockSizes) { @@ -382,10 +386,10 @@ TEST_2D(CodedStreamTest, WriteVarint32SignExtended, kSignExtendedVarintCases, { CodedInputStream coded_input(&input); - uint64 value; + uint64_t value; EXPECT_TRUE(coded_input.ReadVarint64(&value)); - EXPECT_EQ(kSignExtendedVarintCases_case, static_cast<int64>(value)); + EXPECT_EQ(kSignExtendedVarintCases_case, static_cast<int64_t>(value)); } EXPECT_EQ(output.ByteCount(), input.ByteCount()); @@ -398,8 +402,8 @@ TEST_2D(CodedStreamTest, WriteVarint32SignExtended, kSignExtendedVarintCases, // Varint failure test. struct VarintErrorCase { - uint8 bytes[12]; - int size; + uint8_t bytes[12]; + size_t size; bool can_parse; }; @@ -429,22 +433,22 @@ const VarintErrorCase kVarintErrorCases[] = { TEST_2D(CodedStreamTest, ReadVarint32Error, kVarintErrorCases, kBlockSizes) { memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size); - ArrayInputStream input(buffer_, kVarintErrorCases_case.size, + ArrayInputStream input(buffer_, static_cast<int>(kVarintErrorCases_case.size), kBlockSizes_case); CodedInputStream coded_input(&input); - uint32 value; + uint32_t value; EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint32(&value)); } TEST_2D(CodedStreamTest, ReadVarint32Error_LeavesValueInInitializedState, kVarintErrorCases, kBlockSizes) { memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size); - ArrayInputStream input(buffer_, kVarintErrorCases_case.size, + ArrayInputStream input(buffer_, static_cast<int>(kVarintErrorCases_case.size), kBlockSizes_case); CodedInputStream coded_input(&input); - uint32 value = 0; + uint32_t value = 0; EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint32(&value)); // While the specific value following a failure is not critical, we do want to // ensure that it doesn't get set to an uninitialized value. (This check fails @@ -454,22 +458,22 @@ TEST_2D(CodedStreamTest, ReadVarint32Error_LeavesValueInInitializedState, TEST_2D(CodedStreamTest, ReadVarint64Error, kVarintErrorCases, kBlockSizes) { memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size); - ArrayInputStream input(buffer_, kVarintErrorCases_case.size, + ArrayInputStream input(buffer_, static_cast<int>(kVarintErrorCases_case.size), kBlockSizes_case); CodedInputStream coded_input(&input); - uint64 value; + uint64_t value; EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint64(&value)); } TEST_2D(CodedStreamTest, ReadVarint64Error_LeavesValueInInitializedState, kVarintErrorCases, kBlockSizes) { memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size); - ArrayInputStream input(buffer_, kVarintErrorCases_case.size, + ArrayInputStream input(buffer_, static_cast<int>(kVarintErrorCases_case.size), kBlockSizes_case); CodedInputStream coded_input(&input); - uint64 value = 0; + uint64_t value = 0; EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint64(&value)); // While the specific value following a failure is not critical, we do want to // ensure that it doesn't get set to an uninitialized value. (This check fails @@ -481,7 +485,7 @@ TEST_2D(CodedStreamTest, ReadVarint64Error_LeavesValueInInitializedState, // VarintSize struct VarintSizeCase { - uint64 value; + uint64_t value; int size; }; @@ -508,7 +512,7 @@ TEST_1D(CodedStreamTest, VarintSize32, kVarintSizeCases) { EXPECT_EQ(kVarintSizeCases_case.size, CodedOutputStream::VarintSize32( - static_cast<uint32>(kVarintSizeCases_case.value))); + static_cast<uint32_t>(kVarintSizeCases_case.value))); } TEST_1D(CodedStreamTest, VarintSize64, kVarintSizeCases) { @@ -522,8 +526,8 @@ TEST_F(CodedStreamTest, VarintSize32PowersOfTwo) { if (i % 7 == 0) { expected += 1; } - EXPECT_EQ(expected, - CodedOutputStream::VarintSize32(static_cast<uint32>(0x1u << i))); + EXPECT_EQ(expected, CodedOutputStream::VarintSize32( + static_cast<uint32_t>(0x1u << i))); } } @@ -533,8 +537,7 @@ TEST_F(CodedStreamTest, VarintSize64PowersOfTwo) { if (i % 7 == 0) { expected += 1; } - EXPECT_EQ(expected, CodedOutputStream::VarintSize64( - static_cast<uint64>(0x1ull << i))); + EXPECT_EQ(expected, CodedOutputStream::VarintSize64(uint64_t{1} << i)); } } @@ -542,13 +545,13 @@ TEST_F(CodedStreamTest, VarintSize64PowersOfTwo) { // Fixed-size int tests struct Fixed32Case { - uint8 bytes[sizeof(uint32)]; // Encoded bytes. - uint32 value; // Parsed value. + uint8_t bytes[sizeof(uint32_t)]; // Encoded bytes. + uint32_t value; // Parsed value. }; struct Fixed64Case { - uint8 bytes[sizeof(uint64)]; // Encoded bytes. - uint64 value; // Parsed value. + uint8_t bytes[sizeof(uint64_t)]; // Encoded bytes. + uint64_t value; // Parsed value. }; inline std::ostream& operator<<(std::ostream& os, const Fixed32Case& c) { @@ -578,12 +581,12 @@ TEST_2D(CodedStreamTest, ReadLittleEndian32, kFixed32Cases, kBlockSizes) { { CodedInputStream coded_input(&input); - uint32 value; + uint32_t value; EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); EXPECT_EQ(kFixed32Cases_case.value, value); } - EXPECT_EQ(sizeof(uint32), input.ByteCount()); + EXPECT_EQ(sizeof(uint32_t), input.ByteCount()); } TEST_2D(CodedStreamTest, ReadLittleEndian64, kFixed64Cases, kBlockSizes) { @@ -593,12 +596,12 @@ TEST_2D(CodedStreamTest, ReadLittleEndian64, kFixed64Cases, kBlockSizes) { { CodedInputStream coded_input(&input); - uint64 value; + uint64_t value; EXPECT_TRUE(coded_input.ReadLittleEndian64(&value)); EXPECT_EQ(kFixed64Cases_case.value, value); } - EXPECT_EQ(sizeof(uint64), input.ByteCount()); + EXPECT_EQ(sizeof(uint64_t), input.ByteCount()); } TEST_2D(CodedStreamTest, WriteLittleEndian32, kFixed32Cases, kBlockSizes) { @@ -610,11 +613,11 @@ TEST_2D(CodedStreamTest, WriteLittleEndian32, kFixed32Cases, kBlockSizes) { coded_output.WriteLittleEndian32(kFixed32Cases_case.value); EXPECT_FALSE(coded_output.HadError()); - EXPECT_EQ(sizeof(uint32), coded_output.ByteCount()); + EXPECT_EQ(sizeof(uint32_t), coded_output.ByteCount()); } - EXPECT_EQ(sizeof(uint32), output.ByteCount()); - EXPECT_EQ(0, memcmp(buffer_, kFixed32Cases_case.bytes, sizeof(uint32))); + EXPECT_EQ(sizeof(uint32_t), output.ByteCount()); + EXPECT_EQ(0, memcmp(buffer_, kFixed32Cases_case.bytes, sizeof(uint32_t))); } TEST_2D(CodedStreamTest, WriteLittleEndian64, kFixed64Cases, kBlockSizes) { @@ -626,11 +629,11 @@ TEST_2D(CodedStreamTest, WriteLittleEndian64, kFixed64Cases, kBlockSizes) { coded_output.WriteLittleEndian64(kFixed64Cases_case.value); EXPECT_FALSE(coded_output.HadError()); - EXPECT_EQ(sizeof(uint64), coded_output.ByteCount()); + EXPECT_EQ(sizeof(uint64_t), coded_output.ByteCount()); } - EXPECT_EQ(sizeof(uint64), output.ByteCount()); - EXPECT_EQ(0, memcmp(buffer_, kFixed64Cases_case.bytes, sizeof(uint64))); + EXPECT_EQ(sizeof(uint64_t), output.ByteCount()); + EXPECT_EQ(0, memcmp(buffer_, kFixed64Cases_case.bytes, sizeof(uint64_t))); } // Tests using the static methods to read fixed-size values from raw arrays. @@ -638,8 +641,8 @@ TEST_2D(CodedStreamTest, WriteLittleEndian64, kFixed64Cases, kBlockSizes) { TEST_1D(CodedStreamTest, ReadLittleEndian32FromArray, kFixed32Cases) { memcpy(buffer_, kFixed32Cases_case.bytes, sizeof(kFixed32Cases_case.bytes)); - uint32 value; - const uint8* end = + uint32_t value; + const uint8_t* end = CodedInputStream::ReadLittleEndian32FromArray(buffer_, &value); EXPECT_EQ(kFixed32Cases_case.value, value); EXPECT_TRUE(end == buffer_ + sizeof(value)); @@ -648,8 +651,8 @@ TEST_1D(CodedStreamTest, ReadLittleEndian32FromArray, kFixed32Cases) { TEST_1D(CodedStreamTest, ReadLittleEndian64FromArray, kFixed64Cases) { memcpy(buffer_, kFixed64Cases_case.bytes, sizeof(kFixed64Cases_case.bytes)); - uint64 value; - const uint8* end = + uint64_t value; + const uint8_t* end = CodedInputStream::ReadLittleEndian64FromArray(buffer_, &value); EXPECT_EQ(kFixed64Cases_case.value, value); EXPECT_TRUE(end == buffer_ + sizeof(value)); @@ -722,14 +725,14 @@ TEST_1D(CodedStreamTest, ReadStringImpossiblyLarge, kBlockSizes) { TEST_F(CodedStreamTest, ReadStringImpossiblyLargeFromStringOnStack) { // Same test as above, except directly use a buffer. This used to cause // crashes while the above did not. - uint8 buffer[8]; + uint8_t buffer[8]; CodedInputStream coded_input(buffer, 8); std::string str; EXPECT_FALSE(coded_input.ReadString(&str, 1 << 30)); } TEST_F(CodedStreamTest, ReadStringImpossiblyLargeFromStringOnHeap) { - std::unique_ptr<uint8[]> buffer(new uint8[8]); + std::unique_ptr<uint8_t[]> buffer(new uint8_t[8]); CodedInputStream coded_input(buffer.get(), 8); std::string str; EXPECT_FALSE(coded_input.ReadString(&str, 1 << 30)); @@ -1020,7 +1023,7 @@ TEST_1D(CodedStreamTest, BasicLimit, kBlockSizes) { CodedInputStream::Limit limit = coded_input.PushLimit(8); // Read until we hit the limit. - uint32 value; + uint32_t value; EXPECT_EQ(8, coded_input.BytesUntilLimit()); EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); EXPECT_EQ(4, coded_input.BytesUntilLimit()); @@ -1051,7 +1054,7 @@ TEST_1D(CodedStreamTest, SmallLimitOnTopOfBigLimit, kBlockSizes) { EXPECT_EQ(8, coded_input.BytesUntilLimit()); CodedInputStream::Limit limit2 = coded_input.PushLimit(4); - uint32 value; + uint32_t value; // Read until we hit limit2, the top and shortest limit. EXPECT_EQ(4, coded_input.BytesUntilLimit()); @@ -1093,7 +1096,7 @@ TEST_1D(CodedStreamTest, BigLimitOnTopOfSmallLimit, kBlockSizes) { EXPECT_EQ(4, coded_input.BytesUntilLimit()); CodedInputStream::Limit limit2 = coded_input.PushLimit(8); - uint32 value; + uint32_t value; // Read until we hit limit2. Except, wait! limit1 is shorter, so // we end up hitting that first, despite having 4 bytes to go on @@ -1130,7 +1133,7 @@ TEST_F(CodedStreamTest, ExpectAtEnd) { CodedInputStream::Limit limit = coded_input.PushLimit(4); - uint32 value; + uint32_t value; EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); EXPECT_TRUE(coded_input.ExpectAtEnd()); @@ -1275,7 +1278,6 @@ TEST_F(CodedStreamTest, RecursionLimit) { class ReallyBigInputStream : public ZeroCopyInputStream { public: ReallyBigInputStream() : backup_amount_(0), buffer_count_(0) {} - ~ReallyBigInputStream() {} // implements ZeroCopyInputStream ---------------------------------- bool Next(const void** data, int* size) override { @@ -1315,7 +1317,7 @@ class ReallyBigInputStream : public ZeroCopyInputStream { private: char buffer_[1024]; - int64 buffer_count_; + int64_t buffer_count_; }; TEST_F(CodedStreamTest, InputOver2G) { diff --git a/r5dev/thirdparty/protobuf/io/gzip_stream.cc b/r5dev/thirdparty/protobuf/io/gzip_stream.cc index e4d3eefb..ee3e0c15 100644 --- a/r5dev/thirdparty/protobuf/io/gzip_stream.cc +++ b/r5dev/thirdparty/protobuf/io/gzip_stream.cc @@ -36,6 +36,7 @@ #if HAVE_ZLIB #include <thirdparty/protobuf/io/gzip_stream.h> +#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> @@ -70,7 +71,7 @@ GzipInputStream::GzipInputStream(ZeroCopyInputStream* sub_stream, Format format, output_position_ = output_buffer_; } GzipInputStream::~GzipInputStream() { - operator delete(output_buffer_); + internal::SizedDelete(output_buffer_, output_buffer_length_); zerror_ = inflateEnd(&zcontext_); } @@ -244,7 +245,7 @@ void GzipOutputStream::Init(ZeroCopyOutputStream* sub_stream, GzipOutputStream::~GzipOutputStream() { Close(); - operator delete(input_buffer_); + internal::SizedDelete(input_buffer_, input_buffer_length_); } // private diff --git a/r5dev/thirdparty/protobuf/io/gzip_stream.h b/r5dev/thirdparty/protobuf/io/gzip_stream.h index 483bebff..da7e53ac 100644 --- a/r5dev/thirdparty/protobuf/io/gzip_stream.h +++ b/r5dev/thirdparty/protobuf/io/gzip_stream.h @@ -47,8 +47,9 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/port.h> -#include <zlib.h> +#include "zlib.h" +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -56,7 +57,8 @@ namespace protobuf { namespace io { // A ZeroCopyInputStream that reads compressed data through zlib -class PROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream { +class PROTOBUF_EXPORT GzipInputStream PROTOBUF_FUTURE_FINAL + : public ZeroCopyInputStream { public: // Format key for constructor enum Format { @@ -104,7 +106,8 @@ class PROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipInputStream); }; -class PROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream { +class PROTOBUF_EXPORT GzipOutputStream PROTOBUF_FUTURE_FINAL + : public ZeroCopyOutputStream { public: // Format key for constructor enum Format { diff --git a/r5dev/thirdparty/protobuf/io/io_win32.cc b/r5dev/thirdparty/protobuf/io/io_win32.cc index ae8f048e..64c6d81a 100644 --- a/r5dev/thirdparty/protobuf/io/io_win32.cc +++ b/r5dev/thirdparty/protobuf/io/io_win32.cc @@ -397,7 +397,8 @@ ExpandWildcardsResult ExpandWildcards( matched = ExpandWildcardsResult::kSuccess; string filename; if (!strings::wcs_to_utf8(metadata.cFileName, &filename)) { - return ExpandWildcardsResult::kErrorOutputPathConversion; + matched = ExpandWildcardsResult::kErrorOutputPathConversion; + break; } if (dirname.empty()) { diff --git a/r5dev/thirdparty/protobuf/io/io_win32.h b/r5dev/thirdparty/protobuf/io/io_win32.h index 7c3f01d4..4e195113 100644 --- a/r5dev/thirdparty/protobuf/io/io_win32.h +++ b/r5dev/thirdparty/protobuf/io/io_win32.h @@ -53,6 +53,8 @@ #include <string> #include <thirdparty/protobuf/port.h> + +// Must be included last. #include <thirdparty/protobuf/port_def.inc> // Compilers on Windows other than MSVC (e.g. Cygwin, MinGW32) define the diff --git a/r5dev/thirdparty/protobuf/io/io_win32_unittest.cc b/r5dev/thirdparty/protobuf/io/io_win32_unittest.cc index 853ef183..a728da26 100644 --- a/r5dev/thirdparty/protobuf/io/io_win32_unittest.cc +++ b/r5dev/thirdparty/protobuf/io/io_win32_unittest.cc @@ -164,8 +164,8 @@ void IoWin32Test::SetUp() { test_tmpdir.clear(); wtest_tmpdir.clear(); DWORD size = ::GetCurrentDirectoryW(MAX_PATH, working_directory); - EXPECT_GT(size, 0); - EXPECT_LT(size, MAX_PATH); + EXPECT_GT(size, 0U); + EXPECT_LT(size, static_cast<DWORD>(MAX_PATH)); string tmp; bool ok = false; @@ -581,7 +581,7 @@ TEST_F(IoWin32Test, ExpandWildcardsFailsIfNoFileMatchesTest) { TEST_F(IoWin32Test, AsWindowsPathTest) { DWORD size = GetCurrentDirectoryW(0, nullptr); std::unique_ptr<wchar_t[]> cwd_str(new wchar_t[size]); - EXPECT_GT(GetCurrentDirectoryW(size, cwd_str.get()), 0); + EXPECT_GT(GetCurrentDirectoryW(size, cwd_str.get()), 0U); wstring cwd = wstring(L"\\\\?\\") + cwd_str.get(); ASSERT_EQ(testonly_utf8_to_winpath("relative_mkdirtest"), diff --git a/r5dev/thirdparty/protobuf/io/printer.cc b/r5dev/thirdparty/protobuf/io/printer.cc index 1091ee17..21beea09 100644 --- a/r5dev/thirdparty/protobuf/io/printer.cc +++ b/r5dev/thirdparty/protobuf/io/printer.cc @@ -66,8 +66,11 @@ Printer::Printer(ZeroCopyOutputStream* output, char variable_delimiter, annotation_collector_(annotation_collector) {} Printer::~Printer() { - // Only BackUp() if we have called Next() at least once and never failed. - if (buffer_size_ > 0 && !failed_) { + // Only BackUp() if we invoked Next() at least once, and we have never failed. + // Note that we always call `Backup`, i.e. we call BackUp(0) as some output + // streams have buffered output, and BackUp() serves as a flush event in such + // implementations. + if (buffer_ != nullptr && !failed_) { output_->BackUp(buffer_size_); } } diff --git a/r5dev/thirdparty/protobuf/io/printer.h b/r5dev/thirdparty/protobuf/io/printer.h index 786dcfd0..c5a0ae4f 100644 --- a/r5dev/thirdparty/protobuf/io/printer.h +++ b/r5dev/thirdparty/protobuf/io/printer.h @@ -43,6 +43,8 @@ #include <vector> #include <thirdparty/protobuf/stubs/common.h> + +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/io/tokenizer.cc b/r5dev/thirdparty/protobuf/io/tokenizer.cc index 53aa5fa7..c786f129 100644 --- a/r5dev/thirdparty/protobuf/io/tokenizer.cc +++ b/r5dev/thirdparty/protobuf/io/tokenizer.cc @@ -92,12 +92,15 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/io/strtod.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/stubs/stl_util.h> +// Must be included last. +#include <thirdparty/protobuf/port_def.inc> + namespace google { namespace protobuf { namespace io { @@ -147,12 +150,32 @@ CHARACTER_CLASS(Escape, c == 'a' || c == 'b' || c == 'f' || c == 'n' || // Given a char, interpret it as a numeric digit and return its value. // This supports any number base up to 36. -inline int DigitValue(char digit) { - if ('0' <= digit && digit <= '9') return digit - '0'; - if ('a' <= digit && digit <= 'z') return digit - 'a' + 10; - if ('A' <= digit && digit <= 'Z') return digit - 'A' + 10; - return -1; -} +// Represents integer values of digits. +// Uses 36 to indicate an invalid character since we support +// bases up to 36. +static const int8_t kAsciiToInt[256] = { + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, // 00-0F + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, // 10-1F + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, // ' '-'/' + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // '0'-'9' + 36, 36, 36, 36, 36, 36, 36, // ':'-'@' + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // 'A'-'P' + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, // 'Q'-'Z' + 36, 36, 36, 36, 36, 36, // '['-'`' + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // 'a'-'p' + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, // 'q'-'z' + 36, 36, 36, 36, 36, // '{'-DEL + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, // 80-8F + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, // 90-9F + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, // A0-AF + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, // B0-BF + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, // C0-CF + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, // D0-DF + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, // E0-EF + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, // F0-FF +}; + +inline int DigitValue(char digit) { return kAsciiToInt[digit & 0xFF]; } // Inline because it's only used in one place. inline char TranslateEscape(char c) { @@ -686,7 +709,7 @@ bool Tokenizer::Next() { error_collector_->AddError( line_, column_, StringPrintf("Interpreting non ascii codepoint %d.", - static_cast<unsigned char>(current_char_))); + static_cast<unsigned char>(current_char_))); } NextChar(); current_.type = TYPE_SYMBOL; @@ -911,25 +934,49 @@ bool Tokenizer::NextWithComments(std::string* prev_trailing_comments, bool Tokenizer::ParseInteger(const std::string& text, uint64_t max_value, uint64_t* output) { - // Sadly, we can't just use strtoul() since it is only 32-bit and strtoull() - // is non-standard. I hate the C standard library. :( + // We can't just use strtoull() because (a) it accepts negative numbers, + // (b) We want additional range checks, (c) it reports overflows via errno. - // return strtoull(text.c_str(), NULL, 0); +#if 0 + const char *str_begin = text.c_str(); + if (*str_begin == '-') return false; + char *str_end = nullptr; + errno = 0; + *output = std::strtoull(str_begin, &str_end, 0); + return (errno == 0 && str_end && *str_end == '\0' && *output <= max_value); +#endif const char* ptr = text.c_str(); int base = 10; + uint64_t overflow_if_mul_base = (kuint64max / 10) + 1; if (ptr[0] == '0') { if (ptr[1] == 'x' || ptr[1] == 'X') { // This is hex. base = 16; + overflow_if_mul_base = (kuint64max / 16) + 1; ptr += 2; } else { // This is octal. base = 8; + overflow_if_mul_base = (kuint64max / 8) + 1; } } uint64_t result = 0; + // For all the leading '0's, and also the first non-zero character, we + // don't need to multiply. + while (*ptr != '\0') { + int digit = DigitValue(*ptr++); + if (digit >= base) { + // The token provided by Tokenizer is invalid. i.e., 099 is an invalid + // token, but Tokenizer still think it's integer. + return false; + } + if (digit != 0) { + result = digit; + break; + } + } for (; *ptr != '\0'; ptr++) { int digit = DigitValue(*ptr); if (digit < 0 || digit >= base) { @@ -937,13 +984,18 @@ bool Tokenizer::ParseInteger(const std::string& text, uint64_t max_value, // token, but Tokenizer still think it's integer. return false; } - if (static_cast<uint64_t>(digit) > max_value || - result > (max_value - digit) / base) { - // Overflow. + if (result >= overflow_if_mul_base) { + // We know the multiply we're about to do will overflow, so exit now. return false; } + // We know that result * base won't overflow, but adding digit might... result = result * base + digit; + // C++ guarantees defined "wrap" semantics when unsigned integer + // operations overflow, making this a fast way to check if adding + // digit made result overflow, and thus, wrap around. + if (result < static_cast<uint64_t>(base)) return false; } + if (result > max_value) return false; *output = result; return true; @@ -1183,3 +1235,5 @@ bool Tokenizer::IsIdentifier(const std::string& text) { } // namespace io } // namespace protobuf } // namespace google + +#include <thirdparty/protobuf/port_undef.inc> diff --git a/r5dev/thirdparty/protobuf/io/tokenizer.h b/r5dev/thirdparty/protobuf/io/tokenizer.h index e9f0f31a..db244187 100644 --- a/r5dev/thirdparty/protobuf/io/tokenizer.h +++ b/r5dev/thirdparty/protobuf/io/tokenizer.h @@ -43,6 +43,8 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> + +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/io/tokenizer_unittest.cc b/r5dev/thirdparty/protobuf/io/tokenizer_unittest.cc index 108adbc4..6206bbc2 100644 --- a/r5dev/thirdparty/protobuf/io/tokenizer_unittest.cc +++ b/r5dev/thirdparty/protobuf/io/tokenizer_unittest.cc @@ -178,9 +178,10 @@ const int kBlockSizes[] = {1, 2, 3, 5, 7, 13, 32, 1024}; class TokenizerTest : public testing::Test { protected: // For easy testing. - uint64 ParseInteger(const std::string& text) { - uint64 result; - EXPECT_TRUE(Tokenizer::ParseInteger(text, kuint64max, &result)); + uint64_t ParseInteger(const std::string& text) { + uint64_t result; + EXPECT_TRUE(Tokenizer::ParseInteger(text, kuint64max, &result)) + << "'" << text << "'"; return result; } }; @@ -809,8 +810,8 @@ TEST_2D(TokenizerTest, DocComments, kDocCommentCases, kBlockSizes) { // ------------------------------------------------------------------- -// Test parse helpers. It's not really worth setting up a full data-driven -// test here. +// Test parse helpers. +// TODO(b/225783758): Add a fuzz test for this. TEST_F(TokenizerTest, ParseInteger) { EXPECT_EQ(0, ParseInteger("0")); EXPECT_EQ(123, ParseInteger("123")); @@ -823,7 +824,7 @@ TEST_F(TokenizerTest, ParseInteger) { // Test invalid integers that may still be tokenized as integers. EXPECT_EQ(0, ParseInteger("0x")); - uint64 i; + uint64_t i; // Test invalid integers that will never be tokenized as integers. EXPECT_FALSE(Tokenizer::ParseInteger("zxy", kuint64max, &i)); @@ -840,6 +841,107 @@ TEST_F(TokenizerTest, ParseInteger) { EXPECT_FALSE(Tokenizer::ParseInteger("12346", 12345, &i)); EXPECT_TRUE(Tokenizer::ParseInteger("0xFFFFFFFFFFFFFFFF", kuint64max, &i)); EXPECT_FALSE(Tokenizer::ParseInteger("0x10000000000000000", kuint64max, &i)); + + // Test near the limits of signed parsing (values in kint64max +/- 1600) + for (int64_t offset = -1600; offset <= 1600; ++offset) { + // We make sure to perform an unsigned addition so that we avoid signed + // overflow, which would be undefined behavior. + uint64_t i = 0x7FFFFFFFFFFFFFFFu + static_cast<uint64_t>(offset); + char decimal[32]; + snprintf(decimal, 32, "%llu", static_cast<unsigned long long>(i)); + if (offset > 0) { + uint64_t parsed = -1; + EXPECT_FALSE(Tokenizer::ParseInteger(decimal, kint64max, &parsed)) + << decimal << "=>" << parsed; + } else { + uint64_t parsed = -1; + EXPECT_TRUE(Tokenizer::ParseInteger(decimal, kint64max, &parsed)) + << decimal << "=>" << parsed; + EXPECT_EQ(parsed, i); + } + char octal[32]; + snprintf(octal, 32, "0%llo", static_cast<unsigned long long>(i)); + if (offset > 0) { + uint64_t parsed = -1; + EXPECT_FALSE(Tokenizer::ParseInteger(octal, kint64max, &parsed)) + << octal << "=>" << parsed; + } else { + uint64_t parsed = -1; + EXPECT_TRUE(Tokenizer::ParseInteger(octal, kint64max, &parsed)) + << octal << "=>" << parsed; + EXPECT_EQ(parsed, i); + } + char hex[32]; + snprintf(hex, 32, "0x%llx", static_cast<unsigned long long>(i)); + if (offset > 0) { + uint64_t parsed = -1; + EXPECT_FALSE(Tokenizer::ParseInteger(hex, kint64max, &parsed)) + << hex << "=>" << parsed; + } else { + uint64_t parsed = -1; + EXPECT_TRUE(Tokenizer::ParseInteger(hex, kint64max, &parsed)) << hex; + EXPECT_EQ(parsed, i); + } + // EXPECT_NE(offset, -237); + } + + // Test near the limits of unsigned parsing (values in kuint64max +/- 1600) + // By definition, values greater than kuint64max cannot be held in a uint64_t + // variable, so printing them is a little tricky; fortunately all but the + // last four digits are known, so we can hard-code them in the printf string, + // and we only need to format the last 4. + for (int64_t offset = -1600; offset <= 1600; ++offset) { + { + uint64_t i = 18446744073709551615u + offset; + char decimal[32]; + snprintf(decimal, 32, "1844674407370955%04llu", + static_cast<unsigned long long>(1615 + offset)); + if (offset > 0) { + uint64_t parsed = -1; + EXPECT_FALSE(Tokenizer::ParseInteger(decimal, kuint64max, &parsed)) + << decimal << "=>" << parsed; + } else { + uint64_t parsed = -1; + EXPECT_TRUE(Tokenizer::ParseInteger(decimal, kuint64max, &parsed)) + << decimal; + EXPECT_EQ(parsed, i); + } + } + { + uint64_t i = 01777777777777777777777u + offset; + if (offset > 0) { + char octal[32]; + snprintf(octal, 32, "0200000000000000000%04llo", + static_cast<unsigned long long>(offset - 1)); + uint64_t parsed = -1; + EXPECT_FALSE(Tokenizer::ParseInteger(octal, kuint64max, &parsed)) + << octal << "=>" << parsed; + } else { + char octal[32]; + snprintf(octal, 32, "0%llo", static_cast<unsigned long long>(i)); + uint64_t parsed = -1; + EXPECT_TRUE(Tokenizer::ParseInteger(octal, kuint64max, &parsed)) + << octal; + EXPECT_EQ(parsed, i); + } + } + { + uint64_t ui = 0xffffffffffffffffu + offset; + char hex[32]; + if (offset > 0) { + snprintf(hex, 32, "0x1000000000000%04llx", + static_cast<unsigned long long>(offset - 1)); + uint64_t parsed = -1; + EXPECT_FALSE(Tokenizer::ParseInteger(hex, kuint64max, &parsed)) + << hex << "=>" << parsed; + } else { + snprintf(hex, 32, "0x%llx", static_cast<unsigned long long>(ui)); + uint64_t parsed = -1; + EXPECT_TRUE(Tokenizer::ParseInteger(hex, kuint64max, &parsed)) << hex; + EXPECT_EQ(parsed, ui); + } + } + } } TEST_F(TokenizerTest, ParseFloat) { diff --git a/r5dev/thirdparty/protobuf/io/zero_copy_stream.h b/r5dev/thirdparty/protobuf/io/zero_copy_stream.h index 571c22cb..a8f11cfa 100644 --- a/r5dev/thirdparty/protobuf/io/zero_copy_stream.h +++ b/r5dev/thirdparty/protobuf/io/zero_copy_stream.h @@ -108,12 +108,12 @@ #define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__ -#include <string> - #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/port_def.inc> +// Must be included last. +#include <thirdparty/protobuf/port_def.inc> + namespace google { namespace protobuf { namespace io { @@ -154,6 +154,13 @@ class PROTOBUF_EXPORT ZeroCopyInputStream { // buffer that goes beyond what you wanted to read, you can use BackUp() // to return to the point where you intended to finish. // + // This method can be called with `count = 0` to finalize (flush) any + // previously returned buffer. For example, a file output stream can + // flush buffers returned from a previous call to Next() upon such + // BackUp(0) invocations. ZeroCopyOutputStream callers should always + // invoke BackUp() after a final Next() call, even if there is no + // excess buffer data to be backed up to indicate a flush point. + // // Preconditions: // * The last method called must have been Next(). // * count must be less than or equal to the size of the last buffer diff --git a/r5dev/thirdparty/protobuf/io/zero_copy_stream_impl.h b/r5dev/thirdparty/protobuf/io/zero_copy_stream_impl.h index dafb4330..67d8acb3 100644 --- a/r5dev/thirdparty/protobuf/io/zero_copy_stream_impl.h +++ b/r5dev/thirdparty/protobuf/io/zero_copy_stream_impl.h @@ -48,6 +48,7 @@ #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -62,7 +63,8 @@ namespace io { // The latter will introduce an extra layer of buffering, harming performance. // Also, it's conceivable that FileInputStream could someday be enhanced // to use zero-copy file descriptors on OSs which support them. -class PROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream { +class PROTOBUF_EXPORT FileInputStream PROTOBUF_FUTURE_FINAL + : public ZeroCopyInputStream { public: // Creates a stream that reads from the given Unix file descriptor. // If a block_size is given, it specifies the number of bytes that @@ -95,7 +97,8 @@ class PROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream { int64_t ByteCount() const override; private: - class PROTOBUF_EXPORT CopyingFileInputStream : public CopyingInputStream { + class PROTOBUF_EXPORT CopyingFileInputStream PROTOBUF_FUTURE_FINAL + : public CopyingInputStream { public: CopyingFileInputStream(int file_descriptor); ~CopyingFileInputStream() override; @@ -139,7 +142,8 @@ class PROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream { // harming performance. Also, it's conceivable that FileOutputStream could // someday be enhanced to use zero-copy file descriptors on OSs which // support them. -class PROTOBUF_EXPORT FileOutputStream : public CopyingOutputStreamAdaptor { +class PROTOBUF_EXPORT FileOutputStream PROTOBUF_FUTURE_FINAL + : public CopyingOutputStreamAdaptor { public: // Creates a stream that writes to the given Unix file descriptor. // If a block_size is given, it specifies the size of the buffers @@ -168,7 +172,8 @@ class PROTOBUF_EXPORT FileOutputStream : public CopyingOutputStreamAdaptor { int GetErrno() const { return copying_output_.GetErrno(); } private: - class PROTOBUF_EXPORT CopyingFileOutputStream : public CopyingOutputStream { + class PROTOBUF_EXPORT CopyingFileOutputStream PROTOBUF_FUTURE_FINAL + : public CopyingOutputStream { public: CopyingFileOutputStream(int file_descriptor); ~CopyingFileOutputStream() override; @@ -203,7 +208,8 @@ class PROTOBUF_EXPORT FileOutputStream : public CopyingOutputStreamAdaptor { // // Note that for reading files (or anything represented by a file descriptor), // FileInputStream is more efficient. -class PROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { +class PROTOBUF_EXPORT IstreamInputStream PROTOBUF_FUTURE_FINAL + : public ZeroCopyInputStream { public: // Creates a stream that reads from the given C++ istream. // If a block_size is given, it specifies the number of bytes that @@ -218,7 +224,8 @@ class PROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { int64_t ByteCount() const override; private: - class PROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream { + class PROTOBUF_EXPORT CopyingIstreamInputStream PROTOBUF_FUTURE_FINAL + : public CopyingInputStream { public: CopyingIstreamInputStream(std::istream* input); ~CopyingIstreamInputStream() override; @@ -246,7 +253,8 @@ class PROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { // // Note that for writing files (or anything represented by a file descriptor), // FileOutputStream is more efficient. -class PROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { +class PROTOBUF_EXPORT OstreamOutputStream PROTOBUF_FUTURE_FINAL + : public ZeroCopyOutputStream { public: // Creates a stream that writes to the given C++ ostream. // If a block_size is given, it specifies the size of the buffers @@ -261,7 +269,7 @@ class PROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { int64_t ByteCount() const override; private: - class PROTOBUF_EXPORT CopyingOstreamOutputStream + class PROTOBUF_EXPORT CopyingOstreamOutputStream PROTOBUF_FUTURE_FINAL : public CopyingOutputStream { public: CopyingOstreamOutputStream(std::ostream* output); @@ -292,7 +300,8 @@ class PROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { // ConcatenatingInputStream may do odd things. It is suggested that you do // not use ConcatenatingInputStream on streams that might produce read errors // other than end-of-stream. -class PROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream { +class PROTOBUF_EXPORT ConcatenatingInputStream PROTOBUF_FUTURE_FINAL + : public ZeroCopyInputStream { public: // All streams passed in as well as the array itself must remain valid // until the ConcatenatingInputStream is destroyed. diff --git a/r5dev/thirdparty/protobuf/io/zero_copy_stream_impl_lite.cc b/r5dev/thirdparty/protobuf/io/zero_copy_stream_impl_lite.cc index a828f368..3b7d0367 100644 --- a/r5dev/thirdparty/protobuf/io/zero_copy_stream_impl_lite.cc +++ b/r5dev/thirdparty/protobuf/io/zero_copy_stream_impl_lite.cc @@ -124,12 +124,11 @@ bool ArrayOutputStream::Next(void** data, int* size) { } void ArrayOutputStream::BackUp(int count) { - GOOGLE_CHECK_GT(last_returned_size_, 0) - << "BackUp() can only be called after a successful Next()."; - GOOGLE_CHECK_LE(count, last_returned_size_); + GOOGLE_CHECK_LE(count, last_returned_size_) + << "BackUp() can not exceed the size of the last Next() call."; GOOGLE_CHECK_GE(count, 0); position_ -= count; - last_returned_size_ = 0; // Don't let caller back up further. + last_returned_size_ -= count; } int64_t ArrayOutputStream::ByteCount() const { return position_; } @@ -328,6 +327,10 @@ bool CopyingOutputStreamAdaptor::Next(void** data, int* size) { } void CopyingOutputStreamAdaptor::BackUp(int count) { + if (count == 0) { + Flush(); + return; + } GOOGLE_CHECK_GE(count, 0); GOOGLE_CHECK_EQ(buffer_used_, buffer_size_) << " BackUp() can only be called after Next()."; diff --git a/r5dev/thirdparty/protobuf/io/zero_copy_stream_impl_lite.h b/r5dev/thirdparty/protobuf/io/zero_copy_stream_impl_lite.h index 412280ce..d3c08039 100644 --- a/r5dev/thirdparty/protobuf/io/zero_copy_stream_impl_lite.h +++ b/r5dev/thirdparty/protobuf/io/zero_copy_stream_impl_lite.h @@ -55,6 +55,7 @@ #include <thirdparty/protobuf/stubs/stl_util.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -64,7 +65,8 @@ namespace io { // =================================================================== // A ZeroCopyInputStream backed by an in-memory array of bytes. -class PROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream { +class PROTOBUF_EXPORT ArrayInputStream PROTOBUF_FUTURE_FINAL + : public ZeroCopyInputStream { public: // Create an InputStream that returns the bytes pointed to by "data". // "data" remains the property of the caller but must remain valid until @@ -98,7 +100,8 @@ class PROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream { // =================================================================== // A ZeroCopyOutputStream backed by an in-memory array of bytes. -class PROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream { +class PROTOBUF_EXPORT ArrayOutputStream PROTOBUF_FUTURE_FINAL + : public ZeroCopyOutputStream { public: // Create an OutputStream that writes to the bytes pointed to by "data". // "data" remains the property of the caller but must remain valid until @@ -130,7 +133,8 @@ class PROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream { // =================================================================== // A ZeroCopyOutputStream which appends bytes to a string. -class PROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream { +class PROTOBUF_EXPORT StringOutputStream PROTOBUF_FUTURE_FINAL + : public ZeroCopyOutputStream { public: // Create a StringOutputStream which appends bytes to the given string. // The string remains property of the caller, but it is mutated in arbitrary @@ -346,7 +350,8 @@ class PROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream { // A ZeroCopyInputStream which wraps some other stream and limits it to // a particular byte count. -class PROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream { +class PROTOBUF_EXPORT LimitingInputStream PROTOBUF_FUTURE_FINAL + : public ZeroCopyInputStream { public: LimitingInputStream(ZeroCopyInputStream* input, int64_t limit); ~LimitingInputStream() override; diff --git a/r5dev/thirdparty/protobuf/io/zero_copy_stream_unittest.cc b/r5dev/thirdparty/protobuf/io/zero_copy_stream_unittest.cc index 33a6c254..deec2a6e 100644 --- a/r5dev/thirdparty/protobuf/io/zero_copy_stream_unittest.cc +++ b/r5dev/thirdparty/protobuf/io/zero_copy_stream_unittest.cc @@ -49,7 +49,7 @@ #include <chrono> #include <thread> -#ifndef _MSC_VER +#ifndef _WIN32 #include <sys/socket.h> #include <unistd.h> #endif @@ -764,7 +764,7 @@ TEST_F(IoTest, FileIo) { } } -#ifndef _MSC_VER +#ifndef _WIN32 // This tests the FileInputStream with a non blocking file. It opens a pipe in // non blocking mode, then starts reading it. The writing thread starts writing // 100ms after that. diff --git a/r5dev/thirdparty/protobuf/lite_unittest.cc b/r5dev/thirdparty/protobuf/lite_unittest.cc index 815331ce..6ea12c9d 100644 --- a/r5dev/thirdparty/protobuf/lite_unittest.cc +++ b/r5dev/thirdparty/protobuf/lite_unittest.cc @@ -30,23 +30,25 @@ // Author: kenton@google.com (Kenton Varda) +#include <climits> #include <iostream> #include <string> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/arena_test_util.h> -#include <thirdparty/protobuf/map_lite_test_util.h> #include <thirdparty/protobuf/map_lite_unittest.pb.h> -#include <thirdparty/protobuf/test_util_lite.h> #include <thirdparty/protobuf/unittest_lite.pb.h> +#include <gtest/gtest.h> +#include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/arena_test_util.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> +#include <thirdparty/protobuf/map_lite_test_util.h> +#include <thirdparty/protobuf/parse_context.h> +#include <thirdparty/protobuf/test_util_lite.h> #include <thirdparty/protobuf/wire_format_lite.h> -#include <gtest/gtest.h> -#include <thirdparty/protobuf/stubs/strutil.h> namespace google { namespace protobuf { @@ -88,6 +90,61 @@ void SetSomeTypesInEmptyMessageUnknownFields( empty_message->ParseFromString(data); } + +TEST(ParseVarintTest, Varint32) { + auto test_value = [](uint32_t value, int varint_length) { + uint8_t buffer[10]; + uint8_t* p = io::CodedOutputStream::WriteVarint32ToArray(value, buffer); + ASSERT_EQ(p - buffer, varint_length) << "Value = " << value; + + const char* cbuffer = reinterpret_cast<const char*>(buffer); + uint32_t parsed = ~value; + const char* r = internal::VarintParse(cbuffer, &parsed); + ASSERT_EQ(r - cbuffer, varint_length) << "Value = " << value; + ASSERT_EQ(parsed, value); + }; + + uint32_t base = 73; // 1001011b + for (int varint_length = 1; varint_length <= 5; ++varint_length) { + uint32_t values[] = { + base - 73, base - 72, base, base + 126 - 73, base + 126 - 72, + }; + for (uint32_t value : values) { + test_value(value, varint_length); + } + base = (base << 7) + 73; + } + + test_value(std::numeric_limits<uint32_t>::max(), 5); +} + +TEST(ParseVarintTest, Varint64) { + auto test_value = [](uint64_t value, int varint_length) { + uint8_t buffer[10]; + uint8_t* p = io::CodedOutputStream::WriteVarint64ToArray(value, buffer); + ASSERT_EQ(p - buffer, varint_length) << "Value = " << value; + + const char* cbuffer = reinterpret_cast<const char*>(buffer); + uint64_t parsed = ~value; + const char* r = internal::VarintParse(cbuffer, &parsed); + ASSERT_EQ(r - cbuffer, varint_length) << "Value = " << value; + ASSERT_EQ(parsed, value); + }; + + uint64_t base = 73; // 1001011b + for (int varint_length = 1; varint_length <= 10; ++varint_length) { + uint64_t values[] = { + base - 73, base - 72, base, base + 126 - 73, base + 126 - 72, + }; + for (uint64_t value : values) { + test_value(value, varint_length); + } + base = (base << 7) + 73; + } + + test_value(std::numeric_limits<uint64_t>::max(), 10); +} + TEST(Lite, AllLite1) { std::string data; @@ -617,8 +674,9 @@ TEST(Lite, AllLite28) { MapLiteTestUtil::SetMapFields(&message1); size_t size = message1.ByteSizeLong(); data.resize(size); - ::google::protobuf::uint8* start = reinterpret_cast<::google::protobuf::uint8*>(::google::protobuf::string_as_array(&data)); - ::google::protobuf::uint8* end = message1.SerializeWithCachedSizesToArray(start); + ::uint8_t* start = + reinterpret_cast<::uint8_t*>(::google::protobuf::string_as_array(&data)); + ::uint8_t* end = message1.SerializeWithCachedSizesToArray(start); EXPECT_EQ(size, end - start); EXPECT_TRUE(message2.ParseFromString(data)); MapLiteTestUtil::ExpectMapFieldsSet(message2); @@ -877,7 +935,8 @@ TEST(Lite, AllLite43) { protobuf_unittest::TestOneofParsingLite message2; message2.mutable_oneof_submessage(); io::CodedInputStream input_stream( - reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), serialized.size()); + reinterpret_cast<const ::uint8_t*>(serialized.data()), + serialized.size()); EXPECT_TRUE(message2.MergeFromCodedStream(&input_stream)); EXPECT_EQ(17, message2.oneof_int32()); } @@ -887,7 +946,8 @@ TEST(Lite, AllLite43) { protobuf_unittest::TestOneofParsingLite message2; message2.set_oneof_string("string"); io::CodedInputStream input_stream( - reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), serialized.size()); + reinterpret_cast<const ::uint8_t*>(serialized.data()), + serialized.size()); EXPECT_TRUE(message2.MergeFromCodedStream(&input_stream)); EXPECT_EQ(17, message2.oneof_int32()); } @@ -897,7 +957,8 @@ TEST(Lite, AllLite43) { protobuf_unittest::TestOneofParsingLite message2; message2.set_oneof_bytes("bytes"); io::CodedInputStream input_stream( - reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), serialized.size()); + reinterpret_cast<const ::uint8_t*>(serialized.data()), + serialized.size()); EXPECT_TRUE(message2.MergeFromCodedStream(&input_stream)); EXPECT_EQ(17, message2.oneof_int32()); } @@ -916,7 +977,7 @@ TEST(Lite, AllLite44) { protobuf_unittest::TestOneofParsingLite parsed; for (int i = 0; i < 2; ++i) { io::CodedInputStream input_stream( - reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), + reinterpret_cast<const ::uint8_t*>(serialized.data()), serialized.size()); EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream)); EXPECT_EQ(17, parsed.oneof_int32()); @@ -932,7 +993,7 @@ TEST(Lite, AllLite44) { protobuf_unittest::TestOneofParsingLite parsed; for (int i = 0; i < 2; ++i) { io::CodedInputStream input_stream( - reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), + reinterpret_cast<const ::uint8_t*>(serialized.data()), serialized.size()); EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream)); EXPECT_EQ(5, parsed.oneof_submessage().optional_int32()); @@ -948,7 +1009,7 @@ TEST(Lite, AllLite44) { protobuf_unittest::TestOneofParsingLite parsed; for (int i = 0; i < 2; ++i) { io::CodedInputStream input_stream( - reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), + reinterpret_cast<const ::uint8_t*>(serialized.data()), serialized.size()); EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream)); EXPECT_EQ("string", parsed.oneof_string()); @@ -964,7 +1025,7 @@ TEST(Lite, AllLite44) { protobuf_unittest::TestOneofParsingLite parsed; for (int i = 0; i < 2; ++i) { io::CodedInputStream input_stream( - reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), + reinterpret_cast<const ::uint8_t*>(serialized.data()), serialized.size()); EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream)); EXPECT_EQ("bytes", parsed.oneof_bytes()); @@ -980,7 +1041,7 @@ TEST(Lite, AllLite44) { protobuf_unittest::TestOneofParsingLite parsed; for (int i = 0; i < 2; ++i) { io::CodedInputStream input_stream( - reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), + reinterpret_cast<const ::uint8_t*>(serialized.data()), serialized.size()); EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream)); EXPECT_EQ(protobuf_unittest::V2_SECOND, parsed.oneof_enum()); @@ -997,7 +1058,7 @@ TEST(Lite, AllLite45) { protobuf_unittest::ForeignMessageLite a; EXPECT_TRUE(a.ParseFromString(data)); io::CodedInputStream input_stream( - reinterpret_cast<const ::google::protobuf::uint8*>(data.data()), data.size()); + reinterpret_cast<const ::uint8_t*>(data.data()), data.size()); EXPECT_TRUE(a.MergePartialFromCodedStream(&input_stream)); std::string serialized = a.SerializeAsString(); @@ -1059,7 +1120,7 @@ TEST(Lite, CorrectEnding) { // will not encounter an end-group tag. However the parser should behave // like any wire format parser should. static const char kWireFormat[] = "\204\1"; - io::CodedInputStream cis(reinterpret_cast<const uint8*>(kWireFormat), 2); + io::CodedInputStream cis(reinterpret_cast<const uint8_t*>(kWireFormat), 2); // The old CodedInputStream parser got an optimization (ReadTagNoLastTag) // for non-group messages (like TestAllTypesLite) which made it not accept // end-group. This is not a real big deal, but I think going forward its @@ -1072,7 +1133,7 @@ TEST(Lite, CorrectEnding) { // This is an incomplete end-group tag. This should be a genuine parse // failure. static const char kWireFormat[] = "\214"; - io::CodedInputStream cis(reinterpret_cast<const uint8*>(kWireFormat), 1); + io::CodedInputStream cis(reinterpret_cast<const uint8_t*>(kWireFormat), 1); // Unfortunately the old parser detects a parse error in ReadTag and returns // 0 (as it states 0 is an invalid tag). However 0 is not an invalid tag // as it can be used to terminate the stream, so this returns true. diff --git a/r5dev/thirdparty/protobuf/map.h b/r5dev/thirdparty/protobuf/map.h index b9d9e10c..3af53384 100644 --- a/r5dev/thirdparty/protobuf/map.h +++ b/r5dev/thirdparty/protobuf/map.h @@ -37,6 +37,7 @@ #ifndef GOOGLE_PROTOBUF_MAP_H__ #define GOOGLE_PROTOBUF_MAP_H__ + #include <functional> #include <initializer_list> #include <iterator> @@ -58,12 +59,14 @@ #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/generated_enum_util.h> #include <thirdparty/protobuf/map_type_handler.h> +#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/stubs/hash.h> #ifdef SWIG #error "You cannot SWIG proto headers" #endif +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -115,6 +118,11 @@ class MapAllocator { MapAllocator(const MapAllocator<X>& allocator) // NOLINT(runtime/explicit) : arena_(allocator.arena()) {} + // MapAllocator does not support alignments beyond 8. Technically we should + // support up to std::max_align_t, but this fails with ubsan and tcmalloc + // debug allocation logic which assume 8 as default alignment. + static_assert(alignof(value_type) <= 8, ""); + pointer allocate(size_type n, const void* /* hint */ = nullptr) { // If arena is not given, malloc needs to be called which doesn't // construct element object. @@ -128,12 +136,7 @@ class MapAllocator { void deallocate(pointer p, size_type n) { if (arena_ == nullptr) { -#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) - ::operator delete(p, n * sizeof(value_type)); -#else - (void)n; - ::operator delete(p); -#endif + internal::SizedDelete(p, n * sizeof(value_type)); } } @@ -334,7 +337,7 @@ inline size_t SpaceUsedInValues(const void*) { return 0; } // std::pair as value_type, we use this class which provides us more control of // its process of construction and destruction. template <typename Key, typename T> -struct MapPair { +struct PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG MapPair { using first_type = const Key; using second_type = T; @@ -689,40 +692,30 @@ class Map { return FindHelper(k).first; } - // Insert the key into the map, if not present. In that case, the value will - // be value initialized. + // Inserts a new element into the container if there is no element with the + // key in the container. + // The new element is: + // (1) Constructed in-place with the given args, if mapped_type is not + // arena constructible. + // (2) Constructed in-place with the arena and then assigned with a + // mapped_type temporary constructed with the given args, otherwise. + template <typename K, typename... Args> + std::pair<iterator, bool> try_emplace(K&& k, Args&&... args) { + return ArenaAwareTryEmplace(Arena::is_arena_constructable<mapped_type>(), + std::forward<K>(k), + std::forward<Args>(args)...); + } + + // Inserts the key into the map, if not present. In that case, the value + // will be value initialized. template <typename K> std::pair<iterator, bool> insert(K&& k) { - std::pair<const_iterator, size_type> p = FindHelper(k); - // Case 1: key was already present. - if (p.first.node_ != nullptr) - return std::make_pair(iterator(p.first), false); - // Case 2: insert. - if (ResizeIfLoadIsOutOfRange(num_elements_ + 1)) { - p = FindHelper(k); - } - const size_type b = p.second; // bucket number - // If K is not key_type, make the conversion to key_type explicit. - using TypeToInit = typename std::conditional< - std::is_same<typename std::decay<K>::type, key_type>::value, K&&, - key_type>::type; - Node* node = Alloc<Node>(1); - // Even when arena is nullptr, CreateInArenaStorage is still used to - // ensure the arena of submessage will be consistent. Otherwise, - // submessage may have its own arena when message-owned arena is enabled. - Arena::CreateInArenaStorage(const_cast<Key*>(&node->kv.first), - alloc_.arena(), - static_cast<TypeToInit>(std::forward<K>(k))); - Arena::CreateInArenaStorage(&node->kv.second, alloc_.arena()); - - iterator result = InsertUnique(b, node); - ++num_elements_; - return std::make_pair(result, true); + return try_emplace(std::forward<K>(k)); } template <typename K> value_type& operator[](K&& k) { - return *insert(std::forward<K>(k)).first; + return *try_emplace(std::forward<K>(k)).first; } void erase(iterator it) { @@ -764,6 +757,79 @@ class Map { } private: + template <typename K, typename... Args> + std::pair<iterator, bool> TryEmplaceInternal(K&& k, Args&&... args) { + std::pair<const_iterator, size_type> p = FindHelper(k); + // Case 1: key was already present. + if (p.first.node_ != nullptr) + return std::make_pair(iterator(p.first), false); + // Case 2: insert. + if (ResizeIfLoadIsOutOfRange(num_elements_ + 1)) { + p = FindHelper(k); + } + const size_type b = p.second; // bucket number + // If K is not key_type, make the conversion to key_type explicit. + using TypeToInit = typename std::conditional< + std::is_same<typename std::decay<K>::type, key_type>::value, K&&, + key_type>::type; + Node* node = Alloc<Node>(1); + // Even when arena is nullptr, CreateInArenaStorage is still used to + // ensure the arena of submessage will be consistent. Otherwise, + // submessage may have its own arena when message-owned arena is enabled. + // Note: This only works if `Key` is not arena constructible. + Arena::CreateInArenaStorage(const_cast<Key*>(&node->kv.first), + alloc_.arena(), + static_cast<TypeToInit>(std::forward<K>(k))); + // Note: if `T` is arena constructible, `Args` needs to be empty. + Arena::CreateInArenaStorage(&node->kv.second, alloc_.arena(), + std::forward<Args>(args)...); + + iterator result = InsertUnique(b, node); + ++num_elements_; + return std::make_pair(result, true); + } + + // A helper function to perform an assignment of `mapped_type`. + // If the first argument is true, then it is a regular assignment. + // Otherwise, we first create a temporary and then perform an assignment. + template <typename V> + static void AssignMapped(std::true_type, mapped_type& mapped, V&& v) { + mapped = std::forward<V>(v); + } + template <typename... Args> + static void AssignMapped(std::false_type, mapped_type& mapped, + Args&&... args) { + mapped = mapped_type(std::forward<Args>(args)...); + } + + // Case 1: `mapped_type` is arena constructible. A temporary object is + // created and then (if `Args` are not empty) assigned to a mapped value + // that was created with the arena. + template <typename K> + std::pair<iterator, bool> ArenaAwareTryEmplace(std::true_type, K&& k) { + // case 1.1: "default" constructed (e.g. from arena only). + return TryEmplaceInternal(std::forward<K>(k)); + } + template <typename K, typename... Args> + std::pair<iterator, bool> ArenaAwareTryEmplace(std::true_type, K&& k, + Args&&... args) { + // case 1.2: "default" constructed + copy/move assignment + auto p = TryEmplaceInternal(std::forward<K>(k)); + if (p.second) { + AssignMapped(std::is_same<void(typename std::decay<Args>::type...), + void(mapped_type)>(), + p.first->second, std::forward<Args>(args)...); + } + return p; + } + // Case 2: `mapped_type` is not arena constructible. Using in-place + // construction. + template <typename... Args> + std::pair<iterator, bool> ArenaAwareTryEmplace(std::false_type, + Args&&... args) { + return TryEmplaceInternal(std::forward<Args>(args)...); + } + const_iterator find(const Key& k, TreeIterator* it) const { return FindHelper(k, it).first; } @@ -1279,21 +1345,26 @@ class Map { } // insert - std::pair<iterator, bool> insert(const value_type& value) { - std::pair<typename InnerMap::iterator, bool> p = - elements_.insert(value.first); - if (p.second) { - p.first->second = value.second; - } + template <typename K, typename... Args> + std::pair<iterator, bool> try_emplace(K&& k, Args&&... args) { + auto p = + elements_.try_emplace(std::forward<K>(k), std::forward<Args>(args)...); return std::pair<iterator, bool>(iterator(p.first), p.second); } + std::pair<iterator, bool> insert(const value_type& value) { + return try_emplace(value.first, value.second); + } + std::pair<iterator, bool> insert(value_type&& value) { + return try_emplace(value.first, std::move(value.second)); + } + template <typename... Args> + std::pair<iterator, bool> emplace(Args&&... args) { + return insert(value_type(std::forward<Args>(args)...)); + } template <class InputIt> void insert(InputIt first, InputIt last) { - for (InputIt it = first; it != last; ++it) { - iterator exist_it = find(it->first); - if (exist_it == end()) { - operator[](it->first) = it->second; - } + for (; first != last; ++first) { + try_emplace(first->first, first->second); } } void insert(std::initializer_list<value_type> values) { diff --git a/r5dev/thirdparty/protobuf/map_entry.h b/r5dev/thirdparty/protobuf/map_entry.h index b41dac7b..bf90b1c2 100644 --- a/r5dev/thirdparty/protobuf/map_entry.h +++ b/r5dev/thirdparty/protobuf/map_entry.h @@ -31,14 +31,15 @@ #ifndef GOOGLE_PROTOBUF_MAP_ENTRY_H__ #define GOOGLE_PROTOBUF_MAP_ENTRY_H__ +#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/generated_message_reflection.h> #include <thirdparty/protobuf/map_entry_lite.h> #include <thirdparty/protobuf/map_type_handler.h> -#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/reflection_ops.h> #include <thirdparty/protobuf/unknown_field_set.h> #include <thirdparty/protobuf/wire_format_lite.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG @@ -93,14 +94,12 @@ template <typename Derived, typename Key, typename Value, class MapEntry : public MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType, kValueFieldType> { public: - constexpr MapEntry() : _internal_metadata_() {} + constexpr MapEntry() {} explicit MapEntry(Arena* arena) : MapEntryImpl<Derived, Message, Key, Value, kKeyFieldType, - kValueFieldType>(arena), - _internal_metadata_(arena) {} - ~MapEntry() { + kValueFieldType>(arena) {} + ~MapEntry() override { Message::_internal_metadata_.template Delete<UnknownFieldSet>(); - _internal_metadata_.Delete<UnknownFieldSet>(); } typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -117,8 +116,6 @@ class MapEntry : public MapEntryImpl<Derived, Message, Key, Value, return size; } - InternalMetadata _internal_metadata_; - private: friend class ::PROTOBUF_NAMESPACE_ID::Arena; template <typename C, typename K, typename V, @@ -128,29 +125,6 @@ class MapEntry : public MapEntryImpl<Derived, Message, Key, Value, GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntry); }; -// Specialization for the full runtime -template <typename Derived, typename Key, typename Value, - WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType> -struct MapEntryHelper< - MapEntry<Derived, Key, Value, kKeyFieldType, kValueFieldType> > - : MapEntryHelper< - MapEntryLite<Derived, Key, Value, kKeyFieldType, kValueFieldType> > { - explicit MapEntryHelper(const MapPair<Key, Value>& map_pair) - : MapEntryHelper< - MapEntryLite<Derived, Key, Value, kKeyFieldType, kValueFieldType> >( - map_pair) {} -}; - -template <typename Derived, typename K, typename V, - WireFormatLite::FieldType key, WireFormatLite::FieldType value> -struct DeconstructMapEntry<MapEntry<Derived, K, V, key, value> > { - typedef K Key; - typedef V Value; - static constexpr WireFormatLite::FieldType kKeyFieldType = key; - static constexpr WireFormatLite::FieldType kValueFieldType = value; -}; - } // namespace internal } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/map_entry_lite.h b/r5dev/thirdparty/protobuf/map_entry_lite.h index bb30f500..02f8904e 100644 --- a/r5dev/thirdparty/protobuf/map_entry_lite.h +++ b/r5dev/thirdparty/protobuf/map_entry_lite.h @@ -32,19 +32,23 @@ #define GOOGLE_PROTOBUF_MAP_ENTRY_LITE_H__ #include <assert.h> + +#include <algorithm> #include <string> +#include <utility> #include <thirdparty/protobuf/stubs/casts.h> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> +#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/arenastring.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/map.h> #include <thirdparty/protobuf/map_type_handler.h> -#include <thirdparty/protobuf/port.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/wire_format_lite.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG #error "You cannot SWIG proto headers" @@ -97,44 +101,6 @@ struct MoveHelper<false, false, true, T> { // strings and similar } }; -// Functions for operating on a map entry. Does not contain any representation -// (this class is not intended to be instantiated). -template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType> -struct MapEntryFuncs { - typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler; - typedef MapTypeHandler<kValueFieldType, Value> ValueTypeHandler; - static const int kKeyFieldNumber = 1; - static const int kValueFieldNumber = 2; - - static uint8_t* InternalSerialize(int field_number, const Key& key, - const Value& value, uint8_t* ptr, - io::EpsCopyOutputStream* stream) { - ptr = stream->EnsureSpace(ptr); - ptr = WireFormatLite::WriteTagToArray( - field_number, WireFormatLite::WIRETYPE_LENGTH_DELIMITED, ptr); - ptr = io::CodedOutputStream::WriteVarint32ToArray(GetCachedSize(key, value), - ptr); - - ptr = KeyTypeHandler::Write(kKeyFieldNumber, key, ptr, stream); - return ValueTypeHandler::Write(kValueFieldNumber, value, ptr, stream); - } - - static size_t ByteSizeLong(const Key& key, const Value& value) { - // Tags for key and value will both be one byte (field numbers 1 and 2). - size_t inner_length = - 2 + KeyTypeHandler::ByteSize(key) + ValueTypeHandler::ByteSize(value); - return inner_length + io::CodedOutputStream::VarintSize32( - static_cast<uint32_t>(inner_length)); - } - - static int GetCachedSize(const Key& key, const Value& value) { - // Tags for key and value will both be one byte (field numbers 1 and 2). - return 2 + KeyTypeHandler::GetCachedSize(key) + - ValueTypeHandler::GetCachedSize(value); - } -}; - // MapEntryImpl is used to implement parsing and serialization of map entries. // It uses Curious Recursive Template Pattern (CRTP) to provide the type of // the eventual code to the template code. @@ -193,7 +159,7 @@ class MapEntryImpl : public Base { value_(ValueTypeHandler::Constinit()), _has_bits_{} {} - ~MapEntryImpl() { + ~MapEntryImpl() override { if (Base::GetArenaForAllocation() != nullptr) return; KeyTypeHandler::DeleteNoArena(key_); ValueTypeHandler::DeleteNoArena(value_); @@ -329,51 +295,6 @@ class MapEntryImpl : public Base { delete entry_; } - // This does what the typical MergePartialFromCodedStream() is expected to - // do, with the additional side-effect that if successful (i.e., if true is - // going to be its return value) it inserts the key-value pair into map_. - bool MergePartialFromCodedStream(io::CodedInputStream* input) { - // Look for the expected thing: a key and then a value. If it fails, - // invoke the enclosing class's MergePartialFromCodedStream, or return - // false if that would be pointless. - if (input->ExpectTag(kKeyTag)) { - if (!KeyTypeHandler::Read(input, &key_)) { - return false; - } - // Peek at the next byte to see if it is kValueTag. If not, bail out. - const void* data; - int size; - input->GetDirectBufferPointerInline(&data, &size); - // We could use memcmp here, but we don't bother. The tag is one byte. - static_assert(kTagSize == 1, "tag size must be 1"); - if (size > 0 && *reinterpret_cast<const char*>(data) == kValueTag) { - typename Map::size_type map_size = map_->size(); - value_ptr_ = &(*map_)[key_]; - if (PROTOBUF_PREDICT_TRUE(map_size != map_->size())) { - // We created a new key-value pair. Fill in the value. - typedef - typename MapIf<ValueTypeHandler::kIsEnum, int*, Value*>::type T; - input->Skip(kTagSize); // Skip kValueTag. - if (!ValueTypeHandler::Read(input, - reinterpret_cast<T>(value_ptr_))) { - map_->erase(key_); // Failure! Undo insertion. - return false; - } - if (input->ExpectAtEnd()) return true; - return ReadBeyondKeyValuePair(input); - } - } - } else { - key_ = Key(); - } - - NewEntry(); - *entry_->mutable_key() = key_; - const bool result = entry_->MergePartialFromCodedStream(input); - if (result) UseKeyAndValueFromEntry(); - return result; - } - const char* _InternalParse(const char* ptr, ParseContext* ctx) { if (PROTOBUF_PREDICT_TRUE(!ctx->Done(&ptr) && *ptr == kKeyTag)) { ptr = KeyTypeHandler::Read(ptr + 1, ctx, &key_); @@ -493,7 +414,7 @@ class MapEntryImpl : public Base { public: inline Arena* GetArena() const { return Base::GetArena(); } - public: // Needed for constructing tables + protected: // Needed for constructing tables KeyOnMemory key_; ValueOnMemory value_; uint32_t _has_bits_[1]; @@ -523,7 +444,7 @@ class MapEntryLite : public MapEntryImpl<T, MessageLite, Key, Value, SuperType; constexpr MapEntryLite() {} explicit MapEntryLite(Arena* arena) : SuperType(arena) {} - ~MapEntryLite() { + ~MapEntryLite() override { MessageLite::_internal_metadata_.template Delete<std::string>(); } void MergeFrom(const MapEntryLite& other) { MergeFromInternal(other); } @@ -531,118 +452,106 @@ class MapEntryLite : public MapEntryImpl<T, MessageLite, Key, Value, private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryLite); }; -// The completely unprincipled and unwieldy use of template parameters in -// the map code necessitates wrappers to make the code a little bit more -// manageable. -template <typename Derived> -struct DeconstructMapEntry; - -template <typename T, typename K, typename V, WireFormatLite::FieldType key, - WireFormatLite::FieldType value> -struct DeconstructMapEntry<MapEntryLite<T, K, V, key, value> > { - typedef K Key; - typedef V Value; - static const WireFormatLite::FieldType kKeyFieldType = key; - static const WireFormatLite::FieldType kValueFieldType = value; -}; // Helpers for deterministic serialization ============================= -// This struct can be used with any generic sorting algorithm. If the Key -// type is relatively small and easy to copy then copying Keys into an -// array of SortItems can be beneficial. Then all the data the sorting -// algorithm needs to touch is in that one array. -template <typename Key, typename PtrToKeyValuePair> -struct SortItem { - SortItem() {} - explicit SortItem(PtrToKeyValuePair p) : first(p->first), second(p) {} - - Key first; - PtrToKeyValuePair second; +// Iterator base for MapSorterFlat and MapSorterPtr. +template <typename storage_type> +struct MapSorterIt { + storage_type* ptr; + MapSorterIt(storage_type* ptr) : ptr(ptr) {} + bool operator==(const MapSorterIt& other) const { return ptr == other.ptr; } + bool operator!=(const MapSorterIt& other) const { return !(*this == other); } + MapSorterIt& operator++() { ++ptr; return *this; } + MapSorterIt operator++(int) { auto other = *this; ++ptr; return other; } + MapSorterIt operator+(int v) { return MapSorterIt{ptr + v}; } }; -template <typename T> -struct CompareByFirstField { - bool operator()(const T& a, const T& b) const { return a.first < b.first; } -}; +// MapSorterFlat stores keys inline with pointers to map entries, so that +// keys can be compared without indirection. This type is used for maps with +// keys that are not strings. +template <typename MapT> +class MapSorterFlat { + public: + using value_type = typename MapT::value_type; + using storage_type = std::pair<typename MapT::key_type, const value_type*>; -template <typename T> -struct CompareByDerefFirst { - bool operator()(const T& a, const T& b) const { return a->first < b->first; } -}; + // This const_iterator dereferenes to the map entry stored in the sorting + // array pairs. This is the same interface as the Map::const_iterator type, + // and allows generated code to use the same loop body with either form: + // for (const auto& entry : map) { ... } + // for (const auto& entry : MapSorterFlat(map)) { ... } + struct const_iterator : public MapSorterIt<storage_type> { + using pointer = const typename MapT::value_type*; + using reference = const typename MapT::value_type&; + using MapSorterIt<storage_type>::MapSorterIt; -// Helper for table driven serialization + pointer operator->() const { return this->ptr->second; } + reference operator*() const { return *this->operator->(); } + }; -template <WireFormatLite::FieldType FieldType> -struct FromHelper { - template <typename T> - static const T& From(const T& x) { - return x; + explicit MapSorterFlat(const MapT& m) + : size_(m.size()), items_(size_ ? new storage_type[size_] : nullptr) { + if (!size_) return; + storage_type* it = &items_[0]; + for (const auto& entry : m) { + *it++ = {entry.first, &entry}; + } + std::sort(&items_[0], &items_[size_], + [](const storage_type& a, const storage_type& b) { + return a.first < b.first; + }); } + size_t size() const { return size_; } + const_iterator begin() const { return {items_.get()}; } + const_iterator end() const { return {items_.get() + size_}; } + + private: + size_t size_; + std::unique_ptr<storage_type[]> items_; }; -template <> -struct FromHelper<WireFormatLite::TYPE_STRING> { - static ArenaStringPtr From(const std::string& x) { - ArenaStringPtr res; - TaggedPtr<std::string> ptr; - ptr.Set(const_cast<std::string*>(&x)); - res.UnsafeSetTaggedPointer(ptr); - return res; +// MapSorterPtr stores and sorts pointers to map entries. This type is used for +// maps with keys that are strings. +template <typename MapT> +class MapSorterPtr { + public: + using value_type = typename MapT::value_type; + using storage_type = const typename MapT::value_type*; + + // This const_iterator dereferenes the map entry pointer stored in the sorting + // array. This is the same interface as the Map::const_iterator type, and + // allows generated code to use the same loop body with either form: + // for (const auto& entry : map) { ... } + // for (const auto& entry : MapSorterPtr(map)) { ... } + struct const_iterator : public MapSorterIt<storage_type> { + using pointer = const typename MapT::value_type*; + using reference = const typename MapT::value_type&; + using MapSorterIt<storage_type>::MapSorterIt; + + pointer operator->() const { return *this->ptr; } + reference operator*() const { return *this->operator->(); } + }; + + explicit MapSorterPtr(const MapT& m) + : size_(m.size()), items_(size_ ? new storage_type[size_] : nullptr) { + if (!size_) return; + storage_type* it = &items_[0]; + for (const auto& entry : m) { + *it++ = &entry; + } + std::sort(&items_[0], &items_[size_], + [](const storage_type& a, const storage_type& b) { + return a->first < b->first; + }); } -}; -template <> -struct FromHelper<WireFormatLite::TYPE_BYTES> { - static ArenaStringPtr From(const std::string& x) { - ArenaStringPtr res; - TaggedPtr<std::string> ptr; - ptr.Set(const_cast<std::string*>(&x)); - res.UnsafeSetTaggedPointer(ptr); - return res; - } -}; -template <> -struct FromHelper<WireFormatLite::TYPE_MESSAGE> { - template <typename T> - static T* From(const T& x) { - return const_cast<T*>(&x); - } -}; + size_t size() const { return size_; } + const_iterator begin() const { return {items_.get()}; } + const_iterator end() const { return {items_.get() + size_}; } -template <typename MapEntryType> -struct MapEntryHelper; - -template <typename T, typename Key, typename Value, - WireFormatLite::FieldType kKeyFieldType, - WireFormatLite::FieldType kValueFieldType> -struct MapEntryHelper< - MapEntryLite<T, Key, Value, kKeyFieldType, kValueFieldType> > { - // Provide utilities to parse/serialize key/value. Provide utilities to - // manipulate internal stored type. - typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler; - typedef MapTypeHandler<kValueFieldType, Value> ValueTypeHandler; - - // Define internal memory layout. Strings and messages are stored as - // pointers, while other types are stored as values. - typedef typename KeyTypeHandler::TypeOnMemory KeyOnMemory; - typedef typename ValueTypeHandler::TypeOnMemory ValueOnMemory; - - explicit MapEntryHelper(const MapPair<Key, Value>& map_pair) - : _has_bits_(3), - _cached_size_(2 + KeyTypeHandler::GetCachedSize(map_pair.first) + - ValueTypeHandler::GetCachedSize(map_pair.second)), - key_(FromHelper<kKeyFieldType>::From(map_pair.first)), - value_(FromHelper<kValueFieldType>::From(map_pair.second)) {} - - // Purposely not following the style guide naming. These are the names - // the proto compiler would generate given the map entry descriptor. - // The proto compiler generates the offsets in this struct as if this was - // a regular message. This way the table driven code barely notices it's - // dealing with a map field. - uint32_t _has_bits_; // NOLINT - uint32_t _cached_size_; // NOLINT - KeyOnMemory key_; // NOLINT - ValueOnMemory value_; // NOLINT + private: + size_t size_; + std::unique_ptr<storage_type[]> items_; }; } // namespace internal diff --git a/r5dev/thirdparty/protobuf/map_field.cc b/r5dev/thirdparty/protobuf/map_field.cc index 16a7203a..830ff092 100644 --- a/r5dev/thirdparty/protobuf/map_field.cc +++ b/r5dev/thirdparty/protobuf/map_field.cc @@ -29,18 +29,23 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <thirdparty/protobuf/map_field.h> -#include <thirdparty/protobuf/map_field_inl.h> #include <vector> +#include <thirdparty/protobuf/map_field_inl.h> + +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { namespace protobuf { namespace internal { -MapFieldBase::~MapFieldBase() { - if (repeated_field_ != nullptr && arena_ == nullptr) delete repeated_field_; +void MapFieldBase::Destruct() { + if (arena_ == nullptr) { + delete repeated_field_; + } + repeated_field_ = nullptr; } const RepeatedPtrFieldBase& MapFieldBase::GetRepeatedField() const { @@ -219,13 +224,15 @@ DynamicMapField::DynamicMapField(const Message* default_entry, Arena* arena) default_entry_(default_entry) {} DynamicMapField::~DynamicMapField() { - if (arena_ != nullptr) return; - // DynamicMapField owns map values. Need to delete them before clearing the - // map. - for (auto& kv : map_) { - kv.second.DeleteData(); + if (arena_ == nullptr) { + // DynamicMapField owns map values. Need to delete them before clearing the + // map. + for (auto& kv : map_) { + kv.second.DeleteData(); + } + map_.clear(); } - map_.clear(); + Destruct(); } int DynamicMapField::size() const { return GetMap().size(); } diff --git a/r5dev/thirdparty/protobuf/map_field.h b/r5dev/thirdparty/protobuf/map_field.h index d4d1c36f..72146f01 100644 --- a/r5dev/thirdparty/protobuf/map_field.h +++ b/r5dev/thirdparty/protobuf/map_field.h @@ -35,6 +35,8 @@ #include <functional> #include <thirdparty/protobuf/arena.h> +#include <thirdparty/protobuf/stubs/mutex.h> +#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/generated_message_reflection.h> #include <thirdparty/protobuf/generated_message_util.h> @@ -42,12 +44,11 @@ #include <thirdparty/protobuf/map_field_lite.h> #include <thirdparty/protobuf/map_type_handler.h> #include <thirdparty/protobuf/message.h> -#include <thirdparty/protobuf/stubs/mutex.h> -#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/repeated_field.h> #include <thirdparty/protobuf/unknown_field_set.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG @@ -59,6 +60,13 @@ namespace protobuf { class DynamicMessage; class MapIterator; +// Microsoft compiler complains about non-virtual destructor, +// even when the destructor is private. +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4265) +#endif // _MSC_VER + #define TYPE_CHECK(EXPECTEDTYPE, METHOD) \ if (type() != EXPECTEDTYPE) { \ GOOGLE_LOG(FATAL) << "Protocol Buffer map usage error:\n" \ @@ -330,15 +338,22 @@ class PROTOBUF_EXPORT MapFieldBase { // It uses a linker initialized mutex, so it is not compatible with regular // runtime instances. // Except in MSVC, where we can't have a constinit mutex. - explicit constexpr MapFieldBase(ConstantInitialized) + // NOLINTNEXTLINE(google-explicit-constructor) + constexpr MapFieldBase(ConstantInitialized) : arena_(nullptr), repeated_field_(nullptr), mutex_(GOOGLE_PROTOBUF_LINKER_INITIALIZED), state_(STATE_MODIFIED_MAP) {} explicit MapFieldBase(Arena* arena) : arena_(arena), repeated_field_(nullptr), state_(STATE_MODIFIED_MAP) {} - virtual ~MapFieldBase(); + protected: + ~MapFieldBase() { // "protected" stops users from deleting a `MapFieldBase *` + GOOGLE_DCHECK(repeated_field_ == nullptr); + } + void Destruct(); + + public: // Returns reference to internal repeated field. Data written using // Map's api prior to calling this function is guarantted to be // included in repeated field. @@ -483,10 +498,18 @@ class TypeDefinedMapFieldBase : public MapFieldBase { // This constructor is for constant initialized global instances. // It uses a linker initialized mutex, so it is not compatible with regular // runtime instances. - explicit constexpr TypeDefinedMapFieldBase(ConstantInitialized tag) + // NOLINTNEXTLINE(google-explicit-constructor) + constexpr TypeDefinedMapFieldBase(ConstantInitialized tag) : MapFieldBase(tag) {} explicit TypeDefinedMapFieldBase(Arena* arena) : MapFieldBase(arena) {} - ~TypeDefinedMapFieldBase() override {} + TypeDefinedMapFieldBase(ArenaInitialized, Arena* arena) + : TypeDefinedMapFieldBase(arena) {} + + protected: + ~TypeDefinedMapFieldBase() {} + using MapFieldBase::Destruct; + + public: void MapBegin(MapIterator* map_iter) const override; void MapEnd(MapIterator* map_iter) const override; bool EqualIterator(const MapIterator& a, const MapIterator& b) const override; @@ -536,18 +559,24 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> { typedef typename MapIf<kIsValueEnum, T, const T&>::type CastValueType; public: - typedef typename Derived::SuperType EntryTypeTrait; typedef Map<Key, T> MapType; - MapField() {} + MapField() : impl_() {} + virtual ~MapField() {} // Destruct() must already have been called! + void Destruct() { + impl_.Destruct(); + TypeDefinedMapFieldBase<Key, T>::Destruct(); + } // This constructor is for constant initialized global instances. // It uses a linker initialized mutex, so it is not compatible with regular // runtime instances. - explicit constexpr MapField(ConstantInitialized tag) + // NOLINTNEXTLINE(google-explicit-constructor) + constexpr MapField(ConstantInitialized tag) : TypeDefinedMapFieldBase<Key, T>(tag), impl_() {} explicit MapField(Arena* arena) : TypeDefinedMapFieldBase<Key, T>(arena), impl_(arena) {} + MapField(ArenaInitialized, Arena* arena) : MapField(arena) {} // Implement MapFieldBase bool ContainsMapKey(const MapKey& map_key) const override; @@ -579,16 +608,6 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> { // Used in the implementation of parsing. Caller should take the ownership iff // arena_ is nullptr. EntryType* NewEntry() const { return impl_.NewEntry(); } - // Used in the implementation of serializing enum value type. Caller should - // take the ownership iff arena_ is nullptr. - EntryType* NewEnumEntryWrapper(const Key& key, const T t) const { - return impl_.NewEnumEntryWrapper(key, t); - } - // Used in the implementation of serializing other value types. Caller should - // take the ownership iff arena_ is nullptr. - EntryType* NewEntryWrapper(const Key& key, const T& t) const { - return impl_.NewEntryWrapper(key, t); - } const char* _InternalParse(const char* ptr, ParseContext* ctx) { return impl_._InternalParse(ptr, ctx); @@ -645,7 +664,7 @@ class PROTOBUF_EXPORT DynamicMapField public: explicit DynamicMapField(const Message* default_entry); DynamicMapField(const Message* default_entry, Arena* arena); - ~DynamicMapField() override; + virtual ~DynamicMapField(); // Implement MapFieldBase bool ContainsMapKey(const MapKey& map_key) const override; @@ -855,8 +874,8 @@ class PROTOBUF_EXPORT MapIterator { MapIterator(Message* message, const FieldDescriptor* field) { const Reflection* reflection = message->GetReflection(); map_ = reflection->MutableMapData(message, field); - key_.SetType(field->message_type()->FindFieldByName("key")->cpp_type()); - value_.SetType(field->message_type()->FindFieldByName("value")->cpp_type()); + key_.SetType(field->message_type()->map_key()->cpp_type()); + value_.SetType(field->message_type()->map_value()->cpp_type()); map_->InitializeIterator(this); } MapIterator(const MapIterator& other) { @@ -918,6 +937,10 @@ class PROTOBUF_EXPORT MapIterator { } // namespace protobuf } // namespace google +#ifdef _MSC_VER +#pragma warning(pop) // restore warning C4265 +#endif // _MSC_VER + #include <thirdparty/protobuf/port_undef.inc> #endif // GOOGLE_PROTOBUF_MAP_FIELD_H__ diff --git a/r5dev/thirdparty/protobuf/map_field_lite.h b/r5dev/thirdparty/protobuf/map_field_lite.h index 6bb26770..845f130b 100644 --- a/r5dev/thirdparty/protobuf/map_field_lite.h +++ b/r5dev/thirdparty/protobuf/map_field_lite.h @@ -32,13 +32,15 @@ #define GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__ #include <type_traits> -#include <thirdparty/protobuf/parse_context.h> + #include <thirdparty/protobuf/io/coded_stream.h> +#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/map.h> #include <thirdparty/protobuf/map_entry_lite.h> -#include <thirdparty/protobuf/port.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/wire_format_lite.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG @@ -49,6 +51,10 @@ namespace google { namespace protobuf { namespace internal { +#ifndef NDEBUG +void MapFieldLiteNotDestructed(void* map_field_lite); +#endif + // This class provides access to map field using generated api. It is used for // internal generated message implementation only. Users should never use this // directly. @@ -61,12 +67,30 @@ class MapFieldLite { public: typedef Map<Key, T> MapType; - typedef EntryType EntryTypeTrait; - - constexpr MapFieldLite() {} + constexpr MapFieldLite() : map_() {} explicit MapFieldLite(Arena* arena) : map_(arena) {} + MapFieldLite(ArenaInitialized, Arena* arena) : MapFieldLite(arena) {} +#ifdef NDEBUG + void Destruct() { map_.~Map(); } + ~MapFieldLite() {} +#else + void Destruct() { + // We want to destruct the map in such a way that we can verify + // that we've done that, but also be sure that we've deallocated + // everything (as opposed to leaving an allocation behind with no + // data in it, as would happen if a vector was resize'd to zero. + // Map::Swap with an empty map accomplishes that. + decltype(map_) swapped_map(map_.arena()); + map_.InternalSwap(swapped_map); + } + ~MapFieldLite() { + if (map_.arena() == nullptr && !map_.empty()) { + MapFieldLiteNotDestructed(this); + } + } +#endif // Accessors const Map<Key, T>& GetMap() const { return map_; } Map<Key, T>* MutableMap() { return &map_; } @@ -88,16 +112,6 @@ class MapFieldLite { EntryType* NewEntry() const { return Arena::CreateMessage<EntryType>(map_.arena()); } - // Used in the implementation of serializing enum value type. Caller should - // take the ownership iff arena_ is nullptr. - EntryType* NewEnumEntryWrapper(const Key& key, const T t) const { - return EntryType::EnumWrap(key, t, map_.arena_); - } - // Used in the implementation of serializing other value types. Caller should - // take the ownership iff arena_ is nullptr. - EntryType* NewEntryWrapper(const Key& key, const T& t) const { - return EntryType::Wrap(key, t, map_.arena_); - } const char* _InternalParse(const char* ptr, ParseContext* ctx) { typename Derived::template Parser<MapFieldLite, Map<Key, T>> parser(this); @@ -116,7 +130,11 @@ class MapFieldLite { private: typedef void DestructorSkippable_; - Map<Key, T> map_; + // map_ is inside an anonymous union so we can explicitly control its + // destruction + union { + Map<Key, T> map_; + }; friend class ::PROTOBUF_NAMESPACE_ID::Arena; }; @@ -175,6 +193,13 @@ struct MapEntryToMapField< MapFieldType; }; +#ifndef NDEBUG +inline PROTOBUF_NOINLINE void MapFieldLiteNotDestructed(void* map_field_lite) { + bool proper_destruct = false; + GOOGLE_CHECK(proper_destruct) << map_field_lite; +} +#endif + } // namespace internal } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/map_field_test.cc b/r5dev/thirdparty/protobuf/map_field_test.cc index 616a6e9a..c85daa21 100644 --- a/r5dev/thirdparty/protobuf/map_field_test.cc +++ b/r5dev/thirdparty/protobuf/map_field_test.cc @@ -34,8 +34,6 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/arena_test_util.h> -#include <thirdparty/protobuf/map_test_util.h> #include <thirdparty/protobuf/map_unittest.pb.h> #include <thirdparty/protobuf/unittest.pb.h> #include <thirdparty/protobuf/arena.h> @@ -44,6 +42,8 @@ #include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/repeated_field.h> #include <gtest/gtest.h> +#include <thirdparty/protobuf/arena_test_util.h> +#include <thirdparty/protobuf/map_test_util.h> // Must be included last. #include <thirdparty/protobuf/port_def.inc> @@ -55,11 +55,21 @@ namespace internal { using unittest::TestAllTypes; +// ArenaHolder from map_test_util.h works fine for fields other than map +// fields. For map fields, the Destruct() call must be made before the +// actual destructor is called. +template <typename MapType> +struct ArenaDestructor : ArenaHolder<MapType> { + using ArenaHolder<MapType>::ArenaHolder; + ~ArenaDestructor() { ArenaHolder<MapType>::get()->Destruct(); } +}; + class MapFieldBaseStub : public MapFieldBase { public: typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; MapFieldBaseStub() {} + virtual ~MapFieldBaseStub() { MapFieldBase::Destruct(); } explicit MapFieldBaseStub(Arena* arena) : MapFieldBase(arena) {} // Get underlined repeated field without synchronizing map. RepeatedPtrField<Message>* InternalRepeatedField() { return repeated_field_; } @@ -110,7 +120,7 @@ class MapFieldBaseStub : public MapFieldBase { class MapFieldBasePrimitiveTest : public testing::TestWithParam<bool> { protected: typedef unittest::TestMap_MapInt32Int32Entry_DoNotUse EntryType; - typedef MapField<EntryType, int32, int32, WireFormatLite::TYPE_INT32, + typedef MapField<EntryType, int32_t, int32_t, WireFormatLite::TYPE_INT32, WireFormatLite::TYPE_INT32> MapFieldType; @@ -135,13 +145,14 @@ class MapFieldBasePrimitiveTest : public testing::TestWithParam<bool> { } std::unique_ptr<Arena> arena_; - ArenaHolder<MapFieldType> map_field_; + ArenaDestructor<MapFieldType> map_field_; MapFieldBase* map_field_base_; - Map<int32, int32>* map_; + Map<int32_t, int32_t>* map_; const Descriptor* map_descriptor_; const FieldDescriptor* key_descriptor_; const FieldDescriptor* value_descriptor_; - std::map<int32, int32> initial_value_map_; // copy of initial values inserted + std::map<int32_t, int32_t> + initial_value_map_; // copy of initial values inserted }; INSTANTIATE_TEST_SUITE_P(MapFieldBasePrimitiveTestInstance, @@ -229,7 +240,7 @@ class MapFieldStateTest : public testing::TestWithParam<std::tuple<State, bool>> { protected: typedef unittest::TestMap_MapInt32Int32Entry_DoNotUse EntryType; - typedef MapField<EntryType, int32, int32, WireFormatLite::TYPE_INT32, + typedef MapField<EntryType, int32_t, int32_t, WireFormatLite::TYPE_INT32, WireFormatLite::TYPE_INT32> MapFieldType; MapFieldStateTest() @@ -256,14 +267,14 @@ class MapFieldStateTest void AddOneStillClean(MapFieldType* map_field) { MapFieldBase* map_field_base = map_field; - Map<int32, int32>* map = map_field->MutableMap(); + Map<int32_t, int32_t>* map = map_field->MutableMap(); (*map)[0] = 0; map_field_base->GetRepeatedField(); Expect(map_field, CLEAN, 1, 1, false); } void MakeMapDirty(MapFieldType* map_field) { - Map<int32, int32>* map = map_field->MutableMap(); + Map<int32_t, int32_t>* map = map_field->MutableMap(); (*map)[0] = 0; Expect(map_field, MAP_DIRTY, 1, 0, true); } @@ -273,7 +284,7 @@ class MapFieldStateTest MapFieldBase* map_field_base = map_field; map_field_base->MutableRepeatedField(); // We use MutableMap on impl_ because we don't want to disturb the syncing - Map<int32, int32>* map = map_field->impl_.MutableMap(); + Map<int32_t, int32_t>* map = map_field->impl_.MutableMap(); map->clear(); Expect(map_field, REPEATED_DIRTY, 0, 1, false); @@ -286,7 +297,7 @@ class MapFieldStateTest reinterpret_cast<MapFieldBaseStub*>(map_field_base); // We use MutableMap on impl_ because we don't want to disturb the syncing - Map<int32, int32>* map = map_field->impl_.MutableMap(); + Map<int32_t, int32_t>* map = map_field->impl_.MutableMap(); RepeatedPtrField<Message>* repeated_field = stub->InternalRepeatedField(); switch (state) { @@ -319,7 +330,7 @@ class MapFieldStateTest } std::unique_ptr<Arena> arena_; - ArenaHolder<MapFieldType> map_field_; + ArenaDestructor<MapFieldType> map_field_; MapFieldBase* map_field_base_; State state_; }; @@ -348,7 +359,7 @@ TEST_P(MapFieldStateTest, MutableMap) { } TEST_P(MapFieldStateTest, MergeFromClean) { - ArenaHolder<MapFieldType> other(arena_.get()); + ArenaDestructor<MapFieldType> other(arena_.get()); AddOneStillClean(other.get()); map_field_->MergeFrom(*other); @@ -363,7 +374,7 @@ TEST_P(MapFieldStateTest, MergeFromClean) { } TEST_P(MapFieldStateTest, MergeFromMapDirty) { - ArenaHolder<MapFieldType> other(arena_.get()); + ArenaDestructor<MapFieldType> other(arena_.get()); MakeMapDirty(other.get()); map_field_->MergeFrom(*other); @@ -378,7 +389,7 @@ TEST_P(MapFieldStateTest, MergeFromMapDirty) { } TEST_P(MapFieldStateTest, MergeFromRepeatedDirty) { - ArenaHolder<MapFieldType> other(arena_.get()); + ArenaDestructor<MapFieldType> other(arena_.get()); MakeRepeatedDirty(other.get()); map_field_->MergeFrom(*other); @@ -393,7 +404,7 @@ TEST_P(MapFieldStateTest, MergeFromRepeatedDirty) { } TEST_P(MapFieldStateTest, SwapClean) { - ArenaHolder<MapFieldType> other(arena_.get()); + ArenaDestructor<MapFieldType> other(arena_.get()); AddOneStillClean(other.get()); map_field_->Swap(other.get()); @@ -416,7 +427,7 @@ TEST_P(MapFieldStateTest, SwapClean) { } TEST_P(MapFieldStateTest, SwapMapDirty) { - ArenaHolder<MapFieldType> other(arena_.get()); + ArenaDestructor<MapFieldType> other(arena_.get()); MakeMapDirty(other.get()); map_field_->Swap(other.get()); @@ -439,7 +450,7 @@ TEST_P(MapFieldStateTest, SwapMapDirty) { } TEST_P(MapFieldStateTest, SwapRepeatedDirty) { - ArenaHolder<MapFieldType> other(arena_.get()); + ArenaDestructor<MapFieldType> other(arena_.get()); MakeRepeatedDirty(other.get()); map_field_->Swap(other.get()); @@ -506,8 +517,8 @@ TEST_P(MapFieldStateTest, MutableMapField) { } class MyMapField - : public MapField<unittest::TestMap_MapInt32Int32Entry_DoNotUse, int32, - int32, internal::WireFormatLite::TYPE_INT32, + : public MapField<unittest::TestMap_MapInt32Int32Entry_DoNotUse, int32_t, + int32_t, internal::WireFormatLite::TYPE_INT32, internal::WireFormatLite::TYPE_INT32> { public: constexpr MyMapField() diff --git a/r5dev/thirdparty/protobuf/map_lite_test_util.cc b/r5dev/thirdparty/protobuf/map_lite_test_util.cc index 420418e1..6e54d6aa 100644 --- a/r5dev/thirdparty/protobuf/map_lite_test_util.cc +++ b/r5dev/thirdparty/protobuf/map_lite_test_util.cc @@ -29,6 +29,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <thirdparty/protobuf/map_lite_test_util.h> + #include <thirdparty/protobuf/map_lite_unittest.pb.h> #include <thirdparty/protobuf/map_test_util_impl.h> diff --git a/r5dev/thirdparty/protobuf/map_lite_unittest.proto b/r5dev/thirdparty/protobuf/map_lite_unittest.proto index cc00deec..7f104315 100644 --- a/r5dev/thirdparty/protobuf/map_lite_unittest.proto +++ b/r5dev/thirdparty/protobuf/map_lite_unittest.proto @@ -120,6 +120,10 @@ message TestRequiredLite { required int32 a = 1; required int32 b = 2; required int32 c = 3; + + extend TestAllExtensionsLite { + optional TestRequiredLite single = 1000; + } } message ForeignMessageArenaLite { diff --git a/r5dev/thirdparty/protobuf/map_test.cc b/r5dev/thirdparty/protobuf/map_test.cc index 9c0a1153..2d9b4c00 100644 --- a/r5dev/thirdparty/protobuf/map_test.cc +++ b/r5dev/thirdparty/protobuf/map_test.cc @@ -55,6 +55,29 @@ namespace internal { namespace { +struct AlignedAsDefault { + int x; +}; +struct alignas(8) AlignedAs8 { + int x; +}; + +template <typename Aligned, bool on_arena = false> +void MapTest_Aligned() { + Arena arena; + constexpr size_t align_mask = alignof(Aligned) - 1; + Map<int, Aligned> map(on_arena ? &arena : nullptr); + map.insert({1, Aligned{}}); + auto it = map.find(1); + ASSERT_NE(it, map.end()); + ASSERT_EQ(reinterpret_cast<intptr_t>(&it->second) & align_mask, 0); + map.clear(); +} + +TEST(MapTest, Aligned) { MapTest_Aligned<AlignedAsDefault>(); } +TEST(MapTest, AlignedOnArena) { MapTest_Aligned<AlignedAsDefault, true>(); } +TEST(MapTest, Aligned8) { MapTest_Aligned<AlignedAs8>(); } +TEST(MapTest, Aligned8OnArena) { MapTest_Aligned<AlignedAs8, true>(); } } // namespace diff --git a/r5dev/thirdparty/protobuf/map_test.inc b/r5dev/thirdparty/protobuf/map_test.inc index 915ea1e4..dd16eb0c 100644 --- a/r5dev/thirdparty/protobuf/map_test.inc +++ b/r5dev/thirdparty/protobuf/map_test.inc @@ -29,7 +29,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // A hack to include windows.h first, which ensures the GetMessage macro can -// be undefined when we include <thirdparty/protobuf/stubs/common.h> +// be undefined when we include <google/protobuf/stubs/common.h> #if defined(_MSC_VER) #define _WINSOCKAPI_ // to avoid re-definition in WinSock2.h #define NOMINMAX // to avoid defining min/max macros @@ -48,31 +48,30 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/testing/file.h> -#include <thirdparty/protobuf/arena_test_util.h> -#include <thirdparty/protobuf/test_util2.h> -#include <thirdparty/protobuf/io/coded_stream.h> -#include <thirdparty/protobuf/io/tokenizer.h> -#include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/descriptor.pb.h> -#include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/descriptor_database.h> -#include <thirdparty/protobuf/dynamic_message.h> -#include <thirdparty/protobuf/map.h> -#include <thirdparty/protobuf/map_field_inl.h> -#include <thirdparty/protobuf/message.h> -#include <thirdparty/protobuf/reflection.h> -#include <thirdparty/protobuf/reflection_ops.h> -#include <thirdparty/protobuf/text_format.h> -#include <thirdparty/protobuf/wire_format.h> -#include <thirdparty/protobuf/util/message_differencer.h> -#include <thirdparty/protobuf/util/time_util.h> #include <gmock/gmock.h> #include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> #include <thirdparty/protobuf/stubs/casts.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/arena_test_util.h> +#include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/descriptor_database.h> +#include <thirdparty/protobuf/dynamic_message.h> +#include <thirdparty/protobuf/io/coded_stream.h> +#include <thirdparty/protobuf/io/tokenizer.h> +#include <thirdparty/protobuf/io/zero_copy_stream_impl.h> +#include <thirdparty/protobuf/map.h> +#include <thirdparty/protobuf/map_field_inl.h> +#include <thirdparty/protobuf/message.h> +#include <thirdparty/protobuf/reflection.h> +#include <thirdparty/protobuf/reflection_ops.h> +#include <thirdparty/protobuf/test_util2.h> +#include <thirdparty/protobuf/text_format.h> +#include <thirdparty/protobuf/util/message_differencer.h> +#include <thirdparty/protobuf/util/time_util.h> +#include <thirdparty/protobuf/wire_format.h> // Must be included last. @@ -99,29 +98,29 @@ namespace { class MapImplTest : public ::testing::Test { protected: MapImplTest() - : map_ptr_(new Map<int32, int32>()), + : map_ptr_(new Map<int32_t, int32_t>()), map_(*map_ptr_), const_map_(*map_ptr_) { EXPECT_TRUE(map_.empty()); EXPECT_EQ(0, map_.size()); } - void ExpectSingleElement(int32 key, int32 value) { + void ExpectSingleElement(int32_t key, int32_t value) { EXPECT_FALSE(map_.empty()); EXPECT_EQ(1, map_.size()); ExpectElement(key, value); } - void ExpectElements(const std::map<int32, int32>& map) { + void ExpectElements(const std::map<int32_t, int32_t>& map) { EXPECT_FALSE(map_.empty()); EXPECT_EQ(map.size(), map_.size()); - for (std::map<int32, int32>::const_iterator it = map.begin(); + for (std::map<int32_t, int32_t>::const_iterator it = map.begin(); it != map.end(); ++it) { ExpectElement(it->first, it->second); } } - void ExpectElement(int32 key, int32 value) { + void ExpectElement(int32_t key, int32_t value) { // Test map size is correct. EXPECT_EQ(value, map_[key]); EXPECT_EQ(1, map_.count(key)); @@ -129,7 +128,7 @@ class MapImplTest : public ::testing::Test { // Check mutable at and find work correctly. EXPECT_EQ(value, map_.at(key)); - Map<int32, int32>::iterator it = map_.find(key); + Map<int32_t, int32_t>::iterator it = map_.find(key); // iterator dereferenceable EXPECT_EQ(key, (*it).first); @@ -149,7 +148,7 @@ class MapImplTest : public ::testing::Test { EXPECT_EQ(value, map_[key]); // copy constructor - Map<int32, int32>::iterator it_copy = it; + Map<int32_t, int32_t>::iterator it_copy = it; EXPECT_EQ(key, it_copy->first); EXPECT_EQ(value, it_copy->second); @@ -157,7 +156,7 @@ class MapImplTest : public ::testing::Test { // Check immutable at and find work correctly. EXPECT_EQ(value, const_map_.at(key)); - Map<int32, int32>::const_iterator const_it = const_map_.find(key); + Map<int32_t, int32_t>::const_iterator const_it = const_map_.find(key); // iterator dereferenceable EXPECT_EQ(key, (*const_it).first); @@ -166,20 +165,20 @@ class MapImplTest : public ::testing::Test { EXPECT_EQ(value, const_it->second); // copy constructor - Map<int32, int32>::const_iterator const_it_copy = const_it; + Map<int32_t, int32_t>::const_iterator const_it_copy = const_it; EXPECT_EQ(key, const_it_copy->first); EXPECT_EQ(value, const_it_copy->second); } - std::unique_ptr<Map<int32, int32> > map_ptr_; - Map<int32, int32>& map_; - const Map<int32, int32>& const_map_; + std::unique_ptr<Map<int32_t, int32_t>> map_ptr_; + Map<int32_t, int32_t>& map_; + const Map<int32_t, int32_t>& const_map_; }; TEST_F(MapImplTest, OperatorBracket) { - int32 key = 0; - int32 value1 = 100; - int32 value2 = 101; + int32_t key = 0; + int32_t value1 = 100; + int32_t value2 = 101; EXPECT_EQ(0, map_[key]); @@ -247,17 +246,17 @@ TEST_F(MapImplTest, OperatorBracketRValue) { } TEST_F(MapImplTest, OperatorBracketNonExist) { - int32 key = 0; - int32 default_value = 0; + int32_t key = 0; + int32_t default_value = 0; EXPECT_EQ(default_value, map_[key]); ExpectSingleElement(key, default_value); } TEST_F(MapImplTest, MutableAt) { - int32 key = 0; - int32 value1 = 100; - int32 value2 = 101; + int32_t key = 0; + int32_t value1 = 100; + int32_t value2 = 101; map_[key] = value1; ExpectSingleElement(key, value1); @@ -326,20 +325,20 @@ TEST_F(MapImplTest, GetReferenceFromIterator) { map_[i] = i; } - for (Map<int32, int32>::const_iterator it = map_.cbegin(); + for (Map<int32_t, int32_t>::const_iterator it = map_.cbegin(); it != map_.cend();) { - Map<int32, int32>::const_reference entry = *it++; + Map<int32_t, int32_t>::const_reference entry = *it++; EXPECT_EQ(entry.first, entry.second); } - for (Map<int32, int32>::const_iterator it = const_map_.begin(); + for (Map<int32_t, int32_t>::const_iterator it = const_map_.begin(); it != const_map_.end();) { - Map<int32, int32>::const_reference entry = *it++; + Map<int32_t, int32_t>::const_reference entry = *it++; EXPECT_EQ(entry.first, entry.second); } - for (Map<int32, int32>::iterator it = map_.begin(); it != map_.end();) { - Map<int32, int32>::reference entry = *it++; + for (Map<int32_t, int32_t>::iterator it = map_.begin(); it != map_.end();) { + Map<int32_t, int32_t>::reference entry = *it++; EXPECT_EQ(entry.first + 1, ++entry.second); } } @@ -367,13 +366,13 @@ TEST_F(MapImplTest, IteratorBasic) { } template <typename Iterator> -static int64 median(Iterator i0, Iterator i1) { - std::vector<int64> v(i0, i1); +static int64_t median(Iterator i0, Iterator i1) { + std::vector<int64_t> v(i0, i1); std::nth_element(v.begin(), v.begin() + v.size() / 2, v.end()); return v[v.size() / 2]; } -static int64 Now() { +static int64_t Now() { return util::TimeUtil::TimestampToNanoseconds( util::TimeUtil::GetCurrentTime()); } @@ -388,14 +387,14 @@ static int k2 = 1321555333; // avoid that, as std::unordered_map does. TEST_F(MapImplTest, BeginIsFast) { if (true) return; // TODO(gpike): make this less flaky and re-enable it. - Map<int32, int32> map; + Map<int32_t, int32_t> map; const int kTestSize = 250000; // Create a random-looking map of size n. Use non-negative integer keys. - uint32 frog = 123983; + uint32_t frog = 123983; int last_key = 0; int counter = 0; while (map.size() < kTestSize) { - frog *= static_cast<uint32>(k0); + frog *= static_cast<uint32_t>(k0); frog ^= frog >> 17; frog += counter++; last_key = @@ -403,18 +402,18 @@ TEST_F(MapImplTest, BeginIsFast) { GOOGLE_DCHECK_GE(last_key, 0); map[last_key] = last_key ^ 1; } - std::vector<int64> times; + std::vector<int64_t> times; // We're going to do map.erase(map.begin()) over and over again. But, // just in case one iteration is fast compared to the granularity of // our time keeping, we measure kChunkSize iterations per outer-loop iter. const int kChunkSize = 1000; GOOGLE_CHECK_EQ(kTestSize % kChunkSize, 0); do { - const int64 start = Now(); + const int64_t start = Now(); for (int i = 0; i < kChunkSize; i++) { map.erase(map.begin()); } - const int64 end = Now(); + const int64_t end = Now(); if (end > start) { times.push_back(end - start); } @@ -423,8 +422,8 @@ TEST_F(MapImplTest, BeginIsFast) { GOOGLE_LOG(WARNING) << "Now() isn't helping us measure time"; return; } - int64 x0 = median(times.begin(), times.begin() + 9); - int64 x1 = median(times.begin() + times.size() - 9, times.end()); + int64_t x0 = median(times.begin(), times.begin() + 9); + int64_t x1 = median(times.begin() + times.size() - 9, times.end()); GOOGLE_LOG(INFO) << "x0=" << x0 << ", x1=" << x1; // x1 will greatly exceed x0 if the code we just executed took O(n^2) time. // And we'll probably time out and never get here. So, this test is @@ -448,13 +447,13 @@ TEST_F(MapImplTest, HashFlood) { // 1024 (or 512 or 2048 or ...) entries. This assumes that map_ uses powers // of 2 for table sizes, and that it's sufficient to "flood" with respect to // the low bits of the output of map_.hash_function(). - std::vector<int64> times; + std::vector<int64_t> times; std::set<int>::iterator it = s.begin(); int count = 0; do { - const int64 start = Now(); + const int64_t start = Now(); map_[*it] = 0; - const int64 end = Now(); + const int64_t end = Now(); if (end > start) { times.push_back(end - start); } @@ -462,24 +461,25 @@ TEST_F(MapImplTest, HashFlood) { ++it; } while (it != s.end()); if (times.size() < .99 * count) return; - int64 x0 = median(times.begin(), times.begin() + 9); - int64 x1 = median(times.begin() + times.size() - 9, times.end()); + int64_t x0 = median(times.begin(), times.begin() + 9); + int64_t x1 = median(times.begin() + times.size() - 9, times.end()); // x1 will greatly exceed x0 if the code we just executed took O(n^2) time. // But we want to allow O(n log n). A factor of 20 should be generous enough. EXPECT_LE(x1, x0 * 20); } TEST_F(MapImplTest, CopyIteratorStressTest) { - std::vector<Map<int32, int32>::iterator> v; + std::vector<Map<int32_t, int32_t>::iterator> v; const int kIters = 1e5; - for (uint32 i = 0; i < kIters; i++) { - int32 key = (3 + i * (5 + i * (-8 + i * (62 + i)))) & 0x77777777; + for (uint32_t i = 0; i < kIters; i++) { + int32_t key = (3 + i * (5 + i * (-8 + i * (62 + i)))) & 0x77777777; map_[key] = i; v.push_back(map_.find(key)); } - for (std::vector<Map<int32, int32>::iterator>::const_iterator it = v.begin(); + for (std::vector<Map<int32_t, int32_t>::iterator>::const_iterator it = + v.begin(); it != v.end(); it++) { - Map<int32, int32>::iterator i = *it; + Map<int32_t, int32_t>::iterator i = *it; ASSERT_EQ(i->first, (*it)->first); ASSERT_EQ(i->second, (*it)->second); } @@ -554,11 +554,11 @@ static void StressTestIterators(int n) { GOOGLE_CHECK_GT(n, 0); // Create a random-looking map of size n. Use non-negative integer keys. Map<int, int> m; - uint32 frog = 123987 + n; + uint32_t frog = 123987 + n; int last_key = 0; int counter = 0; while (m.size() < n) { - frog *= static_cast<uint32>(k0); + frog *= static_cast<uint32_t>(k0); frog ^= frog >> 17; frog += counter++; last_key = @@ -687,47 +687,233 @@ TEST_F(MapImplTest, IteratorCategory) { Map<int, int>::const_iterator>::iterator_category())); } -TEST_F(MapImplTest, InsertSingle) { - int32 key = 0; - int32 value1 = 100; - int32 value2 = 101; +TEST_F(MapImplTest, InsertSingleLValue) { + int32_t key = 0; + int32_t value1 = 100; + int32_t value2 = 101; - // Insert a non-existed key. - std::pair<Map<int32, int32>::iterator, bool> result1 = - map_.insert(Map<int32, int32>::value_type(key, value1)); + // Insert a non-existing key. + Map<int32_t, int32_t>::value_type v1(key, value1); + std::pair<Map<int32_t, int32_t>::iterator, bool> result1 = map_.insert(v1); ExpectSingleElement(key, value1); - Map<int32, int32>::iterator it1 = result1.first; + Map<int32_t, int32_t>::iterator it1 = result1.first; EXPECT_EQ(key, it1->first); EXPECT_EQ(value1, it1->second); EXPECT_TRUE(result1.second); - // Insert an existed key. - std::pair<Map<int32, int32>::iterator, bool> result2 = - map_.insert(Map<int32, int32>::value_type(key, value2)); + // Insert an existing key. + Map<int32_t, int32_t>::value_type v2(key, value2); + std::pair<Map<int32_t, int32_t>::iterator, bool> result2 = map_.insert(v2); ExpectSingleElement(key, value1); - Map<int32, int32>::iterator it2 = result2.first; + Map<int32_t, int32_t>::iterator it2 = result2.first; + EXPECT_TRUE(it1 == it2); + EXPECT_FALSE(result2.second); +} + +TEST_F(MapImplTest, InsertSingleRValue) { + int32_t key = 0; + int32_t value1 = 100; + int32_t value2 = 101; + + // Insert a non-existing key. + std::pair<Map<int32_t, int32_t>::iterator, bool> result1 = + map_.insert(Map<int32_t, int32_t>::value_type(key, value1)); + ExpectSingleElement(key, value1); + + Map<int32_t, int32_t>::iterator it1 = result1.first; + EXPECT_EQ(key, it1->first); + EXPECT_EQ(value1, it1->second); + EXPECT_TRUE(result1.second); + + // Insert an existing key. + std::pair<Map<int32_t, int32_t>::iterator, bool> result2 = + map_.insert(Map<int32_t, int32_t>::value_type(key, value2)); + ExpectSingleElement(key, value1); + + Map<int32_t, int32_t>::iterator it2 = result2.first; + EXPECT_TRUE(it1 == it2); + EXPECT_FALSE(result2.second); +} + +TEST_F(MapImplTest, TryEmplace) { + using ::testing::Pair; + using ::testing::UnorderedElementsAre; + + Map<int32_t, std::string> m; + + m.try_emplace(1, "one"); + EXPECT_EQ(m.size(), 1); + + const int32_t key = 42; + m.try_emplace(key, 3, 'a'); + m.try_emplace(2, std::string("two")); + EXPECT_THAT( + m, UnorderedElementsAre(Pair(1, "one"), Pair(2, "two"), Pair(42, "aaa"))); +} + +TEST_F(MapImplTest, Emplace) { + using ::testing::Pair; + using ::testing::UnorderedElementsAre; + + Map<int32_t, std::string> m; + + m.emplace(1, "one"); + EXPECT_EQ(m.size(), 1); + + const int32_t key = 42; + m.emplace(key, "aaa"); + m.emplace(2, std::string("two")); + EXPECT_THAT( + m, UnorderedElementsAre(Pair(1, "one"), Pair(2, "two"), Pair(42, "aaa"))); +} + +struct CountedInstance { + CountedInstance() { ++num_created; } + CountedInstance(const CountedInstance&) : CountedInstance() {} + CountedInstance(CountedInstance&&) : CountedInstance() {} + + CountedInstance& operator=(const CountedInstance&) { + ++num_assigned; + return *this; + } + + explicit CountedInstance(int x) : CountedInstance() {} + + static int num_created; + static int num_assigned; +}; + +int CountedInstance::num_created = 0; +int CountedInstance::num_assigned = 0; + +TEST_F(MapImplTest, TryEmplaceExisting) { + Map<int32_t, CountedInstance> m; + + m.try_emplace(1, 1); + ASSERT_EQ(m.size(), 1); + + CountedInstance::num_created = 0; + CountedInstance::num_assigned = 0; + m.try_emplace(1, 123); + EXPECT_EQ(m.size(), 1); + EXPECT_EQ(CountedInstance::num_created, 0); + EXPECT_EQ(CountedInstance::num_assigned, 0); +} + +struct ArenaConstructible { + using InternalArenaConstructable_ = void; + using DestructorSkippable_ = void; + + ArenaConstructible() = default; + ArenaConstructible(const ArenaConstructible&) = default; + ArenaConstructible(Arena*) : ArenaConstructible() {} + + ArenaConstructible& operator=(const ArenaConstructible&) = default; + + explicit ArenaConstructible(int) : ArenaConstructible() {} + + Arena* arena() const { return nullptr; } + + CountedInstance unused; +}; + +TEST_F(MapImplTest, TryEmplaceArenaConstructible) { + ASSERT_TRUE(Arena::is_arena_constructable<ArenaConstructible>::value); + + ArenaConstructible v1, v2; + + Map<int32_t, ArenaConstructible> m; + + // "default" construction + CountedInstance::num_created = 0; + CountedInstance::num_assigned = 0; + m.try_emplace(1); + EXPECT_EQ(m.size(), 1); + EXPECT_EQ(CountedInstance::num_created, 1); + EXPECT_EQ(CountedInstance::num_assigned, 0); + + // "default" construction + copy assignment + CountedInstance::num_created = 0; + CountedInstance::num_assigned = 0; + m.try_emplace(2, v1); + EXPECT_EQ(m.size(), 2); + EXPECT_EQ(CountedInstance::num_created, 1); + EXPECT_EQ(CountedInstance::num_assigned, 1); + + // "default" construction + move assignment + CountedInstance::num_created = 0; + CountedInstance::num_assigned = 0; + m.try_emplace(3, std::move(v2)); + EXPECT_EQ(m.size(), 3); + EXPECT_EQ(CountedInstance::num_created, 1); + EXPECT_EQ(CountedInstance::num_assigned, 1); + + // "default" construction + in-place temporary + move assignment + CountedInstance::num_created = 0; + CountedInstance::num_assigned = 0; + m.try_emplace(4, 239); + EXPECT_EQ(m.size(), 4); + EXPECT_EQ(CountedInstance::num_created, 2); + EXPECT_EQ(CountedInstance::num_assigned, 1); +} + +TEST_F(MapImplTest, TryEmplaceExistingArenaConstructible) { + ASSERT_TRUE(Arena::is_arena_constructable<ArenaConstructible>::value); + + Map<int32_t, ArenaConstructible> m; + + m.try_emplace(1, 1); + ASSERT_EQ(m.size(), 1); + + CountedInstance::num_created = 0; + CountedInstance::num_assigned = 0; + m.try_emplace(1, 123); + EXPECT_EQ(m.size(), 1); + EXPECT_EQ(CountedInstance::num_created, 0); + EXPECT_EQ(CountedInstance::num_assigned, 0); +} + +TEST_F(MapImplTest, EmplaceSingle) { + int32_t key = 0; + int32_t value1 = 100; + int32_t value2 = 101; + + // Emplace a non-existing key. + auto result1 = map_.emplace(key, value1); + ExpectSingleElement(key, value1); + + Map<int32_t, int32_t>::iterator it1 = result1.first; + EXPECT_EQ(key, it1->first); + EXPECT_EQ(value1, it1->second); + EXPECT_TRUE(result1.second); + + // Emplace an existing key. + auto result2 = map_.emplace(key, value2); + ExpectSingleElement(key, value1); + + Map<int32_t, int32_t>::iterator it2 = result2.first; EXPECT_TRUE(it1 == it2); EXPECT_FALSE(result2.second); } TEST_F(MapImplTest, InsertByIterator) { - int32 key1 = 0; - int32 key2 = 1; - int32 value1a = 100; - int32 value1b = 101; - int32 value2a = 200; - int32 value2b = 201; + int32_t key1 = 0; + int32_t key2 = 1; + int32_t value1a = 100; + int32_t value1b = 101; + int32_t value2a = 200; + int32_t value2b = 201; - std::map<int32, int32> map1; + std::map<int32_t, int32_t> map1; map1[key1] = value1a; map1[key2] = value2a; map_.insert(map1.begin(), map1.end()); ExpectElements(map1); - std::map<int32, int32> map2; + std::map<int32_t, int32_t> map2; map2[key1] = value1b; map2[key2] = value2b; @@ -744,8 +930,8 @@ TEST_F(MapImplTest, InsertByInitializerList) { } TEST_F(MapImplTest, EraseSingleByKey) { - int32 key = 0; - int32 value = 100; + int32_t key = 0; + int32_t value = 100; map_[key] = value; ExpectSingleElement(key, value); @@ -789,13 +975,13 @@ TEST_F(MapImplTest, EraseMutipleByKey) { } TEST_F(MapImplTest, EraseSingleByIterator) { - int32 key = 0; - int32 value = 100; + int32_t key = 0; + int32_t value = 100; map_[key] = value; ExpectSingleElement(key, value); - Map<int32, int32>::iterator it = map_.find(key); + Map<int32_t, int32_t>::iterator it = map_.find(key); map_.erase(it); EXPECT_TRUE(map_.empty()); EXPECT_EQ(0, map_.size()); @@ -810,7 +996,7 @@ TEST_F(MapImplTest, ValidIteratorAfterErase) { int count = 0; - for (Map<int32, int32>::iterator it = map_.begin(); it != map_.end();) { + for (Map<int32_t, int32_t>::iterator it = map_.begin(); it != map_.end();) { count++; if (it->first % 2 == 1) { map_.erase(it++); @@ -824,12 +1010,12 @@ TEST_F(MapImplTest, ValidIteratorAfterErase) { } TEST_F(MapImplTest, EraseByIterator) { - int32 key1 = 0; - int32 key2 = 1; - int32 value1 = 100; - int32 value2 = 101; + int32_t key1 = 0; + int32_t key2 = 1; + int32_t value1 = 100; + int32_t value2 = 101; - std::map<int32, int32> map; + std::map<int32_t, int32_t> map; map[key1] = value1; map[key2] = value2; @@ -845,8 +1031,8 @@ TEST_F(MapImplTest, EraseByIterator) { } TEST_F(MapImplTest, Clear) { - int32 key = 0; - int32 value = 100; + int32_t key = 0; + int32_t value = 100; map_[key] = value; ExpectSingleElement(key, value); @@ -859,19 +1045,19 @@ TEST_F(MapImplTest, Clear) { EXPECT_TRUE(map_.begin() == map_.end()); } -static void CopyConstructorHelper(Arena* arena, Map<int32, int32>* m) { - int32 key1 = 0; - int32 key2 = 1; - int32 value1 = 100; - int32 value2 = 101; +static void CopyConstructorHelper(Arena* arena, Map<int32_t, int32_t>* m) { + int32_t key1 = 0; + int32_t key2 = 1; + int32_t value1 = 100; + int32_t value2 = 101; - std::map<int32, int32> map; + std::map<int32_t, int32_t> map; map[key1] = value1; map[key2] = value2; m->insert(map.begin(), map.end()); - Map<int32, int32> other(*m); + Map<int32_t, int32_t> other(*m); EXPECT_EQ(2, other.size()); EXPECT_EQ(value1, other.at(key1)); @@ -888,16 +1074,16 @@ TEST_F(MapImplTest, CopyConstructorWithoutArena) { } TEST_F(MapImplTest, IterConstructor) { - int32 key1 = 0; - int32 key2 = 1; - int32 value1 = 100; - int32 value2 = 101; + int32_t key1 = 0; + int32_t key2 = 1; + int32_t value1 = 100; + int32_t value2 = 101; - std::map<int32, int32> map; + std::map<int32_t, int32_t> map; map[key1] = value1; map[key2] = value2; - Map<int32, int32> new_map(map.begin(), map.end()); + Map<int32_t, int32_t> new_map(map.begin(), map.end()); EXPECT_EQ(2, new_map.size()); EXPECT_EQ(value1, new_map.at(key1)); @@ -905,20 +1091,20 @@ TEST_F(MapImplTest, IterConstructor) { } TEST_F(MapImplTest, Assigner) { - int32 key1 = 0; - int32 key2 = 1; - int32 value1 = 100; - int32 value2 = 101; + int32_t key1 = 0; + int32_t key2 = 1; + int32_t value1 = 100; + int32_t value2 = 101; - std::map<int32, int32> map; + std::map<int32_t, int32_t> map; map[key1] = value1; map[key2] = value2; map_.insert(map.begin(), map.end()); - Map<int32, int32> other; - int32 key_other = 123; - int32 value_other = 321; + Map<int32_t, int32_t> other; + int32_t key_other = 123; + int32_t value_other = 321; other[key_other] = value_other; EXPECT_EQ(1, other.size()); @@ -938,7 +1124,7 @@ TEST_F(MapImplTest, Assigner) { TEST_F(MapImplTest, Rehash) { const int test_size = 50; - std::map<int32, int32> reference_map; + std::map<int32_t, int32_t> reference_map; for (int i = 0; i < test_size; i++) { reference_map[i] = i; } @@ -957,8 +1143,8 @@ TEST_F(MapImplTest, EqualRange) { int key = 100, key_missing = 101; map_[key] = 100; - std::pair<Map<int32, int32>::iterator, Map<int32, int32>::iterator> range = - map_.equal_range(key); + std::pair<Map<int32_t, int32_t>::iterator, Map<int32_t, int32_t>::iterator> + range = map_.equal_range(key); EXPECT_TRUE(map_.find(key) == range.first); EXPECT_TRUE(++map_.find(key) == range.second); @@ -966,8 +1152,8 @@ TEST_F(MapImplTest, EqualRange) { EXPECT_TRUE(map_.end() == range.first); EXPECT_TRUE(map_.end() == range.second); - std::pair<Map<int32, int32>::const_iterator, - Map<int32, int32>::const_iterator> + std::pair<Map<int32_t, int32_t>::const_iterator, + Map<int32_t, int32_t>::const_iterator> const_range = const_map_.equal_range(key); EXPECT_TRUE(const_map_.find(key) == const_range.first); EXPECT_TRUE(++const_map_.find(key) == const_range.second); @@ -979,21 +1165,21 @@ TEST_F(MapImplTest, EqualRange) { TEST_F(MapImplTest, ConvertToStdMap) { map_[100] = 101; - std::map<int32, int32> std_map(map_.begin(), map_.end()); + std::map<int32_t, int32_t> std_map(map_.begin(), map_.end()); EXPECT_EQ(1, std_map.size()); EXPECT_EQ(101, std_map[100]); } TEST_F(MapImplTest, ConvertToStdVectorOfPairs) { map_[100] = 101; - std::vector<std::pair<int32, int32> > std_vec(map_.begin(), map_.end()); + std::vector<std::pair<int32_t, int32_t>> std_vec(map_.begin(), map_.end()); EXPECT_EQ(1, std_vec.size()); EXPECT_EQ(100, std_vec[0].first); EXPECT_EQ(101, std_vec[0].second); } TEST_F(MapImplTest, SwapBasic) { - Map<int32, int32> another; + Map<int32_t, int32_t> another; map_[9398] = 41999; another[9398] = 41999; another[8070] = 42056; @@ -1006,8 +1192,8 @@ TEST_F(MapImplTest, SwapBasic) { TEST_F(MapImplTest, SwapArena) { Arena arena1, arena2; - Map<int32, int32> m1(&arena1); - Map<int32, int32> m2(&arena2); + Map<int32_t, int32_t> m1(&arena1); + Map<int32_t, int32_t> m2(&arena2); map_[9398] = 41999; m1[9398] = 41999; m1[8070] = 42056; @@ -1063,7 +1249,7 @@ TEST_F(MapImplTest, CopyAssignMapIterator) { TEST_F(MapImplTest, SpaceUsed) { constexpr size_t kMinCap = 8; - Map<int32, int32> m; + Map<int32_t, int32_t> m; // An newly constructed map should have no space used. EXPECT_EQ(m.SpaceUsedExcludingSelfLong(), 0); @@ -1074,26 +1260,27 @@ TEST_F(MapImplTest, SpaceUsed) { if (m.size() >= capacity * kMaxLoadFactor) { capacity *= 2; } - EXPECT_EQ(m.SpaceUsedExcludingSelfLong(), - sizeof(void*) * capacity + - m.size() * sizeof(std::pair<std::pair<int32, int32>, void*>)); + EXPECT_EQ( + m.SpaceUsedExcludingSelfLong(), + sizeof(void*) * capacity + + m.size() * sizeof(std::pair<std::pair<int32_t, int32_t>, void*>)); } // Test string, and non-scalar keys. - Map<std::string, int32> m2; + Map<std::string, int32_t> m2; std::string str = "Some arbitrarily large string"; m2[str] = 1; EXPECT_EQ(m2.SpaceUsedExcludingSelfLong(), sizeof(void*) * kMinCap + - sizeof(std::pair<std::pair<std::string, int32>, void*>) + + sizeof(std::pair<std::pair<std::string, int32_t>, void*>) + internal::StringSpaceUsedExcludingSelfLong(str)); // Test messages, and non-scalar values. - Map<int32, TestAllTypes> m3; + Map<int32_t, TestAllTypes> m3; m3[0].set_optional_string(str); EXPECT_EQ(m3.SpaceUsedExcludingSelfLong(), sizeof(void*) * kMinCap + - sizeof(std::pair<std::pair<int32, TestAllTypes>, void*>) + + sizeof(std::pair<std::pair<int32_t, TestAllTypes>, void*>) + m3[0].SpaceUsedLong() - sizeof(m3[0])); } @@ -1102,12 +1289,12 @@ TEST_F(MapImplTest, SpaceUsed) { bool MapOrderingIsRandom(int a, int b) { bool saw_a_first = false; bool saw_b_first = false; - std::vector<Map<int32, int32>> v(50); + std::vector<Map<int32_t, int32_t>> v(50); for (int i = 0; i < 50; ++i) { - Map<int32, int32>& m = v[i]; + Map<int32_t, int32_t>& m = v[i]; m[a] = 0; m[b] = 0; - int32 first_element = m.begin()->first; + int32_t first_element = m.begin()->first; if (first_element == a) saw_a_first = true; if (first_element == b) saw_b_first = true; if (saw_a_first && saw_b_first) { @@ -1234,11 +1421,11 @@ TEST_F(MapFieldReflectionTest, RegularFields) { const Reflection* refl = message.GetReflection(); const Descriptor* desc = message.GetDescriptor(); - Map<int32, int32>* map_int32_int32 = message.mutable_map_int32_int32(); - Map<int32, double>* map_int32_double = message.mutable_map_int32_double(); + Map<int32_t, int32_t>* map_int32_int32 = message.mutable_map_int32_int32(); + Map<int32_t, double>* map_int32_double = message.mutable_map_int32_double(); Map<std::string, std::string>* map_string_string = message.mutable_map_string_string(); - Map<int32, ForeignMessage>* map_int32_foreign_message = + Map<int32_t, ForeignMessage>* map_int32_foreign_message = message.mutable_map_int32_foreign_message(); for (int i = 0; i < 10; ++i) { @@ -1259,21 +1446,21 @@ TEST_F(MapFieldReflectionTest, RegularFields) { desc->FindFieldByName("map_int32_foreign_message"); const FieldDescriptor* fd_map_int32_in32_key = - fd_map_int32_int32->message_type()->FindFieldByName("key"); + fd_map_int32_int32->message_type()->map_key(); const FieldDescriptor* fd_map_int32_in32_value = - fd_map_int32_int32->message_type()->FindFieldByName("value"); + fd_map_int32_int32->message_type()->map_value(); const FieldDescriptor* fd_map_int32_double_key = - fd_map_int32_double->message_type()->FindFieldByName("key"); + fd_map_int32_double->message_type()->map_key(); const FieldDescriptor* fd_map_int32_double_value = - fd_map_int32_double->message_type()->FindFieldByName("value"); + fd_map_int32_double->message_type()->map_value(); const FieldDescriptor* fd_map_string_string_key = - fd_map_string_string->message_type()->FindFieldByName("key"); + fd_map_string_string->message_type()->map_key(); const FieldDescriptor* fd_map_string_string_value = - fd_map_string_string->message_type()->FindFieldByName("value"); + fd_map_string_string->message_type()->map_value(); const FieldDescriptor* fd_map_int32_foreign_message_key = - fd_map_int32_foreign_message->message_type()->FindFieldByName("key"); + fd_map_int32_foreign_message->message_type()->map_key(); const FieldDescriptor* fd_map_int32_foreign_message_value = - fd_map_int32_foreign_message->message_type()->FindFieldByName("value"); + fd_map_int32_foreign_message->message_type()->map_value(); // Get RepeatedPtrField objects for all fields of interest. const RepeatedPtrField<Message>& mf_int32_int32 = @@ -1301,14 +1488,14 @@ TEST_F(MapFieldReflectionTest, RegularFields) { { // Check gets through const objects. const Message& message_int32_int32 = mf_int32_int32.Get(i); - int32 key_int32_int32 = message_int32_int32.GetReflection()->GetInt32( + int32_t key_int32_int32 = message_int32_int32.GetReflection()->GetInt32( message_int32_int32, fd_map_int32_in32_key); - int32 value_int32_int32 = message_int32_int32.GetReflection()->GetInt32( + int32_t value_int32_int32 = message_int32_int32.GetReflection()->GetInt32( message_int32_int32, fd_map_int32_in32_value); EXPECT_EQ(value_int32_int32, Func(key_int32_int32, 1)); const Message& message_int32_double = mf_int32_double.Get(i); - int32 key_int32_double = message_int32_double.GetReflection()->GetInt32( + int32_t key_int32_double = message_int32_double.GetReflection()->GetInt32( message_int32_double, fd_map_int32_double_key); double value_int32_double = message_int32_double.GetReflection()->GetDouble( @@ -1325,8 +1512,9 @@ TEST_F(MapFieldReflectionTest, RegularFields) { EXPECT_EQ(value_string_string, StrFunc(Int(key_string_string), 5)); const Message& message_int32_message = mf_int32_foreign_message.Get(i); - int32 key_int32_message = message_int32_message.GetReflection()->GetInt32( - message_int32_message, fd_map_int32_foreign_message_key); + int32_t key_int32_message = + message_int32_message.GetReflection()->GetInt32( + message_int32_message, fd_map_int32_foreign_message_key); const ForeignMessage& value_int32_message = down_cast<const ForeignMessage&>( message_int32_message.GetReflection()->GetMessage( @@ -1337,14 +1525,14 @@ TEST_F(MapFieldReflectionTest, RegularFields) { { // Check gets through mutable objects. const Message& message_int32_int32 = mmf_int32_int32->Get(i); - int32 key_int32_int32 = message_int32_int32.GetReflection()->GetInt32( + int32_t key_int32_int32 = message_int32_int32.GetReflection()->GetInt32( message_int32_int32, fd_map_int32_in32_key); - int32 value_int32_int32 = message_int32_int32.GetReflection()->GetInt32( + int32_t value_int32_int32 = message_int32_int32.GetReflection()->GetInt32( message_int32_int32, fd_map_int32_in32_value); EXPECT_EQ(value_int32_int32, Func(key_int32_int32, 1)); const Message& message_int32_double = mmf_int32_double->Get(i); - int32 key_int32_double = message_int32_double.GetReflection()->GetInt32( + int32_t key_int32_double = message_int32_double.GetReflection()->GetInt32( message_int32_double, fd_map_int32_double_key); double value_int32_double = message_int32_double.GetReflection()->GetDouble( @@ -1361,8 +1549,9 @@ TEST_F(MapFieldReflectionTest, RegularFields) { EXPECT_EQ(value_string_string, StrFunc(Int(key_string_string), 5)); const Message& message_int32_message = mmf_int32_foreign_message->Get(i); - int32 key_int32_message = message_int32_message.GetReflection()->GetInt32( - message_int32_message, fd_map_int32_foreign_message_key); + int32_t key_int32_message = + message_int32_message.GetReflection()->GetInt32( + message_int32_message, fd_map_int32_foreign_message_key); const ForeignMessage& value_int32_message = down_cast<const ForeignMessage&>( message_int32_message.GetReflection()->GetMessage( @@ -1375,15 +1564,16 @@ TEST_F(MapFieldReflectionTest, RegularFields) { for (int i = 0; i < 10; i++) { { Message* message_int32_int32 = mmf_int32_int32->Mutable(i); - int32 key_int32_int32 = message_int32_int32->GetReflection()->GetInt32( + int32_t key_int32_int32 = message_int32_int32->GetReflection()->GetInt32( *message_int32_int32, fd_map_int32_in32_key); message_int32_int32->GetReflection()->SetInt32(message_int32_int32, fd_map_int32_in32_value, Func(key_int32_int32, -1)); Message* message_int32_double = mmf_int32_double->Mutable(i); - int32 key_int32_double = message_int32_double->GetReflection()->GetInt32( - *message_int32_double, fd_map_int32_double_key); + int32_t key_int32_double = + message_int32_double->GetReflection()->GetInt32( + *message_int32_double, fd_map_int32_double_key); message_int32_double->GetReflection()->SetDouble( message_int32_double, fd_map_int32_double_value, Func(key_int32_double, -2)); @@ -1397,7 +1587,7 @@ TEST_F(MapFieldReflectionTest, RegularFields) { StrFunc(Int(key_string_string), -5)); Message* message_int32_message = mmf_int32_foreign_message->Mutable(i); - int32 key_int32_message = + int32_t key_int32_message = message_int32_message->GetReflection()->GetInt32( *message_int32_message, fd_map_int32_foreign_message_key); ForeignMessage* value_int32_message = down_cast<ForeignMessage*>( @@ -1421,11 +1611,11 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { const Reflection* refl = message.GetReflection(); const Descriptor* desc = message.GetDescriptor(); - Map<int32, int32>* map_int32_int32 = message.mutable_map_int32_int32(); - Map<int32, double>* map_int32_double = message.mutable_map_int32_double(); + Map<int32_t, int32_t>* map_int32_int32 = message.mutable_map_int32_int32(); + Map<int32_t, double>* map_int32_double = message.mutable_map_int32_double(); Map<std::string, std::string>* map_string_string = message.mutable_map_string_string(); - Map<int32, ForeignMessage>* map_int32_foreign_message = + Map<int32_t, ForeignMessage>* map_int32_foreign_message = message.mutable_map_int32_foreign_message(); for (int i = 0; i < 10; ++i) { @@ -1446,21 +1636,21 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { desc->FindFieldByName("map_int32_foreign_message"); const FieldDescriptor* fd_map_int32_in32_key = - fd_map_int32_int32->message_type()->FindFieldByName("key"); + fd_map_int32_int32->message_type()->map_key(); const FieldDescriptor* fd_map_int32_in32_value = - fd_map_int32_int32->message_type()->FindFieldByName("value"); + fd_map_int32_int32->message_type()->map_value(); const FieldDescriptor* fd_map_int32_double_key = - fd_map_int32_double->message_type()->FindFieldByName("key"); + fd_map_int32_double->message_type()->map_key(); const FieldDescriptor* fd_map_int32_double_value = - fd_map_int32_double->message_type()->FindFieldByName("value"); + fd_map_int32_double->message_type()->map_value(); const FieldDescriptor* fd_map_string_string_key = - fd_map_string_string->message_type()->FindFieldByName("key"); + fd_map_string_string->message_type()->map_key(); const FieldDescriptor* fd_map_string_string_value = - fd_map_string_string->message_type()->FindFieldByName("value"); + fd_map_string_string->message_type()->map_value(); const FieldDescriptor* fd_map_int32_foreign_message_key = - fd_map_int32_foreign_message->message_type()->FindFieldByName("key"); + fd_map_int32_foreign_message->message_type()->map_key(); const FieldDescriptor* fd_map_int32_foreign_message_value = - fd_map_int32_foreign_message->message_type()->FindFieldByName("value"); + fd_map_int32_foreign_message->message_type()->map_value(); // Get RepeatedFieldRef objects for all fields of interest. const RepeatedFieldRef<Message> mf_int32_int32 = @@ -1525,15 +1715,15 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { // Check gets through const objects. const Message& message_int32_int32 = mf_int32_int32.Get(i, entry_int32_int32.get()); - int32 key_int32_int32 = message_int32_int32.GetReflection()->GetInt32( + int32_t key_int32_int32 = message_int32_int32.GetReflection()->GetInt32( message_int32_int32, fd_map_int32_in32_key); - int32 value_int32_int32 = message_int32_int32.GetReflection()->GetInt32( + int32_t value_int32_int32 = message_int32_int32.GetReflection()->GetInt32( message_int32_int32, fd_map_int32_in32_value); EXPECT_EQ(value_int32_int32, Func(key_int32_int32, 1)); const Message& message_int32_double = mf_int32_double.Get(i, entry_int32_double.get()); - int32 key_int32_double = message_int32_double.GetReflection()->GetInt32( + int32_t key_int32_double = message_int32_double.GetReflection()->GetInt32( message_int32_double, fd_map_int32_double_key); double value_int32_double = message_int32_double.GetReflection()->GetDouble( @@ -1552,8 +1742,9 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { const Message& message_int32_message = mf_int32_foreign_message.Get(i, entry_int32_foreign_message.get()); - int32 key_int32_message = message_int32_message.GetReflection()->GetInt32( - message_int32_message, fd_map_int32_foreign_message_key); + int32_t key_int32_message = + message_int32_message.GetReflection()->GetInt32( + message_int32_message, fd_map_int32_foreign_message_key); const ForeignMessage& value_int32_message = down_cast<const ForeignMessage&>( message_int32_message.GetReflection()->GetMessage( @@ -1565,15 +1756,15 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { // Check gets through mutable objects. const Message& message_int32_int32 = mmf_int32_int32.Get(i, entry_int32_int32.get()); - int32 key_int32_int32 = message_int32_int32.GetReflection()->GetInt32( + int32_t key_int32_int32 = message_int32_int32.GetReflection()->GetInt32( message_int32_int32, fd_map_int32_in32_key); - int32 value_int32_int32 = message_int32_int32.GetReflection()->GetInt32( + int32_t value_int32_int32 = message_int32_int32.GetReflection()->GetInt32( message_int32_int32, fd_map_int32_in32_value); EXPECT_EQ(value_int32_int32, Func(key_int32_int32, 1)); const Message& message_int32_double = mmf_int32_double.Get(i, entry_int32_double.get()); - int32 key_int32_double = message_int32_double.GetReflection()->GetInt32( + int32_t key_int32_double = message_int32_double.GetReflection()->GetInt32( message_int32_double, fd_map_int32_double_key); double value_int32_double = message_int32_double.GetReflection()->GetDouble( @@ -1592,8 +1783,9 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { const Message& message_int32_message = mmf_int32_foreign_message.Get(i, entry_int32_foreign_message.get()); - int32 key_int32_message = message_int32_message.GetReflection()->GetInt32( - message_int32_message, fd_map_int32_foreign_message_key); + int32_t key_int32_message = + message_int32_message.GetReflection()->GetInt32( + message_int32_message, fd_map_int32_foreign_message_key); const ForeignMessage& value_int32_message = down_cast<const ForeignMessage&>( message_int32_message.GetReflection()->GetMessage( @@ -1654,19 +1846,20 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { // Test iterators. { int index = 0; - std::unordered_map<int32, int32> result; + std::unordered_map<int32_t, int32_t> result; for (RepeatedFieldRef<Message>::iterator it = mf_int32_int32.begin(); it != mf_int32_int32.end(); ++it) { const Message& message = *it; - int32 key = + int32_t key = message.GetReflection()->GetInt32(message, fd_map_int32_in32_key); - int32 value = + int32_t value = message.GetReflection()->GetInt32(message, fd_map_int32_in32_value); result[key] = value; ++index; } EXPECT_EQ(10, index); - for (std::unordered_map<int32, int32>::const_iterator it = result.begin(); + for (std::unordered_map<int32_t, int32_t>::const_iterator it = + result.begin(); it != result.end(); ++it) { EXPECT_EQ(message.map_int32_int32().at(it->first), it->second); } @@ -1674,11 +1867,11 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { { int index = 0; - std::unordered_map<int32, double> result; + std::unordered_map<int32_t, double> result; for (RepeatedFieldRef<Message>::iterator it = mf_int32_double.begin(); it != mf_int32_double.end(); ++it) { const Message& message = *it; - int32 key = + int32_t key = message.GetReflection()->GetInt32(message, fd_map_int32_double_key); double value = message.GetReflection()->GetDouble( message, fd_map_int32_double_value); @@ -1686,7 +1879,8 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { ++index; } EXPECT_EQ(10, index); - for (std::unordered_map<int32, double>::const_iterator it = result.begin(); + for (std::unordered_map<int32_t, double>::const_iterator it = + result.begin(); it != result.end(); ++it) { EXPECT_EQ(message.map_int32_double().at(it->first), it->second); } @@ -1715,12 +1909,12 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { { int index = 0; - std::map<int32, ForeignMessage> result; + std::map<int32_t, ForeignMessage> result; for (RepeatedFieldRef<Message>::iterator it = mf_int32_foreign_message.begin(); it != mf_int32_foreign_message.end(); ++it) { const Message& message = *it; - int32 key = message.GetReflection()->GetInt32( + int32_t key = message.GetReflection()->GetInt32( message, fd_map_int32_foreign_message_key); const ForeignMessage& sub_message = down_cast<const ForeignMessage&>(message.GetReflection()->GetMessage( @@ -1729,7 +1923,7 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { ++index; } EXPECT_EQ(10, index); - for (std::map<int32, ForeignMessage>::const_iterator it = result.begin(); + for (std::map<int32_t, ForeignMessage>::const_iterator it = result.begin(); it != result.end(); ++it) { EXPECT_EQ(message.map_int32_foreign_message().at(it->first).c(), it->second.c()); @@ -1805,19 +1999,19 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { // Test MutableRepeatedFieldRef::SwapElements() { const Message& message0a = mmf_int32_int32.Get(0, entry_int32_int32.get()); - int32 int32_value0a = + int32_t int32_value0a = message0a.GetReflection()->GetInt32(message0a, fd_map_int32_in32_value); const Message& message9a = mmf_int32_int32.Get(9, entry_int32_int32.get()); - int32 int32_value9a = + int32_t int32_value9a = message9a.GetReflection()->GetInt32(message9a, fd_map_int32_in32_value); mmf_int32_int32.SwapElements(0, 9); const Message& message0b = mmf_int32_int32.Get(0, entry_int32_int32.get()); - int32 int32_value0b = + int32_t int32_value0b = message0b.GetReflection()->GetInt32(message0b, fd_map_int32_in32_value); const Message& message9b = mmf_int32_int32.Get(9, entry_int32_int32.get()); - int32 int32_value9b = + int32_t int32_value9b = message9b.GetReflection()->GetInt32(message9b, fd_map_int32_in32_value); EXPECT_EQ(int32_value9a, int32_value0b); @@ -1880,13 +2074,13 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { const ForeignMessage& sub_message0a = down_cast<const ForeignMessage&>(message0a.GetReflection()->GetMessage( message0a, fd_map_int32_foreign_message_value)); - int32 int32_value0a = sub_message0a.c(); + int32_t int32_value0a = sub_message0a.c(); const Message& message9a = mmf_int32_foreign_message.Get(9, entry_int32_foreign_message.get()); const ForeignMessage& sub_message9a = down_cast<const ForeignMessage&>(message9a.GetReflection()->GetMessage( message9a, fd_map_int32_foreign_message_value)); - int32 int32_value9a = sub_message9a.c(); + int32_t int32_value9a = sub_message9a.c(); mmf_int32_foreign_message.SwapElements(0, 9); @@ -1895,13 +2089,13 @@ TEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) { const ForeignMessage& sub_message0b = down_cast<const ForeignMessage&>(message0b.GetReflection()->GetMessage( message0b, fd_map_int32_foreign_message_value)); - int32 int32_value0b = sub_message0b.c(); + int32_t int32_value0b = sub_message0b.c(); const Message& message9b = mmf_int32_foreign_message.Get(9, entry_int32_foreign_message.get()); const ForeignMessage& sub_message9b = down_cast<const ForeignMessage&>(message9b.GetReflection()->GetMessage( message9b, fd_map_int32_foreign_message_value)); - int32 int32_value9b = sub_message9b.c(); + int32_t int32_value9b = sub_message9b.c(); EXPECT_EQ(int32_value9a, int32_value0b); EXPECT_EQ(int32_value0a, int32_value9b); @@ -2037,8 +2231,7 @@ TEST_F(MapFieldReflectionTest, MapSizeWithDuplicatedKey) { Message* entry2 = reflection->AddMessage(message.get(), field); const Reflection* entry_reflection = entry1->GetReflection(); - const FieldDescriptor* key_field = - entry1->GetDescriptor()->FindFieldByName("key"); + const FieldDescriptor* key_field = entry1->GetDescriptor()->map_key(); entry_reflection->SetInt32(entry1, key_field, 1); entry_reflection->SetInt32(entry2, key_field, 1); @@ -2058,8 +2251,7 @@ TEST_F(MapFieldReflectionTest, MapSizeWithDuplicatedKey) { Message* entry2 = reflection->AddMessage(&message, field); const Reflection* entry_reflection = entry1->GetReflection(); - const FieldDescriptor* key_field = - entry1->GetDescriptor()->FindFieldByName("key"); + const FieldDescriptor* key_field = entry1->GetDescriptor()->map_key(); entry_reflection->SetInt32(entry1, key_field, 1); entry_reflection->SetInt32(entry2, key_field, 1); @@ -2079,7 +2271,7 @@ TEST_F(MapFieldReflectionTest, UninitializedEntry) { } class MyMapEntry - : public internal::MapEntry<MyMapEntry, ::google::protobuf::int32, ::google::protobuf::int32, + : public internal::MapEntry<MyMapEntry, ::int32_t, ::int32_t, internal::WireFormatLite::TYPE_INT32, internal::WireFormatLite::TYPE_INT32> { public: @@ -2091,7 +2283,7 @@ class MyMapEntry }; class MyMapEntryLite - : public internal::MapEntryLite<MyMapEntryLite, ::google::protobuf::int32, ::google::protobuf::int32, + : public internal::MapEntryLite<MyMapEntryLite, ::int32_t, ::int32_t, internal::WireFormatLite::TYPE_INT32, internal::WireFormatLite::TYPE_INT32> { public: @@ -2405,8 +2597,8 @@ TEST(GeneratedMapFieldTest, SerializationToArray) { MapTestUtil::SetMapFields(&message1); size_t size = message1.ByteSizeLong(); data.resize(size); - uint8* start = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&data)); - uint8* end = message1.SerializeWithCachedSizesToArray(start); + uint8_t* start = reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&data)); + uint8_t* end = message1.SerializeWithCachedSizesToArray(start); EXPECT_EQ(size, end - start); EXPECT_TRUE(message2.ParseFromString(data)); MapTestUtil::ExpectMapFieldsSet(message2); @@ -2699,7 +2891,7 @@ TEST(GeneratedMapFieldTest, SpaceUsed) { // The exact value will depend on internal state, like collisions, // so we can't predict it. But we can predict a lower bound. size_t lower_bound = - initial + kNumValues * (space_used_message + sizeof(int32) + + initial + kNumValues * (space_used_message + sizeof(int32_t) + /* Node::next */ sizeof(void*) + /* table entry */ sizeof(void*)); @@ -2950,8 +3142,7 @@ TEST(GeneratedMapFieldReflectionTest, EmbedProto2Message) { const FieldDescriptor* map_field = UNITTEST::TestMessageMap::descriptor()->FindFieldByName( "map_int32_message"); - const FieldDescriptor* value = - map_field->message_type()->FindFieldByName("value"); + const FieldDescriptor* value = map_field->message_type()->map_value(); Message* entry_message = message.GetReflection()->AddMessage(&message, map_field); @@ -2970,10 +3161,8 @@ TEST(GeneratedMapFieldReflectionTest, MergeFromClearMapEntry) { UNITTEST::TestMap message; const FieldDescriptor* map_field = UNITTEST::TestMap::descriptor()->FindFieldByName("map_int32_int32"); - const FieldDescriptor* key = - map_field->message_type()->FindFieldByName("key"); - const FieldDescriptor* value = - map_field->message_type()->FindFieldByName("value"); + const FieldDescriptor* key = map_field->message_type()->map_key(); + const FieldDescriptor* value = map_field->message_type()->map_value(); Message* entry_message1 = message.GetReflection()->AddMessage(&message, map_field); @@ -3005,7 +3194,7 @@ TEST(GeneratedMapFieldReflectionTest, Proto2MapEntryClear) { const FieldDescriptor* field_descriptor = descriptor->FindFieldByName("known_map_field"); const FieldDescriptor* value_descriptor = - field_descriptor->message_type()->FindFieldByName("value"); + field_descriptor->message_type()->map_value(); Message* sub_message = message.GetReflection()->AddMessage(&message, field_descriptor); EXPECT_EQ(0, sub_message->GetReflection()->GetEnumValue(*sub_message, @@ -3035,7 +3224,7 @@ class MapFieldInDynamicMessageTest : public testing::Test { MapFieldInDynamicMessageTest() : pool_(DescriptorPool::generated_pool()), factory_(pool_) {} - virtual void SetUp() { + void SetUp() override { map_descriptor_ = pool_->FindMessageTypeByName( std::string(UNITTEST_PACKAGE_NAME) + ".TestMap"); recursive_map_descriptor_ = pool_->FindMessageTypeByName( @@ -3133,7 +3322,7 @@ TEST_F(MapFieldInDynamicMessageTest, MapEntryReferernceValidAfterSerialize) { message.get(), "map_int32_foreign_message", 0); const Reflection* map_entry_reflection = map_entry->GetReflection(); const Descriptor* map_entry_desc = map_entry->GetDescriptor(); - const FieldDescriptor* value_field = map_entry_desc->FindFieldByName("value"); + const FieldDescriptor* value_field = map_entry_desc->map_value(); Message* submsg = map_entry_reflection->MutableMessage(map_entry, value_field); @@ -3497,8 +3686,8 @@ static std::string DeterministicSerialization(const T& t) { } // Helper for MapSerializationTest. Return a 7-bit ASCII string. -static std::string ConstructKey(uint64 n) { - std::string s(n % static_cast<uint64>(9), '\0'); +static std::string ConstructKey(uint64_t n) { + std::string s(n % static_cast<uint64_t>(9), '\0'); if (s.empty()) { return StrCat(n); } else { @@ -3516,13 +3705,13 @@ TEST(MapSerializationTest, Deterministic) { UNITTEST::TestIntIntMap inner; (*inner.mutable_m())[0] = (*inner.mutable_m())[10] = (*inner.mutable_m())[-200] = 0; - uint64 frog = 9; - const uint64 multiplier = 0xa29cd16f; + uint64_t frog = 9; + const uint64_t multiplier = 0xa29cd16f; for (int i = 0; i < kIters; i++) { - const int32 i32 = static_cast<int32>(frog & 0xffffffff); - const uint32 u32 = static_cast<uint32>(i32) * 91919; - const int64 i64 = static_cast<int64>(frog); - const uint64 u64 = frog * static_cast<uint64>(187321); + const int32_t i32 = static_cast<int32_t>(frog & 0xffffffff); + const uint32_t u32 = static_cast<uint32_t>(i32) * 91919; + const int64_t i64 = static_cast<int64_t>(frog); + const uint64_t u64 = frog * static_cast<uint64_t>(187321); const bool b = i32 > 0; const std::string s = ConstructKey(frog); (*inner.mutable_m())[i] = i32; @@ -3534,8 +3723,9 @@ TEST(MapSerializationTest, Deterministic) { (*t.mutable_m_uint64())[u64] = (*t.mutable_m_fixed64())[u64] = inner; (*t.mutable_m_bool())[b] = inner; (*t.mutable_m_string())[s] = inner; - (*t.mutable_m_string())[s + std::string(1 << (u32 % static_cast<uint32>(9)), - b)] = inner; + (*t.mutable_m_string())[s + std::string( + 1 << (u32 % static_cast<uint32_t>(9)), b)] = + inner; inner.mutable_m()->erase(i); frog = frog * multiplier + i; frog ^= (frog >> 41); @@ -3569,6 +3759,7 @@ TEST(MapSerializationTest, DeterministicSubmessage) { // randomly-chosen hash function. const int kAttempts = 10; for (int i = 0; i < kAttempts; i++) { + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) UNITTEST::TestSubmessageMaps q(p); ASSERT_EQ(DeterministicSerialization(q), DeterministicSerialization(p)); } @@ -3605,7 +3796,9 @@ TEST(TextFormatMapTest, DynamicMessage) { &expected_text, true)); CleanStringLineEndings(&expected_text, false); - EXPECT_EQ(message->DebugString(), expected_text); + std::string actual_text; + TextFormat::PrintToString(*message, &actual_text); + EXPECT_EQ(actual_text, expected_text); } TEST(TextFormatMapTest, Sorted) { @@ -3620,13 +3813,17 @@ TEST(TextFormatMapTest, Sorted) { &expected_text, true)); CleanStringLineEndings(&expected_text, false); - EXPECT_EQ(message.DebugString(), expected_text); + TextFormat::Printer printer; + std::string actual_text; + printer.PrintToString(message, &actual_text); + EXPECT_EQ(actual_text, expected_text); // Test again on the reverse order. UNITTEST::TestMap message2; tester.SetMapFieldsViaReflection(&message2); tester.SwapMapsViaReflection(&message2); - EXPECT_EQ(message2.DebugString(), expected_text); + printer.PrintToString(message2, &actual_text); + EXPECT_EQ(actual_text, expected_text); } TEST(TextFormatMapTest, ParseCorruptedString) { @@ -3649,7 +3846,8 @@ TEST(TextFormatMapTest, NoDisableIterator) { (*source.mutable_map_int32_int32())[1] = 1; // Get iterator. - Map<int32, int32>::iterator iter = source.mutable_map_int32_int32()->find(1); + Map<int32_t, int32_t>::iterator iter = + source.mutable_map_int32_int32()->find(1); // Serialize message to text format, which will invalidate the previous // iterator previously. @@ -3695,8 +3893,7 @@ TEST(TextFormatMapTest, NoDisableReflectionIterator) { // Modify map via the iterator (invalidated in previous implementation.). const Reflection* map_entry_reflection = iter->GetReflection(); - const FieldDescriptor* value_field_desc = - iter->GetDescriptor()->FindFieldByName("value"); + const FieldDescriptor* value_field_desc = iter->GetDescriptor()->map_value(); map_entry_reflection->SetInt32(&(*iter), value_field_desc, 2); GOOGLE_LOG(INFO) << iter->DebugString(); @@ -3831,13 +4028,13 @@ TEST(ArenaTest, DynamicMapFieldOnArenaMemoryLeak) { } TEST(MoveTest, MoveConstructorWorks) { - Map<int32, TestAllTypes> original_map; + Map<int32_t, TestAllTypes> original_map; original_map[42].mutable_optional_nested_message()->set_bb(42); original_map[43].mutable_optional_nested_message()->set_bb(43); const auto* nested_msg42_ptr = &original_map[42].optional_nested_message(); const auto* nested_msg43_ptr = &original_map[43].optional_nested_message(); - Map<int32, TestAllTypes> moved_to_map(std::move(original_map)); + Map<int32_t, TestAllTypes> moved_to_map(std::move(original_map)); EXPECT_TRUE(original_map.empty()); EXPECT_EQ(2, moved_to_map.size()); EXPECT_EQ(42, moved_to_map[42].optional_nested_message().bb()); @@ -3849,13 +4046,13 @@ TEST(MoveTest, MoveConstructorWorks) { } TEST(MoveTest, MoveAssignmentWorks) { - Map<int32, TestAllTypes> original_map; + Map<int32_t, TestAllTypes> original_map; original_map[42].mutable_optional_nested_message()->set_bb(42); original_map[43].mutable_optional_nested_message()->set_bb(43); const auto* nested_msg42_ptr = &original_map[42].optional_nested_message(); const auto* nested_msg43_ptr = &original_map[43].optional_nested_message(); - Map<int32, TestAllTypes> moved_to_map = std::move(original_map); + Map<int32_t, TestAllTypes> moved_to_map = std::move(original_map); EXPECT_TRUE(original_map.empty()); EXPECT_EQ(2, moved_to_map.size()); EXPECT_EQ(42, moved_to_map[42].optional_nested_message().bb()); diff --git a/r5dev/thirdparty/protobuf/map_test_util.inc b/r5dev/thirdparty/protobuf/map_test_util.inc index 48421332..31908c19 100644 --- a/r5dev/thirdparty/protobuf/map_test_util.inc +++ b/r5dev/thirdparty/protobuf/map_test_util.inc @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <thirdparty/protobuf/map_test_util_impl.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/map_test_util_impl.h> #include <thirdparty/protobuf/message.h> namespace google { diff --git a/r5dev/thirdparty/protobuf/map_type_handler.h b/r5dev/thirdparty/protobuf/map_type_handler.h index babec982..b63ac099 100644 --- a/r5dev/thirdparty/protobuf/map_type_handler.h +++ b/r5dev/thirdparty/protobuf/map_type_handler.h @@ -31,9 +31,10 @@ #ifndef GOOGLE_PROTOBUF_MAP_TYPE_HANDLER_H__ #define GOOGLE_PROTOBUF_MAP_TYPE_HANDLER_H__ -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> +#include <thirdparty/protobuf/arenastring.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/wire_format_lite.h> #ifdef SWIG @@ -322,7 +323,8 @@ inline uint8_t* MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Write( int field, const MapEntryAccessorType& value, uint8_t* ptr, io::EpsCopyOutputStream* stream) { ptr = stream->EnsureSpace(ptr); - return WireFormatLite::InternalWriteMessage(field, value, ptr, stream); + return WireFormatLite::InternalWriteMessage( + field, value, value.GetCachedSize(), ptr, stream); } #define WRITE_METHOD(FieldType, DeclaredType) \ @@ -578,25 +580,26 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::IsInitialized( template <typename Type> \ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge( \ const MapEntryAccessorType& from, TypeOnMemory* to, Arena* arena) { \ - to->Set(&internal::GetEmptyStringAlreadyInited(), from, arena); \ + to->Set(from, arena); \ } \ template <typename Type> \ void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::DeleteNoArena( \ TypeOnMemory& value) { \ - value.DestroyNoArena(&internal::GetEmptyStringAlreadyInited()); \ + value.Destroy(); \ } \ template <typename Type> \ constexpr auto \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Constinit() \ ->TypeOnMemory { \ - return TypeOnMemory(&internal::fixed_address_empty_string); \ + return TypeOnMemory(&internal::fixed_address_empty_string, \ + ConstantInitialized{}); \ } \ template <typename Type> \ inline typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ Type>::MapEntryAccessorType* \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable( \ TypeOnMemory* value, Arena* arena) { \ - return value->Mutable(ArenaStringPtr::EmptyDefault{}, arena); \ + return value->Mutable(arena); \ } \ template <typename Type> \ inline const typename MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ @@ -684,6 +687,48 @@ PRIMITIVE_HANDLER_FUNCTIONS(SFIXED32) PRIMITIVE_HANDLER_FUNCTIONS(BOOL) #undef PRIMITIVE_HANDLER_FUNCTIONS +// Functions for operating on a map entry using type handlers. +// +// Does not contain any representation (this class is not intended to be +// instantiated). +template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, + WireFormatLite::FieldType kValueFieldType> +struct MapEntryFuncs { + typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler; + typedef MapTypeHandler<kValueFieldType, Value> ValueTypeHandler; + enum : int { + kKeyFieldNumber = 1, + kValueFieldNumber = 2 + }; + + static uint8_t* InternalSerialize(int field_number, const Key& key, + const Value& value, uint8_t* ptr, + io::EpsCopyOutputStream* stream) { + ptr = stream->EnsureSpace(ptr); + ptr = WireFormatLite::WriteTagToArray( + field_number, WireFormatLite::WIRETYPE_LENGTH_DELIMITED, ptr); + ptr = io::CodedOutputStream::WriteVarint32ToArray(GetCachedSize(key, value), + ptr); + + ptr = KeyTypeHandler::Write(kKeyFieldNumber, key, ptr, stream); + return ValueTypeHandler::Write(kValueFieldNumber, value, ptr, stream); + } + + static size_t ByteSizeLong(const Key& key, const Value& value) { + // Tags for key and value will both be one byte (field numbers 1 and 2). + size_t inner_length = + 2 + KeyTypeHandler::ByteSize(key) + ValueTypeHandler::ByteSize(value); + return inner_length + io::CodedOutputStream::VarintSize32( + static_cast<uint32_t>(inner_length)); + } + + static int GetCachedSize(const Key& key, const Value& value) { + // Tags for key and value will both be one byte (field numbers 1 and 2). + return 2 + KeyTypeHandler::GetCachedSize(key) + + ValueTypeHandler::GetCachedSize(value); + } +}; + } // namespace internal } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/message.cc b/r5dev/thirdparty/protobuf/message.cc index 9425f7b9..99e35be7 100644 --- a/r5dev/thirdparty/protobuf/message.cc +++ b/r5dev/thirdparty/protobuf/message.cc @@ -41,25 +41,26 @@ #include <thirdparty/protobuf/stubs/casts.h> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/descriptor.pb.h> -#include <thirdparty/protobuf/parse_context.h> -#include <thirdparty/protobuf/reflection_internal.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> +#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/generated_message_reflection.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/map_field.h> #include <thirdparty/protobuf/map_field_inl.h> +#include <thirdparty/protobuf/parse_context.h> +#include <thirdparty/protobuf/reflection_internal.h> #include <thirdparty/protobuf/reflection_ops.h> #include <thirdparty/protobuf/unknown_field_set.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/wire_format_lite.h> -#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/map_util.h> #include <thirdparty/protobuf/stubs/stl_util.h> #include <thirdparty/protobuf/stubs/hash.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -83,11 +84,11 @@ void Message::MergeFrom(const Message& from) { auto* class_from = from.GetClassData(); auto* merge_to_from = class_to ? class_to->merge_to_from : nullptr; if (class_to == nullptr || class_to != class_from) { - merge_to_from = [](Message* to, const Message& from) { - ReflectionOps::Merge(from, to); + merge_to_from = [](Message& to, const Message& from) { + ReflectionOps::Merge(from, &to); }; } - merge_to_from(this, from); + merge_to_from(*this, from); } void Message::CheckTypeAndMergeFrom(const MessageLite& other) { @@ -110,25 +111,28 @@ void Message::CopyFrom(const Message& from) { << ", " "from: " << from.GetDescriptor()->full_name(); - copy_to_from = [](Message* to, const Message& from) { - ReflectionOps::Copy(from, to); + copy_to_from = [](Message& to, const Message& from) { + ReflectionOps::Copy(from, &to); }; } - copy_to_from(this, from); + copy_to_from(*this, from); } -void Message::CopyWithSizeCheck(Message* to, const Message& from) { +void Message::CopyWithSourceCheck(Message& to, const Message& from) { #ifndef NDEBUG - size_t from_size = from.ByteSizeLong(); + FailIfCopyFromDescendant(to, from); #endif - to->Clear(); -#ifndef NDEBUG - GOOGLE_CHECK_EQ(from_size, from.ByteSizeLong()) - << "Source of CopyFrom changed when clearing target. Either " - "source is a nested message in target (not allowed), or " - "another thread is modifying the source."; -#endif - to->GetClassData()->merge_to_from(to, from); + to.Clear(); + to.GetClassData()->merge_to_from(to, from); +} + +void Message::FailIfCopyFromDescendant(Message& to, const Message& from) { + auto* arena = to.GetArenaForAllocation(); + bool same_message_owned_arena = to.GetOwningArena() == nullptr && + arena != nullptr && + arena == from.GetOwningArena(); + GOOGLE_CHECK(!same_message_owned_arena && !internal::IsDescendant(to, from)) + << "Source of CopyFrom cannot be a descendant of the target."; } std::string Message::GetTypeName() const { diff --git a/r5dev/thirdparty/protobuf/message.h b/r5dev/thirdparty/protobuf/message.h index b49f9e87..e039965d 100644 --- a/r5dev/thirdparty/protobuf/message.h +++ b/r5dev/thirdparty/protobuf/message.h @@ -110,6 +110,7 @@ #ifndef GOOGLE_PROTOBUF_MESSAGE_H__ #define GOOGLE_PROTOBUF_MESSAGE_H__ + #include <iosfwd> #include <string> #include <type_traits> @@ -118,16 +119,15 @@ #include <thirdparty/protobuf/stubs/casts.h> #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/arena.h> +#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/generated_message_reflection.h> #include <thirdparty/protobuf/generated_message_util.h> +#include <thirdparty/protobuf/map.h> // TODO(b/211442718): cleanup #include <thirdparty/protobuf/message_lite.h> -#include <thirdparty/protobuf/port.h> -#define GOOGLE_PROTOBUF_HAS_ONEOF -#define GOOGLE_PROTOBUF_HAS_ARENAS - +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG @@ -145,7 +145,6 @@ class MessageFactory; // Defined in other files. class AssignDescriptorsHelper; class DynamicMessageFactory; -class DynamicMessageReflectionHelper; class GeneratedMessageReflectionTestHelper; class MapKey; class MapValueConstRef; @@ -220,6 +219,9 @@ const To& GetConstRefAtOffset(const Message& message, uint32_t offset) { } bool CreateUnknownEnumValues(const FieldDescriptor* field); + +// Returns true if "message" is a descendant of "root". +PROTOBUF_EXPORT bool IsDescendant(Message& root, const Message& message); } // namespace internal // Abstract interface for protocol messages. @@ -253,7 +255,7 @@ class PROTOBUF_EXPORT Message : public MessageLite { // Make this message into a copy of the given message. The given message // must have the same descriptor, but need not necessarily be the same class. // By default this is just implemented as "Clear(); MergeFrom(from);". - virtual void CopyFrom(const Message& from); + void CopyFrom(const Message& from); // Merge the fields from the given message into this message. Singular // fields will be overwritten, if specified in from, except for embedded @@ -303,8 +305,11 @@ class PROTOBUF_EXPORT Message : public MessageLite { // Debugging & Testing---------------------------------------------- - // Generates a human readable form of this message, useful for debugging - // and other purposes. + // Generates a human-readable form of this message for debugging purposes. + // Note that the format and content of a debug string is not guaranteed, may + // change without notice, and should not be depended on. Code that does + // anything except display a string to assist in debugging should use + // TextFormat instead. std::string DebugString() const; // Like DebugString(), but with less whitespace. std::string ShortDebugString() const; @@ -366,8 +371,8 @@ class PROTOBUF_EXPORT Message : public MessageLite { // Note: The order of arguments (to, then from) is chosen so that the ABI // of this function is the same as the CopyFrom method. That is, the // hidden "this" parameter comes first. - void (*copy_to_from)(Message* to, const Message& from_msg); - void (*merge_to_from)(Message* to, const Message& from_msg); + void (*copy_to_from)(Message& to, const Message& from_msg); + void (*merge_to_from)(Message& to, const Message& from_msg); }; // GetClassData() returns a pointer to a ClassData struct which // exists in global memory and is unique to each subclass. This uniqueness @@ -376,11 +381,14 @@ class PROTOBUF_EXPORT Message : public MessageLite { // TODO(jorg): change to pure virtual virtual const ClassData* GetClassData() const { return nullptr; } - // CopyWithSizeCheck calls Clear() and then MergeFrom(), and in debug + // CopyWithSourceCheck calls Clear() and then MergeFrom(), and in debug // builds, checks that calling Clear() on the destination message doesn't - // alter the size of the source. It assumes the messages are known to be - // of the same type, and thus uses GetClassData(). - static void CopyWithSizeCheck(Message* to, const Message& from); + // alter the source. It assumes the messages are known to be of the same + // type, and thus uses GetClassData(). + static void CopyWithSourceCheck(Message& to, const Message& from); + + // Fail if "from" is a descendant of "to" as such copy is not allowed. + static void FailIfCopyFromDescendant(Message& to, const Message& from); inline explicit Message(Arena* arena, bool is_message_owned = false) : MessageLite(arena, is_message_owned) {} @@ -1022,6 +1030,7 @@ class PROTOBUF_EXPORT Reflection final { bool IsEagerlyVerifiedLazyField(const FieldDescriptor* field) const; friend class FastReflectionMessageMutator; + friend bool internal::IsDescendant(Message& root, const Message& message); const Descriptor* const descriptor_; const internal::ReflectionSchema schema_; @@ -1040,7 +1049,6 @@ class PROTOBUF_EXPORT Reflection final { friend class ::PROTOBUF_NAMESPACE_ID::MessageLayoutInspector; friend class ::PROTOBUF_NAMESPACE_ID::AssignDescriptorsHelper; friend class DynamicMessageFactory; - friend class DynamicMessageReflectionHelper; friend class GeneratedMessageReflectionTestHelper; friend class python::MapReflectionFriend; friend class python::MessageReflectionFriend; @@ -1144,7 +1152,7 @@ class PROTOBUF_EXPORT Reflection final { const internal::ExtensionSet& GetExtensionSet(const Message& message) const; internal::ExtensionSet* MutableExtensionSet(Message* message) const; - inline const internal::InternalMetadata& GetInternalMetadata( + const internal::InternalMetadata& GetInternalMetadata( const Message& message) const; internal::InternalMetadata* MutableInternalMetadata(Message* message) const; @@ -1163,6 +1171,8 @@ class PROTOBUF_EXPORT Reflection final { inline uint32_t* MutableInlinedStringDonatedArray(Message* message) const; inline bool IsInlinedStringDonated(const Message& message, const FieldDescriptor* field) const; + inline void SwapInlinedStringDonated(Message* lhs, Message* rhs, + const FieldDescriptor* field) const; // Shallow-swap fields listed in fields vector of two messages. It is the // caller's responsibility to make sure shallow swap is safe. @@ -1375,11 +1385,11 @@ T* DynamicCastToGenerated(Message* from) { // Call this function to ensure that this message's reflection is linked into // the binary: // -// google::protobuf::LinkMessageReflection<FooMessage>(); +// google::protobuf::LinkMessageReflection<pkg::FooMessage>(); // // This will ensure that the following lookup will succeed: // -// DescriptorPool::generated_pool()->FindMessageTypeByName("FooMessage"); +// DescriptorPool::generated_pool()->FindMessageTypeByName("pkg.FooMessage"); // // As a side-effect, it will also guarantee that anything else from the same // .proto file will also be available for lookup in the generated pool. diff --git a/r5dev/thirdparty/protobuf/message_lite.cc b/r5dev/thirdparty/protobuf/message_lite.cc index 5db4f389..048634e4 100644 --- a/r5dev/thirdparty/protobuf/message_lite.cc +++ b/r5dev/thirdparty/protobuf/message_lite.cc @@ -41,20 +41,19 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> #include <thirdparty/protobuf/arena.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> +#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/repeated_field.h> -#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/stl_util.h> #include <thirdparty/protobuf/stubs/mutex.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -230,7 +229,7 @@ bool MessageLite::MergeFromImpl(io::CodedInputStream* input, if (PROTOBUF_PREDICT_FALSE(!ptr)) return false; ctx.BackUp(ptr); if (!ctx.EndedAtEndOfStream()) { - GOOGLE_DCHECK(ctx.LastTag() != 1); // We can't end on a pushed limit. + GOOGLE_DCHECK_NE(ctx.LastTag(), 1); // We can't end on a pushed limit. if (ctx.IsExceedingLimit(ptr)) return false; input->SetLastTag(ctx.LastTag()); } else { @@ -506,9 +505,8 @@ std::string MessageLite::SerializePartialAsString() const { namespace internal { -template <> -MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype( - const MessageLite* prototype, Arena* arena) { +MessageLite* NewFromPrototypeHelper(const MessageLite* prototype, + Arena* arena) { return prototype->New(arena); } template <> @@ -522,6 +520,15 @@ void GenericTypeHandler<std::string>::Merge(const std::string& from, *to = from; } +// Non-inline implementations of InternalMetadata destructor +// This is moved out of the header because the GOOGLE_DCHECK produces a lot of code. +void InternalMetadata::CheckedDestruct() { + if (HasMessageOwnedArenaTag()) { + GOOGLE_DCHECK(!HasUnknownFieldsTag()); + delete reinterpret_cast<Arena*>(ptr_ - kMessageOwnedArenaTagMask); + } +} + // Non-inline variants of std::string specializations for // various InternalMetadata routines. template <> diff --git a/r5dev/thirdparty/protobuf/message_lite.h b/r5dev/thirdparty/protobuf/message_lite.h index dbd2df43..6682c5b9 100644 --- a/r5dev/thirdparty/protobuf/message_lite.h +++ b/r5dev/thirdparty/protobuf/message_lite.h @@ -39,6 +39,7 @@ #ifndef GOOGLE_PROTOBUF_MESSAGE_LITE_H__ #define GOOGLE_PROTOBUF_MESSAGE_LITE_H__ + #include <climits> #include <string> @@ -46,12 +47,12 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> -#include <thirdparty/protobuf/explicitly_constructed.h> -#include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/stubs/once.h> #include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/stubs/strutil.h> - +#include <thirdparty/protobuf/explicitly_constructed.h> +#include <thirdparty/protobuf/metadata_lite.h> +#include <thirdparty/protobuf/stubs/hash.h> // TODO(b/211442718): cleanup // clang-format off #include <thirdparty/protobuf/port_def.inc> @@ -83,12 +84,6 @@ namespace internal { class SwapFieldHelper; -// Tag type used to invoke the constinit constructor overload of some classes. -// Such constructors are internal implementation details of the library. -struct ConstantInitialized { - explicit ConstantInitialized() = default; -}; - // See parse_context.h for explanation class ParseContext; @@ -130,8 +125,9 @@ inline int ToIntSize(size_t size) { } // Default empty string object. Don't use this directly. Instead, call -// GetEmptyString() to get the reference. -PROTOBUF_EXPORT extern ExplicitlyConstructed<std::string> +// GetEmptyString() to get the reference. This empty string is aligned with a +// minimum alignment of 8 bytes to match the requirement of ArenaStringPtr. +PROTOBUF_EXPORT extern ExplicitlyConstructedArenaString fixed_address_empty_string; @@ -187,14 +183,13 @@ class PROTOBUF_EXPORT MessageLite { // if arena is a nullptr. virtual MessageLite* New(Arena* arena) const = 0; - // Same as GetOwningArena. - Arena* GetArena() const { return GetOwningArena(); } + // Returns user-owned arena; nullptr if it's message owned. + Arena* GetArena() const { return _internal_metadata_.user_arena(); } // Clear all fields of the message and set them to their default values. - // Clear() avoids freeing memory, assuming that any memory allocated - // to hold parts of the message will be needed again to hold the next - // message. If you actually want to free the memory used by a Message, - // you must delete it. + // Clear() assumes that any memory allocated to hold parts of the message + // will likely be needed again, so the memory used may not be freed. + // To ensure that all memory used by a Message is freed, you must delete it. virtual void Clear() = 0; // Quickly check if all required fields have values set. @@ -422,6 +417,8 @@ class PROTOBUF_EXPORT MessageLite { return nullptr; } + virtual void OnDemandRegisterArenaDtor(Arena* /*arena*/) {} + protected: template <typename T> static T* CreateMaybeMessage(Arena* arena) { @@ -442,6 +439,10 @@ class PROTOBUF_EXPORT MessageLite { // messages, etc), or owning incoming objects (e.g., set allocated). Arena* GetArenaForAllocation() const { return _internal_metadata_.arena(); } + // Returns true if this message is enabled for message-owned arena (MOA) + // trials. No lite messages are eligible for MOA. + static bool InMoaTrial() { return false; } + internal::InternalMetadata _internal_metadata_; public: @@ -472,9 +473,6 @@ class PROTOBUF_EXPORT MessageLite { } private: - // TODO(gerbens) make this a pure abstract function - virtual const void* InternalGetTable() const { return nullptr; } - friend class FastReflectionMessageMutator; friend class FastReflectionStringSetter; friend class Message; diff --git a/r5dev/thirdparty/protobuf/message_unittest.inc b/r5dev/thirdparty/protobuf/message_unittest.inc index 96acb536..663d01ea 100644 --- a/r5dev/thirdparty/protobuf/message_unittest.inc +++ b/r5dev/thirdparty/protobuf/message_unittest.inc @@ -51,20 +51,20 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/test_util2.h> -#include <thirdparty/protobuf/io/coded_stream.h> -#include <thirdparty/protobuf/io/zero_copy_stream.h> -#include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/descriptor.pb.h> -#include <thirdparty/protobuf/arena.h> -#include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/generated_message_reflection.h> #include <gmock/gmock.h> #include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/arena.h> +#include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/io/io_win32.h> +#include <thirdparty/protobuf/generated_message_reflection.h> +#include <thirdparty/protobuf/io/coded_stream.h> +#include <thirdparty/protobuf/io/zero_copy_stream.h> +#include <thirdparty/protobuf/io/zero_copy_stream_impl.h> +#include <thirdparty/protobuf/test_util2.h> namespace google { @@ -264,6 +264,79 @@ TEST(MESSAGE_TEST_NAME, ParseFailsIfExtensionNotInitialized) { UNITTEST_PACKAGE_NAME))); } +TEST(MESSAGE_TEST_NAME, MergeFromUninitialized) { + UNITTEST::TestNestedRequiredForeign o, p, q; + UNITTEST::TestNestedRequiredForeign* child = o.mutable_child(); + constexpr int kDepth = 2; + for (int i = 0; i < kDepth; i++) { + child->set_dummy(i); + child = child->mutable_child(); + } + UNITTEST::TestRequiredForeign* payload = child->mutable_payload(); + payload->mutable_optional_message()->set_a(1); + payload->mutable_optional_message()->set_dummy2(100); + payload->mutable_optional_message()->set_dummy4(200); + ASSERT_TRUE(p.ParsePartialFromString(o.SerializePartialAsString())); + + q.mutable_child()->set_dummy(500); + q = p; + q.ParsePartialFromString(q.SerializePartialAsString()); + EXPECT_TRUE(TestUtil::EqualsToSerialized(q, o.SerializePartialAsString())); + EXPECT_TRUE(TestUtil::EqualsToSerialized(q, p.SerializePartialAsString())); +} + +TEST(MESSAGE_TEST_NAME, ExplicitLazyExceedRecursionLimit) { + UNITTEST::NestedTestAllTypes original, parsed; + // Build proto with recursion depth of 3. + original.mutable_lazy_child() + ->mutable_child() + ->mutable_payload() + ->set_optional_int32(-1); + std::string serialized; + EXPECT_TRUE(original.SerializeToString(&serialized)); + + // User annotated LazyField ([lazy = true]) is eagerly verified and should + // catch the recursion limit violation. + io::ArrayInputStream array_stream(serialized.data(), serialized.size()); + io::CodedInputStream input_stream(&array_stream); + input_stream.SetRecursionLimit(2); + EXPECT_FALSE(parsed.ParseFromCodedStream(&input_stream)); + + // Lazy read results in parsing error which can be verified by not having + // expected value. + EXPECT_NE(parsed.lazy_child().child().payload().optional_int32(), -1); +} + +TEST(MESSAGE_TEST_NAME, NestedExplicitLazyExceedRecursionLimit) { + UNITTEST::NestedTestAllTypes original, parsed; + // Build proto with recursion depth of 5, with nested annotated LazyField. + original.mutable_lazy_child() + ->mutable_child() + ->mutable_lazy_child() + ->mutable_child() + ->mutable_payload() + ->set_optional_int32(-1); + std::string serialized; + EXPECT_TRUE(original.SerializeToString(&serialized)); + + // User annotated LazyField ([lazy = true]) is eagerly verified and should + // catch the recursion limit violation. + io::ArrayInputStream array_stream(serialized.data(), serialized.size()); + io::CodedInputStream input_stream(&array_stream); + input_stream.SetRecursionLimit(4); + EXPECT_FALSE(parsed.ParseFromCodedStream(&input_stream)); + + // Lazy read results in parsing error which can be verified by not having + // expected value. + EXPECT_NE(parsed.lazy_child() + .child() + .lazy_child() + .child() + .payload() + .optional_int32(), + -1); +} + TEST(MESSAGE_TEST_NAME, ParseFailsIfSubmessageTruncated) { UNITTEST::NestedTestAllTypes o, p; constexpr int kDepth = 5; @@ -349,6 +422,165 @@ TEST(MESSAGE_TEST_NAME, ParseFailsIfExtensionWireMalformed) { EXPECT_FALSE(p.ParseFromString(serialized)); } +TEST(MESSAGE_TEST_NAME, UninitializedAndMalformed) { + UNITTEST::TestRequiredForeign o, p1, p2; + o.mutable_optional_message()->set_a(-1); + + // -1 becomes \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x1 + std::string serialized; + EXPECT_TRUE(o.SerializePartialToString(&serialized)); + + // Should parse correctly. + EXPECT_TRUE(p1.ParsePartialFromString(serialized)); + EXPECT_FALSE(p1.IsInitialized()); + + // Overwriting the last byte to 0xFF results in malformed wire. + serialized[serialized.size() - 1] = 0xFF; + EXPECT_FALSE(p2.ParseFromString(serialized)); + EXPECT_FALSE(p2.IsInitialized()); +} + +inline UNITTEST::NestedTestAllTypes InitNestedProto(int depth) { + UNITTEST::NestedTestAllTypes p; + auto* child = p.mutable_child(); + for (int i = 0; i < depth; i++) { + child->mutable_payload()->set_optional_int32(i); + child = child->mutable_child(); + } + // -1 becomes \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x1 + child->mutable_payload()->set_optional_int32(-1); + return p; +} + +// Parsing proto must not access beyond the bound. +TEST(MESSAGE_TEST_NAME, ParseStrictlyBoundedStream) { + UNITTEST::NestedTestAllTypes o, p; + constexpr int kDepth = 2; + o = InitNestedProto(kDepth); + TestUtil::SetAllFields(o.mutable_child()->mutable_payload()); + o.mutable_child()->mutable_child()->mutable_payload()->set_optional_string( + std::string(1024, 'a')); + + std::string data; + EXPECT_TRUE(o.SerializeToString(&data)); + + TestUtil::BoundedArrayInputStream stream(data.data(), data.size()); + EXPECT_TRUE(p.ParseFromBoundedZeroCopyStream(&stream, data.size())); + TestUtil::ExpectAllFieldsSet(p.child().payload()); +} + +TEST(MESSAGE_TEST_NAME, AllSetMethodsOnStringField) { + UNITTEST::TestAllTypes msg; + + + msg.set_optional_string("Asciiz"); + EXPECT_EQ(msg.optional_string(), "Asciiz"); + + msg.set_optional_string("Length delimited", 6); + EXPECT_EQ(msg.optional_string(), "Length"); + + std::string value = "std::string value 1"; + msg.set_optional_string(value); + EXPECT_EQ(msg.optional_string(), "std::string value 1"); + + value = "std::string value 2"; + msg.set_optional_string(std::cref(value)); + EXPECT_EQ(msg.optional_string(), "std::string value 2"); + + value = "std::string value 3"; + msg.set_optional_string(std::move(value)); + EXPECT_EQ(msg.optional_string(), "std::string value 3"); +} + +TEST(MESSAGE_TEST_NAME, SuccessAfterParsingFailure) { + UNITTEST::NestedTestAllTypes o, p, q; + constexpr int kDepth = 5; + o = InitNestedProto(kDepth); + std::string serialized; + EXPECT_TRUE(o.SerializeToString(&serialized)); + + // Should parse correctly. + EXPECT_TRUE(p.ParseFromString(serialized)); + + // Overwriting the last byte to 0xFF results in malformed wire. + serialized[serialized.size() - 1] = 0xFF; + EXPECT_FALSE(p.ParseFromString(serialized)); + + // Subsequent serialization should be parsed correctly. + EXPECT_TRUE(q.ParseFromString(p.SerializeAsString())); +} + +TEST(MESSAGE_TEST_NAME, ExceedRecursionLimit) { + UNITTEST::NestedTestAllTypes o, p; + const int kDepth = io::CodedInputStream::GetDefaultRecursionLimit() + 10; + o = InitNestedProto(kDepth); + std::string serialized; + EXPECT_TRUE(o.SerializeToString(&serialized)); + + // Recursion level deeper than the default. + EXPECT_FALSE(p.ParseFromString(serialized)); +} + +TEST(MESSAGE_TEST_NAME, SupportCustomRecursionLimitRead) { + UNITTEST::NestedTestAllTypes o, p; + const int kDepth = io::CodedInputStream::GetDefaultRecursionLimit() + 10; + o = InitNestedProto(kDepth); + std::string serialized; + EXPECT_TRUE(o.SerializeToString(&serialized)); + + // Should pass with custom limit + reads. + io::ArrayInputStream raw_input(serialized.data(), serialized.size()); + io::CodedInputStream input(&raw_input); + input.SetRecursionLimit(kDepth + 10); + EXPECT_TRUE(p.ParseFromCodedStream(&input)); + + EXPECT_EQ(p.child().payload().optional_int32(), 0); + EXPECT_EQ(p.child().child().payload().optional_int32(), 1); + + // Verify p serializes successfully (survives VerifyConsistency). + std::string result; + EXPECT_TRUE(p.SerializeToString(&result)); +} + +TEST(MESSAGE_TEST_NAME, SupportCustomRecursionLimitWrite) { + UNITTEST::NestedTestAllTypes o, p; + const int kDepth = io::CodedInputStream::GetDefaultRecursionLimit() + 10; + o = InitNestedProto(kDepth); + std::string serialized; + EXPECT_TRUE(o.SerializeToString(&serialized)); + + // Should pass with custom limit + writes. + io::ArrayInputStream raw_input(serialized.data(), serialized.size()); + io::CodedInputStream input(&raw_input); + input.SetRecursionLimit(kDepth + 10); + EXPECT_TRUE(p.ParseFromCodedStream(&input)); + + EXPECT_EQ(p.mutable_child()->mutable_payload()->optional_int32(), 0); + EXPECT_EQ( + p.mutable_child()->mutable_child()->mutable_payload()->optional_int32(), + 1); +} + +// While deep recursion is never guaranteed, this test aims to catch potential +// issues with very deep recursion. +TEST(MESSAGE_TEST_NAME, SupportDeepRecursionLimit) { + UNITTEST::NestedTestAllTypes o, p; + constexpr int kDepth = 1000; + auto* child = o.mutable_child(); + for (int i = 0; i < kDepth; i++) { + child = child->mutable_child(); + } + child->mutable_payload()->set_optional_int32(100); + + std::string serialized; + EXPECT_TRUE(o.SerializeToString(&serialized)); + + io::ArrayInputStream raw_input(serialized.data(), serialized.size()); + io::CodedInputStream input(&raw_input); + input.SetRecursionLimit(1100); + EXPECT_TRUE(p.ParseFromCodedStream(&input)); +} + TEST(MESSAGE_TEST_NAME, Swap) { UNITTEST::NestedTestAllTypes o; constexpr int kDepth = 5; @@ -485,7 +717,7 @@ class RepeatedInputStream : public io::ZeroCopyInputStream { std::string data_; size_t count_; // The number of strings that haven't been consumed. size_t position_; // Position in the std::string for the next read. - int64 total_byte_count_; + int64_t total_byte_count_; }; } // namespace @@ -513,6 +745,8 @@ TEST(MESSAGE_TEST_NAME, TestParseMessagesCloseTo2G) { } TEST(MESSAGE_TEST_NAME, TestParseMessagesOver2G) { + constexpr int32_t kint32max = std::numeric_limits<int32_t>::max(); + // Create a message with a large std::string field. std::string value = std::string(64 * 1024 * 1024, 'x'); UNITTEST::TestAllTypes message; diff --git a/r5dev/thirdparty/protobuf/metadata_lite.h b/r5dev/thirdparty/protobuf/metadata_lite.h index b08eab1c..79d9e83f 100644 --- a/r5dev/thirdparty/protobuf/metadata_lite.h +++ b/r5dev/thirdparty/protobuf/metadata_lite.h @@ -36,6 +36,7 @@ #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/port.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG @@ -59,20 +60,32 @@ namespace internal { // It uses bit 0 == 0 to indicate an arena pointer and bit 0 == 1 to indicate a // UFS+Arena-container pointer. Besides it uses bit 1 == 0 to indicate arena // allocation and bit 1 == 1 to indicate heap allocation. -class InternalMetadata { +class PROTOBUF_EXPORT InternalMetadata { public: constexpr InternalMetadata() : ptr_(0) {} - explicit InternalMetadata(Arena* arena, bool is_message_owned = false) - : ptr_(is_message_owned - ? reinterpret_cast<intptr_t>(arena) | kMessageOwnedArenaTagMask - : reinterpret_cast<intptr_t>(arena)) { + explicit InternalMetadata(Arena* arena, bool is_message_owned = false) { + SetArena(arena, is_message_owned); + } + + void SetArena(Arena* arena, bool is_message_owned) { + ptr_ = is_message_owned + ? reinterpret_cast<intptr_t>(arena) | kMessageOwnedArenaTagMask + : reinterpret_cast<intptr_t>(arena); GOOGLE_DCHECK(!is_message_owned || arena != nullptr); } + // To keep the ABI identical between debug and non-debug builds, + // the destructor is always defined here even though it may delegate + // to a non-inline private method. + // (see https://github.com/protocolbuffers/protobuf/issues/9947) ~InternalMetadata() { +#if defined(NDEBUG) || defined(_MSC_VER) if (HasMessageOwnedArenaTag()) { - delete arena(); + delete reinterpret_cast<Arena*>(ptr_ - kMessageOwnedArenaTagMask); } +#else + CheckedDestruct(); +#endif } template <typename T> @@ -83,10 +96,31 @@ class InternalMetadata { } } + // DeleteReturnArena will delete the unknown fields only if they weren't + // allocated on an arena. Then it updates the flags so that if you call + // have_unknown_fields(), it will return false. Finally, it returns the + // current value of arena(). It is designed to be used as part of a + // Message class's destructor call, so that when control eventually gets + // to ~InternalMetadata(), we don't need to check for have_unknown_fields() + // again. + template <typename T> + Arena* DeleteReturnArena() { + if (have_unknown_fields()) { + return DeleteOutOfLineHelper<T>(); + } else { + return PtrValue<Arena>(); + } + } + PROTOBUF_NDEBUG_INLINE Arena* owning_arena() const { return HasMessageOwnedArenaTag() ? nullptr : arena(); } + PROTOBUF_NDEBUG_INLINE Arena* user_arena() const { + Arena* a = arena(); + return a && !a->IsMessageOwned() ? a : nullptr; + } + PROTOBUF_NDEBUG_INLINE Arena* arena() const { if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) { return PtrValue<ContainerBase>()->arena; @@ -187,9 +221,18 @@ class InternalMetadata { }; template <typename T> - PROTOBUF_NOINLINE void DeleteOutOfLineHelper() { - if (arena() == nullptr) { + PROTOBUF_NOINLINE Arena* DeleteOutOfLineHelper() { + if (auto* a = arena()) { + // Subtle: we want to preserve the message-owned arena flag, while at the + // same time replacing the pointer to Container<T> with a pointer to the + // arena. + intptr_t message_owned_arena_tag = ptr_ & kMessageOwnedArenaTagMask; + ptr_ = reinterpret_cast<intptr_t>(a) | message_owned_arena_tag; + return a; + } else { delete PtrValue<Container<T>>(); + ptr_ = 0; + return nullptr; } } @@ -222,6 +265,9 @@ class InternalMetadata { PROTOBUF_NOINLINE void DoSwap(T* other) { mutable_unknown_fields<T>()->Swap(other); } + + // Private helper with debug checks for ~InternalMetadata() + void CheckedDestruct(); }; // String Template specializations. diff --git a/r5dev/thirdparty/protobuf/parse_context.cc b/r5dev/thirdparty/protobuf/parse_context.cc index 16175984..94a4ce58 100644 --- a/r5dev/thirdparty/protobuf/parse_context.cc +++ b/r5dev/thirdparty/protobuf/parse_context.cc @@ -30,15 +30,16 @@ #include <thirdparty/protobuf/parse_context.h> -#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/arenastring.h> +#include <thirdparty/protobuf/endian.h> #include <thirdparty/protobuf/message_lite.h> #include <thirdparty/protobuf/repeated_field.h> -#include <thirdparty/protobuf/wire_format_lite.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/wire_format_lite.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -50,8 +51,8 @@ namespace { // Only call if at start of tag. bool ParseEndsInSlopRegion(const char* begin, int overrun, int depth) { constexpr int kSlopBytes = EpsCopyInputStream::kSlopBytes; - GOOGLE_DCHECK(overrun >= 0); - GOOGLE_DCHECK(overrun <= kSlopBytes); + GOOGLE_DCHECK_GE(overrun, 0); + GOOGLE_DCHECK_LE(overrun, kSlopBytes); auto ptr = begin + overrun; auto end = begin + kSlopBytes; while (ptr < end) { @@ -180,17 +181,17 @@ std::pair<const char*, bool> EpsCopyInputStream::DoneFallback(int overrun, // if (ptr < limit_end_) return {ptr, false}; GOOGLE_DCHECK(limit_end_ == buffer_end_ + (std::min)(0, limit_)); // At this point we know the following assertion holds. - GOOGLE_DCHECK(limit_ > 0); + GOOGLE_DCHECK_GT(limit_, 0); GOOGLE_DCHECK(limit_end_ == buffer_end_); // because limit_ > 0 const char* p; do { // We are past the end of buffer_end_, in the slop region. - GOOGLE_DCHECK(overrun >= 0); + GOOGLE_DCHECK_GE(overrun, 0); p = NextBuffer(overrun, depth); if (p == nullptr) { // We are at the end of the stream if (PROTOBUF_PREDICT_FALSE(overrun != 0)) return {nullptr, true}; - GOOGLE_DCHECK(limit_ > 0); + GOOGLE_DCHECK_GT(limit_, 0); limit_end_ = buffer_end_; // Distinguish ending on a pushed limit or ending on end-of-stream. SetEndOfStream(); @@ -234,19 +235,6 @@ const char* EpsCopyInputStream::AppendStringFallback(const char* ptr, int size, } -template <int> -void byteswap(void* p); -template <> -void byteswap<1>(void* /*p*/) {} -template <> -void byteswap<4>(void* p) { - *static_cast<uint32_t*>(p) = bswap_32(*static_cast<uint32_t*>(p)); -} -template <> -void byteswap<8>(void* p) { - *static_cast<uint64_t*>(p) = bswap_64(*static_cast<uint64_t*>(p)); -} - const char* EpsCopyInputStream::InitFrom(io::ZeroCopyInputStream* zcis) { zcis_ = zcis; const void* data; @@ -388,12 +376,13 @@ const char* StringParser(const char* begin, const char* end, void* object, } // Defined in wire_format_lite.cc -void PrintUTF8ErrorLog(const char* field_name, const char* operation_str, +void PrintUTF8ErrorLog(StringPiece message_name, + StringPiece field_name, const char* operation_str, bool emit_stacktrace); bool VerifyUTF8(StringPiece str, const char* field_name) { if (!IsStructurallyValidUTF8(str)) { - PrintUTF8ErrorLog(field_name, "parsing", false); + PrintUTF8ErrorLog("", field_name, "parsing", false); return false; } return true; diff --git a/r5dev/thirdparty/protobuf/parse_context.h b/r5dev/thirdparty/protobuf/parse_context.h index 91e7f1ed..aa60e97a 100644 --- a/r5dev/thirdparty/protobuf/parse_context.h +++ b/r5dev/thirdparty/protobuf/parse_context.h @@ -34,19 +34,22 @@ #include <cstdint> #include <cstring> #include <string> +#include <type_traits> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/arena.h> +#include <thirdparty/protobuf/port.h> +#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/arenastring.h> +#include <thirdparty/protobuf/endian.h> #include <thirdparty/protobuf/implicit_weak_message.h> #include <thirdparty/protobuf/inlined_string_field.h> #include <thirdparty/protobuf/metadata_lite.h> -#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/repeated_field.h> #include <thirdparty/protobuf/wire_format_lite.h> -#include <thirdparty/protobuf/stubs/strutil.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> @@ -197,6 +200,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { return ptr > limit_end_ && (next_chunk_ == nullptr || ptr - buffer_end_ > limit_); } + bool AliasingEnabled() const { return aliasing_ != kNoAliasing; } int BytesUntilLimit(const char* ptr) const { return limit_ + static_cast<int>(buffer_end_ - ptr); } @@ -370,6 +374,10 @@ class PROTOBUF_EXPORT EpsCopyInputStream { friend class ImplicitWeakMessage; }; +using LazyEagerVerifyFnType = const char* (*)(const char* ptr, + ParseContext* ctx); +using LazyEagerVerifyFnRef = std::remove_pointer<LazyEagerVerifyFnType>::type&; + // ParseContext holds all data that is global to the entire parse. Most // importantly it contains the input stream, but also recursion depth and also // stores the end group tag, in case a parser ended on a endgroup, to verify @@ -399,6 +407,18 @@ class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream { const char* ParseMessage(MessageLite* msg, const char* ptr); + // Spawns a child parsing context that inherits key properties. New context + // inherits the following: + // --depth_, data_, check_required_fields_, lazy_parse_mode_ + // The spawned context always disables aliasing (different input). + template <typename... T> + ParseContext Spawn(const char** start, T&&... args) { + ParseContext spawned(depth_, false, start, std::forward<T>(args)...); + // Transfer key context states. + spawned.data_ = data_; + return spawned; + } + // This overload supports those few cases where ParseMessage is called // on a class that is not actually a proto message. // TODO(jorg): Eliminate this use case. @@ -467,10 +487,7 @@ struct EndianHelper<2> { static uint16_t Load(const void* p) { uint16_t tmp; std::memcpy(&tmp, p, 2); -#ifndef PROTOBUF_LITTLE_ENDIAN - tmp = bswap_16(tmp); -#endif - return tmp; + return little_endian::ToHost(tmp); } }; @@ -479,10 +496,7 @@ struct EndianHelper<4> { static uint32_t Load(const void* p) { uint32_t tmp; std::memcpy(&tmp, p, 4); -#ifndef PROTOBUF_LITTLE_ENDIAN - tmp = bswap_32(tmp); -#endif - return tmp; + return little_endian::ToHost(tmp); } }; @@ -491,10 +505,7 @@ struct EndianHelper<8> { static uint64_t Load(const void* p) { uint64_t tmp; std::memcpy(&tmp, p, 8); -#ifndef PROTOBUF_LITTLE_ENDIAN - tmp = bswap_64(tmp); -#endif - return tmp; + return little_endian::ToHost(tmp); } }; @@ -565,20 +576,96 @@ inline const char* ReadTag(const char* p, uint32_t* out, return tmp.first; } +// As above, but optimized to consume very few registers while still being fast, +// ReadTagInlined is useful for callers that don't mind the extra code but would +// like to avoid an extern function call causing spills into the stack. +// +// Two support routines for ReadTagInlined come first... +template <class T> +PROTOBUF_NODISCARD PROTOBUF_ALWAYS_INLINE constexpr T RotateLeft( + T x, int s) noexcept { + return static_cast<T>(x << (s & (std::numeric_limits<T>::digits - 1))) | + static_cast<T>(x >> ((-s) & (std::numeric_limits<T>::digits - 1))); +} + +PROTOBUF_NODISCARD inline PROTOBUF_ALWAYS_INLINE uint64_t +RotRight7AndReplaceLowByte(uint64_t res, const char& byte) { +#if defined(__x86_64__) && defined(__GNUC__) + // This will only use one register for `res`. + // `byte` comes as a reference to allow the compiler to generate code like: + // + // rorq $7, %rcx + // movb 1(%rax), %cl + // + // which avoids loading the incoming bytes into a separate register first. + asm("ror $7,%0\n\t" + "movb %1,%b0" + : "+r"(res) + : "m"(byte)); +#else + res = RotateLeft(res, -7); + res = res & ~0xFF; + res |= 0xFF & byte; +#endif + return res; +}; + +inline PROTOBUF_ALWAYS_INLINE +const char* ReadTagInlined(const char* ptr, uint32_t* out) { + uint64_t res = 0xFF & ptr[0]; + if (PROTOBUF_PREDICT_FALSE(res >= 128)) { + res = RotRight7AndReplaceLowByte(res, ptr[1]); + if (PROTOBUF_PREDICT_FALSE(res & 0x80)) { + res = RotRight7AndReplaceLowByte(res, ptr[2]); + if (PROTOBUF_PREDICT_FALSE(res & 0x80)) { + res = RotRight7AndReplaceLowByte(res, ptr[3]); + if (PROTOBUF_PREDICT_FALSE(res & 0x80)) { + // Note: this wouldn't work if res were 32-bit, + // because then replacing the low byte would overwrite + // the bottom 4 bits of the result. + res = RotRight7AndReplaceLowByte(res, ptr[4]); + if (PROTOBUF_PREDICT_FALSE(res & 0x80)) { + // The proto format does not permit longer than 5-byte encodings for + // tags. + *out = 0; + return nullptr; + } + *out = static_cast<uint32_t>(RotateLeft(res, 28)); +#if defined(__GNUC__) + // Note: this asm statement prevents the compiler from + // trying to share the "return ptr + constant" among all + // branches. + asm("" : "+r"(ptr)); +#endif + return ptr + 5; + } + *out = static_cast<uint32_t>(RotateLeft(res, 21)); + return ptr + 4; + } + *out = static_cast<uint32_t>(RotateLeft(res, 14)); + return ptr + 3; + } + *out = static_cast<uint32_t>(RotateLeft(res, 7)); + return ptr + 2; + } + *out = static_cast<uint32_t>(res); + return ptr + 1; +} + // Decode 2 consecutive bytes of a varint and returns the value, shifted left // by 1. It simultaneous updates *ptr to *ptr + 1 or *ptr + 2 depending if the // first byte's continuation bit is set. // If bit 15 of return value is set (equivalent to the continuation bits of both // bytes being set) the varint continues, otherwise the parse is done. On x86 // movsx eax, dil -// add edi, eax +// and edi, eax +// add eax, edi // adc [rsi], 1 -// add eax, eax -// and eax, edi inline uint32_t DecodeTwoBytes(const char** ptr) { uint32_t value = UnalignedLoad<uint16_t>(*ptr); // Sign extend the low byte continuation bit uint32_t x = static_cast<int8_t>(value); + value &= x; // Mask out the high byte iff no continuation // This add is an amazing operation, it cancels the low byte continuation bit // from y transferring it to the carry. Simultaneously it also shifts the 7 // LSB left by one tightly against high byte varint bits. Hence value now @@ -586,7 +673,7 @@ inline uint32_t DecodeTwoBytes(const char** ptr) { value += x; // Use the carry to update the ptr appropriately. *ptr += value < x ? 2 : 1; - return value & (x + x); // Mask out the high byte iff no continuation + return value; } // More efficient varint parsing for big varints @@ -787,7 +874,7 @@ inline bool VerifyUTF8(const std::string* s, const char* field_name) { } // All the string parsers with or without UTF checking and for all CTypes. -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* InlineGreedyStringParser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* InlineGreedyStringParser( std::string* s, const char* ptr, ParseContext* ctx); @@ -859,19 +946,19 @@ PROTOBUF_NODISCARD const char* WireFormatParser(T& field_parser, // corresponding field // These are packed varints -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedInt32Parser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedInt32Parser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedUInt32Parser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedUInt32Parser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedInt64Parser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedInt64Parser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedUInt64Parser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedUInt64Parser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedSInt32Parser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedSInt32Parser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedSInt64Parser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedSInt64Parser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedEnumParser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedEnumParser( void* object, const char* ptr, ParseContext* ctx); template <typename T> @@ -905,28 +992,28 @@ PROTOBUF_NODISCARD const char* PackedEnumParserArg( }); } -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedBoolParser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedBoolParser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedFixed32Parser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedFixed32Parser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedSFixed32Parser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedSFixed32Parser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedFixed64Parser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedFixed64Parser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedSFixed64Parser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedSFixed64Parser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedFloatParser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedFloatParser( void* object, const char* ptr, ParseContext* ctx); -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* PackedDoubleParser( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedDoubleParser( void* object, const char* ptr, ParseContext* ctx); // This is the only recursive parser. -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* UnknownGroupLiteParse( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* UnknownGroupLiteParse( std::string* unknown, const char* ptr, ParseContext* ctx); // This is a helper to for the UnknownGroupLiteParse but is actually also // useful in the generated code. It uses overload on std::string* vs // UnknownFieldSet* to make the generated code isomorphic between full and lite. -PROTOBUF_EXPORT PROTOBUF_NODISCARD const char* UnknownFieldParse( +PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* UnknownFieldParse( uint32_t tag, std::string* unknown, const char* ptr, ParseContext* ctx); } // namespace internal diff --git a/r5dev/thirdparty/protobuf/port.h b/r5dev/thirdparty/protobuf/port.h index 4c09eb1d..a5c060b6 100644 --- a/r5dev/thirdparty/protobuf/port.h +++ b/r5dev/thirdparty/protobuf/port.h @@ -36,5 +36,45 @@ #ifndef GOOGLE_PROTOBUF_PORT_H__ #define GOOGLE_PROTOBUF_PORT_H__ +#include <cstddef> +#include <new> + + +namespace google { +namespace protobuf { +namespace internal { +inline void SizedDelete(void* p, size_t size) { +#if defined(__cpp_sized_deallocation) + ::operator delete(p, size); +#else + ::operator delete(p); +#endif +} +inline void SizedArrayDelete(void* p, size_t size) { +#if defined(__cpp_sized_deallocation) + ::operator delete[](p, size); +#else + ::operator delete[](p); +#endif +} + +// Tag type used to invoke the constinit constructor overload of classes +// such as ArenaStringPtr and MapFieldBase. Such constructors are internal +// implementation details of the library. +struct ConstantInitialized { + explicit ConstantInitialized() = default; +}; + +// Tag type used to invoke the arena constructor overload of classes such +// as ExtensionSet and MapFieldLite in aggregate initialization. These +// classes typically don't have move/copy constructors, which rules out +// explicit initialization in pre-C++17. +struct ArenaInitialized { + explicit ArenaInitialized() = default; +}; + +} // namespace internal +} // namespace protobuf +} // namespace google #endif // GOOGLE_PROTOBUF_PORT_H__ diff --git a/r5dev/thirdparty/protobuf/port_def.inc b/r5dev/thirdparty/protobuf/port_def.inc index 37632cf5..6c6aa183 100644 --- a/r5dev/thirdparty/protobuf/port_def.inc +++ b/r5dev/thirdparty/protobuf/port_def.inc @@ -118,6 +118,27 @@ #define PROTOBUF_has_builtin_DEFINED_ #endif +// Portable PROTOBUF_BUILTIN_BSWAPxx definitions +// Code must check for availability, e.g.: `defined(PROTOBUF_BUILTIN_BSWAP32)` +#ifdef PROTOBUF_BUILTIN_BSWAP16 +#error PROTOBUF_BUILTIN_BSWAP16 was previously defined +#endif +#ifdef PROTOBUF_BUILTIN_BSWAP32 +#error PROTOBUF_BUILTIN_BSWAP32 was previously defined +#endif +#ifdef PROTOBUF_BUILTIN_BSWAP64 +#error PROTOBUF_BUILTIN_BSWAP64 was previously defined +#endif +#if defined(__GNUC__) || __has_builtin(__builtin_bswap16) +#define PROTOBUF_BUILTIN_BSWAP16(x) __builtin_bswap16(x) +#endif +#if defined(__GNUC__) || __has_builtin(__builtin_bswap32) +#define PROTOBUF_BUILTIN_BSWAP32(x) __builtin_bswap32(x) +#endif +#if defined(__GNUC__) || __has_builtin(__builtin_bswap64) +#define PROTOBUF_BUILTIN_BSWAP64(x) __builtin_bswap64(x) +#endif + // Portable check for GCC minimum version: // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html #if defined(__GNUC__) && defined(__GNUC_MINOR__) \ @@ -148,22 +169,26 @@ // Future versions of protobuf will include breaking changes to some APIs. // This macro can be set to enable these API changes ahead of time, so that // user code can be updated before upgrading versions of protobuf. +// PROTOBUF_FUTURE_FINAL is used on classes that are historically not marked as +// final, but that may be marked final in future (breaking) releases. // #define PROTOBUF_FUTURE_BREAKING_CHANGES 1 +// #define PROTOBUF_FUTURE_FINAL final +#define PROTOBUF_FUTURE_FINAL #ifdef PROTOBUF_VERSION #error PROTOBUF_VERSION was previously defined #endif -#define PROTOBUF_VERSION 3019004 +#define PROTOBUF_VERSION 3021012 #ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC #error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined #endif -#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3019000 +#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3021000 #ifdef PROTOBUF_MIN_PROTOC_VERSION #error PROTOBUF_MIN_PROTOC_VERSION was previously defined #endif -#define PROTOBUF_MIN_PROTOC_VERSION 3019000 +#define PROTOBUF_MIN_PROTOC_VERSION 3021000 #ifdef PROTOBUF_VERSION_SUFFIX #error PROTOBUF_VERSION_SUFFIX was previously defined @@ -229,11 +254,15 @@ #ifdef PROTOBUF_TAILCALL #error PROTOBUF_TAILCALL was previously defined #endif -#if __has_cpp_attribute(clang::musttail) && \ - !defined(__arm__) && !defined(_ARCH_PPC) && !defined(__wasm__) +#if __has_cpp_attribute(clang::musttail) && !defined(__arm__) && \ + !defined(_ARCH_PPC) && !defined(__wasm__) && \ + !(defined(_MSC_VER) && defined(_M_IX86)) && \ + !(defined(__NDK_MAJOR__) && __NDK_MAJOR <= 24) # ifndef PROTO2_OPENSOURCE // Compilation fails on ARM32: b/195943306 // Compilation fails on powerpc64le: b/187985113 +// Compilation fails on X86 Windows: +// https://github.com/llvm/llvm-project/issues/53271 # endif #define PROTOBUF_MUSTTAIL [[clang::musttail]] #define PROTOBUF_TAILCALL true @@ -356,17 +385,25 @@ // The minimum library version which works with the current version of the // headers. -#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3019000 +#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3021000 #ifdef PROTOBUF_RTTI #error PROTOBUF_RTTI was previously defined #endif #if defined(GOOGLE_PROTOBUF_NO_RTTI) && GOOGLE_PROTOBUF_NO_RTTI +// A user-provided definition GOOGLE_PROTOBUF_NO_RTTI=1 disables RTTI. #define PROTOBUF_RTTI 0 -#elif __has_feature(cxx_rtti) +#elif defined(__cpp_rtti) +// https://en.cppreference.com/w/cpp/feature_test #define PROTOBUF_RTTI 1 -#elif defined(__cxx_rtti) -// https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros#C.2B.2B98 +#elif __has_feature(cxx_rtti) +// https://clang.llvm.org/docs/LanguageExtensions.html#c-rtti +#define PROTOBUF_RTTI 1 +#elif defined(__GXX_RTTI) +// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html +#define PROTOBUF_RTTI 1 +#elif defined(_CPPRTTI) +// https://docs.microsoft.com/en-us/cpp/build/reference/gr-enable-run-time-type-information #define PROTOBUF_RTTI 1 #else #define PROTOBUF_RTTI 0 @@ -439,7 +476,7 @@ # else # define PROTOC_EXPORT __declspec(dllimport) # endif // defined(LIBPROTOC_EXPORTS) -#elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOBUF_EXPORTS) +#elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOC_EXPORTS) # define PROTOC_EXPORT __attribute__((visibility("default"))) #else # define PROTOC_EXPORT @@ -459,7 +496,7 @@ #ifdef PROTOBUF_NODISCARD #error PROTOBUF_NODISCARD was previously defined #endif -#if __has_cpp_attribute(nodiscard) +#if __has_cpp_attribute(nodiscard) && PROTOBUF_CPLUSPLUS_MIN(201703L) #define PROTOBUF_NODISCARD [[nodiscard]] #elif __has_attribute(warn_unused_result) || PROTOBUF_GNUC_MIN(4, 8) #define PROTOBUF_NODISCARD __attribute__((warn_unused_result)) @@ -467,6 +504,13 @@ #define PROTOBUF_NODISCARD #endif +// Enable all stable experiments if this flag is set. This allows us to group +// all of these experiments under a single build flag, which can be enabled in +// the protobuf.stable-experiments TAP project. +#ifdef PROTOBUF_ENABLE_STABLE_EXPERIMENTS +#define PROTOBUF_FORCE_MESSAGE_OWNED_ARENA +#endif // !PROTOBUF_ENABLE_STABLE_EXPERIMENTS + #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE #error PROTOBUF_FORCE_COPY_IN_RELEASE was previously defined #endif @@ -479,6 +523,10 @@ #error PROTOBUF_FORCE_COPY_IN_MOVE was previously defined #endif +#ifdef PROTOBUF_FORCE_RESET_IN_CLEAR +#error PROTOBUF_FORCE_RESET_IN_CLEAR was previously defined +#endif + // Force copy the default string to a string field so that non-optimized builds // have harder-to-rely-on address stability. #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING @@ -560,6 +608,22 @@ #define PROTOBUF_THREAD_LOCAL __thread #endif +// TODO(b/228173843): cleanup PROTOBUF_LITTLE_ENDIAN in various 3p forks. +#if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ + __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) +#define PROTOBUF_LITTLE_ENDIAN 1 +#ifdef PROTOBUF_BIG_ENDIAN +#error Conflicting PROTOBUF_BIG_ENDIAN was previously defined +#endif +#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ + __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#define PROTOBUF_BIG_ENDIAN 1 +#elif defined(_WIN32) || defined(__x86_64__) || defined(__aarch64__) +#define PROTOBUF_LITTLE_ENDIAN 1 +#else +#error "endian detection failed for current compiler" +#endif + // For enabling message owned arena, one major blocker is semantic change from // moving to copying when there is ownership transfer (e.g., move ctor, swap, // set allocated, release). This change not only causes performance regression @@ -574,16 +638,29 @@ #ifdef PROTOBUF_CONSTINIT #error PROTOBUF_CONSTINIT was previously defined #endif -#if defined(__cpp_constinit) && !PROTOBUF_GNUC_MIN(3, 0) && !defined(_MSC_VER) -// Our use of constinit does not yet work with GCC: -// https://github.com/protocolbuffers/protobuf/issues/8310 -// Does not work yet with Visual Studio 2019 Update 16.10 +#if defined(__cpp_constinit) && !defined(_MSC_VER) #define PROTOBUF_CONSTINIT constinit -#elif !defined(_MSC_VER) && \ - __has_cpp_attribute(clang::require_constant_initialization) +#define PROTOBUF_CONSTEXPR constexpr +// Some older Clang versions incorrectly raise an error about +// constant-initializing weak default instance pointers. Versions 12.0 and +// higher seem to work, except that XCode 12.5.1 shows the error even though it +// uses Clang 12.0.5. +// Clang-cl on Windows raises error also. +#elif !defined(_MSC_VER) && __has_cpp_attribute(clang::require_constant_initialization) && \ + ((defined(__APPLE__) && __clang_major__ >= 13) || \ + (!defined(__APPLE__) && __clang_major__ >= 12)) #define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]] +#define PROTOBUF_CONSTEXPR constexpr +#elif PROTOBUF_GNUC_MIN(12, 2) +#define PROTOBUF_CONSTINIT __constinit +#define PROTOBUF_CONSTEXPR constexpr +// MSVC 17 currently seems to raise an error about constant-initialized pointers. +#elif defined(_MSC_VER) && _MSC_VER >= 1930 +#define PROTOBUF_CONSTINIT +#define PROTOBUF_CONSTEXPR constexpr #else #define PROTOBUF_CONSTINIT +#define PROTOBUF_CONSTEXPR #endif // Some globals with an empty non-trivial destructor are annotated with @@ -598,26 +675,49 @@ #define PROTOBUF_ATTRIBUTE_NO_DESTROY #endif +// Force clang to always emit complete debug info for a type. +// Clang uses constructor homing to determine when to emit debug info for a +// type. If the constructor of a type is never used, which can happen in some +// cases where member variables are constructed in place for optimization +// purposes (see b/208803175 for an example), the type will have incomplete +// debug info unless this attribute is used. +#ifdef PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG +#error PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG was previously defined +#endif +#if __has_cpp_attribute(clang::standalone_debug) +#define PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG [[clang::standalone_debug]] +#else +#define PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG +#endif + // Protobuf extensions and reflection require registration of the protos linked // in the binary. Not until everything is registered does the runtime have a // complete view on all protos. When code is using reflection or extensions // in between registration calls this can lead to surprising behavior. By // having the registration run first we mitigate this scenario. -// Highest priority is 101. We use 102 to allow code that really wants to -// higher priority to still beat us. -#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY -#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY was previously defined +// Highest priority is 101. We use 102 for registration, to allow code that +// really wants to higher priority to still beat us. Some initialization happens +// at higher priority, though, since it is needed before registration. +#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 +#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 was previously defined #endif -#if PROTOBUF_GNUC_MIN(3, 0) && (!defined(__APPLE__) || defined(__clang__)) && !((defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__))) -#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY __attribute__((init_priority((102)))) +#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 was previously defined +#endif +#if PROTOBUF_GNUC_MIN(3, 0) && (!defined(__APPLE__) || defined(__clang__)) && \ + !((defined(sun) || defined(__sun)) && \ + (defined(__SVR4) || defined(__svr4__))) +#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 __attribute__((init_priority((101)))) +#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 __attribute__((init_priority((102)))) #else -#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY +#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 +#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 #endif #ifdef PROTOBUF_PRAGMA_INIT_SEG #error PROTOBUF_PRAGMA_INIT_SEG was previously defined #endif -#if _MSC_VER +#ifdef _MSC_VER #define PROTOBUF_PRAGMA_INIT_SEG __pragma(init_seg(lib)) #else #define PROTOBUF_PRAGMA_INIT_SEG @@ -679,19 +779,6 @@ #endif #if defined(PROTOBUF_EXPERIMENTAL_USE_TAIL_CALL_TABLE_PARSER) #define PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED 1 -// Selectively use static member functions instead of templates: -#ifndef PROTOBUF_TC_STATIC_PARSE_SINGULAR1 -# define PROTOBUF_TC_STATIC_PARSE_SINGULAR1 1 -#endif -#ifndef PROTOBUF_TC_STATIC_PARSE_SINGULAR2 -# define PROTOBUF_TC_STATIC_PARSE_SINGULAR2 0 -#endif -#ifndef PROTOBUF_TC_STATIC_PARSE_REPEATED1 -# define PROTOBUF_TC_STATIC_PARSE_REPEATED1 0 -#endif -#ifndef PROTOBUF_TC_STATIC_PARSE_REPEATED2 -# define PROTOBUF_TC_STATIC_PARSE_REPEATED2 0 -#endif #endif #define PROTOBUF_TC_PARAM_DECL \ @@ -712,6 +799,8 @@ #define PROTOBUF_UNUSED #endif +// ThreadSafeArenaz is turned off completely in opensource builds. + // Windows declares several inconvenient macro names. We #undef them and then // restore them in port_undef.inc. #ifdef _MSC_VER @@ -729,8 +818,12 @@ #undef ERROR_INSTALL_FAILED #pragma push_macro("ERROR_NOT_FOUND") #undef ERROR_NOT_FOUND +#pragma push_macro("GetClassName") +#undef GetClassName #pragma push_macro("GetMessage") #undef GetMessage +#pragma push_macro("GetObject") +#undef GetObject #pragma push_macro("IGNORE") #undef IGNORE #pragma push_macro("IN") @@ -757,12 +850,28 @@ #undef SERVICE_DISABLED #pragma push_macro("SEVERITY_ERROR") #undef SEVERITY_ERROR +#pragma push_macro("STATUS_PENDING") +#undef STATUS_PENDING #pragma push_macro("STRICT") #undef STRICT #pragma push_macro("timezone") #undef timezone #endif // _MSC_VER +#ifdef __APPLE__ +// Inconvenient macro names from usr/include/math.h in some macOS SDKs. +#pragma push_macro("DOMAIN") +#undef DOMAIN +// Inconvenient macro names from /usr/include/mach/boolean.h in some macOS SDKs. +#pragma push_macro("TRUE") +#undef TRUE +#pragma push_macro("FALSE") +#undef FALSE +// Inconvenient macro names from usr/include/sys/syslimits.h in some macOS SDKs. +#pragma push_macro("UID_MAX") +#undef UID_MAX +#endif // __APPLE__ + #if defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER) // Don't let Objective-C Macros interfere with proto identifiers with the same // name. @@ -770,12 +879,7 @@ #undef DEBUG #endif // defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER) -#if defined(__clang__) -#pragma clang diagnostic push -// TODO(gerbens) ideally we cleanup the code. But a cursory try shows many -// violations. So let's ignore for now. -#pragma clang diagnostic ignored "-Wshorten-64-to-32" -#elif PROTOBUF_GNUC_MIN(3, 0) +#if PROTOBUF_GNUC_MIN(3, 0) // GCC does not allow disabling diagnostics within an expression: // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60875, so we disable this one // globally even though it's only used for PROTOBUF_FIELD_OFFSET. @@ -784,7 +888,7 @@ #endif // Silence some MSVC warnings in all our code. -#if _MSC_VER +#ifdef _MSC_VER #pragma warning(push) // For non-trivial unions #pragma warning(disable : 4582) diff --git a/r5dev/thirdparty/protobuf/port_undef.inc b/r5dev/thirdparty/protobuf/port_undef.inc index 579eb419..e880fa5c 100644 --- a/r5dev/thirdparty/protobuf/port_undef.inc +++ b/r5dev/thirdparty/protobuf/port_undef.inc @@ -34,6 +34,10 @@ #ifndef PROTOBUF_NAMESPACE #error "port_undef.inc must be included after port_def.inc" #endif + +#undef PROTOBUF_BUILTIN_BSWAP16 +#undef PROTOBUF_BUILTIN_BSWAP32 +#undef PROTOBUF_BUILTIN_BSWAP64 #undef PROTOBUF_GNUC_MIN #undef PROTOBUF_MSC_VER_MIN #undef PROTOBUF_CPLUSPLUS_MIN @@ -67,6 +71,7 @@ #undef PROTOBUF_FORCE_COPY_IN_RELEASE #undef PROTOBUF_FORCE_COPY_IN_SWAP #undef PROTOBUF_FORCE_COPY_IN_MOVE +#undef PROTOBUF_FORCE_RESET_IN_CLEAR #undef PROTOBUF_FORCE_COPY_DEFAULT_STRING #undef PROTOBUF_NAMESPACE_OPEN #undef PROTOBUF_NAMESPACE_CLOSE @@ -76,22 +81,24 @@ #undef PROTOBUF_EXPORT_TEMPLATE_DEFINE #undef PROTOBUF_ALIGNAS #undef PROTOBUF_FINAL +#undef PROTOBUF_FUTURE_FINAL #undef PROTOBUF_THREAD_LOCAL +#undef PROTOBUF_LITTLE_ENDIAN +#undef PROTOBUF_BIG_ENDIAN #undef PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT #undef PROTOBUF_CONSTINIT +#undef PROTOBUF_CONSTEXPR #undef PROTOBUF_ATTRIBUTE_WEAK #undef PROTOBUF_HAVE_ATTRIBUTE_WEAK #undef PROTOBUF_ATTRIBUTE_NO_DESTROY -#undef PROTOBUF_ATTRIBUTE_INIT_PRIORITY +#undef PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG +#undef PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 +#undef PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 #undef PROTOBUF_PRAGMA_INIT_SEG #undef PROTOBUF_ASAN #undef PROTOBUF_MSAN #undef PROTOBUF_TSAN #undef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED -#undef PROTOBUF_TC_STATIC_PARSE_SINGULAR1 -#undef PROTOBUF_TC_STATIC_PARSE_SINGULAR2 -#undef PROTOBUF_TC_STATIC_PARSE_REPEATED1 -#undef PROTOBUF_TC_STATIC_PARSE_REPEATED2 #undef PROTOBUF_TC_PARAM_DECL #undef PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED #undef PROTOBUF_LOCKS_EXCLUDED @@ -111,7 +118,9 @@ #pragma pop_macro("ERROR_BUSY") #pragma pop_macro("ERROR_INSTALL_FAILED") #pragma pop_macro("ERROR_NOT_FOUND") +#pragma pop_macro("GetClassName") #pragma pop_macro("GetMessage") +#pragma pop_macro("GetObject") #pragma pop_macro("IGNORE") #pragma pop_macro("IN") #pragma pop_macro("INPUT_KEYBOARD") @@ -126,20 +135,26 @@ #pragma pop_macro("SERVICE_DISABLED") #pragma pop_macro("SEVERITY_ERROR") #pragma pop_macro("STRICT") +#pragma pop_macro("STATUS_PENDING") #pragma pop_macro("timezone") #endif +#ifdef __APPLE__ +#pragma pop_macro("DOMAIN") +#pragma pop_macro("TRUE") +#pragma pop_macro("FALSE") +#pragma pop_macro("UID_MAX") +#endif // __APPLE__ + #if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) #pragma pop_macro("DEBUG") #endif // defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) -#if defined(__clang__) -#pragma clang diagnostic pop -#elif defined(__GNUC__) +#if defined(__GNUC__) #pragma GCC diagnostic pop #endif // Pop the warning(push) from port_def.inc -#if _MSC_VER +#ifdef _MSC_VER #pragma warning(pop) #endif diff --git a/r5dev/thirdparty/protobuf/proto3_arena_unittest.cc b/r5dev/thirdparty/protobuf/proto3_arena_unittest.cc index b2f9aa63..1a776ef5 100644 --- a/r5dev/thirdparty/protobuf/proto3_arena_unittest.cc +++ b/r5dev/thirdparty/protobuf/proto3_arena_unittest.cc @@ -32,7 +32,6 @@ #include <string> #include <vector> -#include <thirdparty/protobuf/test_util.h> #include <thirdparty/protobuf/unittest.pb.h> #include <thirdparty/protobuf/unittest_proto3_arena.pb.h> #include <thirdparty/protobuf/unittest_proto3_optional.pb.h> @@ -41,6 +40,7 @@ #include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/test_util.h> // Must be included last. #include <thirdparty/protobuf/port_def.inc> @@ -75,6 +75,7 @@ void SetAllFields(TestAllTypes* m) { m->set_optional_nested_enum(proto3_arena_unittest::TestAllTypes::BAZ); m->set_optional_foreign_enum(proto3_arena_unittest::FOREIGN_BAZ); m->mutable_optional_lazy_message()->set_bb(45); + m->mutable_optional_unverified_lazy_message()->set_bb(46); m->add_repeated_int32(100); m->add_repeated_string("asdf"); m->add_repeated_bytes("jkl;"); @@ -101,6 +102,8 @@ void ExpectAllFieldsSet(const TestAllTypes& m) { EXPECT_EQ(proto3_arena_unittest::FOREIGN_BAZ, m.optional_foreign_enum()); EXPECT_EQ(true, m.has_optional_lazy_message()); EXPECT_EQ(45, m.optional_lazy_message().bb()); + EXPECT_EQ(true, m.has_optional_unverified_lazy_message()); + EXPECT_EQ(46, m.optional_unverified_lazy_message().bb()); EXPECT_EQ(1, m.repeated_int32_size()); EXPECT_EQ(100, m.repeated_int32(0)); diff --git a/r5dev/thirdparty/protobuf/proto3_lite_unittest.inc b/r5dev/thirdparty/protobuf/proto3_lite_unittest.inc index 6d674ec2..5048600c 100644 --- a/r5dev/thirdparty/protobuf/proto3_lite_unittest.inc +++ b/r5dev/thirdparty/protobuf/proto3_lite_unittest.inc @@ -53,6 +53,7 @@ void SetAllFields(TestAllTypes* m) { m->set_optional_foreign_enum( UNITTEST::FOREIGN_BAZ); m->mutable_optional_lazy_message()->set_bb(45); + m->mutable_optional_unverified_lazy_message()->set_bb(46); m->add_repeated_int32(100); m->add_repeated_string("asdf"); m->add_repeated_bytes("jkl;"); @@ -81,6 +82,8 @@ void ExpectAllFieldsSet(const TestAllTypes& m) { m.optional_foreign_enum()); EXPECT_EQ(true, m.has_optional_lazy_message()); EXPECT_EQ(45, m.optional_lazy_message().bb()); + EXPECT_EQ(true, m.has_optional_unverified_lazy_message()); + EXPECT_EQ(46, m.optional_unverified_lazy_message().bb()); EXPECT_EQ(1, m.repeated_int32_size()); EXPECT_EQ(100, m.repeated_int32(0)); diff --git a/r5dev/thirdparty/protobuf/reflection.h b/r5dev/thirdparty/protobuf/reflection.h index a26194ff..387ed67e 100644 --- a/r5dev/thirdparty/protobuf/reflection.h +++ b/r5dev/thirdparty/protobuf/reflection.h @@ -33,6 +33,7 @@ #ifndef GOOGLE_PROTOBUF_REFLECTION_H__ #define GOOGLE_PROTOBUF_REFLECTION_H__ + #include <memory> #include <thirdparty/protobuf/message.h> @@ -42,6 +43,7 @@ #error "You cannot SWIG proto headers" #endif +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/reflection_ops.cc b/r5dev/thirdparty/protobuf/reflection_ops.cc index ec631c6c..18adda69 100644 --- a/r5dev/thirdparty/protobuf/reflection_ops.cc +++ b/r5dev/thirdparty/protobuf/reflection_ops.cc @@ -38,12 +38,13 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/map_field.h> #include <thirdparty/protobuf/map_field_inl.h> #include <thirdparty/protobuf/unknown_field_set.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -169,8 +170,10 @@ void ReflectionOps::Merge(const Message& from, Message* to) { } } - to_reflection->MutableUnknownFields(to)->MergeFrom( - from_reflection->GetUnknownFields(from)); + if (!from_reflection->GetUnknownFields(from).empty()) { + to_reflection->MutableUnknownFields(to)->MergeFrom( + from_reflection->GetUnknownFields(from)); + } } void ReflectionOps::Clear(Message* message) { @@ -182,7 +185,9 @@ void ReflectionOps::Clear(Message* message) { reflection->ClearField(message, field); } - reflection->MutableUnknownFields(message)->Clear(); + if (reflection->GetInternalMetadata(*message).have_unknown_fields()) { + reflection->MutableUnknownFields(message)->Clear(); + } } bool ReflectionOps::IsInitialized(const Message& message, bool check_fields, @@ -420,16 +425,16 @@ void ReflectionOps::FindInitializationErrors(const Message& message, void GenericSwap(Message* lhs, Message* rhs) { #ifndef PROTOBUF_FORCE_COPY_IN_SWAP - GOOGLE_DCHECK(Arena::InternalHelper<Message>::GetOwningArena(lhs) != - Arena::InternalHelper<Message>::GetOwningArena(rhs)); - GOOGLE_DCHECK(Arena::InternalHelper<Message>::GetOwningArena(lhs) != nullptr || - Arena::InternalHelper<Message>::GetOwningArena(rhs) != nullptr); + GOOGLE_DCHECK(Arena::InternalGetOwningArena(lhs) != + Arena::InternalGetOwningArena(rhs)); + GOOGLE_DCHECK(Arena::InternalGetOwningArena(lhs) != nullptr || + Arena::InternalGetOwningArena(rhs) != nullptr); #endif // !PROTOBUF_FORCE_COPY_IN_SWAP // At least one of these must have an arena, so make `rhs` point to it. - Arena* arena = Arena::InternalHelper<Message>::GetOwningArena(rhs); + Arena* arena = Arena::InternalGetOwningArena(rhs); if (arena == nullptr) { std::swap(lhs, rhs); - arena = Arena::InternalHelper<Message>::GetOwningArena(rhs); + arena = Arena::InternalGetOwningArena(rhs); } // Improve efficiency by placing the temporary on an arena so that messages diff --git a/r5dev/thirdparty/protobuf/reflection_ops.h b/r5dev/thirdparty/protobuf/reflection_ops.h index 4823cba5..79c3c5aa 100644 --- a/r5dev/thirdparty/protobuf/reflection_ops.h +++ b/r5dev/thirdparty/protobuf/reflection_ops.h @@ -45,6 +45,7 @@ #error "You cannot SWIG proto headers" #endif +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/reflection_ops_unittest.cc b/r5dev/thirdparty/protobuf/reflection_ops_unittest.cc index 4770d84d..8348249f 100644 --- a/r5dev/thirdparty/protobuf/reflection_ops_unittest.cc +++ b/r5dev/thirdparty/protobuf/reflection_ops_unittest.cc @@ -33,14 +33,14 @@ // Sanjay Ghemawat, Jeff Dean, and others. #include <thirdparty/protobuf/reflection_ops.h> -#include <thirdparty/protobuf/test_util.h> -#include <thirdparty/protobuf/unittest.pb.h> -#include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> +#include <thirdparty/protobuf/unittest.pb.h> +#include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> +#include <thirdparty/protobuf/test_util.h> #include <thirdparty/protobuf/stubs/strutil.h> @@ -110,7 +110,7 @@ TEST(ReflectionOpsTest, Merge) { // This tests concatenating. message2.add_repeated_int32(message.repeated_int32(1)); - int32 i = message.repeated_int32(0); + int32_t i = message.repeated_int32(0); message.clear_repeated_int32(); message.add_repeated_int32(i); @@ -143,7 +143,7 @@ TEST(ReflectionOpsTest, MergeExtensions) { message2.AddExtension( unittest::repeated_int32_extension, message.GetExtension(unittest::repeated_int32_extension, 1)); - int32 i = message.GetExtension(unittest::repeated_int32_extension, 0); + int32_t i = message.GetExtension(unittest::repeated_int32_extension, 0); message.ClearExtension(unittest::repeated_int32_extension); message.AddExtension(unittest::repeated_int32_extension, i); @@ -516,7 +516,7 @@ TEST(ReflectionOpsTest, GenericSwap) { unittest::TestAllTypes message; auto* arena_message = Arena::CreateMessage<unittest::TestAllTypes>(&arena); TestUtil::SetAllFields(arena_message); - const uint64 initial_arena_size = arena.SpaceUsed(); + const uint64_t initial_arena_size = arena.SpaceUsed(); GenericSwap(&message, arena_message); @@ -529,7 +529,7 @@ TEST(ReflectionOpsTest, GenericSwap) { unittest::TestAllTypes message; auto* arena_message = Arena::CreateMessage<unittest::TestAllTypes>(&arena); TestUtil::SetAllFields(arena_message); - const uint64 initial_arena_size = arena.SpaceUsed(); + const uint64_t initial_arena_size = arena.SpaceUsed(); GenericSwap(arena_message, &message); diff --git a/r5dev/thirdparty/protobuf/reflection_tester.cc b/r5dev/thirdparty/protobuf/reflection_tester.cc index 74380df4..44a8d1ad 100644 --- a/r5dev/thirdparty/protobuf/reflection_tester.cc +++ b/r5dev/thirdparty/protobuf/reflection_tester.cc @@ -30,9 +30,9 @@ #include <thirdparty/protobuf/reflection_tester.h> +#include <gtest/gtest.h> #include <thirdparty/protobuf/map_field.h> #include <thirdparty/protobuf/message.h> -#include <gtest/gtest.h> // Must include last. #include <thirdparty/protobuf/port_def.inc> diff --git a/r5dev/thirdparty/protobuf/repeated_field.cc b/r5dev/thirdparty/protobuf/repeated_field.cc index 79ebfa82..e9b29598 100644 --- a/r5dev/thirdparty/protobuf/repeated_field.cc +++ b/r5dev/thirdparty/protobuf/repeated_field.cc @@ -39,6 +39,7 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -54,6 +55,16 @@ template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<float>; template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedField<double>; template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedPtrField<std::string>; +namespace internal { +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<bool>; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<int32_t>; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<uint32_t>; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<int64_t>; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<uint64_t>; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<float>; +template class PROTOBUF_EXPORT_TEMPLATE_DEFINE RepeatedIterator<double>; +} // namespace internal + } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/repeated_field.h b/r5dev/thirdparty/protobuf/repeated_field.h index 08c7894b..7c450c71 100644 --- a/r5dev/thirdparty/protobuf/repeated_field.h +++ b/r5dev/thirdparty/protobuf/repeated_field.h @@ -39,32 +39,25 @@ // particularly different from STL vector as it manages ownership of the // pointers that it contains. // -// Typically, clients should not need to access RepeatedField objects directly, -// but should instead use the accessor functions generated automatically by the -// protocol compiler. -// // This header covers RepeatedField. #ifndef GOOGLE_PROTOBUF_REPEATED_FIELD_H__ #define GOOGLE_PROTOBUF_REPEATED_FIELD_H__ -#include <utility> -#ifdef _MSC_VER -// This is required for min/max on VS2013 only. -#include <algorithm> -#endif +#include <algorithm> #include <iterator> #include <limits> #include <string> #include <type_traits> +#include <utility> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/repeated_ptr_field.h> #include <thirdparty/protobuf/arena.h> -#include <thirdparty/protobuf/message_lite.h> #include <thirdparty/protobuf/port.h> +#include <thirdparty/protobuf/message_lite.h> +#include <thirdparty/protobuf/repeated_ptr_field.h> // Must be included last. @@ -81,9 +74,18 @@ class Message; namespace internal { -// kRepeatedFieldLowerClampLimit is the smallest size that will be allocated -// when growing a repeated field. -constexpr int kRepeatedFieldLowerClampLimit = 4; +template <typename T, int kRepHeaderSize> +constexpr int RepeatedFieldLowerClampLimit() { + // The header is padded to be at least `sizeof(T)` when it would be smaller + // otherwise. + static_assert(sizeof(T) <= kRepHeaderSize, ""); + // We want to pad the minimum size to be a power of two bytes, including the + // header. + // The first allocation is kRepHeaderSize bytes worth of elements for a total + // of 2*kRepHeaderSize bytes. + // For an 8-byte header, we allocate 8 bool, 2 ints, or 1 int64. + return kRepHeaderSize / sizeof(T); +} // kRepeatedFieldUpperClampLimit is the lowest signed integer value that // overflows when multiplied by 2 (which is undefined behavior). Sizes above @@ -120,7 +122,6 @@ inline void SwapBlock(char* p, char* q) { // Swaps two blocks of memory of size kSize: // template <int kSize> void memswap(char* p, char* q); - template <int kSize> inline typename std::enable_if<(kSize == 0), void>::type memswap(char*, char*) { } @@ -148,6 +149,9 @@ PROTO_MEMSWAP_DEF_SIZE(uint64_t, (1u << 31)) #undef PROTO_MEMSWAP_DEF_SIZE +template <typename Element> +class RepeatedIterator; + } // namespace internal // RepeatedField is used to represent repeated fields of a primitive type (in @@ -192,20 +196,20 @@ class RepeatedField final { void Set(int index, const Element& value); void Add(const Element& value); - // Appends a new element and return a pointer to it. + // Appends a new element and returns a pointer to it. // The new element is uninitialized if |Element| is a POD type. Element* Add(); - // Append elements in the range [begin, end) after reserving + // Appends elements in the range [begin, end) after reserving // the appropriate number of elements. template <typename Iter> void Add(Iter begin, Iter end); - // Remove the last element in the array. + // Removes the last element in the array. void RemoveLast(); - // Extract elements with indices in "[start .. start+num-1]". - // Copy them into "elements[0 .. num-1]" if "elements" is not nullptr. - // Caution: implementation also moves elements with indices [start+num ..]. + // Extracts elements with indices in "[start .. start+num-1]". + // Copies them into "elements[0 .. num-1]" if "elements" is not nullptr. + // Caution: also moves elements with indices [start+num ..]. // Calling this routine inside a loop can cause quadratic behavior. void ExtractSubrange(int start, int num, Element* elements); @@ -217,11 +221,11 @@ class RepeatedField final { template <typename Iter> PROTOBUF_ATTRIBUTE_REINITIALIZES void Assign(Iter begin, Iter end); - // Reserve space to expand the field to at least the given size. If the + // Reserves space to expand the field to at least the given size. If the // array is grown, it will always be at least doubled in size. void Reserve(int new_size); - // Resize the RepeatedField to a new, smaller size. This is O(1). + // Resizes the RepeatedField to a new, smaller size. This is O(1). void Truncate(int new_size); void AddAlreadyReserved(const Element& value); @@ -242,22 +246,22 @@ class RepeatedField final { Element* mutable_data(); const Element* data() const; - // Swap entire contents with "other". If they are separate arenas then, copies - // data between each other. + // Swaps entire contents with "other". If they are separate arenas then, + // copies data between each other. void Swap(RepeatedField* other); - // Swap entire contents with "other". Should be called only if the caller can + // Swaps entire contents with "other". Should be called only if the caller can // guarantee that both repeated fields are on the same arena or are on the // heap. Swapping between different arenas is disallowed and caught by a // GOOGLE_DCHECK (see API docs for details). void UnsafeArenaSwap(RepeatedField* other); - // Swap two elements. + // Swaps two elements. void SwapElements(int index1, int index2); // STL-like iterator support - typedef Element* iterator; - typedef const Element* const_iterator; + typedef internal::RepeatedIterator<Element> iterator; + typedef internal::RepeatedIterator<const Element> const_iterator; typedef Element value_type; typedef value_type& reference; typedef const value_type& const_reference; @@ -308,10 +312,9 @@ class RepeatedField final { // Invalidates all iterators at or after the removed range, including end(). iterator erase(const_iterator first, const_iterator last); - // Get the Arena on which this RepeatedField stores its elements. + // Gets the Arena on which this RepeatedField stores its elements. inline Arena* GetArena() const { - return (total_size_ == 0) ? static_cast<Arena*>(arena_or_elements_) - : rep()->arena; + return GetOwningArena(); } // For internal use only. @@ -320,6 +323,14 @@ class RepeatedField final { inline void InternalSwap(RepeatedField* other); private: + template <typename T> friend class Arena::InternalHelper; + + // Gets the Arena on which this RepeatedField stores its elements. + inline Arena* GetOwningArena() const { + return (total_size_ == 0) ? static_cast<Arena*>(arena_or_elements_) + : rep()->arena; + } + static constexpr int kInitialSize = 0; // A note on the representation here (see also comment below for // RepeatedPtrFieldBase's struct Rep): @@ -333,21 +344,24 @@ class RepeatedField final { // RepeatedField class to avoid costly cache misses due to the indirection. int current_size_; int total_size_; + // Pad the Rep after arena allow for power-of-two byte sizes when + // sizeof(Element) > sizeof(Arena*). eg for 16-byte objects. + static PROTOBUF_CONSTEXPR const size_t kRepHeaderSize = + sizeof(Arena*) < sizeof(Element) ? sizeof(Element) : sizeof(Arena*); struct Rep { Arena* arena; - // Here we declare a huge array as a way of approximating C's "flexible - // array member" feature without relying on undefined behavior. - Element elements[(std::numeric_limits<int>::max() - 2 * sizeof(Arena*)) / - sizeof(Element)]; + Element* elements() { + return reinterpret_cast<Element*>(reinterpret_cast<char*>(this) + + kRepHeaderSize); + } }; - static constexpr size_t kRepHeaderSize = offsetof(Rep, elements); // If total_size_ == 0 this points to an Arena otherwise it points to the // elements member of a Rep struct. Using this invariant allows the storage of // the arena pointer without an extra allocation in the constructor. void* arena_or_elements_; - // Return pointer to elements array. + // Returns a pointer to elements array. // pre-condition: the array must have been allocated. Element* elements() const { GOOGLE_DCHECK_GT(total_size_, 0); @@ -355,48 +369,48 @@ class RepeatedField final { return unsafe_elements(); } - // Return pointer to elements array if it exists otherwise either null or - // a invalid pointer is returned. This only happens for empty repeated fields, - // where you can't dereference this pointer anyway (it's empty). + // Returns a pointer to elements array if it exists; otherwise either null or + // an invalid pointer is returned. This only happens for empty repeated + // fields, where you can't dereference this pointer anyway (it's empty). Element* unsafe_elements() const { return static_cast<Element*>(arena_or_elements_); } - // Return pointer to the Rep struct. + // Returns a pointer to the Rep struct. // pre-condition: the Rep must have been allocated, ie elements() is safe. Rep* rep() const { - char* addr = reinterpret_cast<char*>(elements()) - offsetof(Rep, elements); - return reinterpret_cast<Rep*>(addr); + return reinterpret_cast<Rep*>(reinterpret_cast<char*>(elements()) - + kRepHeaderSize); } friend class Arena; typedef void InternalArenaConstructable_; - // Move the contents of |from| into |to|, possibly clobbering |from| in the + // Moves the contents of |from| into |to|, possibly clobbering |from| in the // process. For primitive types this is just a memcpy(), but it could be // specialized for non-primitive types to, say, swap each element instead. void MoveArray(Element* to, Element* from, int size); - // Copy the elements of |from| into |to|. + // Copies the elements of |from| into |to|. void CopyArray(Element* to, const Element* from, int size); // Internal helper to delete all elements and deallocate the storage. - void InternalDeallocate(Rep* rep, int size) { + void InternalDeallocate(Rep* rep, int size, bool in_destructor) { if (rep != nullptr) { - Element* e = &rep->elements[0]; + Element* e = &rep->elements()[0]; if (!std::is_trivial<Element>::value) { - Element* limit = &rep->elements[size]; + Element* limit = &rep->elements()[size]; for (; e < limit; e++) { e->~Element(); } } + const size_t bytes = size * sizeof(*e) + kRepHeaderSize; if (rep->arena == nullptr) { -#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) - const size_t bytes = size * sizeof(*e) + kRepHeaderSize; - ::operator delete(static_cast<void*>(rep), bytes); -#else - ::operator delete(static_cast<void*>(rep)); -#endif + internal::SizedDelete(rep, bytes); + } else if (!in_destructor) { + // If we are in the destructor, we might be being destroyed as part of + // the arena teardown. We can't try and return blocks to the arena then. + rep->arena->ReturnArrayMemory(rep, bytes); } } } @@ -419,7 +433,7 @@ class RepeatedField final { // largely the presence of the fallback path disturbs the compilers mem-to-reg // analysis. // - // This class takes ownership of a repeated field for the duration of it's + // This class takes ownership of a repeated field for the duration of its // lifetime. The repeated field should not be accessed during this time, ie. // only access through this class is allowed. This class should always be a // function local stack variable. Intended use @@ -432,13 +446,13 @@ class RepeatedField final { // } // } // - // Typically due to the fact adder is a local stack variable. The compiler - // will be successful in mem-to-reg transformation and the machine code will - // be loop: cmp %size, %capacity jae fallback mov dword ptr [%buffer + %size * - // 4], %val inc %size jmp loop + // Typically, due to the fact that adder is a local stack variable, the + // compiler will be successful in mem-to-reg transformation and the machine + // code will be loop: cmp %size, %capacity jae fallback mov dword ptr [%buffer + // + %size * 4], %val inc %size jmp loop // // The first version executes at 7 cycles per iteration while the second - // version near 1 or 2 cycles. + // version executes at only 1 or 2 cycles. template <int = 0, bool = std::is_trivial<Element>::value> class FastAdderImpl { public: @@ -531,13 +545,13 @@ RepeatedField<Element>::RepeatedField(Iter begin, Iter end) template <typename Element> RepeatedField<Element>::~RepeatedField() { #ifndef NDEBUG - // Try to trigger segfault / asan failure in non-opt builds. If arena_ + // Try to trigger segfault / asan failure in non-opt builds if arena_ // lifetime has ended before the destructor. - auto arena = GetArena(); + auto arena = GetOwningArena(); if (arena) (void)arena->SpaceAllocated(); #endif if (total_size_ > 0) { - InternalDeallocate(rep(), total_size_); + InternalDeallocate(rep(), total_size_, true); } } @@ -557,7 +571,7 @@ inline RepeatedField<Element>::RepeatedField(RepeatedField&& other) noexcept // We don't just call Swap(&other) here because it would perform 3 copies if // other is on an arena. This field can't be on an arena because arena // construction always uses the Arena* accepting constructor. - if (other.GetArena()) { + if (other.GetOwningArena()) { CopyFrom(other); } else { InternalSwap(&other); @@ -571,9 +585,9 @@ inline RepeatedField<Element>& RepeatedField<Element>::operator=( // We don't just call Swap(&other) here because it would perform 3 copies if // the two fields are on different arenas. if (this != &other) { - if (GetArena() != other.GetArena() + if (GetOwningArena() != other.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - || GetArena() == nullptr + || GetOwningArena() == nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { CopyFrom(other); @@ -612,15 +626,15 @@ inline Element* RepeatedField<Element>::AddAlreadyReserved() { } template <typename Element> -inline Element* RepeatedField<Element>::AddNAlreadyReserved(int n) { - GOOGLE_DCHECK_GE(total_size_ - current_size_, n) +inline Element* RepeatedField<Element>::AddNAlreadyReserved(int elements) { + GOOGLE_DCHECK_GE(total_size_ - current_size_, elements) << total_size_ << ", " << current_size_; - // Warning: sometimes people call this when n == 0 and total_size_ == 0. In - // this case the return pointer points to a zero size array (n == 0). Hence - // we can just use unsafe_elements(), because the user cannot dereference the - // pointer anyway. + // Warning: sometimes people call this when elements == 0 and + // total_size_ == 0. In this case the return pointer points to a zero size + // array (n == 0). Hence we can just use unsafe_elements(), because the user + // cannot dereference the pointer anyway. Element* ret = unsafe_elements() + current_size_; - current_size_ += n; + current_size_ += elements; return ret; } @@ -817,13 +831,14 @@ template <typename Element> void RepeatedField<Element>::Swap(RepeatedField* other) { if (this == other) return; #ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && GetArena() == other->GetArena()) { + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { #else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { + if (GetOwningArena() == other->GetOwningArena()) { #endif // !PROTOBUF_FORCE_COPY_IN_SWAP InternalSwap(other); } else { - RepeatedField<Element> temp(other->GetArena()); + RepeatedField<Element> temp(other->GetOwningArena()); temp.MergeFrom(*this); CopyFrom(*other); other->UnsafeArenaSwap(&temp); @@ -833,6 +848,7 @@ void RepeatedField<Element>::Swap(RepeatedField* other) { template <typename Element> void RepeatedField<Element>::UnsafeArenaSwap(RepeatedField* other) { if (this == other) return; + GOOGLE_DCHECK_EQ(GetOwningArena(), other->GetOwningArena()); InternalSwap(other); } @@ -845,31 +861,31 @@ void RepeatedField<Element>::SwapElements(int index1, int index2) { template <typename Element> inline typename RepeatedField<Element>::iterator RepeatedField<Element>::begin() { - return unsafe_elements(); + return iterator(unsafe_elements()); } template <typename Element> inline typename RepeatedField<Element>::const_iterator RepeatedField<Element>::begin() const { - return unsafe_elements(); + return const_iterator(unsafe_elements()); } template <typename Element> inline typename RepeatedField<Element>::const_iterator RepeatedField<Element>::cbegin() const { - return unsafe_elements(); + return const_iterator(unsafe_elements()); } template <typename Element> inline typename RepeatedField<Element>::iterator RepeatedField<Element>::end() { - return unsafe_elements() + current_size_; + return iterator(unsafe_elements() + current_size_); } template <typename Element> inline typename RepeatedField<Element>::const_iterator RepeatedField<Element>::end() const { - return unsafe_elements() + current_size_; + return const_iterator(unsafe_elements() + current_size_); } template <typename Element> inline typename RepeatedField<Element>::const_iterator RepeatedField<Element>::cend() const { - return unsafe_elements() + current_size_; + return const_iterator(unsafe_elements() + current_size_); } template <typename Element> @@ -886,18 +902,23 @@ namespace internal { // new_size > total_size && // (total_size == 0 || // total_size >= kRepeatedFieldLowerClampLimit) +template <typename T, int kRepHeaderSize> inline int CalculateReserveSize(int total_size, int new_size) { - if (new_size < kRepeatedFieldLowerClampLimit) { + constexpr int lower_limit = RepeatedFieldLowerClampLimit<T, kRepHeaderSize>(); + if (new_size < lower_limit) { // Clamp to smallest allowed size. - return kRepeatedFieldLowerClampLimit; + return lower_limit; } - if (total_size < kRepeatedFieldUpperClampLimit) { - return std::max(total_size * 2, new_size); - } else { - // Clamp to largest allowed size. - GOOGLE_DCHECK_GT(new_size, kRepeatedFieldUpperClampLimit); + constexpr int kMaxSizeBeforeClamp = + (std::numeric_limits<int>::max() - kRepHeaderSize) / 2; + if (PROTOBUF_PREDICT_FALSE(total_size > kMaxSizeBeforeClamp)) { return std::numeric_limits<int>::max(); } + // We want to double the number of bytes, not the number of elements, to try + // to stay within power-of-two allocations. + // The allocation has kRepHeaderSize + sizeof(T) * capacity. + int doubled_size = 2 * total_size + kRepHeaderSize / sizeof(T); + return std::max(doubled_size, new_size); } } // namespace internal @@ -908,8 +929,11 @@ void RepeatedField<Element>::Reserve(int new_size) { if (total_size_ >= new_size) return; Rep* old_rep = total_size_ > 0 ? rep() : nullptr; Rep* new_rep; - Arena* arena = GetArena(); - new_size = internal::CalculateReserveSize(total_size_, new_size); + Arena* arena = GetOwningArena(); + + new_size = internal::CalculateReserveSize<Element, kRepHeaderSize>( + total_size_, new_size); + GOOGLE_DCHECK_LE( static_cast<size_t>(new_size), (std::numeric_limits<size_t>::max() - kRepHeaderSize) / sizeof(Element)) @@ -928,7 +952,7 @@ void RepeatedField<Element>::Reserve(int new_size) { // total_size_ == 0 || // total_size_ >= internal::kMinRepeatedFieldAllocationSize total_size_ = new_size; - arena_or_elements_ = new_rep->elements; + arena_or_elements_ = new_rep->elements(); // Invoke placement-new on newly allocated elements. We shouldn't have to do // this, since Element is supposed to be POD, but a previous version of this // code allocated storage with "new Element[size]" and some code uses @@ -944,11 +968,11 @@ void RepeatedField<Element>::Reserve(int new_size) { new (e) Element; } if (current_size_ > 0) { - MoveArray(&elements()[0], old_rep->elements, current_size_); + MoveArray(&elements()[0], old_rep->elements(), current_size_); } // Likewise, we need to invoke destructors on the old array. - InternalDeallocate(old_rep, old_total_size); + InternalDeallocate(old_rep, old_total_size, false); } @@ -1003,6 +1027,130 @@ struct ElementCopier<Element, true> { // Ported by johannes from util/gtl/proto-array-iterators.h namespace internal { + +// STL-like iterator implementation for RepeatedField. You should not +// refer to this class directly; use RepeatedField<T>::iterator instead. +// +// Note: All of the iterator operators *must* be inlined to avoid performance +// regressions. This is caused by the extern template declarations below (which +// are required because of the RepeatedField extern template declarations). If +// any of these functions aren't explicitly inlined (e.g. defined in the class), +// the compiler isn't allowed to inline them. +template <typename Element> +class RepeatedIterator { + public: + using iterator_category = std::random_access_iterator_tag; + // Note: remove_const is necessary for std::partial_sum, which uses value_type + // to determine the summation variable type. + using value_type = typename std::remove_const<Element>::type; + using difference_type = std::ptrdiff_t; + using pointer = Element*; + using reference = Element&; + + constexpr RepeatedIterator() noexcept : it_(nullptr) {} + + // Allows "upcasting" from RepeatedIterator<T**> to + // RepeatedIterator<const T*const*>. + template <typename OtherElement, + typename std::enable_if<std::is_convertible< + OtherElement*, pointer>::value>::type* = nullptr> + constexpr RepeatedIterator( + const RepeatedIterator<OtherElement>& other) noexcept + : it_(other.it_) {} + + // dereferenceable + constexpr reference operator*() const noexcept { return *it_; } + constexpr pointer operator->() const noexcept { return it_; } + + private: + // Helper alias to hide the internal type. + using iterator = RepeatedIterator<Element>; + + public: + // {inc,dec}rementable + iterator& operator++() noexcept { + ++it_; + return *this; + } + iterator operator++(int) noexcept { return iterator(it_++); } + iterator& operator--() noexcept { + --it_; + return *this; + } + iterator operator--(int) noexcept { return iterator(it_--); } + + // equality_comparable + friend constexpr bool operator==(const iterator& x, + const iterator& y) noexcept { + return x.it_ == y.it_; + } + friend constexpr bool operator!=(const iterator& x, + const iterator& y) noexcept { + return x.it_ != y.it_; + } + + // less_than_comparable + friend constexpr bool operator<(const iterator& x, + const iterator& y) noexcept { + return x.it_ < y.it_; + } + friend constexpr bool operator<=(const iterator& x, + const iterator& y) noexcept { + return x.it_ <= y.it_; + } + friend constexpr bool operator>(const iterator& x, + const iterator& y) noexcept { + return x.it_ > y.it_; + } + friend constexpr bool operator>=(const iterator& x, + const iterator& y) noexcept { + return x.it_ >= y.it_; + } + + // addable, subtractable + iterator& operator+=(difference_type d) noexcept { + it_ += d; + return *this; + } + constexpr iterator operator+(difference_type d) const noexcept { + return iterator(it_ + d); + } + friend constexpr iterator operator+(const difference_type d, + iterator it) noexcept { + return it + d; + } + + iterator& operator-=(difference_type d) noexcept { + it_ -= d; + return *this; + } + iterator constexpr operator-(difference_type d) const noexcept { + return iterator(it_ - d); + } + + // indexable + constexpr reference operator[](difference_type d) const noexcept { + return it_[d]; + } + + // random access iterator + friend constexpr difference_type operator-(iterator it1, + iterator it2) noexcept { + return it1.it_ - it2.it_; + } + + private: + template <typename OtherElement> + friend class RepeatedIterator; + + // Allow construction from RepeatedField. + friend class RepeatedField<value_type>; + explicit RepeatedIterator(Element* it) noexcept : it_(it) {} + + // The internal iterator. + Element* it_; +}; + // A back inserter for RepeatedField objects. template <typename T> class RepeatedFieldBackInsertIterator { @@ -1049,6 +1197,20 @@ extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<uint64_t>; extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<float>; extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<double>; +namespace internal { +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedIterator<bool>; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE + RepeatedIterator<int32_t>; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE + RepeatedIterator<uint32_t>; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE + RepeatedIterator<int64_t>; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE + RepeatedIterator<uint64_t>; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedIterator<float>; +extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedIterator<double>; +} // namespace internal + } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/repeated_field_reflection_unittest.cc b/r5dev/thirdparty/protobuf/repeated_field_reflection_unittest.cc index 9bafb157..40a9e26b 100644 --- a/r5dev/thirdparty/protobuf/repeated_field_reflection_unittest.cc +++ b/r5dev/thirdparty/protobuf/repeated_field_reflection_unittest.cc @@ -34,12 +34,11 @@ // This test proto2 methods on a proto2 layout. #include <thirdparty/protobuf/stubs/casts.h> -#include <thirdparty/protobuf/stubs/stringprintf.h> -#include <thirdparty/protobuf/test_util.h> #include <thirdparty/protobuf/unittest.pb.h> #include <thirdparty/protobuf/dynamic_message.h> #include <thirdparty/protobuf/reflection.h> #include <gtest/gtest.h> +#include <thirdparty/protobuf/test_util.h> namespace google { namespace protobuf { @@ -77,14 +76,14 @@ TEST(RepeatedFieldReflectionTest, RegularFields) { desc->FindFieldByName("repeated_foreign_message"); // Get RepeatedField objects for all fields of interest. - const RepeatedField<int32>& rf_int32 = - refl->GetRepeatedField<int32>(message, fd_repeated_int32); + const RepeatedField<int32_t>& rf_int32 = + refl->GetRepeatedField<int32_t>(message, fd_repeated_int32); const RepeatedField<double>& rf_double = refl->GetRepeatedField<double>(message, fd_repeated_double); // Get mutable RepeatedField objects for all fields of interest. - RepeatedField<int32>* mrf_int32 = - refl->MutableRepeatedField<int32>(&message, fd_repeated_int32); + RepeatedField<int32_t>* mrf_int32 = + refl->MutableRepeatedField<int32_t>(&message, fd_repeated_int32); RepeatedField<double>* mrf_double = refl->MutableRepeatedField<double>(&message, fd_repeated_double); @@ -142,7 +141,7 @@ TEST(RepeatedFieldReflectionTest, RegularFields) { // Make sure types are checked correctly at runtime. const FieldDescriptor* fd_optional_int32 = desc->FindFieldByName("optional_int32"); - EXPECT_DEATH(refl->GetRepeatedField<int32>(message, fd_optional_int32), + EXPECT_DEATH(refl->GetRepeatedField<int32_t>(message, fd_optional_int32), "requires a repeated field"); EXPECT_DEATH(refl->GetRepeatedField<double>(message, fd_repeated_int32), "not the right type"); @@ -167,12 +166,13 @@ TEST(RepeatedFieldReflectionTest, ExtensionFields) { desc->file()->FindExtensionByName("repeated_int64_extension"); GOOGLE_CHECK(fd_repeated_int64_extension != nullptr); - const RepeatedField<int64>& rf_int64_extension = - refl->GetRepeatedField<int64>(extended_message, - fd_repeated_int64_extension); + const RepeatedField<int64_t>& rf_int64_extension = + refl->GetRepeatedField<int64_t>(extended_message, + fd_repeated_int64_extension); - RepeatedField<int64>* mrf_int64_extension = refl->MutableRepeatedField<int64>( - &extended_message, fd_repeated_int64_extension); + RepeatedField<int64_t>* mrf_int64_extension = + refl->MutableRepeatedField<int64_t>(&extended_message, + fd_repeated_int64_extension); for (int i = 0; i < 10; ++i) { EXPECT_EQ(Func(i, 1), rf_int64_extension.Get(i)); @@ -234,8 +234,8 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForRegularFields) { desc->FindFieldByName("repeated_foreign_message"); // Get RepeatedFieldRef objects for all fields of interest. - const RepeatedFieldRef<int32> rf_int32 = - refl->GetRepeatedFieldRef<int32>(message, fd_repeated_int32); + const RepeatedFieldRef<int32_t> rf_int32 = + refl->GetRepeatedFieldRef<int32_t>(message, fd_repeated_int32); const RepeatedFieldRef<double> rf_double = refl->GetRepeatedFieldRef<double>(message, fd_repeated_double); const RepeatedFieldRef<std::string> rf_string = @@ -247,8 +247,8 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForRegularFields) { refl->GetRepeatedFieldRef<Message>(message, fd_repeated_foreign_message); // Get MutableRepeatedFieldRef objects for all fields of interest. - const MutableRepeatedFieldRef<int32> mrf_int32 = - refl->GetMutableRepeatedFieldRef<int32>(&message, fd_repeated_int32); + const MutableRepeatedFieldRef<int32_t> mrf_int32 = + refl->GetMutableRepeatedFieldRef<int32_t>(&message, fd_repeated_int32); const MutableRepeatedFieldRef<double> mrf_double = refl->GetMutableRepeatedFieldRef<double>(&message, fd_repeated_double); const MutableRepeatedFieldRef<std::string> mrf_string = @@ -425,7 +425,7 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForRegularFields) { // Make sure types are checked correctly at runtime. const FieldDescriptor* fd_optional_int32 = desc->FindFieldByName("optional_int32"); - EXPECT_DEATH(refl->GetRepeatedFieldRef<int32>(message, fd_optional_int32), + EXPECT_DEATH(refl->GetRepeatedFieldRef<int32_t>(message, fd_optional_int32), ""); EXPECT_DEATH(refl->GetRepeatedFieldRef<double>(message, fd_repeated_int32), ""); @@ -453,11 +453,11 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForEnums) { const MutableRepeatedFieldRef<TestAllTypes::NestedEnum> mutable_enum_ref = refl->GetMutableRepeatedFieldRef<TestAllTypes::NestedEnum>( &message, fd_repeated_nested_enum); - const RepeatedFieldRef<int32> int32_ref = - refl->GetRepeatedFieldRef<int32>(message, fd_repeated_nested_enum); - const MutableRepeatedFieldRef<int32> mutable_int32_ref = - refl->GetMutableRepeatedFieldRef<int32>(&message, - fd_repeated_nested_enum); + const RepeatedFieldRef<int32_t> int32_ref = + refl->GetRepeatedFieldRef<int32_t>(message, fd_repeated_nested_enum); + const MutableRepeatedFieldRef<int32_t> mutable_int32_ref = + refl->GetMutableRepeatedFieldRef<int32_t>(&message, + fd_repeated_nested_enum); EXPECT_EQ(message.repeated_nested_enum_size(), enum_ref.size()); EXPECT_EQ(message.repeated_nested_enum_size(), mutable_enum_ref.size()); @@ -540,13 +540,13 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForExtensionFields) { desc->file()->FindExtensionByName("repeated_int64_extension"); GOOGLE_CHECK(fd_repeated_int64_extension != nullptr); - const RepeatedFieldRef<int64> rf_int64_extension = - refl->GetRepeatedFieldRef<int64>(extended_message, - fd_repeated_int64_extension); + const RepeatedFieldRef<int64_t> rf_int64_extension = + refl->GetRepeatedFieldRef<int64_t>(extended_message, + fd_repeated_int64_extension); - const MutableRepeatedFieldRef<int64> mrf_int64_extension = - refl->GetMutableRepeatedFieldRef<int64>(&extended_message, - fd_repeated_int64_extension); + const MutableRepeatedFieldRef<int64_t> mrf_int64_extension = + refl->GetMutableRepeatedFieldRef<int64_t>(&extended_message, + fd_repeated_int64_extension); for (int i = 0; i < 10; ++i) { EXPECT_EQ(Func(i, 1), rf_int64_extension.Get(i)); @@ -594,8 +594,8 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefMergeFromAndSwap) { desc->FindFieldByName("repeated_nested_enum"); // Get MutableRepeatedFieldRef objects for all fields of interest. - const MutableRepeatedFieldRef<int32> mrf_int32 = - refl->GetMutableRepeatedFieldRef<int32>(&m0, fd_repeated_int32); + const MutableRepeatedFieldRef<int32_t> mrf_int32 = + refl->GetMutableRepeatedFieldRef<int32_t>(&m0, fd_repeated_int32); const MutableRepeatedFieldRef<double> mrf_double = refl->GetMutableRepeatedFieldRef<double>(&m0, fd_repeated_double); const MutableRepeatedFieldRef<std::string> mrf_string = @@ -608,7 +608,7 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefMergeFromAndSwap) { &m0, fd_repeated_nested_enum); // Test MutableRepeatedRef::CopyFrom - mrf_int32.CopyFrom(refl->GetRepeatedFieldRef<int32>(m1, fd_repeated_int32)); + mrf_int32.CopyFrom(refl->GetRepeatedFieldRef<int32_t>(m1, fd_repeated_int32)); mrf_double.CopyFrom( refl->GetRepeatedFieldRef<double>(m1, fd_repeated_double)); mrf_string.CopyFrom( @@ -626,7 +626,8 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefMergeFromAndSwap) { } // Test MutableRepeatedRef::MergeFrom - mrf_int32.MergeFrom(refl->GetRepeatedFieldRef<int32>(m2, fd_repeated_int32)); + mrf_int32.MergeFrom( + refl->GetRepeatedFieldRef<int32_t>(m2, fd_repeated_int32)); mrf_double.MergeFrom( refl->GetRepeatedFieldRef<double>(m2, fd_repeated_double)); mrf_string.MergeFrom( @@ -646,7 +647,7 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefMergeFromAndSwap) { // Test MutableRepeatedRef::Swap // Swap between m0 and m2. mrf_int32.Swap( - refl->GetMutableRepeatedFieldRef<int32>(&m2, fd_repeated_int32)); + refl->GetMutableRepeatedFieldRef<int32_t>(&m2, fd_repeated_int32)); mrf_double.Swap( refl->GetMutableRepeatedFieldRef<double>(&m2, fd_repeated_double)); mrf_string.Swap( @@ -694,9 +695,9 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefDynamicMessage) { std::unique_ptr<Message> dynamic_message(factory.GetPrototype(desc)->New()); const Reflection* refl = dynamic_message->GetReflection(); - MutableRepeatedFieldRef<int32> rf_int32 = - refl->GetMutableRepeatedFieldRef<int32>(dynamic_message.get(), - fd_repeated_int32); + MutableRepeatedFieldRef<int32_t> rf_int32 = + refl->GetMutableRepeatedFieldRef<int32_t>(dynamic_message.get(), + fd_repeated_int32); rf_int32.Add(1234); EXPECT_EQ(1, refl->FieldSize(*dynamic_message, fd_repeated_int32)); EXPECT_EQ(1234, diff --git a/r5dev/thirdparty/protobuf/repeated_field_unittest.cc b/r5dev/thirdparty/protobuf/repeated_field_unittest.cc index 1cd0dae6..3da428fe 100644 --- a/r5dev/thirdparty/protobuf/repeated_field_unittest.cc +++ b/r5dev/thirdparty/protobuf/repeated_field_unittest.cc @@ -43,6 +43,7 @@ #include <limits> #include <list> #include <sstream> +#include <string> #include <type_traits> #include <vector> @@ -63,7 +64,10 @@ namespace protobuf { namespace { using ::protobuf_unittest::TestAllTypes; +using ::testing::AllOf; using ::testing::ElementsAre; +using ::testing::Ge; +using ::testing::Le; TEST(RepeatedField, ConstInit) { PROTOBUF_CONSTINIT static RepeatedField<int> field{}; // NOLINT @@ -123,7 +127,10 @@ TEST(RepeatedField, Small) { EXPECT_TRUE(field.empty()); EXPECT_EQ(field.size(), 0); // Additional bytes are for 'struct Rep' header. - int expected_usage = 4 * sizeof(int) + sizeof(Arena*); + int expected_usage = + (sizeof(Arena*) > sizeof(int) ? sizeof(Arena*) / sizeof(int) : 3) * + sizeof(int) + + sizeof(Arena*); EXPECT_GE(field.SpaceUsedExcludingSelf(), expected_usage); } @@ -148,6 +155,85 @@ TEST(RepeatedField, Large) { EXPECT_GE(field.SpaceUsedExcludingSelf(), expected_usage); } +template <typename Rep> +void CheckAllocationSizes(bool is_ptr) { + using T = typename Rep::value_type; + // Use a large initial block to make the checks below easier to predict. + std::string buf(1 << 20, 0); + + Arena arena(&buf[0], buf.size()); + auto* rep = Arena::CreateMessage<Rep>(&arena); + size_t prev = arena.SpaceUsed(); + + for (int i = 0; i < 100; ++i) { + rep->Add(T{}); + if (sizeof(void*) == 8) { + // For RepeatedPtrField we also allocate the T in the arena. + // Subtract those from the count. + size_t new_used = arena.SpaceUsed() - (is_ptr ? sizeof(T) * (i + 1) : 0); + size_t last_alloc = new_used - prev; + prev = new_used; + + // When we actually allocated something, check the size. + if (last_alloc != 0) { + // Must be `>= 16`, as expected by the Arena. + ASSERT_GE(last_alloc, 16); + // Must be of a power of two. + size_t log2 = Bits::Log2FloorNonZero64(last_alloc); + ASSERT_EQ((1 << log2), last_alloc); + } + + // The byte size must be a multiple of 8. + ASSERT_EQ(rep->Capacity() * sizeof(T) % 8, 0); + } + } +} + +TEST(RepeatedField, ArenaAllocationSizesMatchExpectedValues) { + // RepeatedField guarantees that in 64-bit mode we never allocate anything + // smaller than 16 bytes from an arena. + // This is important to avoid a branch in the reallocation path. + // This is also important because allocating anything less would be wasting + // memory. + // If the allocation size is wrong, ReturnArrayMemory will GOOGLE_DCHECK. + CheckAllocationSizes<RepeatedField<bool>>(false); + CheckAllocationSizes<RepeatedField<uint8_t>>(false); + CheckAllocationSizes<RepeatedField<uint16_t>>(false); + CheckAllocationSizes<RepeatedField<uint32_t>>(false); + CheckAllocationSizes<RepeatedField<uint64_t>>(false); + CheckAllocationSizes<RepeatedField<std::pair<uint64_t, uint64_t>>>(false); +} + +template <typename Rep> +void CheckNaturalGrowthOnArenasReuseBlocks(bool is_ptr) { + Arena arena; + std::vector<Rep*> values; + using T = typename Rep::value_type; + + static constexpr int kNumFields = 100; + static constexpr int kNumElems = 1000; + for (int i = 0; i < kNumFields; ++i) { + values.push_back(Arena::CreateMessage<Rep>(&arena)); + auto& field = *values.back(); + for (int j = 0; j < kNumElems; ++j) { + field.Add(T{}); + } + } + + size_t used_bytes_if_reusing = + values.size() * values[0]->Capacity() * (is_ptr ? sizeof(T*) : sizeof(T)); + // Use a 2% slack for other overhead. + // If we were not reusing the blocks, the actual value would be ~2x the + // expected. + EXPECT_THAT( + arena.SpaceUsed() - (is_ptr ? sizeof(T) * kNumElems * kNumFields : 0), + AllOf(Ge(used_bytes_if_reusing), Le(1.02 * used_bytes_if_reusing))); +} + +TEST(RepeatedField, NaturalGrowthOnArenasReuseBlocks) { + CheckNaturalGrowthOnArenasReuseBlocks<RepeatedField<int>>(false); +} + // Test swapping between various types of RepeatedFields. TEST(RepeatedField, SwapSmallSmall) { RepeatedField<int> field1; @@ -287,16 +373,38 @@ TEST(RepeatedField, ReserveNothing) { } TEST(RepeatedField, ReserveLowerClamp) { - const int clamped_value = internal::CalculateReserveSize(0, 1); - EXPECT_EQ(internal::kRepeatedFieldLowerClampLimit, clamped_value); - EXPECT_EQ(clamped_value, internal::CalculateReserveSize(clamped_value, 2)); + int clamped_value = internal::CalculateReserveSize<bool, sizeof(void*)>(0, 1); + EXPECT_GE(clamped_value, 8 / sizeof(bool)); + EXPECT_EQ((internal::RepeatedFieldLowerClampLimit<bool, sizeof(void*)>()), + clamped_value); + // EXPECT_EQ(clamped_value, (internal::CalculateReserveSize<bool, + // sizeof(void*)>( clamped_value, 2))); + + clamped_value = internal::CalculateReserveSize<int, sizeof(void*)>(0, 1); + EXPECT_GE(clamped_value, 8 / sizeof(int)); + EXPECT_EQ((internal::RepeatedFieldLowerClampLimit<int, sizeof(void*)>()), + clamped_value); + // EXPECT_EQ(clamped_value, (internal::CalculateReserveSize<int, + // sizeof(void*)>( clamped_value, 2))); } TEST(RepeatedField, ReserveGrowth) { // Make sure the field capacity doubles in size on repeated reservation. - for (int size = internal::kRepeatedFieldLowerClampLimit, i = 0; i < 4; - ++i, size *= 2) { - EXPECT_EQ(size * 2, internal::CalculateReserveSize(size, size + 1)); + for (int size = internal::RepeatedFieldLowerClampLimit<int, sizeof(void*)>(), + i = 0; + i < 4; ++i) { + int next = + sizeof(Arena*) >= sizeof(int) + ? + // for small enough elements, we double number of total bytes + ((2 * (size * sizeof(int) + sizeof(Arena*))) - sizeof(Arena*)) / + sizeof(int) + : + // we just double the number of elements if too large size. + size * 2; + EXPECT_EQ(next, (internal::CalculateReserveSize<int, sizeof(void*)>( + size, size + 1))); + size = next; } } @@ -306,22 +414,24 @@ TEST(RepeatedField, ReserveLarge) { const int new_size = old_size * 3 + 1; // Reserving more than 2x current capacity should grow directly to that size. - EXPECT_EQ(new_size, internal::CalculateReserveSize(old_size, new_size)); + EXPECT_EQ(new_size, (internal::CalculateReserveSize<int, sizeof(void*)>( + old_size, new_size))); } TEST(RepeatedField, ReserveHuge) { // Largest value that does not clamp to the large limit: - constexpr int non_clamping_limit = std::numeric_limits<int>::max() / 2; + constexpr int non_clamping_limit = + (std::numeric_limits<int>::max() - sizeof(Arena*)) / 2; ASSERT_LT(2 * non_clamping_limit, std::numeric_limits<int>::max()); - EXPECT_LT(internal::CalculateReserveSize(non_clamping_limit, - non_clamping_limit + 1), + EXPECT_LT((internal::CalculateReserveSize<int, sizeof(void*)>( + non_clamping_limit, non_clamping_limit + 1)), std::numeric_limits<int>::max()); // Smallest size that *will* clamp to the upper limit: constexpr int min_clamping_size = std::numeric_limits<int>::max() / 2 + 1; - EXPECT_EQ( - internal::CalculateReserveSize(min_clamping_size, min_clamping_size + 1), - std::numeric_limits<int>::max()); + EXPECT_EQ((internal::CalculateReserveSize<int, sizeof(void*)>( + min_clamping_size, min_clamping_size + 1)), + std::numeric_limits<int>::max()); #ifdef PROTOBUF_TEST_ALLOW_LARGE_ALLOC // The rest of this test may allocate several GB of memory, so it is only @@ -797,12 +907,12 @@ TEST(RepeatedField, ExtractSubrange) { for (int num = 0; num <= sz; ++num) { for (int start = 0; start < sz - num; ++start) { // Create RepeatedField with sz elements having values 0 through sz-1. - RepeatedField<int32> field; + RepeatedField<int32_t> field; for (int i = 0; i < sz; ++i) field.Add(i); EXPECT_EQ(field.size(), sz); // Create a catcher array and call ExtractSubrange. - int32 catcher[10]; + int32_t catcher[10]; for (int i = 0; i < 10; ++i) catcher[i] = -1; field.ExtractSubrange(start, num, catcher); @@ -962,6 +1072,14 @@ TEST(RepeatedPtrField, Large) { EXPECT_GE(field.SpaceUsedExcludingSelf(), min_expected_usage); } +TEST(RepeatedPtrField, ArenaAllocationSizesMatchExpectedValues) { + CheckAllocationSizes<RepeatedPtrField<std::string>>(true); +} + +TEST(RepeatedPtrField, NaturalGrowthOnArenasReuseBlocks) { + CheckNaturalGrowthOnArenasReuseBlocks<RepeatedPtrField<std::string>>(true); +} + TEST(RepeatedPtrField, AddAndAssignRanges) { RepeatedPtrField<std::string> field; @@ -1193,12 +1311,12 @@ TEST(RepeatedPtrField, AddAllocated) { } field.RemoveLast(); index = field.size(); - std::string* qux = new std::string("qux"); - field.AddAllocated(qux); + std::string* moo = new std::string("moo"); + field.AddAllocated(moo); EXPECT_EQ(index + 1, field.size()); // We should have discarded the cleared object. EXPECT_EQ(0, field.ClearedCount()); - EXPECT_EQ(qux, &field.Get(index)); + EXPECT_EQ(moo, &field.Get(index)); } TEST(RepeatedPtrField, AddAllocatedDifferentArena) { @@ -1585,7 +1703,7 @@ TEST(RepeatedPtrField, DeleteSubrange) { // Iterator tests stolen from net/proto/proto-array_unittest. class RepeatedFieldIteratorTest : public testing::Test { protected: - virtual void SetUp() { + void SetUp() override { for (int i = 0; i < 3; ++i) { proto_array_.Add(i); } @@ -1621,8 +1739,8 @@ TEST_F(RepeatedFieldIteratorTest, ConstIteration) { EXPECT_EQ(1, *iter++); EXPECT_EQ(2, *iter); ++iter; - EXPECT_TRUE(proto_array_.end() == iter); - EXPECT_EQ(2, *(proto_array_.end() - 1)); + EXPECT_TRUE(const_proto_array.end() == iter); + EXPECT_EQ(2, *(const_proto_array.end() - 1)); } TEST_F(RepeatedFieldIteratorTest, Mutation) { @@ -1635,7 +1753,7 @@ TEST_F(RepeatedFieldIteratorTest, Mutation) { class RepeatedPtrFieldIteratorTest : public testing::Test { protected: - virtual void SetUp() { + void SetUp() override { proto_array_.Add()->assign("foo"); proto_array_.Add()->assign("bar"); proto_array_.Add()->assign("baz"); @@ -1666,6 +1784,7 @@ TEST_F(RepeatedPtrFieldIteratorTest, ConstIteration) { const RepeatedPtrField<std::string>& const_proto_array = proto_array_; RepeatedPtrField<std::string>::const_iterator iter = const_proto_array.begin(); + iter - const_proto_array.cbegin(); EXPECT_EQ("foo", *iter); ++iter; EXPECT_EQ("bar", *(iter++)); @@ -1711,6 +1830,23 @@ TEST_F(RepeatedPtrFieldIteratorTest, RandomAccess) { EXPECT_EQ(3, proto_array_.end() - proto_array_.begin()); } +TEST_F(RepeatedPtrFieldIteratorTest, RandomAccessConst) { + RepeatedPtrField<std::string>::const_iterator iter = proto_array_.cbegin(); + RepeatedPtrField<std::string>::const_iterator iter2 = iter; + ++iter2; + ++iter2; + EXPECT_TRUE(iter + 2 == iter2); + EXPECT_TRUE(iter == iter2 - 2); + EXPECT_EQ("baz", iter[2]); + EXPECT_EQ("baz", *(iter + 2)); + EXPECT_EQ(3, proto_array_.cend() - proto_array_.cbegin()); +} + +TEST_F(RepeatedPtrFieldIteratorTest, DifferenceConstConversion) { + EXPECT_EQ(3, proto_array_.end() - proto_array_.cbegin()); + EXPECT_EQ(3, proto_array_.cend() - proto_array_.begin()); +} + TEST_F(RepeatedPtrFieldIteratorTest, Comparable) { RepeatedPtrField<std::string>::const_iterator iter = proto_array_.begin(); RepeatedPtrField<std::string>::const_iterator iter2 = iter + 1; @@ -1724,6 +1860,22 @@ TEST_F(RepeatedPtrFieldIteratorTest, Comparable) { EXPECT_TRUE(iter >= iter); } +TEST_F(RepeatedPtrFieldIteratorTest, ComparableConstConversion) { + RepeatedPtrField<std::string>::iterator iter = proto_array_.begin(); + RepeatedPtrField<std::string>::const_iterator iter2 = iter + 1; + EXPECT_TRUE(iter == iter); + EXPECT_TRUE(iter == proto_array_.cbegin()); + EXPECT_TRUE(proto_array_.cbegin() == iter); + EXPECT_TRUE(iter != iter2); + EXPECT_TRUE(iter2 != iter); + EXPECT_TRUE(iter < iter2); + EXPECT_TRUE(iter <= iter2); + EXPECT_TRUE(iter <= iter); + EXPECT_TRUE(iter2 > iter); + EXPECT_TRUE(iter2 >= iter); + EXPECT_TRUE(iter >= iter); +} + // Uninitialized iterator does not point to any of the RepeatedPtrField. TEST_F(RepeatedPtrFieldIteratorTest, UninitializedIterator) { RepeatedPtrField<std::string>::iterator iter; @@ -1754,15 +1906,15 @@ TEST_F(RepeatedPtrFieldIteratorTest, STLAlgorithms_lower_bound) { TEST_F(RepeatedPtrFieldIteratorTest, Mutation) { RepeatedPtrField<std::string>::iterator iter = proto_array_.begin(); - *iter = "qux"; - EXPECT_EQ("qux", proto_array_.Get(0)); + *iter = "moo"; + EXPECT_EQ("moo", proto_array_.Get(0)); } // ------------------------------------------------------------------- class RepeatedPtrFieldPtrsIteratorTest : public testing::Test { protected: - virtual void SetUp() { + void SetUp() override { proto_array_.Add()->assign("foo"); proto_array_.Add()->assign("bar"); proto_array_.Add()->assign("baz"); @@ -1835,6 +1987,13 @@ TEST_F(RepeatedPtrFieldPtrsIteratorTest, RandomConstPtrAccess) { EXPECT_EQ(3, const_proto_array_->end() - const_proto_array_->begin()); } +TEST_F(RepeatedPtrFieldPtrsIteratorTest, DifferenceConstConversion) { + EXPECT_EQ(3, + proto_array_.pointer_end() - const_proto_array_->pointer_begin()); + EXPECT_EQ(3, + const_proto_array_->pointer_end() - proto_array_.pointer_begin()); +} + TEST_F(RepeatedPtrFieldPtrsIteratorTest, ComparablePtr) { RepeatedPtrField<std::string>::pointer_iterator iter = proto_array_.pointer_begin(); @@ -1863,6 +2022,23 @@ TEST_F(RepeatedPtrFieldPtrsIteratorTest, ComparableConstPtr) { EXPECT_TRUE(iter >= iter); } +TEST_F(RepeatedPtrFieldPtrsIteratorTest, ComparableConstConversion) { + RepeatedPtrField<std::string>::pointer_iterator iter = + proto_array_.pointer_begin(); + RepeatedPtrField<std::string>::const_pointer_iterator iter2 = iter + 1; + EXPECT_TRUE(iter == iter); + EXPECT_TRUE(iter == const_proto_array_->pointer_begin()); + EXPECT_TRUE(const_proto_array_->pointer_begin() == iter); + EXPECT_TRUE(iter != iter2); + EXPECT_TRUE(iter2 != iter); + EXPECT_TRUE(iter < iter2); + EXPECT_TRUE(iter <= iter2); + EXPECT_TRUE(iter <= iter); + EXPECT_TRUE(iter2 > iter); + EXPECT_TRUE(iter2 >= iter); + EXPECT_TRUE(iter >= iter); +} + // Uninitialized iterator does not point to any of the RepeatedPtrOverPtrs. // Dereferencing an uninitialized iterator crashes the process. TEST_F(RepeatedPtrFieldPtrsIteratorTest, UninitializedPtrIterator) { @@ -1931,8 +2107,8 @@ TEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrSTLAlgorithms_lower_bound) { TEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrMutation) { RepeatedPtrField<std::string>::pointer_iterator iter = proto_array_.pointer_begin(); - **iter = "qux"; - EXPECT_EQ("qux", proto_array_.Get(0)); + **iter = "moo"; + EXPECT_EQ("moo", proto_array_.Get(0)); EXPECT_EQ("bar", proto_array_.Get(1)); EXPECT_EQ("baz", proto_array_.Get(2)); @@ -1980,7 +2156,7 @@ class RepeatedFieldInsertionIteratorsTest : public testing::Test { std::vector<Nested*> nested_ptrs; TestAllTypes protobuffer; - virtual void SetUp() { + void SetUp() override { fibonacci.push_back(1); fibonacci.push_back(1); fibonacci.push_back(2); @@ -2023,7 +2199,7 @@ class RepeatedFieldInsertionIteratorsTest : public testing::Test { protobuffer.mutable_repeated_nested_message())); } - virtual void TearDown() { + void TearDown() override { for (auto ptr : nested_ptrs) { delete ptr; } @@ -2160,7 +2336,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest, MoveStrings) { } TEST_F(RepeatedFieldInsertionIteratorsTest, MoveProtos) { - auto make_nested = [](int32 x) { + auto make_nested = [](int32_t x) { Nested ret; ret.set_bb(x); return ret; diff --git a/r5dev/thirdparty/protobuf/repeated_ptr_field.cc b/r5dev/thirdparty/protobuf/repeated_ptr_field.cc index 9f721309..50b42385 100644 --- a/r5dev/thirdparty/protobuf/repeated_ptr_field.cc +++ b/r5dev/thirdparty/protobuf/repeated_ptr_field.cc @@ -32,14 +32,15 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/repeated_field.h> - #include <algorithm> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/implicit_weak_message.h> +#include <thirdparty/protobuf/repeated_field.h> +#include <thirdparty/protobuf/port.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -55,9 +56,9 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) { return &rep_->elements[current_size_]; } Rep* old_rep = rep_; - Arena* arena = GetArena(); - new_size = std::max(internal::kRepeatedFieldLowerClampLimit, - std::max(total_size_ * 2, new_size)); + Arena* arena = GetOwningArena(); + new_size = internal::CalculateReserveSize<void*, kRepHeaderSize>(total_size_, + new_size); GOOGLE_CHECK_LE(static_cast<int64_t>(new_size), static_cast<int64_t>( (std::numeric_limits<size_t>::max() - kRepHeaderSize) / @@ -69,25 +70,24 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) { } else { rep_ = reinterpret_cast<Rep*>(Arena::CreateArray<char>(arena, bytes)); } -#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) const int old_total_size = total_size_; -#endif total_size_ = new_size; - if (old_rep && old_rep->allocated_size > 0) { - memcpy(rep_->elements, old_rep->elements, - old_rep->allocated_size * sizeof(rep_->elements[0])); + if (old_rep) { + if (old_rep->allocated_size > 0) { + memcpy(rep_->elements, old_rep->elements, + old_rep->allocated_size * sizeof(rep_->elements[0])); + } rep_->allocated_size = old_rep->allocated_size; - } else { - rep_->allocated_size = 0; - } - if (arena == nullptr) { -#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) + const size_t old_size = old_total_size * sizeof(rep_->elements[0]) + kRepHeaderSize; - ::operator delete(static_cast<void*>(old_rep), old_size); -#else - ::operator delete(static_cast<void*>(old_rep)); -#endif + if (arena == nullptr) { + internal::SizedDelete(old_rep, old_size); + } else { + arena_->ReturnArrayMemory(old_rep, old_size); + } + } else { + rep_->allocated_size = 0; } return &rep_->elements[current_size_]; } @@ -106,14 +106,9 @@ void RepeatedPtrFieldBase::DestroyProtos() { for (int i = 0; i < n; i++) { delete static_cast<MessageLite*>(elements[i]); } -#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) const size_t size = total_size_ * sizeof(elements[0]) + kRepHeaderSize; - ::operator delete(static_cast<void*>(rep_), size); + internal::SizedDelete(rep_, size); rep_ = nullptr; -#else - ::operator delete(static_cast<void*>(rep_)); - rep_ = nullptr; -#endif } void* RepeatedPtrFieldBase::AddOutOfLineHelper(void* obj) { diff --git a/r5dev/thirdparty/protobuf/repeated_ptr_field.h b/r5dev/thirdparty/protobuf/repeated_ptr_field.h index 0f536339..b44894f0 100644 --- a/r5dev/thirdparty/protobuf/repeated_ptr_field.h +++ b/r5dev/thirdparty/protobuf/repeated_ptr_field.h @@ -39,16 +39,15 @@ // particularly different from STL vector as it manages ownership of the // pointers that it contains. // -// Typically, clients should not need to access RepeatedField objects directly, -// but should instead use the accessor functions generated automatically by the -// protocol compiler. -// // This header covers RepeatedPtrField. +// IWYU pragma: private, include "net/proto2/public/repeated_field.h" + #ifndef GOOGLE_PROTOBUF_REPEATED_PTR_FIELD_H__ #define GOOGLE_PROTOBUF_REPEATED_PTR_FIELD_H__ #include <utility> + #ifdef _MSC_VER // This is required for min/max on VS2013 only. #include <algorithm> @@ -62,8 +61,8 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/arena.h> -#include <thirdparty/protobuf/message_lite.h> #include <thirdparty/protobuf/port.h> +#include <thirdparty/protobuf/message_lite.h> // Must be included last. @@ -166,8 +165,14 @@ struct IsMovable // }; class PROTOBUF_EXPORT RepeatedPtrFieldBase { protected: - constexpr RepeatedPtrFieldBase(); - explicit RepeatedPtrFieldBase(Arena* arena); + constexpr RepeatedPtrFieldBase() + : arena_(nullptr), current_size_(0), total_size_(0), rep_(nullptr) {} + explicit RepeatedPtrFieldBase(Arena* arena) + : arena_(arena), current_size_(0), total_size_(0), rep_(nullptr) {} + + RepeatedPtrFieldBase(const RepeatedPtrFieldBase&) = delete; + RepeatedPtrFieldBase& operator=(const RepeatedPtrFieldBase&) = delete; + ~RepeatedPtrFieldBase() { #ifndef NDEBUG // Try to trigger segfault / asan failure in non-opt builds. If arena_ @@ -176,27 +181,84 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { #endif } - // Must be called from destructor. - template <typename TypeHandler> - void Destroy(); - bool NeedsDestroy() const { return rep_ != nullptr && arena_ == nullptr; } - void DestroyProtos(); - - bool empty() const; - int size() const; + bool empty() const { return current_size_ == 0; } + int size() const { return current_size_; } + int Capacity() const { return total_size_; } template <typename TypeHandler> - const typename TypeHandler::Type& at(int index) const; - template <typename TypeHandler> - typename TypeHandler::Type& at(int index); + const typename TypeHandler::Type& at(int index) const { + GOOGLE_CHECK_GE(index, 0); + GOOGLE_CHECK_LT(index, current_size_); + return *cast<TypeHandler>(rep_->elements[index]); + } template <typename TypeHandler> - typename TypeHandler::Type* Mutable(int index); + typename TypeHandler::Type& at(int index) { + GOOGLE_CHECK_GE(index, 0); + GOOGLE_CHECK_LT(index, current_size_); + return *cast<TypeHandler>(rep_->elements[index]); + } + template <typename TypeHandler> - void Delete(int index); + typename TypeHandler::Type* Mutable(int index) { + GOOGLE_DCHECK_GE(index, 0); + GOOGLE_DCHECK_LT(index, current_size_); + return cast<TypeHandler>(rep_->elements[index]); + } + template <typename TypeHandler> typename TypeHandler::Type* Add( - typename TypeHandler::Type* prototype = nullptr); + const typename TypeHandler::Type* prototype = nullptr) { + if (rep_ != nullptr && current_size_ < rep_->allocated_size) { + return cast<TypeHandler>(rep_->elements[current_size_++]); + } + typename TypeHandler::Type* result = + TypeHandler::NewFromPrototype(prototype, arena_); + return reinterpret_cast<typename TypeHandler::Type*>( + AddOutOfLineHelper(result)); + } + + template < + typename TypeHandler, + typename std::enable_if<TypeHandler::Movable::value>::type* = nullptr> + inline void Add(typename TypeHandler::Type&& value) { + if (rep_ != nullptr && current_size_ < rep_->allocated_size) { + *cast<TypeHandler>(rep_->elements[current_size_++]) = std::move(value); + return; + } + if (!rep_ || rep_->allocated_size == total_size_) { + Reserve(total_size_ + 1); + } + ++rep_->allocated_size; + typename TypeHandler::Type* result = + TypeHandler::New(arena_, std::move(value)); + rep_->elements[current_size_++] = result; + } + + template <typename TypeHandler> + void Delete(int index) { + GOOGLE_DCHECK_GE(index, 0); + GOOGLE_DCHECK_LT(index, current_size_); + TypeHandler::Delete(cast<TypeHandler>(rep_->elements[index]), arena_); + } + + // Must be called from destructor. + template <typename TypeHandler> + void Destroy() { + if (rep_ != nullptr && arena_ == nullptr) { + int n = rep_->allocated_size; + void* const* elements = rep_->elements; + for (int i = 0; i < n; i++) { + TypeHandler::Delete(cast<TypeHandler>(elements[i]), nullptr); + } + const size_t size = total_size_ * sizeof(elements[0]) + kRepHeaderSize; + internal::SizedDelete(rep_, size); + } + rep_ = nullptr; + } + + bool NeedsDestroy() const { return rep_ != nullptr && arena_ == nullptr; } + void DestroyProtos(); // implemented in the cc file public: // The next few methods are public so that they can be called from generated @@ -204,7 +266,11 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { // application code. template <typename TypeHandler> - const typename TypeHandler::Type& Get(int index) const; + const typename TypeHandler::Type& Get(int index) const { + GOOGLE_DCHECK_GE(index, 0); + GOOGLE_DCHECK_LT(index, current_size_); + return *cast<TypeHandler>(rep_->elements[index]); + } // Creates and adds an element using the given prototype, without introducing // a link-time dependency on the concrete message type. This method is used to @@ -213,29 +279,61 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { MessageLite* AddWeak(const MessageLite* prototype); template <typename TypeHandler> - void Clear(); + void Clear() { + const int n = current_size_; + GOOGLE_DCHECK_GE(n, 0); + if (n > 0) { + void* const* elements = rep_->elements; + int i = 0; + do { + TypeHandler::Clear(cast<TypeHandler>(elements[i++])); + } while (i < n); + current_size_ = 0; + } + } template <typename TypeHandler> - void MergeFrom(const RepeatedPtrFieldBase& other); + void MergeFrom(const RepeatedPtrFieldBase& other) { + // To avoid unnecessary code duplication and reduce binary size, we use a + // layered approach to implementing MergeFrom(). The toplevel method is + // templated, so we get a small thunk per concrete message type in the + // binary. This calls a shared implementation with most of the logic, + // passing a function pointer to another type-specific piece of code that + // calls the object-allocate and merge handlers. + GOOGLE_DCHECK_NE(&other, this); + if (other.current_size_ == 0) return; + MergeFromInternal(other, + &RepeatedPtrFieldBase::MergeFromInnerLoop<TypeHandler>); + } - inline void InternalSwap(RepeatedPtrFieldBase*); + inline void InternalSwap(RepeatedPtrFieldBase* rhs) { + GOOGLE_DCHECK(this != rhs); + + // Swap all fields at once. + auto temp = std::make_tuple(rhs->arena_, rhs->current_size_, + rhs->total_size_, rhs->rep_); + std::tie(rhs->arena_, rhs->current_size_, rhs->total_size_, rhs->rep_) = + std::make_tuple(arena_, current_size_, total_size_, rep_); + std::tie(arena_, current_size_, total_size_, rep_) = temp; + } protected: - template < - typename TypeHandler, - typename std::enable_if<TypeHandler::Movable::value>::type* = nullptr> - void Add(typename TypeHandler::Type&& value); + template <typename TypeHandler> + void RemoveLast() { + GOOGLE_DCHECK_GT(current_size_, 0); + TypeHandler::Clear(cast<TypeHandler>(rep_->elements[--current_size_])); + } template <typename TypeHandler> - void RemoveLast(); - template <typename TypeHandler> - void CopyFrom(const RepeatedPtrFieldBase& other); + void CopyFrom(const RepeatedPtrFieldBase& other) { + if (&other == this) return; + RepeatedPtrFieldBase::Clear<TypeHandler>(); + RepeatedPtrFieldBase::MergeFrom<TypeHandler>(other); + } - void CloseGap(int start, int num); + void CloseGap(int start, int num); // implemented in the cc file - void Reserve(int new_size); - - int Capacity() const; + void Reserve(int new_size); // implemented in the cc file template <typename TypeHandler> static inline typename TypeHandler::Type* copy( @@ -246,27 +344,70 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { } // Used for constructing iterators. - void* const* raw_data() const; - void** raw_mutable_data() const; + void* const* raw_data() const { return rep_ ? rep_->elements : nullptr; } + void** raw_mutable_data() const { + return rep_ ? const_cast<void**>(rep_->elements) : nullptr; + } template <typename TypeHandler> - typename TypeHandler::Type** mutable_data(); - template <typename TypeHandler> - const typename TypeHandler::Type* const* data() const; + typename TypeHandler::Type** mutable_data() { + // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this + // method entirely. + return reinterpret_cast<typename TypeHandler::Type**>(raw_mutable_data()); + } template <typename TypeHandler> - PROTOBUF_NDEBUG_INLINE void Swap(RepeatedPtrFieldBase* other); - - void SwapElements(int index1, int index2); + const typename TypeHandler::Type* const* data() const { + // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this + // method entirely. + return reinterpret_cast<const typename TypeHandler::Type* const*>( + raw_data()); + } template <typename TypeHandler> - size_t SpaceUsedExcludingSelfLong() const; + PROTOBUF_NDEBUG_INLINE void Swap(RepeatedPtrFieldBase* other) { +#ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) +#else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) +#endif // !PROTOBUF_FORCE_COPY_IN_SWAP + { + InternalSwap(other); + } else { + SwapFallback<TypeHandler>(other); + } + } + + void SwapElements(int index1, int index2) { + using std::swap; // enable ADL with fallback + swap(rep_->elements[index1], rep_->elements[index2]); + } + + template <typename TypeHandler> + size_t SpaceUsedExcludingSelfLong() const { + size_t allocated_bytes = static_cast<size_t>(total_size_) * sizeof(void*); + if (rep_ != nullptr) { + for (int i = 0; i < rep_->allocated_size; ++i) { + allocated_bytes += + TypeHandler::SpaceUsedLong(*cast<TypeHandler>(rep_->elements[i])); + } + allocated_bytes += kRepHeaderSize; + } + return allocated_bytes; + } // Advanced memory management -------------------------------------- // Like Add(), but if there are no cleared objects to use, returns nullptr. template <typename TypeHandler> - typename TypeHandler::Type* AddFromCleared(); + typename TypeHandler::Type* AddFromCleared() { + if (rep_ != nullptr && current_size_ < rep_->allocated_size) { + return cast<TypeHandler>(rep_->elements[current_size_++]); + } else { + return nullptr; + } + } template <typename TypeHandler> void AddAllocated(typename TypeHandler::Type* value) { @@ -275,7 +416,31 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { } template <typename TypeHandler> - void UnsafeArenaAddAllocated(typename TypeHandler::Type* value); + void UnsafeArenaAddAllocated(typename TypeHandler::Type* value) { + // Make room for the new pointer. + if (!rep_ || current_size_ == total_size_) { + // The array is completely full with no cleared objects, so grow it. + Reserve(total_size_ + 1); + ++rep_->allocated_size; + } else if (rep_->allocated_size == total_size_) { + // There is no more space in the pointer array because it contains some + // cleared objects awaiting reuse. We don't want to grow the array in + // this case because otherwise a loop calling AddAllocated() followed by + // Clear() would leak memory. + TypeHandler::Delete(cast<TypeHandler>(rep_->elements[current_size_]), + arena_); + } else if (current_size_ < rep_->allocated_size) { + // We have some cleared objects. We don't care about their order, so we + // can just move the first one to the end to make space. + rep_->elements[rep_->allocated_size] = rep_->elements[current_size_]; + ++rep_->allocated_size; + } else { + // There are no cleared objects. + ++rep_->allocated_size; + } + + rep_->elements[current_size_++] = value; + } template <typename TypeHandler> PROTOBUF_NODISCARD typename TypeHandler::Type* ReleaseLast() { @@ -283,51 +448,189 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { return ReleaseLastInternal<TypeHandler>(t); } - // Releases last element and returns it, but does not do out-of-arena copy. - // And just returns the raw pointer to the contained element in the arena. + // Releases and returns the last element, but does not do out-of-arena copy. + // Instead, just returns the raw pointer to the contained element in the + // arena. template <typename TypeHandler> - typename TypeHandler::Type* UnsafeArenaReleaseLast(); + typename TypeHandler::Type* UnsafeArenaReleaseLast() { + GOOGLE_DCHECK_GT(current_size_, 0); + typename TypeHandler::Type* result = + cast<TypeHandler>(rep_->elements[--current_size_]); + --rep_->allocated_size; + if (current_size_ < rep_->allocated_size) { + // There are cleared elements on the end; replace the removed element + // with the last allocated element. + rep_->elements[current_size_] = rep_->elements[rep_->allocated_size]; + } + return result; + } - int ClearedCount() const; - template <typename TypeHandler> - void AddCleared(typename TypeHandler::Type* value); - template <typename TypeHandler> - PROTOBUF_NODISCARD typename TypeHandler::Type* ReleaseCleared(); + int ClearedCount() const { + return rep_ ? (rep_->allocated_size - current_size_) : 0; + } template <typename TypeHandler> - void AddAllocatedInternal(typename TypeHandler::Type* value, std::true_type); - template <typename TypeHandler> - void AddAllocatedInternal(typename TypeHandler::Type* value, std::false_type); + void AddCleared(typename TypeHandler::Type* value) { + GOOGLE_DCHECK(GetOwningArena() == nullptr) << "AddCleared() can only be used on a " + "RepeatedPtrField not on an arena."; + GOOGLE_DCHECK(TypeHandler::GetOwningArena(value) == nullptr) + << "AddCleared() can only accept values not on an arena."; + if (!rep_ || rep_->allocated_size == total_size_) { + Reserve(total_size_ + 1); + } + rep_->elements[rep_->allocated_size++] = value; + } + template <typename TypeHandler> + PROTOBUF_NODISCARD typename TypeHandler::Type* ReleaseCleared() { + GOOGLE_DCHECK(GetOwningArena() == nullptr) + << "ReleaseCleared() can only be used on a RepeatedPtrField not on " + << "an arena."; + GOOGLE_DCHECK(GetOwningArena() == nullptr); + GOOGLE_DCHECK(rep_ != nullptr); + GOOGLE_DCHECK_GT(rep_->allocated_size, current_size_); + return cast<TypeHandler>(rep_->elements[--rep_->allocated_size]); + } + + template <typename TypeHandler> + void AddAllocatedInternal(typename TypeHandler::Type* value, std::true_type) { + // AddAllocated version that implements arena-safe copying behavior. + Arena* element_arena = + reinterpret_cast<Arena*>(TypeHandler::GetOwningArena(value)); + Arena* arena = GetOwningArena(); + if (arena == element_arena && rep_ && rep_->allocated_size < total_size_) { + // Fast path: underlying arena representation (tagged pointer) is equal to + // our arena pointer, and we can add to array without resizing it (at + // least one slot that is not allocated). + void** elems = rep_->elements; + if (current_size_ < rep_->allocated_size) { + // Make space at [current] by moving first allocated element to end of + // allocated list. + elems[rep_->allocated_size] = elems[current_size_]; + } + elems[current_size_] = value; + current_size_ = current_size_ + 1; + rep_->allocated_size = rep_->allocated_size + 1; + } else { + AddAllocatedSlowWithCopy<TypeHandler>(value, element_arena, arena); + } + } + + template <typename TypeHandler> + void AddAllocatedInternal( + // AddAllocated version that does not implement arena-safe copying + // behavior. + typename TypeHandler::Type* value, std::false_type) { + if (rep_ && rep_->allocated_size < total_size_) { + // Fast path: underlying arena representation (tagged pointer) is equal to + // our arena pointer, and we can add to array without resizing it (at + // least one slot that is not allocated). + void** elems = rep_->elements; + if (current_size_ < rep_->allocated_size) { + // Make space at [current] by moving first allocated element to end of + // allocated list. + elems[rep_->allocated_size] = elems[current_size_]; + } + elems[current_size_] = value; + current_size_ = current_size_ + 1; + ++rep_->allocated_size; + } else { + UnsafeArenaAddAllocated<TypeHandler>(value); + } + } + + // Slowpath handles all cases, copying if necessary. template <typename TypeHandler> PROTOBUF_NOINLINE void AddAllocatedSlowWithCopy( - typename TypeHandler::Type* value, Arena* value_arena, Arena* my_arena); - template <typename TypeHandler> - PROTOBUF_NOINLINE void AddAllocatedSlowWithoutCopy( - typename TypeHandler::Type* value); + // Pass value_arena and my_arena to avoid duplicate virtual call (value) + // or load (mine). + typename TypeHandler::Type* value, Arena* value_arena, Arena* my_arena) { + // Ensure that either the value is in the same arena, or if not, we do the + // appropriate thing: Own() it (if it's on heap and we're in an arena) or + // copy it to our arena/heap (otherwise). + if (my_arena != nullptr && value_arena == nullptr) { + my_arena->Own(value); + } else if (my_arena != value_arena) { + typename TypeHandler::Type* new_value = + TypeHandler::NewFromPrototype(value, my_arena); + TypeHandler::Merge(*value, new_value); + TypeHandler::Delete(value, value_arena); + value = new_value; + } + + UnsafeArenaAddAllocated<TypeHandler>(value); + } template <typename TypeHandler> - typename TypeHandler::Type* ReleaseLastInternal(std::true_type); - template <typename TypeHandler> - typename TypeHandler::Type* ReleaseLastInternal(std::false_type); + typename TypeHandler::Type* ReleaseLastInternal(std::true_type) { + // ReleaseLast() for types that implement merge/copy behavior. + // First, release an element. + typename TypeHandler::Type* result = UnsafeArenaReleaseLast<TypeHandler>(); + // Now perform a copy if we're on an arena. + Arena* arena = GetOwningArena(); + + typename TypeHandler::Type* new_result; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + new_result = copy<TypeHandler>(result); + if (arena == nullptr) delete result; +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + new_result = (arena == nullptr) ? result : copy<TypeHandler>(result); +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return new_result; + } template <typename TypeHandler> - PROTOBUF_NOINLINE void SwapFallback(RepeatedPtrFieldBase* other); + typename TypeHandler::Type* ReleaseLastInternal(std::false_type) { + // ReleaseLast() for types that *do not* implement merge/copy behavior -- + // this is the same as UnsafeArenaReleaseLast(). Note that we GOOGLE_DCHECK-fail if + // we're on an arena, since the user really should implement the copy + // operation in this case. + GOOGLE_DCHECK(GetOwningArena() == nullptr) + << "ReleaseLast() called on a RepeatedPtrField that is on an arena, " + << "with a type that does not implement MergeFrom. This is unsafe; " + << "please implement MergeFrom for your type."; + return UnsafeArenaReleaseLast<TypeHandler>(); + } + + template <typename TypeHandler> + PROTOBUF_NOINLINE void SwapFallback(RepeatedPtrFieldBase* other) { +#ifdef PROTOBUF_FORCE_COPY_IN_SWAP + GOOGLE_DCHECK(GetOwningArena() == nullptr || + other->GetOwningArena() != GetOwningArena()); +#else // PROTOBUF_FORCE_COPY_IN_SWAP + GOOGLE_DCHECK(other->GetOwningArena() != GetOwningArena()); +#endif // !PROTOBUF_FORCE_COPY_IN_SWAP + + // Copy semantics in this case. We try to improve efficiency by placing the + // temporary on |other|'s arena so that messages are copied twice rather + // than three times. + RepeatedPtrFieldBase temp(other->GetOwningArena()); + temp.MergeFrom<TypeHandler>(*this); + this->Clear<TypeHandler>(); + this->MergeFrom<TypeHandler>(*other); + other->InternalSwap(&temp); + temp.Destroy<TypeHandler>(); // Frees rep_ if `other` had no arena. + } inline Arena* GetArena() const { return arena_; } + protected: + inline Arena* GetOwningArena() const { return arena_; } + private: + template <typename T> friend class Arena::InternalHelper; + static constexpr int kInitialSize = 0; // A few notes on internal representation: // // We use an indirected approach, with struct Rep, to keep // sizeof(RepeatedPtrFieldBase) equivalent to what it was before arena support - // was added, namely, 3 8-byte machine words on x86-64. An instance of Rep is + // was added; namely, 3 8-byte machine words on x86-64. An instance of Rep is // allocated only when the repeated field is non-empty, and it is a // dynamically-sized struct (the header is directly followed by elements[]). // We place arena_ and current_size_ directly in the object to avoid cache // misses due to the indirection, because these fields are checked frequently. - // Placing all fields directly in the RepeatedPtrFieldBase instance costs + // Placing all fields directly in the RepeatedPtrFieldBase instance would cost // significant performance for memory-sensitive workloads. Arena* arena_; int current_size_; @@ -356,20 +659,55 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { void MergeFromInternal(const RepeatedPtrFieldBase& other, void (RepeatedPtrFieldBase::*inner_loop)(void**, void**, int, - int)); + int)) { + // Note: wrapper has already guaranteed that other.rep_ != nullptr here. + int other_size = other.current_size_; + void** other_elements = other.rep_->elements; + void** new_elements = InternalExtend(other_size); + int allocated_elems = rep_->allocated_size - current_size_; + (this->*inner_loop)(new_elements, other_elements, other_size, + allocated_elems); + current_size_ += other_size; + if (rep_->allocated_size < current_size_) { + rep_->allocated_size = current_size_; + } + } + // Merges other_elems to our_elems. template <typename TypeHandler> PROTOBUF_NOINLINE void MergeFromInnerLoop(void** our_elems, void** other_elems, int length, - int already_allocated); + int already_allocated) { + if (already_allocated < length) { + Arena* arena = GetOwningArena(); + typename TypeHandler::Type* elem_prototype = + reinterpret_cast<typename TypeHandler::Type*>(other_elems[0]); + for (int i = already_allocated; i < length; i++) { + // Allocate a new empty element that we'll merge into below + typename TypeHandler::Type* new_elem = + TypeHandler::NewFromPrototype(elem_prototype, arena); + our_elems[i] = new_elem; + } + } + // Main loop that does the actual merging + for (int i = 0; i < length; i++) { + // Already allocated: use existing element. + typename TypeHandler::Type* other_elem = + reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]); + typename TypeHandler::Type* new_elem = + reinterpret_cast<typename TypeHandler::Type*>(our_elems[i]); + TypeHandler::Merge(*other_elem, new_elem); + } + } - // Internal helper: extend array space if necessary to contain |extend_amount| - // more elements, and return a pointer to the element immediately following - // the old list of elements. This interface factors out common behavior from - // Reserve() and MergeFrom() to reduce code size. |extend_amount| must be > 0. + // Internal helper: extends array space if necessary to contain + // |extend_amount| more elements, and returns a pointer to the element + // immediately following the old list of elements. This interface factors out + // common behavior from Reserve() and MergeFrom() to reduce code size. + // |extend_amount| must be > 0. void** InternalExtend(int extend_amount); - // Internal helper for Add: add "obj" as the next element in the + // Internal helper for Add: adds "obj" as the next element in the // array, including potentially resizing the array with Reserve if // needed void* AddOutOfLineHelper(void* obj); @@ -399,8 +737,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { friend class AccessorHelper; template <typename T> friend struct google::protobuf::WeakRepeatedPtrField; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPtrFieldBase); + friend class internal::TcParser; // TODO(jorg): Remove this friend. }; template <typename GenericType> @@ -415,8 +752,10 @@ class GenericTypeHandler { static inline GenericType* New(Arena* arena, GenericType&& value) { return Arena::Create<GenericType>(arena, std::move(value)); } - static inline GenericType* NewFromPrototype(const GenericType* prototype, - Arena* arena = nullptr); + static inline GenericType* NewFromPrototype(const GenericType* /*prototype*/, + Arena* arena = nullptr) { + return New(arena); + } static inline void Delete(GenericType* value, Arena* arena) { if (arena == nullptr) { delete value; @@ -427,38 +766,37 @@ class GenericTypeHandler { } static inline void Clear(GenericType* value) { value->Clear(); } - PROTOBUF_NOINLINE static void Merge(const GenericType& from, GenericType* to); static inline size_t SpaceUsedLong(const GenericType& value) { return value.SpaceUsedLong(); } }; -template <typename GenericType> -GenericType* GenericTypeHandler<GenericType>::NewFromPrototype( - const GenericType* /* prototype */, Arena* arena) { - return New(arena); -} -template <typename GenericType> -void GenericTypeHandler<GenericType>::Merge(const GenericType& from, - GenericType* to) { - to->MergeFrom(from); -} +// NewFromPrototypeHelper() is not defined inline here, as we will need to do a +// virtual function dispatch anyways to go from Message* to call New/Merge. (The +// additional helper is needed as a workaround for MSVC.) +MessageLite* NewFromPrototypeHelper(const MessageLite* prototype, Arena* arena); -// NewFromPrototype() and Merge() are not defined inline here, as we will need -// to do a virtual function dispatch anyways to go from Message* to call -// New/Merge. template <> -MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype( - const MessageLite* prototype, Arena* arena); +inline MessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype( + const MessageLite* prototype, Arena* arena) { + return NewFromPrototypeHelper(prototype, arena); +} template <> inline Arena* GenericTypeHandler<MessageLite>::GetOwningArena( MessageLite* value) { return value->GetOwningArena(); } + +template <typename GenericType> +PROTOBUF_NOINLINE inline void GenericTypeHandler<GenericType>::Merge( + const GenericType& from, GenericType* to) { + to->MergeFrom(from); +} template <> void GenericTypeHandler<MessageLite>::Merge(const MessageLite& from, MessageLite* to); + template <> inline void GenericTypeHandler<std::string>::Clear(std::string* value) { value->clear(); @@ -513,6 +851,7 @@ class StringTypeHandler { // Messages. template <typename Element> class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { + public: constexpr RepeatedPtrField(); explicit RepeatedPtrField(Arena* arena); @@ -536,8 +875,28 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { const Element& Get(int index) const; Element* Mutable(int index); + + // Unlike std::vector, adding an element to a RepeatedPtrField doesn't always + // make a new element; it might re-use an element left over from when the + // field was Clear()'d or reize()'d smaller. For this reason, Add() is the + // fastest API for adding a new element. Element* Add(); + + // `Add(std::move(value));` is equivalent to `*Add() = std::move(value);` + // It will either move-construct to the end of this field, or swap value + // with the new-or-recycled element at the end of this field. Note that + // this operation is very slow if this RepeatedPtrField is not on the + // same Arena, if any, as `value`. void Add(Element&& value); + + // Copying to the end of this RepeatedPtrField is slowest of all; it can't + // reliably copy-construct to the last element of this RepeatedPtrField, for + // example (unlike std::vector). + // We currently block this API. The right way to add to the end is to call + // Add() and modify the element it points to. + // If you must add an existing value, call `*Add() = value;` + void Add(const Element& value) = delete; + // Append elements in the range [begin, end) after reserving // the appropriate number of elements. template <typename Iter> @@ -549,12 +908,12 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { const Element& at(int index) const; Element& at(int index); - // Remove the last element in the array. + // Removes the last element in the array. // Ownership of the element is retained by the array. void RemoveLast(); - // Delete elements with indices in the range [start .. start+num-1]. - // Caution: implementation moves all elements with indices [start+num .. ]. + // Deletes elements with indices in the range [start .. start+num-1]. + // Caution: moves all elements with indices [start+num .. ]. // Calling this routine inside a loop can cause quadratic behavior. void DeleteSubrange(int start, int num); @@ -566,7 +925,7 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { template <typename Iter> PROTOBUF_ATTRIBUTE_REINITIALIZES void Assign(Iter begin, Iter end); - // Reserve space to expand the field to at least the given size. This only + // Reserves space to expand the field to at least the given size. This only // resizes the pointer array; it doesn't allocate any objects. If the // array is grown, it will always be at least doubled in size. void Reserve(int new_size); @@ -575,20 +934,24 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { // Gets the underlying array. This pointer is possibly invalidated by // any add or remove operation. + // + // This API is deprecated. Instead of directly working with element array, + // use APIs in repeated_field_util.h; e.g. sorting, etc. + PROTOBUF_DEPRECATED_MSG("Use APIs in repeated_field_util.h") Element** mutable_data(); const Element* const* data() const; - // Swap entire contents with "other". If they are on separate arenas, then + // Swaps entire contents with "other". If they are on separate arenas, then // copies data. void Swap(RepeatedPtrField* other); - // Swap entire contents with "other". Caller should guarantee that either both - // fields are on the same arena or both are on the heap. Swapping between + // Swaps entire contents with "other". Caller should guarantee that either + // both fields are on the same arena or both are on the heap. Swapping between // different arenas with this function is disallowed and is caught via // GOOGLE_DCHECK. void UnsafeArenaSwap(RepeatedPtrField* other); - // Swap two elements. + // Swaps two elements. void SwapElements(int index1, int index2); // STL-like iterator support @@ -645,7 +1008,7 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { // When hardcore memory management becomes necessary -- as it sometimes // does here at Google -- the following methods may be useful. - // Add an already-allocated object, passing ownership to the + // Adds an already-allocated object, passing ownership to the // RepeatedPtrField. // // Note that some special behavior occurs with respect to arenas: @@ -658,7 +1021,7 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { // this at runtime, so User Beware. void AddAllocated(Element* value); - // Remove the last element and return it, passing ownership to the caller. + // Removes and returns the last element, passing ownership to the caller. // Requires: size() > 0 // // If this RepeatedPtrField is on an arena, an object copy is required to pass @@ -666,7 +1029,7 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { // UnsafeArenaReleaseLast() if this behavior is undesired. PROTOBUF_NODISCARD Element* ReleaseLast(); - // Add an already-allocated object, skipping arena-ownership checks. The user + // Adds an already-allocated object, skipping arena-ownership checks. The user // must guarantee that the given object is in the same arena as this // RepeatedPtrField. // It is also useful in legacy code that uses temporary ownership to avoid @@ -677,16 +1040,16 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { // temp_field.UnsafeArenaExtractSubrange(0, temp_field.size(), nullptr); // If you put temp_field on the arena this fails, because the ownership // transfers to the arena at the "AddAllocated" call and is not released - // anymore causing a double delete. UnsafeArenaAddAllocated prevents this. + // anymore, causing a double delete. UnsafeArenaAddAllocated prevents this. void UnsafeArenaAddAllocated(Element* value); - // Remove the last element and return it. Unlike ReleaseLast, the returned - // pointer is always to the original object. This may be in an arena, and - // therefore have the arena's lifetime. + // Removes and returns the last element. Unlike ReleaseLast, the returned + // pointer is always to the original object. This may be in an arena, in + // which case it would have the arena's lifetime. // Requires: current_size_ > 0 Element* UnsafeArenaReleaseLast(); - // Extract elements with indices in the range "[start .. start+num-1]". + // Extracts elements with indices in the range "[start .. start+num-1]". // The caller assumes ownership of the extracted elements and is responsible // for deleting them when they are no longer needed. // If "elements" is non-nullptr, then pointers to the extracted elements @@ -717,22 +1080,21 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { // Hardcore programs may choose to manipulate these cleared objects // to better optimize memory management using the following routines. - // Get the number of cleared objects that are currently being kept + // Gets the number of cleared objects that are currently being kept // around for reuse. int ClearedCount() const; #ifndef PROTOBUF_FUTURE_BREAKING_CHANGES - // Add an element to the pool of cleared objects, passing ownership to + // Adds an element to the pool of cleared objects, passing ownership to // the RepeatedPtrField. The element must be cleared prior to calling // this method. // - // This method cannot be called when the repeated field is on an arena or when - // |value| is; both cases will trigger a GOOGLE_DCHECK-failure. + // This method cannot be called when either the repeated field or |value| is + // on an arena; both cases will trigger a GOOGLE_DCHECK-failure. void AddCleared(Element* value); - // Remove a single element from the cleared pool and return it, passing + // Removes and returns a single element from the cleared pool, passing // ownership to the caller. The element is guaranteed to be cleared. // Requires: ClearedCount() > 0 // - // // This method cannot be called when the repeated field is on an arena; doing // so will trigger a GOOGLE_DCHECK-failure. PROTOBUF_NODISCARD Element* ReleaseCleared(); @@ -767,6 +1129,9 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { // Note: RepeatedPtrField SHOULD NOT be subclassed by users. class TypeHandler; + // Internal version of GetArena(). + inline Arena* GetOwningArena() const; + // Implementations for ExtractSubrange(). The copying behavior must be // included only if the type supports the necessary operations (e.g., // MergeFrom()), so we must resolve this at compile time. ExtractSubrange() @@ -785,446 +1150,6 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { }; -// implementation ==================================================== - -namespace internal { - -constexpr RepeatedPtrFieldBase::RepeatedPtrFieldBase() - : arena_(nullptr), current_size_(0), total_size_(0), rep_(nullptr) {} - -inline RepeatedPtrFieldBase::RepeatedPtrFieldBase(Arena* arena) - : arena_(arena), current_size_(0), total_size_(0), rep_(nullptr) {} - -template <typename TypeHandler> -void RepeatedPtrFieldBase::Destroy() { - if (rep_ != nullptr && arena_ == nullptr) { - int n = rep_->allocated_size; - void* const* elements = rep_->elements; - for (int i = 0; i < n; i++) { - TypeHandler::Delete(cast<TypeHandler>(elements[i]), nullptr); - } -#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) - const size_t size = total_size_ * sizeof(elements[0]) + kRepHeaderSize; - ::operator delete(static_cast<void*>(rep_), size); -#else - ::operator delete(static_cast<void*>(rep_)); -#endif - } - rep_ = nullptr; -} - -template <typename TypeHandler> -inline void RepeatedPtrFieldBase::Swap(RepeatedPtrFieldBase* other) { -#ifdef PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() != nullptr && GetArena() == other->GetArena()) { -#else // PROTOBUF_FORCE_COPY_IN_SWAP - if (GetArena() == other->GetArena()) { -#endif // !PROTOBUF_FORCE_COPY_IN_SWAP - InternalSwap(other); - } else { - SwapFallback<TypeHandler>(other); - } -} - -template <typename TypeHandler> -void RepeatedPtrFieldBase::SwapFallback(RepeatedPtrFieldBase* other) { -#ifdef PROTOBUF_FORCE_COPY_IN_SWAP - GOOGLE_DCHECK(GetArena() == nullptr || other->GetArena() != GetArena()); -#else // PROTOBUF_FORCE_COPY_IN_SWAP - GOOGLE_DCHECK(other->GetArena() != GetArena()); -#endif // !PROTOBUF_FORCE_COPY_IN_SWAP - - // Copy semantics in this case. We try to improve efficiency by placing the - // temporary on |other|'s arena so that messages are copied twice rather than - // three times. - RepeatedPtrFieldBase temp(other->GetArena()); - temp.MergeFrom<TypeHandler>(*this); - this->Clear<TypeHandler>(); - this->MergeFrom<TypeHandler>(*other); - other->InternalSwap(&temp); - temp.Destroy<TypeHandler>(); // Frees rep_ if `other` had no arena. -} - -inline bool RepeatedPtrFieldBase::empty() const { return current_size_ == 0; } - -inline int RepeatedPtrFieldBase::size() const { return current_size_; } - -template <typename TypeHandler> -inline const typename TypeHandler::Type& RepeatedPtrFieldBase::Get( - int index) const { - GOOGLE_DCHECK_GE(index, 0); - GOOGLE_DCHECK_LT(index, current_size_); - return *cast<TypeHandler>(rep_->elements[index]); -} - -template <typename TypeHandler> -inline const typename TypeHandler::Type& RepeatedPtrFieldBase::at( - int index) const { - GOOGLE_CHECK_GE(index, 0); - GOOGLE_CHECK_LT(index, current_size_); - return *cast<TypeHandler>(rep_->elements[index]); -} - -template <typename TypeHandler> -inline typename TypeHandler::Type& RepeatedPtrFieldBase::at(int index) { - GOOGLE_CHECK_GE(index, 0); - GOOGLE_CHECK_LT(index, current_size_); - return *cast<TypeHandler>(rep_->elements[index]); -} - -template <typename TypeHandler> -inline typename TypeHandler::Type* RepeatedPtrFieldBase::Mutable(int index) { - GOOGLE_DCHECK_GE(index, 0); - GOOGLE_DCHECK_LT(index, current_size_); - return cast<TypeHandler>(rep_->elements[index]); -} - -template <typename TypeHandler> -inline void RepeatedPtrFieldBase::Delete(int index) { - GOOGLE_DCHECK_GE(index, 0); - GOOGLE_DCHECK_LT(index, current_size_); - TypeHandler::Delete(cast<TypeHandler>(rep_->elements[index]), arena_); -} - -template <typename TypeHandler> -inline typename TypeHandler::Type* RepeatedPtrFieldBase::Add( - typename TypeHandler::Type* prototype) { - if (rep_ != nullptr && current_size_ < rep_->allocated_size) { - return cast<TypeHandler>(rep_->elements[current_size_++]); - } - typename TypeHandler::Type* result = - TypeHandler::NewFromPrototype(prototype, arena_); - return reinterpret_cast<typename TypeHandler::Type*>( - AddOutOfLineHelper(result)); -} - -template <typename TypeHandler, - typename std::enable_if<TypeHandler::Movable::value>::type*> -inline void RepeatedPtrFieldBase::Add(typename TypeHandler::Type&& value) { - if (rep_ != nullptr && current_size_ < rep_->allocated_size) { - *cast<TypeHandler>(rep_->elements[current_size_++]) = std::move(value); - return; - } - if (!rep_ || rep_->allocated_size == total_size_) { - Reserve(total_size_ + 1); - } - ++rep_->allocated_size; - typename TypeHandler::Type* result = - TypeHandler::New(arena_, std::move(value)); - rep_->elements[current_size_++] = result; -} - -template <typename TypeHandler> -inline void RepeatedPtrFieldBase::RemoveLast() { - GOOGLE_DCHECK_GT(current_size_, 0); - TypeHandler::Clear(cast<TypeHandler>(rep_->elements[--current_size_])); -} - -template <typename TypeHandler> -void RepeatedPtrFieldBase::Clear() { - const int n = current_size_; - GOOGLE_DCHECK_GE(n, 0); - if (n > 0) { - void* const* elements = rep_->elements; - int i = 0; - do { - TypeHandler::Clear(cast<TypeHandler>(elements[i++])); - } while (i < n); - current_size_ = 0; - } -} - -// To avoid unnecessary code duplication and reduce binary size, we use a -// layered approach to implementing MergeFrom(). The toplevel method is -// templated, so we get a small thunk per concrete message type in the binary. -// This calls a shared implementation with most of the logic, passing a function -// pointer to another type-specific piece of code that calls the object-allocate -// and merge handlers. -template <typename TypeHandler> -inline void RepeatedPtrFieldBase::MergeFrom(const RepeatedPtrFieldBase& other) { - GOOGLE_DCHECK_NE(&other, this); - if (other.current_size_ == 0) return; - MergeFromInternal(other, - &RepeatedPtrFieldBase::MergeFromInnerLoop<TypeHandler>); -} - -inline void RepeatedPtrFieldBase::MergeFromInternal( - const RepeatedPtrFieldBase& other, - void (RepeatedPtrFieldBase::*inner_loop)(void**, void**, int, int)) { - // Note: wrapper has already guaranteed that other.rep_ != nullptr here. - int other_size = other.current_size_; - void** other_elements = other.rep_->elements; - void** new_elements = InternalExtend(other_size); - int allocated_elems = rep_->allocated_size - current_size_; - (this->*inner_loop)(new_elements, other_elements, other_size, - allocated_elems); - current_size_ += other_size; - if (rep_->allocated_size < current_size_) { - rep_->allocated_size = current_size_; - } -} - -// Merges other_elems to our_elems. -template <typename TypeHandler> -void RepeatedPtrFieldBase::MergeFromInnerLoop(void** our_elems, - void** other_elems, int length, - int already_allocated) { - if (already_allocated < length) { - Arena* arena = GetArena(); - typename TypeHandler::Type* elem_prototype = - reinterpret_cast<typename TypeHandler::Type*>(other_elems[0]); - for (int i = already_allocated; i < length; i++) { - // Allocate a new empty element that we'll merge into below - typename TypeHandler::Type* new_elem = - TypeHandler::NewFromPrototype(elem_prototype, arena); - our_elems[i] = new_elem; - } - } - // Main loop that does the actual merging - for (int i = 0; i < length; i++) { - // Already allocated: use existing element. - typename TypeHandler::Type* other_elem = - reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]); - typename TypeHandler::Type* new_elem = - reinterpret_cast<typename TypeHandler::Type*>(our_elems[i]); - TypeHandler::Merge(*other_elem, new_elem); - } -} - -template <typename TypeHandler> -inline void RepeatedPtrFieldBase::CopyFrom(const RepeatedPtrFieldBase& other) { - if (&other == this) return; - RepeatedPtrFieldBase::Clear<TypeHandler>(); - RepeatedPtrFieldBase::MergeFrom<TypeHandler>(other); -} - -inline int RepeatedPtrFieldBase::Capacity() const { return total_size_; } - -inline void* const* RepeatedPtrFieldBase::raw_data() const { - return rep_ ? rep_->elements : nullptr; -} - -inline void** RepeatedPtrFieldBase::raw_mutable_data() const { - return rep_ ? const_cast<void**>(rep_->elements) : nullptr; -} - -template <typename TypeHandler> -inline typename TypeHandler::Type** RepeatedPtrFieldBase::mutable_data() { - // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this - // method entirely. - return reinterpret_cast<typename TypeHandler::Type**>(raw_mutable_data()); -} - -template <typename TypeHandler> -inline const typename TypeHandler::Type* const* RepeatedPtrFieldBase::data() - const { - // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this - // method entirely. - return reinterpret_cast<const typename TypeHandler::Type* const*>(raw_data()); -} - -inline void RepeatedPtrFieldBase::SwapElements(int index1, int index2) { - using std::swap; // enable ADL with fallback - swap(rep_->elements[index1], rep_->elements[index2]); -} - -template <typename TypeHandler> -inline size_t RepeatedPtrFieldBase::SpaceUsedExcludingSelfLong() const { - size_t allocated_bytes = static_cast<size_t>(total_size_) * sizeof(void*); - if (rep_ != nullptr) { - for (int i = 0; i < rep_->allocated_size; ++i) { - allocated_bytes += - TypeHandler::SpaceUsedLong(*cast<TypeHandler>(rep_->elements[i])); - } - allocated_bytes += kRepHeaderSize; - } - return allocated_bytes; -} - -template <typename TypeHandler> -inline typename TypeHandler::Type* RepeatedPtrFieldBase::AddFromCleared() { - if (rep_ != nullptr && current_size_ < rep_->allocated_size) { - return cast<TypeHandler>(rep_->elements[current_size_++]); - } else { - return nullptr; - } -} - -// AddAllocated version that implements arena-safe copying behavior. -template <typename TypeHandler> -void RepeatedPtrFieldBase::AddAllocatedInternal( - typename TypeHandler::Type* value, std::true_type) { - Arena* element_arena = - reinterpret_cast<Arena*>(TypeHandler::GetOwningArena(value)); - Arena* arena = GetArena(); - if (arena == element_arena && rep_ && rep_->allocated_size < total_size_) { - // Fast path: underlying arena representation (tagged pointer) is equal to - // our arena pointer, and we can add to array without resizing it (at least - // one slot that is not allocated). - void** elems = rep_->elements; - if (current_size_ < rep_->allocated_size) { - // Make space at [current] by moving first allocated element to end of - // allocated list. - elems[rep_->allocated_size] = elems[current_size_]; - } - elems[current_size_] = value; - current_size_ = current_size_ + 1; - rep_->allocated_size = rep_->allocated_size + 1; - } else { - AddAllocatedSlowWithCopy<TypeHandler>(value, element_arena, arena); - } -} - -// Slowpath handles all cases, copying if necessary. -template <typename TypeHandler> -void RepeatedPtrFieldBase::AddAllocatedSlowWithCopy( - // Pass value_arena and my_arena to avoid duplicate virtual call (value) or - // load (mine). - typename TypeHandler::Type* value, Arena* value_arena, Arena* my_arena) { - // Ensure that either the value is in the same arena, or if not, we do the - // appropriate thing: Own() it (if it's on heap and we're in an arena) or copy - // it to our arena/heap (otherwise). - if (my_arena != nullptr && value_arena == nullptr) { - my_arena->Own(value); - } else if (my_arena != value_arena) { - typename TypeHandler::Type* new_value = - TypeHandler::NewFromPrototype(value, my_arena); - TypeHandler::Merge(*value, new_value); - TypeHandler::Delete(value, value_arena); - value = new_value; - } - - UnsafeArenaAddAllocated<TypeHandler>(value); -} - -// AddAllocated version that does not implement arena-safe copying behavior. -template <typename TypeHandler> -void RepeatedPtrFieldBase::AddAllocatedInternal( - typename TypeHandler::Type* value, std::false_type) { - if (rep_ && rep_->allocated_size < total_size_) { - // Fast path: underlying arena representation (tagged pointer) is equal to - // our arena pointer, and we can add to array without resizing it (at least - // one slot that is not allocated). - void** elems = rep_->elements; - if (current_size_ < rep_->allocated_size) { - // Make space at [current] by moving first allocated element to end of - // allocated list. - elems[rep_->allocated_size] = elems[current_size_]; - } - elems[current_size_] = value; - current_size_ = current_size_ + 1; - ++rep_->allocated_size; - } else { - UnsafeArenaAddAllocated<TypeHandler>(value); - } -} - -template <typename TypeHandler> -void RepeatedPtrFieldBase::UnsafeArenaAddAllocated( - typename TypeHandler::Type* value) { - // Make room for the new pointer. - if (!rep_ || current_size_ == total_size_) { - // The array is completely full with no cleared objects, so grow it. - Reserve(total_size_ + 1); - ++rep_->allocated_size; - } else if (rep_->allocated_size == total_size_) { - // There is no more space in the pointer array because it contains some - // cleared objects awaiting reuse. We don't want to grow the array in this - // case because otherwise a loop calling AddAllocated() followed by Clear() - // would leak memory. - TypeHandler::Delete(cast<TypeHandler>(rep_->elements[current_size_]), - arena_); - } else if (current_size_ < rep_->allocated_size) { - // We have some cleared objects. We don't care about their order, so we - // can just move the first one to the end to make space. - rep_->elements[rep_->allocated_size] = rep_->elements[current_size_]; - ++rep_->allocated_size; - } else { - // There are no cleared objects. - ++rep_->allocated_size; - } - - rep_->elements[current_size_++] = value; -} - -// ReleaseLast() for types that implement merge/copy behavior. -template <typename TypeHandler> -inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseLastInternal( - std::true_type) { - // First, release an element. - typename TypeHandler::Type* result = UnsafeArenaReleaseLast<TypeHandler>(); - // Now perform a copy if we're on an arena. - Arena* arena = GetArena(); - - typename TypeHandler::Type* new_result; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - new_result = copy<TypeHandler>(result); - if (arena == nullptr) delete result; -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - new_result = (arena == nullptr) ? result : copy<TypeHandler>(result); -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return new_result; -} - -// ReleaseLast() for types that *do not* implement merge/copy behavior -- this -// is the same as UnsafeArenaReleaseLast(). Note that we GOOGLE_DCHECK-fail if we're on -// an arena, since the user really should implement the copy operation in this -// case. -template <typename TypeHandler> -inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseLastInternal( - std::false_type) { - GOOGLE_DCHECK(GetArena() == nullptr) - << "ReleaseLast() called on a RepeatedPtrField that is on an arena, " - << "with a type that does not implement MergeFrom. This is unsafe; " - << "please implement MergeFrom for your type."; - return UnsafeArenaReleaseLast<TypeHandler>(); -} - -template <typename TypeHandler> -inline typename TypeHandler::Type* -RepeatedPtrFieldBase::UnsafeArenaReleaseLast() { - GOOGLE_DCHECK_GT(current_size_, 0); - typename TypeHandler::Type* result = - cast<TypeHandler>(rep_->elements[--current_size_]); - --rep_->allocated_size; - if (current_size_ < rep_->allocated_size) { - // There are cleared elements on the end; replace the removed element - // with the last allocated element. - rep_->elements[current_size_] = rep_->elements[rep_->allocated_size]; - } - return result; -} - -inline int RepeatedPtrFieldBase::ClearedCount() const { - return rep_ ? (rep_->allocated_size - current_size_) : 0; -} - -template <typename TypeHandler> -inline void RepeatedPtrFieldBase::AddCleared( - typename TypeHandler::Type* value) { - GOOGLE_DCHECK(GetArena() == nullptr) - << "AddCleared() can only be used on a RepeatedPtrField not on an arena."; - GOOGLE_DCHECK(TypeHandler::GetOwningArena(value) == nullptr) - << "AddCleared() can only accept values not on an arena."; - if (!rep_ || rep_->allocated_size == total_size_) { - Reserve(total_size_ + 1); - } - rep_->elements[rep_->allocated_size++] = value; -} - -template <typename TypeHandler> -inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseCleared() { - GOOGLE_DCHECK(GetArena() == nullptr) - << "ReleaseCleared() can only be used on a RepeatedPtrField not on " - << "an arena."; - GOOGLE_DCHECK(GetArena() == nullptr); - GOOGLE_DCHECK(rep_ != nullptr); - GOOGLE_DCHECK_GT(rep_->allocated_size, current_size_); - return cast<TypeHandler>(rep_->elements[--rep_->allocated_size]); -} - -} // namespace internal - // ------------------------------------------------------------------- template <typename Element> @@ -1286,7 +1211,7 @@ inline RepeatedPtrField<Element>::RepeatedPtrField( // We don't just call Swap(&other) here because it would perform 3 copies if // other is on an arena. This field can't be on an arena because arena // construction always uses the Arena* accepting constructor. - if (other.GetArena()) { + if (other.GetOwningArena()) { CopyFrom(other); } else { InternalSwap(&other); @@ -1300,9 +1225,9 @@ inline RepeatedPtrField<Element>& RepeatedPtrField<Element>::operator=( // We don't just call Swap(&other) here because it would perform 3 copies if // the two fields are on different arenas. if (this != &other) { - if (GetArena() != other.GetArena() + if (GetOwningArena() != other.GetOwningArena() #ifdef PROTOBUF_FORCE_COPY_IN_MOVE - || GetArena() == nullptr + || GetOwningArena() == nullptr #endif // !PROTOBUF_FORCE_COPY_IN_MOVE ) { CopyFrom(other); @@ -1411,7 +1336,7 @@ inline void RepeatedPtrField<Element>::ExtractSubrangeInternal( return; } - Arena* arena = GetArena(); + Arena* arena = GetOwningArena(); #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE // Always copy. for (int i = 0; i < num; ++i) { @@ -1449,7 +1374,7 @@ inline void RepeatedPtrField<Element>::ExtractSubrangeInternal( // ExtractSubrange() must return heap-allocated objects by contract, and we // cannot fulfill this contract if we are an on arena, we must GOOGLE_DCHECK() that // we are not on an arena. - GOOGLE_DCHECK(GetArena() == nullptr) + GOOGLE_DCHECK(GetOwningArena() == nullptr) << "ExtractSubrange() when arena is non-nullptr is only supported when " << "the Element type supplies a MergeFrom() operation to make copies."; UnsafeArenaExtractSubrange(start, num, elements); @@ -1531,6 +1456,7 @@ template <typename Element> inline void RepeatedPtrField<Element>::UnsafeArenaSwap( RepeatedPtrField* other) { if (this == other) return; + GOOGLE_DCHECK_EQ(GetOwningArena(), other->GetOwningArena()); RepeatedPtrFieldBase::InternalSwap(other); } @@ -1544,6 +1470,11 @@ inline Arena* RepeatedPtrField<Element>::GetArena() const { return RepeatedPtrFieldBase::GetArena(); } +template <typename Element> +inline Arena* RepeatedPtrField<Element>::GetOwningArena() const { + return RepeatedPtrFieldBase::GetOwningArena(); +} + template <typename Element> inline size_t RepeatedPtrField<Element>::SpaceUsedExcludingSelfLong() const { return RepeatedPtrFieldBase::SpaceUsedExcludingSelfLong<TypeHandler>(); @@ -1624,16 +1555,13 @@ class RepeatedPtrIterator { RepeatedPtrIterator() : it_(nullptr) {} explicit RepeatedPtrIterator(void* const* it) : it_(it) {} - // Allow "upcasting" from RepeatedPtrIterator<T**> to + // Allows "upcasting" from RepeatedPtrIterator<T**> to // RepeatedPtrIterator<const T*const*>. - template <typename OtherElement> + template <typename OtherElement, + typename std::enable_if<std::is_convertible< + OtherElement*, pointer>::value>::type* = nullptr> RepeatedPtrIterator(const RepeatedPtrIterator<OtherElement>& other) - : it_(other.it_) { - // Force a compiler error if the other type is not convertible to ours. - if (false) { - static_cast<void>([](OtherElement* from) -> Element* { return from; }); - } - } + : it_(other.it_) {} // dereferenceable reference operator*() const { return *reinterpret_cast<Element*>(*it_); } @@ -1652,14 +1580,26 @@ class RepeatedPtrIterator { iterator operator--(int) { return iterator(it_--); } // equality_comparable - bool operator==(const iterator& x) const { return it_ == x.it_; } - bool operator!=(const iterator& x) const { return it_ != x.it_; } + friend bool operator==(const iterator& x, const iterator& y) { + return x.it_ == y.it_; + } + friend bool operator!=(const iterator& x, const iterator& y) { + return x.it_ != y.it_; + } // less_than_comparable - bool operator<(const iterator& x) const { return it_ < x.it_; } - bool operator<=(const iterator& x) const { return it_ <= x.it_; } - bool operator>(const iterator& x) const { return it_ > x.it_; } - bool operator>=(const iterator& x) const { return it_ >= x.it_; } + friend bool operator<(const iterator& x, const iterator& y) { + return x.it_ < y.it_; + } + friend bool operator<=(const iterator& x, const iterator& y) { + return x.it_ <= y.it_; + } + friend bool operator>(const iterator& x, const iterator& y) { + return x.it_ > y.it_; + } + friend bool operator>=(const iterator& x, const iterator& y) { + return x.it_ >= y.it_; + } // addable, subtractable iterator& operator+=(difference_type d) { @@ -1687,7 +1627,9 @@ class RepeatedPtrIterator { reference operator[](difference_type d) const { return *(*this + d); } // random access iterator - difference_type operator-(const iterator& x) const { return it_ - x.it_; } + friend difference_type operator-(iterator it1, iterator it2) { + return it1.it_ - it2.it_; + } private: template <typename OtherElement> @@ -1697,7 +1639,7 @@ class RepeatedPtrIterator { void* const* it_; }; -// Provide an iterator that operates on pointers to the underlying objects +// Provides an iterator that operates on pointers to the underlying objects // rather than the objects themselves as RepeatedPtrIterator does. // Consider using this when working with stl algorithms that change // the array. @@ -1717,6 +1659,17 @@ class RepeatedPtrOverPtrsIterator { RepeatedPtrOverPtrsIterator() : it_(nullptr) {} explicit RepeatedPtrOverPtrsIterator(VoidPtr* it) : it_(it) {} + // Allows "upcasting" from RepeatedPtrOverPtrsIterator<T**> to + // RepeatedPtrOverPtrsIterator<const T*const*>. + template < + typename OtherElement, typename OtherVoidPtr, + typename std::enable_if< + std::is_convertible<OtherElement*, pointer>::value && + std::is_convertible<OtherVoidPtr*, VoidPtr>::value>::type* = nullptr> + RepeatedPtrOverPtrsIterator( + const RepeatedPtrOverPtrsIterator<OtherElement, OtherVoidPtr>& other) + : it_(other.it_) {} + // dereferenceable reference operator*() const { return *reinterpret_cast<Element*>(it_); } pointer operator->() const { return &(operator*()); } @@ -1734,14 +1687,26 @@ class RepeatedPtrOverPtrsIterator { iterator operator--(int) { return iterator(it_--); } // equality_comparable - bool operator==(const iterator& x) const { return it_ == x.it_; } - bool operator!=(const iterator& x) const { return it_ != x.it_; } + friend bool operator==(const iterator& x, const iterator& y) { + return x.it_ == y.it_; + } + friend bool operator!=(const iterator& x, const iterator& y) { + return x.it_ != y.it_; + } // less_than_comparable - bool operator<(const iterator& x) const { return it_ < x.it_; } - bool operator<=(const iterator& x) const { return it_ <= x.it_; } - bool operator>(const iterator& x) const { return it_ > x.it_; } - bool operator>=(const iterator& x) const { return it_ >= x.it_; } + friend bool operator<(const iterator& x, const iterator& y) { + return x.it_ < y.it_; + } + friend bool operator<=(const iterator& x, const iterator& y) { + return x.it_ <= y.it_; + } + friend bool operator>(const iterator& x, const iterator& y) { + return x.it_ > y.it_; + } + friend bool operator>=(const iterator& x, const iterator& y) { + return x.it_ >= y.it_; + } // addable, subtractable iterator& operator+=(difference_type d) { @@ -1769,27 +1734,18 @@ class RepeatedPtrOverPtrsIterator { reference operator[](difference_type d) const { return *(*this + d); } // random access iterator - difference_type operator-(const iterator& x) const { return it_ - x.it_; } + friend difference_type operator-(iterator it1, iterator it2) { + return it1.it_ - it2.it_; + } private: - template <typename OtherElement> - friend class RepeatedPtrIterator; + template <typename OtherElement, typename OtherVoidPtr> + friend class RepeatedPtrOverPtrsIterator; // The internal iterator. VoidPtr* it_; }; -void RepeatedPtrFieldBase::InternalSwap(RepeatedPtrFieldBase* rhs) { - GOOGLE_DCHECK(this != rhs); - - // Swap all fields at once. - auto temp = std::make_tuple(rhs->arena_, rhs->current_size_, rhs->total_size_, - rhs->rep_); - std::tie(rhs->arena_, rhs->current_size_, rhs->total_size_, rhs->rep_) = - std::make_tuple(arena_, current_size_, total_size_, rep_); - std::tie(arena_, current_size_, total_size_, rep_) = temp; -} - } // namespace internal template <typename Element> @@ -1992,9 +1948,9 @@ AllocatedRepeatedPtrFieldBackInserter( // temp_field.UnsafeArenaAddAllocated(new T); // ... // Do something with temp_field // temp_field.UnsafeArenaExtractSubrange(0, temp_field.size(), nullptr); -// If you put temp_field on the arena this fails, because the ownership -// transfers to the arena at the "AddAllocated" call and is not released anymore -// causing a double delete. Using UnsafeArenaAddAllocated prevents this. +// Putting temp_field on the arena fails because the ownership transfers to the +// arena at the "AddAllocated" call and is not released anymore causing a +// double delete. This function uses UnsafeArenaAddAllocated to prevent this. template <typename T> internal::UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator<T> UnsafeArenaAllocatedRepeatedPtrFieldBackInserter( diff --git a/r5dev/thirdparty/protobuf/service.h b/r5dev/thirdparty/protobuf/service.h index 3200e2dc..ce407596 100644 --- a/r5dev/thirdparty/protobuf/service.h +++ b/r5dev/thirdparty/protobuf/service.h @@ -100,6 +100,7 @@ #ifndef GOOGLE_PROTOBUF_SERVICE_H__ #define GOOGLE_PROTOBUF_SERVICE_H__ + #include <string> #include <thirdparty/protobuf/stubs/callback.h> #include <thirdparty/protobuf/stubs/common.h> @@ -108,6 +109,7 @@ #error "You cannot SWIG proto headers" #endif +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/source_context.pb.cc b/r5dev/thirdparty/protobuf/source_context.pb.cc index c51b3437..1944ce6f 100644 --- a/r5dev/thirdparty/protobuf/source_context.pb.cc +++ b/r5dev/thirdparty/protobuf/source_context.pb.cc @@ -16,23 +16,28 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + PROTOBUF_NAMESPACE_OPEN -constexpr SourceContext::SourceContext( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : file_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){} +PROTOBUF_CONSTEXPR SourceContext::SourceContext( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.file_name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} struct SourceContextDefaultTypeInternal { - constexpr SourceContextDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR SourceContextDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~SourceContextDefaultTypeInternal() {} union { SourceContext _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SourceContextDefaultTypeInternal _SourceContext_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceContextDefaultTypeInternal _SourceContext_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto[1]; -static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr; +static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto[1]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr; const uint32_t TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ @@ -41,14 +46,14 @@ const uint32_t TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceContext, file_name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceContext, _impl_.file_name_), }; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceContext)}, }; -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_), +static const ::_pb::Message* const file_default_instances[] = { + &::PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_._instance, }; const char descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = @@ -59,19 +64,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eprot "tobuf/types/known/sourcecontextpb\242\002\003GPB\252" "\002\036Google.Protobuf.WellKnownTypesb\006proto3" ; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto = { - false, false, 240, descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto, "google/protobuf/source_context.proto", - &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once, nullptr, 0, 1, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, +static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto = { + false, false, 240, descriptor_table_protodef_google_2fprotobuf_2fsource_5fcontext_2eproto, + "google/protobuf/source_context.proto", + &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once, nullptr, 0, 1, + schemas, file_default_instances, TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, + file_level_service_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_getter() { +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto; } // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fsource_5fcontext_2eproto(&descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fsource_5fcontext_2eproto(&descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto); PROTOBUF_NAMESPACE_OPEN // =================================================================== @@ -83,53 +90,58 @@ class SourceContext::_Internal { SourceContext::SourceContext(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.SourceContext) } SourceContext::SourceContext(const SourceContext& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + SourceContext* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.file_name_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - file_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.file_name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.file_name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_file_name().empty()) { - file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_file_name(), - GetArenaForAllocation()); + _this->_impl_.file_name_.Set(from._internal_file_name(), + _this->GetArenaForAllocation()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext) } -inline void SourceContext::SharedCtor() { -file_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +inline void SourceContext::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.file_name_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.file_name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.file_name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } SourceContext::~SourceContext() { // @@protoc_insertion_point(destructor:google.protobuf.SourceContext) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void SourceContext::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - file_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.file_name_.Destroy(); } -void SourceContext::ArenaDtor(void* object) { - SourceContext* _this = reinterpret_cast< SourceContext* >(object); - (void)_this; -} -void SourceContext::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void SourceContext::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void SourceContext::Clear() { @@ -138,23 +150,23 @@ void SourceContext::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - file_name_.ClearToEmpty(); + _impl_.file_name_.ClearToEmpty(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* SourceContext::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* SourceContext::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // string file_name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_file_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.SourceContext.file_name")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.SourceContext.file_name")); } else goto handle_unusual; continue; @@ -198,7 +210,7 @@ uint8_t* SourceContext::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceContext) @@ -220,32 +232,28 @@ size_t SourceContext::ByteSizeLong() const { this->_internal_file_name()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SourceContext::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, SourceContext::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SourceContext::GetClassData() const { return &_class_data_; } -void SourceContext::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<SourceContext *>(to)->MergeFrom( - static_cast<const SourceContext &>(from)); -} - -void SourceContext::MergeFrom(const SourceContext& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceContext) - GOOGLE_DCHECK_NE(&from, this); +void SourceContext::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<SourceContext*>(&to_msg); + auto& from = static_cast<const SourceContext&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceContext) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (!from._internal_file_name().empty()) { - _internal_set_file_name(from._internal_file_name()); + _this->_internal_set_file_name(from._internal_file_name()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void SourceContext::CopyFrom(const SourceContext& from) { @@ -265,14 +273,13 @@ void SourceContext::InternalSwap(SourceContext* other) { auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &file_name_, lhs_arena, - &other->file_name_, rhs_arena + &_impl_.file_name_, lhs_arena, + &other->_impl_.file_name_, rhs_arena ); } ::PROTOBUF_NAMESPACE_ID::Metadata SourceContext::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_getter, &descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto_once, file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto[0]); } @@ -280,7 +287,8 @@ void SourceContext::InternalSwap(SourceContext* other) { // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::SourceContext* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceContext >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::SourceContext* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::SourceContext >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::SourceContext >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/thirdparty/protobuf/source_context.pb.h b/r5dev/thirdparty/protobuf/source_context.pb.h index 858f0442..39df2087 100644 --- a/r5dev/thirdparty/protobuf/source_context.pb.h +++ b/r5dev/thirdparty/protobuf/source_context.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/generated_message_reflection.h> @@ -42,14 +41,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto; @@ -70,7 +61,7 @@ class PROTOBUF_EXPORT SourceContext final : public: inline SourceContext() : SourceContext(nullptr) {} ~SourceContext() override; - explicit constexpr SourceContext(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR SourceContext(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); SourceContext(const SourceContext& from); SourceContext(SourceContext&& from) noexcept @@ -145,9 +136,11 @@ class PROTOBUF_EXPORT SourceContext final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const SourceContext& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const SourceContext& from); + void MergeFrom( const SourceContext& from) { + SourceContext::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -156,10 +149,10 @@ class PROTOBUF_EXPORT SourceContext final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(SourceContext* other); @@ -172,9 +165,6 @@ class PROTOBUF_EXPORT SourceContext final : protected: explicit SourceContext(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -210,8 +200,11 @@ class PROTOBUF_EXPORT SourceContext final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr file_name_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr file_name_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto; }; // =================================================================== @@ -227,7 +220,7 @@ class PROTOBUF_EXPORT SourceContext final : // string file_name = 1; inline void SourceContext::clear_file_name() { - file_name_.ClearToEmpty(); + _impl_.file_name_.ClearToEmpty(); } inline const std::string& SourceContext::file_name() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name) @@ -237,7 +230,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void SourceContext::set_file_name(ArgT0&& arg0, ArgT... args) { - file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.file_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name) } inline std::string* SourceContext::mutable_file_name() { @@ -246,19 +239,19 @@ inline std::string* SourceContext::mutable_file_name() { return _s; } inline const std::string& SourceContext::_internal_file_name() const { - return file_name_.Get(); + return _impl_.file_name_.Get(); } inline void SourceContext::_internal_set_file_name(const std::string& value) { - file_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.file_name_.Set(value, GetArenaForAllocation()); } inline std::string* SourceContext::_internal_mutable_file_name() { - return file_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.file_name_.Mutable(GetArenaForAllocation()); } inline std::string* SourceContext::release_file_name() { // @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name) - return file_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.file_name_.Release(); } inline void SourceContext::set_allocated_file_name(std::string* file_name) { if (file_name != nullptr) { @@ -266,11 +259,10 @@ inline void SourceContext::set_allocated_file_name(std::string* file_name) { } else { } - file_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), file_name, - GetArenaForAllocation()); + _impl_.file_name_.SetAllocated(file_name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (file_name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - file_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.file_name_.IsDefault()) { + _impl_.file_name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name) diff --git a/r5dev/thirdparty/protobuf/struct.pb.cc b/r5dev/thirdparty/protobuf/struct.pb.cc index 916fcc07..5c6d8e54 100644 --- a/r5dev/thirdparty/protobuf/struct.pb.cc +++ b/r5dev/thirdparty/protobuf/struct.pb.cc @@ -16,58 +16,66 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + PROTOBUF_NAMESPACE_OPEN -constexpr Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized){} +PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUse::Struct_FieldsEntry_DoNotUse( + ::_pbi::ConstantInitialized) {} struct Struct_FieldsEntry_DoNotUseDefaultTypeInternal { - constexpr Struct_FieldsEntry_DoNotUseDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUseDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~Struct_FieldsEntry_DoNotUseDefaultTypeInternal() {} union { Struct_FieldsEntry_DoNotUse _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_; -constexpr Struct::Struct( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : fields_(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_; +PROTOBUF_CONSTEXPR Struct::Struct( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.fields_)*/{::_pbi::ConstantInitialized()} + , /*decltype(_impl_._cached_size_)*/{}} {} struct StructDefaultTypeInternal { - constexpr StructDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR StructDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~StructDefaultTypeInternal() {} union { Struct _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT StructDefaultTypeInternal _Struct_default_instance_; -constexpr Value::Value( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : _oneof_case_{}{} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 StructDefaultTypeInternal _Struct_default_instance_; +PROTOBUF_CONSTEXPR Value::Value( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.kind_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_._oneof_case_)*/{}} {} struct ValueDefaultTypeInternal { - constexpr ValueDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR ValueDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~ValueDefaultTypeInternal() {} union { Value _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ValueDefaultTypeInternal _Value_default_instance_; -constexpr ListValue::ListValue( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : values_(){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ValueDefaultTypeInternal _Value_default_instance_; +PROTOBUF_CONSTEXPR ListValue::ListValue( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.values_)*/{} + , /*decltype(_impl_._cached_size_)*/{}} {} struct ListValueDefaultTypeInternal { - constexpr ListValueDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR ListValueDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~ListValueDefaultTypeInternal() {} union { ListValue _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ListValueDefaultTypeInternal _ListValue_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ListValueDefaultTypeInternal _ListValue_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fstruct_2eproto[4]; -static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto[1]; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto = nullptr; +static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fstruct_2eproto[4]; +static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto[1]; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto = nullptr; const uint32_t TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse, _has_bits_), @@ -86,40 +94,40 @@ const uint32_t TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets[] PROTOBU ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct, fields_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Struct, _impl_.fields_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _internal_metadata_), ~0u, // no _extensions_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _oneof_case_[0]), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _impl_._oneof_case_[0]), ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - ::PROTOBUF_NAMESPACE_ID::internal::kInvalidFieldOffsetTag, - ::PROTOBUF_NAMESPACE_ID::internal::kInvalidFieldOffsetTag, - ::PROTOBUF_NAMESPACE_ID::internal::kInvalidFieldOffsetTag, - ::PROTOBUF_NAMESPACE_ID::internal::kInvalidFieldOffsetTag, - ::PROTOBUF_NAMESPACE_ID::internal::kInvalidFieldOffsetTag, - ::PROTOBUF_NAMESPACE_ID::internal::kInvalidFieldOffsetTag, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, kind_), + ::_pbi::kInvalidFieldOffsetTag, + ::_pbi::kInvalidFieldOffsetTag, + ::_pbi::kInvalidFieldOffsetTag, + ::_pbi::kInvalidFieldOffsetTag, + ::_pbi::kInvalidFieldOffsetTag, + ::_pbi::kInvalidFieldOffsetTag, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Value, _impl_.kind_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ListValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ListValue, values_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ListValue, _impl_.values_), }; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, 8, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse)}, { 10, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Struct)}, { 17, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Value)}, { 30, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ListValue)}, }; -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Struct_FieldsEntry_DoNotUse_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Struct_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Value_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_ListValue_default_instance_), +static const ::_pb::Message* const file_default_instances[] = { + &::PROTOBUF_NAMESPACE_ID::_Struct_FieldsEntry_DoNotUse_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_Struct_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_Value_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_ListValue_default_instance_._instance, }; const char descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = @@ -140,19 +148,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto[] PROTOB "rotobuf/types/known/structpb\370\001\001\242\002\003GPB\252\002\036" "Google.Protobuf.WellKnownTypesb\006proto3" ; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fstruct_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto = { - false, false, 638, descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto, "google/protobuf/struct.proto", - &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, nullptr, 0, 4, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fstruct_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto, file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto, +static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fstruct_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto = { + false, false, 638, descriptor_table_protodef_google_2fprotobuf_2fstruct_2eproto, + "google/protobuf/struct.proto", + &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, nullptr, 0, 4, + schemas, file_default_instances, TableStruct_google_2fprotobuf_2fstruct_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fstruct_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto, + file_level_service_descriptors_google_2fprotobuf_2fstruct_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter() { +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fstruct_2eproto; } // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fstruct_2eproto(&descriptor_table_google_2fprotobuf_2fstruct_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fstruct_2eproto(&descriptor_table_google_2fprotobuf_2fstruct_2eproto); PROTOBUF_NAMESPACE_OPEN const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* NullValue_descriptor() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fstruct_2eproto); @@ -177,7 +187,7 @@ void Struct_FieldsEntry_DoNotUse::MergeFrom(const Struct_FieldsEntry_DoNotUse& o MergeFromInternal(other); } ::PROTOBUF_NAMESPACE_ID::Metadata Struct_FieldsEntry_DoNotUse::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, file_level_metadata_google_2fprotobuf_2fstruct_2eproto[0]); } @@ -190,47 +200,57 @@ class Struct::_Internal { Struct::Struct(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - fields_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + if (arena != nullptr && !is_message_owned) { + arena->OwnCustomDestructor(this, &Struct::ArenaDtor); } // @@protoc_insertion_point(arena_constructor:google.protobuf.Struct) } Struct::Struct(const Struct& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + Struct* const _this = this; (void)_this; + new (&_impl_) Impl_{ + /*decltype(_impl_.fields_)*/{} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - fields_.MergeFrom(from.fields_); + _this->_impl_.fields_.MergeFrom(from._impl_.fields_); // @@protoc_insertion_point(copy_constructor:google.protobuf.Struct) } -inline void Struct::SharedCtor() { +inline void Struct::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + /*decltype(_impl_.fields_)*/{::_pbi::ArenaInitialized(), arena} + , /*decltype(_impl_._cached_size_)*/{} + }; } Struct::~Struct() { // @@protoc_insertion_point(destructor:google.protobuf.Struct) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + ArenaDtor(this); + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Struct::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.fields_.Destruct(); + _impl_.fields_.~MapField(); } void Struct::ArenaDtor(void* object) { Struct* _this = reinterpret_cast< Struct* >(object); - (void)_this; - _this->fields_. ~MapField(); -} -inline void Struct::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena) { - if (arena != nullptr) { - arena->OwnCustomDestructor(this, &Struct::ArenaDtor); - } + _this->_impl_.fields_.Destruct(); } void Struct::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Struct::Clear() { @@ -239,15 +259,15 @@ void Struct::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - fields_.Clear(); + _impl_.fields_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Struct::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Struct::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // map<string, .google.protobuf.Value> fields = 1; case 1: @@ -255,7 +275,7 @@ const char* Struct::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int ptr -= 1; do { ptr += 1; - ptr = ctx->ParseMessage(&fields_, ptr); + ptr = ctx->ParseMessage(&_impl_.fields_, ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); @@ -293,48 +313,32 @@ uint8_t* Struct::_InternalSerialize( // map<string, .google.protobuf.Value> fields = 1; if (!this->_internal_fields().empty()) { - typedef ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >::const_pointer - ConstPtr; - typedef ConstPtr SortItem; - typedef ::PROTOBUF_NAMESPACE_ID::internal::CompareByDerefFirst<SortItem> Less; - struct Utf8Check { - static void Check(ConstPtr p) { - (void)p; - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - p->first.data(), static_cast<int>(p->first.length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "google.protobuf.Struct.FieldsEntry.key"); - } + using MapType = ::_pb::Map<std::string, ::PROTOBUF_NAMESPACE_ID::Value>; + using WireHelper = Struct_FieldsEntry_DoNotUse::Funcs; + const auto& map_field = this->_internal_fields(); + auto check_utf8 = [](const MapType::value_type& entry) { + (void)entry; + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + entry.first.data(), static_cast<int>(entry.first.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "google.protobuf.Struct.FieldsEntry.key"); }; - if (stream->IsSerializationDeterministic() && - this->_internal_fields().size() > 1) { - ::std::unique_ptr<SortItem[]> items( - new SortItem[this->_internal_fields().size()]); - typedef ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >::size_type size_type; - size_type n = 0; - for (::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >::const_iterator - it = this->_internal_fields().begin(); - it != this->_internal_fields().end(); ++it, ++n) { - items[static_cast<ptrdiff_t>(n)] = SortItem(&*it); - } - ::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less()); - for (size_type i = 0; i < n; i++) { - target = Struct_FieldsEntry_DoNotUse::Funcs::InternalSerialize(1, items[static_cast<ptrdiff_t>(i)]->first, items[static_cast<ptrdiff_t>(i)]->second, target, stream); - Utf8Check::Check(&(*items[static_cast<ptrdiff_t>(i)])); + if (stream->IsSerializationDeterministic() && map_field.size() > 1) { + for (const auto& entry : ::_pbi::MapSorterPtr<MapType>(map_field)) { + target = WireHelper::InternalSerialize(1, entry.first, entry.second, target, stream); + check_utf8(entry); } } else { - for (::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >::const_iterator - it = this->_internal_fields().begin(); - it != this->_internal_fields().end(); ++it) { - target = Struct_FieldsEntry_DoNotUse::Funcs::InternalSerialize(1, it->first, it->second, target, stream); - Utf8Check::Check(&(*it)); + for (const auto& entry : map_field) { + target = WireHelper::InternalSerialize(1, entry.first, entry.second, target, stream); + check_utf8(entry); } } } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Struct) @@ -358,30 +362,26 @@ size_t Struct::ByteSizeLong() const { total_size += Struct_FieldsEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Struct::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Struct::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Struct::GetClassData() const { return &_class_data_; } -void Struct::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Struct *>(to)->MergeFrom( - static_cast<const Struct &>(from)); -} - -void Struct::MergeFrom(const Struct& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Struct) - GOOGLE_DCHECK_NE(&from, this); +void Struct::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Struct*>(&to_msg); + auto& from = static_cast<const Struct&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Struct) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - fields_.MergeFrom(from.fields_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.fields_.MergeFrom(from._impl_.fields_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Struct::CopyFrom(const Struct& from) { @@ -398,11 +398,11 @@ bool Struct::IsInitialized() const { void Struct::InternalSwap(Struct* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - fields_.InternalSwap(&other->fields_); + _impl_.fields_.InternalSwap(&other->_impl_.fields_); } ::PROTOBUF_NAMESPACE_ID::Metadata Struct::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, file_level_metadata_google_2fprotobuf_2fstruct_2eproto[1]); } @@ -417,24 +417,24 @@ class Value::_Internal { const ::PROTOBUF_NAMESPACE_ID::Struct& Value::_Internal::struct_value(const Value* msg) { - return *msg->kind_.struct_value_; + return *msg->_impl_.kind_.struct_value_; } const ::PROTOBUF_NAMESPACE_ID::ListValue& Value::_Internal::list_value(const Value* msg) { - return *msg->kind_.list_value_; + return *msg->_impl_.kind_.list_value_; } void Value::set_allocated_struct_value(::PROTOBUF_NAMESPACE_ID::Struct* struct_value) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); clear_kind(); if (struct_value) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::Struct>::GetOwningArena(struct_value); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(struct_value); if (message_arena != submessage_arena) { struct_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, struct_value, submessage_arena); } set_has_struct_value(); - kind_.struct_value_ = struct_value; + _impl_.kind_.struct_value_ = struct_value; } // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value) } @@ -443,52 +443,57 @@ void Value::set_allocated_list_value(::PROTOBUF_NAMESPACE_ID::ListValue* list_va clear_kind(); if (list_value) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::PROTOBUF_NAMESPACE_ID::ListValue>::GetOwningArena(list_value); + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(list_value); if (message_arena != submessage_arena) { list_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, list_value, submessage_arena); } set_has_list_value(); - kind_.list_value_ = list_value; + _impl_.kind_.list_value_ = list_value; } // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value) } Value::Value(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Value) } Value::Value(const Value& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + Value* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.kind_){} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_._oneof_case_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); clear_has_kind(); switch (from.kind_case()) { case kNullValue: { - _internal_set_null_value(from._internal_null_value()); + _this->_internal_set_null_value(from._internal_null_value()); break; } case kNumberValue: { - _internal_set_number_value(from._internal_number_value()); + _this->_internal_set_number_value(from._internal_number_value()); break; } case kStringValue: { - _internal_set_string_value(from._internal_string_value()); + _this->_internal_set_string_value(from._internal_string_value()); break; } case kBoolValue: { - _internal_set_bool_value(from._internal_bool_value()); + _this->_internal_set_bool_value(from._internal_bool_value()); break; } case kStructValue: { - _internal_mutable_struct_value()->::PROTOBUF_NAMESPACE_ID::Struct::MergeFrom(from._internal_struct_value()); + _this->_internal_mutable_struct_value()->::PROTOBUF_NAMESPACE_ID::Struct::MergeFrom( + from._internal_struct_value()); break; } case kListValue: { - _internal_mutable_list_value()->::PROTOBUF_NAMESPACE_ID::ListValue::MergeFrom(from._internal_list_value()); + _this->_internal_mutable_list_value()->::PROTOBUF_NAMESPACE_ID::ListValue::MergeFrom( + from._internal_list_value()); break; } case KIND_NOT_SET: { @@ -498,15 +503,25 @@ Value::Value(const Value& from) // @@protoc_insertion_point(copy_constructor:google.protobuf.Value) } -inline void Value::SharedCtor() { -clear_has_kind(); +inline void Value::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.kind_){} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_._oneof_case_)*/{} + }; + clear_has_kind(); } Value::~Value() { // @@protoc_insertion_point(destructor:google.protobuf.Value) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Value::SharedDtor() { @@ -516,14 +531,8 @@ inline void Value::SharedDtor() { } } -void Value::ArenaDtor(void* object) { - Value* _this = reinterpret_cast< Value* >(object); - (void)_this; -} -void Value::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Value::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Value::clear_kind() { @@ -538,7 +547,7 @@ void Value::clear_kind() { break; } case kStringValue: { - kind_.string_value_.Destroy(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_.kind_.string_value_.Destroy(); break; } case kBoolValue: { @@ -547,13 +556,13 @@ void Value::clear_kind() { } case kStructValue: { if (GetArenaForAllocation() == nullptr) { - delete kind_.struct_value_; + delete _impl_.kind_.struct_value_; } break; } case kListValue: { if (GetArenaForAllocation() == nullptr) { - delete kind_.list_value_; + delete _impl_.kind_.list_value_; } break; } @@ -561,7 +570,7 @@ void Value::clear_kind() { break; } } - _oneof_case_[0] = KIND_NOT_SET; + _impl_._oneof_case_[0] = KIND_NOT_SET; } @@ -575,11 +584,11 @@ void Value::Clear() { _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Value::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // .google.protobuf.NullValue null_value = 1; case 1: @@ -602,9 +611,9 @@ const char* Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) { auto str = _internal_mutable_string_value(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Value.string_value")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Value.string_value")); } else goto handle_unusual; continue; @@ -664,14 +673,14 @@ uint8_t* Value::_InternalSerialize( // .google.protobuf.NullValue null_value = 1; if (_internal_has_null_value()) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 1, this->_internal_null_value(), target); } // double number_value = 2; if (_internal_has_number_value()) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(2, this->_internal_number_value(), target); + target = ::_pbi::WireFormatLite::WriteDoubleToArray(2, this->_internal_number_value(), target); } // string string_value = 3; @@ -687,27 +696,25 @@ uint8_t* Value::_InternalSerialize( // bool bool_value = 4; if (_internal_has_bool_value()) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(4, this->_internal_bool_value(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(4, this->_internal_bool_value(), target); } // .google.protobuf.Struct struct_value = 5; if (_internal_has_struct_value()) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 5, _Internal::struct_value(this), target, stream); + InternalWriteMessage(5, _Internal::struct_value(this), + _Internal::struct_value(this).GetCachedSize(), target, stream); } // .google.protobuf.ListValue list_value = 6; if (_internal_has_list_value()) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 6, _Internal::list_value(this), target, stream); + InternalWriteMessage(6, _Internal::list_value(this), + _Internal::list_value(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Value) @@ -726,7 +733,7 @@ size_t Value::ByteSizeLong() const { // .google.protobuf.NullValue null_value = 1; case kNullValue: { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_null_value()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_null_value()); break; } // double number_value = 2; @@ -750,72 +757,70 @@ size_t Value::ByteSizeLong() const { case kStructValue: { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *kind_.struct_value_); + *_impl_.kind_.struct_value_); break; } // .google.protobuf.ListValue list_value = 6; case kListValue: { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *kind_.list_value_); + *_impl_.kind_.list_value_); break; } case KIND_NOT_SET: { break; } } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Value::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Value::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Value::GetClassData() const { return &_class_data_; } -void Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Value *>(to)->MergeFrom( - static_cast<const Value &>(from)); -} - -void Value::MergeFrom(const Value& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Value) - GOOGLE_DCHECK_NE(&from, this); +void Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Value*>(&to_msg); + auto& from = static_cast<const Value&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Value) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; switch (from.kind_case()) { case kNullValue: { - _internal_set_null_value(from._internal_null_value()); + _this->_internal_set_null_value(from._internal_null_value()); break; } case kNumberValue: { - _internal_set_number_value(from._internal_number_value()); + _this->_internal_set_number_value(from._internal_number_value()); break; } case kStringValue: { - _internal_set_string_value(from._internal_string_value()); + _this->_internal_set_string_value(from._internal_string_value()); break; } case kBoolValue: { - _internal_set_bool_value(from._internal_bool_value()); + _this->_internal_set_bool_value(from._internal_bool_value()); break; } case kStructValue: { - _internal_mutable_struct_value()->::PROTOBUF_NAMESPACE_ID::Struct::MergeFrom(from._internal_struct_value()); + _this->_internal_mutable_struct_value()->::PROTOBUF_NAMESPACE_ID::Struct::MergeFrom( + from._internal_struct_value()); break; } case kListValue: { - _internal_mutable_list_value()->::PROTOBUF_NAMESPACE_ID::ListValue::MergeFrom(from._internal_list_value()); + _this->_internal_mutable_list_value()->::PROTOBUF_NAMESPACE_ID::ListValue::MergeFrom( + from._internal_list_value()); break; } case KIND_NOT_SET: { break; } } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Value::CopyFrom(const Value& from) { @@ -832,12 +837,12 @@ bool Value::IsInitialized() const { void Value::InternalSwap(Value* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(kind_, other->kind_); - swap(_oneof_case_[0], other->_oneof_case_[0]); + swap(_impl_.kind_, other->_impl_.kind_); + swap(_impl_._oneof_case_[0], other->_impl_._oneof_case_[0]); } ::PROTOBUF_NAMESPACE_ID::Metadata Value::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, file_level_metadata_google_2fprotobuf_2fstruct_2eproto[2]); } @@ -850,43 +855,47 @@ class ListValue::_Internal { ListValue::ListValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - values_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.ListValue) } ListValue::ListValue(const ListValue& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - values_(from.values_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + ListValue* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.values_){from._impl_.values_} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.ListValue) } -inline void ListValue::SharedCtor() { +inline void ListValue::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.values_){arena} + , /*decltype(_impl_._cached_size_)*/{} + }; } ListValue::~ListValue() { // @@protoc_insertion_point(destructor:google.protobuf.ListValue) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void ListValue::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.values_.~RepeatedPtrField(); } -void ListValue::ArenaDtor(void* object) { - ListValue* _this = reinterpret_cast< ListValue* >(object); - (void)_this; -} -void ListValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void ListValue::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void ListValue::Clear() { @@ -895,15 +904,15 @@ void ListValue::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - values_.Clear(); + _impl_.values_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* ListValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* ListValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // repeated .google.protobuf.Value values = 1; case 1: @@ -948,15 +957,15 @@ uint8_t* ListValue::_InternalSerialize( (void) cached_has_bits; // repeated .google.protobuf.Value values = 1; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_values_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_values_size()); i < n; i++) { + const auto& repfield = this->_internal_values(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, this->_internal_values(i), target, stream); + InternalWriteMessage(1, repfield, repfield.GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ListValue) @@ -973,35 +982,31 @@ size_t ListValue::ByteSizeLong() const { // repeated .google.protobuf.Value values = 1; total_size += 1UL * this->_internal_values_size(); - for (const auto& msg : this->values_) { + for (const auto& msg : this->_impl_.values_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData ListValue::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, ListValue::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ListValue::GetClassData() const { return &_class_data_; } -void ListValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<ListValue *>(to)->MergeFrom( - static_cast<const ListValue &>(from)); -} - -void ListValue::MergeFrom(const ListValue& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ListValue) - GOOGLE_DCHECK_NE(&from, this); +void ListValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<ListValue*>(&to_msg); + auto& from = static_cast<const ListValue&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ListValue) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - values_.MergeFrom(from.values_); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_impl_.values_.MergeFrom(from._impl_.values_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void ListValue::CopyFrom(const ListValue& from) { @@ -1018,11 +1023,11 @@ bool ListValue::IsInitialized() const { void ListValue::InternalSwap(ListValue* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - values_.InternalSwap(&other->values_); + _impl_.values_.InternalSwap(&other->_impl_.values_); } ::PROTOBUF_NAMESPACE_ID::Metadata ListValue::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fstruct_2eproto_getter, &descriptor_table_google_2fprotobuf_2fstruct_2eproto_once, file_level_metadata_google_2fprotobuf_2fstruct_2eproto[3]); } @@ -1030,16 +1035,20 @@ void ListValue::InternalSwap(ListValue* other) { // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Struct* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Struct >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Struct* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Struct >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Struct >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Value* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Value >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Value* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Value >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Value >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ListValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ListValue >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::ListValue* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ListValue >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::ListValue >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/thirdparty/protobuf/struct.pb.h b/r5dev/thirdparty/protobuf/struct.pb.h index a4857074..175297ea 100644 --- a/r5dev/thirdparty/protobuf/struct.pb.h +++ b/r5dev/thirdparty/protobuf/struct.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/generated_message_reflection.h> @@ -46,14 +45,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fstruct_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[4] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto; @@ -115,7 +106,7 @@ public: ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> SuperType; Struct_FieldsEntry_DoNotUse(); - explicit constexpr Struct_FieldsEntry_DoNotUse( + explicit PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUse( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); explicit Struct_FieldsEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena); void MergeFrom(const Struct_FieldsEntry_DoNotUse& other); @@ -126,6 +117,7 @@ public: static bool ValidateValue(void*) { return true; } using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto; }; // ------------------------------------------------------------------- @@ -135,7 +127,7 @@ class PROTOBUF_EXPORT Struct final : public: inline Struct() : Struct(nullptr) {} ~Struct() override; - explicit constexpr Struct(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Struct(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Struct(const Struct& from); Struct(Struct&& from) noexcept @@ -210,9 +202,11 @@ class PROTOBUF_EXPORT Struct final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Struct& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Struct& from); + void MergeFrom( const Struct& from) { + Struct::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -221,10 +215,10 @@ class PROTOBUF_EXPORT Struct final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Struct* other); @@ -239,7 +233,6 @@ class PROTOBUF_EXPORT Struct final : bool is_message_owned = false); private: static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -279,12 +272,15 @@ class PROTOBUF_EXPORT Struct final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::MapField< - Struct_FieldsEntry_DoNotUse, - std::string, ::PROTOBUF_NAMESPACE_ID::Value, - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> fields_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::MapField< + Struct_FieldsEntry_DoNotUse, + std::string, ::PROTOBUF_NAMESPACE_ID::Value, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> fields_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto; }; // ------------------------------------------------------------------- @@ -294,7 +290,7 @@ class PROTOBUF_EXPORT Value final : public: inline Value() : Value(nullptr) {} ~Value() override; - explicit constexpr Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Value(const Value& from); Value(Value&& from) noexcept @@ -379,9 +375,11 @@ class PROTOBUF_EXPORT Value final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Value& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Value& from); + void MergeFrom( const Value& from) { + Value::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -390,10 +388,10 @@ class PROTOBUF_EXPORT Value final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Value* other); @@ -406,9 +404,6 @@ class PROTOBUF_EXPORT Value final : protected: explicit Value(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -539,19 +534,22 @@ class PROTOBUF_EXPORT Value final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - union KindUnion { - constexpr KindUnion() : _constinit_{} {} - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized _constinit_; - int null_value_; - double number_value_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr string_value_; - bool bool_value_; - ::PROTOBUF_NAMESPACE_ID::Struct* struct_value_; - ::PROTOBUF_NAMESPACE_ID::ListValue* list_value_; - } kind_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - uint32_t _oneof_case_[1]; + struct Impl_ { + union KindUnion { + constexpr KindUnion() : _constinit_{} {} + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized _constinit_; + int null_value_; + double number_value_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr string_value_; + bool bool_value_; + ::PROTOBUF_NAMESPACE_ID::Struct* struct_value_; + ::PROTOBUF_NAMESPACE_ID::ListValue* list_value_; + } kind_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + uint32_t _oneof_case_[1]; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto; }; // ------------------------------------------------------------------- @@ -561,7 +559,7 @@ class PROTOBUF_EXPORT ListValue final : public: inline ListValue() : ListValue(nullptr) {} ~ListValue() override; - explicit constexpr ListValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR ListValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ListValue(const ListValue& from); ListValue(ListValue&& from) noexcept @@ -636,9 +634,11 @@ class PROTOBUF_EXPORT ListValue final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const ListValue& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const ListValue& from); + void MergeFrom( const ListValue& from) { + ListValue::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -647,10 +647,10 @@ class PROTOBUF_EXPORT ListValue final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(ListValue* other); @@ -663,9 +663,6 @@ class PROTOBUF_EXPORT ListValue final : protected: explicit ListValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -705,8 +702,11 @@ class PROTOBUF_EXPORT ListValue final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Value > values_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Value > values_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto; }; // =================================================================== @@ -724,17 +724,17 @@ class PROTOBUF_EXPORT ListValue final : // map<string, .google.protobuf.Value> fields = 1; inline int Struct::_internal_fields_size() const { - return fields_.size(); + return _impl_.fields_.size(); } inline int Struct::fields_size() const { return _internal_fields_size(); } inline void Struct::clear_fields() { - fields_.Clear(); + _impl_.fields_.Clear(); } inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >& Struct::_internal_fields() const { - return fields_.GetMap(); + return _impl_.fields_.GetMap(); } inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >& Struct::fields() const { @@ -743,7 +743,7 @@ Struct::fields() const { } inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >* Struct::_internal_mutable_fields() { - return fields_.MutableMap(); + return _impl_.fields_.MutableMap(); } inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >* Struct::mutable_fields() { @@ -763,17 +763,17 @@ inline bool Value::has_null_value() const { return _internal_has_null_value(); } inline void Value::set_has_null_value() { - _oneof_case_[0] = kNullValue; + _impl_._oneof_case_[0] = kNullValue; } inline void Value::clear_null_value() { if (_internal_has_null_value()) { - kind_.null_value_ = 0; + _impl_.kind_.null_value_ = 0; clear_has_kind(); } } inline ::PROTOBUF_NAMESPACE_ID::NullValue Value::_internal_null_value() const { if (_internal_has_null_value()) { - return static_cast< ::PROTOBUF_NAMESPACE_ID::NullValue >(kind_.null_value_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::NullValue >(_impl_.kind_.null_value_); } return static_cast< ::PROTOBUF_NAMESPACE_ID::NullValue >(0); } @@ -786,7 +786,7 @@ inline void Value::_internal_set_null_value(::PROTOBUF_NAMESPACE_ID::NullValue v clear_kind(); set_has_null_value(); } - kind_.null_value_ = value; + _impl_.kind_.null_value_ = value; } inline void Value::set_null_value(::PROTOBUF_NAMESPACE_ID::NullValue value) { _internal_set_null_value(value); @@ -801,17 +801,17 @@ inline bool Value::has_number_value() const { return _internal_has_number_value(); } inline void Value::set_has_number_value() { - _oneof_case_[0] = kNumberValue; + _impl_._oneof_case_[0] = kNumberValue; } inline void Value::clear_number_value() { if (_internal_has_number_value()) { - kind_.number_value_ = 0; + _impl_.kind_.number_value_ = 0; clear_has_kind(); } } inline double Value::_internal_number_value() const { if (_internal_has_number_value()) { - return kind_.number_value_; + return _impl_.kind_.number_value_; } return 0; } @@ -820,7 +820,7 @@ inline void Value::_internal_set_number_value(double value) { clear_kind(); set_has_number_value(); } - kind_.number_value_ = value; + _impl_.kind_.number_value_ = value; } inline double Value::number_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.number_value) @@ -839,11 +839,11 @@ inline bool Value::has_string_value() const { return _internal_has_string_value(); } inline void Value::set_has_string_value() { - _oneof_case_[0] = kStringValue; + _impl_._oneof_case_[0] = kStringValue; } inline void Value::clear_string_value() { if (_internal_has_string_value()) { - kind_.string_value_.Destroy(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + _impl_.kind_.string_value_.Destroy(); clear_has_kind(); } } @@ -856,9 +856,9 @@ inline void Value::set_string_value(ArgT0&& arg0, ArgT... args) { if (!_internal_has_string_value()) { clear_kind(); set_has_string_value(); - kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.kind_.string_value_.InitDefault(); } - kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.kind_.string_value_.Set( static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) } inline std::string* Value::mutable_string_value() { @@ -868,7 +868,7 @@ inline std::string* Value::mutable_string_value() { } inline const std::string& Value::_internal_string_value() const { if (_internal_has_string_value()) { - return kind_.string_value_.Get(); + return _impl_.kind_.string_value_.Get(); } return ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(); } @@ -876,24 +876,23 @@ inline void Value::_internal_set_string_value(const std::string& value) { if (!_internal_has_string_value()) { clear_kind(); set_has_string_value(); - kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.kind_.string_value_.InitDefault(); } - kind_.string_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.kind_.string_value_.Set(value, GetArenaForAllocation()); } inline std::string* Value::_internal_mutable_string_value() { if (!_internal_has_string_value()) { clear_kind(); set_has_string_value(); - kind_.string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.kind_.string_value_.InitDefault(); } - return kind_.string_value_.Mutable( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.kind_.string_value_.Mutable( GetArenaForAllocation()); } inline std::string* Value::release_string_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.string_value) if (_internal_has_string_value()) { clear_has_kind(); - return kind_.string_value_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.kind_.string_value_.Release(); } else { return nullptr; } @@ -904,11 +903,7 @@ inline void Value::set_allocated_string_value(std::string* string_value) { } if (string_value != nullptr) { set_has_string_value(); - kind_.string_value_.UnsafeSetDefault(string_value); - ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArenaForAllocation(); - if (arena != nullptr) { - arena->Own(string_value); - } + _impl_.kind_.string_value_.InitAllocated(string_value, GetArenaForAllocation()); } // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value) } @@ -921,17 +916,17 @@ inline bool Value::has_bool_value() const { return _internal_has_bool_value(); } inline void Value::set_has_bool_value() { - _oneof_case_[0] = kBoolValue; + _impl_._oneof_case_[0] = kBoolValue; } inline void Value::clear_bool_value() { if (_internal_has_bool_value()) { - kind_.bool_value_ = false; + _impl_.kind_.bool_value_ = false; clear_has_kind(); } } inline bool Value::_internal_bool_value() const { if (_internal_has_bool_value()) { - return kind_.bool_value_; + return _impl_.kind_.bool_value_; } return false; } @@ -940,7 +935,7 @@ inline void Value::_internal_set_bool_value(bool value) { clear_kind(); set_has_bool_value(); } - kind_.bool_value_ = value; + _impl_.kind_.bool_value_ = value; } inline bool Value::bool_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.bool_value) @@ -959,12 +954,12 @@ inline bool Value::has_struct_value() const { return _internal_has_struct_value(); } inline void Value::set_has_struct_value() { - _oneof_case_[0] = kStructValue; + _impl_._oneof_case_[0] = kStructValue; } inline void Value::clear_struct_value() { if (_internal_has_struct_value()) { if (GetArenaForAllocation() == nullptr) { - delete kind_.struct_value_; + delete _impl_.kind_.struct_value_; } clear_has_kind(); } @@ -973,11 +968,11 @@ inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::release_struct_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.struct_value) if (_internal_has_struct_value()) { clear_has_kind(); - ::PROTOBUF_NAMESPACE_ID::Struct* temp = kind_.struct_value_; + ::PROTOBUF_NAMESPACE_ID::Struct* temp = _impl_.kind_.struct_value_; if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - kind_.struct_value_ = nullptr; + _impl_.kind_.struct_value_ = nullptr; return temp; } else { return nullptr; @@ -985,7 +980,7 @@ inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::release_struct_value() { } inline const ::PROTOBUF_NAMESPACE_ID::Struct& Value::_internal_struct_value() const { return _internal_has_struct_value() - ? *kind_.struct_value_ + ? *_impl_.kind_.struct_value_ : reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::Struct&>(::PROTOBUF_NAMESPACE_ID::_Struct_default_instance_); } inline const ::PROTOBUF_NAMESPACE_ID::Struct& Value::struct_value() const { @@ -996,8 +991,8 @@ inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::unsafe_arena_release_struct_value // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.struct_value) if (_internal_has_struct_value()) { clear_has_kind(); - ::PROTOBUF_NAMESPACE_ID::Struct* temp = kind_.struct_value_; - kind_.struct_value_ = nullptr; + ::PROTOBUF_NAMESPACE_ID::Struct* temp = _impl_.kind_.struct_value_; + _impl_.kind_.struct_value_ = nullptr; return temp; } else { return nullptr; @@ -1007,7 +1002,7 @@ inline void Value::unsafe_arena_set_allocated_struct_value(::PROTOBUF_NAMESPACE_ clear_kind(); if (struct_value) { set_has_struct_value(); - kind_.struct_value_ = struct_value; + _impl_.kind_.struct_value_ = struct_value; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value) } @@ -1015,9 +1010,9 @@ inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::_internal_mutable_struct_value() if (!_internal_has_struct_value()) { clear_kind(); set_has_struct_value(); - kind_.struct_value_ = CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Struct >(GetArenaForAllocation()); + _impl_.kind_.struct_value_ = CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Struct >(GetArenaForAllocation()); } - return kind_.struct_value_; + return _impl_.kind_.struct_value_; } inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::mutable_struct_value() { ::PROTOBUF_NAMESPACE_ID::Struct* _msg = _internal_mutable_struct_value(); @@ -1033,12 +1028,12 @@ inline bool Value::has_list_value() const { return _internal_has_list_value(); } inline void Value::set_has_list_value() { - _oneof_case_[0] = kListValue; + _impl_._oneof_case_[0] = kListValue; } inline void Value::clear_list_value() { if (_internal_has_list_value()) { if (GetArenaForAllocation() == nullptr) { - delete kind_.list_value_; + delete _impl_.kind_.list_value_; } clear_has_kind(); } @@ -1047,11 +1042,11 @@ inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::release_list_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.list_value) if (_internal_has_list_value()) { clear_has_kind(); - ::PROTOBUF_NAMESPACE_ID::ListValue* temp = kind_.list_value_; + ::PROTOBUF_NAMESPACE_ID::ListValue* temp = _impl_.kind_.list_value_; if (GetArenaForAllocation() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - kind_.list_value_ = nullptr; + _impl_.kind_.list_value_ = nullptr; return temp; } else { return nullptr; @@ -1059,7 +1054,7 @@ inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::release_list_value() { } inline const ::PROTOBUF_NAMESPACE_ID::ListValue& Value::_internal_list_value() const { return _internal_has_list_value() - ? *kind_.list_value_ + ? *_impl_.kind_.list_value_ : reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::ListValue&>(::PROTOBUF_NAMESPACE_ID::_ListValue_default_instance_); } inline const ::PROTOBUF_NAMESPACE_ID::ListValue& Value::list_value() const { @@ -1070,8 +1065,8 @@ inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::unsafe_arena_release_list_valu // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.list_value) if (_internal_has_list_value()) { clear_has_kind(); - ::PROTOBUF_NAMESPACE_ID::ListValue* temp = kind_.list_value_; - kind_.list_value_ = nullptr; + ::PROTOBUF_NAMESPACE_ID::ListValue* temp = _impl_.kind_.list_value_; + _impl_.kind_.list_value_ = nullptr; return temp; } else { return nullptr; @@ -1081,7 +1076,7 @@ inline void Value::unsafe_arena_set_allocated_list_value(::PROTOBUF_NAMESPACE_ID clear_kind(); if (list_value) { set_has_list_value(); - kind_.list_value_ = list_value; + _impl_.kind_.list_value_ = list_value; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.list_value) } @@ -1089,9 +1084,9 @@ inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::_internal_mutable_list_value() if (!_internal_has_list_value()) { clear_kind(); set_has_list_value(); - kind_.list_value_ = CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ListValue >(GetArenaForAllocation()); + _impl_.kind_.list_value_ = CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ListValue >(GetArenaForAllocation()); } - return kind_.list_value_; + return _impl_.kind_.list_value_; } inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::mutable_list_value() { ::PROTOBUF_NAMESPACE_ID::ListValue* _msg = _internal_mutable_list_value(); @@ -1103,10 +1098,10 @@ inline bool Value::has_kind() const { return kind_case() != KIND_NOT_SET; } inline void Value::clear_has_kind() { - _oneof_case_[0] = KIND_NOT_SET; + _impl_._oneof_case_[0] = KIND_NOT_SET; } inline Value::KindCase Value::kind_case() const { - return Value::KindCase(_oneof_case_[0]); + return Value::KindCase(_impl_._oneof_case_[0]); } // ------------------------------------------------------------------- @@ -1114,32 +1109,32 @@ inline Value::KindCase Value::kind_case() const { // repeated .google.protobuf.Value values = 1; inline int ListValue::_internal_values_size() const { - return values_.size(); + return _impl_.values_.size(); } inline int ListValue::values_size() const { return _internal_values_size(); } inline void ListValue::clear_values() { - values_.Clear(); + _impl_.values_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::Value* ListValue::mutable_values(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.ListValue.values) - return values_.Mutable(index); + return _impl_.values_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Value >* ListValue::mutable_values() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.ListValue.values) - return &values_; + return &_impl_.values_; } inline const ::PROTOBUF_NAMESPACE_ID::Value& ListValue::_internal_values(int index) const { - return values_.Get(index); + return _impl_.values_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::Value& ListValue::values(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.ListValue.values) return _internal_values(index); } inline ::PROTOBUF_NAMESPACE_ID::Value* ListValue::_internal_add_values() { - return values_.Add(); + return _impl_.values_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::Value* ListValue::add_values() { ::PROTOBUF_NAMESPACE_ID::Value* _add = _internal_add_values(); @@ -1149,7 +1144,7 @@ inline ::PROTOBUF_NAMESPACE_ID::Value* ListValue::add_values() { inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Value >& ListValue::values() const { // @@protoc_insertion_point(field_list:google.protobuf.ListValue.values) - return values_; + return _impl_.values_; } #ifdef __GNUC__ diff --git a/r5dev/thirdparty/protobuf/stubs/common.cc b/r5dev/thirdparty/protobuf/stubs/common.cc index 77ce16ff..2dc2d5f7 100644 --- a/r5dev/thirdparty/protobuf/stubs/common.cc +++ b/r5dev/thirdparty/protobuf/stubs/common.cc @@ -298,15 +298,15 @@ void DoNothing() {} // TODO(xiaofeng): PROTOBUF_LITTLE_ENDIAN is unfortunately defined in // google/protobuf/io/coded_stream.h and therefore can not be used here. // Maybe move that macro definition here in the future. -uint32 ghtonl(uint32 x) { +uint32_t ghtonl(uint32_t x) { union { - uint32 result; - uint8 result_array[4]; + uint32_t result; + uint8_t result_array[4]; }; - result_array[0] = static_cast<uint8>(x >> 24); - result_array[1] = static_cast<uint8>((x >> 16) & 0xFF); - result_array[2] = static_cast<uint8>((x >> 8) & 0xFF); - result_array[3] = static_cast<uint8>(x & 0xFF); + result_array[0] = static_cast<uint8_t>(x >> 24); + result_array[1] = static_cast<uint8_t>((x >> 16) & 0xFF); + result_array[2] = static_cast<uint8_t>((x >> 8) & 0xFF); + result_array[3] = static_cast<uint8_t>(x & 0xFF); return result; } diff --git a/r5dev/thirdparty/protobuf/stubs/common.h b/r5dev/thirdparty/protobuf/stubs/common.h index 4681f042..6db161b7 100644 --- a/r5dev/thirdparty/protobuf/stubs/common.h +++ b/r5dev/thirdparty/protobuf/stubs/common.h @@ -82,7 +82,7 @@ namespace internal { // The current version, represented as a single integer to make comparison // easier: major * 10^6 + minor * 10^3 + micro -#define GOOGLE_PROTOBUF_VERSION 3019004 +#define GOOGLE_PROTOBUF_VERSION 3021012 // A suffix string for alpha, beta or rc releases. Empty for stable releases. #define GOOGLE_PROTOBUF_VERSION_SUFFIX "" @@ -90,15 +90,15 @@ namespace internal { // The minimum header version which works with the current version of // the library. This constant should only be used by protoc's C++ code // generator. -static const int kMinHeaderVersionForLibrary = 3019000; +static const int kMinHeaderVersionForLibrary = 3021000; // The minimum protoc version which works with the current version of the // headers. -#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3019000 +#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3021000 // The minimum header version which works with the current version of // protoc. This constant should only be used in VerifyVersion(). -static const int kMinHeaderVersionForProtoc = 3019000; +static const int kMinHeaderVersionForProtoc = 3021000; // Verifies that the headers and libraries are compatible. Use the macro // below to call this. @@ -189,10 +189,6 @@ class FatalException : public std::exception { }; #endif -// This is at the end of the file instead of the beginning to work around a bug -// in some versions of MSVC. -using std::string; - } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/stubs/int128.cc b/r5dev/thirdparty/protobuf/stubs/int128.cc index f1129010..964823ce 100644 --- a/r5dev/thirdparty/protobuf/stubs/int128.cc +++ b/r5dev/thirdparty/protobuf/stubs/int128.cc @@ -57,14 +57,14 @@ const uint128_pod kuint128max = {uint64_t{0xFFFFFFFFFFFFFFFFu}, (pos) |= (sh); \ } \ } while (0) -static inline int Fls64(uint64 n) { +static inline int Fls64(uint64_t n) { GOOGLE_DCHECK_NE(0, n); int pos = 0; - STEP(uint64, n, pos, 0x20); - uint32 n32 = n; - STEP(uint32, n32, pos, 0x10); - STEP(uint32, n32, pos, 0x08); - STEP(uint32, n32, pos, 0x04); + STEP(uint64_t, n, pos, 0x20); + uint32_t n32 = n; + STEP(uint32_t, n32, pos, 0x10); + STEP(uint32_t, n32, pos, 0x08); + STEP(uint32_t, n32, pos, 0x04); return pos + ((uint64_t{0x3333333322221100u} >> (n32 << 2)) & 0x3); } #undef STEP @@ -72,7 +72,7 @@ static inline int Fls64(uint64 n) { // Like Fls64() above, but returns the 0-based position of the last set bit // (i.e., most significant bit) in the given uint128. The argument may not be 0. static inline int Fls128(uint128 n) { - if (uint64 hi = Uint128High64(n)) { + if (uint64_t hi = Uint128High64(n)) { return Fls64(hi) + 64; } return Fls64(Uint128Low64(n)); @@ -132,16 +132,16 @@ std::ostream& operator<<(std::ostream& o, const uint128& b) { switch (flags & std::ios::basefield) { case std::ios::hex: div = - static_cast<uint64>(uint64_t{0x1000000000000000u}); // 16^15 + static_cast<uint64_t>(uint64_t{0x1000000000000000u}); // 16^15 div_base_log = 15; break; case std::ios::oct: - div = static_cast<uint64>( + div = static_cast<uint64_t>( uint64_t{01000000000000000000000u}); // 8^21 div_base_log = 21; break; default: // std::ios::dec - div = static_cast<uint64>( + div = static_cast<uint64_t>( uint64_t{10000000000000000000u}); // 10^19 div_base_log = 19; break; @@ -173,12 +173,13 @@ std::ostream& operator<<(std::ostream& o, const uint128& b) { // Add the requisite padding. std::streamsize width = o.width(0); - if (width > rep.size()) { + auto repSize = static_cast<std::streamsize>(rep.size()); + if (width > repSize) { if ((flags & std::ios::adjustfield) == std::ios::left) { - rep.append(width - rep.size(), o.fill()); + rep.append(width - repSize, o.fill()); } else { - rep.insert(static_cast<std::string::size_type>(0), - width - rep.size(), o.fill()); + rep.insert(static_cast<std::string::size_type>(0), width - repSize, + o.fill()); } } diff --git a/r5dev/thirdparty/protobuf/stubs/int128.h b/r5dev/thirdparty/protobuf/stubs/int128.h index 0df5bffb..ca498617 100644 --- a/r5dev/thirdparty/protobuf/stubs/int128.h +++ b/r5dev/thirdparty/protobuf/stubs/int128.h @@ -53,17 +53,17 @@ struct uint128_pod; class PROTOBUF_EXPORT uint128 { public: UINT128_CONSTEXPR uint128(); // Sets to 0, but don't trust on this behavior. - UINT128_CONSTEXPR uint128(uint64 top, uint64 bottom); + UINT128_CONSTEXPR uint128(uint64_t top, uint64_t bottom); #ifndef SWIG UINT128_CONSTEXPR uint128(int bottom); - UINT128_CONSTEXPR uint128(uint32 bottom); // Top 96 bits = 0 + UINT128_CONSTEXPR uint128(uint32_t bottom); // Top 96 bits = 0 #endif - UINT128_CONSTEXPR uint128(uint64 bottom); // hi_ = 0 + UINT128_CONSTEXPR uint128(uint64_t bottom); // hi_ = 0 UINT128_CONSTEXPR uint128(const uint128_pod &val); // Trivial copy constructor, assignment operator and destructor. - void Initialize(uint64 top, uint64 bottom); + void Initialize(uint64_t top, uint64_t bottom); // Arithmetic operators. uint128& operator+=(const uint128& b); @@ -82,8 +82,8 @@ class PROTOBUF_EXPORT uint128 { uint128& operator++(); uint128& operator--(); - friend uint64 Uint128Low64(const uint128& v); - friend uint64 Uint128High64(const uint128& v); + friend uint64_t Uint128Low64(const uint128& v); + friend uint64_t Uint128High64(const uint128& v); // We add "std::" to avoid including all of port.h. PROTOBUF_EXPORT friend std::ostream& operator<<(std::ostream& o, @@ -96,12 +96,12 @@ class PROTOBUF_EXPORT uint128 { // Little-endian memory order optimizations can benefit from // having lo_ first, hi_ last. // See util/endian/endian.h and Load128/Store128 for storing a uint128. - uint64 lo_; - uint64 hi_; + uint64_t lo_; + uint64_t hi_; // Not implemented, just declared for catching automatic type conversions. - uint128(uint8); - uint128(uint16); + uint128(uint8_t); + uint128(uint16_t); uint128(float v); uint128(double v); }; @@ -114,8 +114,8 @@ struct uint128_pod { // of static instances, which is the primary reason for this struct in the // first place. This does not seem to defeat any optimizations wrt // operations involving this struct. - uint64 hi; - uint64 lo; + uint64_t hi; + uint64_t lo; }; PROTOBUF_EXPORT extern const uint128_pod kuint128max; @@ -127,8 +127,8 @@ PROTOBUF_EXPORT extern std::ostream& operator<<(std::ostream& o, // Methods to access low and high pieces of 128-bit value. // Defined externally from uint128 to facilitate conversion // to native 128-bit types when compilers support them. -inline uint64 Uint128Low64(const uint128& v) { return v.lo_; } -inline uint64 Uint128High64(const uint128& v) { return v.hi_; } +inline uint64_t Uint128Low64(const uint128& v) { return v.lo_; } +inline uint64_t Uint128High64(const uint128& v) { return v.hi_; } // TODO: perhaps it would be nice to have int128, a signed 128-bit type? @@ -144,22 +144,22 @@ inline bool operator!=(const uint128& lhs, const uint128& rhs) { } inline UINT128_CONSTEXPR uint128::uint128() : lo_(0), hi_(0) {} -inline UINT128_CONSTEXPR uint128::uint128(uint64 top, uint64 bottom) +inline UINT128_CONSTEXPR uint128::uint128(uint64_t top, uint64_t bottom) : lo_(bottom), hi_(top) {} inline UINT128_CONSTEXPR uint128::uint128(const uint128_pod& v) : lo_(v.lo), hi_(v.hi) {} -inline UINT128_CONSTEXPR uint128::uint128(uint64 bottom) +inline UINT128_CONSTEXPR uint128::uint128(uint64_t bottom) : lo_(bottom), hi_(0) {} #ifndef SWIG -inline UINT128_CONSTEXPR uint128::uint128(uint32 bottom) +inline UINT128_CONSTEXPR uint128::uint128(uint32_t bottom) : lo_(bottom), hi_(0) {} inline UINT128_CONSTEXPR uint128::uint128(int bottom) - : lo_(bottom), hi_(static_cast<int64>((bottom < 0) ? -1 : 0)) {} + : lo_(bottom), hi_(static_cast<int64_t>((bottom < 0) ? -1 : 0)) {} #endif #undef UINT128_CONSTEXPR -inline void uint128::Initialize(uint64 top, uint64 bottom) { +inline void uint128::Initialize(uint64_t top, uint64_t bottom) { hi_ = top; lo_ = bottom; } @@ -183,9 +183,9 @@ CMP128(<=) // Unary operators inline uint128 operator-(const uint128& val) { - const uint64 hi_flip = ~Uint128High64(val); - const uint64 lo_flip = ~Uint128Low64(val); - const uint64 lo_add = lo_flip + 1; + const uint64_t hi_flip = ~Uint128High64(val); + const uint64_t lo_flip = ~Uint128Low64(val); + const uint64_t lo_add = lo_flip + 1; if (lo_add < lo_flip) { return uint128(hi_flip + 1, lo_add); } @@ -235,9 +235,9 @@ inline uint128 operator<<(const uint128& val, int amount) { if (amount == 0) { return val; } - uint64 new_hi = (Uint128High64(val) << amount) | - (Uint128Low64(val) >> (64 - amount)); - uint64 new_lo = Uint128Low64(val) << amount; + uint64_t new_hi = (Uint128High64(val) << amount) | + (Uint128Low64(val) >> (64 - amount)); + uint64_t new_lo = Uint128Low64(val) << amount; return uint128(new_hi, new_lo); } else if (amount < 128) { return uint128(Uint128Low64(val) << (amount - 64), 0); @@ -252,9 +252,9 @@ inline uint128 operator>>(const uint128& val, int amount) { if (amount == 0) { return val; } - uint64 new_hi = Uint128High64(val) >> amount; - uint64 new_lo = (Uint128Low64(val) >> amount) | - (Uint128High64(val) << (64 - amount)); + uint64_t new_hi = Uint128High64(val) >> amount; + uint64_t new_lo = (Uint128Low64(val) >> amount) | + (Uint128High64(val) << (64 - amount)); return uint128(new_hi, new_lo); } else if (amount < 128) { return uint128(0, Uint128High64(val) >> (amount - 64)); @@ -319,7 +319,7 @@ inline uint128 operator%(const uint128& lhs, const uint128& rhs) { inline uint128& uint128::operator+=(const uint128& b) { hi_ += b.hi_; - uint64 lolo = lo_ + b.lo_; + uint64_t lolo = lo_ + b.lo_; if (lolo < lo_) ++hi_; lo_ = lolo; @@ -335,19 +335,19 @@ inline uint128& uint128::operator-=(const uint128& b) { } inline uint128& uint128::operator*=(const uint128& b) { - uint64 a96 = hi_ >> 32; - uint64 a64 = hi_ & 0xffffffffu; - uint64 a32 = lo_ >> 32; - uint64 a00 = lo_ & 0xffffffffu; - uint64 b96 = b.hi_ >> 32; - uint64 b64 = b.hi_ & 0xffffffffu; - uint64 b32 = b.lo_ >> 32; - uint64 b00 = b.lo_ & 0xffffffffu; + uint64_t a96 = hi_ >> 32; + uint64_t a64 = hi_ & 0xffffffffu; + uint64_t a32 = lo_ >> 32; + uint64_t a00 = lo_ & 0xffffffffu; + uint64_t b96 = b.hi_ >> 32; + uint64_t b64 = b.hi_ & 0xffffffffu; + uint64_t b32 = b.lo_ >> 32; + uint64_t b00 = b.lo_ & 0xffffffffu; // multiply [a96 .. a00] x [b96 .. b00] // terms higher than c96 disappear off the high side // terms c96 and c64 are safe to ignore carry bit - uint64 c96 = a96 * b00 + a64 * b32 + a32 * b64 + a00 * b96; - uint64 c64 = a64 * b00 + a32 * b32 + a00 * b64; + uint64_t c96 = a96 * b00 + a64 * b32 + a32 * b64 + a00 * b96; + uint64_t c64 = a64 * b00 + a32 * b32 + a00 * b64; this->hi_ = (c96 << 32) + c64; this->lo_ = 0; // add terms after this one at a time to capture carry diff --git a/r5dev/thirdparty/protobuf/stubs/int128_unittest.cc b/r5dev/thirdparty/protobuf/stubs/int128_unittest.cc index 9afcd769..27f95d4b 100644 --- a/r5dev/thirdparty/protobuf/stubs/int128_unittest.cc +++ b/r5dev/thirdparty/protobuf/stubs/int128_unittest.cc @@ -53,7 +53,7 @@ TEST(Int128, AllTests) { uint128 bigger(2001, 1); uint128 biggest(kuint128max); uint128 high_low(1, 0); - uint128 low_high(0, kuint64max); + uint128 low_high(0, std::numeric_limits<uint64_t>::max()); EXPECT_LT(one, two); EXPECT_GT(two, one); EXPECT_LT(one, big); @@ -121,8 +121,8 @@ TEST(Int128, AllTests) { big_copy = big; EXPECT_EQ(big >> 128, big_copy >>= 128); - EXPECT_EQ(Uint128High64(biggest), kuint64max); - EXPECT_EQ(Uint128Low64(biggest), kuint64max); + EXPECT_EQ(Uint128High64(biggest), std::numeric_limits<uint64_t>::max()); + EXPECT_EQ(Uint128Low64(biggest), std::numeric_limits<uint64_t>::max()); EXPECT_EQ(zero + one, one); EXPECT_EQ(one + one, two); EXPECT_EQ(big_minus_one + one, big); @@ -131,13 +131,13 @@ TEST(Int128, AllTests) { EXPECT_EQ(zero - one, biggest); EXPECT_EQ(big - big, zero); EXPECT_EQ(big - one, big_minus_one); - EXPECT_EQ(big + kuint64max, bigger); + EXPECT_EQ(big + std::numeric_limits<uint64_t>::max(), bigger); EXPECT_EQ(biggest + 1, zero); EXPECT_EQ(zero - 1, biggest); EXPECT_EQ(high_low - one, low_high); EXPECT_EQ(low_high + one, high_low); EXPECT_EQ(Uint128High64((uint128(1) << 64) - 1), 0); - EXPECT_EQ(Uint128Low64((uint128(1) << 64) - 1), kuint64max); + EXPECT_EQ(Uint128Low64((uint128(1) << 64) - 1), std::numeric_limits<uint64_t>::max()); EXPECT_TRUE(!!one); EXPECT_TRUE(!!high_low); EXPECT_FALSE(!!zero); @@ -317,7 +317,7 @@ TEST(Int128, AliasTests) { x1 += x1; EXPECT_EQ(x2, x1); - uint128 x3(1, static_cast<uint64>(1) << 63); + uint128 x3(1, static_cast<uint64_t>(1) << 63); uint128 x4(3, 0); x3 += x3; EXPECT_EQ(x4, x3); @@ -403,10 +403,10 @@ TEST(Int128, DivideAndMod) { EXPECT_EQ(expected_r, result_r); } -static uint64 RandomUint64() { - uint64 v1 = rand(); - uint64 v2 = rand(); - uint64 v3 = rand(); +static uint64_t RandomUint64() { + uint64_t v1 = rand(); + uint64_t v2 = rand(); + uint64_t v3 = rand(); return v1 * v2 + v3; } diff --git a/r5dev/thirdparty/protobuf/stubs/platform_macros.h b/r5dev/thirdparty/protobuf/stubs/platform_macros.h index 24799600..d10faf9a 100644 --- a/r5dev/thirdparty/protobuf/stubs/platform_macros.h +++ b/r5dev/thirdparty/protobuf/stubs/platform_macros.h @@ -122,11 +122,11 @@ GOOGLE_PROTOBUF_PLATFORM_ERROR #undef GOOGLE_PROTOBUF_PLATFORM_ERROR -#if defined(GOOGLE_PROTOBUF_OS_ANDROID) || defined(GOOGLE_PROTOBUF_OS_IPHONE) || defined(__OpenBSD__) +#if defined(GOOGLE_PROTOBUF_OS_ANDROID) || defined(GOOGLE_PROTOBUF_OS_IPHONE) // Android ndk does not support the __thread keyword very well yet. Here // we use pthread_key_create()/pthread_getspecific()/... methods for // TLS support on android. -// iOS and OpenBSD also do not support the __thread keyword. +// iOS also does not support the __thread keyword. #define GOOGLE_PROTOBUF_NO_THREADLOCAL #endif diff --git a/r5dev/thirdparty/protobuf/stubs/port.h b/r5dev/thirdparty/protobuf/stubs/port.h index 24816966..d7e67f3c 100644 --- a/r5dev/thirdparty/protobuf/stubs/port.h +++ b/r5dev/thirdparty/protobuf/stubs/port.h @@ -163,68 +163,68 @@ void __sanitizer_unaligned_store64(void *p, uint64_t v); } // extern "C" #endif // __cplusplus -inline uint16 GOOGLE_UNALIGNED_LOAD16(const void *p) { +inline uint16_t GOOGLE_UNALIGNED_LOAD16(const void *p) { return __sanitizer_unaligned_load16(p); } -inline uint32 GOOGLE_UNALIGNED_LOAD32(const void *p) { +inline uint32_t GOOGLE_UNALIGNED_LOAD32(const void *p) { return __sanitizer_unaligned_load32(p); } -inline uint64 GOOGLE_UNALIGNED_LOAD64(const void *p) { +inline uint64_t GOOGLE_UNALIGNED_LOAD64(const void *p) { return __sanitizer_unaligned_load64(p); } -inline void GOOGLE_UNALIGNED_STORE16(void *p, uint16 v) { +inline void GOOGLE_UNALIGNED_STORE16(void *p, uint16_t v) { __sanitizer_unaligned_store16(p, v); } -inline void GOOGLE_UNALIGNED_STORE32(void *p, uint32 v) { +inline void GOOGLE_UNALIGNED_STORE32(void *p, uint32_t v) { __sanitizer_unaligned_store32(p, v); } -inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) { +inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64_t v) { __sanitizer_unaligned_store64(p, v); } #elif defined(GOOGLE_PROTOBUF_USE_UNALIGNED) && GOOGLE_PROTOBUF_USE_UNALIGNED -#define GOOGLE_UNALIGNED_LOAD16(_p) (*reinterpret_cast<const uint16 *>(_p)) -#define GOOGLE_UNALIGNED_LOAD32(_p) (*reinterpret_cast<const uint32 *>(_p)) -#define GOOGLE_UNALIGNED_LOAD64(_p) (*reinterpret_cast<const uint64 *>(_p)) +#define GOOGLE_UNALIGNED_LOAD16(_p) (*reinterpret_cast<const uint16_t *>(_p)) +#define GOOGLE_UNALIGNED_LOAD32(_p) (*reinterpret_cast<const uint32_t *>(_p)) +#define GOOGLE_UNALIGNED_LOAD64(_p) (*reinterpret_cast<const uint64_t *>(_p)) -#define GOOGLE_UNALIGNED_STORE16(_p, _val) (*reinterpret_cast<uint16 *>(_p) = (_val)) -#define GOOGLE_UNALIGNED_STORE32(_p, _val) (*reinterpret_cast<uint32 *>(_p) = (_val)) -#define GOOGLE_UNALIGNED_STORE64(_p, _val) (*reinterpret_cast<uint64 *>(_p) = (_val)) +#define GOOGLE_UNALIGNED_STORE16(_p, _val) (*reinterpret_cast<uint16_t *>(_p) = (_val)) +#define GOOGLE_UNALIGNED_STORE32(_p, _val) (*reinterpret_cast<uint32_t *>(_p) = (_val)) +#define GOOGLE_UNALIGNED_STORE64(_p, _val) (*reinterpret_cast<uint64_t *>(_p) = (_val)) #else -inline uint16 GOOGLE_UNALIGNED_LOAD16(const void *p) { - uint16 t; +inline uint16_t GOOGLE_UNALIGNED_LOAD16(const void *p) { + uint16_t t; memcpy(&t, p, sizeof t); return t; } -inline uint32 GOOGLE_UNALIGNED_LOAD32(const void *p) { - uint32 t; +inline uint32_t GOOGLE_UNALIGNED_LOAD32(const void *p) { + uint32_t t; memcpy(&t, p, sizeof t); return t; } -inline uint64 GOOGLE_UNALIGNED_LOAD64(const void *p) { - uint64 t; +inline uint64_t GOOGLE_UNALIGNED_LOAD64(const void *p) { + uint64_t t; memcpy(&t, p, sizeof t); return t; } -inline void GOOGLE_UNALIGNED_STORE16(void *p, uint16 v) { +inline void GOOGLE_UNALIGNED_STORE16(void *p, uint16_t v) { memcpy(p, &v, sizeof v); } -inline void GOOGLE_UNALIGNED_STORE32(void *p, uint32 v) { +inline void GOOGLE_UNALIGNED_STORE32(void *p, uint32_t v) { memcpy(p, &v, sizeof v); } -inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) { +inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); } #endif @@ -251,14 +251,14 @@ inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) { #elif !defined(__linux__) && !defined(__ANDROID__) && !defined(__CYGWIN__) #ifndef bswap_16 -static inline uint16 bswap_16(uint16 x) { - return static_cast<uint16>(((x & 0xFF) << 8) | ((x & 0xFF00) >> 8)); +static inline uint16_t bswap_16(uint16_t x) { + return static_cast<uint16_t>(((x & 0xFF) << 8) | ((x & 0xFF00) >> 8)); } #define bswap_16(x) bswap_16(x) #endif #ifndef bswap_32 -static inline uint32 bswap_32(uint32 x) { +static inline uint32_t bswap_32(uint32_t x) { return (((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | @@ -268,7 +268,7 @@ static inline uint32 bswap_32(uint32 x) { #endif #ifndef bswap_64 -static inline uint64 bswap_64(uint64 x) { +static inline uint64_t bswap_64(uint64_t x) { return (((x & uint64_t{0xFFu}) << 56) | ((x & uint64_t{0xFF00u}) << 40) | ((x & uint64_t{0xFF0000u}) << 24) | ((x & uint64_t{0xFF000000u}) << 8) | @@ -287,9 +287,9 @@ static inline uint64 bswap_64(uint64 x) { class Bits { public: - static uint32 Log2FloorNonZero(uint32 n) { + static uint32_t Log2FloorNonZero(uint32_t n) { #if defined(__GNUC__) - return 31 ^ static_cast<uint32>(__builtin_clz(n)); + return 31 ^ static_cast<uint32_t>(__builtin_clz(n)); #elif defined(_MSC_VER) unsigned long where; _BitScanReverse(&where, n); @@ -299,7 +299,7 @@ class Bits { #endif } - static uint32 Log2FloorNonZero64(uint64 n) { + static uint32_t Log2FloorNonZero64(uint64_t n) { // Older versions of clang run into an instruction-selection failure when // it encounters __builtin_clzll: // https://bugs.chromium.org/p/nativeclient/issues/detail?id=4395 @@ -307,7 +307,7 @@ class Bits { // To work around this, when we build with those we use the portable // implementation instead. #if defined(__GNUC__) && !defined(GOOGLE_PROTOBUF_USE_PORTABLE_LOG2) - return 63 ^ static_cast<uint32>(__builtin_clzll(n)); + return 63 ^ static_cast<uint32_t>(__builtin_clzll(n)); #elif defined(_MSC_VER) && defined(_M_X64) unsigned long where; _BitScanReverse64(&where, n); @@ -317,14 +317,14 @@ class Bits { #endif } private: - static int Log2FloorNonZero_Portable(uint32 n) { + static int Log2FloorNonZero_Portable(uint32_t n) { if (n == 0) return -1; int log = 0; - uint32 value = n; + uint32_t value = n; for (int i = 4; i >= 0; --i) { int shift = (1 << i); - uint32 x = value >> shift; + uint32_t x = value >> shift; if (x != 0) { value = x; log += shift; @@ -334,11 +334,11 @@ class Bits { return log; } - static int Log2FloorNonZero64_Portable(uint64 n) { - const uint32 topbits = static_cast<uint32>(n >> 32); + static int Log2FloorNonZero64_Portable(uint64_t n) { + const uint32_t topbits = static_cast<uint32_t>(n >> 32); if (topbits == 0) { // Top bits are zero, so scan in bottom bits - return static_cast<int>(Log2FloorNonZero(static_cast<uint32>(n))); + return static_cast<int>(Log2FloorNonZero(static_cast<uint32_t>(n))); } else { return 32 + static_cast<int>(Log2FloorNonZero(topbits)); } @@ -347,60 +347,60 @@ class Bits { // =================================================================== // from google3/util/endian/endian.h -PROTOBUF_EXPORT uint32 ghtonl(uint32 x); +PROTOBUF_EXPORT uint32_t ghtonl(uint32_t x); class BigEndian { public: #ifdef PROTOBUF_LITTLE_ENDIAN - static uint16 FromHost16(uint16 x) { return bswap_16(x); } - static uint16 ToHost16(uint16 x) { return bswap_16(x); } + static uint16_t FromHost16(uint16_t x) { return bswap_16(x); } + static uint16_t ToHost16(uint16_t x) { return bswap_16(x); } - static uint32 FromHost32(uint32 x) { return bswap_32(x); } - static uint32 ToHost32(uint32 x) { return bswap_32(x); } + static uint32_t FromHost32(uint32_t x) { return bswap_32(x); } + static uint32_t ToHost32(uint32_t x) { return bswap_32(x); } - static uint64 FromHost64(uint64 x) { return bswap_64(x); } - static uint64 ToHost64(uint64 x) { return bswap_64(x); } + static uint64_t FromHost64(uint64_t x) { return bswap_64(x); } + static uint64_t ToHost64(uint64_t x) { return bswap_64(x); } static bool IsLittleEndian() { return true; } #else - static uint16 FromHost16(uint16 x) { return x; } - static uint16 ToHost16(uint16 x) { return x; } + static uint16_t FromHost16(uint16_t x) { return x; } + static uint16_t ToHost16(uint16_t x) { return x; } - static uint32 FromHost32(uint32 x) { return x; } - static uint32 ToHost32(uint32 x) { return x; } + static uint32_t FromHost32(uint32_t x) { return x; } + static uint32_t ToHost32(uint32_t x) { return x; } - static uint64 FromHost64(uint64 x) { return x; } - static uint64 ToHost64(uint64 x) { return x; } + static uint64_t FromHost64(uint64_t x) { return x; } + static uint64_t ToHost64(uint64_t x) { return x; } static bool IsLittleEndian() { return false; } #endif /* ENDIAN */ // Functions to do unaligned loads and stores in big-endian order. - static uint16 Load16(const void *p) { + static uint16_t Load16(const void *p) { return ToHost16(GOOGLE_UNALIGNED_LOAD16(p)); } - static void Store16(void *p, uint16 v) { + static void Store16(void *p, uint16_t v) { GOOGLE_UNALIGNED_STORE16(p, FromHost16(v)); } - static uint32 Load32(const void *p) { + static uint32_t Load32(const void *p) { return ToHost32(GOOGLE_UNALIGNED_LOAD32(p)); } - static void Store32(void *p, uint32 v) { + static void Store32(void *p, uint32_t v) { GOOGLE_UNALIGNED_STORE32(p, FromHost32(v)); } - static uint64 Load64(const void *p) { + static uint64_t Load64(const void *p) { return ToHost64(GOOGLE_UNALIGNED_LOAD64(p)); } - static void Store64(void *p, uint64 v) { + static void Store64(void *p, uint64_t v) { GOOGLE_UNALIGNED_STORE64(p, FromHost64(v)); } }; diff --git a/r5dev/thirdparty/protobuf/stubs/stl_util.h b/r5dev/thirdparty/protobuf/stubs/stl_util.h index a2bd9e28..97a6a169 100644 --- a/r5dev/thirdparty/protobuf/stubs/stl_util.h +++ b/r5dev/thirdparty/protobuf/stubs/stl_util.h @@ -37,6 +37,9 @@ #include <algorithm> +// Must be last. +#include <thirdparty/protobuf/port_def.inc> // NOLINT + namespace google { namespace protobuf { @@ -57,7 +60,7 @@ inline void STLStringResizeUninitializedAmortized(std::string* s, const size_t cap = s->capacity(); if (new_size > cap) { // Make sure to always grow by at least a factor of 2x. - s->reserve(std::max(new_size, 2 * cap)); + s->reserve(std::max<size_t>(new_size, 2 * cap)); } STLStringResizeUninitialized(s, new_size); } @@ -82,4 +85,6 @@ inline char* string_as_array(std::string* str) { } // namespace protobuf } // namespace google +#include <thirdparty/protobuf/port_undef.inc> // NOLINT + #endif // GOOGLE_PROTOBUF_STUBS_STL_UTIL_H__ diff --git a/r5dev/thirdparty/protobuf/stubs/structurally_valid.cc b/r5dev/thirdparty/protobuf/stubs/structurally_valid.cc index 4f8d3349..a951a5f3 100644 --- a/r5dev/thirdparty/protobuf/stubs/structurally_valid.cc +++ b/r5dev/thirdparty/protobuf/stubs/structurally_valid.cc @@ -42,9 +42,9 @@ namespace internal { // in making a string replacement, how many bytes to add 0..255, and the offset // 0..64k-1 of the replacement string in remap_string. struct RemapEntry { - uint8 delete_bytes; - uint8 add_bytes; - uint16 bytes_offset; + uint8_t delete_bytes; + uint8_t add_bytes; + uint16_t bytes_offset; }; // Exit type codes for state tables. All but the first get stuffed into @@ -81,18 +81,18 @@ typedef enum { // byte value and 6 for space-optimized tables subscripted by only six // significant bits in UTF-8 continuation bytes. typedef struct { - const uint32 state0; - const uint32 state0_size; - const uint32 total_size; + const uint32_t state0; + const uint32_t state0_size; + const uint32_t total_size; const int max_expand; const int entry_shift; const int bytes_per_entry; - const uint32 losub; - const uint32 hiadd; - const uint8* state_table; + const uint32_t losub; + const uint32_t hiadd; + const uint8_t* state_table; const RemapEntry* remap_base; - const uint8* remap_string; - const uint8* fast_state; + const uint8_t* remap_string; + const uint8_t* fast_state; } UTF8StateMachineObj; typedef UTF8StateMachineObj UTF8ScanObj; @@ -122,7 +122,7 @@ static const unsigned int utf8acceptnonsurrogates_BYTES = 1; static const unsigned int utf8acceptnonsurrogates_LOSUB = 0x20202020; static const unsigned int utf8acceptnonsurrogates_HIADD = 0x00000000; -static const uint8 utf8acceptnonsurrogates[] = { +static const uint8_t utf8acceptnonsurrogates[] = { // state[0] 0x000000 Byte 1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -376,11 +376,13 @@ static const UTF8ScanObj utf8acceptnonsurrogates_obj = { // Return true if current Tbl pointer is within state0 range // Note that unsigned compare checks both ends of range simultaneously -static inline bool InStateZero(const UTF8ScanObj* st, const uint8* Tbl) { - const uint8* Tbl0 = &st->state_table[st->state0]; - return (static_cast<uint32>(Tbl - Tbl0) < st->state0_size); +static inline bool InStateZero(const UTF8ScanObj* st, const uint8_t* Tbl) { + const uint8_t* Tbl0 = &st->state_table[st->state0]; + return (static_cast<uint32_t>(Tbl - Tbl0) < st->state0_size); } +namespace { + // Scan a UTF-8 string based on state table. // Always scan complete UTF-8 characters // Set number of bytes scanned. Return reason for exiting @@ -392,19 +394,19 @@ int UTF8GenericScan(const UTF8ScanObj* st, if (str_length == 0) return kExitOK; int eshift = st->entry_shift; - const uint8* isrc = reinterpret_cast<const uint8*>(str); - const uint8* src = isrc; - const uint8* srclimit = isrc + str_length; - const uint8* srclimit8 = str_length < 7 ? isrc : srclimit - 7; - const uint8* Tbl_0 = &st->state_table[st->state0]; + const uint8_t* isrc = reinterpret_cast<const uint8_t*>(str); + const uint8_t* src = isrc; + const uint8_t* srclimit = isrc + str_length; + const uint8_t* srclimit8 = str_length < 7 ? isrc : srclimit - 7; + const uint8_t* Tbl_0 = &st->state_table[st->state0]; DoAgain: // Do state-table scan int e = 0; - uint8 c; - const uint8* Tbl2 = &st->fast_state[0]; - const uint32 losub = st->losub; - const uint32 hiadd = st->hiadd; + uint8_t c; + const uint8_t* Tbl2 = &st->fast_state[0]; + const uint32_t losub = st->losub; + const uint32_t hiadd = st->hiadd; // Check initial few bytes one at a time until 8-byte aligned //---------------------------- while ((((uintptr_t)src & 0x07) != 0) && @@ -418,12 +420,12 @@ int UTF8GenericScan(const UTF8ScanObj* st, // including slowing slightly on cr/lf/ht //---------------------------- while (src < srclimit8) { - uint32 s0123 = (reinterpret_cast<const uint32 *>(src))[0]; - uint32 s4567 = (reinterpret_cast<const uint32 *>(src))[1]; + uint32_t s0123 = (reinterpret_cast<const uint32_t *>(src))[0]; + uint32_t s4567 = (reinterpret_cast<const uint32_t *>(src))[1]; src += 8; // This is a fast range check for all bytes in [lowsub..0x80-hiadd) - uint32 temp = (s0123 - losub) | (s0123 + hiadd) | - (s4567 - losub) | (s4567 + hiadd); + uint32_t temp = (s0123 - losub) | (s0123 + hiadd) | + (s4567 - losub) | (s4567 + hiadd); if ((temp & 0x80808080) != 0) { // We typically end up here on cr/lf/ht; src was incremented int e0123 = (Tbl2[src[-8]] | Tbl2[src[-7]]) | @@ -446,7 +448,7 @@ int UTF8GenericScan(const UTF8ScanObj* st, // Byte-at-a-time scan //---------------------------- - const uint8* Tbl = Tbl_0; + const uint8_t* Tbl = Tbl_0; while (src < srclimit) { c = *src; e = Tbl[c]; @@ -500,10 +502,10 @@ int UTF8GenericScanFastAscii(const UTF8ScanObj* st, *bytes_consumed = 0; if (str_length == 0) return kExitOK; - const uint8* isrc = reinterpret_cast<const uint8*>(str); - const uint8* src = isrc; - const uint8* srclimit = isrc + str_length; - const uint8* srclimit8 = str_length < 7 ? isrc : srclimit - 7; + const uint8_t* isrc = reinterpret_cast<const uint8_t*>(str); + const uint8_t* src = isrc; + const uint8_t* srclimit = isrc + str_length; + const uint8_t* srclimit8 = str_length < 7 ? isrc : srclimit - 7; int n; int rest_consumed; int exit_reason; @@ -515,8 +517,9 @@ int UTF8GenericScanFastAscii(const UTF8ScanObj* st, } if (((uintptr_t)src & 0x07) == 0) { while ((src < srclimit8) && - (((reinterpret_cast<const uint32*>(src)[0] | - reinterpret_cast<const uint32*>(src)[1]) & 0x80808080) == 0)) { + (((reinterpret_cast<const uint32_t*>(src)[0] | + reinterpret_cast<const uint32_t*>(src)[1]) & + 0x80808080) == 0)) { src += 8; } } @@ -539,7 +542,6 @@ int UTF8GenericScanFastAscii(const UTF8ScanObj* st, // UTF-8 strings. Since UTF-8 validation is only used for debugging // anyway, we simply always return success if initialization hasn't // occurred yet. -namespace { bool module_initialized_ = false; diff --git a/r5dev/thirdparty/protobuf/stubs/strutil.cc b/r5dev/thirdparty/protobuf/stubs/strutil.cc index 9459264b..702f7414 100644 --- a/r5dev/thirdparty/protobuf/stubs/strutil.cc +++ b/r5dev/thirdparty/protobuf/stubs/strutil.cc @@ -498,13 +498,13 @@ int CEscapeInternal(const char* src, int src_len, char* dest, // Note that if we emit \xNN and the src character after that is a hex // digit then that digit must be escaped too to prevent it being // interpreted as part of the character code by C. - if ((!utf8_safe || static_cast<uint8>(*src) < 0x80) && + if ((!utf8_safe || static_cast<uint8_t>(*src) < 0x80) && (!isprint(*src) || (last_hex_escape && isxdigit(*src)))) { if (dest_len - used < 4) // need space for 4 letter escape return -1; sprintf(dest + used, (use_hex ? "\\x%02x" : "\\%03o"), - static_cast<uint8>(*src)); + static_cast<uint8_t>(*src)); is_hex_escape = use_hex; used += 4; } else { @@ -628,39 +628,39 @@ std::string CHexEscape(const std::string &src) { // platforms, including errno preservation in error-free calls. // ---------------------------------------------------------------------- -int32 strto32_adaptor(const char *nptr, char **endptr, int base) { +int32_t strto32_adaptor(const char *nptr, char **endptr, int base) { const int saved_errno = errno; errno = 0; const long result = strtol(nptr, endptr, base); if (errno == ERANGE && result == LONG_MIN) { - return kint32min; + return std::numeric_limits<int32_t>::min(); } else if (errno == ERANGE && result == LONG_MAX) { - return kint32max; - } else if (errno == 0 && result < kint32min) { + return std::numeric_limits<int32_t>::max(); + } else if (errno == 0 && result < std::numeric_limits<int32_t>::min()) { errno = ERANGE; - return kint32min; - } else if (errno == 0 && result > kint32max) { + return std::numeric_limits<int32_t>::min(); + } else if (errno == 0 && result > std::numeric_limits<int32_t>::max()) { errno = ERANGE; - return kint32max; + return std::numeric_limits<int32_t>::max(); } if (errno == 0) errno = saved_errno; - return static_cast<int32>(result); + return static_cast<int32_t>(result); } -uint32 strtou32_adaptor(const char *nptr, char **endptr, int base) { +uint32_t strtou32_adaptor(const char *nptr, char **endptr, int base) { const int saved_errno = errno; errno = 0; const unsigned long result = strtoul(nptr, endptr, base); if (errno == ERANGE && result == ULONG_MAX) { - return kuint32max; - } else if (errno == 0 && result > kuint32max) { + return std::numeric_limits<uint32_t>::max(); + } else if (errno == 0 && result > std::numeric_limits<uint32_t>::max()) { errno = ERANGE; - return kuint32max; + return std::numeric_limits<uint32_t>::max(); } if (errno == 0) errno = saved_errno; - return static_cast<uint32>(result); + return static_cast<uint32_t>(result); } inline bool safe_parse_sign(std::string *text /*inout*/, @@ -800,7 +800,7 @@ bool safe_uint_internal(std::string text, IntType *value_p) { // null character. Also used by FastInt64ToBufferLeft. static const int kFastInt64ToBufferOffset = 21; -char *FastInt64ToBuffer(int64 i, char* buffer) { +char *FastInt64ToBuffer(int64_t i, char* buffer) { // We could collapse the positive and negative sections, but that // would be slightly slower for positive numbers... // 22 bytes is enough to store -2**64, -18446744073709551616. @@ -845,7 +845,7 @@ static const int kFastInt32ToBufferOffset = 11; // Yes, this is a duplicate of FastInt64ToBuffer. But, we need this for the // compiler to generate 32 bit arithmetic instructions. It's much faster, at // least with 32 bit binaries. -char *FastInt32ToBuffer(int32 i, char* buffer) { +char *FastInt32ToBuffer(int32_t i, char* buffer) { // We could collapse the positive and negative sections, but that // would be slightly slower for positive numbers... // 12 bytes is enough to store -2**32, -4294967296. @@ -896,7 +896,7 @@ char *FastHexToBuffer(int i, char* buffer) { return p + 1; } -char *InternalFastHexToBuffer(uint64 value, char* buffer, int num_byte) { +char *InternalFastHexToBuffer(uint64_t value, char* buffer, int num_byte) { static const char *hexdigits = "0123456789abcdef"; buffer[num_byte] = '\0'; for (int i = num_byte - 1; i >= 0; i--) { @@ -906,18 +906,18 @@ char *InternalFastHexToBuffer(uint64 value, char* buffer, int num_byte) { // platforms, we use 64-bit '&' directly. buffer[i] = hexdigits[value & 0xf]; #else - buffer[i] = hexdigits[uint32(value) & 0xf]; + buffer[i] = hexdigits[uint32_t(value) & 0xf]; #endif value >>= 4; } return buffer; } -char *FastHex64ToBuffer(uint64 value, char* buffer) { +char *FastHex64ToBuffer(uint64_t value, char* buffer) { return InternalFastHexToBuffer(value, buffer, 16); } -char *FastHex32ToBuffer(uint32 value, char* buffer) { +char *FastHex32ToBuffer(uint32_t value, char* buffer) { return InternalFastHexToBuffer(value, buffer, 8); } @@ -960,8 +960,8 @@ static const char two_ASCII_digits[100][2] = { {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'} }; -char* FastUInt32ToBufferLeft(uint32 u, char* buffer) { - uint32 digits; +char* FastUInt32ToBufferLeft(uint32_t u, char* buffer) { + uint32_t digits; const char *ASCII_digits = nullptr; // The idea of this implementation is to trim the number of divides to as few // as possible by using multiplication and subtraction rather than mod (%), @@ -1042,8 +1042,8 @@ done: goto sublt100_000_000; } -char* FastInt32ToBufferLeft(int32 i, char* buffer) { - uint32 u = 0; +char* FastInt32ToBufferLeft(int32_t i, char* buffer) { + uint32_t u = 0; if (i < 0) { *buffer++ = '-'; u -= i; @@ -1053,14 +1053,14 @@ char* FastInt32ToBufferLeft(int32 i, char* buffer) { return FastUInt32ToBufferLeft(u, buffer); } -char* FastUInt64ToBufferLeft(uint64 u64, char* buffer) { +char* FastUInt64ToBufferLeft(uint64_t u64, char* buffer) { int digits; const char *ASCII_digits = nullptr; - uint32 u = static_cast<uint32>(u64); + uint32_t u = static_cast<uint32_t>(u64); if (u == u64) return FastUInt32ToBufferLeft(u, buffer); - uint64 top_11_digits = u64 / 1000000000; + uint64_t top_11_digits = u64 / 1000000000; buffer = FastUInt64ToBufferLeft(top_11_digits, buffer); u = u64 - (top_11_digits * 1000000000); @@ -1095,8 +1095,8 @@ char* FastUInt64ToBufferLeft(uint64 u64, char* buffer) { return buffer; } -char* FastInt64ToBufferLeft(int64 i, char* buffer) { - uint64 u = 0; +char* FastInt64ToBufferLeft(int64_t i, char* buffer) { + uint64_t u = 0; if (i < 0) { *buffer++ = '-'; u -= i; @@ -1341,19 +1341,19 @@ bool safe_strtod(const char* str, double* value) { return *str != '\0' && *endptr == '\0'; } -bool safe_strto32(const std::string &str, int32 *value) { +bool safe_strto32(const std::string &str, int32_t *value) { return safe_int_internal(str, value); } -bool safe_strtou32(const std::string &str, uint32 *value) { +bool safe_strtou32(const std::string &str, uint32_t *value) { return safe_uint_internal(str, value); } -bool safe_strto64(const std::string &str, int64 *value) { +bool safe_strto64(const std::string &str, int64_t *value) { return safe_int_internal(str, value); } -bool safe_strtou64(const std::string &str, uint64 *value) { +bool safe_strtou64(const std::string &str, uint64_t *value) { return safe_uint_internal(str, value); } @@ -1400,12 +1400,12 @@ namespace strings { AlphaNum::AlphaNum(strings::Hex hex) { char *const end = &digits[kFastToBufferSize]; char *writer = end; - uint64 value = hex.value; - uint64 width = hex.spec; + uint64_t value = hex.value; + uint64_t width = hex.spec; // We accomplish minimum width by OR'ing in 0x10000 to the user's value, // where 0x10000 is the smallest hex number that is as wide as the user // asked for. - uint64 mask = ((static_cast<uint64>(1) << (width - 1) * 4)) | value; + uint64_t mask = (static_cast<uint64_t>(1) << ((width - 1) * 4)) | value; static const char hexdigits[] = "0123456789abcdef"; do { *--writer = hexdigits[value & 0xF]; @@ -2104,7 +2104,7 @@ int Base64EscapeInternal(const unsigned char *src, int szsrc, // Three bytes of data encodes to four characters of ciphertext. // So we can pump through three-byte chunks atomically. while (cur_src < limit_src - 3) { // keep going as long as we have >= 32 bits - uint32 in = BigEndian::Load32(cur_src) >> 8; + uint32_t in = BigEndian::Load32(cur_src) >> 8; cur_dest[0] = base64[in >> 18]; in &= 0x3FFFF; @@ -2130,7 +2130,7 @@ int Base64EscapeInternal(const unsigned char *src, int szsrc, // One byte left: this encodes to two characters, and (optionally) // two pad characters to round out the four-character cipherblock. if ((szdest -= 2) < 0) return 0; - uint32 in = cur_src[0]; + uint32_t in = cur_src[0]; cur_dest[0] = base64[in >> 2]; in &= 0x3; cur_dest[1] = base64[in << 4]; @@ -2147,7 +2147,7 @@ int Base64EscapeInternal(const unsigned char *src, int szsrc, // Two bytes left: this encodes to three characters, and (optionally) // one pad character to round out the four-character cipherblock. if ((szdest -= 3) < 0) return 0; - uint32 in = BigEndian::Load16(cur_src); + uint32_t in = BigEndian::Load16(cur_src); cur_dest[0] = base64[in >> 10]; in &= 0x3FF; cur_dest[1] = base64[in >> 4]; @@ -2166,7 +2166,7 @@ int Base64EscapeInternal(const unsigned char *src, int szsrc, // the loop because the loop above always reads 4 bytes, and the fourth // byte is past the end of the input. if ((szdest -= 4) < 0) return 0; - uint32 in = (cur_src[0] << 16) + BigEndian::Load16(cur_src + 1); + uint32_t in = (cur_src[0] << 16) + BigEndian::Load16(cur_src + 1); cur_dest[0] = base64[in >> 18]; in &= 0x3FFFF; cur_dest[1] = base64[in >> 12]; @@ -2243,8 +2243,8 @@ void WebSafeBase64EscapeWithPadding(StringPiece src, std::string *dest) { // Helper to append a Unicode code point to a string as UTF8, without bringing // in any external dependencies. -int EncodeAsUTF8Char(uint32 code_point, char* output) { - uint32 tmp = 0; +int EncodeAsUTF8Char(uint32_t code_point, char* output) { + uint32_t tmp = 0; int len = 0; if (code_point <= 0x7f) { tmp = code_point; @@ -2296,7 +2296,7 @@ int UTF8FirstLetterNumBytes(const char* src, int len) { if (len == 0) { return 0; } - return kUTF8LenTbl[*reinterpret_cast<const uint8*>(src)]; + return kUTF8LenTbl[*reinterpret_cast<const uint8_t*>(src)]; } // ---------------------------------------------------------------------- diff --git a/r5dev/thirdparty/protobuf/stubs/strutil.h b/r5dev/thirdparty/protobuf/stubs/strutil.h index b0f6d472..03d2638a 100644 --- a/r5dev/thirdparty/protobuf/stubs/strutil.h +++ b/r5dev/thirdparty/protobuf/stubs/strutil.h @@ -355,20 +355,20 @@ PROTOBUF_EXPORT std::string CHexEscape(const std::string& src); // platforms, so using these is safer, from the point of view of // overflow behavior, than using the standard libc functions. // ---------------------------------------------------------------------- -PROTOBUF_EXPORT int32 strto32_adaptor(const char* nptr, char** endptr, - int base); -PROTOBUF_EXPORT uint32 strtou32_adaptor(const char* nptr, char** endptr, +PROTOBUF_EXPORT int32_t strto32_adaptor(const char* nptr, char** endptr, int base); +PROTOBUF_EXPORT uint32_t strtou32_adaptor(const char* nptr, char** endptr, + int base); -inline int32 strto32(const char *nptr, char **endptr, int base) { - if (sizeof(int32) == sizeof(long)) +inline int32_t strto32(const char *nptr, char **endptr, int base) { + if (sizeof(int32_t) == sizeof(long)) return strtol(nptr, endptr, base); else return strto32_adaptor(nptr, endptr, base); } -inline uint32 strtou32(const char *nptr, char **endptr, int base) { - if (sizeof(uint32) == sizeof(unsigned long)) +inline uint32_t strtou32(const char *nptr, char **endptr, int base) { + if (sizeof(uint32_t) == sizeof(unsigned long)) return strtoul(nptr, endptr, base); else return strtou32_adaptor(nptr, endptr, base); @@ -376,15 +376,15 @@ inline uint32 strtou32(const char *nptr, char **endptr, int base) { // For now, long long is 64-bit on all the platforms we care about, so these // functions can simply pass the call to strto[u]ll. -inline int64 strto64(const char *nptr, char **endptr, int base) { - static_assert(sizeof(int64) == sizeof(long long), - "sizeof_int64_is_not_sizeof_long_long"); +inline int64_t strto64(const char *nptr, char **endptr, int base) { + static_assert(sizeof(int64_t) == sizeof(long long), + "sizeof int64_t is not sizeof long long"); return strtoll(nptr, endptr, base); } -inline uint64 strtou64(const char *nptr, char **endptr, int base) { - static_assert(sizeof(uint64) == sizeof(unsigned long long), - "sizeof_uint64_is_not_sizeof_long_long"); +inline uint64_t strtou64(const char *nptr, char **endptr, int base) { + static_assert(sizeof(uint64_t) == sizeof(unsigned long long), + "sizeof uint64_t is not sizeof unsigned long long"); return strtoull(nptr, endptr, base); } @@ -399,33 +399,33 @@ inline uint64 strtou64(const char *nptr, char **endptr, int base) { // ---------------------------------------------------------------------- PROTOBUF_EXPORT bool safe_strtob(StringPiece str, bool* value); -PROTOBUF_EXPORT bool safe_strto32(const std::string& str, int32* value); -PROTOBUF_EXPORT bool safe_strtou32(const std::string& str, uint32* value); -inline bool safe_strto32(const char* str, int32* value) { +PROTOBUF_EXPORT bool safe_strto32(const std::string& str, int32_t* value); +PROTOBUF_EXPORT bool safe_strtou32(const std::string& str, uint32_t* value); +inline bool safe_strto32(const char* str, int32_t* value) { return safe_strto32(std::string(str), value); } -inline bool safe_strto32(StringPiece str, int32* value) { +inline bool safe_strto32(StringPiece str, int32_t* value) { return safe_strto32(str.ToString(), value); } -inline bool safe_strtou32(const char* str, uint32* value) { +inline bool safe_strtou32(const char* str, uint32_t* value) { return safe_strtou32(std::string(str), value); } -inline bool safe_strtou32(StringPiece str, uint32* value) { +inline bool safe_strtou32(StringPiece str, uint32_t* value) { return safe_strtou32(str.ToString(), value); } -PROTOBUF_EXPORT bool safe_strto64(const std::string& str, int64* value); -PROTOBUF_EXPORT bool safe_strtou64(const std::string& str, uint64* value); -inline bool safe_strto64(const char* str, int64* value) { +PROTOBUF_EXPORT bool safe_strto64(const std::string& str, int64_t* value); +PROTOBUF_EXPORT bool safe_strtou64(const std::string& str, uint64_t* value); +inline bool safe_strto64(const char* str, int64_t* value) { return safe_strto64(std::string(str), value); } -inline bool safe_strto64(StringPiece str, int64* value) { +inline bool safe_strto64(StringPiece str, int64_t* value) { return safe_strto64(str.ToString(), value); } -inline bool safe_strtou64(const char* str, uint64* value) { +inline bool safe_strtou64(const char* str, uint64_t* value) { return safe_strtou64(std::string(str), value); } -inline bool safe_strtou64(StringPiece str, uint64* value) { +inline bool safe_strtou64(StringPiece str, uint64_t* value) { return safe_strtou64(str.ToString(), value); } @@ -470,13 +470,13 @@ inline bool safe_strtod(StringPiece str, double* value) { // DoubleToBuffer() and FloatToBuffer(). static const int kFastToBufferSize = 32; -PROTOBUF_EXPORT char* FastInt32ToBuffer(int32 i, char* buffer); -PROTOBUF_EXPORT char* FastInt64ToBuffer(int64 i, char* buffer); -char* FastUInt32ToBuffer(uint32 i, char* buffer); // inline below -char* FastUInt64ToBuffer(uint64 i, char* buffer); // inline below +PROTOBUF_EXPORT char* FastInt32ToBuffer(int32_t i, char* buffer); +PROTOBUF_EXPORT char* FastInt64ToBuffer(int64_t i, char* buffer); +char* FastUInt32ToBuffer(uint32_t i, char* buffer); // inline below +char* FastUInt64ToBuffer(uint64_t i, char* buffer); // inline below PROTOBUF_EXPORT char* FastHexToBuffer(int i, char* buffer); -PROTOBUF_EXPORT char* FastHex64ToBuffer(uint64 i, char* buffer); -PROTOBUF_EXPORT char* FastHex32ToBuffer(uint32 i, char* buffer); +PROTOBUF_EXPORT char* FastHex64ToBuffer(uint64_t i, char* buffer); +PROTOBUF_EXPORT char* FastHex32ToBuffer(uint32_t i, char* buffer); // at least 22 bytes long inline char* FastIntToBuffer(int i, char* buffer) { @@ -512,17 +512,17 @@ inline char* FastULongToBuffer(unsigned long i, char* buffer) { // terminating the string). // ---------------------------------------------------------------------- -PROTOBUF_EXPORT char* FastInt32ToBufferLeft(int32 i, char* buffer); -PROTOBUF_EXPORT char* FastUInt32ToBufferLeft(uint32 i, char* buffer); -PROTOBUF_EXPORT char* FastInt64ToBufferLeft(int64 i, char* buffer); -PROTOBUF_EXPORT char* FastUInt64ToBufferLeft(uint64 i, char* buffer); +PROTOBUF_EXPORT char* FastInt32ToBufferLeft(int32_t i, char* buffer); +PROTOBUF_EXPORT char* FastUInt32ToBufferLeft(uint32_t i, char* buffer); +PROTOBUF_EXPORT char* FastInt64ToBufferLeft(int64_t i, char* buffer); +PROTOBUF_EXPORT char* FastUInt64ToBufferLeft(uint64_t i, char* buffer); // Just define these in terms of the above. -inline char* FastUInt32ToBuffer(uint32 i, char* buffer) { +inline char* FastUInt32ToBuffer(uint32_t i, char* buffer) { FastUInt32ToBufferLeft(i, buffer); return buffer; } -inline char* FastUInt64ToBuffer(uint64 i, char* buffer) { +inline char* FastUInt64ToBuffer(uint64_t i, char* buffer) { FastUInt64ToBufferLeft(i, buffer); return buffer; } @@ -595,7 +595,7 @@ enum PadSpec { }; struct Hex { - uint64 value; + uint64_t value; enum PadSpec spec; template <class Int> explicit Hex(Int v, PadSpec s = NO_PAD) @@ -607,10 +607,10 @@ struct Hex { sizeof(v) == 1 || sizeof(v) == 2 || sizeof(v) == 4 || sizeof(v) == 8, "Unknown integer type"); #endif - value = sizeof(v) == 1 ? static_cast<uint8>(v) - : sizeof(v) == 2 ? static_cast<uint16>(v) - : sizeof(v) == 4 ? static_cast<uint32>(v) - : static_cast<uint64>(v); + value = sizeof(v) == 1 ? static_cast<uint8_t>(v) + : sizeof(v) == 2 ? static_cast<uint16_t>(v) + : sizeof(v) == 4 ? static_cast<uint32_t>(v) + : static_cast<uint64_t>(v); } }; @@ -789,7 +789,7 @@ std::string Join(const Range& components, const char* delim) { // ToHex() // Return a lower-case hex string representation of the given integer. // ---------------------------------------------------------------------- -PROTOBUF_EXPORT std::string ToHex(uint64 num); +PROTOBUF_EXPORT std::string ToHex(uint64_t num); // ---------------------------------------------------------------------- // GlobalReplaceSubstring() @@ -863,7 +863,7 @@ PROTOBUF_EXPORT void Base64Escape(const unsigned char* src, int szsrc, PROTOBUF_EXPORT void WebSafeBase64Escape(const unsigned char* src, int szsrc, std::string* dest, bool do_padding); -inline bool IsValidCodePoint(uint32 code_point) { +inline bool IsValidCodePoint(uint32_t code_point) { return code_point < 0xD800 || (code_point >= 0xE000 && code_point <= 0x10FFFF); } @@ -875,7 +875,7 @@ static const int UTFmax = 4; // in any external dependencies. The output buffer must be as least 4 bytes // large. // ---------------------------------------------------------------------- -PROTOBUF_EXPORT int EncodeAsUTF8Char(uint32 code_point, char* output); +PROTOBUF_EXPORT int EncodeAsUTF8Char(uint32_t code_point, char* output); // ---------------------------------------------------------------------- // UTF8FirstLetterNumBytes() diff --git a/r5dev/thirdparty/protobuf/stubs/time.cc b/r5dev/thirdparty/protobuf/stubs/time.cc index da796771..b76a7036 100644 --- a/r5dev/thirdparty/protobuf/stubs/time.cc +++ b/r5dev/thirdparty/protobuf/stubs/time.cc @@ -10,23 +10,23 @@ namespace protobuf { namespace internal { namespace { -static const int64 kSecondsPerMinute = 60; -static const int64 kSecondsPerHour = 3600; -static const int64 kSecondsPerDay = kSecondsPerHour * 24; -static const int64 kSecondsPer400Years = +static const int64_t kSecondsPerMinute = 60; +static const int64_t kSecondsPerHour = 3600; +static const int64_t kSecondsPerDay = kSecondsPerHour * 24; +static const int64_t kSecondsPer400Years = kSecondsPerDay * (400 * 365 + 400 / 4 - 3); // Seconds from 0001-01-01T00:00:00 to 1970-01-01T:00:00:00 -static const int64 kSecondsFromEraToEpoch = 62135596800LL; +static const int64_t kSecondsFromEraToEpoch = 62135596800LL; // The range of timestamp values we support. -static const int64 kMinTime = -62135596800LL; // 0001-01-01T00:00:00 -static const int64 kMaxTime = 253402300799LL; // 9999-12-31T23:59:59 +static const int64_t kMinTime = -62135596800LL; // 0001-01-01T00:00:00 +static const int64_t kMaxTime = 253402300799LL; // 9999-12-31T23:59:59 static const int kNanosPerMillisecond = 1000000; static const int kNanosPerMicrosecond = 1000; // Count the seconds from the given year (start at Jan 1, 00:00) to 100 years // after. -int64 SecondsPer100Years(int year) { +int64_t SecondsPer100Years(int year) { if (year % 400 == 0 || year % 400 > 300) { return kSecondsPerDay * (100 * 365 + 100 / 4); } else { @@ -36,7 +36,7 @@ int64 SecondsPer100Years(int year) { // Count the seconds from the given year (start at Jan 1, 00:00) to 4 years // after. -int64 SecondsPer4Years(int year) { +int64_t SecondsPer4Years(int year) { if ((year % 100 == 0 || year % 100 > 96) && !(year % 400 == 0 || year % 400 > 396)) { // No leap years. @@ -51,7 +51,7 @@ bool IsLeapYear(int year) { return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0); } -int64 SecondsPerYear(int year) { +int64_t SecondsPerYear(int year) { return kSecondsPerDay * (IsLeapYear(year) ? 366 : 365); } @@ -59,7 +59,7 @@ static const int kDaysInMonth[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; -int64 SecondsPerMonth(int month, bool leap) { +int64_t SecondsPerMonth(int month, bool leap) { if (month == 2 && leap) { return kSecondsPerDay * (kDaysInMonth[month] + 1); } @@ -88,8 +88,8 @@ bool ValidateDateTime(const DateTime& time) { // Count the number of seconds elapsed from 0001-01-01T00:00:00 to the given // time. -int64 SecondsSinceCommonEra(const DateTime& time) { - int64 result = 0; +int64_t SecondsSinceCommonEra(const DateTime& time) { + int64_t result = 0; // Years should be between 1 and 9999. assert(time.year >= 1 && time.year <= 9999); int year = 1; @@ -130,7 +130,7 @@ int64 SecondsSinceCommonEra(const DateTime& time) { // Format nanoseconds with either 3, 6, or 9 digits depending on the required // precision to represent the exact value. -std::string FormatNanos(int32 nanos) { +std::string FormatNanos(int32_t nanos) { if (nanos % kNanosPerMillisecond == 0) { return StringPrintf("%03d", nanos / kNanosPerMillisecond); } else if (nanos % kNanosPerMicrosecond == 0) { @@ -167,7 +167,7 @@ const char* ParseInt(const char* data, int width, int min_value, // Consumes the fractional parts of a second into nanos. For example, // "010" will be parsed to 10000000 nanos. -const char* ParseNanos(const char* data, int32* nanos) { +const char* ParseNanos(const char* data, int32_t* nanos) { if (!ascii_isdigit(*data)) { return nullptr; } @@ -190,7 +190,7 @@ const char* ParseNanos(const char* data, int32* nanos) { return data; } -const char* ParseTimezoneOffset(const char* data, int64* offset) { +const char* ParseTimezoneOffset(const char* data, int64_t* offset) { // Accept format "HH:MM". E.g., "08:00" int hour; if ((data = ParseInt(data, 2, 0, 23, &hour)) == nullptr) { @@ -208,7 +208,7 @@ const char* ParseTimezoneOffset(const char* data, int64* offset) { } } // namespace -bool SecondsToDateTime(int64 seconds, DateTime* time) { +bool SecondsToDateTime(int64_t seconds, DateTime* time) { if (seconds < kMinTime || seconds > kMaxTime) { return false; } @@ -253,7 +253,7 @@ bool SecondsToDateTime(int64 seconds, DateTime* time) { return true; } -bool DateTimeToSeconds(const DateTime& time, int64* seconds) { +bool DateTimeToSeconds(const DateTime& time, int64_t* seconds) { if (!ValidateDateTime(time)) { return false; } @@ -261,14 +261,14 @@ bool DateTimeToSeconds(const DateTime& time, int64* seconds) { return true; } -void GetCurrentTime(int64* seconds, int32* nanos) { +void GetCurrentTime(int64_t* seconds, int32_t* nanos) { // TODO(xiaofeng): Improve the accuracy of this implementation (or just // remove this method from protobuf). *seconds = time(nullptr); *nanos = 0; } -std::string FormatTime(int64 seconds, int32 nanos) { +std::string FormatTime(int64_t seconds, int32_t nanos) { DateTime time; if (nanos < 0 || nanos > 999999999 || !SecondsToDateTime(seconds, &time)) { return "InvalidTime"; @@ -282,7 +282,7 @@ std::string FormatTime(int64 seconds, int32 nanos) { return result + "Z"; } -bool ParseTime(const std::string& value, int64* seconds, int32* nanos) { +bool ParseTime(const std::string& value, int64_t* seconds, int32_t* nanos) { DateTime time; const char* data = value.c_str(); // We only accept: @@ -341,14 +341,14 @@ bool ParseTime(const std::string& value, int64* seconds, int32* nanos) { ++data; } else if (*data == '+') { ++data; - int64 offset; + int64_t offset; if ((data = ParseTimezoneOffset(data, &offset)) == nullptr) { return false; } *seconds -= offset; } else if (*data == '-') { ++data; - int64 offset; + int64_t offset; if ((data = ParseTimezoneOffset(data, &offset)) == nullptr) { return false; } diff --git a/r5dev/thirdparty/protobuf/stubs/time.h b/r5dev/thirdparty/protobuf/stubs/time.h index 45edd15c..8c41cecb 100644 --- a/r5dev/thirdparty/protobuf/stubs/time.h +++ b/r5dev/thirdparty/protobuf/stubs/time.h @@ -30,6 +30,8 @@ #ifndef GOOGLE_PROTOBUF_STUBS_TIME_H_ #define GOOGLE_PROTOBUF_STUBS_TIME_H_ +#include <cstdint> + #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/port_def.inc> @@ -51,12 +53,12 @@ struct DateTime { // negative to represent time before 1970-01-01) to DateTime. Returns false // if the timestamp is not in the range between 0001-01-01T00:00:00 and // 9999-12-31T23:59:59. -bool PROTOBUF_EXPORT SecondsToDateTime(int64 seconds, DateTime* time); +bool PROTOBUF_EXPORT SecondsToDateTime(int64_t seconds, DateTime* time); // Converts DateTime to a timestamp (seconds since 1970-01-01T00:00:00). // Returns false if the DateTime is not valid or is not in the valid range. -bool PROTOBUF_EXPORT DateTimeToSeconds(const DateTime& time, int64* seconds); +bool PROTOBUF_EXPORT DateTimeToSeconds(const DateTime& time, int64_t* seconds); -void PROTOBUF_EXPORT GetCurrentTime(int64* seconds, int32* nanos); +void PROTOBUF_EXPORT GetCurrentTime(int64_t* seconds, int32_t* nanos); // Formats a time string in RFC3339 format. // @@ -65,11 +67,11 @@ void PROTOBUF_EXPORT GetCurrentTime(int64* seconds, int32* nanos); // value. // // Note that "nanos" must in the range of [0, 999999999]. -std::string PROTOBUF_EXPORT FormatTime(int64 seconds, int32 nanos); +std::string PROTOBUF_EXPORT FormatTime(int64_t seconds, int32_t nanos); // Parses a time string. This method accepts RFC3339 date/time string with UTC // offset. For example, "2015-05-20T13:29:35.120-08:00". -bool PROTOBUF_EXPORT ParseTime(const std::string& value, int64* seconds, - int32* nanos); +bool PROTOBUF_EXPORT ParseTime(const std::string& value, int64_t* seconds, + int32_t* nanos); } // namespace internal } // namespace protobuf diff --git a/r5dev/thirdparty/protobuf/test_messages_proto2.proto b/r5dev/thirdparty/protobuf/test_messages_proto2.proto index 39fc123f..c7b9c487 100644 --- a/r5dev/thirdparty/protobuf/test_messages_proto2.proto +++ b/r5dev/thirdparty/protobuf/test_messages_proto2.proto @@ -209,6 +209,7 @@ message TestAllTypesProto2 { optional double default_double = 252 [ default = 7e22]; optional bool default_bool = 253 [ default = true]; optional string default_string = 254 [ default = "Rosebud"]; + optional bytes default_bytes = 255 [ default = "joshua"]; // Test field-name-to-JSON-name convention. // (protobuf says names can be any valid C/C++ identifier.) @@ -290,3 +291,7 @@ message EnumOnlyProto2 { kTrue = 1; } } + +message OneStringProto2 { + optional string data = 1; +} diff --git a/r5dev/thirdparty/protobuf/test_messages_proto3.proto b/r5dev/thirdparty/protobuf/test_messages_proto3.proto index 278ee4f9..1e1285ea 100644 --- a/r5dev/thirdparty/protobuf/test_messages_proto3.proto +++ b/r5dev/thirdparty/protobuf/test_messages_proto3.proto @@ -80,8 +80,8 @@ message TestAllTypesProto3 { ALIAS_FOO = 0; ALIAS_BAR = 1; ALIAS_BAZ = 2; - QUX = 2; - qux = 2; + MOO = 2; + moo = 2; bAz = 2; } @@ -278,8 +278,7 @@ enum ForeignEnum { FOREIGN_BAZ = 2; } -message NullHypothesisProto3 { -} +message NullHypothesisProto3 {} message EnumOnlyProto3 { enum Bool { diff --git a/r5dev/thirdparty/protobuf/test_util.h b/r5dev/thirdparty/protobuf/test_util.h index 85335e9b..83fc3d5f 100644 --- a/r5dev/thirdparty/protobuf/test_util.h +++ b/r5dev/thirdparty/protobuf/test_util.h @@ -44,6 +44,7 @@ #undef UNITTEST #undef UNITTEST_IMPORT +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -237,6 +238,10 @@ inline void TestUtil::ReflectionTester::SetAllFieldsViaReflection( sub_message = reflection->MutableMessage(message, F("optional_lazy_message")); sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 127); + sub_message = reflection->MutableMessage( + message, F("optional_unverified_lazy_message")); + sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 128); + // ----------------------------------------------------------------- reflection->AddInt32(message, F("repeated_int32"), 201); @@ -347,7 +352,7 @@ inline void TestUtil::ReflectionTester::SetOneofViaReflection( Message* sub_message = reflection->MutableMessage( message, descriptor->FindFieldByName("foo_lazy_message")); sub_message->GetReflection()->SetInt64( - sub_message, sub_message->GetDescriptor()->FindFieldByName("qux_int"), + sub_message, sub_message->GetDescriptor()->FindFieldByName("moo_int"), 100); reflection->SetString(message, descriptor->FindFieldByName("bar_cord"), @@ -375,7 +380,7 @@ inline void TestUtil::ReflectionTester::ExpectOneofSetViaReflection( message, descriptor->FindFieldByName("foo_lazy_message")); EXPECT_EQ(100, sub_message->GetReflection()->GetInt64( *sub_message, - sub_message->GetDescriptor()->FindFieldByName("qux_int"))); + sub_message->GetDescriptor()->FindFieldByName("moo_int"))); EXPECT_EQ("101", reflection->GetString( message, descriptor->FindFieldByName("bar_cord"))); @@ -467,6 +472,8 @@ inline void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection1( EXPECT_TRUE( reflection->HasField(message, F("optional_public_import_message"))); EXPECT_TRUE(reflection->HasField(message, F("optional_lazy_message"))); + EXPECT_TRUE( + reflection->HasField(message, F("optional_unverified_lazy_message"))); sub_message = &reflection->GetMessage(message, F("optionalgroup")); EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, group_a_)); @@ -481,6 +488,9 @@ inline void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection1( EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, import_e_)); sub_message = &reflection->GetMessage(message, F("optional_lazy_message")); EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, nested_b_)); + sub_message = + &reflection->GetMessage(message, F("optional_unverified_lazy_message")); + EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, nested_b_)); EXPECT_TRUE(reflection->HasField(message, F("optional_nested_enum"))); EXPECT_TRUE(reflection->HasField(message, F("optional_foreign_enum"))); @@ -529,6 +539,10 @@ inline void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection1( sub_message = &reflection->GetMessage(message, F("optional_lazy_message")); EXPECT_EQ(127, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_)); + sub_message = + &reflection->GetMessage(message, F("optional_unverified_lazy_message")); + EXPECT_EQ(128, + sub_message->GetReflection()->GetInt32(*sub_message, nested_b_)); EXPECT_EQ(nested_baz_, reflection->GetEnum(message, F("optional_nested_enum"))); @@ -896,6 +910,8 @@ inline void TestUtil::ReflectionTester::ExpectClearViaReflection( EXPECT_FALSE( reflection->HasField(message, F("optional_public_import_message"))); EXPECT_FALSE(reflection->HasField(message, F("optional_lazy_message"))); + EXPECT_FALSE( + reflection->HasField(message, F("optional_unverified_lazy_message"))); EXPECT_FALSE(reflection->HasField(message, F("optional_nested_enum"))); EXPECT_FALSE(reflection->HasField(message, F("optional_foreign_enum"))); @@ -948,6 +964,10 @@ inline void TestUtil::ReflectionTester::ExpectClearViaReflection( sub_message = &reflection->GetMessage(message, F("optional_lazy_message")); EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, nested_b_)); EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_)); + sub_message = + &reflection->GetMessage(message, F("optional_unverified_lazy_message")); + EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, nested_b_)); + EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_)); // Enums without defaults are set to the first value in the enum. EXPECT_EQ(nested_foo_, diff --git a/r5dev/thirdparty/protobuf/test_util.inc b/r5dev/thirdparty/protobuf/test_util.inc index 927a0041..8d2e81aa 100644 --- a/r5dev/thirdparty/protobuf/test_util.inc +++ b/r5dev/thirdparty/protobuf/test_util.inc @@ -39,9 +39,9 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> +#include <gtest/gtest.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/message.h> -#include <gtest/gtest.h> namespace google { namespace protobuf { @@ -143,6 +143,7 @@ inline void TestUtil::SetOptionalFields(UNITTEST::TestAllTypes* message) { message->mutable_optional_import_message()->set_d(120); message->mutable_optional_public_import_message()->set_e(126); message->mutable_optional_lazy_message()->set_bb(127); + message->mutable_optional_unverified_lazy_message()->set_bb(128); message->set_optional_nested_enum(UNITTEST::TestAllTypes::BAZ); message->set_optional_foreign_enum(UNITTEST::FOREIGN_BAZ); @@ -347,6 +348,7 @@ inline void TestUtil::ExpectAllFieldsSet( EXPECT_TRUE(message.has_optional_import_message()); EXPECT_TRUE(message.has_optional_public_import_message()); EXPECT_TRUE(message.has_optional_lazy_message()); + EXPECT_TRUE(message.has_optional_unverified_lazy_message()); EXPECT_TRUE(message.optionalgroup().has_a()); EXPECT_TRUE(message.optional_nested_message().has_bb()); @@ -354,6 +356,7 @@ inline void TestUtil::ExpectAllFieldsSet( EXPECT_TRUE(message.optional_import_message().has_d()); EXPECT_TRUE(message.optional_public_import_message().has_e()); EXPECT_TRUE(message.optional_lazy_message().has_bb()); + EXPECT_TRUE(message.optional_unverified_lazy_message().has_bb()); EXPECT_TRUE(message.has_optional_nested_enum()); EXPECT_TRUE(message.has_optional_foreign_enum()); @@ -386,6 +389,7 @@ inline void TestUtil::ExpectAllFieldsSet( EXPECT_EQ(120, message.optional_import_message().d()); EXPECT_EQ(126, message.optional_public_import_message().e()); EXPECT_EQ(127, message.optional_lazy_message().bb()); + EXPECT_EQ(128, message.optional_unverified_lazy_message().bb()); EXPECT_EQ(UNITTEST::TestAllTypes::BAZ, message.optional_nested_enum()); EXPECT_EQ(UNITTEST::FOREIGN_BAZ, message.optional_foreign_enum()); @@ -556,6 +560,7 @@ inline void TestUtil::ExpectClear(const UNITTEST::TestAllTypes& message) { EXPECT_FALSE(message.has_optional_import_message()); EXPECT_FALSE(message.has_optional_public_import_message()); EXPECT_FALSE(message.has_optional_lazy_message()); + EXPECT_FALSE(message.has_optional_unverified_lazy_message()); EXPECT_FALSE(message.has_optional_nested_enum()); EXPECT_FALSE(message.has_optional_foreign_enum()); @@ -588,6 +593,7 @@ inline void TestUtil::ExpectClear(const UNITTEST::TestAllTypes& message) { EXPECT_FALSE(message.optional_import_message().has_d()); EXPECT_FALSE(message.optional_public_import_message().has_e()); EXPECT_FALSE(message.optional_lazy_message().has_bb()); + EXPECT_FALSE(message.optional_unverified_lazy_message().has_bb()); EXPECT_EQ(0, message.optionalgroup().a()); EXPECT_EQ(0, message.optional_nested_message().bb()); @@ -595,6 +601,7 @@ inline void TestUtil::ExpectClear(const UNITTEST::TestAllTypes& message) { EXPECT_EQ(0, message.optional_import_message().d()); EXPECT_EQ(0, message.optional_public_import_message().e()); EXPECT_EQ(0, message.optional_lazy_message().bb()); + EXPECT_EQ(0, message.optional_unverified_lazy_message().bb()); // Enums without defaults are set to the first value in the enum. EXPECT_EQ(UNITTEST::TestAllTypes::FOO, message.optional_nested_enum()); @@ -987,6 +994,9 @@ inline void TestUtil::SetAllExtensions(UNITTEST::TestAllExtensions* message) { ->set_e(126); message->MutableExtension(UNITTEST::optional_lazy_message_extension) ->set_bb(127); + message + ->MutableExtension(UNITTEST::optional_unverified_lazy_message_extension) + ->set_bb(128); // ----------------------------------------------------------------- @@ -1183,6 +1193,8 @@ inline void TestUtil::ExpectAllExtensionsSet( EXPECT_TRUE( message.HasExtension(UNITTEST::optional_public_import_message_extension)); EXPECT_TRUE(message.HasExtension(UNITTEST::optional_lazy_message_extension)); + EXPECT_TRUE(message.HasExtension( + UNITTEST::optional_unverified_lazy_message_extension)); EXPECT_TRUE(message.GetExtension(UNITTEST::optionalgroup_extension).has_a()); EXPECT_TRUE(message.GetExtension(UNITTEST::optional_nested_message_extension) @@ -1196,6 +1208,9 @@ inline void TestUtil::ExpectAllExtensionsSet( .has_e()); EXPECT_TRUE( message.GetExtension(UNITTEST::optional_lazy_message_extension).has_bb()); + EXPECT_TRUE( + message.GetExtension(UNITTEST::optional_unverified_lazy_message_extension) + .has_bb()); EXPECT_TRUE(message.HasExtension(UNITTEST::optional_nested_enum_extension)); EXPECT_TRUE(message.HasExtension(UNITTEST::optional_foreign_enum_extension)); @@ -1248,6 +1263,10 @@ inline void TestUtil::ExpectAllExtensionsSet( EXPECT_EQ( 127, message.GetExtension(UNITTEST::optional_lazy_message_extension).bb()); + EXPECT_EQ( + 128, + message.GetExtension(UNITTEST::optional_unverified_lazy_message_extension) + .bb()); // ----------------------------------------------------------------- @@ -1476,6 +1495,8 @@ inline void TestUtil::ExpectExtensionsClear( EXPECT_FALSE( message.HasExtension(UNITTEST::optional_public_import_message_extension)); EXPECT_FALSE(message.HasExtension(UNITTEST::optional_lazy_message_extension)); + EXPECT_FALSE(message.HasExtension( + UNITTEST::optional_unverified_lazy_message_extension)); EXPECT_FALSE(message.HasExtension(UNITTEST::optional_nested_enum_extension)); EXPECT_FALSE(message.HasExtension(UNITTEST::optional_foreign_enum_extension)); @@ -1515,6 +1536,9 @@ inline void TestUtil::ExpectExtensionsClear( .has_e()); EXPECT_FALSE( message.GetExtension(UNITTEST::optional_lazy_message_extension).has_bb()); + EXPECT_FALSE( + message.GetExtension(UNITTEST::optional_unverified_lazy_message_extension) + .has_bb()); EXPECT_EQ(0, message.GetExtension(UNITTEST::optionalgroup_extension).a()); EXPECT_EQ( @@ -1531,6 +1555,10 @@ inline void TestUtil::ExpectExtensionsClear( .e()); EXPECT_EQ( 0, message.GetExtension(UNITTEST::optional_lazy_message_extension).bb()); + EXPECT_EQ( + 0, + message.GetExtension(UNITTEST::optional_unverified_lazy_message_extension) + .bb()); // Enums without defaults are set to the first value in the enum. EXPECT_EQ(UNITTEST::TestAllTypes::FOO, @@ -2315,7 +2343,7 @@ inline void TestUtil::ExpectRepeatedExtensionsSwapped( } inline void TestUtil::SetOneof1(UNITTEST::TestOneof2* message) { - message->mutable_foo_lazy_message()->set_qux_int(100); + message->mutable_foo_lazy_message()->set_moo_int(100); message->set_bar_string("101"); message->set_baz_int(102); message->set_baz_string("103"); @@ -2332,7 +2360,7 @@ inline void TestUtil::ExpectOneofSet1(const UNITTEST::TestOneof2& message) { ExpectAtMostOneFieldSetInOneof(message); EXPECT_TRUE(message.has_foo_lazy_message()); - EXPECT_TRUE(message.foo_lazy_message().has_qux_int()); + EXPECT_TRUE(message.foo_lazy_message().has_moo_int()); EXPECT_TRUE(message.has_bar_string()); EXPECT_TRUE(message.has_baz_int()); @@ -2340,7 +2368,7 @@ inline void TestUtil::ExpectOneofSet1(const UNITTEST::TestOneof2& message) { ASSERT_EQ(0, message.foo_lazy_message().corge_int_size()); - EXPECT_EQ(100, message.foo_lazy_message().qux_int()); + EXPECT_EQ(100, message.foo_lazy_message().moo_int()); EXPECT_EQ("101", message.bar_string()); EXPECT_EQ(102, message.baz_int()); EXPECT_EQ("103", message.baz_string()); diff --git a/r5dev/thirdparty/protobuf/test_util2.h b/r5dev/thirdparty/protobuf/test_util2.h index ec98fe91..ccfc8bb4 100644 --- a/r5dev/thirdparty/protobuf/test_util2.h +++ b/r5dev/thirdparty/protobuf/test_util2.h @@ -33,8 +33,10 @@ #include <thirdparty/protobuf/stubs/strutil.h> -#include <thirdparty/protobuf/util/message_differencer.h> #include <thirdparty/protobuf/testing/googletest.h> +#include <thirdparty/protobuf/io/zero_copy_stream.h> +#include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> +#include <thirdparty/protobuf/util/message_differencer.h> namespace google { namespace protobuf { @@ -75,6 +77,28 @@ bool EqualsToSerialized(const ProtoType& message, const std::string& data) { return util::MessageDifferencer::Equals(message, other); } +// Wraps io::ArrayInputStream while checking against bound. When a blocking +// stream is used with bounded length, proto parsing must not access beyond the +// bound. Otherwise, it can result in unintended block, then deadlock. +class BoundedArrayInputStream : public io::ZeroCopyInputStream { + public: + BoundedArrayInputStream(const void* data, int size) + : stream_(data, size), bound_(size) {} + ~BoundedArrayInputStream() override {} + + bool Next(const void** data, int* size) override { + GOOGLE_CHECK_LT(stream_.ByteCount(), bound_); + return stream_.Next(data, size); + } + void BackUp(int count) override { stream_.BackUp(count); } + bool Skip(int count) override { return stream_.Skip(count); } + int64_t ByteCount() const override { return stream_.ByteCount(); } + + private: + io::ArrayInputStream stream_; + int bound_; +}; + } // namespace TestUtil } // namespace protobuf } // namespace google diff --git a/r5dev/thirdparty/protobuf/test_util_lite.cc b/r5dev/thirdparty/protobuf/test_util_lite.cc index 713e7438..f1fafa58 100644 --- a/r5dev/thirdparty/protobuf/test_util_lite.cc +++ b/r5dev/thirdparty/protobuf/test_util_lite.cc @@ -65,6 +65,7 @@ void TestUtilLite::SetAllFields(unittest::TestAllTypesLite* message) { message->mutable_optional_import_message()->set_d(120); message->mutable_optional_public_import_message()->set_e(126); message->mutable_optional_lazy_message()->set_bb(127); + message->mutable_optional_unverified_lazy_message()->set_bb(128); message->set_optional_nested_enum(unittest::TestAllTypesLite::BAZ); message->set_optional_foreign_enum(unittest::FOREIGN_LITE_BAZ); @@ -214,6 +215,7 @@ void TestUtilLite::ExpectAllFieldsSet( EXPECT_TRUE(message.has_optional_import_message()); EXPECT_TRUE(message.has_optional_public_import_message()); EXPECT_TRUE(message.has_optional_lazy_message()); + EXPECT_TRUE(message.has_optional_unverified_lazy_message()); EXPECT_TRUE(message.optionalgroup().has_a()); EXPECT_TRUE(message.optional_nested_message().has_bb()); @@ -221,6 +223,7 @@ void TestUtilLite::ExpectAllFieldsSet( EXPECT_TRUE(message.optional_import_message().has_d()); EXPECT_TRUE(message.optional_public_import_message().has_e()); EXPECT_TRUE(message.optional_lazy_message().has_bb()); + EXPECT_TRUE(message.optional_unverified_lazy_message().has_bb()); EXPECT_TRUE(message.has_optional_nested_enum()); EXPECT_TRUE(message.has_optional_foreign_enum()); @@ -249,6 +252,7 @@ void TestUtilLite::ExpectAllFieldsSet( EXPECT_EQ(120, message.optional_import_message().d()); EXPECT_EQ(126, message.optional_public_import_message().e()); EXPECT_EQ(127, message.optional_lazy_message().bb()); + EXPECT_EQ(128, message.optional_unverified_lazy_message().bb()); EXPECT_EQ(unittest::TestAllTypesLite::BAZ, message.optional_nested_enum()); EXPECT_EQ(unittest::FOREIGN_LITE_BAZ, message.optional_foreign_enum()); @@ -415,6 +419,7 @@ void TestUtilLite::ExpectClear(const unittest::TestAllTypesLite& message) { EXPECT_FALSE(message.has_optional_import_message()); EXPECT_FALSE(message.has_optional_public_import_message()); EXPECT_FALSE(message.has_optional_lazy_message()); + EXPECT_FALSE(message.has_optional_unverified_lazy_message()); EXPECT_FALSE(message.has_optional_nested_enum()); EXPECT_FALSE(message.has_optional_foreign_enum()); @@ -445,6 +450,7 @@ void TestUtilLite::ExpectClear(const unittest::TestAllTypesLite& message) { EXPECT_FALSE(message.optional_import_message().has_d()); EXPECT_FALSE(message.optional_public_import_message().has_e()); EXPECT_FALSE(message.optional_lazy_message().has_bb()); + EXPECT_FALSE(message.optional_unverified_lazy_message().has_bb()); EXPECT_EQ(0, message.optionalgroup().a()); EXPECT_EQ(0, message.optional_nested_message().bb()); @@ -836,6 +842,10 @@ void TestUtilLite::SetAllExtensions(unittest::TestAllExtensionsLite* message) { ->set_e(126); message->MutableExtension(unittest::optional_lazy_message_extension_lite) ->set_bb(127); + message + ->MutableExtension( + unittest::optional_unverified_lazy_message_extension_lite) + ->set_bb(128); message->SetExtension(unittest::optional_nested_enum_extension_lite, unittest::TestAllTypesLite::BAZ); @@ -1022,6 +1032,8 @@ void TestUtilLite::ExpectAllExtensionsSet( unittest::optional_public_import_message_extension_lite)); EXPECT_TRUE( message.HasExtension(unittest::optional_lazy_message_extension_lite)); + EXPECT_TRUE(message.HasExtension( + unittest::optional_unverified_lazy_message_extension_lite)); EXPECT_TRUE( message.GetExtension(unittest::optionalgroup_extension_lite).has_a()); @@ -1041,6 +1053,10 @@ void TestUtilLite::ExpectAllExtensionsSet( EXPECT_TRUE( message.GetExtension(unittest::optional_lazy_message_extension_lite) .has_bb()); + EXPECT_TRUE(message + .GetExtension( + unittest::optional_unverified_lazy_message_extension_lite) + .has_bb()); EXPECT_TRUE( message.HasExtension(unittest::optional_nested_enum_extension_lite)); @@ -1099,6 +1115,11 @@ void TestUtilLite::ExpectAllExtensionsSet( EXPECT_EQ(127, message.GetExtension(unittest::optional_lazy_message_extension_lite) .bb()); + EXPECT_EQ(128, + message + .GetExtension( + unittest::optional_unverified_lazy_message_extension_lite) + .bb()); EXPECT_EQ( unittest::TestAllTypesLite::BAZ, diff --git a/r5dev/thirdparty/protobuf/testdata/golden_message b/r5dev/thirdparty/protobuf/testdata/golden_message index 0b7e6552..5825975c 100644 Binary files a/r5dev/thirdparty/protobuf/testdata/golden_message and b/r5dev/thirdparty/protobuf/testdata/golden_message differ diff --git a/r5dev/thirdparty/protobuf/testdata/golden_message_oneof_implemented b/r5dev/thirdparty/protobuf/testdata/golden_message_oneof_implemented index b48c8985..794ca5e0 100644 Binary files a/r5dev/thirdparty/protobuf/testdata/golden_message_oneof_implemented and b/r5dev/thirdparty/protobuf/testdata/golden_message_oneof_implemented differ diff --git a/r5dev/thirdparty/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt b/r5dev/thirdparty/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt index ec95e1e8..86389c93 100644 --- a/r5dev/thirdparty/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt +++ b/r5dev/thirdparty/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt @@ -36,6 +36,9 @@ optional_public_import_message { optional_lazy_message { bb: 127 } +optional_unverified_lazy_message { + bb: 128 +} repeated_int32: 201 repeated_int32: 301 repeated_int64: 202 diff --git a/r5dev/thirdparty/protobuf/testdata/text_format_unittest_data_pointy.txt b/r5dev/thirdparty/protobuf/testdata/text_format_unittest_data_pointy.txt index e1011ebf..788025c5 100644 --- a/r5dev/thirdparty/protobuf/testdata/text_format_unittest_data_pointy.txt +++ b/r5dev/thirdparty/protobuf/testdata/text_format_unittest_data_pointy.txt @@ -36,6 +36,9 @@ optional_public_import_message < optional_lazy_message < bb: 127 > +optional_unverified_lazy_message < + bb: 128 +> repeated_int32: 201 repeated_int32: 301 repeated_int64: 202 diff --git a/r5dev/thirdparty/protobuf/testdata/text_format_unittest_data_pointy_oneof.txt b/r5dev/thirdparty/protobuf/testdata/text_format_unittest_data_pointy_oneof.txt index 95109f62..b2d33670 100644 --- a/r5dev/thirdparty/protobuf/testdata/text_format_unittest_data_pointy_oneof.txt +++ b/r5dev/thirdparty/protobuf/testdata/text_format_unittest_data_pointy_oneof.txt @@ -36,6 +36,9 @@ optional_public_import_message < optional_lazy_message < bb: 127 > +optional_unverified_lazy_message < + bb: 128 +> repeated_int32: 201 repeated_int32: 301 repeated_int64: 202 diff --git a/r5dev/thirdparty/protobuf/testdata/text_format_unittest_extensions_data.txt b/r5dev/thirdparty/protobuf/testdata/text_format_unittest_extensions_data.txt index 8c8b1eb4..5c3a03ac 100644 --- a/r5dev/thirdparty/protobuf/testdata/text_format_unittest_extensions_data.txt +++ b/r5dev/thirdparty/protobuf/testdata/text_format_unittest_extensions_data.txt @@ -36,6 +36,9 @@ [protobuf_unittest.optional_lazy_message_extension] { bb: 127 } +[protobuf_unittest.optional_unverified_lazy_message_extension] { + bb: 128 +} [protobuf_unittest.repeated_int32_extension]: 201 [protobuf_unittest.repeated_int32_extension]: 301 [protobuf_unittest.repeated_int64_extension]: 202 diff --git a/r5dev/thirdparty/protobuf/testdata/text_format_unittest_extensions_data_pointy.txt b/r5dev/thirdparty/protobuf/testdata/text_format_unittest_extensions_data_pointy.txt index 132f7445..4233ca78 100644 --- a/r5dev/thirdparty/protobuf/testdata/text_format_unittest_extensions_data_pointy.txt +++ b/r5dev/thirdparty/protobuf/testdata/text_format_unittest_extensions_data_pointy.txt @@ -36,6 +36,9 @@ [protobuf_unittest.optional_lazy_message_extension] < bb: 127 > +[protobuf_unittest.optional_unverified_lazy_message_extension] < + bb: 128 +> [protobuf_unittest.repeated_int32_extension]: 201 [protobuf_unittest.repeated_int32_extension]: 301 [protobuf_unittest.repeated_int64_extension]: 202 diff --git a/r5dev/thirdparty/protobuf/text_format.cc b/r5dev/thirdparty/protobuf/text_format.cc index 1ce441e0..fff0713b 100644 --- a/r5dev/thirdparty/protobuf/text_format.cc +++ b/r5dev/thirdparty/protobuf/text_format.cc @@ -42,32 +42,30 @@ #include <climits> #include <cmath> #include <limits> +#include <utility> #include <vector> -#include <thirdparty/protobuf/stubs/stringprintf.h> -#include <thirdparty/protobuf/any.h> -#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/tokenizer.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> +#include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/any.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/dynamic_message.h> +#include <thirdparty/protobuf/io/strtod.h> #include <thirdparty/protobuf/map_field.h> #include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/repeated_field.h> #include <thirdparty/protobuf/unknown_field_set.h> #include <thirdparty/protobuf/wire_format_lite.h> -#include <thirdparty/protobuf/stubs/strutil.h> -#include <thirdparty/protobuf/io/strtod.h> #include <thirdparty/protobuf/stubs/map_util.h> #include <thirdparty/protobuf/stubs/stl_util.h> // Must be included last. #include <thirdparty/protobuf/port_def.inc> -#define DEBUG_STRING_SILENT_MARKER "\t " - namespace google { namespace protobuf { @@ -86,7 +84,10 @@ inline bool IsOctNumber(const std::string& str) { } // namespace namespace internal { -// Controls insertion of DEBUG_STRING_SILENT_MARKER. +const char kDebugStringSilentMarker[] = ""; +const char kDebugStringSilentMarkerForDetection[] = "\t "; + +// Controls insertion of kDebugStringSilentMarker. PROTOBUF_EXPORT std::atomic<bool> enable_debug_text_format_marker; } // namespace internal @@ -245,8 +246,8 @@ class TextFormat::Parser::ParserImpl { public: // Determines if repeated values for non-repeated fields and // oneofs are permitted, e.g., the string "foo: 1 foo: 2" for a - // required/optional field named "foo", or "baz: 1 qux: 2" - // where "baz" and "qux" are members of the same oneof. + // required/optional field named "foo", or "baz: 1 bar: 2" + // where "baz" and "bar" are members of the same oneof. enum SingularOverwritePolicy { ALLOW_SINGULAR_OVERWRITES = 0, // the last value is retained FORBID_SINGULAR_OVERWRITES = 1, // an error is issued @@ -276,6 +277,7 @@ class TextFormat::Parser::ParserImpl { allow_partial_(allow_partial), initial_recursion_limit_(recursion_limit), recursion_limit_(recursion_limit), + had_silent_marker_(false), had_errors_(false) { // For backwards-compatibility with proto1, we need to allow the 'f' suffix // for floats. @@ -429,10 +431,11 @@ class TextFormat::Parser::ParserImpl { std::string prefix_and_full_type_name = StrCat(prefix, full_type_name); DO(ConsumeBeforeWhitespace("]")); - TryConsumeWhitespace(prefix_and_full_type_name, "Any"); + TryConsumeWhitespace(); // ':' is optional between message labels and values. - TryConsumeBeforeWhitespace(":"); - TryConsumeWhitespace(prefix_and_full_type_name, "Any"); + if (TryConsumeBeforeWhitespace(":")) { + TryConsumeWhitespace(); + } std::string serialized_value; const Descriptor* value_descriptor = finder_ ? finder_->FindAnyType(*message, prefix, full_type_name) @@ -454,15 +457,16 @@ class TextFormat::Parser::ParserImpl { } } reflection->SetString(message, any_type_url_field, - prefix_and_full_type_name); - reflection->SetString(message, any_value_field, serialized_value); + std::move(prefix_and_full_type_name)); + reflection->SetString(message, any_value_field, + std::move(serialized_value)); return true; } if (TryConsume("[")) { // Extension. DO(ConsumeFullTypeName(&field_name)); DO(ConsumeBeforeWhitespace("]")); - TryConsumeWhitespace(message->GetTypeName(), "Extension"); + TryConsumeWhitespace(); field = finder_ ? finder_->FindExtension(message, field_name) : DefaultFinderFindExtension(message, field_name); @@ -482,7 +486,7 @@ class TextFormat::Parser::ParserImpl { } } else { DO(ConsumeIdentifierBeforeWhitespace(&field_name)); - TryConsumeWhitespace(message->GetTypeName(), "Normal"); + TryConsumeWhitespace(); int32_t field_number; if (allow_field_number_ && safe_strto32(field_name, &field_number)) { @@ -551,7 +555,7 @@ class TextFormat::Parser::ParserImpl { // If there is no ":" or there is a "{" or "<" after ":", this field has // to be a message or the input is ill-formed. if (TryConsumeBeforeWhitespace(":")) { - TryConsumeWhitespace(message->GetTypeName(), "Unknown/Reserved"); + TryConsumeWhitespace(); if (!LookingAt("{") && !LookingAt("<")) { return SkipFieldValue(); } @@ -587,7 +591,9 @@ class TextFormat::Parser::ParserImpl { if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // ':' is optional here. bool consumed_semicolon = TryConsumeBeforeWhitespace(":"); - TryConsumeWhitespace(message->GetTypeName(), "Normal"); + if (consumed_semicolon) { + TryConsumeWhitespace(); + } if (consumed_semicolon && field->options().weak() && LookingAtType(io::Tokenizer::TYPE_STRING)) { // we are getting a bytes string for a weak field. @@ -602,7 +608,7 @@ class TextFormat::Parser::ParserImpl { } else { // ':' is required here. DO(ConsumeBeforeWhitespace(":")); - TryConsumeWhitespace(message->GetTypeName(), "Normal"); + TryConsumeWhitespace(); } if (field->is_repeated() && TryConsume("[")) { @@ -653,15 +659,15 @@ class TextFormat::Parser::ParserImpl { // Skips the next field including the field's name and value. bool SkipField() { + std::string field_name; if (TryConsume("[")) { // Extension name or type URL. - DO(ConsumeTypeUrlOrFullTypeName()); + DO(ConsumeTypeUrlOrFullTypeName(&field_name)); DO(ConsumeBeforeWhitespace("]")); } else { - std::string field_name; DO(ConsumeIdentifierBeforeWhitespace(&field_name)); } - TryConsumeWhitespace("Unknown/Reserved", "n/a"); + TryConsumeWhitespace(); // Try to guess the type of this field. // If this field is not a message, there should be a ":" between the @@ -670,7 +676,7 @@ class TextFormat::Parser::ParserImpl { // If there is no ":" or there is a "{" or "<" after ":", this field has // to be a message or the input is ill-formed. if (TryConsumeBeforeWhitespace(":")) { - TryConsumeWhitespace("Unknown/Reserved", "n/a"); + TryConsumeWhitespace(); if (!LookingAt("{") && !LookingAt("<")) { DO(SkipFieldValue()); } else { @@ -800,7 +806,7 @@ class TextFormat::Parser::ParserImpl { case FieldDescriptor::CPPTYPE_STRING: { std::string value; DO(ConsumeString(&value)); - SET_FIELD(String, value); + SET_FIELD(String, std::move(value)); break; } @@ -975,7 +981,7 @@ class TextFormat::Parser::ParserImpl { } // Consumes an identifier and saves its value in the identifier parameter. - // Returns false if the token is not of type IDENTFIER. + // Returns false if the token is not of type IDENTIFIER. bool ConsumeIdentifier(std::string* identifier) { if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { *identifier = tokenizer_.current().text; @@ -1018,11 +1024,21 @@ class TextFormat::Parser::ParserImpl { return true; } - bool ConsumeTypeUrlOrFullTypeName() { - std::string discarded; - DO(ConsumeIdentifier(&discarded)); - while (TryConsume(".") || TryConsume("/")) { - DO(ConsumeIdentifier(&discarded)); + bool ConsumeTypeUrlOrFullTypeName(std::string* name) { + DO(ConsumeIdentifier(name)); + while (true) { + std::string connector; + if (TryConsume(".")) { + connector = "."; + } else if (TryConsume("/")) { + connector = "/"; + } else { + break; + } + std::string part; + DO(ConsumeIdentifier(&part)); + *name += connector; + *name += part; } return true; } @@ -1264,13 +1280,16 @@ class TextFormat::Parser::ParserImpl { return result; } - bool TryConsumeWhitespace(const std::string& message_type, - const char* field_type) { + bool TryConsumeWhitespace() { + had_silent_marker_ = false; if (LookingAtType(io::Tokenizer::TYPE_WHITESPACE)) { + if (tokenizer_.current().text == + StrCat(" ", internal::kDebugStringSilentMarkerForDetection)) { + had_silent_marker_ = true; + } tokenizer_.Next(); return true; } - return false; } @@ -1311,6 +1330,7 @@ class TextFormat::Parser::ParserImpl { const bool allow_partial_; const int initial_recursion_limit_; int recursion_limit_; + bool had_silent_marker_; bool had_errors_; }; @@ -1342,10 +1362,10 @@ class TextFormat::Printer::TextGenerator indent_level_(initial_indent_level), initial_indent_level_(initial_indent_level) {} - ~TextGenerator() { + ~TextGenerator() override { // Only BackUp() if we're sure we've successfully called Next() at least // once. - if (!failed_ && buffer_size_ > 0) { + if (!failed_) { output_->BackUp(buffer_size_); } } @@ -1404,7 +1424,7 @@ class TextFormat::Printer::TextGenerator void PrintMaybeWithMarker(StringPiece text) { Print(text.data(), text.size()); if (ConsumeInsertSilentMarker()) { - PrintLiteral(DEBUG_STRING_SILENT_MARKER); + PrintLiteral(internal::kDebugStringSilentMarker); } } @@ -1412,7 +1432,7 @@ class TextFormat::Printer::TextGenerator StringPiece text_tail) { Print(text_head.data(), text_head.size()); if (ConsumeInsertSilentMarker()) { - PrintLiteral(DEBUG_STRING_SILENT_MARKER); + PrintLiteral(internal::kDebugStringSilentMarker); } Print(text_tail.data(), text_tail.size()); } @@ -1640,7 +1660,6 @@ bool TextFormat::Parser::MergeFromString(ConstStringParam input, return Merge(&input_stream, output); } - bool TextFormat::Parser::MergeUsingImpl(io::ZeroCopyInputStream* /* input */, Message* output, ParserImpl* parser_impl) { @@ -1689,7 +1708,6 @@ bool TextFormat::Parser::ParseFieldValueFromString(const std::string& input, return Parser().MergeFromString(input, output); } - #undef DO // =========================================================================== @@ -2272,7 +2290,7 @@ class MapEntryMessageComparator { namespace internal { class MapFieldPrinterHelper { public: - // DynamicMapSorter::Sort cannot be used because it enfores syncing with + // DynamicMapSorter::Sort cannot be used because it enforces syncing with // repeated field. static bool SortMap(const Message& message, const Reflection* reflection, const FieldDescriptor* field, diff --git a/r5dev/thirdparty/protobuf/text_format.h b/r5dev/thirdparty/protobuf/text_format.h index f8122d60..cd45372c 100644 --- a/r5dev/thirdparty/protobuf/text_format.h +++ b/r5dev/thirdparty/protobuf/text_format.h @@ -38,17 +38,19 @@ #ifndef GOOGLE_PROTOBUF_TEXT_FORMAT_H__ #define GOOGLE_PROTOBUF_TEXT_FORMAT_H__ + #include <map> #include <memory> #include <string> #include <vector> #include <thirdparty/protobuf/stubs/common.h> +#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/message_lite.h> -#include <thirdparty/protobuf/port.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG @@ -58,6 +60,11 @@ namespace google { namespace protobuf { +namespace internal { +PROTOBUF_EXPORT extern const char kDebugStringSilentMarker[1]; +PROTOBUF_EXPORT extern const char kDebugStringSilentMarkerForDetection[3]; +} // namespace internal + namespace io { class ErrorCollector; // tokenizer.h } @@ -454,16 +461,15 @@ class PROTOBUF_EXPORT TextFormat { }; // Parses a text-format protocol message from the given input stream to - // the given message object. This function parses the human-readable format - // written by Print(). Returns true on success. The message is cleared first, - // even if the function fails -- See Merge() to avoid this behavior. + // the given message object. This function parses the human-readable + // serialization format written by Print(). Returns true on success. The + // message is cleared first, even if the function fails -- See Merge() to + // avoid this behavior. // // Example input: "user {\n id: 123 extra { gender: MALE language: 'en' }\n}" // - // One use for this function is parsing handwritten strings in test code. - // Another use is to parse the output from google::protobuf::Message::DebugString() - // (or ShortDebugString()), because these functions output using - // google::protobuf::TextFormat::Print(). + // One common use for this function is parsing handwritten strings in test + // code. // // If you would like to read a protocol buffer serialized in the // (non-human-readable) binary wire format, see diff --git a/r5dev/thirdparty/protobuf/text_format_unittest.cc b/r5dev/thirdparty/protobuf/text_format_unittest.cc index 3d7ec182..c40f6b5a 100644 --- a/r5dev/thirdparty/protobuf/text_format_unittest.cc +++ b/r5dev/thirdparty/protobuf/text_format_unittest.cc @@ -47,8 +47,6 @@ #include <thirdparty/protobuf/testing/file.h> #include <thirdparty/protobuf/any.pb.h> #include <thirdparty/protobuf/map_unittest.pb.h> -#include <thirdparty/protobuf/test_util.h> -#include <thirdparty/protobuf/test_util2.h> #include <thirdparty/protobuf/unittest.pb.h> #include <thirdparty/protobuf/unittest_mset.pb.h> #include <thirdparty/protobuf/unittest_mset_wire_format.pb.h> @@ -61,8 +59,11 @@ #include <gtest/gtest.h> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/substitute.h> +#include <thirdparty/protobuf/test_util.h> +#include <thirdparty/protobuf/test_util2.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -76,6 +77,8 @@ extern PROTOBUF_EXPORT std::atomic<bool> enable_debug_text_format_marker; // Can't use an anonymous namespace here due to brokenness of Tru64 compiler. namespace text_format_unittest { +using ::google::protobuf::internal::kDebugStringSilentMarker; + // A basic string with different escapable characters for testing. const std::string kEscapeTestString = "\"A string with ' characters \n and \r newlines and \t tabs and \001 " @@ -93,21 +96,21 @@ class TextFormatTest : public testing::Test { TestUtil::GetTestDataPath( "net/proto2/internal/" "testdata/text_format_unittest_data_oneof_implemented.txt"), - &static_proto_debug_string_, true)); - CleanStringLineEndings(&static_proto_debug_string_, false); + &static_proto_text_format_, true)); + CleanStringLineEndings(&static_proto_text_format_, false); } - TextFormatTest() : proto_debug_string_(static_proto_debug_string_) {} + TextFormatTest() : proto_text_format_(static_proto_text_format_) {} protected: - // Debug string read from text_format_unittest_data.txt. - const std::string proto_debug_string_; + // Text format read from text_format_unittest_data.txt. + const std::string proto_text_format_; unittest::TestAllTypes proto_; private: - static std::string static_proto_debug_string_; + static std::string static_proto_text_format_; }; -std::string TextFormatTest::static_proto_debug_string_; +std::string TextFormatTest::static_proto_text_format_; class TextFormatExtensionsTest : public testing::Test { public: @@ -115,31 +118,34 @@ class TextFormatExtensionsTest : public testing::Test { GOOGLE_CHECK_OK(File::GetContents( TestUtil::GetTestDataPath("net/proto2/internal/testdata/" "text_format_unittest_extensions_data.txt"), - &static_proto_debug_string_, true)); - CleanStringLineEndings(&static_proto_debug_string_, false); + &static_proto_text_format_, true)); + CleanStringLineEndings(&static_proto_text_format_, false); } - TextFormatExtensionsTest() - : proto_debug_string_(static_proto_debug_string_) {} + TextFormatExtensionsTest() : proto_text_format_(static_proto_text_format_) {} protected: // Debug string read from text_format_unittest_data.txt. - const std::string proto_debug_string_; + const std::string proto_text_format_; unittest::TestAllExtensions proto_; private: - static std::string static_proto_debug_string_; + static std::string static_proto_text_format_; }; -std::string TextFormatExtensionsTest::static_proto_debug_string_; +std::string TextFormatExtensionsTest::static_proto_text_format_; TEST_F(TextFormatTest, Basic) { TestUtil::SetAllFields(&proto_); - EXPECT_EQ(proto_debug_string_, proto_.DebugString()); + std::string actual_proto_text_format; + TextFormat::PrintToString(proto_, &actual_proto_text_format); + EXPECT_EQ(actual_proto_text_format, proto_text_format_); } TEST_F(TextFormatExtensionsTest, Extensions) { TestUtil::SetAllExtensions(&proto_); - EXPECT_EQ(proto_debug_string_, proto_.DebugString()); + std::string actual_proto_text_format; + TextFormat::PrintToString(proto_, &actual_proto_text_format); + EXPECT_EQ(actual_proto_text_format, proto_text_format_); } TEST_F(TextFormatTest, ShortDebugString) { @@ -148,11 +154,12 @@ TEST_F(TextFormatTest, ShortDebugString) { proto_.mutable_optional_nested_message()->set_bb(2); proto_.mutable_optional_foreign_message(); - EXPECT_EQ( - "optional_int32: 1 optional_string: \"hello\" " - "optional_nested_message { bb: 2 } " - "optional_foreign_message { }", - proto_.ShortDebugString()); + EXPECT_EQ(proto_.ShortDebugString(), + StrCat("optional_int32: ", kDebugStringSilentMarker, + "1 " + "optional_string: \"hello\" " + "optional_nested_message { bb: 2 } " + "optional_foreign_message { }")); } TEST_F(TextFormatTest, ShortPrimitiveRepeateds) { @@ -222,7 +229,8 @@ TEST_F(TextFormatTest, StringEscape) { // Hardcode a correct value to test against. std::string correct_string = - "optional_string: " + kEscapeTestStringEscaped + "\n"; + StrCat("optional_string: ", kDebugStringSilentMarker, + kEscapeTestStringEscaped, "\n"); // Compare. EXPECT_EQ(correct_string, debug_string); @@ -230,8 +238,8 @@ TEST_F(TextFormatTest, StringEscape) { // the protocol buffer contains no UTF-8 text. EXPECT_EQ(correct_string, utf8_debug_string); - std::string expected_short_debug_string = - "optional_string: " + kEscapeTestStringEscaped; + std::string expected_short_debug_string = StrCat( + "optional_string: ", kDebugStringSilentMarker, kEscapeTestStringEscaped); EXPECT_EQ(expected_short_debug_string, proto_.ShortDebugString()); } @@ -246,19 +254,13 @@ TEST_F(TextFormatTest, Utf8DebugString) { // Hardcode a correct value to test against. std::string correct_utf8_string = - "optional_string: " - "\"\350\260\267\346\255\214\"" - "\n" - "optional_bytes: " - "\"\\350\\260\\267\\346\\255\\214\"" - "\n"; + StrCat("optional_string: ", kDebugStringSilentMarker, + "\"\350\260\267\346\255\214\"\n" + "optional_bytes: \"\\350\\260\\267\\346\\255\\214\"\n"); std::string correct_string = - "optional_string: " - "\"\\350\\260\\267\\346\\255\\214\"" - "\n" - "optional_bytes: " - "\"\\350\\260\\267\\346\\255\\214\"" - "\n"; + StrCat("optional_string: ", kDebugStringSilentMarker, + "\"\\350\\260\\267\\346\\255\\214\"\n" + "optional_bytes: \"\\350\\260\\267\\346\\255\\214\"\n"); // Compare. EXPECT_EQ(correct_utf8_string, utf8_debug_string); @@ -281,18 +283,18 @@ TEST_F(TextFormatTest, PrintUnknownFields) { unknown_fields->AddVarint(8, 2); unknown_fields->AddVarint(8, 3); - EXPECT_EQ( - "5: 1\n" - "5: 0x00000002\n" - "5: 0x0000000000000003\n" - "5: \"4\"\n" - "5 {\n" - " 10: 5\n" - "}\n" - "8: 1\n" - "8: 2\n" - "8: 3\n", - message.DebugString()); + EXPECT_EQ(StrCat("5: ", kDebugStringSilentMarker, + "1\n" + "5: 0x00000002\n" + "5: 0x0000000000000003\n" + "5: \"4\"\n" + "5 {\n" + " 10: 5\n" + "}\n" + "8: 1\n" + "8: 2\n" + "8: 3\n"), + message.DebugString()); } TEST_F(TextFormatTest, PrintUnknownFieldsHidden) { @@ -456,7 +458,7 @@ TEST_F(TextFormatTest, PrintBufferTooSmall) { // A printer that appends 'u' to all unsigned int32. class CustomUInt32FieldValuePrinter : public TextFormat::FieldValuePrinter { public: - virtual std::string PrintUInt32(uint32 val) const { + std::string PrintUInt32(uint32_t val) const override { return StrCat(FieldValuePrinter::PrintUInt32(val), "u"); } }; @@ -480,7 +482,7 @@ TEST_F(TextFormatTest, DefaultCustomFieldPrinter) { class CustomInt32FieldValuePrinter : public TextFormat::FieldValuePrinter { public: - virtual std::string PrintInt32(int32 val) const { + std::string PrintInt32(int32_t val) const override { return StrCat("value-is(", FieldValuePrinter::PrintInt32(val), ")"); } }; @@ -531,14 +533,14 @@ TEST_F(TextFormatTest, ErrorCasesRegisteringFieldValuePrinterShouldFail) { class CustomMessageFieldValuePrinter : public TextFormat::FieldValuePrinter { public: - virtual std::string PrintInt32(int32 v) const { + std::string PrintInt32(int32_t v) const override { return StrCat(FieldValuePrinter::PrintInt32(v), " # x", strings::Hex(v)); } - virtual std::string PrintMessageStart(const Message& message, int field_index, - int field_count, - bool single_line_mode) const { + std::string PrintMessageStart(const Message& message, int field_index, + int field_count, + bool single_line_mode) const override { if (single_line_mode) { return " { "; } @@ -629,9 +631,9 @@ TEST_F(TextFormatTest, CustomPrinterForMessageContent) { class CustomMultilineCommentPrinter : public TextFormat::FieldValuePrinter { public: - virtual std::string PrintMessageStart(const Message& message, int field_index, - int field_count, - bool single_line_comment) const { + std::string PrintMessageStart(const Message& message, int field_index, + int field_count, + bool single_line_comment) const override { return StrCat(" { # 1\n", " # 2\n"); } }; @@ -799,15 +801,15 @@ TEST_F(TextFormatTest, CustomMessagePrinter) { } TEST_F(TextFormatTest, ParseBasic) { - io::ArrayInputStream input_stream(proto_debug_string_.data(), - proto_debug_string_.size()); + io::ArrayInputStream input_stream(proto_text_format_.data(), + proto_text_format_.size()); TextFormat::Parse(&input_stream, &proto_); TestUtil::ExpectAllFieldsSet(proto_); } TEST_F(TextFormatExtensionsTest, ParseExtensions) { - io::ArrayInputStream input_stream(proto_debug_string_.data(), - proto_debug_string_.size()); + io::ArrayInputStream input_stream(proto_text_format_.data(), + proto_text_format_.size()); TextFormat::Parse(&input_stream, &proto_); TestUtil::ExpectAllExtensionsSet(proto_); } @@ -843,12 +845,12 @@ TEST_F(TextFormatTest, PrintUnknownEnumFieldProto3) { proto.add_repeated_nested_enum( static_cast<proto3_unittest::TestAllTypes::NestedEnum>(-2147483648)); - EXPECT_EQ( - "repeated_nested_enum: 10\n" - "repeated_nested_enum: -10\n" - "repeated_nested_enum: 2147483647\n" - "repeated_nested_enum: -2147483648\n", - proto.DebugString()); + EXPECT_EQ(StrCat("repeated_nested_enum: ", kDebugStringSilentMarker, + "10\n" + "repeated_nested_enum: -10\n" + "repeated_nested_enum: 2147483647\n" + "repeated_nested_enum: -2147483648\n"), + proto.DebugString()); } TEST_F(TextFormatTest, ParseUnknownEnumFieldProto3) { @@ -1101,19 +1103,20 @@ TEST_F(TextFormatTest, PrintExotic) { // have this problem, so we switched to that instead. EXPECT_EQ( - "repeated_int64: -9223372036854775808\n" - "repeated_uint64: 18446744073709551615\n" - "repeated_double: 123.456\n" - "repeated_double: 1.23e+21\n" - "repeated_double: 1.23e-18\n" - "repeated_double: inf\n" - "repeated_double: -inf\n" - "repeated_double: nan\n" - "repeated_double: nan\n" - "repeated_double: nan\n" - "repeated_double: nan\n" - "repeated_string: " - "\"\\000\\001\\007\\010\\014\\n\\r\\t\\013\\\\\\'\\\"\"\n", + StrCat("repeated_int64: ", kDebugStringSilentMarker, + "-9223372036854775808\n" + "repeated_uint64: 18446744073709551615\n" + "repeated_double: 123.456\n" + "repeated_double: 1.23e+21\n" + "repeated_double: 1.23e-18\n" + "repeated_double: inf\n" + "repeated_double: -inf\n" + "repeated_double: nan\n" + "repeated_double: nan\n" + "repeated_double: nan\n" + "repeated_double: nan\n" + "repeated_string: " + "\"\\000\\001\\007\\010\\014\\n\\r\\t\\013\\\\\\'\\\"\"\n"), RemoveRedundantZeros(message.DebugString())); } @@ -1160,47 +1163,47 @@ TEST_F(TextFormatTest, PrintFloatPrecision) { message.add_repeated_double(1.2345678987654e100); message.add_repeated_double(1.23456789876543e100); - EXPECT_EQ( - "repeated_float: 1\n" - "repeated_float: 1.2\n" - "repeated_float: 1.23\n" - "repeated_float: 1.234\n" - "repeated_float: 1.2345\n" - "repeated_float: 1.23456\n" - "repeated_float: 1.2e+10\n" - "repeated_float: 1.23e+10\n" - "repeated_float: 1.234e+10\n" - "repeated_float: 1.2345e+10\n" - "repeated_float: 1.23456e+10\n" - "repeated_double: 1.2\n" - "repeated_double: 1.23\n" - "repeated_double: 1.234\n" - "repeated_double: 1.2345\n" - "repeated_double: 1.23456\n" - "repeated_double: 1.234567\n" - "repeated_double: 1.2345678\n" - "repeated_double: 1.23456789\n" - "repeated_double: 1.234567898\n" - "repeated_double: 1.2345678987\n" - "repeated_double: 1.23456789876\n" - "repeated_double: 1.234567898765\n" - "repeated_double: 1.2345678987654\n" - "repeated_double: 1.23456789876543\n" - "repeated_double: 1.2e+100\n" - "repeated_double: 1.23e+100\n" - "repeated_double: 1.234e+100\n" - "repeated_double: 1.2345e+100\n" - "repeated_double: 1.23456e+100\n" - "repeated_double: 1.234567e+100\n" - "repeated_double: 1.2345678e+100\n" - "repeated_double: 1.23456789e+100\n" - "repeated_double: 1.234567898e+100\n" - "repeated_double: 1.2345678987e+100\n" - "repeated_double: 1.23456789876e+100\n" - "repeated_double: 1.234567898765e+100\n" - "repeated_double: 1.2345678987654e+100\n" - "repeated_double: 1.23456789876543e+100\n", - RemoveRedundantZeros(message.DebugString())); + EXPECT_EQ(StrCat("repeated_float: ", kDebugStringSilentMarker, + "1\n" + "repeated_float: 1.2\n" + "repeated_float: 1.23\n" + "repeated_float: 1.234\n" + "repeated_float: 1.2345\n" + "repeated_float: 1.23456\n" + "repeated_float: 1.2e+10\n" + "repeated_float: 1.23e+10\n" + "repeated_float: 1.234e+10\n" + "repeated_float: 1.2345e+10\n" + "repeated_float: 1.23456e+10\n" + "repeated_double: 1.2\n" + "repeated_double: 1.23\n" + "repeated_double: 1.234\n" + "repeated_double: 1.2345\n" + "repeated_double: 1.23456\n" + "repeated_double: 1.234567\n" + "repeated_double: 1.2345678\n" + "repeated_double: 1.23456789\n" + "repeated_double: 1.234567898\n" + "repeated_double: 1.2345678987\n" + "repeated_double: 1.23456789876\n" + "repeated_double: 1.234567898765\n" + "repeated_double: 1.2345678987654\n" + "repeated_double: 1.23456789876543\n" + "repeated_double: 1.2e+100\n" + "repeated_double: 1.23e+100\n" + "repeated_double: 1.234e+100\n" + "repeated_double: 1.2345e+100\n" + "repeated_double: 1.23456e+100\n" + "repeated_double: 1.234567e+100\n" + "repeated_double: 1.2345678e+100\n" + "repeated_double: 1.23456789e+100\n" + "repeated_double: 1.234567898e+100\n" + "repeated_double: 1.2345678987e+100\n" + "repeated_double: 1.23456789876e+100\n" + "repeated_double: 1.234567898765e+100\n" + "repeated_double: 1.2345678987654e+100\n" + "repeated_double: 1.23456789876543e+100\n"), + RemoveRedundantZeros(message.DebugString())); } TEST_F(TextFormatTest, AllowPartial) { @@ -1433,17 +1436,17 @@ class TextFormatParserTest : public testing::Test { class MockErrorCollector : public io::ErrorCollector { public: MockErrorCollector() {} - ~MockErrorCollector() {} + ~MockErrorCollector() override {} std::string text_; // implements ErrorCollector ------------------------------------- - void AddError(int line, int column, const std::string& message) { + void AddError(int line, int column, const std::string& message) override { strings::SubstituteAndAppend(&text_, "$0:$1: $2\n", line + 1, column + 1, message); } - void AddWarning(int line, int column, const std::string& message) { + void AddWarning(int line, int column, const std::string& message) override { AddError(line, column, "WARNING:" + message); } }; @@ -2063,9 +2066,9 @@ TEST_F(TextFormatParserTest, ParseSkippedFieldWithAdditionalWhiteSpaces) { class TextFormatMessageSetTest : public testing::Test { protected: - static const char proto_debug_string_[]; + static const char proto_text_format_[]; }; -const char TextFormatMessageSetTest::proto_debug_string_[] = +const char TextFormatMessageSetTest::proto_text_format_[] = "message_set {\n" " [protobuf_unittest.TestMessageSetExtension1] {\n" " i: 23\n" @@ -2085,12 +2088,14 @@ TEST_F(TextFormatMessageSetTest, Serialize) { proto.mutable_message_set()->MutableExtension( protobuf_unittest::TestMessageSetExtension2::message_set_extension); item_b->set_str("foo"); - EXPECT_EQ(proto_debug_string_, proto.DebugString()); + std::string actual_proto_text_format; + TextFormat::PrintToString(proto, &actual_proto_text_format); + EXPECT_EQ(proto_text_format_, actual_proto_text_format); } TEST_F(TextFormatMessageSetTest, Deserialize) { protobuf_unittest::TestMessageSetContainer proto; - ASSERT_TRUE(TextFormat::ParseFromString(proto_debug_string_, &proto)); + ASSERT_TRUE(TextFormat::ParseFromString(proto_text_format_, &proto)); EXPECT_EQ( 23, proto.message_set() @@ -2250,131 +2255,6 @@ TEST(TextFormatUnknownFieldTest, TestUnknownExtension) { EXPECT_FALSE(parser.ParseFromString("unknown_field: 1", &proto)); } -class TextFormatSilentMarkerTest : public testing::Test { - public: - void SetUp() override { - google::protobuf::internal::enable_debug_text_format_marker = true; - } - void TearDown() override { - google::protobuf::internal::enable_debug_text_format_marker = false; - } -}; - -TEST_F(TextFormatSilentMarkerTest, NonMessageFieldAsFirstField) { - protobuf_unittest::TestAllTypes proto; - proto.set_optional_int32(1); - proto.mutable_optional_nested_message()->set_bb(2); - - EXPECT_EQ( - "optional_int32: \t 1\n" - "optional_nested_message {\n" - " bb: 2\n" - "}\n", - proto.DebugString()); - - EXPECT_EQ( - "optional_int32: \t 1 " - "optional_nested_message { bb: 2 }", - proto.ShortDebugString()); -} - -TEST_F(TextFormatSilentMarkerTest, MessageFieldAsFirstField) { - protobuf_unittest::TestAllTypes proto; - proto.mutable_optional_nested_message()->set_bb(2); - proto.add_repeated_int32(3); - - EXPECT_EQ( - "optional_nested_message \t {\n" - " bb: 2\n" - "}\n" - "repeated_int32: 3\n", - proto.DebugString()); - - EXPECT_EQ( - "optional_nested_message \t { bb: 2 } " - "repeated_int32: 3", - proto.ShortDebugString()); -} - -TEST_F(TextFormatSilentMarkerTest, UnknownFieldAsFirstField) { - unittest::TestEmptyMessage message; - UnknownFieldSet* unknown_fields = message.mutable_unknown_fields(); - - unknown_fields->AddVarint(5, 1); - unknown_fields->AddGroup(5)->AddVarint(10, 5); - - EXPECT_EQ( - "5: \t 1\n" - "5 {\n" - " 10: 5\n" - "}\n", - message.DebugString()); - - EXPECT_EQ( - "5: \t 1 " - "5 { 10: 5 }", - message.ShortDebugString()); - - unknown_fields->Clear(); - unknown_fields->AddGroup(5)->AddVarint(10, 5); - unknown_fields->AddVarint(5, 1); - - EXPECT_EQ( - "5 \t {\n" - " 10: 5\n" - "}\n" - "5: 1\n", - message.DebugString()); - - EXPECT_EQ( - "5 \t { 10: 5 } " - "5: 1", - message.ShortDebugString()); -} - -TEST_F(TextFormatSilentMarkerTest, AnyFieldAsFirstField) { - protobuf_unittest::TestAllTypes proto; - proto.set_optional_string("teststr"); - proto.set_optional_int32(432); - Any any; - any.PackFrom(proto); - - EXPECT_EQ( - "[type.googleapis.com/protobuf_unittest.TestAllTypes] \t {\n" - " optional_int32: 432\n" - " optional_string: \"teststr\"\n" - "}\n", - any.DebugString()); - - EXPECT_EQ( - "[type.googleapis.com/protobuf_unittest.TestAllTypes]" - " \t { optional_int32: 432 optional_string: \"teststr\" }", - any.ShortDebugString()); -} - -TEST_F(TextFormatSilentMarkerTest, ExtensionFieldAsFirstField) { - unittest::TestAllExtensions proto; - proto.SetExtension(protobuf_unittest::optional_int32_extension, 101); - proto.SetExtension(protobuf_unittest::optional_int64_extension, 102); - - EXPECT_EQ( - "[protobuf_unittest.optional_int32_extension]: \t 101\n" - "[protobuf_unittest.optional_int64_extension]: 102\n", - proto.DebugString()); -} - -TEST_F(TextFormatSilentMarkerTest, MapFieldAsFirstField) { - unittest::TestMap proto; - (*proto.mutable_map_int32_int32())[0] = 1; - (*proto.mutable_map_int64_int64())[2] = 3; - - EXPECT_EQ( - "map_int32_int32 \t {\n key: 0\n value: 1\n}\n" - "map_int64_int64 {\n key: 2\n value: 3\n}\n", - proto.DebugString()); -} - - TEST(TextFormatFloatingPointTest, PreservesNegative0) { proto3_unittest::TestAllTypes in_message; in_message.set_optional_float(-0.0f); diff --git a/r5dev/thirdparty/protobuf/timestamp.pb.cc b/r5dev/thirdparty/protobuf/timestamp.pb.cc index c330ffd3..c56c4881 100644 --- a/r5dev/thirdparty/protobuf/timestamp.pb.cc +++ b/r5dev/thirdparty/protobuf/timestamp.pb.cc @@ -16,24 +16,29 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + PROTOBUF_NAMESPACE_OPEN -constexpr Timestamp::Timestamp( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : seconds_(int64_t{0}) - , nanos_(0){} +PROTOBUF_CONSTEXPR Timestamp::Timestamp( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.seconds_)*/int64_t{0} + , /*decltype(_impl_.nanos_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} struct TimestampDefaultTypeInternal { - constexpr TimestampDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR TimestampDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~TimestampDefaultTypeInternal() {} union { Timestamp _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT TimestampDefaultTypeInternal _Timestamp_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 TimestampDefaultTypeInternal _Timestamp_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto[1]; -static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr; +static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto[1]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr; const uint32_t TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ @@ -42,15 +47,15 @@ const uint32_t TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets[] PROT ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, seconds_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, nanos_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, _impl_.seconds_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Timestamp, _impl_.nanos_), }; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Timestamp)}, }; -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Timestamp_default_instance_), +static const ::_pb::Message* const file_default_instances[] = { + &::PROTOBUF_NAMESPACE_ID::_Timestamp_default_instance_._instance, }; const char descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = @@ -61,19 +66,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto[] PRO "tobuf/types/known/timestamppb\370\001\001\242\002\003GPB\252\002" "\036Google.Protobuf.WellKnownTypesb\006proto3" ; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto = { - false, false, 239, descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto, "google/protobuf/timestamp.proto", - &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once, nullptr, 0, 1, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto, +static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto = { + false, false, 239, descriptor_table_protodef_google_2fprotobuf_2ftimestamp_2eproto, + "google/protobuf/timestamp.proto", + &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once, nullptr, 0, 1, + schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftimestamp_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto, + file_level_service_descriptors_google_2fprotobuf_2ftimestamp_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_getter() { +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto; } // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ftimestamp_2eproto(&descriptor_table_google_2fprotobuf_2ftimestamp_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ftimestamp_2eproto(&descriptor_table_google_2fprotobuf_2ftimestamp_2eproto); PROTOBUF_NAMESPACE_OPEN // =================================================================== @@ -85,47 +92,50 @@ class Timestamp::_Internal { Timestamp::Timestamp(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Timestamp) } Timestamp::Timestamp(const Timestamp& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + Timestamp* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.seconds_){} + , decltype(_impl_.nanos_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::memcpy(&seconds_, &from.seconds_, - static_cast<size_t>(reinterpret_cast<char*>(&nanos_) - - reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_)); + ::memcpy(&_impl_.seconds_, &from._impl_.seconds_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.nanos_) - + reinterpret_cast<char*>(&_impl_.seconds_)) + sizeof(_impl_.nanos_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Timestamp) } -inline void Timestamp::SharedCtor() { -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&seconds_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&nanos_) - - reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_)); +inline void Timestamp::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.seconds_){int64_t{0}} + , decltype(_impl_.nanos_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; } Timestamp::~Timestamp() { // @@protoc_insertion_point(destructor:google.protobuf.Timestamp) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Timestamp::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } -void Timestamp::ArenaDtor(void* object) { - Timestamp* _this = reinterpret_cast< Timestamp* >(object); - (void)_this; -} -void Timestamp::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Timestamp::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Timestamp::Clear() { @@ -134,22 +144,22 @@ void Timestamp::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - ::memset(&seconds_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&nanos_) - - reinterpret_cast<char*>(&seconds_)) + sizeof(nanos_)); + ::memset(&_impl_.seconds_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.nanos_) - + reinterpret_cast<char*>(&_impl_.seconds_)) + sizeof(_impl_.nanos_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Timestamp::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Timestamp::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // int64 seconds = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { - seconds_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.seconds_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -157,7 +167,7 @@ const char* Timestamp::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:: // int32 nanos = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { - nanos_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.nanos_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -194,17 +204,17 @@ uint8_t* Timestamp::_InternalSerialize( // int64 seconds = 1; if (this->_internal_seconds() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(1, this->_internal_seconds(), target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(1, this->_internal_seconds(), target); } // int32 nanos = 2; if (this->_internal_nanos() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_nanos(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_nanos(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Timestamp) @@ -221,43 +231,39 @@ size_t Timestamp::ByteSizeLong() const { // int64 seconds = 1; if (this->_internal_seconds() != 0) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64SizePlusOne(this->_internal_seconds()); + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_seconds()); } // int32 nanos = 2; if (this->_internal_nanos() != 0) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_nanos()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_nanos()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Timestamp::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Timestamp::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Timestamp::GetClassData() const { return &_class_data_; } -void Timestamp::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Timestamp *>(to)->MergeFrom( - static_cast<const Timestamp &>(from)); -} - -void Timestamp::MergeFrom(const Timestamp& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Timestamp) - GOOGLE_DCHECK_NE(&from, this); +void Timestamp::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Timestamp*>(&to_msg); + auto& from = static_cast<const Timestamp&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Timestamp) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_seconds() != 0) { - _internal_set_seconds(from._internal_seconds()); + _this->_internal_set_seconds(from._internal_seconds()); } if (from._internal_nanos() != 0) { - _internal_set_nanos(from._internal_nanos()); + _this->_internal_set_nanos(from._internal_nanos()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Timestamp::CopyFrom(const Timestamp& from) { @@ -275,15 +281,15 @@ void Timestamp::InternalSwap(Timestamp* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Timestamp, nanos_) - + sizeof(Timestamp::nanos_) - - PROTOBUF_FIELD_OFFSET(Timestamp, seconds_)>( - reinterpret_cast<char*>(&seconds_), - reinterpret_cast<char*>(&other->seconds_)); + PROTOBUF_FIELD_OFFSET(Timestamp, _impl_.nanos_) + + sizeof(Timestamp::_impl_.nanos_) + - PROTOBUF_FIELD_OFFSET(Timestamp, _impl_.seconds_)>( + reinterpret_cast<char*>(&_impl_.seconds_), + reinterpret_cast<char*>(&other->_impl_.seconds_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Timestamp::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftimestamp_2eproto_once, file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto[0]); } @@ -291,7 +297,8 @@ void Timestamp::InternalSwap(Timestamp* other) { // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Timestamp* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Timestamp >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Timestamp* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Timestamp >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Timestamp >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/thirdparty/protobuf/timestamp.pb.h b/r5dev/thirdparty/protobuf/timestamp.pb.h index 4bf9cbe8..9365e1ab 100644 --- a/r5dev/thirdparty/protobuf/timestamp.pb.h +++ b/r5dev/thirdparty/protobuf/timestamp.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/generated_message_reflection.h> @@ -42,14 +41,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftimestamp_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftimestamp_2eproto; @@ -70,7 +61,7 @@ class PROTOBUF_EXPORT Timestamp final : public: inline Timestamp() : Timestamp(nullptr) {} ~Timestamp() override; - explicit constexpr Timestamp(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Timestamp(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Timestamp(const Timestamp& from); Timestamp(Timestamp&& from) noexcept @@ -145,9 +136,11 @@ class PROTOBUF_EXPORT Timestamp final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Timestamp& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Timestamp& from); + void MergeFrom( const Timestamp& from) { + Timestamp::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -156,10 +149,10 @@ class PROTOBUF_EXPORT Timestamp final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Timestamp* other); @@ -172,9 +165,6 @@ class PROTOBUF_EXPORT Timestamp final : protected: explicit Timestamp(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -215,9 +205,12 @@ class PROTOBUF_EXPORT Timestamp final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - int64_t seconds_; - int32_t nanos_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + int64_t seconds_; + int32_t nanos_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2ftimestamp_2eproto; }; // =================================================================== @@ -233,10 +226,10 @@ class PROTOBUF_EXPORT Timestamp final : // int64 seconds = 1; inline void Timestamp::clear_seconds() { - seconds_ = int64_t{0}; + _impl_.seconds_ = int64_t{0}; } inline int64_t Timestamp::_internal_seconds() const { - return seconds_; + return _impl_.seconds_; } inline int64_t Timestamp::seconds() const { // @@protoc_insertion_point(field_get:google.protobuf.Timestamp.seconds) @@ -244,7 +237,7 @@ inline int64_t Timestamp::seconds() const { } inline void Timestamp::_internal_set_seconds(int64_t value) { - seconds_ = value; + _impl_.seconds_ = value; } inline void Timestamp::set_seconds(int64_t value) { _internal_set_seconds(value); @@ -253,10 +246,10 @@ inline void Timestamp::set_seconds(int64_t value) { // int32 nanos = 2; inline void Timestamp::clear_nanos() { - nanos_ = 0; + _impl_.nanos_ = 0; } inline int32_t Timestamp::_internal_nanos() const { - return nanos_; + return _impl_.nanos_; } inline int32_t Timestamp::nanos() const { // @@protoc_insertion_point(field_get:google.protobuf.Timestamp.nanos) @@ -264,7 +257,7 @@ inline int32_t Timestamp::nanos() const { } inline void Timestamp::_internal_set_nanos(int32_t value) { - nanos_ = value; + _impl_.nanos_ = value; } inline void Timestamp::set_nanos(int32_t value) { _internal_set_nanos(value); diff --git a/r5dev/thirdparty/protobuf/type.pb.cc b/r5dev/thirdparty/protobuf/type.pb.cc index f8527a3f..f51b4b78 100644 --- a/r5dev/thirdparty/protobuf/type.pb.cc +++ b/r5dev/thirdparty/protobuf/type.pb.cc @@ -16,96 +16,101 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + PROTOBUF_NAMESPACE_OPEN -constexpr Type::Type( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : fields_() - , oneofs_() - , options_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , source_context_(nullptr) - , syntax_(0) -{} +PROTOBUF_CONSTEXPR Type::Type( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.fields_)*/{} + , /*decltype(_impl_.oneofs_)*/{} + , /*decltype(_impl_.options_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.source_context_)*/nullptr + , /*decltype(_impl_.syntax_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} struct TypeDefaultTypeInternal { - constexpr TypeDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR TypeDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~TypeDefaultTypeInternal() {} union { Type _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT TypeDefaultTypeInternal _Type_default_instance_; -constexpr Field::Field( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : options_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , type_url_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , json_name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , default_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , kind_(0) - - , cardinality_(0) - - , number_(0) - , oneof_index_(0) - , packed_(false){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 TypeDefaultTypeInternal _Type_default_instance_; +PROTOBUF_CONSTEXPR Field::Field( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.options_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.type_url_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.json_name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.default_value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.kind_)*/0 + , /*decltype(_impl_.cardinality_)*/0 + , /*decltype(_impl_.number_)*/0 + , /*decltype(_impl_.oneof_index_)*/0 + , /*decltype(_impl_.packed_)*/false + , /*decltype(_impl_._cached_size_)*/{}} {} struct FieldDefaultTypeInternal { - constexpr FieldDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FieldDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~FieldDefaultTypeInternal() {} union { Field _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FieldDefaultTypeInternal _Field_default_instance_; -constexpr Enum::Enum( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : enumvalue_() - , options_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , source_context_(nullptr) - , syntax_(0) -{} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDefaultTypeInternal _Field_default_instance_; +PROTOBUF_CONSTEXPR Enum::Enum( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.enumvalue_)*/{} + , /*decltype(_impl_.options_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.source_context_)*/nullptr + , /*decltype(_impl_.syntax_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} struct EnumDefaultTypeInternal { - constexpr EnumDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~EnumDefaultTypeInternal() {} union { Enum _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumDefaultTypeInternal _Enum_default_instance_; -constexpr EnumValue::EnumValue( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : options_() - , name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , number_(0){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDefaultTypeInternal _Enum_default_instance_; +PROTOBUF_CONSTEXPR EnumValue::EnumValue( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.options_)*/{} + , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.number_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} struct EnumValueDefaultTypeInternal { - constexpr EnumValueDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumValueDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~EnumValueDefaultTypeInternal() {} union { EnumValue _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EnumValueDefaultTypeInternal _EnumValue_default_instance_; -constexpr Option::Option( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : name_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) - , value_(nullptr){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDefaultTypeInternal _EnumValue_default_instance_; +PROTOBUF_CONSTEXPR Option::Option( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.value_)*/nullptr + , /*decltype(_impl_._cached_size_)*/{}} {} struct OptionDefaultTypeInternal { - constexpr OptionDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR OptionDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~OptionDefaultTypeInternal() {} union { Option _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT OptionDefaultTypeInternal _Option_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OptionDefaultTypeInternal _Option_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2ftype_2eproto[5]; -static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto[3]; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto = nullptr; +static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2ftype_2eproto[5]; +static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto[3]; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto = nullptr; const uint32_t TableStruct_google_2fprotobuf_2ftype_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ @@ -114,58 +119,58 @@ const uint32_t TableStruct_google_2fprotobuf_2ftype_2eproto::offsets[] PROTOBUF_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, fields_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, oneofs_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, source_context_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, syntax_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.fields_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.oneofs_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.source_context_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Type, _impl_.syntax_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, kind_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, cardinality_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, number_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, type_url_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, oneof_index_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, packed_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, json_name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, default_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.kind_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.cardinality_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.number_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.type_url_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.oneof_index_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.packed_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.json_name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Field, _impl_.default_value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, enumvalue_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, source_context_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, syntax_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.enumvalue_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.source_context_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Enum, _impl_.syntax_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, number_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _impl_.number_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValue, _impl_.options_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Option, _impl_.value_), }; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Type)}, { 12, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Field)}, { 28, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Enum)}, @@ -173,12 +178,12 @@ static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOB { 48, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Option)}, }; -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Type_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Field_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Enum_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_EnumValue_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Option_default_instance_), +static const ::_pb::Message* const file_default_instances[] = { + &::PROTOBUF_NAMESPACE_ID::_Type_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_Field_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_Enum_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumValue_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_Option_default_instance_._instance, }; const char descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = @@ -223,23 +228,25 @@ const char descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto[] PROTOBUF "buf/types/known/typepb\370\001\001\242\002\003GPB\252\002\036Google" ".Protobuf.WellKnownTypesb\006proto3" ; -static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_google_2fprotobuf_2ftype_2eproto_deps[2] = { +static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2ftype_2eproto_deps[2] = { &::descriptor_table_google_2fprotobuf_2fany_2eproto, &::descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto, }; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2ftype_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftype_2eproto = { - false, false, 1592, descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto, "google/protobuf/type.proto", - &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, descriptor_table_google_2fprotobuf_2ftype_2eproto_deps, 2, 5, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftype_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2ftype_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto, file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto, +static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2ftype_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2ftype_2eproto = { + false, false, 1592, descriptor_table_protodef_google_2fprotobuf_2ftype_2eproto, + "google/protobuf/type.proto", + &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, descriptor_table_google_2fprotobuf_2ftype_2eproto_deps, 2, 5, + schemas, file_default_instances, TableStruct_google_2fprotobuf_2ftype_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2ftype_2eproto, file_level_enum_descriptors_google_2fprotobuf_2ftype_2eproto, + file_level_service_descriptors_google_2fprotobuf_2ftype_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2ftype_2eproto_getter() { +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2ftype_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2ftype_2eproto; } // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ftype_2eproto(&descriptor_table_google_2fprotobuf_2ftype_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2ftype_2eproto(&descriptor_table_google_2fprotobuf_2ftype_2eproto); PROTOBUF_NAMESPACE_OPEN const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Field_Kind_descriptor() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2ftype_2eproto); @@ -345,81 +352,87 @@ class Type::_Internal { const ::PROTOBUF_NAMESPACE_ID::SourceContext& Type::_Internal::source_context(const Type* msg) { - return *msg->source_context_; + return *msg->_impl_.source_context_; } void Type::clear_source_context() { - if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) { - delete source_context_; + if (GetArenaForAllocation() == nullptr && _impl_.source_context_ != nullptr) { + delete _impl_.source_context_; } - source_context_ = nullptr; + _impl_.source_context_ = nullptr; } Type::Type(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - fields_(arena), - oneofs_(arena), - options_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Type) } Type::Type(const Type& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - fields_(from.fields_), - oneofs_(from.oneofs_), - options_(from.options_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + Type* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.fields_){from._impl_.fields_} + , decltype(_impl_.oneofs_){from._impl_.oneofs_} + , decltype(_impl_.options_){from._impl_.options_} + , decltype(_impl_.name_){} + , decltype(_impl_.source_context_){nullptr} + , decltype(_impl_.syntax_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_name().empty()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } if (from._internal_has_source_context()) { - source_context_ = new ::PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_); - } else { - source_context_ = nullptr; + _this->_impl_.source_context_ = new ::PROTOBUF_NAMESPACE_ID::SourceContext(*from._impl_.source_context_); } - syntax_ = from.syntax_; + _this->_impl_.syntax_ = from._impl_.syntax_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Type) } -inline void Type::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&source_context_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&syntax_) - - reinterpret_cast<char*>(&source_context_)) + sizeof(syntax_)); +inline void Type::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.fields_){arena} + , decltype(_impl_.oneofs_){arena} + , decltype(_impl_.options_){arena} + , decltype(_impl_.name_){} + , decltype(_impl_.source_context_){nullptr} + , decltype(_impl_.syntax_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } Type::~Type() { // @@protoc_insertion_point(destructor:google.protobuf.Type) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Type::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete source_context_; + _impl_.fields_.~RepeatedPtrField(); + _impl_.oneofs_.~RepeatedPtrField(); + _impl_.options_.~RepeatedPtrField(); + _impl_.name_.Destroy(); + if (this != internal_default_instance()) delete _impl_.source_context_; } -void Type::ArenaDtor(void* object) { - Type* _this = reinterpret_cast< Type* >(object); - (void)_this; -} -void Type::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Type::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Type::Clear() { @@ -428,31 +441,31 @@ void Type::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - fields_.Clear(); - oneofs_.Clear(); - options_.Clear(); - name_.ClearToEmpty(); - if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) { - delete source_context_; + _impl_.fields_.Clear(); + _impl_.oneofs_.Clear(); + _impl_.options_.Clear(); + _impl_.name_.ClearToEmpty(); + if (GetArenaForAllocation() == nullptr && _impl_.source_context_ != nullptr) { + delete _impl_.source_context_; } - source_context_ = nullptr; - syntax_ = 0; + _impl_.source_context_ = nullptr; + _impl_.syntax_ = 0; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Type::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Type::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Type.name")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Type.name")); } else goto handle_unusual; continue; @@ -476,9 +489,9 @@ const char* Type::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inter do { ptr += 1; auto str = _internal_add_oneofs(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Type.oneofs")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Type.oneofs")); if (!ctx->DataAvailable(ptr)) break; } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); } else @@ -554,11 +567,11 @@ uint8_t* Type::_InternalSerialize( } // repeated .google.protobuf.Field fields = 2; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_fields_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_fields_size()); i < n; i++) { + const auto& repfield = this->_internal_fields(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, this->_internal_fields(i), target, stream); + InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream); } // repeated string oneofs = 3; @@ -572,30 +585,29 @@ uint8_t* Type::_InternalSerialize( } // repeated .google.protobuf.Option options = 4; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_options_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) { + const auto& repfield = this->_internal_options(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(4, this->_internal_options(i), target, stream); + InternalWriteMessage(4, repfield, repfield.GetCachedSize(), target, stream); } // .google.protobuf.SourceContext source_context = 5; if (this->_internal_has_source_context()) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 5, _Internal::source_context(this), target, stream); + InternalWriteMessage(5, _Internal::source_context(this), + _Internal::source_context(this).GetCachedSize(), target, stream); } // .google.protobuf.Syntax syntax = 6; if (this->_internal_syntax() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 6, this->_internal_syntax(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Type) @@ -612,22 +624,22 @@ size_t Type::ByteSizeLong() const { // repeated .google.protobuf.Field fields = 2; total_size += 1UL * this->_internal_fields_size(); - for (const auto& msg : this->fields_) { + for (const auto& msg : this->_impl_.fields_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated string oneofs = 3; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(oneofs_.size()); - for (int i = 0, n = oneofs_.size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(_impl_.oneofs_.size()); + for (int i = 0, n = _impl_.oneofs_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - oneofs_.Get(i)); + _impl_.oneofs_.Get(i)); } // repeated .google.protobuf.Option options = 4; total_size += 1UL * this->_internal_options_size(); - for (const auto& msg : this->options_) { + for (const auto& msg : this->_impl_.options_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } @@ -643,50 +655,47 @@ size_t Type::ByteSizeLong() const { if (this->_internal_has_source_context()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *source_context_); + *_impl_.source_context_); } // .google.protobuf.Syntax syntax = 6; if (this->_internal_syntax() != 0) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_syntax()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Type::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Type::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Type::GetClassData() const { return &_class_data_; } -void Type::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Type *>(to)->MergeFrom( - static_cast<const Type &>(from)); -} - -void Type::MergeFrom(const Type& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Type) - GOOGLE_DCHECK_NE(&from, this); +void Type::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Type*>(&to_msg); + auto& from = static_cast<const Type&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Type) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - fields_.MergeFrom(from.fields_); - oneofs_.MergeFrom(from.oneofs_); - options_.MergeFrom(from.options_); + _this->_impl_.fields_.MergeFrom(from._impl_.fields_); + _this->_impl_.oneofs_.MergeFrom(from._impl_.oneofs_); + _this->_impl_.options_.MergeFrom(from._impl_.options_); if (!from._internal_name().empty()) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (from._internal_has_source_context()) { - _internal_mutable_source_context()->::PROTOBUF_NAMESPACE_ID::SourceContext::MergeFrom(from._internal_source_context()); + _this->_internal_mutable_source_context()->::PROTOBUF_NAMESPACE_ID::SourceContext::MergeFrom( + from._internal_source_context()); } if (from._internal_syntax() != 0) { - _internal_set_syntax(from._internal_syntax()); + _this->_internal_set_syntax(from._internal_syntax()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Type::CopyFrom(const Type& from) { @@ -705,24 +714,23 @@ void Type::InternalSwap(Type* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - fields_.InternalSwap(&other->fields_); - oneofs_.InternalSwap(&other->oneofs_); - options_.InternalSwap(&other->options_); + _impl_.fields_.InternalSwap(&other->_impl_.fields_); + _impl_.oneofs_.InternalSwap(&other->_impl_.oneofs_); + _impl_.options_.InternalSwap(&other->_impl_.options_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Type, syntax_) - + sizeof(Type::syntax_) - - PROTOBUF_FIELD_OFFSET(Type, source_context_)>( - reinterpret_cast<char*>(&source_context_), - reinterpret_cast<char*>(&other->source_context_)); + PROTOBUF_FIELD_OFFSET(Type, _impl_.syntax_) + + sizeof(Type::_impl_.syntax_) + - PROTOBUF_FIELD_OFFSET(Type, _impl_.source_context_)>( + reinterpret_cast<char*>(&_impl_.source_context_), + reinterpret_cast<char*>(&other->_impl_.source_context_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Type::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, file_level_metadata_google_2fprotobuf_2ftype_2eproto[0]); } @@ -735,102 +743,120 @@ class Field::_Internal { Field::Field(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - options_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Field) } Field::Field(const Field& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - options_(from.options_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + Field* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.options_){from._impl_.options_} + , decltype(_impl_.name_){} + , decltype(_impl_.type_url_){} + , decltype(_impl_.json_name_){} + , decltype(_impl_.default_value_){} + , decltype(_impl_.kind_){} + , decltype(_impl_.cardinality_){} + , decltype(_impl_.number_){} + , decltype(_impl_.oneof_index_){} + , decltype(_impl_.packed_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_name().empty()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } - type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.type_url_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.type_url_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_type_url().empty()) { - type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type_url(), - GetArenaForAllocation()); + _this->_impl_.type_url_.Set(from._internal_type_url(), + _this->GetArenaForAllocation()); } - json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.json_name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.json_name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_json_name().empty()) { - json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_json_name(), - GetArenaForAllocation()); + _this->_impl_.json_name_.Set(from._internal_json_name(), + _this->GetArenaForAllocation()); } - default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.default_value_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.default_value_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_default_value().empty()) { - default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_default_value(), - GetArenaForAllocation()); + _this->_impl_.default_value_.Set(from._internal_default_value(), + _this->GetArenaForAllocation()); } - ::memcpy(&kind_, &from.kind_, - static_cast<size_t>(reinterpret_cast<char*>(&packed_) - - reinterpret_cast<char*>(&kind_)) + sizeof(packed_)); + ::memcpy(&_impl_.kind_, &from._impl_.kind_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.packed_) - + reinterpret_cast<char*>(&_impl_.kind_)) + sizeof(_impl_.packed_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Field) } -inline void Field::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&kind_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&packed_) - - reinterpret_cast<char*>(&kind_)) + sizeof(packed_)); +inline void Field::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.options_){arena} + , decltype(_impl_.name_){} + , decltype(_impl_.type_url_){} + , decltype(_impl_.json_name_){} + , decltype(_impl_.default_value_){} + , decltype(_impl_.kind_){0} + , decltype(_impl_.cardinality_){0} + , decltype(_impl_.number_){0} + , decltype(_impl_.oneof_index_){0} + , decltype(_impl_.packed_){false} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.type_url_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.type_url_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.json_name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.json_name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.default_value_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.default_value_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } Field::~Field() { // @@protoc_insertion_point(destructor:google.protobuf.Field) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Field::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - type_url_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - json_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - default_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.options_.~RepeatedPtrField(); + _impl_.name_.Destroy(); + _impl_.type_url_.Destroy(); + _impl_.json_name_.Destroy(); + _impl_.default_value_.Destroy(); } -void Field::ArenaDtor(void* object) { - Field* _this = reinterpret_cast< Field* >(object); - (void)_this; -} -void Field::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Field::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Field::Clear() { @@ -839,22 +865,22 @@ void Field::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - options_.Clear(); - name_.ClearToEmpty(); - type_url_.ClearToEmpty(); - json_name_.ClearToEmpty(); - default_value_.ClearToEmpty(); - ::memset(&kind_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&packed_) - - reinterpret_cast<char*>(&kind_)) + sizeof(packed_)); + _impl_.options_.Clear(); + _impl_.name_.ClearToEmpty(); + _impl_.type_url_.ClearToEmpty(); + _impl_.json_name_.ClearToEmpty(); + _impl_.default_value_.ClearToEmpty(); + ::memset(&_impl_.kind_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.packed_) - + reinterpret_cast<char*>(&_impl_.kind_)) + sizeof(_impl_.packed_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Field::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // .google.protobuf.Field.Kind kind = 1; case 1: @@ -877,7 +903,7 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte // int32 number = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) { - number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -886,9 +912,9 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Field.name")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Field.name")); } else goto handle_unusual; continue; @@ -896,16 +922,16 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte case 6: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) { auto str = _internal_mutable_type_url(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Field.type_url")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Field.type_url")); } else goto handle_unusual; continue; // int32 oneof_index = 7; case 7: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 56)) { - oneof_index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.oneof_index_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -913,7 +939,7 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte // bool packed = 8; case 8: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 64)) { - packed_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.packed_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -935,9 +961,9 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte case 10: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 82)) { auto str = _internal_mutable_json_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Field.json_name")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Field.json_name")); } else goto handle_unusual; continue; @@ -945,9 +971,9 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte case 11: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 90)) { auto str = _internal_mutable_default_value(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Field.default_value")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Field.default_value")); } else goto handle_unusual; continue; @@ -983,21 +1009,21 @@ uint8_t* Field::_InternalSerialize( // .google.protobuf.Field.Kind kind = 1; if (this->_internal_kind() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 1, this->_internal_kind(), target); } // .google.protobuf.Field.Cardinality cardinality = 2; if (this->_internal_cardinality() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 2, this->_internal_cardinality(), target); } // int32 number = 3; if (this->_internal_number() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_number(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_number(), target); } // string name = 4; @@ -1023,21 +1049,21 @@ uint8_t* Field::_InternalSerialize( // int32 oneof_index = 7; if (this->_internal_oneof_index() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(7, this->_internal_oneof_index(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(7, this->_internal_oneof_index(), target); } // bool packed = 8; if (this->_internal_packed() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(8, this->_internal_packed(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(8, this->_internal_packed(), target); } // repeated .google.protobuf.Option options = 9; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_options_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) { + const auto& repfield = this->_internal_options(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(9, this->_internal_options(i), target, stream); + InternalWriteMessage(9, repfield, repfield.GetCachedSize(), target, stream); } // string json_name = 10; @@ -1061,7 +1087,7 @@ uint8_t* Field::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Field) @@ -1078,7 +1104,7 @@ size_t Field::ByteSizeLong() const { // repeated .google.protobuf.Option options = 9; total_size += 1UL * this->_internal_options_size(); - for (const auto& msg : this->options_) { + for (const auto& msg : this->_impl_.options_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } @@ -1114,23 +1140,23 @@ size_t Field::ByteSizeLong() const { // .google.protobuf.Field.Kind kind = 1; if (this->_internal_kind() != 0) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_kind()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_kind()); } // .google.protobuf.Field.Cardinality cardinality = 2; if (this->_internal_cardinality() != 0) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_cardinality()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_cardinality()); } // int32 number = 3; if (this->_internal_number() != 0) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_number()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_number()); } // int32 oneof_index = 7; if (this->_internal_oneof_index() != 0) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_oneof_index()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_oneof_index()); } // bool packed = 8; @@ -1138,57 +1164,53 @@ size_t Field::ByteSizeLong() const { total_size += 1 + 1; } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Field::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Field::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Field::GetClassData() const { return &_class_data_; } -void Field::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Field *>(to)->MergeFrom( - static_cast<const Field &>(from)); -} - -void Field::MergeFrom(const Field& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Field) - GOOGLE_DCHECK_NE(&from, this); +void Field::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Field*>(&to_msg); + auto& from = static_cast<const Field&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Field) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - options_.MergeFrom(from.options_); + _this->_impl_.options_.MergeFrom(from._impl_.options_); if (!from._internal_name().empty()) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (!from._internal_type_url().empty()) { - _internal_set_type_url(from._internal_type_url()); + _this->_internal_set_type_url(from._internal_type_url()); } if (!from._internal_json_name().empty()) { - _internal_set_json_name(from._internal_json_name()); + _this->_internal_set_json_name(from._internal_json_name()); } if (!from._internal_default_value().empty()) { - _internal_set_default_value(from._internal_default_value()); + _this->_internal_set_default_value(from._internal_default_value()); } if (from._internal_kind() != 0) { - _internal_set_kind(from._internal_kind()); + _this->_internal_set_kind(from._internal_kind()); } if (from._internal_cardinality() != 0) { - _internal_set_cardinality(from._internal_cardinality()); + _this->_internal_set_cardinality(from._internal_cardinality()); } if (from._internal_number() != 0) { - _internal_set_number(from._internal_number()); + _this->_internal_set_number(from._internal_number()); } if (from._internal_oneof_index() != 0) { - _internal_set_oneof_index(from._internal_oneof_index()); + _this->_internal_set_oneof_index(from._internal_oneof_index()); } if (from._internal_packed() != 0) { - _internal_set_packed(from._internal_packed()); + _this->_internal_set_packed(from._internal_packed()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Field::CopyFrom(const Field& from) { @@ -1207,37 +1229,33 @@ void Field::InternalSwap(Field* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - options_.InternalSwap(&other->options_); + _impl_.options_.InternalSwap(&other->_impl_.options_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &type_url_, lhs_arena, - &other->type_url_, rhs_arena + &_impl_.type_url_, lhs_arena, + &other->_impl_.type_url_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &json_name_, lhs_arena, - &other->json_name_, rhs_arena + &_impl_.json_name_, lhs_arena, + &other->_impl_.json_name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &default_value_, lhs_arena, - &other->default_value_, rhs_arena + &_impl_.default_value_, lhs_arena, + &other->_impl_.default_value_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Field, packed_) - + sizeof(Field::packed_) - - PROTOBUF_FIELD_OFFSET(Field, kind_)>( - reinterpret_cast<char*>(&kind_), - reinterpret_cast<char*>(&other->kind_)); + PROTOBUF_FIELD_OFFSET(Field, _impl_.packed_) + + sizeof(Field::_impl_.packed_) + - PROTOBUF_FIELD_OFFSET(Field, _impl_.kind_)>( + reinterpret_cast<char*>(&_impl_.kind_), + reinterpret_cast<char*>(&other->_impl_.kind_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Field::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, file_level_metadata_google_2fprotobuf_2ftype_2eproto[1]); } @@ -1251,79 +1269,84 @@ class Enum::_Internal { const ::PROTOBUF_NAMESPACE_ID::SourceContext& Enum::_Internal::source_context(const Enum* msg) { - return *msg->source_context_; + return *msg->_impl_.source_context_; } void Enum::clear_source_context() { - if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) { - delete source_context_; + if (GetArenaForAllocation() == nullptr && _impl_.source_context_ != nullptr) { + delete _impl_.source_context_; } - source_context_ = nullptr; + _impl_.source_context_ = nullptr; } Enum::Enum(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - enumvalue_(arena), - options_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Enum) } Enum::Enum(const Enum& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - enumvalue_(from.enumvalue_), - options_(from.options_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + Enum* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.enumvalue_){from._impl_.enumvalue_} + , decltype(_impl_.options_){from._impl_.options_} + , decltype(_impl_.name_){} + , decltype(_impl_.source_context_){nullptr} + , decltype(_impl_.syntax_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_name().empty()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } if (from._internal_has_source_context()) { - source_context_ = new ::PROTOBUF_NAMESPACE_ID::SourceContext(*from.source_context_); - } else { - source_context_ = nullptr; + _this->_impl_.source_context_ = new ::PROTOBUF_NAMESPACE_ID::SourceContext(*from._impl_.source_context_); } - syntax_ = from.syntax_; + _this->_impl_.syntax_ = from._impl_.syntax_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Enum) } -inline void Enum::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( - reinterpret_cast<char*>(&source_context_) - reinterpret_cast<char*>(this)), - 0, static_cast<size_t>(reinterpret_cast<char*>(&syntax_) - - reinterpret_cast<char*>(&source_context_)) + sizeof(syntax_)); +inline void Enum::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.enumvalue_){arena} + , decltype(_impl_.options_){arena} + , decltype(_impl_.name_){} + , decltype(_impl_.source_context_){nullptr} + , decltype(_impl_.syntax_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } Enum::~Enum() { // @@protoc_insertion_point(destructor:google.protobuf.Enum) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Enum::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete source_context_; + _impl_.enumvalue_.~RepeatedPtrField(); + _impl_.options_.~RepeatedPtrField(); + _impl_.name_.Destroy(); + if (this != internal_default_instance()) delete _impl_.source_context_; } -void Enum::ArenaDtor(void* object) { - Enum* _this = reinterpret_cast< Enum* >(object); - (void)_this; -} -void Enum::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Enum::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Enum::Clear() { @@ -1332,30 +1355,30 @@ void Enum::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - enumvalue_.Clear(); - options_.Clear(); - name_.ClearToEmpty(); - if (GetArenaForAllocation() == nullptr && source_context_ != nullptr) { - delete source_context_; + _impl_.enumvalue_.Clear(); + _impl_.options_.Clear(); + _impl_.name_.ClearToEmpty(); + if (GetArenaForAllocation() == nullptr && _impl_.source_context_ != nullptr) { + delete _impl_.source_context_; } - source_context_ = nullptr; - syntax_ = 0; + _impl_.source_context_ = nullptr; + _impl_.syntax_ = 0; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Enum::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Enum::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Enum.name")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Enum.name")); } else goto handle_unusual; continue; @@ -1442,38 +1465,37 @@ uint8_t* Enum::_InternalSerialize( } // repeated .google.protobuf.EnumValue enumvalue = 2; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_enumvalue_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_enumvalue_size()); i < n; i++) { + const auto& repfield = this->_internal_enumvalue(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, this->_internal_enumvalue(i), target, stream); + InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream); } // repeated .google.protobuf.Option options = 3; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_options_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) { + const auto& repfield = this->_internal_options(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, this->_internal_options(i), target, stream); + InternalWriteMessage(3, repfield, repfield.GetCachedSize(), target, stream); } // .google.protobuf.SourceContext source_context = 4; if (this->_internal_has_source_context()) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 4, _Internal::source_context(this), target, stream); + InternalWriteMessage(4, _Internal::source_context(this), + _Internal::source_context(this).GetCachedSize(), target, stream); } // .google.protobuf.Syntax syntax = 5; if (this->_internal_syntax() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + target = ::_pbi::WireFormatLite::WriteEnumToArray( 5, this->_internal_syntax(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Enum) @@ -1490,14 +1512,14 @@ size_t Enum::ByteSizeLong() const { // repeated .google.protobuf.EnumValue enumvalue = 2; total_size += 1UL * this->_internal_enumvalue_size(); - for (const auto& msg : this->enumvalue_) { + for (const auto& msg : this->_impl_.enumvalue_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.Option options = 3; total_size += 1UL * this->_internal_options_size(); - for (const auto& msg : this->options_) { + for (const auto& msg : this->_impl_.options_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } @@ -1513,49 +1535,46 @@ size_t Enum::ByteSizeLong() const { if (this->_internal_has_source_context()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *source_context_); + *_impl_.source_context_); } // .google.protobuf.Syntax syntax = 5; if (this->_internal_syntax() != 0) { total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_syntax()); + ::_pbi::WireFormatLite::EnumSize(this->_internal_syntax()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Enum::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Enum::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Enum::GetClassData() const { return &_class_data_; } -void Enum::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Enum *>(to)->MergeFrom( - static_cast<const Enum &>(from)); -} - -void Enum::MergeFrom(const Enum& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Enum) - GOOGLE_DCHECK_NE(&from, this); +void Enum::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Enum*>(&to_msg); + auto& from = static_cast<const Enum&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Enum) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - enumvalue_.MergeFrom(from.enumvalue_); - options_.MergeFrom(from.options_); + _this->_impl_.enumvalue_.MergeFrom(from._impl_.enumvalue_); + _this->_impl_.options_.MergeFrom(from._impl_.options_); if (!from._internal_name().empty()) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (from._internal_has_source_context()) { - _internal_mutable_source_context()->::PROTOBUF_NAMESPACE_ID::SourceContext::MergeFrom(from._internal_source_context()); + _this->_internal_mutable_source_context()->::PROTOBUF_NAMESPACE_ID::SourceContext::MergeFrom( + from._internal_source_context()); } if (from._internal_syntax() != 0) { - _internal_set_syntax(from._internal_syntax()); + _this->_internal_set_syntax(from._internal_syntax()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Enum::CopyFrom(const Enum& from) { @@ -1574,23 +1593,22 @@ void Enum::InternalSwap(Enum* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - enumvalue_.InternalSwap(&other->enumvalue_); - options_.InternalSwap(&other->options_); + _impl_.enumvalue_.InternalSwap(&other->_impl_.enumvalue_); + _impl_.options_.InternalSwap(&other->_impl_.options_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Enum, syntax_) - + sizeof(Enum::syntax_) - - PROTOBUF_FIELD_OFFSET(Enum, source_context_)>( - reinterpret_cast<char*>(&source_context_), - reinterpret_cast<char*>(&other->source_context_)); + PROTOBUF_FIELD_OFFSET(Enum, _impl_.syntax_) + + sizeof(Enum::_impl_.syntax_) + - PROTOBUF_FIELD_OFFSET(Enum, _impl_.source_context_)>( + reinterpret_cast<char*>(&_impl_.source_context_), + reinterpret_cast<char*>(&other->_impl_.source_context_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Enum::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, file_level_metadata_google_2fprotobuf_2ftype_2eproto[2]); } @@ -1603,58 +1621,65 @@ class EnumValue::_Internal { EnumValue::EnumValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) - : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), - options_(arena) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValue) } EnumValue::EnumValue(const EnumValue& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - options_(from.options_) { + : ::PROTOBUF_NAMESPACE_ID::Message() { + EnumValue* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.options_){from._impl_.options_} + , decltype(_impl_.name_){} + , decltype(_impl_.number_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_name().empty()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } - number_ = from.number_; + _this->_impl_.number_ = from._impl_.number_; // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValue) } -inline void EnumValue::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -number_ = 0; +inline void EnumValue::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.options_){arena} + , decltype(_impl_.name_){} + , decltype(_impl_.number_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } EnumValue::~EnumValue() { // @@protoc_insertion_point(destructor:google.protobuf.EnumValue) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void EnumValue::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.options_.~RepeatedPtrField(); + _impl_.name_.Destroy(); } -void EnumValue::ArenaDtor(void* object) { - EnumValue* _this = reinterpret_cast< EnumValue* >(object); - (void)_this; -} -void EnumValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void EnumValue::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void EnumValue::Clear() { @@ -1663,32 +1688,32 @@ void EnumValue::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - options_.Clear(); - name_.ClearToEmpty(); - number_ = 0; + _impl_.options_.Clear(); + _impl_.name_.ClearToEmpty(); + _impl_.number_ = 0; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* EnumValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* EnumValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.EnumValue.name")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.EnumValue.name")); } else goto handle_unusual; continue; // int32 number = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) { - number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -1748,19 +1773,19 @@ uint8_t* EnumValue::_InternalSerialize( // int32 number = 2; if (this->_internal_number() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_number(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_number(), target); } // repeated .google.protobuf.Option options = 3; - for (unsigned int i = 0, - n = static_cast<unsigned int>(this->_internal_options_size()); i < n; i++) { - target = stream->EnsureSpace(target); + for (unsigned i = 0, + n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) { + const auto& repfield = this->_internal_options(i); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, this->_internal_options(i), target, stream); + InternalWriteMessage(3, repfield, repfield.GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValue) @@ -1777,7 +1802,7 @@ size_t EnumValue::ByteSizeLong() const { // repeated .google.protobuf.Option options = 3; total_size += 1UL * this->_internal_options_size(); - for (const auto& msg : this->options_) { + for (const auto& msg : this->_impl_.options_) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } @@ -1791,39 +1816,35 @@ size_t EnumValue::ByteSizeLong() const { // int32 number = 2; if (this->_internal_number() != 0) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_number()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_number()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData EnumValue::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, EnumValue::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*EnumValue::GetClassData() const { return &_class_data_; } -void EnumValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<EnumValue *>(to)->MergeFrom( - static_cast<const EnumValue &>(from)); -} - -void EnumValue::MergeFrom(const EnumValue& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValue) - GOOGLE_DCHECK_NE(&from, this); +void EnumValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<EnumValue*>(&to_msg); + auto& from = static_cast<const EnumValue&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValue) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; - options_.MergeFrom(from.options_); + _this->_impl_.options_.MergeFrom(from._impl_.options_); if (!from._internal_name().empty()) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (from._internal_number() != 0) { - _internal_set_number(from._internal_number()); + _this->_internal_set_number(from._internal_number()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void EnumValue::CopyFrom(const EnumValue& from) { @@ -1842,17 +1863,16 @@ void EnumValue::InternalSwap(EnumValue* other) { auto* lhs_arena = GetArenaForAllocation(); auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); - options_.InternalSwap(&other->options_); + _impl_.options_.InternalSwap(&other->_impl_.options_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); - swap(number_, other->number_); + swap(_impl_.number_, other->_impl_.number_); } ::PROTOBUF_NAMESPACE_ID::Metadata EnumValue::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, file_level_metadata_google_2fprotobuf_2ftype_2eproto[3]); } @@ -1866,71 +1886,75 @@ class Option::_Internal { const ::PROTOBUF_NAMESPACE_ID::Any& Option::_Internal::value(const Option* msg) { - return *msg->value_; + return *msg->_impl_.value_; } void Option::clear_value() { - if (GetArenaForAllocation() == nullptr && value_ != nullptr) { - delete value_; + if (GetArenaForAllocation() == nullptr && _impl_.value_ != nullptr) { + delete _impl_.value_; } - value_ = nullptr; + _impl_.value_ = nullptr; } Option::Option(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Option) } Option::Option(const Option& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + Option* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.name_){} + , decltype(_impl_.value_){nullptr} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.name_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.name_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_name().empty()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArenaForAllocation()); + _this->_impl_.name_.Set(from._internal_name(), + _this->GetArenaForAllocation()); } if (from._internal_has_value()) { - value_ = new ::PROTOBUF_NAMESPACE_ID::Any(*from.value_); - } else { - value_ = nullptr; + _this->_impl_.value_ = new ::PROTOBUF_NAMESPACE_ID::Any(*from._impl_.value_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.Option) } -inline void Option::SharedCtor() { -name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING -value_ = nullptr; +inline void Option::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.name_){} + , decltype(_impl_.value_){nullptr} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.name_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.name_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } Option::~Option() { // @@protoc_insertion_point(destructor:google.protobuf.Option) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Option::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete value_; + _impl_.name_.Destroy(); + if (this != internal_default_instance()) delete _impl_.value_; } -void Option::ArenaDtor(void* object) { - Option* _this = reinterpret_cast< Option* >(object); - (void)_this; -} -void Option::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Option::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Option::Clear() { @@ -1939,27 +1963,27 @@ void Option::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - name_.ClearToEmpty(); - if (GetArenaForAllocation() == nullptr && value_ != nullptr) { - delete value_; + _impl_.name_.ClearToEmpty(); + if (GetArenaForAllocation() == nullptr && _impl_.value_ != nullptr) { + delete _impl_.value_; } - value_ = nullptr; + _impl_.value_ = nullptr; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Option::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Option::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.Option.name")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Option.name")); } else goto handle_unusual; continue; @@ -2012,14 +2036,13 @@ uint8_t* Option::_InternalSerialize( // .google.protobuf.Any value = 2; if (this->_internal_has_value()) { - target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 2, _Internal::value(this), target, stream); + InternalWriteMessage(2, _Internal::value(this), + _Internal::value(this).GetCachedSize(), target, stream); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Option) @@ -2045,38 +2068,35 @@ size_t Option::ByteSizeLong() const { if (this->_internal_has_value()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *value_); + *_impl_.value_); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Option::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Option::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Option::GetClassData() const { return &_class_data_; } -void Option::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Option *>(to)->MergeFrom( - static_cast<const Option &>(from)); -} - -void Option::MergeFrom(const Option& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Option) - GOOGLE_DCHECK_NE(&from, this); +void Option::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Option*>(&to_msg); + auto& from = static_cast<const Option&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Option) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (!from._internal_name().empty()) { - _internal_set_name(from._internal_name()); + _this->_internal_set_name(from._internal_name()); } if (from._internal_has_value()) { - _internal_mutable_value()->::PROTOBUF_NAMESPACE_ID::Any::MergeFrom(from._internal_value()); + _this->_internal_mutable_value()->::PROTOBUF_NAMESPACE_ID::Any::MergeFrom( + from._internal_value()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Option::CopyFrom(const Option& from) { @@ -2096,15 +2116,14 @@ void Option::InternalSwap(Option* other) { auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &name_, lhs_arena, - &other->name_, rhs_arena + &_impl_.name_, lhs_arena, + &other->_impl_.name_, rhs_arena ); - swap(value_, other->value_); + swap(_impl_.value_, other->_impl_.value_); } ::PROTOBUF_NAMESPACE_ID::Metadata Option::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2ftype_2eproto_getter, &descriptor_table_google_2fprotobuf_2ftype_2eproto_once, file_level_metadata_google_2fprotobuf_2ftype_2eproto[4]); } @@ -2112,19 +2131,24 @@ void Option::InternalSwap(Option* other) { // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Type* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Type >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Type* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Type >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Type >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Field* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Field >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Field* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Field >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Field >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Enum* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Enum >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Enum* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Enum >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Enum >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumValue >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::EnumValue* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::EnumValue >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::EnumValue >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Option* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Option >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Option* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Option >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Option >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/thirdparty/protobuf/type.pb.h b/r5dev/thirdparty/protobuf/type.pb.h index 8b5a82c6..f4187381 100644 --- a/r5dev/thirdparty/protobuf/type.pb.h +++ b/r5dev/thirdparty/protobuf/type.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/generated_message_reflection.h> @@ -45,14 +44,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2ftype_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[5] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2ftype_2eproto; @@ -183,7 +174,7 @@ class PROTOBUF_EXPORT Type final : public: inline Type() : Type(nullptr) {} ~Type() override; - explicit constexpr Type(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Type(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Type(const Type& from); Type(Type&& from) noexcept @@ -258,9 +249,11 @@ class PROTOBUF_EXPORT Type final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Type& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Type& from); + void MergeFrom( const Type& from) { + Type::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -269,10 +262,10 @@ class PROTOBUF_EXPORT Type final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Type* other); @@ -285,9 +278,6 @@ class PROTOBUF_EXPORT Type final : protected: explicit Type(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -415,13 +405,16 @@ class PROTOBUF_EXPORT Type final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Field > fields_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> oneofs_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::SourceContext* source_context_; - int syntax_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Field > fields_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> oneofs_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::SourceContext* source_context_; + int syntax_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2ftype_2eproto; }; // ------------------------------------------------------------------- @@ -431,7 +424,7 @@ class PROTOBUF_EXPORT Field final : public: inline Field() : Field(nullptr) {} ~Field() override; - explicit constexpr Field(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Field(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Field(const Field& from); Field(Field&& from) noexcept @@ -506,9 +499,11 @@ class PROTOBUF_EXPORT Field final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Field& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Field& from); + void MergeFrom( const Field& from) { + Field::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -517,10 +512,10 @@ class PROTOBUF_EXPORT Field final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Field* other); @@ -533,9 +528,6 @@ class PROTOBUF_EXPORT Field final : protected: explicit Field(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -783,17 +775,20 @@ class PROTOBUF_EXPORT Field final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_url_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr json_name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr default_value_; - int kind_; - int cardinality_; - int32_t number_; - int32_t oneof_index_; - bool packed_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_url_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr json_name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr default_value_; + int kind_; + int cardinality_; + int32_t number_; + int32_t oneof_index_; + bool packed_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2ftype_2eproto; }; // ------------------------------------------------------------------- @@ -803,7 +798,7 @@ class PROTOBUF_EXPORT Enum final : public: inline Enum() : Enum(nullptr) {} ~Enum() override; - explicit constexpr Enum(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Enum(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Enum(const Enum& from); Enum(Enum&& from) noexcept @@ -878,9 +873,11 @@ class PROTOBUF_EXPORT Enum final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Enum& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Enum& from); + void MergeFrom( const Enum& from) { + Enum::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -889,10 +886,10 @@ class PROTOBUF_EXPORT Enum final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Enum* other); @@ -905,9 +902,6 @@ class PROTOBUF_EXPORT Enum final : protected: explicit Enum(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -1010,12 +1004,15 @@ class PROTOBUF_EXPORT Enum final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumValue > enumvalue_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::SourceContext* source_context_; - int syntax_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumValue > enumvalue_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::SourceContext* source_context_; + int syntax_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2ftype_2eproto; }; // ------------------------------------------------------------------- @@ -1025,7 +1022,7 @@ class PROTOBUF_EXPORT EnumValue final : public: inline EnumValue() : EnumValue(nullptr) {} ~EnumValue() override; - explicit constexpr EnumValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR EnumValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); EnumValue(const EnumValue& from); EnumValue(EnumValue&& from) noexcept @@ -1100,9 +1097,11 @@ class PROTOBUF_EXPORT EnumValue final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const EnumValue& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const EnumValue& from); + void MergeFrom( const EnumValue& from) { + EnumValue::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1111,10 +1110,10 @@ class PROTOBUF_EXPORT EnumValue final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(EnumValue* other); @@ -1127,9 +1126,6 @@ class PROTOBUF_EXPORT EnumValue final : protected: explicit EnumValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -1194,10 +1190,13 @@ class PROTOBUF_EXPORT EnumValue final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - int32_t number_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option > options_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + int32_t number_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2ftype_2eproto; }; // ------------------------------------------------------------------- @@ -1207,7 +1206,7 @@ class PROTOBUF_EXPORT Option final : public: inline Option() : Option(nullptr) {} ~Option() override; - explicit constexpr Option(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Option(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Option(const Option& from); Option(Option&& from) noexcept @@ -1282,9 +1281,11 @@ class PROTOBUF_EXPORT Option final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Option& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Option& from); + void MergeFrom( const Option& from) { + Option::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1293,10 +1294,10 @@ class PROTOBUF_EXPORT Option final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Option* other); @@ -1309,9 +1310,6 @@ class PROTOBUF_EXPORT Option final : protected: explicit Option(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -1366,9 +1364,12 @@ class PROTOBUF_EXPORT Option final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::Any* value_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::Any* value_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2ftype_2eproto; }; // =================================================================== @@ -1384,7 +1385,7 @@ class PROTOBUF_EXPORT Option final : // string name = 1; inline void Type::clear_name() { - name_.ClearToEmpty(); + _impl_.name_.ClearToEmpty(); } inline const std::string& Type::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.name) @@ -1394,7 +1395,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Type::set_name(ArgT0&& arg0, ArgT... args) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Type.name) } inline std::string* Type::mutable_name() { @@ -1403,19 +1404,19 @@ inline std::string* Type::mutable_name() { return _s; } inline const std::string& Type::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void Type::_internal_set_name(const std::string& value) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* Type::_internal_mutable_name() { - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* Type::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Type.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.name_.Release(); } inline void Type::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -1423,11 +1424,10 @@ inline void Type::set_allocated_name(std::string* name) { } else { } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name) @@ -1435,32 +1435,32 @@ inline void Type::set_allocated_name(std::string* name) { // repeated .google.protobuf.Field fields = 2; inline int Type::_internal_fields_size() const { - return fields_.size(); + return _impl_.fields_.size(); } inline int Type::fields_size() const { return _internal_fields_size(); } inline void Type::clear_fields() { - fields_.Clear(); + _impl_.fields_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::Field* Type::mutable_fields(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Type.fields) - return fields_.Mutable(index); + return _impl_.fields_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Field >* Type::mutable_fields() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.fields) - return &fields_; + return &_impl_.fields_; } inline const ::PROTOBUF_NAMESPACE_ID::Field& Type::_internal_fields(int index) const { - return fields_.Get(index); + return _impl_.fields_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::Field& Type::fields(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Type.fields) return _internal_fields(index); } inline ::PROTOBUF_NAMESPACE_ID::Field* Type::_internal_add_fields() { - return fields_.Add(); + return _impl_.fields_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::Field* Type::add_fields() { ::PROTOBUF_NAMESPACE_ID::Field* _add = _internal_add_fields(); @@ -1470,18 +1470,18 @@ inline ::PROTOBUF_NAMESPACE_ID::Field* Type::add_fields() { inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Field >& Type::fields() const { // @@protoc_insertion_point(field_list:google.protobuf.Type.fields) - return fields_; + return _impl_.fields_; } // repeated string oneofs = 3; inline int Type::_internal_oneofs_size() const { - return oneofs_.size(); + return _impl_.oneofs_.size(); } inline int Type::oneofs_size() const { return _internal_oneofs_size(); } inline void Type::clear_oneofs() { - oneofs_.Clear(); + _impl_.oneofs_.Clear(); } inline std::string* Type::add_oneofs() { std::string* _s = _internal_add_oneofs(); @@ -1489,7 +1489,7 @@ inline std::string* Type::add_oneofs() { return _s; } inline const std::string& Type::_internal_oneofs(int index) const { - return oneofs_.Get(index); + return _impl_.oneofs_.Get(index); } inline const std::string& Type::oneofs(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Type.oneofs) @@ -1497,85 +1497,85 @@ inline const std::string& Type::oneofs(int index) const { } inline std::string* Type::mutable_oneofs(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Type.oneofs) - return oneofs_.Mutable(index); + return _impl_.oneofs_.Mutable(index); } inline void Type::set_oneofs(int index, const std::string& value) { - oneofs_.Mutable(index)->assign(value); + _impl_.oneofs_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) } inline void Type::set_oneofs(int index, std::string&& value) { - oneofs_.Mutable(index)->assign(std::move(value)); + _impl_.oneofs_.Mutable(index)->assign(std::move(value)); // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs) } inline void Type::set_oneofs(int index, const char* value) { GOOGLE_DCHECK(value != nullptr); - oneofs_.Mutable(index)->assign(value); + _impl_.oneofs_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set_char:google.protobuf.Type.oneofs) } inline void Type::set_oneofs(int index, const char* value, size_t size) { - oneofs_.Mutable(index)->assign( + _impl_.oneofs_.Mutable(index)->assign( reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.oneofs) } inline std::string* Type::_internal_add_oneofs() { - return oneofs_.Add(); + return _impl_.oneofs_.Add(); } inline void Type::add_oneofs(const std::string& value) { - oneofs_.Add()->assign(value); + _impl_.oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) } inline void Type::add_oneofs(std::string&& value) { - oneofs_.Add(std::move(value)); + _impl_.oneofs_.Add(std::move(value)); // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs) } inline void Type::add_oneofs(const char* value) { GOOGLE_DCHECK(value != nullptr); - oneofs_.Add()->assign(value); + _impl_.oneofs_.Add()->assign(value); // @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs) } inline void Type::add_oneofs(const char* value, size_t size) { - oneofs_.Add()->assign(reinterpret_cast<const char*>(value), size); + _impl_.oneofs_.Add()->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_add_pointer:google.protobuf.Type.oneofs) } inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>& Type::oneofs() const { // @@protoc_insertion_point(field_list:google.protobuf.Type.oneofs) - return oneofs_; + return _impl_.oneofs_; } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>* Type::mutable_oneofs() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.oneofs) - return &oneofs_; + return &_impl_.oneofs_; } // repeated .google.protobuf.Option options = 4; inline int Type::_internal_options_size() const { - return options_.size(); + return _impl_.options_.size(); } inline int Type::options_size() const { return _internal_options_size(); } inline void Type::clear_options() { - options_.Clear(); + _impl_.options_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::Option* Type::mutable_options(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Type.options) - return options_.Mutable(index); + return _impl_.options_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >* Type::mutable_options() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.options) - return &options_; + return &_impl_.options_; } inline const ::PROTOBUF_NAMESPACE_ID::Option& Type::_internal_options(int index) const { - return options_.Get(index); + return _impl_.options_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::Option& Type::options(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Type.options) return _internal_options(index); } inline ::PROTOBUF_NAMESPACE_ID::Option* Type::_internal_add_options() { - return options_.Add(); + return _impl_.options_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::Option* Type::add_options() { ::PROTOBUF_NAMESPACE_ID::Option* _add = _internal_add_options(); @@ -1585,18 +1585,18 @@ inline ::PROTOBUF_NAMESPACE_ID::Option* Type::add_options() { inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >& Type::options() const { // @@protoc_insertion_point(field_list:google.protobuf.Type.options) - return options_; + return _impl_.options_; } // .google.protobuf.SourceContext source_context = 5; inline bool Type::_internal_has_source_context() const { - return this != internal_default_instance() && source_context_ != nullptr; + return this != internal_default_instance() && _impl_.source_context_ != nullptr; } inline bool Type::has_source_context() const { return _internal_has_source_context(); } inline const ::PROTOBUF_NAMESPACE_ID::SourceContext& Type::_internal_source_context() const { - const ::PROTOBUF_NAMESPACE_ID::SourceContext* p = source_context_; + const ::PROTOBUF_NAMESPACE_ID::SourceContext* p = _impl_.source_context_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::SourceContext&>( ::PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_); } @@ -1607,9 +1607,9 @@ inline const ::PROTOBUF_NAMESPACE_ID::SourceContext& Type::source_context() cons inline void Type::unsafe_arena_set_allocated_source_context( ::PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.source_context_); } - source_context_ = source_context; + _impl_.source_context_ = source_context; if (source_context) { } else { @@ -1619,8 +1619,8 @@ inline void Type::unsafe_arena_set_allocated_source_context( } inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Type::release_source_context() { - ::PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; - source_context_ = nullptr; + ::PROTOBUF_NAMESPACE_ID::SourceContext* temp = _impl_.source_context_; + _impl_.source_context_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -1635,17 +1635,17 @@ inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Type::release_source_context() { inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Type::unsafe_arena_release_source_context() { // @@protoc_insertion_point(field_release:google.protobuf.Type.source_context) - ::PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; - source_context_ = nullptr; + ::PROTOBUF_NAMESPACE_ID::SourceContext* temp = _impl_.source_context_; + _impl_.source_context_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Type::_internal_mutable_source_context() { - if (source_context_ == nullptr) { + if (_impl_.source_context_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceContext>(GetArenaForAllocation()); - source_context_ = p; + _impl_.source_context_ = p; } - return source_context_; + return _impl_.source_context_; } inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Type::mutable_source_context() { ::PROTOBUF_NAMESPACE_ID::SourceContext* _msg = _internal_mutable_source_context(); @@ -1655,12 +1655,11 @@ inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Type::mutable_source_context() { inline void Type::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.source_context_); } if (source_context) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper< - ::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena( + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)); if (message_arena != submessage_arena) { source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( @@ -1670,16 +1669,16 @@ inline void Type::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCo } else { } - source_context_ = source_context; + _impl_.source_context_ = source_context; // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context) } // .google.protobuf.Syntax syntax = 6; inline void Type::clear_syntax() { - syntax_ = 0; + _impl_.syntax_ = 0; } inline ::PROTOBUF_NAMESPACE_ID::Syntax Type::_internal_syntax() const { - return static_cast< ::PROTOBUF_NAMESPACE_ID::Syntax >(syntax_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::Syntax >(_impl_.syntax_); } inline ::PROTOBUF_NAMESPACE_ID::Syntax Type::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.syntax) @@ -1687,7 +1686,7 @@ inline ::PROTOBUF_NAMESPACE_ID::Syntax Type::syntax() const { } inline void Type::_internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) { - syntax_ = value; + _impl_.syntax_ = value; } inline void Type::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) { _internal_set_syntax(value); @@ -1700,10 +1699,10 @@ inline void Type::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) { // .google.protobuf.Field.Kind kind = 1; inline void Field::clear_kind() { - kind_ = 0; + _impl_.kind_ = 0; } inline ::PROTOBUF_NAMESPACE_ID::Field_Kind Field::_internal_kind() const { - return static_cast< ::PROTOBUF_NAMESPACE_ID::Field_Kind >(kind_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::Field_Kind >(_impl_.kind_); } inline ::PROTOBUF_NAMESPACE_ID::Field_Kind Field::kind() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.kind) @@ -1711,7 +1710,7 @@ inline ::PROTOBUF_NAMESPACE_ID::Field_Kind Field::kind() const { } inline void Field::_internal_set_kind(::PROTOBUF_NAMESPACE_ID::Field_Kind value) { - kind_ = value; + _impl_.kind_ = value; } inline void Field::set_kind(::PROTOBUF_NAMESPACE_ID::Field_Kind value) { _internal_set_kind(value); @@ -1720,10 +1719,10 @@ inline void Field::set_kind(::PROTOBUF_NAMESPACE_ID::Field_Kind value) { // .google.protobuf.Field.Cardinality cardinality = 2; inline void Field::clear_cardinality() { - cardinality_ = 0; + _impl_.cardinality_ = 0; } inline ::PROTOBUF_NAMESPACE_ID::Field_Cardinality Field::_internal_cardinality() const { - return static_cast< ::PROTOBUF_NAMESPACE_ID::Field_Cardinality >(cardinality_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::Field_Cardinality >(_impl_.cardinality_); } inline ::PROTOBUF_NAMESPACE_ID::Field_Cardinality Field::cardinality() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.cardinality) @@ -1731,7 +1730,7 @@ inline ::PROTOBUF_NAMESPACE_ID::Field_Cardinality Field::cardinality() const { } inline void Field::_internal_set_cardinality(::PROTOBUF_NAMESPACE_ID::Field_Cardinality value) { - cardinality_ = value; + _impl_.cardinality_ = value; } inline void Field::set_cardinality(::PROTOBUF_NAMESPACE_ID::Field_Cardinality value) { _internal_set_cardinality(value); @@ -1740,10 +1739,10 @@ inline void Field::set_cardinality(::PROTOBUF_NAMESPACE_ID::Field_Cardinality va // int32 number = 3; inline void Field::clear_number() { - number_ = 0; + _impl_.number_ = 0; } inline int32_t Field::_internal_number() const { - return number_; + return _impl_.number_; } inline int32_t Field::number() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.number) @@ -1751,7 +1750,7 @@ inline int32_t Field::number() const { } inline void Field::_internal_set_number(int32_t value) { - number_ = value; + _impl_.number_ = value; } inline void Field::set_number(int32_t value) { _internal_set_number(value); @@ -1760,7 +1759,7 @@ inline void Field::set_number(int32_t value) { // string name = 4; inline void Field::clear_name() { - name_.ClearToEmpty(); + _impl_.name_.ClearToEmpty(); } inline const std::string& Field::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.name) @@ -1770,7 +1769,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Field::set_name(ArgT0&& arg0, ArgT... args) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Field.name) } inline std::string* Field::mutable_name() { @@ -1779,19 +1778,19 @@ inline std::string* Field::mutable_name() { return _s; } inline const std::string& Field::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void Field::_internal_set_name(const std::string& value) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* Field::_internal_mutable_name() { - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* Field::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Field.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.name_.Release(); } inline void Field::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -1799,11 +1798,10 @@ inline void Field::set_allocated_name(std::string* name) { } else { } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name) @@ -1811,7 +1809,7 @@ inline void Field::set_allocated_name(std::string* name) { // string type_url = 6; inline void Field::clear_type_url() { - type_url_.ClearToEmpty(); + _impl_.type_url_.ClearToEmpty(); } inline const std::string& Field::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url) @@ -1821,7 +1819,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Field::set_type_url(ArgT0&& arg0, ArgT... args) { - type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Field.type_url) } inline std::string* Field::mutable_type_url() { @@ -1830,19 +1828,19 @@ inline std::string* Field::mutable_type_url() { return _s; } inline const std::string& Field::_internal_type_url() const { - return type_url_.Get(); + return _impl_.type_url_.Get(); } inline void Field::_internal_set_type_url(const std::string& value) { - type_url_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.type_url_.Set(value, GetArenaForAllocation()); } inline std::string* Field::_internal_mutable_type_url() { - return type_url_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.type_url_.Mutable(GetArenaForAllocation()); } inline std::string* Field::release_type_url() { // @@protoc_insertion_point(field_release:google.protobuf.Field.type_url) - return type_url_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.type_url_.Release(); } inline void Field::set_allocated_type_url(std::string* type_url) { if (type_url != nullptr) { @@ -1850,11 +1848,10 @@ inline void Field::set_allocated_type_url(std::string* type_url) { } else { } - type_url_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type_url, - GetArenaForAllocation()); + _impl_.type_url_.SetAllocated(type_url, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (type_url_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.type_url_.IsDefault()) { + _impl_.type_url_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url) @@ -1862,10 +1859,10 @@ inline void Field::set_allocated_type_url(std::string* type_url) { // int32 oneof_index = 7; inline void Field::clear_oneof_index() { - oneof_index_ = 0; + _impl_.oneof_index_ = 0; } inline int32_t Field::_internal_oneof_index() const { - return oneof_index_; + return _impl_.oneof_index_; } inline int32_t Field::oneof_index() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.oneof_index) @@ -1873,7 +1870,7 @@ inline int32_t Field::oneof_index() const { } inline void Field::_internal_set_oneof_index(int32_t value) { - oneof_index_ = value; + _impl_.oneof_index_ = value; } inline void Field::set_oneof_index(int32_t value) { _internal_set_oneof_index(value); @@ -1882,10 +1879,10 @@ inline void Field::set_oneof_index(int32_t value) { // bool packed = 8; inline void Field::clear_packed() { - packed_ = false; + _impl_.packed_ = false; } inline bool Field::_internal_packed() const { - return packed_; + return _impl_.packed_; } inline bool Field::packed() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.packed) @@ -1893,7 +1890,7 @@ inline bool Field::packed() const { } inline void Field::_internal_set_packed(bool value) { - packed_ = value; + _impl_.packed_ = value; } inline void Field::set_packed(bool value) { _internal_set_packed(value); @@ -1902,32 +1899,32 @@ inline void Field::set_packed(bool value) { // repeated .google.protobuf.Option options = 9; inline int Field::_internal_options_size() const { - return options_.size(); + return _impl_.options_.size(); } inline int Field::options_size() const { return _internal_options_size(); } inline void Field::clear_options() { - options_.Clear(); + _impl_.options_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::Option* Field::mutable_options(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Field.options) - return options_.Mutable(index); + return _impl_.options_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >* Field::mutable_options() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Field.options) - return &options_; + return &_impl_.options_; } inline const ::PROTOBUF_NAMESPACE_ID::Option& Field::_internal_options(int index) const { - return options_.Get(index); + return _impl_.options_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::Option& Field::options(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Field.options) return _internal_options(index); } inline ::PROTOBUF_NAMESPACE_ID::Option* Field::_internal_add_options() { - return options_.Add(); + return _impl_.options_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::Option* Field::add_options() { ::PROTOBUF_NAMESPACE_ID::Option* _add = _internal_add_options(); @@ -1937,12 +1934,12 @@ inline ::PROTOBUF_NAMESPACE_ID::Option* Field::add_options() { inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >& Field::options() const { // @@protoc_insertion_point(field_list:google.protobuf.Field.options) - return options_; + return _impl_.options_; } // string json_name = 10; inline void Field::clear_json_name() { - json_name_.ClearToEmpty(); + _impl_.json_name_.ClearToEmpty(); } inline const std::string& Field::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name) @@ -1952,7 +1949,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Field::set_json_name(ArgT0&& arg0, ArgT... args) { - json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.json_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Field.json_name) } inline std::string* Field::mutable_json_name() { @@ -1961,19 +1958,19 @@ inline std::string* Field::mutable_json_name() { return _s; } inline const std::string& Field::_internal_json_name() const { - return json_name_.Get(); + return _impl_.json_name_.Get(); } inline void Field::_internal_set_json_name(const std::string& value) { - json_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.json_name_.Set(value, GetArenaForAllocation()); } inline std::string* Field::_internal_mutable_json_name() { - return json_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.json_name_.Mutable(GetArenaForAllocation()); } inline std::string* Field::release_json_name() { // @@protoc_insertion_point(field_release:google.protobuf.Field.json_name) - return json_name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.json_name_.Release(); } inline void Field::set_allocated_json_name(std::string* json_name) { if (json_name != nullptr) { @@ -1981,11 +1978,10 @@ inline void Field::set_allocated_json_name(std::string* json_name) { } else { } - json_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), json_name, - GetArenaForAllocation()); + _impl_.json_name_.SetAllocated(json_name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (json_name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.json_name_.IsDefault()) { + _impl_.json_name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name) @@ -1993,7 +1989,7 @@ inline void Field::set_allocated_json_name(std::string* json_name) { // string default_value = 11; inline void Field::clear_default_value() { - default_value_.ClearToEmpty(); + _impl_.default_value_.ClearToEmpty(); } inline const std::string& Field::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value) @@ -2003,7 +1999,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Field::set_default_value(ArgT0&& arg0, ArgT... args) { - default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.default_value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Field.default_value) } inline std::string* Field::mutable_default_value() { @@ -2012,19 +2008,19 @@ inline std::string* Field::mutable_default_value() { return _s; } inline const std::string& Field::_internal_default_value() const { - return default_value_.Get(); + return _impl_.default_value_.Get(); } inline void Field::_internal_set_default_value(const std::string& value) { - default_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.default_value_.Set(value, GetArenaForAllocation()); } inline std::string* Field::_internal_mutable_default_value() { - return default_value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.default_value_.Mutable(GetArenaForAllocation()); } inline std::string* Field::release_default_value() { // @@protoc_insertion_point(field_release:google.protobuf.Field.default_value) - return default_value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.default_value_.Release(); } inline void Field::set_allocated_default_value(std::string* default_value) { if (default_value != nullptr) { @@ -2032,11 +2028,10 @@ inline void Field::set_allocated_default_value(std::string* default_value) { } else { } - default_value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), default_value, - GetArenaForAllocation()); + _impl_.default_value_.SetAllocated(default_value, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (default_value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.default_value_.IsDefault()) { + _impl_.default_value_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value) @@ -2048,7 +2043,7 @@ inline void Field::set_allocated_default_value(std::string* default_value) { // string name = 1; inline void Enum::clear_name() { - name_.ClearToEmpty(); + _impl_.name_.ClearToEmpty(); } inline const std::string& Enum::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.name) @@ -2058,7 +2053,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Enum::set_name(ArgT0&& arg0, ArgT... args) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Enum.name) } inline std::string* Enum::mutable_name() { @@ -2067,19 +2062,19 @@ inline std::string* Enum::mutable_name() { return _s; } inline const std::string& Enum::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void Enum::_internal_set_name(const std::string& value) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* Enum::_internal_mutable_name() { - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* Enum::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Enum.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.name_.Release(); } inline void Enum::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -2087,11 +2082,10 @@ inline void Enum::set_allocated_name(std::string* name) { } else { } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name) @@ -2099,32 +2093,32 @@ inline void Enum::set_allocated_name(std::string* name) { // repeated .google.protobuf.EnumValue enumvalue = 2; inline int Enum::_internal_enumvalue_size() const { - return enumvalue_.size(); + return _impl_.enumvalue_.size(); } inline int Enum::enumvalue_size() const { return _internal_enumvalue_size(); } inline void Enum::clear_enumvalue() { - enumvalue_.Clear(); + _impl_.enumvalue_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::EnumValue* Enum::mutable_enumvalue(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.enumvalue) - return enumvalue_.Mutable(index); + return _impl_.enumvalue_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumValue >* Enum::mutable_enumvalue() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Enum.enumvalue) - return &enumvalue_; + return &_impl_.enumvalue_; } inline const ::PROTOBUF_NAMESPACE_ID::EnumValue& Enum::_internal_enumvalue(int index) const { - return enumvalue_.Get(index); + return _impl_.enumvalue_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::EnumValue& Enum::enumvalue(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.enumvalue) return _internal_enumvalue(index); } inline ::PROTOBUF_NAMESPACE_ID::EnumValue* Enum::_internal_add_enumvalue() { - return enumvalue_.Add(); + return _impl_.enumvalue_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::EnumValue* Enum::add_enumvalue() { ::PROTOBUF_NAMESPACE_ID::EnumValue* _add = _internal_add_enumvalue(); @@ -2134,37 +2128,37 @@ inline ::PROTOBUF_NAMESPACE_ID::EnumValue* Enum::add_enumvalue() { inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::EnumValue >& Enum::enumvalue() const { // @@protoc_insertion_point(field_list:google.protobuf.Enum.enumvalue) - return enumvalue_; + return _impl_.enumvalue_; } // repeated .google.protobuf.Option options = 3; inline int Enum::_internal_options_size() const { - return options_.size(); + return _impl_.options_.size(); } inline int Enum::options_size() const { return _internal_options_size(); } inline void Enum::clear_options() { - options_.Clear(); + _impl_.options_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::Option* Enum::mutable_options(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.options) - return options_.Mutable(index); + return _impl_.options_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >* Enum::mutable_options() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.Enum.options) - return &options_; + return &_impl_.options_; } inline const ::PROTOBUF_NAMESPACE_ID::Option& Enum::_internal_options(int index) const { - return options_.Get(index); + return _impl_.options_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::Option& Enum::options(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.options) return _internal_options(index); } inline ::PROTOBUF_NAMESPACE_ID::Option* Enum::_internal_add_options() { - return options_.Add(); + return _impl_.options_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::Option* Enum::add_options() { ::PROTOBUF_NAMESPACE_ID::Option* _add = _internal_add_options(); @@ -2174,18 +2168,18 @@ inline ::PROTOBUF_NAMESPACE_ID::Option* Enum::add_options() { inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >& Enum::options() const { // @@protoc_insertion_point(field_list:google.protobuf.Enum.options) - return options_; + return _impl_.options_; } // .google.protobuf.SourceContext source_context = 4; inline bool Enum::_internal_has_source_context() const { - return this != internal_default_instance() && source_context_ != nullptr; + return this != internal_default_instance() && _impl_.source_context_ != nullptr; } inline bool Enum::has_source_context() const { return _internal_has_source_context(); } inline const ::PROTOBUF_NAMESPACE_ID::SourceContext& Enum::_internal_source_context() const { - const ::PROTOBUF_NAMESPACE_ID::SourceContext* p = source_context_; + const ::PROTOBUF_NAMESPACE_ID::SourceContext* p = _impl_.source_context_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::SourceContext&>( ::PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_); } @@ -2196,9 +2190,9 @@ inline const ::PROTOBUF_NAMESPACE_ID::SourceContext& Enum::source_context() cons inline void Enum::unsafe_arena_set_allocated_source_context( ::PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.source_context_); } - source_context_ = source_context; + _impl_.source_context_ = source_context; if (source_context) { } else { @@ -2208,8 +2202,8 @@ inline void Enum::unsafe_arena_set_allocated_source_context( } inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Enum::release_source_context() { - ::PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; - source_context_ = nullptr; + ::PROTOBUF_NAMESPACE_ID::SourceContext* temp = _impl_.source_context_; + _impl_.source_context_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -2224,17 +2218,17 @@ inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Enum::release_source_context() { inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Enum::unsafe_arena_release_source_context() { // @@protoc_insertion_point(field_release:google.protobuf.Enum.source_context) - ::PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; - source_context_ = nullptr; + ::PROTOBUF_NAMESPACE_ID::SourceContext* temp = _impl_.source_context_; + _impl_.source_context_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Enum::_internal_mutable_source_context() { - if (source_context_ == nullptr) { + if (_impl_.source_context_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceContext>(GetArenaForAllocation()); - source_context_ = p; + _impl_.source_context_ = p; } - return source_context_; + return _impl_.source_context_; } inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Enum::mutable_source_context() { ::PROTOBUF_NAMESPACE_ID::SourceContext* _msg = _internal_mutable_source_context(); @@ -2244,12 +2238,11 @@ inline ::PROTOBUF_NAMESPACE_ID::SourceContext* Enum::mutable_source_context() { inline void Enum::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceContext* source_context) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context_); + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.source_context_); } if (source_context) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper< - ::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena( + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_context)); if (message_arena != submessage_arena) { source_context = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( @@ -2259,16 +2252,16 @@ inline void Enum::set_allocated_source_context(::PROTOBUF_NAMESPACE_ID::SourceCo } else { } - source_context_ = source_context; + _impl_.source_context_ = source_context; // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context) } // .google.protobuf.Syntax syntax = 5; inline void Enum::clear_syntax() { - syntax_ = 0; + _impl_.syntax_ = 0; } inline ::PROTOBUF_NAMESPACE_ID::Syntax Enum::_internal_syntax() const { - return static_cast< ::PROTOBUF_NAMESPACE_ID::Syntax >(syntax_); + return static_cast< ::PROTOBUF_NAMESPACE_ID::Syntax >(_impl_.syntax_); } inline ::PROTOBUF_NAMESPACE_ID::Syntax Enum::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.syntax) @@ -2276,7 +2269,7 @@ inline ::PROTOBUF_NAMESPACE_ID::Syntax Enum::syntax() const { } inline void Enum::_internal_set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) { - syntax_ = value; + _impl_.syntax_ = value; } inline void Enum::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) { _internal_set_syntax(value); @@ -2289,7 +2282,7 @@ inline void Enum::set_syntax(::PROTOBUF_NAMESPACE_ID::Syntax value) { // string name = 1; inline void EnumValue::clear_name() { - name_.ClearToEmpty(); + _impl_.name_.ClearToEmpty(); } inline const std::string& EnumValue::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name) @@ -2299,7 +2292,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void EnumValue::set_name(ArgT0&& arg0, ArgT... args) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name) } inline std::string* EnumValue::mutable_name() { @@ -2308,19 +2301,19 @@ inline std::string* EnumValue::mutable_name() { return _s; } inline const std::string& EnumValue::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void EnumValue::_internal_set_name(const std::string& value) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* EnumValue::_internal_mutable_name() { - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* EnumValue::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.name_.Release(); } inline void EnumValue::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -2328,11 +2321,10 @@ inline void EnumValue::set_allocated_name(std::string* name) { } else { } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name) @@ -2340,10 +2332,10 @@ inline void EnumValue::set_allocated_name(std::string* name) { // int32 number = 2; inline void EnumValue::clear_number() { - number_ = 0; + _impl_.number_ = 0; } inline int32_t EnumValue::_internal_number() const { - return number_; + return _impl_.number_; } inline int32_t EnumValue::number() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.number) @@ -2351,7 +2343,7 @@ inline int32_t EnumValue::number() const { } inline void EnumValue::_internal_set_number(int32_t value) { - number_ = value; + _impl_.number_ = value; } inline void EnumValue::set_number(int32_t value) { _internal_set_number(value); @@ -2360,32 +2352,32 @@ inline void EnumValue::set_number(int32_t value) { // repeated .google.protobuf.Option options = 3; inline int EnumValue::_internal_options_size() const { - return options_.size(); + return _impl_.options_.size(); } inline int EnumValue::options_size() const { return _internal_options_size(); } inline void EnumValue::clear_options() { - options_.Clear(); + _impl_.options_.Clear(); } inline ::PROTOBUF_NAMESPACE_ID::Option* EnumValue::mutable_options(int index) { // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.options) - return options_.Mutable(index); + return _impl_.options_.Mutable(index); } inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >* EnumValue::mutable_options() { // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValue.options) - return &options_; + return &_impl_.options_; } inline const ::PROTOBUF_NAMESPACE_ID::Option& EnumValue::_internal_options(int index) const { - return options_.Get(index); + return _impl_.options_.Get(index); } inline const ::PROTOBUF_NAMESPACE_ID::Option& EnumValue::options(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.options) return _internal_options(index); } inline ::PROTOBUF_NAMESPACE_ID::Option* EnumValue::_internal_add_options() { - return options_.Add(); + return _impl_.options_.Add(); } inline ::PROTOBUF_NAMESPACE_ID::Option* EnumValue::add_options() { ::PROTOBUF_NAMESPACE_ID::Option* _add = _internal_add_options(); @@ -2395,7 +2387,7 @@ inline ::PROTOBUF_NAMESPACE_ID::Option* EnumValue::add_options() { inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Option >& EnumValue::options() const { // @@protoc_insertion_point(field_list:google.protobuf.EnumValue.options) - return options_; + return _impl_.options_; } // ------------------------------------------------------------------- @@ -2404,7 +2396,7 @@ EnumValue::options() const { // string name = 1; inline void Option::clear_name() { - name_.ClearToEmpty(); + _impl_.name_.ClearToEmpty(); } inline const std::string& Option::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Option.name) @@ -2414,7 +2406,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Option::set_name(ArgT0&& arg0, ArgT... args) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.Option.name) } inline std::string* Option::mutable_name() { @@ -2423,19 +2415,19 @@ inline std::string* Option::mutable_name() { return _s; } inline const std::string& Option::_internal_name() const { - return name_.Get(); + return _impl_.name_.Get(); } inline void Option::_internal_set_name(const std::string& value) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.name_.Set(value, GetArenaForAllocation()); } inline std::string* Option::_internal_mutable_name() { - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.name_.Mutable(GetArenaForAllocation()); } inline std::string* Option::release_name() { // @@protoc_insertion_point(field_release:google.protobuf.Option.name) - return name_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.name_.Release(); } inline void Option::set_allocated_name(std::string* name) { if (name != nullptr) { @@ -2443,11 +2435,10 @@ inline void Option::set_allocated_name(std::string* name) { } else { } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArenaForAllocation()); + _impl_.name_.SetAllocated(name, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (name_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.name_.IsDefault()) { + _impl_.name_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name) @@ -2455,13 +2446,13 @@ inline void Option::set_allocated_name(std::string* name) { // .google.protobuf.Any value = 2; inline bool Option::_internal_has_value() const { - return this != internal_default_instance() && value_ != nullptr; + return this != internal_default_instance() && _impl_.value_ != nullptr; } inline bool Option::has_value() const { return _internal_has_value(); } inline const ::PROTOBUF_NAMESPACE_ID::Any& Option::_internal_value() const { - const ::PROTOBUF_NAMESPACE_ID::Any* p = value_; + const ::PROTOBUF_NAMESPACE_ID::Any* p = _impl_.value_; return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Any&>( ::PROTOBUF_NAMESPACE_ID::_Any_default_instance_); } @@ -2472,9 +2463,9 @@ inline const ::PROTOBUF_NAMESPACE_ID::Any& Option::value() const { inline void Option::unsafe_arena_set_allocated_value( ::PROTOBUF_NAMESPACE_ID::Any* value) { if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(value_); + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.value_); } - value_ = value; + _impl_.value_ = value; if (value) { } else { @@ -2484,8 +2475,8 @@ inline void Option::unsafe_arena_set_allocated_value( } inline ::PROTOBUF_NAMESPACE_ID::Any* Option::release_value() { - ::PROTOBUF_NAMESPACE_ID::Any* temp = value_; - value_ = nullptr; + ::PROTOBUF_NAMESPACE_ID::Any* temp = _impl_.value_; + _impl_.value_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); @@ -2500,17 +2491,17 @@ inline ::PROTOBUF_NAMESPACE_ID::Any* Option::release_value() { inline ::PROTOBUF_NAMESPACE_ID::Any* Option::unsafe_arena_release_value() { // @@protoc_insertion_point(field_release:google.protobuf.Option.value) - ::PROTOBUF_NAMESPACE_ID::Any* temp = value_; - value_ = nullptr; + ::PROTOBUF_NAMESPACE_ID::Any* temp = _impl_.value_; + _impl_.value_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::Any* Option::_internal_mutable_value() { - if (value_ == nullptr) { + if (_impl_.value_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Any>(GetArenaForAllocation()); - value_ = p; + _impl_.value_ = p; } - return value_; + return _impl_.value_; } inline ::PROTOBUF_NAMESPACE_ID::Any* Option::mutable_value() { ::PROTOBUF_NAMESPACE_ID::Any* _msg = _internal_mutable_value(); @@ -2520,12 +2511,11 @@ inline ::PROTOBUF_NAMESPACE_ID::Any* Option::mutable_value() { inline void Option::set_allocated_value(::PROTOBUF_NAMESPACE_ID::Any* value) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); if (message_arena == nullptr) { - delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(value_); + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.value_); } if (value) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper< - ::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena( + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(value)); if (message_arena != submessage_arena) { value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( @@ -2535,7 +2525,7 @@ inline void Option::set_allocated_value(::PROTOBUF_NAMESPACE_ID::Any* value) { } else { } - value_ = value; + _impl_.value_ = value; // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.value) } diff --git a/r5dev/thirdparty/protobuf/unittest.proto b/r5dev/thirdparty/protobuf/unittest.proto index 7dda9246..f1b0bd04 100644 --- a/r5dev/thirdparty/protobuf/unittest.proto +++ b/r5dev/thirdparty/protobuf/unittest.proto @@ -113,6 +113,7 @@ message TestAllTypes { optional_public_import_message = 26; optional NestedMessage optional_lazy_message = 27 [lazy=true]; + optional NestedMessage optional_unverified_lazy_message = 28 [unverified_lazy=true]; // Repeated repeated int32 repeated_int32 = 31; @@ -187,6 +188,8 @@ message NestedTestAllTypes { optional NestedTestAllTypes child = 1; optional TestAllTypes payload = 2; repeated NestedTestAllTypes repeated_child = 3; + optional NestedTestAllTypes lazy_child = 4 [lazy=true]; + optional TestAllTypes eager_child = 5 [lazy=false]; } message TestDeprecatedFields { @@ -262,6 +265,8 @@ extend TestAllExtensions { optional TestAllTypes.NestedMessage optional_lazy_message_extension = 27 [lazy=true]; + optional TestAllTypes.NestedMessage + optional_unverified_lazy_message_extension = 28 [unverified_lazy=true]; // Repeated repeated int32 repeated_int32_extension = 31; @@ -370,6 +375,33 @@ message TestChildExtension { optional TestAllExtensions optional_extension = 3; } +// Emulates wireformat data of TestChildExtension with dynamic extension +// (DynamicExtension). +message TestChildExtensionData { + message NestedTestAllExtensionsData { + message NestedDynamicExtensions { + optional int32 a = 1; + optional int32 b = 2; + } + optional NestedDynamicExtensions dynamic = 409707008; + } + optional string a = 1; + optional string b = 2; + optional NestedTestAllExtensionsData optional_extension = 3; +} + +message TestNestedChildExtension { + optional int32 a = 1; + optional TestChildExtension child = 2; +} + +// Emulates wireformat data of TestNestedChildExtension with dynamic extension +// (DynamicExtension). +message TestNestedChildExtensionData { + optional int32 a = 1; + optional TestChildExtensionData child = 2; +} + // We have separate messages for testing required fields because it's // annoying to have to fill in required fields in TestProto in order to // do anything with it. Note that we don't need to test every type of @@ -418,6 +450,9 @@ message TestRequired { optional int32 dummy32 = 32; required int32 c = 33; + + // Add an optional child message to make this non-trivial for go/pdlazy. + optional ForeignMessage optional_foreign = 34; } message TestRequiredForeign { @@ -432,6 +467,12 @@ message TestRequiredMessage { required TestRequired required_message = 3; } +message TestNestedRequiredForeign { + optional TestNestedRequiredForeign child = 1; + optional TestRequiredForeign payload = 2; + optional int32 dummy = 3; +} + // Test that we can use NestedMessage from outside TestAllTypes. message TestForeignNested { optional TestAllTypes.NestedMessage foreign_nested = 1; @@ -519,7 +560,14 @@ message TestEagerMessage { message TestLazyMessage { optional TestAllTypes sub_message = 1 [lazy=true]; } - +message TestEagerMaybeLazy { + message NestedMessage { + optional TestPackedTypes packed = 1; + } + optional TestAllTypes message_foo = 1; + optional TestAllTypes message_bar = 2; + optional NestedMessage message_baz = 3; +} // Needed for a Python test. message TestNestedMessageHasBits { message NestedMessage { @@ -685,6 +733,41 @@ message MoreBytes { repeated bytes data = 1; } +message ManyOptionalString { + optional string str1 = 1; + optional string str2 = 2; + optional string str3 = 3; + optional string str4 = 4; + optional string str5 = 5; + optional string str6 = 6; + optional string str7 = 7; + optional string str8 = 8; + optional string str9 = 9; + optional string str10 = 10; + optional string str11 = 11; + optional string str12 = 12; + optional string str13 = 13; + optional string str14 = 14; + optional string str15 = 15; + optional string str16 = 16; + optional string str17 = 17; + optional string str18 = 18; + optional string str19 = 19; + optional string str20 = 20; + optional string str21 = 21; + optional string str22 = 22; + optional string str23 = 23; + optional string str24 = 24; + optional string str25 = 25; + optional string str26 = 26; + optional string str27 = 27; + optional string str28 = 28; + optional string str29 = 29; + optional string str30 = 30; + optional string str31 = 31; + optional string str32 = 32; +} + // Test int32, uint32, int64, uint64, and bool are all compatible message Int32Message { optional int32 data = 1; @@ -762,7 +845,7 @@ message TestOneof2 { optional string baz_string = 19 [default = "BAZ"]; message NestedMessage { - optional int64 qux_int = 1; + optional int64 moo_int = 1; repeated int32 corge_int = 2; } @@ -943,11 +1026,28 @@ message TestParsingMerge { } } +// Test that the correct exception is thrown by parseFrom in a corner case +// involving merging, extensions, and required fields. +message TestMergeException { + optional TestAllExtensions all_extensions = 1; +} + message TestCommentInjectionMessage { // */ <- This should not close the generated doc comment optional string a = 1 [default="*/ <- Neither should this."]; } +// Used to check that the c++ code generator re-orders messages to reduce +// padding. +message TestMessageSize { + optional bool m1 = 1; + optional int64 m2 = 2; + optional bool m3 = 3; + optional string m4 = 4; + optional int32 m5 = 5; + optional int64 m6 = 6; +} + // Test that RPC services work. message FooRequest {} @@ -1023,6 +1123,37 @@ extend TestExtensionInsideTable { optional int32 test_extension_inside_table_extension = 5; } +// NOTE(b/202996544): Intentionally nested to mirror go/glep. +message TestNestedGroupExtensionOuter { + optional group Layer1OptionalGroup = 1 { + repeated group Layer2RepeatedGroup = 2 { + extensions 3 + // NOTE: extension metadata is not supported due to targets such as + // `//third_party/protobuf_legacy_opensource/src:shell_scripts_test`, + // eee https://screenshot.googleplex.com/Axz2QD8nxjdpyFF + //[metadata = { + // NOTE: can't write type there due to some clever build gen code at + // http://google3/net/proto2/internal/BUILD;l=1247;rcl=411090862 + // type: "protobuf_unittest.TestNestedGroupExtensionInnerExtension", + // name: "inner", + // }] + ; + optional string another_field = 6; + } + repeated group Layer2AnotherOptionalRepeatedGroup = 4 { + optional string but_why_tho = 5; + } + } +} + +message TestNestedGroupExtensionInnerExtension { + optional string inner_name= 1; +} + +extend TestNestedGroupExtensionOuter.Layer1OptionalGroup.Layer2RepeatedGroup { + optional TestNestedGroupExtensionInnerExtension inner = 3; +} + enum VeryLargeEnum { ENUM_LABEL_DEFAULT = 0; ENUM_LABEL_1 = 1; @@ -1155,4 +1286,133 @@ message TestExtensionRangeSerialize { } } +message TestVerifyInt32Simple { + optional int32 optional_int32_1 = 1; + optional int32 optional_int32_2 = 2; + optional int32 optional_int32_63 = 63; + optional int32 optional_int32_64 = 64; +} + +message TestVerifyInt32 { + optional int32 optional_int32_1 = 1; + optional int32 optional_int32_2 = 2; + optional int32 optional_int32_63 = 63; + optional int32 optional_int32_64 = 64; + + optional TestAllTypes optional_all_types = 9; + repeated TestAllTypes repeated_all_types = 10; +} + +message TestVerifyMostlyInt32 { + optional int64 optional_int64_30 = 30; + + optional int32 optional_int32_1 = 1; + optional int32 optional_int32_2 = 2; + optional int32 optional_int32_3 = 3; + optional int32 optional_int32_4 = 4; + optional int32 optional_int32_63 = 63; + optional int32 optional_int32_64 = 64; + + optional TestAllTypes optional_all_types = 9; + repeated TestAllTypes repeated_all_types = 10; +} + +message TestVerifyMostlyInt32BigFieldNumber { + optional int64 optional_int64_30 = 30; + optional int32 optional_int32_300 = 300; + + optional int32 optional_int32_1 = 1; + optional int32 optional_int32_2 = 2; + optional int32 optional_int32_3 = 3; + optional int32 optional_int32_4 = 4; + optional int32 optional_int32_63 = 63; + optional int32 optional_int32_64 = 64; + + optional TestAllTypes optional_all_types = 9; + repeated TestAllTypes repeated_all_types = 10; +} + +message TestVerifyUint32Simple { + optional uint32 optional_uint32_1 = 1; + optional uint32 optional_uint32_2 = 2; + optional uint32 optional_uint32_63 = 63; + optional uint32 optional_uint32_64 = 64; +} + +message TestVerifyUint32 { + optional uint32 optional_uint32_1 = 1; + optional uint32 optional_uint32_2 = 2; + optional uint32 optional_uint32_63 = 63; + optional uint32 optional_uint32_64 = 64; + + optional TestAllTypes optional_all_types = 9; + repeated TestAllTypes repeated_all_types = 10; +} + +message TestVerifyOneUint32 { + optional uint32 optional_uint32_1 = 1; + optional int32 optional_int32_2 = 2; + optional int32 optional_int32_63 = 63; + optional int32 optional_int32_64 = 64; + + optional TestAllTypes optional_all_types = 9; + repeated TestAllTypes repeated_all_types = 10; +} + +message TestVerifyOneInt32BigFieldNumber { + optional int32 optional_int32_65 = 65; + + optional int64 optional_int64_1 = 1; + optional int64 optional_int64_2 = 2; + optional int64 optional_int64_63 = 63; + optional int64 optional_int64_64 = 64; + + optional TestAllTypes optional_all_types = 9; + repeated TestAllTypes repeated_all_types = 10; +} + +message TestVerifyInt32BigFieldNumber { + optional int32 optional_int32_1000 = 1000; + optional int32 optional_int32_65 = 65; + + optional int32 optional_int32_1 = 1; + optional int32 optional_int32_2 = 2; + optional int32 optional_int32_63 = 63; + optional int32 optional_int32_64 = 64; + + optional TestAllTypes optional_all_types = 9; + repeated TestAllTypes repeated_all_types = 10; +} + +message TestVerifyUint32BigFieldNumber { + optional uint32 optional_uint32_1000 = 1000; + optional uint32 optional_uint32_65 = 65; + + optional uint32 optional_uint32_1 = 1; + optional uint32 optional_uint32_2 = 2; + optional uint32 optional_uint32_63 = 63; + optional uint32 optional_uint32_64 = 64; + + optional TestAllTypes optional_all_types = 9; + repeated TestAllTypes repeated_all_types = 10; +} + +message TestVerifyBigFieldNumberUint32 { + message Nested { + optional uint32 optional_uint32_5000 = 5000; + optional uint32 optional_uint32_1000 = 1000; + optional uint32 optional_uint32_66 = 66; + optional uint32 optional_uint32_65 = 65; + + optional uint32 optional_uint32_1 = 1; + optional uint32 optional_uint32_2 = 2; + optional uint32 optional_uint32_63 = 63; + optional uint32 optional_uint32_64 = 64; + + optional Nested optional_nested = 9; + repeated Nested repeated_nested = 10; + } + optional Nested optional_nested = 1; +} + diff --git a/r5dev/thirdparty/protobuf/unittest_custom_options.proto b/r5dev/thirdparty/protobuf/unittest_custom_options.proto index 1812d71e..d7416619 100644 --- a/r5dev/thirdparty/protobuf/unittest_custom_options.proto +++ b/r5dev/thirdparty/protobuf/unittest_custom_options.proto @@ -245,7 +245,7 @@ message ComplexOptionType2 { } message ComplexOptionType3 { - optional int32 qux = 1; + optional int32 moo = 1; optional group ComplexOptionType5 = 2 { optional int32 plugh = 3; @@ -253,7 +253,7 @@ message ComplexOptionType3 { } extend ComplexOptionType1 { - optional int32 quux = 7663707; + optional int32 mooo = 7663707; optional ComplexOptionType3 corge = 7663442; } @@ -274,18 +274,18 @@ extend google.protobuf.MessageOptions { // Note that we try various different ways of naming the same extension. message VariousComplexOptions { option (.protobuf_unittest.complex_opt1).foo = 42; - option (protobuf_unittest.complex_opt1).(.protobuf_unittest.quux) = 324; - option (.protobuf_unittest.complex_opt1).(protobuf_unittest.corge).qux = 876; + option (protobuf_unittest.complex_opt1).(.protobuf_unittest.mooo) = 324; + option (.protobuf_unittest.complex_opt1).(protobuf_unittest.corge).moo = 876; option (protobuf_unittest.complex_opt1).foo4 = 99; option (protobuf_unittest.complex_opt1).foo4 = 88; option (complex_opt2).baz = 987; option (complex_opt2).(grault) = 654; option (complex_opt2).bar.foo = 743; - option (complex_opt2).bar.(quux) = 1999; - option (complex_opt2).bar.(protobuf_unittest.corge).qux = 2008; + option (complex_opt2).bar.(mooo) = 1999; + option (complex_opt2).bar.(protobuf_unittest.corge).moo = 2008; option (complex_opt2).(garply).foo = 741; - option (complex_opt2).(garply).(.protobuf_unittest.quux) = 1998; - option (complex_opt2).(protobuf_unittest.garply).(corge).qux = 2121; + option (complex_opt2).(garply).(.protobuf_unittest.mooo) = 1998; + option (complex_opt2).(protobuf_unittest.garply).(corge).moo = 2121; option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971; option (complex_opt2).fred.waldo = 321; option (complex_opt2).barney = { @@ -294,7 +294,7 @@ message VariousComplexOptions { option (complex_opt2).barney = { waldo: 212 }; - option (protobuf_unittest.complex_opt3).qux = 9; + option (protobuf_unittest.complex_opt3).moo = 9; option (complex_opt3).complexoptiontype5.plugh = 22; option (complexopt6).xyzzy = 24; } @@ -439,7 +439,9 @@ message NestedOptionType { // Custom message option that has a required enum field. // WARNING: this is strongly discouraged! message OldOptionType { - enum TestEnum { OLD_VALUE = 0; } + enum TestEnum { + OLD_VALUE = 0; + } required TestEnum value = 1; } diff --git a/r5dev/thirdparty/protobuf/unittest_drop_unknown_fields.proto b/r5dev/thirdparty/protobuf/unittest_drop_unknown_fields.proto index 8aa3a37b..a8a98ad3 100644 --- a/r5dev/thirdparty/protobuf/unittest_drop_unknown_fields.proto +++ b/r5dev/thirdparty/protobuf/unittest_drop_unknown_fields.proto @@ -31,8 +31,8 @@ syntax = "proto3"; package unittest_drop_unknown_fields; -option objc_class_prefix = "DropUnknowns"; +option objc_class_prefix = "DropUnknowns"; option csharp_namespace = "Google.Protobuf.TestProtos"; message Foo { @@ -50,7 +50,7 @@ message FooWithExtraFields { FOO = 0; BAR = 1; BAZ = 2; - QUX = 3; + MOO = 3; } int32 int32_value = 1; NestedEnum enum_value = 2; diff --git a/r5dev/thirdparty/protobuf/unittest_lite.proto b/r5dev/thirdparty/protobuf/unittest_lite.proto index 92282a6f..010d4a9c 100644 --- a/r5dev/thirdparty/protobuf/unittest_lite.proto +++ b/r5dev/thirdparty/protobuf/unittest_lite.proto @@ -97,6 +97,8 @@ message TestAllTypesLite { optional_public_import_message = 26; optional NestedMessage optional_lazy_message = 27 [lazy = true]; + optional NestedMessage optional_unverified_lazy_message = 28 + [unverified_lazy = true]; // Repeated repeated int32 repeated_int32 = 31; @@ -247,6 +249,9 @@ extend TestAllExtensionsLite { optional TestAllTypesLite.NestedMessage optional_lazy_message_extension_lite = 27 [lazy = true]; + optional TestAllTypesLite.NestedMessage + optional_unverified_lazy_message_extension_lite = 28 + [unverified_lazy = true]; // Repeated repeated int32 repeated_int32_extension_lite = 31; @@ -391,6 +396,12 @@ message TestParsingMergeLite { } } +// Test that the correct exception is thrown by parseFrom in a corner case +// involving merging, extensions, and required fields. +message TestMergeExceptionLite { + optional TestAllExtensionsLite all_extensions = 1; +} + // TestEmptyMessageLite is used to test unknown fields support in lite mode. message TestEmptyMessageLite {} @@ -400,7 +411,9 @@ message TestEmptyMessageWithExtensionsLite { extensions 1 to max; } -enum V1EnumLite { V1_FIRST = 1; } +enum V1EnumLite { + V1_FIRST = 1; +} enum V2EnumLite { V2_FIRST = 1; @@ -463,6 +476,12 @@ message TestOneofParsingLite { } } +message TestMessageSetLite { + option message_set_wire_format = true; + + extensions 100 to max; +} + // The following four messages are set up to test for wire compatibility between // packed and non-packed repeated fields. We use the field number 2048, because // that is large enough to require a 3-byte varint for the tag. diff --git a/r5dev/thirdparty/protobuf/unittest_mset.proto b/r5dev/thirdparty/protobuf/unittest_mset.proto index 4e7a8c51..32949947 100644 --- a/r5dev/thirdparty/protobuf/unittest_mset.proto +++ b/r5dev/thirdparty/protobuf/unittest_mset.proto @@ -48,6 +48,11 @@ message TestMessageSetContainer { optional proto2_wireformat_unittest.TestMessageSet message_set = 1; } +message NestedTestMessageSetContainer { + optional TestMessageSetContainer container = 1; + optional NestedTestMessageSetContainer child = 2; +} + message TestMessageSetExtension1 { extend proto2_wireformat_unittest.TestMessageSet { optional TestMessageSetExtension1 message_set_extension = 1545008; @@ -64,6 +69,18 @@ message TestMessageSetExtension2 { optional string str = 25; } +message NestedTestInt { + optional fixed32 a = 1; + optional NestedTestInt child = 2; +} + +message TestMessageSetExtension3 { + extend proto2_wireformat_unittest.TestMessageSet { + optional TestMessageSetExtension3 message_set_extension = 195273129; + } + optional NestedTestInt msg = 35; +} + // This message was used to generate // //net/proto2/python/internal/testdata/message_set_message, but is commented // out since it must not actually exist in code, to simulate an "unknown" diff --git a/r5dev/thirdparty/protobuf/unittest_no_generic_services.proto b/r5dev/thirdparty/protobuf/unittest_no_generic_services.proto index c2f042ba..57a0d165 100644 --- a/r5dev/thirdparty/protobuf/unittest_no_generic_services.proto +++ b/r5dev/thirdparty/protobuf/unittest_no_generic_services.proto @@ -31,6 +31,7 @@ // Author: kenton@google.com (Kenton Varda) syntax = "proto2"; + package protobuf_unittest.no_generic_services_test; @@ -41,14 +42,12 @@ message TestMessage { extensions 1000 to max; } -enum TestEnum { - FOO = 1; -} +enum TestEnum { FOO = 1; } extend TestMessage { optional int32 test_extension = 1000; } service TestService { - rpc Foo(TestMessage) returns(TestMessage); + rpc Foo(TestMessage) returns (TestMessage); } diff --git a/r5dev/thirdparty/protobuf/unittest_proto3.proto b/r5dev/thirdparty/protobuf/unittest_proto3.proto index 89c8799a..910f4010 100644 --- a/r5dev/thirdparty/protobuf/unittest_proto3.proto +++ b/r5dev/thirdparty/protobuf/unittest_proto3.proto @@ -76,7 +76,7 @@ message TestAllTypes { // optional int32 a = 17; // } - NestedMessage optional_nested_message = 18; + optional NestedMessage optional_nested_message = 18; ForeignMessage optional_foreign_message = 19; protobuf_unittest_import.ImportMessage optional_import_message = 20; @@ -96,6 +96,7 @@ message TestAllTypes { 26; NestedMessage optional_lazy_message = 27 [lazy = true]; + NestedMessage optional_unverified_lazy_message = 28 [unverified_lazy = true]; protobuf_unittest_import.ImportMessage optional_lazy_import_message = 115 [lazy = true]; diff --git a/r5dev/thirdparty/protobuf/unittest_proto3_arena.proto b/r5dev/thirdparty/protobuf/unittest_proto3_arena.proto index 17529397..7dc6cd06 100644 --- a/r5dev/thirdparty/protobuf/unittest_proto3_arena.proto +++ b/r5dev/thirdparty/protobuf/unittest_proto3_arena.proto @@ -96,6 +96,7 @@ message TestAllTypes { optional_public_import_message = 26; NestedMessage optional_lazy_message = 27 [lazy=true]; + NestedMessage optional_unverified_lazy_message = 28 [unverified_lazy=true]; protobuf_unittest_import.ImportMessage optional_lazy_import_message = 115 [lazy = true]; diff --git a/r5dev/thirdparty/protobuf/unknown_field_set.cc b/r5dev/thirdparty/protobuf/unknown_field_set.cc index a87bd45c..7e5d14c9 100644 --- a/r5dev/thirdparty/protobuf/unknown_field_set.cc +++ b/r5dev/thirdparty/protobuf/unknown_field_set.cc @@ -36,17 +36,19 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> +#include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> #include <thirdparty/protobuf/extension_set.h> #include <thirdparty/protobuf/generated_message_tctable_decl.h> #include <thirdparty/protobuf/generated_message_tctable_impl.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/wire_format_lite.h> #include <thirdparty/protobuf/stubs/stl_util.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -109,7 +111,7 @@ void UnknownFieldSet::MergeToInternalMetadata( size_t UnknownFieldSet::SpaceUsedExcludingSelfLong() const { if (fields_.empty()) return 0; - size_t total_size = sizeof(fields_) + sizeof(UnknownField) * fields_.size(); + size_t total_size = sizeof(UnknownField) * fields_.capacity(); for (const UnknownField& field : fields_) { switch (field.type()) { @@ -238,6 +240,20 @@ bool UnknownFieldSet::ParseFromArray(const void* data, int size) { return ParseFromZeroCopyStream(&input); } +bool UnknownFieldSet::SerializeToString(std::string* output) const { + const size_t size = + google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(*this); + STLStringResizeUninitializedAmortized(output, size); + google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + *this, reinterpret_cast<uint8_t*>(const_cast<char*>(output->data()))); + return true; +} + +bool UnknownFieldSet::SerializeToCodedStream( + io::CodedOutputStream* output) const { + google::protobuf::internal::WireFormat::SerializeUnknownFields(*this, output); + return !output->HadError(); +} void UnknownField::Delete() { switch (type()) { case UnknownField::TYPE_LENGTH_DELIMITED: diff --git a/r5dev/thirdparty/protobuf/unknown_field_set.h b/r5dev/thirdparty/protobuf/unknown_field_set.h index cd384261..3c9bd115 100644 --- a/r5dev/thirdparty/protobuf/unknown_field_set.h +++ b/r5dev/thirdparty/protobuf/unknown_field_set.h @@ -38,6 +38,7 @@ #ifndef GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__ #define GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__ + #include <assert.h> #include <string> @@ -45,12 +46,13 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> -#include <thirdparty/protobuf/message_lite.h> #include <thirdparty/protobuf/port.h> +#include <thirdparty/protobuf/message_lite.h> +#include <thirdparty/protobuf/parse_context.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> #ifdef SWIG @@ -172,6 +174,9 @@ class PROTOBUF_EXPORT UnknownFieldSet { template <typename MessageType> bool MergeFromMessage(const MessageType& message); + // Serialization. + bool SerializeToString(std::string* output) const; + bool SerializeToCodedStream(io::CodedOutputStream* output) const; static const UnknownFieldSet& default_instance(); private: @@ -259,15 +264,6 @@ class PROTOBUF_EXPORT UnknownField { inline std::string* mutable_length_delimited(); inline UnknownFieldSet* mutable_group(); - // Serialization API. - // These methods can take advantage of the underlying implementation and may - // archieve a better performance than using getters to retrieve the data and - // do the serialization yourself. - void SerializeLengthDelimitedNoTag(io::CodedOutputStream* output) const { - output->SetCur(InternalSerializeLengthDelimitedNoTag(output->Cur(), - output->EpsCopy())); - } - inline size_t GetLengthDelimitedSize() const; uint8_t* InternalSerializeLengthDelimitedNoTag( uint8_t* target, io::EpsCopyOutputStream* stream) const; diff --git a/r5dev/thirdparty/protobuf/unknown_field_set_unittest.cc b/r5dev/thirdparty/protobuf/unknown_field_set_unittest.cc index 3ed6d746..cb3852df 100644 --- a/r5dev/thirdparty/protobuf/unknown_field_set_unittest.cc +++ b/r5dev/thirdparty/protobuf/unknown_field_set_unittest.cc @@ -37,22 +37,26 @@ #include <thirdparty/protobuf/unknown_field_set.h> +#include <string> #include <unordered_set> +#include <vector> #include <thirdparty/protobuf/stubs/callback.h> #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/test_util.h> #include <thirdparty/protobuf/unittest.pb.h> #include <thirdparty/protobuf/unittest_lite.pb.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/stubs/mutex.h> +#include <thirdparty/protobuf/text_format.h> #include <thirdparty/protobuf/wire_format.h> +#include <gmock/gmock.h> #include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> #include <thirdparty/protobuf/stubs/time.h> +#include <thirdparty/protobuf/test_util.h> #include <thirdparty/protobuf/stubs/stl_util.h> namespace google { @@ -62,7 +66,7 @@ using internal::WireFormat; class UnknownFieldSetTest : public testing::Test { protected: - virtual void SetUp() { + void SetUp() override { descriptor_ = unittest::TestAllTypes::descriptor(); TestUtil::SetAllFields(&all_fields_); all_fields_.SerializeToString(&all_fields_data_); @@ -130,12 +134,12 @@ TEST_F(UnknownFieldSetTest, AllFieldsPresent) { } } - std::unordered_set<uint32> unknown_tags; + std::unordered_set<uint32_t> unknown_tags; for (int i = 0; i < unknown_fields_->field_count(); i++) { unknown_tags.insert(unknown_fields_->field(i).number()); } - for (uint32 t : unknown_tags) { + for (uint32_t t : unknown_tags) { EXPECT_NE(descriptor_->FindFieldByNumber(t), nullptr); } @@ -200,8 +204,9 @@ TEST_F(UnknownFieldSetTest, SerializeFastAndSlowAreEquivalent) { slow_buffer.resize(size); fast_buffer.resize(size); - uint8* target = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&fast_buffer)); - uint8* result = WireFormat::SerializeUnknownFieldsToArray( + uint8_t* target = + reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&fast_buffer)); + uint8_t* result = WireFormat::SerializeUnknownFieldsToArray( empty_message_.unknown_fields(), target); EXPECT_EQ(size, result - target); @@ -302,6 +307,8 @@ TEST_F(UnknownFieldSetTest, MergeFrom) { destination.MergeFrom(source); + std::string destination_text; + TextFormat::PrintToString(destination, &destination_text); EXPECT_EQ( // Note: The ordering of fields here depends on the ordering of adds // and merging, above. @@ -309,7 +316,7 @@ TEST_F(UnknownFieldSetTest, MergeFrom) { "3: 2\n" "2: 3\n" "3: 4\n", - destination.DebugString()); + destination_text); } TEST_F(UnknownFieldSetTest, MergeFromMessage) { @@ -322,6 +329,8 @@ TEST_F(UnknownFieldSetTest, MergeFromMessage) { destination.mutable_unknown_fields()->MergeFromMessage(source); + std::string destination_text; + TextFormat::PrintToString(destination, &destination_text); EXPECT_EQ( // Note: The ordering of fields here depends on the ordering of adds // and merging, above. @@ -329,7 +338,7 @@ TEST_F(UnknownFieldSetTest, MergeFromMessage) { "3: 2\n" "2: 3\n" "3: 4\n", - destination.DebugString()); + destination_text); } TEST_F(UnknownFieldSetTest, MergeFromMessageLite) { @@ -531,38 +540,61 @@ TEST_F(UnknownFieldSetTest, UnknownEnumValue) { TEST_F(UnknownFieldSetTest, SpaceUsedExcludingSelf) { UnknownFieldSet empty; empty.AddVarint(1, 0); - EXPECT_EQ(sizeof(std::vector<UnknownField>) + sizeof(UnknownField), - empty.SpaceUsedExcludingSelf()); + EXPECT_EQ(sizeof(UnknownField), empty.SpaceUsedExcludingSelf()); } TEST_F(UnknownFieldSetTest, SpaceUsed) { + // Keep shadow vectors to avoid making assumptions about its capacity growth. + // We imitate the push back calls here to determine the expected capacity. + std::vector<UnknownField> shadow_vector, shadow_vector_group; unittest::TestEmptyMessage empty_message; // Make sure an unknown field set has zero space used until a field is // actually added. - size_t base_size = empty_message.SpaceUsedLong(); + const size_t base = empty_message.SpaceUsedLong(); + std::string* str = nullptr; + UnknownFieldSet* group = nullptr; + const auto total = [&] { + size_t result = base; + result += shadow_vector.capacity() * sizeof(UnknownField); + result += shadow_vector_group.capacity() * sizeof(UnknownField); + if (str != nullptr) { + result += sizeof(std::string); + static const size_t sso_capacity = std::string().capacity(); + if (str->capacity() > sso_capacity) result += str->capacity(); + } + if (group != nullptr) { + result += sizeof(UnknownFieldSet); + } + return result; + }; + UnknownFieldSet* unknown_fields = empty_message.mutable_unknown_fields(); - EXPECT_EQ(base_size, empty_message.SpaceUsedLong()); + EXPECT_EQ(total(), empty_message.SpaceUsedLong()); // Make sure each thing we add to the set increases the SpaceUsedLong(). unknown_fields->AddVarint(1, 0); - EXPECT_LT(base_size, empty_message.SpaceUsedLong()); - base_size = empty_message.SpaceUsedLong(); + shadow_vector.emplace_back(); + EXPECT_EQ(total(), empty_message.SpaceUsedLong()) << "Var"; - std::string* str = unknown_fields->AddLengthDelimited(1); - EXPECT_LT(base_size, empty_message.SpaceUsedLong()); - base_size = empty_message.SpaceUsedLong(); + str = unknown_fields->AddLengthDelimited(1); + shadow_vector.emplace_back(); + EXPECT_EQ(total(), empty_message.SpaceUsedLong()) << "Str"; str->assign(sizeof(std::string) + 1, 'x'); - EXPECT_LT(base_size, empty_message.SpaceUsedLong()); - base_size = empty_message.SpaceUsedLong(); + EXPECT_EQ(total(), empty_message.SpaceUsedLong()) << "Str2"; - UnknownFieldSet* group = unknown_fields->AddGroup(1); - EXPECT_LT(base_size, empty_message.SpaceUsedLong()); - base_size = empty_message.SpaceUsedLong(); + group = unknown_fields->AddGroup(1); + shadow_vector.emplace_back(); + EXPECT_EQ(total(), empty_message.SpaceUsedLong()) << "Group"; group->AddVarint(1, 0); - EXPECT_LT(base_size, empty_message.SpaceUsedLong()); + shadow_vector_group.emplace_back(); + EXPECT_EQ(total(), empty_message.SpaceUsedLong()) << "Group2"; + + unknown_fields->AddVarint(1, 0); + shadow_vector.emplace_back(); + EXPECT_EQ(total(), empty_message.SpaceUsedLong()) << "Var2"; } @@ -646,6 +678,7 @@ TEST_F(UnknownFieldSetTest, DeleteByNumber) { MAKE_VECTOR(kExpectedFieldNumbers5)); } #undef MAKE_VECTOR + } // namespace } // namespace protobuf diff --git a/r5dev/thirdparty/protobuf/util/delimited_message_util.cc b/r5dev/thirdparty/protobuf/util/delimited_message_util.cc index 66d4fd75..716894be 100644 --- a/r5dev/thirdparty/protobuf/util/delimited_message_util.cc +++ b/r5dev/thirdparty/protobuf/util/delimited_message_util.cc @@ -64,13 +64,13 @@ bool ParseDelimitedFromZeroCopyStream(MessageLite* message, bool ParseDelimitedFromCodedStream(MessageLite* message, io::CodedInputStream* input, bool* clean_eof) { - if (clean_eof != NULL) *clean_eof = false; + if (clean_eof != nullptr) *clean_eof = false; int start = input->CurrentPosition(); // Read the size. - uint32 size; + uint32_t size; if (!input->ReadVarint32(&size)) { - if (clean_eof != NULL) *clean_eof = input->CurrentPosition() == start; + if (clean_eof != nullptr) *clean_eof = input->CurrentPosition() == start; return false; } @@ -79,7 +79,7 @@ bool ParseDelimitedFromCodedStream(MessageLite* message, int position_after_size = input->CurrentPosition(); // Tell the stream not to read beyond that size. - io::CodedInputStream::Limit limit = input->PushLimit(size); + io::CodedInputStream::Limit limit = input->PushLimit(static_cast<int>(size)); // Parse the message. if (!message->MergeFromCodedStream(input)) return false; @@ -105,11 +105,12 @@ bool SerializeDelimitedToCodedStream(const MessageLite& message, size_t size = message.ByteSizeLong(); if (size > INT_MAX) return false; - output->WriteVarint32(size); + output->WriteVarint32(static_cast<uint32_t>(size)); // Write the content. - uint8* buffer = output->GetDirectBufferForNBytesAndAdvance(size); - if (buffer != NULL) { + uint8_t* buffer = + output->GetDirectBufferForNBytesAndAdvance(static_cast<int>(size)); + if (buffer != nullptr) { // Optimization: The message fits in one buffer, so use the faster // direct-to-array serialization path. message.SerializeWithCachedSizesToArray(buffer); diff --git a/r5dev/thirdparty/protobuf/util/delimited_message_util.h b/r5dev/thirdparty/protobuf/util/delimited_message_util.h index 6d18f009..86fa648c 100644 --- a/r5dev/thirdparty/protobuf/util/delimited_message_util.h +++ b/r5dev/thirdparty/protobuf/util/delimited_message_util.h @@ -41,6 +41,7 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/util/field_comparator.h b/r5dev/thirdparty/protobuf/util/field_comparator.h index 9286f5d7..82a9f2ee 100644 --- a/r5dev/thirdparty/protobuf/util/field_comparator.h +++ b/r5dev/thirdparty/protobuf/util/field_comparator.h @@ -33,12 +33,15 @@ #ifndef GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ #define GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ + #include <cstdint> #include <map> #include <string> #include <vector> #include <thirdparty/protobuf/stubs/common.h> + +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/util/field_comparator_test.cc b/r5dev/thirdparty/protobuf/util/field_comparator_test.cc index 19e5b829..731e1324 100644 --- a/r5dev/thirdparty/protobuf/util/field_comparator_test.cc +++ b/r5dev/thirdparty/protobuf/util/field_comparator_test.cc @@ -48,7 +48,7 @@ using protobuf_unittest::TestAllTypes; class DefaultFieldComparatorTest : public ::testing::Test { protected: - void SetUp() { descriptor_ = TestAllTypes::descriptor(); } + void SetUp() override { descriptor_ = TestAllTypes::descriptor(); } const Descriptor* descriptor_; DefaultFieldComparator comparator_; @@ -58,22 +58,25 @@ class DefaultFieldComparatorTest : public ::testing::Test { TEST_F(DefaultFieldComparatorTest, RecursesIntoGroup) { const FieldDescriptor* field = descriptor_->FindFieldByName("optionalgroup"); - EXPECT_EQ(FieldComparator::RECURSE, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ( + FieldComparator::RECURSE, + comparator_.Compare(message_1_, message_2_, field, -1, -1, nullptr)); } TEST_F(DefaultFieldComparatorTest, RecursesIntoNestedMessage) { const FieldDescriptor* field = descriptor_->FindFieldByName("optional_nested_message"); - EXPECT_EQ(FieldComparator::RECURSE, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ( + FieldComparator::RECURSE, + comparator_.Compare(message_1_, message_2_, field, -1, -1, nullptr)); } TEST_F(DefaultFieldComparatorTest, RecursesIntoForeignMessage) { const FieldDescriptor* field = descriptor_->FindFieldByName("optional_foreign_message"); - EXPECT_EQ(FieldComparator::RECURSE, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ( + FieldComparator::RECURSE, + comparator_.Compare(message_1_, message_2_, field, -1, -1, nullptr)); } TEST_F(DefaultFieldComparatorTest, Int32Comparison) { @@ -81,12 +84,13 @@ TEST_F(DefaultFieldComparatorTest, Int32Comparison) { message_1_.set_optional_int32(1); message_2_.set_optional_int32(1); - EXPECT_EQ(FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, comparator_.Compare(message_1_, message_2_, + field, -1, -1, nullptr)); message_2_.set_optional_int32(-1); - EXPECT_EQ(FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ( + FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field, -1, -1, nullptr)); } TEST_F(DefaultFieldComparatorTest, Int64Comparison) { @@ -94,12 +98,13 @@ TEST_F(DefaultFieldComparatorTest, Int64Comparison) { message_1_.set_optional_int64(1L); message_2_.set_optional_int64(1L); - EXPECT_EQ(FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, comparator_.Compare(message_1_, message_2_, + field, -1, -1, nullptr)); message_2_.set_optional_int64(-1L); - EXPECT_EQ(FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ( + FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field, -1, -1, nullptr)); } TEST_F(DefaultFieldComparatorTest, UInt32Comparison) { @@ -108,12 +113,13 @@ TEST_F(DefaultFieldComparatorTest, UInt32Comparison) { message_1_.set_optional_uint32(1); message_2_.set_optional_uint32(1); - EXPECT_EQ(FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, comparator_.Compare(message_1_, message_2_, + field, -1, -1, nullptr)); message_2_.set_optional_uint32(2); - EXPECT_EQ(FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ( + FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field, -1, -1, nullptr)); } TEST_F(DefaultFieldComparatorTest, UInt64Comparison) { @@ -122,12 +128,13 @@ TEST_F(DefaultFieldComparatorTest, UInt64Comparison) { message_1_.set_optional_uint64(1L); message_2_.set_optional_uint64(1L); - EXPECT_EQ(FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, comparator_.Compare(message_1_, message_2_, + field, -1, -1, nullptr)); message_2_.set_optional_uint64(2L); - EXPECT_EQ(FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ( + FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field, -1, -1, nullptr)); } TEST_F(DefaultFieldComparatorTest, BooleanComparison) { @@ -135,12 +142,13 @@ TEST_F(DefaultFieldComparatorTest, BooleanComparison) { message_1_.set_optional_bool(true); message_2_.set_optional_bool(true); - EXPECT_EQ(FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, comparator_.Compare(message_1_, message_2_, + field, -1, -1, nullptr)); message_2_.set_optional_bool(false); - EXPECT_EQ(FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ( + FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field, -1, -1, nullptr)); } TEST_F(DefaultFieldComparatorTest, EnumComparison) { @@ -149,12 +157,13 @@ TEST_F(DefaultFieldComparatorTest, EnumComparison) { message_1_.set_optional_nested_enum(TestAllTypes::BAR); message_2_.set_optional_nested_enum(TestAllTypes::BAR); - EXPECT_EQ(FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, comparator_.Compare(message_1_, message_2_, + field, -1, -1, nullptr)); message_2_.set_optional_nested_enum(TestAllTypes::BAZ); - EXPECT_EQ(FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ( + FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field, -1, -1, nullptr)); } TEST_F(DefaultFieldComparatorTest, StringComparison) { @@ -163,12 +172,13 @@ TEST_F(DefaultFieldComparatorTest, StringComparison) { message_1_.set_optional_string("foo"); message_2_.set_optional_string("foo"); - EXPECT_EQ(FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, comparator_.Compare(message_1_, message_2_, + field, -1, -1, nullptr)); message_2_.set_optional_string("bar"); - EXPECT_EQ(FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL)); + EXPECT_EQ( + FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field, -1, -1, nullptr)); } TEST_F(DefaultFieldComparatorTest, FloatingPointComparisonExact) { @@ -182,22 +192,22 @@ TEST_F(DefaultFieldComparatorTest, FloatingPointComparisonExact) { message_1_.set_optional_double(0.1); message_2_.set_optional_double(0.1); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); message_2_.set_optional_float(0.2f); message_2_.set_optional_double(0.2); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); } TEST_F(DefaultFieldComparatorTest, FloatingPointComparisonApproximate) { @@ -222,21 +232,21 @@ TEST_F(DefaultFieldComparatorTest, FloatingPointComparisonApproximate) { // DefaultFieldComparator's default float comparison mode is EXACT. ASSERT_EQ(DefaultFieldComparator::EXACT, comparator_.float_comparison()); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); comparator_.set_float_comparison(DefaultFieldComparator::APPROXIMATE); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); } TEST_F(DefaultFieldComparatorTest, FloatingPointComparisonTreatNaNsAsEqual) { @@ -254,36 +264,36 @@ TEST_F(DefaultFieldComparatorTest, FloatingPointComparisonTreatNaNsAsEqual) { // treating NaNs as different. ASSERT_EQ(DefaultFieldComparator::EXACT, comparator_.float_comparison()); ASSERT_EQ(false, comparator_.treat_nan_as_equal()); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); comparator_.set_float_comparison(DefaultFieldComparator::APPROXIMATE); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); comparator_.set_treat_nan_as_equal(true); ASSERT_EQ(true, comparator_.treat_nan_as_equal()); comparator_.set_float_comparison(DefaultFieldComparator::EXACT); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); comparator_.set_float_comparison(DefaultFieldComparator::APPROXIMATE); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); } TEST_F(DefaultFieldComparatorTest, @@ -299,62 +309,62 @@ TEST_F(DefaultFieldComparatorTest, message_2_.set_optional_double(109.9); comparator_.set_float_comparison(DefaultFieldComparator::APPROXIMATE); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); // Should fail since the fraction is too low. comparator_.SetFractionAndMargin(field_float, 0.01, 0.0); comparator_.SetFractionAndMargin(field_double, 0.01, 0.0); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); // Should fail since the margin is too low. comparator_.SetFractionAndMargin(field_float, 0.0, 9.0); comparator_.SetFractionAndMargin(field_double, 0.0, 9.0); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); // Should succeed since the fraction is high enough. comparator_.SetFractionAndMargin(field_float, 0.2, 0.0); comparator_.SetFractionAndMargin(field_double, 0.2, 0.0); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); // Should succeed since the margin is high enough. comparator_.SetFractionAndMargin(field_float, 0.0, 10.0); comparator_.SetFractionAndMargin(field_double, 0.0, 10.0); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); // Setting values for one of the fields should not affect the other. comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); // +inf should be equal even though they are not technically within margin or // fraction. @@ -364,12 +374,12 @@ TEST_F(DefaultFieldComparatorTest, message_2_.set_optional_double(std::numeric_limits<double>::infinity()); comparator_.SetFractionAndMargin(field_float, 0.0, 0.0); comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); // -inf should be equal even though they are not technically within margin or // fraction. @@ -379,12 +389,12 @@ TEST_F(DefaultFieldComparatorTest, message_2_.set_optional_double(-std::numeric_limits<double>::infinity()); comparator_.SetFractionAndMargin(field_float, 0.0, 0.0); comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); // Finite values and inf should not be equal, even for a positive fraction. message_1_.set_optional_float(std::numeric_limits<float>::infinity()); @@ -414,23 +424,23 @@ TEST_F(DefaultFieldComparatorTest, message_2_.set_optional_double(109.9); comparator_.set_float_comparison(DefaultFieldComparator::APPROXIMATE); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); // Set default fraction and margin. comparator_.SetDefaultFractionAndMargin(0.01, 0.0); // Float comparisons should fail since the fraction is too low. - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); // Set field-specific fraction and margin for one field (field_float) but not // the other (field_double) @@ -438,37 +448,37 @@ TEST_F(DefaultFieldComparatorTest, // The field with the override should succeed, since its field-specific // fraction is high enough. - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); // The field with no override should fail, since the default fraction is too // low - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); // Set the default fraction and margin high enough so that fields that use // the default should succeed comparator_.SetDefaultFractionAndMargin(0.2, 0.0); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); // The field with an override should still be OK - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); // Set fraction and margin for the field with an override to be too low comparator_.SetFractionAndMargin(field_float, 0.01, 0.0); // Now our default is high enough but field_float's override is too low. - EXPECT_EQ( - FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field_float, -1, -1, NULL)); - EXPECT_EQ( - FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field_double, -1, -1, NULL)); + EXPECT_EQ(FieldComparator::DIFFERENT, + comparator_.Compare(message_1_, message_2_, field_float, -1, -1, + nullptr)); + EXPECT_EQ(FieldComparator::SAME, + comparator_.Compare(message_1_, message_2_, field_double, -1, -1, + nullptr)); } // Simple test checking whether we compare values at correct indices. @@ -482,11 +492,11 @@ TEST_F(DefaultFieldComparatorTest, RepeatedFieldComparison) { message_2_.add_repeated_string("baz"); EXPECT_EQ(FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field, 0, 0, NULL)); + comparator_.Compare(message_1_, message_2_, field, 0, 0, nullptr)); EXPECT_EQ(FieldComparator::DIFFERENT, - comparator_.Compare(message_1_, message_2_, field, 1, 1, NULL)); + comparator_.Compare(message_1_, message_2_, field, 1, 1, nullptr)); EXPECT_EQ(FieldComparator::SAME, - comparator_.Compare(message_1_, message_2_, field, 1, 0, NULL)); + comparator_.Compare(message_1_, message_2_, field, 1, 0, nullptr)); } } // namespace diff --git a/r5dev/thirdparty/protobuf/util/field_mask_util.cc b/r5dev/thirdparty/protobuf/util/field_mask_util.cc index ea87fadb..34b6a627 100644 --- a/r5dev/thirdparty/protobuf/util/field_mask_util.cc +++ b/r5dev/thirdparty/protobuf/util/field_mask_util.cc @@ -32,8 +32,8 @@ #include <cstdint> -#include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/stubs/map_util.h> // Must be included last. @@ -339,7 +339,7 @@ void FieldMaskTree::AddPath(const std::string& path) { return; } Node*& child = node->children[node_name]; - if (child == NULL) { + if (child == nullptr) { new_branch = true; child = new Node(); } @@ -423,7 +423,7 @@ void FieldMaskTree::IntersectPath(const std::string& path, FieldMaskTree* out) { return; } const Node* result = FindPtrOrNull(node->children, node_name); - if (result == NULL) { + if (result == nullptr) { // No intersection found. return; } @@ -459,7 +459,7 @@ void FieldMaskTree::MergeMessage(const Node* node, const Message& source, const std::string& field_name = it->first; const Node* child = it->second; const FieldDescriptor* field = descriptor->FindFieldByName(field_name); - if (field == NULL) { + if (field == nullptr) { GOOGLE_LOG(ERROR) << "Cannot find field \"" << field_name << "\" in message " << descriptor->full_name(); continue; diff --git a/r5dev/thirdparty/protobuf/util/field_mask_util.h b/r5dev/thirdparty/protobuf/util/field_mask_util.h index dd4c9fca..818e0c08 100644 --- a/r5dev/thirdparty/protobuf/util/field_mask_util.h +++ b/r5dev/thirdparty/protobuf/util/field_mask_util.h @@ -37,8 +37,8 @@ #include <string> #include <thirdparty/protobuf/field_mask.pb.h> -#include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/descriptor.h> // Must be included last. #include <thirdparty/protobuf/port_def.inc> @@ -96,8 +96,9 @@ class PROTOBUF_EXPORT FieldMaskUtil { template <typename T> static bool IsValidFieldMask(const FieldMask& mask) { for (int i = 0; i < mask.paths_size(); ++i) { - if (!GetFieldDescriptors(T::descriptor(), mask.paths(i), nullptr)) + if (!GetFieldDescriptors(T::descriptor(), mask.paths(i), nullptr)) { return false; + } } return true; } diff --git a/r5dev/thirdparty/protobuf/util/field_mask_util_test.cc b/r5dev/thirdparty/protobuf/util/field_mask_util_test.cc index 679004b3..d7687a55 100644 --- a/r5dev/thirdparty/protobuf/util/field_mask_util_test.cc +++ b/r5dev/thirdparty/protobuf/util/field_mask_util_test.cc @@ -227,7 +227,7 @@ TEST(FieldMaskUtilTest, TestGetFieldMaskForAllFields) { EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask("bb", mask)); mask = FieldMaskUtil::GetFieldMaskForAllFields<TestAllTypes>(); - EXPECT_EQ(75, mask.paths_size()); + EXPECT_EQ(76, mask.paths_size()); EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask("optional_int32", mask)); EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask("optional_int64", mask)); EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask("optional_uint32", mask)); diff --git a/r5dev/thirdparty/protobuf/util/internal/constants.h b/r5dev/thirdparty/protobuf/util/internal/constants.h index e1b9f3fb..dda0d6ae 100644 --- a/r5dev/thirdparty/protobuf/util/internal/constants.h +++ b/r5dev/thirdparty/protobuf/util/internal/constants.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_CONSTANTS_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_CONSTANTS_H__ #include <cstdint> @@ -98,4 +98,4 @@ const char kOptionJspbMessageId[] = "jspb.message_id"; } // namespace util } // namespace protobuf } // namespace google -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_CONSTANTS_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/datapiece.cc b/r5dev/thirdparty/protobuf/util/internal/datapiece.cc index 8278f95c..3d6a671f 100644 --- a/r5dev/thirdparty/protobuf/util/internal/datapiece.cc +++ b/r5dev/thirdparty/protobuf/util/internal/datapiece.cc @@ -37,9 +37,9 @@ #include <thirdparty/protobuf/struct.pb.h> #include <thirdparty/protobuf/type.pb.h> #include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/stubs/status.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/stubs/mathutil.h> namespace google { @@ -100,6 +100,24 @@ util::StatusOr<float> DoubleToFloat(double before) { return static_cast<float>(before); } else if (before > std::numeric_limits<float>::max() || before < -std::numeric_limits<float>::max()) { + // Some doubles are larger than the largest float, but after + // rounding they will be equal to the largest float. + // We can't just attempt the conversion because that has UB if + // the value really is out-of-range. + // Here we take advantage that 1/2-ing a large floating point + // will not lose precision. + double half_before = before * 0.5; + if (half_before < std::numeric_limits<float>::max() && + half_before > -std::numeric_limits<float>::max()) { + const float half_fmax = std::numeric_limits<float>::max() * 0.5f; + // If after being cut in half, the value is less than the largest float, + // then it's safe to convert it to float. Importantly, this conversion + // rounds in the same way that the original does. + float half_after = static_cast<float>(half_before); + if (half_after <= half_fmax && half_after >= -half_fmax) { + return half_after + half_after; + } + } // Double value outside of the range of float. return util::InvalidArgumentError(DoubleAsString(before)); } else { diff --git a/r5dev/thirdparty/protobuf/util/internal/datapiece.h b/r5dev/thirdparty/protobuf/util/internal/datapiece.h index 08e1144f..92ab233d 100644 --- a/r5dev/thirdparty/protobuf/util/internal/datapiece.h +++ b/r5dev/thirdparty/protobuf/util/internal/datapiece.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_DATAPIECE_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_DATAPIECE_H__ #include <cstdint> #include <string> @@ -40,6 +40,7 @@ #include <thirdparty/protobuf/stubs/statusor.h> #include <thirdparty/protobuf/stubs/strutil.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -215,4 +216,4 @@ class PROTOBUF_EXPORT DataPiece { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_DATAPIECE_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/default_value_objectwriter.h b/r5dev/thirdparty/protobuf/util/internal/default_value_objectwriter.h index 9c58892c..3400a6e2 100644 --- a/r5dev/thirdparty/protobuf/util/internal/default_value_objectwriter.h +++ b/r5dev/thirdparty/protobuf/util/internal/default_value_objectwriter.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_DEFAULT_VALUE_OBJECTWRITER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_DEFAULT_VALUE_OBJECTWRITER_H__ #include <cstdint> #include <functional> @@ -38,12 +38,12 @@ #include <vector> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/util/internal/type_info.h> +#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/util/internal/datapiece.h> #include <thirdparty/protobuf/util/internal/object_writer.h> +#include <thirdparty/protobuf/util/internal/type_info.h> #include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/util/type_resolver.h> -#include <thirdparty/protobuf/stubs/strutil.h> // Must be included last. #include <thirdparty/protobuf/port_def.inc> @@ -81,7 +81,7 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { const google::protobuf::Type& type, ObjectWriter* ow); - virtual ~DefaultValueObjectWriter(); + ~DefaultValueObjectWriter() override; // ObjectWriter methods. DefaultValueObjectWriter* StartObject(StringPiece name) override; @@ -329,4 +329,4 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_DEFAULT_VALUE_OBJECTWRITER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/default_value_objectwriter_test.cc b/r5dev/thirdparty/protobuf/util/internal/default_value_objectwriter_test.cc index 6ef8fb85..214e287b 100644 --- a/r5dev/thirdparty/protobuf/util/internal/default_value_objectwriter_test.cc +++ b/r5dev/thirdparty/protobuf/util/internal/default_value_objectwriter_test.cc @@ -32,8 +32,8 @@ #include <thirdparty/protobuf/util/internal/expecting_objectwriter.h> #include <thirdparty/protobuf/util/internal/testdata/default_value_test.pb.h> -#include <thirdparty/protobuf/util/internal/type_info_test_helper.h> #include <thirdparty/protobuf/util/internal/constants.h> +#include <thirdparty/protobuf/util/internal/type_info_test_helper.h> #include <gtest/gtest.h> namespace google { @@ -57,7 +57,7 @@ class BaseDefaultValueObjectWriterTest &mock_)); } - virtual ~BaseDefaultValueObjectWriterTest() {} + ~BaseDefaultValueObjectWriterTest() override {} TypeInfoTestHelper helper_; MockObjectWriter mock_; @@ -71,7 +71,7 @@ class DefaultValueObjectWriterTest : public BaseDefaultValueObjectWriterTest { protected: DefaultValueObjectWriterTest() : BaseDefaultValueObjectWriterTest(DefaultValueTest::descriptor()) {} - virtual ~DefaultValueObjectWriterTest() {} + ~DefaultValueObjectWriterTest() override {} }; INSTANTIATE_TEST_SUITE_P(DifferentTypeInfoSourceTest, diff --git a/r5dev/thirdparty/protobuf/util/internal/error_listener.h b/r5dev/thirdparty/protobuf/util/internal/error_listener.h index cd9388d2..0da67631 100644 --- a/r5dev/thirdparty/protobuf/util/internal/error_listener.h +++ b/r5dev/thirdparty/protobuf/util/internal/error_listener.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_ERROR_LISTENER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_ERROR_LISTENER_H__ #include <algorithm> #include <memory> @@ -39,8 +39,8 @@ #include <thirdparty/protobuf/stubs/callback.h> #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> -#include <thirdparty/protobuf/util/internal/location_tracker.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/util/internal/location_tracker.h> // Must be included last. #include <thirdparty/protobuf/port_def.inc> @@ -106,4 +106,4 @@ class PROTOBUF_EXPORT NoopErrorListener : public ErrorListener { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_ERROR_LISTENER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/expecting_objectwriter.h b/r5dev/thirdparty/protobuf/util/internal/expecting_objectwriter.h index d8d85236..32b46d19 100644 --- a/r5dev/thirdparty/protobuf/util/internal/expecting_objectwriter.h +++ b/r5dev/thirdparty/protobuf/util/internal/expecting_objectwriter.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_EXPECTING_OBJECTWRITER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_EXPECTING_OBJECTWRITER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_EXPECTING_OBJECTWRITER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_EXPECTING_OBJECTWRITER_H__ // An implementation of ObjectWriter that automatically sets the // gmock expectations for the response to a method. Every method @@ -53,9 +53,9 @@ #include <cstdint> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/util/internal/object_writer.h> #include <gmock/gmock.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/util/internal/object_writer.h> namespace google { namespace protobuf { @@ -102,7 +102,7 @@ class ExpectingObjectWriter : public ObjectWriter { public: explicit ExpectingObjectWriter(MockObjectWriter* mock) : mock_(mock) {} - virtual ObjectWriter* StartObject(StringPiece name) { + ObjectWriter* StartObject(StringPiece name) override { (name.empty() ? EXPECT_CALL(*mock_, StartObject(IsEmpty())) : EXPECT_CALL(*mock_, StartObject(Eq(std::string(name))))) .WillOnce(Return(mock_)) @@ -110,14 +110,14 @@ class ExpectingObjectWriter : public ObjectWriter { return this; } - virtual ObjectWriter* EndObject() { + ObjectWriter* EndObject() override { EXPECT_CALL(*mock_, EndObject()) .WillOnce(Return(mock_)) .RetiresOnSaturation(); return this; } - virtual ObjectWriter* StartList(StringPiece name) { + ObjectWriter* StartList(StringPiece name) override { (name.empty() ? EXPECT_CALL(*mock_, StartList(IsEmpty())) : EXPECT_CALL(*mock_, StartList(Eq(std::string(name))))) .WillOnce(Return(mock_)) @@ -125,14 +125,14 @@ class ExpectingObjectWriter : public ObjectWriter { return this; } - virtual ObjectWriter* EndList() { + ObjectWriter* EndList() override { EXPECT_CALL(*mock_, EndList()) .WillOnce(Return(mock_)) .RetiresOnSaturation(); return this; } - virtual ObjectWriter* RenderBool(StringPiece name, bool value) { + ObjectWriter* RenderBool(StringPiece name, bool value) override { (name.empty() ? EXPECT_CALL(*mock_, RenderBool(IsEmpty(), TypedEq<bool>(value))) : EXPECT_CALL(*mock_, @@ -142,7 +142,7 @@ class ExpectingObjectWriter : public ObjectWriter { return this; } - virtual ObjectWriter* RenderInt32(StringPiece name, int32_t value) { + ObjectWriter* RenderInt32(StringPiece name, int32_t value) override { (name.empty() ? EXPECT_CALL(*mock_, RenderInt32(IsEmpty(), TypedEq<int32_t>(value))) : EXPECT_CALL(*mock_, RenderInt32(Eq(std::string(name)), @@ -152,7 +152,7 @@ class ExpectingObjectWriter : public ObjectWriter { return this; } - virtual ObjectWriter* RenderUint32(StringPiece name, uint32_t value) { + ObjectWriter* RenderUint32(StringPiece name, uint32_t value) override { (name.empty() ? EXPECT_CALL(*mock_, RenderUint32(IsEmpty(), TypedEq<uint32_t>(value))) : EXPECT_CALL(*mock_, RenderUint32(Eq(std::string(name)), @@ -162,7 +162,7 @@ class ExpectingObjectWriter : public ObjectWriter { return this; } - virtual ObjectWriter* RenderInt64(StringPiece name, int64_t value) { + ObjectWriter* RenderInt64(StringPiece name, int64_t value) override { (name.empty() ? EXPECT_CALL(*mock_, RenderInt64(IsEmpty(), TypedEq<int64_t>(value))) : EXPECT_CALL(*mock_, RenderInt64(Eq(std::string(name)), @@ -172,7 +172,7 @@ class ExpectingObjectWriter : public ObjectWriter { return this; } - virtual ObjectWriter* RenderUint64(StringPiece name, uint64_t value) { + ObjectWriter* RenderUint64(StringPiece name, uint64_t value) override { (name.empty() ? EXPECT_CALL(*mock_, RenderUint64(IsEmpty(), TypedEq<uint64_t>(value))) : EXPECT_CALL(*mock_, RenderUint64(Eq(std::string(name)), @@ -182,7 +182,7 @@ class ExpectingObjectWriter : public ObjectWriter { return this; } - virtual ObjectWriter* RenderDouble(StringPiece name, double value) { + ObjectWriter* RenderDouble(StringPiece name, double value) override { (name.empty() ? EXPECT_CALL(*mock_, RenderDouble(IsEmpty(), NanSensitiveDoubleEq(value))) @@ -193,7 +193,7 @@ class ExpectingObjectWriter : public ObjectWriter { return this; } - virtual ObjectWriter* RenderFloat(StringPiece name, float value) { + ObjectWriter* RenderFloat(StringPiece name, float value) override { (name.empty() ? EXPECT_CALL(*mock_, RenderFloat(IsEmpty(), NanSensitiveFloatEq(value))) @@ -204,8 +204,8 @@ class ExpectingObjectWriter : public ObjectWriter { return this; } - virtual ObjectWriter* RenderString(StringPiece name, - StringPiece value) { + ObjectWriter* RenderString(StringPiece name, + StringPiece value) override { (name.empty() ? EXPECT_CALL(*mock_, RenderString(IsEmpty(), TypedEq<StringPiece>( std::string(value)))) @@ -228,7 +228,7 @@ class ExpectingObjectWriter : public ObjectWriter { return this; } - virtual ObjectWriter* RenderNull(StringPiece name) { + ObjectWriter* RenderNull(StringPiece name) override { (name.empty() ? EXPECT_CALL(*mock_, RenderNull(IsEmpty())) : EXPECT_CALL(*mock_, RenderNull(Eq(std::string(name)))) .WillOnce(Return(mock_)) @@ -247,4 +247,4 @@ class ExpectingObjectWriter : public ObjectWriter { } // namespace protobuf } // namespace google -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_EXPECTING_OBJECTWRITER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_EXPECTING_OBJECTWRITER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/field_mask_utility.cc b/r5dev/thirdparty/protobuf/util/internal/field_mask_utility.cc index 4f90c718..e9fbec1f 100644 --- a/r5dev/thirdparty/protobuf/util/internal/field_mask_utility.cc +++ b/r5dev/thirdparty/protobuf/util/internal/field_mask_utility.cc @@ -30,9 +30,9 @@ #include <thirdparty/protobuf/util/internal/field_mask_utility.h> -#include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/stubs/status.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/stubs/status_macros.h> // Must be included last. diff --git a/r5dev/thirdparty/protobuf/util/internal/field_mask_utility.h b/r5dev/thirdparty/protobuf/util/internal/field_mask_utility.h index 21be28bd..3ebe272c 100644 --- a/r5dev/thirdparty/protobuf/util/internal/field_mask_utility.h +++ b/r5dev/thirdparty/protobuf/util/internal/field_mask_utility.h @@ -30,8 +30,8 @@ // FieldMask related utility methods. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_FIELD_MASK_UTILITY_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_FIELD_MASK_UTILITY_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_FIELD_MASK_UTILITY_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_FIELD_MASK_UTILITY_H__ #include <functional> #include <stack> @@ -71,4 +71,4 @@ util::Status DecodeCompactFieldMaskPaths(StringPiece paths, } // namespace protobuf } // namespace google -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_FIELD_MASK_UTILITY_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_FIELD_MASK_UTILITY_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/json_escaping.h b/r5dev/thirdparty/protobuf/util/internal/json_escaping.h index 7b5a4762..28035c28 100644 --- a/r5dev/thirdparty/protobuf/util/internal/json_escaping.h +++ b/r5dev/thirdparty/protobuf/util/internal/json_escaping.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__ -#define GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_ESCAPING_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_ESCAPING_H__ #include <cstdint> @@ -95,4 +95,4 @@ class JsonEscaping { } // namespace protobuf } // namespace google -#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL__JSON_ESCAPING_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_ESCAPING_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/json_objectwriter.cc b/r5dev/thirdparty/protobuf/util/internal/json_objectwriter.cc index 0d908c48..ac14b37c 100644 --- a/r5dev/thirdparty/protobuf/util/internal/json_objectwriter.cc +++ b/r5dev/thirdparty/protobuf/util/internal/json_objectwriter.cc @@ -38,8 +38,8 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/util/internal/utility.h> -#include <thirdparty/protobuf/util/internal/json_escaping.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/util/internal/json_escaping.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/util/internal/json_objectwriter.h b/r5dev/thirdparty/protobuf/util/internal/json_objectwriter.h index d94c5bb7..8c56698b 100644 --- a/r5dev/thirdparty/protobuf/util/internal/json_objectwriter.h +++ b/r5dev/thirdparty/protobuf/util/internal/json_objectwriter.h @@ -28,16 +28,16 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_OBJECTWRITER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_OBJECTWRITER_H__ #include <cstdint> #include <memory> #include <string> #include <thirdparty/protobuf/io/coded_stream.h> -#include <thirdparty/protobuf/util/internal/structured_objectwriter.h> #include <thirdparty/protobuf/stubs/bytestream.h> +#include <thirdparty/protobuf/util/internal/structured_objectwriter.h> // clang-format off #include <thirdparty/protobuf/port_def.inc> @@ -111,7 +111,7 @@ class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { } } } - virtual ~JsonObjectWriter(); + ~JsonObjectWriter() override; // ObjectWriter methods. JsonObjectWriter* StartObject(StringPiece name) override; @@ -275,4 +275,4 @@ class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_OBJECTWRITER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/json_objectwriter_test.cc b/r5dev/thirdparty/protobuf/util/internal/json_objectwriter_test.cc index c1787996..dafb6a58 100644 --- a/r5dev/thirdparty/protobuf/util/internal/json_objectwriter_test.cc +++ b/r5dev/thirdparty/protobuf/util/internal/json_objectwriter_test.cc @@ -33,8 +33,8 @@ #include <cstdint> #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> -#include <thirdparty/protobuf/util/internal/utility.h> #include <gtest/gtest.h> +#include <thirdparty/protobuf/util/internal/utility.h> namespace google { namespace protobuf { diff --git a/r5dev/thirdparty/protobuf/util/internal/json_stream_parser.cc b/r5dev/thirdparty/protobuf/util/internal/json_stream_parser.cc index d0ce947d..cd710b67 100644 --- a/r5dev/thirdparty/protobuf/util/internal/json_stream_parser.cc +++ b/r5dev/thirdparty/protobuf/util/internal/json_stream_parser.cc @@ -485,7 +485,7 @@ util::Status JsonStreamParser::ParseUnicodeEscape() { } GOOGLE_DCHECK_EQ('\\', p_.data()[0]); GOOGLE_DCHECK_EQ('u', p_.data()[1]); - uint32 code = 0; + uint32_t code = 0; for (int i = 2; i < kUnicodeEscapedLength; ++i) { if (!isxdigit(p_.data()[i])) { return ReportFailure("Invalid escape sequence.", @@ -505,7 +505,7 @@ util::Status JsonStreamParser::ParseUnicodeEscape() { } } else if (p_.data()[kUnicodeEscapedLength] == '\\' && p_.data()[kUnicodeEscapedLength + 1] == 'u') { - uint32 low_code = 0; + uint32_t low_code = 0; for (int i = kUnicodeEscapedLength + 2; i < 2 * kUnicodeEscapedLength; ++i) { if (!isxdigit(p_.data()[i])) { @@ -626,7 +626,7 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) { return status; } - // Positive non-floating point number, parse as a uint64. + // Positive non-floating point number, parse as a uint64_t. if (!negative) { // Octal/Hex numbers are not valid JSON values. if (number.length() >= 2 && number[0] == '0') { @@ -654,7 +654,7 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) { "Octal/hex numbers are not valid JSON values.", ParseErrorType::OCTAL_OR_HEX_ARE_NOT_VALID_JSON_VALUES); } - // Negative non-floating point number, parse as an int64. + // Negative non-floating point number, parse as an int64_t. if (safe_strto64(number, &result->int_val)) { result->type = NumberResult::INT; p_.remove_prefix(index); diff --git a/r5dev/thirdparty/protobuf/util/internal/json_stream_parser.h b/r5dev/thirdparty/protobuf/util/internal/json_stream_parser.h index cd3e47d2..d687faba 100644 --- a/r5dev/thirdparty/protobuf/util/internal/json_stream_parser.h +++ b/r5dev/thirdparty/protobuf/util/internal/json_stream_parser.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_STREAM_PARSER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_STREAM_PARSER_H__ #include <cstdint> #include <stack> @@ -40,6 +40,7 @@ #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/status.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -346,4 +347,4 @@ class PROTOBUF_EXPORT JsonStreamParser { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_STREAM_PARSER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/json_stream_parser_test.cc b/r5dev/thirdparty/protobuf/util/internal/json_stream_parser_test.cc index 418a4bfd..a3564777 100644 --- a/r5dev/thirdparty/protobuf/util/internal/json_stream_parser_test.cc +++ b/r5dev/thirdparty/protobuf/util/internal/json_stream_parser_test.cc @@ -35,9 +35,9 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/util/internal/expecting_objectwriter.h> -#include <thirdparty/protobuf/util/internal/object_writer.h> #include <gtest/gtest.h> #include <thirdparty/protobuf/stubs/time.h> +#include <thirdparty/protobuf/util/internal/object_writer.h> #include <thirdparty/protobuf/stubs/status.h> @@ -85,7 +85,7 @@ using ParseErrorType = class JsonStreamParserTest : public ::testing::Test { protected: JsonStreamParserTest() : mock_(), ow_(&mock_) {} - virtual ~JsonStreamParserTest() {} + ~JsonStreamParserTest() override {} util::Status RunTest(StringPiece json, int split, std::function<void(JsonStreamParser*)> setup) { diff --git a/r5dev/thirdparty/protobuf/util/internal/location_tracker.h b/r5dev/thirdparty/protobuf/util/internal/location_tracker.h index 88657cc6..e919fee4 100644 --- a/r5dev/thirdparty/protobuf/util/internal/location_tracker.h +++ b/r5dev/thirdparty/protobuf/util/internal/location_tracker.h @@ -28,13 +28,14 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_LOCATION_TRACKER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_LOCATION_TRACKER_H__ #include <string> #include <thirdparty/protobuf/stubs/common.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -66,4 +67,4 @@ class PROTOBUF_EXPORT LocationTrackerInterface { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_LOCATION_TRACKER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/mock_error_listener.h b/r5dev/thirdparty/protobuf/util/internal/mock_error_listener.h index 2ba42ed9..a9eb9092 100644 --- a/r5dev/thirdparty/protobuf/util/internal/mock_error_listener.h +++ b/r5dev/thirdparty/protobuf/util/internal/mock_error_listener.h @@ -28,13 +28,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_MOCK_ERROR_LISTENER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_MOCK_ERROR_LISTENER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_MOCK_ERROR_LISTENER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_MOCK_ERROR_LISTENER_H__ -#include <thirdparty/protobuf/util/internal/error_listener.h> -#include <thirdparty/protobuf/util/internal/location_tracker.h> #include <gmock/gmock.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/util/internal/error_listener.h> +#include <thirdparty/protobuf/util/internal/location_tracker.h> namespace google { namespace protobuf { @@ -44,7 +44,7 @@ namespace converter { class MockErrorListener : public ErrorListener { public: MockErrorListener() {} - virtual ~MockErrorListener() {} + ~MockErrorListener() override {} MOCK_METHOD(void, InvalidName, (const LocationTrackerInterface& loc, @@ -65,4 +65,4 @@ class MockErrorListener : public ErrorListener { } // namespace protobuf } // namespace google -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_MOCK_ERROR_LISTENER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_MOCK_ERROR_LISTENER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/object_location_tracker.h b/r5dev/thirdparty/protobuf/util/internal/object_location_tracker.h index 05e41687..45878fd5 100644 --- a/r5dev/thirdparty/protobuf/util/internal/object_location_tracker.h +++ b/r5dev/thirdparty/protobuf/util/internal/object_location_tracker.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_LOCATION_TRACKER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_LOCATION_TRACKER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_LOCATION_TRACKER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_LOCATION_TRACKER_H__ #include <string> @@ -61,4 +61,4 @@ class ObjectLocationTracker : public LocationTrackerInterface { } // namespace protobuf } // namespace google -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_LOCATION_TRACKER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_LOCATION_TRACKER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/object_source.h b/r5dev/thirdparty/protobuf/util/internal/object_source.h index dfb13eb4..2ef5bbcb 100644 --- a/r5dev/thirdparty/protobuf/util/internal/object_source.h +++ b/r5dev/thirdparty/protobuf/util/internal/object_source.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_SOURCE_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_SOURCE_H__ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/status.h> @@ -82,4 +82,4 @@ class PROTOBUF_EXPORT ObjectSource { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_SOURCE_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/object_writer.h b/r5dev/thirdparty/protobuf/util/internal/object_writer.h index d27de42c..0297498e 100644 --- a/r5dev/thirdparty/protobuf/util/internal/object_writer.h +++ b/r5dev/thirdparty/protobuf/util/internal/object_writer.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_WRITER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_WRITER_H__ #include <cstdint> @@ -148,4 +148,4 @@ class PROTOBUF_EXPORT ObjectWriter { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_WRITER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/proto_writer.cc b/r5dev/thirdparty/protobuf/util/internal/proto_writer.cc index 2dcc536d..43e3cf94 100644 --- a/r5dev/thirdparty/protobuf/util/internal/proto_writer.cc +++ b/r5dev/thirdparty/protobuf/util/internal/proto_writer.cc @@ -33,19 +33,21 @@ #include <cstdint> #include <functional> #include <stack> +#include <unordered_set> #include <thirdparty/protobuf/stubs/once.h> #include <thirdparty/protobuf/wire_format_lite.h> -#include <thirdparty/protobuf/util/internal/field_mask_utility.h> -#include <thirdparty/protobuf/util/internal/object_location_tracker.h> -#include <thirdparty/protobuf/util/internal/constants.h> -#include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/statusor.h> #include <thirdparty/protobuf/stubs/time.h> +#include <thirdparty/protobuf/util/internal/constants.h> +#include <thirdparty/protobuf/util/internal/field_mask_utility.h> +#include <thirdparty/protobuf/util/internal/object_location_tracker.h> +#include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/stubs/map_util.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -269,9 +271,9 @@ inline util::Status WriteString(int field_number, const DataPiece& data, } // Given a google::protobuf::Type, returns the set of all required fields. -std::set<const google::protobuf::Field*> GetRequiredFields( +std::unordered_set<const google::protobuf::Field*> GetRequiredFields( const google::protobuf::Type& type) { - std::set<const google::protobuf::Field*> required; + std::unordered_set<const google::protobuf::Field*> required; for (int i = 0; i < type.fields_size(); i++) { const google::protobuf::Field& field = type.fields(i); if (field.cardinality() == google::protobuf::Field::CARDINALITY_REQUIRED) { @@ -346,7 +348,7 @@ ProtoWriter::ProtoElement* ProtoWriter::ProtoElement::pop() { if (!proto3_) { // Calls the registered error listener for any required field(s) not yet // seen. - for (std::set<const google::protobuf::Field*>::iterator it = + for (std::unordered_set<const google::protobuf::Field*>::iterator it = required_fields_.begin(); it != required_fields_.end(); ++it) { ow_->MissingField(ow_->use_json_name_in_missing_fields_ diff --git a/r5dev/thirdparty/protobuf/util/internal/proto_writer.h b/r5dev/thirdparty/protobuf/util/internal/proto_writer.h index ed5fd4a1..5d129fe4 100644 --- a/r5dev/thirdparty/protobuf/util/internal/proto_writer.h +++ b/r5dev/thirdparty/protobuf/util/internal/proto_writer.h @@ -28,12 +28,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTO_WRITER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTO_WRITER_H__ #include <cstdint> #include <deque> #include <string> +#include <unordered_set> #include <vector> #include <thirdparty/protobuf/stubs/common.h> @@ -41,13 +42,13 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/util/internal/type_info.h> +#include <thirdparty/protobuf/stubs/bytestream.h> +#include <thirdparty/protobuf/stubs/status.h> #include <thirdparty/protobuf/util/internal/datapiece.h> #include <thirdparty/protobuf/util/internal/error_listener.h> #include <thirdparty/protobuf/util/internal/structured_objectwriter.h> +#include <thirdparty/protobuf/util/internal/type_info.h> #include <thirdparty/protobuf/util/type_resolver.h> -#include <thirdparty/protobuf/stubs/bytestream.h> -#include <thirdparty/protobuf/stubs/status.h> #include <thirdparty/protobuf/stubs/hash.h> #include <thirdparty/protobuf/stubs/status.h> @@ -235,7 +236,7 @@ class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { // size_index_ : index into ProtoWriter::size_insert_ // for later insertion of serialized message length. const google::protobuf::Type& type_; - std::set<const google::protobuf::Field*> required_fields_; + std::unordered_set<const google::protobuf::Field*> required_fields_; const int size_index_; // Tracks position in repeated fields, needed for LocationTrackerInterface. @@ -385,4 +386,4 @@ class PROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTO_WRITER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/protostream_objectsource.cc b/r5dev/thirdparty/protobuf/util/internal/protostream_objectsource.cc index d5317869..6674811e 100644 --- a/r5dev/thirdparty/protobuf/util/internal/protostream_objectsource.cc +++ b/r5dev/thirdparty/protobuf/util/internal/protostream_objectsource.cc @@ -36,7 +36,6 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/descriptor.h> @@ -44,19 +43,22 @@ #include <thirdparty/protobuf/unknown_field_set.h> #include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/wire_format_lite.h> -#include <thirdparty/protobuf/util/internal/field_mask_utility.h> -#include <thirdparty/protobuf/util/internal/constants.h> -#include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/casts.h> #include <thirdparty/protobuf/stubs/status.h> +#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/stubs/time.h> +#include <thirdparty/protobuf/util/internal/constants.h> +#include <thirdparty/protobuf/util/internal/field_mask_utility.h> +#include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/stubs/map_util.h> #include <thirdparty/protobuf/stubs/status_macros.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> + namespace google { namespace protobuf { namespace util { @@ -782,7 +784,7 @@ util::Status ProtoStreamObjectSource::RenderNonMessageField( } case google::protobuf::Field::TYPE_INT64: { stream_->ReadVarint64(&buffer64); - ow->RenderInt64(field_name, bit_cast<int64>(buffer64)); + ow->RenderInt64(field_name, bit_cast<int64_t>(buffer64)); break; } case google::protobuf::Field::TYPE_UINT32: { @@ -792,7 +794,7 @@ util::Status ProtoStreamObjectSource::RenderNonMessageField( } case google::protobuf::Field::TYPE_UINT64: { stream_->ReadVarint64(&buffer64); - ow->RenderUint64(field_name, bit_cast<uint64>(buffer64)); + ow->RenderUint64(field_name, bit_cast<uint64_t>(buffer64)); break; } case google::protobuf::Field::TYPE_SINT32: { @@ -812,7 +814,7 @@ util::Status ProtoStreamObjectSource::RenderNonMessageField( } case google::protobuf::Field::TYPE_SFIXED64: { stream_->ReadLittleEndian64(&buffer64); - ow->RenderInt64(field_name, bit_cast<int64>(buffer64)); + ow->RenderInt64(field_name, bit_cast<int64_t>(buffer64)); break; } case google::protobuf::Field::TYPE_FIXED32: { @@ -822,7 +824,7 @@ util::Status ProtoStreamObjectSource::RenderNonMessageField( } case google::protobuf::Field::TYPE_FIXED64: { stream_->ReadLittleEndian64(&buffer64); - ow->RenderUint64(field_name, bit_cast<uint64>(buffer64)); + ow->RenderUint64(field_name, bit_cast<uint64_t>(buffer64)); break; } case google::protobuf::Field::TYPE_FLOAT: { @@ -1096,11 +1098,11 @@ const std::string FormatNanos(uint32_t nanos, bool with_trailing_zeros) { return with_trailing_zeros ? ".000" : ""; } - const char* format = (nanos % 1000 != 0) ? "%.9f" - : (nanos % 1000000 != 0) ? "%.6f" - : "%.3f"; - std::string formatted = - StringPrintf(format, static_cast<double>(nanos) / kNanosPerSecond); + const int precision = (nanos % 1000 != 0) ? 9 + : (nanos % 1000000 != 0) ? 6 + : 3; + std::string formatted = StringPrintf( + "%.*f", precision, static_cast<double>(nanos) / kNanosPerSecond); // remove the leading 0 before decimal. return formatted.substr(1); } diff --git a/r5dev/thirdparty/protobuf/util/internal/protostream_objectsource.h b/r5dev/thirdparty/protobuf/util/internal/protostream_objectsource.h index 7ec60a4b..a825922f 100644 --- a/r5dev/thirdparty/protobuf/util/internal/protostream_objectsource.h +++ b/r5dev/thirdparty/protobuf/util/internal/protostream_objectsource.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTSOURCE_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTSOURCE_H__ #include <cstdint> #include <functional> @@ -40,16 +40,17 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/type.pb.h> -#include <thirdparty/protobuf/util/internal/type_info.h> -#include <thirdparty/protobuf/util/internal/object_source.h> -#include <thirdparty/protobuf/util/internal/object_writer.h> -#include <thirdparty/protobuf/util/type_resolver.h> #include <thirdparty/protobuf/stubs/statusor.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/util/internal/object_source.h> +#include <thirdparty/protobuf/util/internal/object_writer.h> +#include <thirdparty/protobuf/util/internal/type_info.h> +#include <thirdparty/protobuf/util/type_resolver.h> #include <thirdparty/protobuf/stubs/hash.h> #include <thirdparty/protobuf/stubs/status.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -325,4 +326,4 @@ class PROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTSOURCE_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/protostream_objectsource_test.cc b/r5dev/thirdparty/protobuf/util/internal/protostream_objectsource_test.cc index c5e59be5..ef689552 100644 --- a/r5dev/thirdparty/protobuf/util/internal/protostream_objectsource_test.cc +++ b/r5dev/thirdparty/protobuf/util/internal/protostream_objectsource_test.cc @@ -46,11 +46,11 @@ #include <thirdparty/protobuf/util/internal/testdata/proto3.pb.h> #include <thirdparty/protobuf/util/internal/testdata/struct.pb.h> #include <thirdparty/protobuf/util/internal/testdata/timestamp_duration.pb.h> -#include <thirdparty/protobuf/util/internal/type_info_test_helper.h> -#include <thirdparty/protobuf/util/internal/constants.h> #include <gtest/gtest.h> #include <thirdparty/protobuf/stubs/casts.h> #include <thirdparty/protobuf/stubs/status.h> +#include <thirdparty/protobuf/util/internal/constants.h> +#include <thirdparty/protobuf/util/internal/type_info_test_helper.h> namespace google { @@ -103,7 +103,7 @@ class ProtostreamObjectSourceTest helper_.ResetTypeInfo(Book::descriptor(), Proto3Message::descriptor()); } - virtual ~ProtostreamObjectSourceTest() {} + ~ProtostreamObjectSourceTest() override {} void DoTest(const Message& msg, const Descriptor* descriptor) { util::Status status = ExecuteTest(msg, descriptor); diff --git a/r5dev/thirdparty/protobuf/util/internal/protostream_objectwriter.cc b/r5dev/thirdparty/protobuf/util/internal/protostream_objectwriter.cc index 91e173eb..edae02a3 100644 --- a/r5dev/thirdparty/protobuf/util/internal/protostream_objectwriter.cc +++ b/r5dev/thirdparty/protobuf/util/internal/protostream_objectwriter.cc @@ -38,17 +38,18 @@ #include <thirdparty/protobuf/stubs/once.h> #include <thirdparty/protobuf/wire_format_lite.h> -#include <thirdparty/protobuf/util/internal/field_mask_utility.h> -#include <thirdparty/protobuf/util/internal/object_location_tracker.h> -#include <thirdparty/protobuf/util/internal/constants.h> -#include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/status.h> #include <thirdparty/protobuf/stubs/statusor.h> #include <thirdparty/protobuf/stubs/time.h> +#include <thirdparty/protobuf/util/internal/constants.h> +#include <thirdparty/protobuf/util/internal/field_mask_utility.h> +#include <thirdparty/protobuf/util/internal/object_location_tracker.h> +#include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/stubs/map_util.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -56,9 +57,9 @@ namespace protobuf { namespace util { namespace converter { +using util::Status; using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite; using std::placeholders::_1; -using util::Status; ProtoStreamObjectWriter::ProtoStreamObjectWriter( @@ -139,7 +140,7 @@ Status GetNanosFromStringPiece(StringPiece s_nanos, } int32_t i_nanos = 0; // 's_nanos' contains fractional seconds -- i.e. 'nanos' is equal to - // "0." + s_nanos.ToString() seconds. An int32 is used for the + // "0." + s_nanos.ToString() seconds. An int32_t is used for the // conversion to 'nanos', rather than a double, so that there is no // loss of precision. if (!s_nanos.empty() && !safe_strto32(s_nanos, &i_nanos)) { @@ -158,7 +159,7 @@ Status GetNanosFromStringPiece(StringPiece s_nanos, // point in "0." + s_nanos.ToString() int32_t scale = num_leading_zeros + s_nanos.size(); // 'conversion' converts i_nanos into nanoseconds. - // conversion = kNanosPerSecond / static_cast<int32>(std::pow(10, scale)) + // conversion = kNanosPerSecond / static_cast<int32_t>(std::pow(10, scale)) // For efficiency, we precompute the conversion factor. int32_t conversion = 0; switch (scale) { @@ -502,7 +503,7 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::StartObject( // stream, we write those values. if (master_type_.name() == kStructType) { // Struct has a map<string, Value> field called "fields". - // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto + // https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/struct.proto // "fields": [ Push("fields", Item::MAP, true, true); return this; @@ -513,7 +514,7 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::StartObject( // object within that type is a struct type. So start a struct. // // The struct field in Value type is named "struct_value" - // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto + // https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/struct.proto // Also start the map field "fields" within the struct. // "struct_value": { // "fields": [ @@ -702,7 +703,7 @@ ProtoStreamObjectWriter* ProtoStreamObjectWriter::StartList( // we have to start the "list_value" within google.protobuf.Value. // // See - // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto + // https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/struct.proto // // Render // "<name>": { @@ -1031,8 +1032,8 @@ Status ProtoStreamObjectWriter::RenderTimestamp(ProtoStreamObjectWriter* ow, StringPiece value(data.str()); - int64 seconds; - int32 nanos; + int64_t seconds; + int32_t nanos; if (!::google::protobuf::internal::ParseTime(value.ToString(), &seconds, &nanos)) { return util::InvalidArgumentError(StrCat("Invalid time format: ", value)); diff --git a/r5dev/thirdparty/protobuf/util/internal/protostream_objectwriter.h b/r5dev/thirdparty/protobuf/util/internal/protostream_objectwriter.h index e699113c..5b0b916c 100644 --- a/r5dev/thirdparty/protobuf/util/internal/protostream_objectwriter.h +++ b/r5dev/thirdparty/protobuf/util/internal/protostream_objectwriter.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTWRITER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTWRITER_H__ #include <deque> #include <string> @@ -41,16 +41,17 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/util/internal/type_info.h> +#include <thirdparty/protobuf/stubs/bytestream.h> +#include <thirdparty/protobuf/stubs/status.h> #include <thirdparty/protobuf/util/internal/datapiece.h> #include <thirdparty/protobuf/util/internal/error_listener.h> #include <thirdparty/protobuf/util/internal/proto_writer.h> #include <thirdparty/protobuf/util/internal/structured_objectwriter.h> +#include <thirdparty/protobuf/util/internal/type_info.h> #include <thirdparty/protobuf/util/type_resolver.h> -#include <thirdparty/protobuf/stubs/bytestream.h> -#include <thirdparty/protobuf/stubs/status.h> #include <thirdparty/protobuf/stubs/hash.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -449,4 +450,4 @@ class PROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_PROTOSTREAM_OBJECTWRITER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/protostream_objectwriter_test.cc b/r5dev/thirdparty/protobuf/util/internal/protostream_objectwriter_test.cc index a53bf825..161f2b7e 100644 --- a/r5dev/thirdparty/protobuf/util/internal/protostream_objectwriter_test.cc +++ b/r5dev/thirdparty/protobuf/util/internal/protostream_objectwriter_test.cc @@ -38,8 +38,6 @@ #include <thirdparty/protobuf/wrappers.pb.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> #include <thirdparty/protobuf/descriptor.pb.h> -#include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/dynamic_message.h> #include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/util/internal/mock_error_listener.h> #include <thirdparty/protobuf/util/internal/testdata/anys.pb.h> @@ -51,13 +49,15 @@ #include <thirdparty/protobuf/util/internal/testdata/struct.pb.h> #include <thirdparty/protobuf/util/internal/testdata/timestamp_duration.pb.h> #include <thirdparty/protobuf/util/internal/testdata/wrappers.pb.h> -#include <thirdparty/protobuf/util/internal/type_info_test_helper.h> -#include <thirdparty/protobuf/util/internal/constants.h> -#include <thirdparty/protobuf/util/message_differencer.h> -#include <thirdparty/protobuf/util/type_resolver_util.h> #include <thirdparty/protobuf/stubs/bytestream.h> #include <thirdparty/protobuf/stubs/strutil.h> #include <gtest/gtest.h> +#include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/dynamic_message.h> +#include <thirdparty/protobuf/util/internal/constants.h> +#include <thirdparty/protobuf/util/internal/type_info_test_helper.h> +#include <thirdparty/protobuf/util/message_differencer.h> +#include <thirdparty/protobuf/util/type_resolver_util.h> namespace google { @@ -134,7 +134,7 @@ class BaseProtoStreamObjectWriterTest ResetTypeInfo(descriptors); } - virtual ~BaseProtoStreamObjectWriterTest() {} + ~BaseProtoStreamObjectWriterTest() override {} void CheckOutput(const Message& expected, int expected_length) { size_t nbytes; @@ -178,7 +178,7 @@ class ProtoStreamObjectWriterTest : public BaseProtoStreamObjectWriterTest { void ResetProtoWriter() { ResetTypeInfo(Book::descriptor()); } - virtual ~ProtoStreamObjectWriterTest() {} + ~ProtoStreamObjectWriterTest() override {} }; INSTANTIATE_TEST_SUITE_P(DifferentTypeInfoSourceTest, diff --git a/r5dev/thirdparty/protobuf/util/internal/structured_objectwriter.h b/r5dev/thirdparty/protobuf/util/internal/structured_objectwriter.h index 10ebe4fc..0b5713ed 100644 --- a/r5dev/thirdparty/protobuf/util/internal/structured_objectwriter.h +++ b/r5dev/thirdparty/protobuf/util/internal/structured_objectwriter.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_STRUCTURED_OBJECTWRITER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_STRUCTURED_OBJECTWRITER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_STRUCTURED_OBJECTWRITER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_STRUCTURED_OBJECTWRITER_H__ #include <memory> @@ -37,6 +37,7 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/util/internal/object_writer.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -57,7 +58,7 @@ namespace converter { // Derived classes could be thread-unsafe. class PROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter { public: - virtual ~StructuredObjectWriter() {} + ~StructuredObjectWriter() override {} protected: // A base element class for subclasses to extend, makes tracking state easier. @@ -117,4 +118,4 @@ class PROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_STRUCTURED_OBJECTWRITER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_STRUCTURED_OBJECTWRITER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/type_info.cc b/r5dev/thirdparty/protobuf/util/internal/type_info.cc index 7e37a222..1d8422cc 100644 --- a/r5dev/thirdparty/protobuf/util/internal/type_info.cc +++ b/r5dev/thirdparty/protobuf/util/internal/type_info.cc @@ -35,10 +35,10 @@ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/type.pb.h> -#include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/stubs/status.h> #include <thirdparty/protobuf/stubs/statusor.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/util/internal/utility.h> #include <thirdparty/protobuf/stubs/map_util.h> #include <thirdparty/protobuf/stubs/status.h> @@ -54,7 +54,7 @@ class TypeInfoForTypeResolver : public TypeInfo { explicit TypeInfoForTypeResolver(TypeResolver* type_resolver) : type_resolver_(type_resolver) {} - virtual ~TypeInfoForTypeResolver() { + ~TypeInfoForTypeResolver() override { DeleteCachedTypes(&cached_types_); DeleteCachedTypes(&cached_enums_); } diff --git a/r5dev/thirdparty/protobuf/util/internal/type_info.h b/r5dev/thirdparty/protobuf/util/internal/type_info.h index 875e0340..06dc8b0a 100644 --- a/r5dev/thirdparty/protobuf/util/internal/type_info.h +++ b/r5dev/thirdparty/protobuf/util/internal/type_info.h @@ -28,14 +28,14 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_TYPE_INFO_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_TYPE_INFO_H__ #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/type.pb.h> -#include <thirdparty/protobuf/util/type_resolver.h> #include <thirdparty/protobuf/stubs/statusor.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/util/type_resolver.h> #include <thirdparty/protobuf/stubs/status.h> // Must be included last. @@ -94,4 +94,4 @@ class PROTOBUF_EXPORT TypeInfo { #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_TYPE_INFO_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/type_info_test_helper.cc b/r5dev/thirdparty/protobuf/util/internal/type_info_test_helper.cc index 8b1a8799..c43fa9bc 100644 --- a/r5dev/thirdparty/protobuf/util/internal/type_info_test_helper.cc +++ b/r5dev/thirdparty/protobuf/util/internal/type_info_test_helper.cc @@ -36,11 +36,11 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/util/internal/default_value_objectwriter.h> -#include <thirdparty/protobuf/util/internal/type_info.h> #include <thirdparty/protobuf/util/internal/constants.h> +#include <thirdparty/protobuf/util/internal/default_value_objectwriter.h> #include <thirdparty/protobuf/util/internal/protostream_objectsource.h> #include <thirdparty/protobuf/util/internal/protostream_objectwriter.h> +#include <thirdparty/protobuf/util/internal/type_info.h> #include <thirdparty/protobuf/util/type_resolver.h> #include <thirdparty/protobuf/util/type_resolver_util.h> diff --git a/r5dev/thirdparty/protobuf/util/internal/type_info_test_helper.h b/r5dev/thirdparty/protobuf/util/internal/type_info_test_helper.h index 77fa1d57..9f4391a0 100644 --- a/r5dev/thirdparty/protobuf/util/internal/type_info_test_helper.h +++ b/r5dev/thirdparty/protobuf/util/internal/type_info_test_helper.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_TEST_HELPER_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_TEST_HELPER_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_TYPE_INFO_TEST_HELPER_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_TYPE_INFO_TEST_HELPER_H__ #include <memory> #include <vector> @@ -37,9 +37,9 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/util/internal/default_value_objectwriter.h> -#include <thirdparty/protobuf/util/internal/type_info.h> #include <thirdparty/protobuf/util/internal/protostream_objectsource.h> #include <thirdparty/protobuf/util/internal/protostream_objectwriter.h> +#include <thirdparty/protobuf/util/internal/type_info.h> #include <thirdparty/protobuf/util/type_resolver.h> namespace google { @@ -93,4 +93,4 @@ class TypeInfoTestHelper { } // namespace protobuf } // namespace google -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_TEST_HELPER_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_TYPE_INFO_TEST_HELPER_H__ diff --git a/r5dev/thirdparty/protobuf/util/internal/utility.cc b/r5dev/thirdparty/protobuf/util/internal/utility.cc index 893dfc73..bd7355d0 100644 --- a/r5dev/thirdparty/protobuf/util/internal/utility.cc +++ b/r5dev/thirdparty/protobuf/util/internal/utility.cc @@ -41,8 +41,8 @@ #include <thirdparty/protobuf/wrappers.pb.h> #include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/util/internal/constants.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/util/internal/constants.h> #include <thirdparty/protobuf/stubs/map_util.h> // clang-format off diff --git a/r5dev/thirdparty/protobuf/util/internal/utility.h b/r5dev/thirdparty/protobuf/util/internal/utility.h index 97da15d4..1fc3c14f 100644 --- a/r5dev/thirdparty/protobuf/util/internal/utility.h +++ b/r5dev/thirdparty/protobuf/util/internal/utility.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__ -#define GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__ +#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_UTILITY_H__ +#define GOOGLE_PROTOBUF_UTIL_INTERNAL_UTILITY_H__ #include <cstdint> #include <memory> @@ -201,4 +201,4 @@ PROTOBUF_EXPORT bool SafeStrToFloat(StringPiece str, float* value); #include <thirdparty/protobuf/port_undef.inc> -#endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__ +#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_UTILITY_H__ diff --git a/r5dev/thirdparty/protobuf/util/json_util.cc b/r5dev/thirdparty/protobuf/util/json_util.cc index dc7c08a1..5ecd7321 100644 --- a/r5dev/thirdparty/protobuf/util/json_util.cc +++ b/r5dev/thirdparty/protobuf/util/json_util.cc @@ -31,9 +31,12 @@ #include <thirdparty/protobuf/util/json_util.h> #include <thirdparty/protobuf/stubs/common.h> +#include <thirdparty/protobuf/stubs/once.h> +#include <thirdparty/protobuf/stubs/status.h> +#include <thirdparty/protobuf/stubs/bytestream.h> +#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> -#include <thirdparty/protobuf/stubs/once.h> #include <thirdparty/protobuf/util/internal/default_value_objectwriter.h> #include <thirdparty/protobuf/util/internal/error_listener.h> #include <thirdparty/protobuf/util/internal/json_objectwriter.h> @@ -42,9 +45,6 @@ #include <thirdparty/protobuf/util/internal/protostream_objectwriter.h> #include <thirdparty/protobuf/util/type_resolver.h> #include <thirdparty/protobuf/util/type_resolver_util.h> -#include <thirdparty/protobuf/stubs/bytestream.h> -#include <thirdparty/protobuf/stubs/status.h> -#include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/status_macros.h> // clang-format off @@ -64,7 +64,7 @@ ZeroCopyStreamByteSink::~ZeroCopyStreamByteSink() { void ZeroCopyStreamByteSink::Append(const char* bytes, size_t len) { while (true) { - if (len <= buffer_size_) { + if (len <= buffer_size_) { // NOLINT memcpy(buffer_, bytes, len); buffer_ = static_cast<char*>(buffer_) + len; buffer_size_ -= len; @@ -218,7 +218,7 @@ util::Status JsonToBinaryString(TypeResolver* resolver, namespace { const char* kTypeUrlPrefix = "type.googleapis.com"; -TypeResolver* generated_type_resolver_ = NULL; +TypeResolver* generated_type_resolver_ = nullptr; PROTOBUF_NAMESPACE_ID::internal::once_flag generated_type_resolver_init_; std::string GetTypeUrl(const Message& message) { @@ -226,7 +226,9 @@ std::string GetTypeUrl(const Message& message) { message.GetDescriptor()->full_name(); } -void DeleteGeneratedTypeResolver() { delete generated_type_resolver_; } +void DeleteGeneratedTypeResolver() { // NOLINT + delete generated_type_resolver_; +} void InitGeneratedTypeResolver() { generated_type_resolver_ = NewTypeResolverForDescriptorPool( diff --git a/r5dev/thirdparty/protobuf/util/json_util.h b/r5dev/thirdparty/protobuf/util/json_util.h index 861187fd..37d0c17b 100644 --- a/r5dev/thirdparty/protobuf/util/json_util.h +++ b/r5dev/thirdparty/protobuf/util/json_util.h @@ -33,12 +33,13 @@ #ifndef GOOGLE_PROTOBUF_UTIL_JSON_UTIL_H__ #define GOOGLE_PROTOBUF_UTIL_JSON_UTIL_H__ -#include <thirdparty/protobuf/message.h> -#include <thirdparty/protobuf/util/type_resolver.h> #include <thirdparty/protobuf/stubs/bytestream.h> #include <thirdparty/protobuf/stubs/status.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/message.h> +#include <thirdparty/protobuf/util/type_resolver.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -61,8 +62,7 @@ struct JsonParseOptions { bool case_insensitive_enum_parsing; JsonParseOptions() - : ignore_unknown_fields(false), - case_insensitive_enum_parsing(false) {} + : ignore_unknown_fields(false), case_insensitive_enum_parsing(false) {} }; struct JsonPrintOptions { @@ -181,8 +181,8 @@ namespace internal { class PROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink { public: explicit ZeroCopyStreamByteSink(io::ZeroCopyOutputStream* stream) - : stream_(stream), buffer_(NULL), buffer_size_(0) {} - ~ZeroCopyStreamByteSink(); + : stream_(stream), buffer_(nullptr), buffer_size_(0) {} + ~ZeroCopyStreamByteSink() override; void Append(const char* bytes, size_t len) override; diff --git a/r5dev/thirdparty/protobuf/util/json_util_test.cc b/r5dev/thirdparty/protobuf/util/json_util_test.cc index 08d42eef..36b62e68 100644 --- a/r5dev/thirdparty/protobuf/util/json_util_test.cc +++ b/r5dev/thirdparty/protobuf/util/json_util_test.cc @@ -34,16 +34,16 @@ #include <list> #include <string> -#include <thirdparty/protobuf/io/zero_copy_stream.h> -#include <thirdparty/protobuf/io/zero_copy_stream_impl.h> -#include <thirdparty/protobuf/descriptor_database.h> -#include <thirdparty/protobuf/dynamic_message.h> #include <thirdparty/protobuf/util/internal/testdata/maps.pb.h> #include <thirdparty/protobuf/util/json_format.pb.h> #include <thirdparty/protobuf/util/json_format_proto3.pb.h> +#include <gtest/gtest.h> +#include <thirdparty/protobuf/descriptor_database.h> +#include <thirdparty/protobuf/dynamic_message.h> +#include <thirdparty/protobuf/io/zero_copy_stream.h> +#include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/util/type_resolver.h> #include <thirdparty/protobuf/util/type_resolver_util.h> -#include <gtest/gtest.h> namespace google { namespace protobuf { @@ -265,7 +265,9 @@ TEST_F(JsonUtilTest, ParseMessage) { // functions are working properly. std::string input = "{\n" - " \"int32Value\": 1024,\n" + " \"int32Value\": 1234567891,\n" + " \"int64Value\": 5302428716536692736,\n" + " \"floatValue\": 3.4028235e+38,\n" " \"repeatedInt32Value\": [1, 2],\n" " \"messageValue\": {\n" " \"value\": 2048\n" @@ -277,7 +279,9 @@ TEST_F(JsonUtilTest, ParseMessage) { JsonParseOptions options; TestMessage m; ASSERT_TRUE(FromJson(input, &m, options)); - EXPECT_EQ(1024, m.int32_value()); + EXPECT_EQ(1234567891, m.int32_value()); + EXPECT_EQ(5302428716536692736, m.int64_value()); + EXPECT_EQ(3.402823466e+38f, m.float_value()); ASSERT_EQ(2, m.repeated_int32_value_size()); EXPECT_EQ(1, m.repeated_int32_value(0)); EXPECT_EQ(2, m.repeated_int32_value(1)); diff --git a/r5dev/thirdparty/protobuf/util/message_differencer.cc b/r5dev/thirdparty/protobuf/util/message_differencer.cc index aa43b75c..91696bdf 100644 --- a/r5dev/thirdparty/protobuf/util/message_differencer.cc +++ b/r5dev/thirdparty/protobuf/util/message_differencer.cc @@ -44,7 +44,6 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/io/printer.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> @@ -55,8 +54,9 @@ #include <thirdparty/protobuf/map_field.h> #include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/text_format.h> -#include <thirdparty/protobuf/util/field_comparator.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/stubs/stringprintf.h> +#include <thirdparty/protobuf/util/field_comparator.h> // Always include as last one, otherwise it can break compilation #include <thirdparty/protobuf/port_def.inc> @@ -66,6 +66,26 @@ namespace protobuf { namespace util { +namespace { + +std::string PrintShortTextFormat(const google::protobuf::Message& message) { + std::string debug_string; + + google::protobuf::TextFormat::Printer printer; + printer.SetSingleLineMode(true); + printer.SetExpandAny(true); + + printer.PrintToString(message, &debug_string); + // Single line mode currently might have an extra space at the end. + if (!debug_string.empty() && debug_string[debug_string.size() - 1] == ' ') { + debug_string.resize(debug_string.size() - 1); + } + + return debug_string; +} + +} // namespace + // A reporter to report the total number of diffs. // TODO(ykzhu): we can improve this to take into account the value differencers. class NumDiffsReporter : public google::protobuf::util::MessageDifferencer::Reporter { @@ -331,9 +351,14 @@ void MessageDifferencer::set_message_field_comparison( message_field_comparison_ = comparison; } +MessageDifferencer::MessageFieldComparison +MessageDifferencer::message_field_comparison() const { + return message_field_comparison_; +} + void MessageDifferencer::set_scope(Scope scope) { scope_ = scope; } -MessageDifferencer::Scope MessageDifferencer::scope() { return scope_; } +MessageDifferencer::Scope MessageDifferencer::scope() const { return scope_; } void MessageDifferencer::set_float_comparison(FloatComparison comparison) { default_field_comparator_.set_float_comparison( @@ -347,7 +372,7 @@ void MessageDifferencer::set_repeated_field_comparison( } MessageDifferencer::RepeatedFieldComparison -MessageDifferencer::repeated_field_comparison() { +MessageDifferencer::repeated_field_comparison() const { return repeated_field_comparison_; } @@ -2007,14 +2032,13 @@ void MessageDifferencer::StreamReporter::PrintValue( if (field->is_map() && message1_ != nullptr && message2_ != nullptr) { fd = field_message.GetDescriptor()->field(1); if (fd->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - output = field_message.GetReflection() - ->GetMessage(field_message, fd) - .ShortDebugString(); + output = PrintShortTextFormat( + field_message.GetReflection()->GetMessage(field_message, fd)); } else { TextFormat::PrintFieldValueToString(field_message, fd, -1, &output); } } else { - output = field_message.ShortDebugString(); + output = PrintShortTextFormat(field_message); } if (output.empty()) { printer_->Print("{ }"); diff --git a/r5dev/thirdparty/protobuf/util/message_differencer.h b/r5dev/thirdparty/protobuf/util/message_differencer.h index e61a77c3..6dc42755 100644 --- a/r5dev/thirdparty/protobuf/util/message_differencer.h +++ b/r5dev/thirdparty/protobuf/util/message_differencer.h @@ -43,6 +43,7 @@ #ifndef GOOGLE_PROTOBUF_UTIL_MESSAGE_DIFFERENCER_H__ #define GOOGLE_PROTOBUF_UTIL_MESSAGE_DIFFERENCER_H__ + #include <functional> #include <map> #include <memory> @@ -222,16 +223,16 @@ class PROTOBUF_EXPORT MessageDifferencer { // itself and the second will be the actual field in the embedded message // that was added/deleted/modified. // Fields will be reported in PostTraversalOrder. - // For example, given following proto, if both baz and quux are changed. + // For example, given following proto, if both baz and mooo are changed. // foo { // bar { // baz: 1 - // quux: 2 + // mooo: 2 // } // } // ReportModified will be invoked with following order: - // 1. foo.bar.baz or foo.bar.quux - // 2. foo.bar.quux or foo.bar.baz + // 1. foo.bar.baz or foo.bar.mooo + // 2. foo.bar.mooo or foo.bar.baz // 2. foo.bar // 3. foo class PROTOBUF_EXPORT Reporter { @@ -544,6 +545,9 @@ class PROTOBUF_EXPORT MessageDifferencer { // to compare fields in messages. void set_message_field_comparison(MessageFieldComparison comparison); + // Returns the current message field comparison used in this differencer. + MessageFieldComparison message_field_comparison() const; + // Tells the differencer whether or not to report matches. This method must // be called before Compare. The default for a new differencer is false. void set_report_matches(bool report_matches) { @@ -567,7 +571,7 @@ class PROTOBUF_EXPORT MessageDifferencer { void set_scope(Scope scope); // Returns the current scope used by this differencer. - Scope scope(); + Scope scope() const; // DEPRECATED. Pass a DefaultFieldComparator instance instead. // Sets the type of comparison (as defined in the FloatComparison enumeration @@ -583,7 +587,7 @@ class PROTOBUF_EXPORT MessageDifferencer { void set_repeated_field_comparison(RepeatedFieldComparison comparison); // Returns the current repeated field comparison used by this differencer. - RepeatedFieldComparison repeated_field_comparison(); + RepeatedFieldComparison repeated_field_comparison() const; // Compares the two specified messages, returning true if they are the same, // false otherwise. If this method returns false, any changes between the diff --git a/r5dev/thirdparty/protobuf/util/message_differencer_unittest.cc b/r5dev/thirdparty/protobuf/util/message_differencer_unittest.cc index 1ee675fb..88a7e00e 100644 --- a/r5dev/thirdparty/protobuf/util/message_differencer_unittest.cc +++ b/r5dev/thirdparty/protobuf/util/message_differencer_unittest.cc @@ -70,7 +70,7 @@ const FieldDescriptor* GetFieldDescriptor(const Message& message, std::vector<std::string> field_path = Split(field_name, ".", true); const Descriptor* descriptor = message.GetDescriptor(); - const FieldDescriptor* field = NULL; + const FieldDescriptor* field = nullptr; for (int i = 0; i < field_path.size(); i++) { field = descriptor->FindFieldByName(field_path[i]); descriptor = field->message_type(); @@ -1034,9 +1034,9 @@ TEST(MessageDifferencerTest, desc->FindFieldByName("optional_int64"); const FieldDescriptor* default_int64_desc = desc->FindFieldByName("default_int64"); - ASSERT_TRUE(optional_int32_desc != NULL); - ASSERT_TRUE(optional_int64_desc != NULL); - ASSERT_TRUE(default_int64_desc != NULL); + ASSERT_TRUE(optional_int32_desc != nullptr); + ASSERT_TRUE(optional_int64_desc != nullptr); + ASSERT_TRUE(default_int64_desc != nullptr); msg1.set_optional_int32(0); msg2.set_optional_int64(0); msg1.set_default_int64(default_int64_desc->default_value_int64()); @@ -1860,11 +1860,10 @@ static const char* const kIgnoredFields[] = {"rm.b", "rm.m.b"}; class TestIgnorer : public util::MessageDifferencer::IgnoreCriteria { public: - virtual bool IsIgnored( - const Message& message1, const Message& message2, - const FieldDescriptor* field, - const std::vector<util::MessageDifferencer::SpecificField>& - parent_fields) { + bool IsIgnored(const Message& message1, const Message& message2, + const FieldDescriptor* field, + const std::vector<util::MessageDifferencer::SpecificField>& + parent_fields) override { std::string name = ""; for (int i = 0; i < parent_fields.size(); ++i) { name += parent_fields[i].field->name() + "."; @@ -1907,8 +1906,8 @@ class ValueProductMapKeyComparator : public util::MessageDifferencer::MapKeyComparator { public: typedef util::MessageDifferencer::SpecificField SpecificField; - virtual bool IsMatch(const Message& message1, const Message& message2, - const std::vector<SpecificField>& parent_fields) const { + bool IsMatch(const Message& message1, const Message& message2, + const std::vector<SpecificField>& parent_fields) const override { const Reflection* reflection1 = message1.GetReflection(); const Reflection* reflection2 = message2.GetReflection(); // FieldDescriptor for item.ra @@ -1968,8 +1967,8 @@ class OffsetByOneMapKeyComparator : public util::MessageDifferencer::MapKeyComparator { public: typedef util::MessageDifferencer::SpecificField SpecificField; - virtual bool IsMatch(const Message& message1, const Message& message2, - const std::vector<SpecificField>& parent_fields) const { + bool IsMatch(const Message& message1, const Message& message2, + const std::vector<SpecificField>& parent_fields) const override { return parent_fields.back().index + 1 == parent_fields.back().new_index; } }; @@ -2366,11 +2365,10 @@ class ParentSavingFieldComparator : public util::FieldComparator { public: ParentSavingFieldComparator() {} - virtual ComparisonResult Compare(const Message& message_1, - const Message& message_2, - const FieldDescriptor* field, int index_1, - int index_2, - const util::FieldContext* field_context) { + ComparisonResult Compare(const Message& message_1, const Message& message_2, + const FieldDescriptor* field, int index_1, + int index_2, + const util::FieldContext* field_context) override { if (field_context) parent_fields_ = *(field_context->parent_fields()); if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { return RECURSE; @@ -2423,7 +2421,7 @@ class ComparisonTest : public testing::Test { unknown2_ = empty2_.mutable_unknown_fields(); } - ~ComparisonTest() {} + ~ComparisonTest() override {} void SetSpecialFieldOption(const Message& message, util::MessageDifferencer* d) { @@ -3403,12 +3401,11 @@ class LengthMapKeyComparator : public util::MessageDifferencer::MapKeyComparator { public: typedef util::MessageDifferencer::SpecificField SpecificField; - virtual bool IsMatch(const Message& message1, const Message& message2, - const std::vector<SpecificField>& parent_fields) const { + bool IsMatch(const Message& message1, const Message& message2, + const std::vector<SpecificField>& parent_fields) const override { const Reflection* reflection1 = message1.GetReflection(); const Reflection* reflection2 = message2.GetReflection(); - const FieldDescriptor* key_field = - message1.GetDescriptor()->FindFieldByName("key"); + const FieldDescriptor* key_field = message1.GetDescriptor()->map_key(); return reflection1->GetString(message1, key_field).size() == reflection2->GetString(message2, key_field).size(); } @@ -3452,7 +3449,7 @@ class MatchingTest : public testing::Test { protected: MatchingTest() {} - ~MatchingTest() {} + ~MatchingTest() override {} std::string RunWithResult(MessageDifferencer* differencer, const Message& msg1, const Message& msg2, @@ -3717,7 +3714,7 @@ TEST_F(MatchingTest, MatchingWorksWithExtensions) { const FieldDescriptor* nested_key; descriptor = msg1.GetDescriptor()->file(); desc = descriptor->FindExtensionByName("repeated_nested_message_extension"); - ASSERT_FALSE(desc == NULL); + ASSERT_FALSE(desc == nullptr); nested_key = desc->message_type()->FindFieldByName("bb"); MessageDifferencer differencer; diff --git a/r5dev/thirdparty/protobuf/util/time_util.cc b/r5dev/thirdparty/protobuf/util/time_util.cc index 7c7c28dc..05a6c194 100644 --- a/r5dev/thirdparty/protobuf/util/time_util.cc +++ b/r5dev/thirdparty/protobuf/util/time_util.cc @@ -32,11 +32,11 @@ #include <cstdint> -#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/duration.pb.h> #include <thirdparty/protobuf/timestamp.pb.h> #include <thirdparty/protobuf/stubs/int128.h> +#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/stubs/time.h> // Must go after other includes. @@ -116,15 +116,15 @@ std::string FormatNanos(int32_t nanos) { } } -std::string FormatTime(int64 seconds, int32 nanos) { +std::string FormatTime(int64_t seconds, int32_t nanos) { return ::google::protobuf::internal::FormatTime(seconds, nanos); } -bool ParseTime(const std::string& value, int64* seconds, int32* nanos) { +bool ParseTime(const std::string& value, int64_t* seconds, int32_t* nanos) { return ::google::protobuf::internal::ParseTime(value, seconds, nanos); } -void CurrentTime(int64* seconds, int32* nanos) { +void CurrentTime(int64_t* seconds, int32_t* nanos) { return ::google::protobuf::internal::GetCurrentTime(seconds, nanos); } @@ -207,7 +207,7 @@ bool TimeUtil::FromString(const std::string& value, Duration* duration) { return false; } bool negative = (value[0] == '-'); - int sign_length = (negative ? 1 : 0); + size_t sign_length = (negative ? 1 : 0); // Parse the duration value as two integers rather than a float value // to avoid precision loss. std::string seconds_part, nanos_part; @@ -228,7 +228,7 @@ bool TimeUtil::FromString(const std::string& value, Duration* duration) { if (end != nanos_part.c_str() + nanos_part.length()) { return false; } - nanos = nanos * Pow(10, 9 - nanos_part.length()); + nanos = nanos * Pow(10, static_cast<int>(9 - nanos_part.length())); if (negative) { // If a Duration is negative, both seconds and nanos should be negative. seconds = -seconds; @@ -434,9 +434,12 @@ Duration& operator*=(Duration& d, int64_t r) { // NOLINT } Duration& operator*=(Duration& d, double r) { // NOLINT - double result = (d.seconds() * 1.0 + 1.0 * d.nanos() / kNanosPerSecond) * r; + double result = + (static_cast<double>(d.seconds()) + d.nanos() * (1.0 / kNanosPerSecond)) * + r; int64_t seconds = static_cast<int64_t>(result); - int32_t nanos = static_cast<int32_t>((result - seconds) * kNanosPerSecond); + int32_t nanos = static_cast<int32_t>((result - static_cast<double>(seconds)) * + kNanosPerSecond); // Note that we normalize here not just because nanos can have a different // sign from seconds but also that nanos can be any arbitrary value when // overflow happens (i.e., the result is a much larger value than what diff --git a/r5dev/thirdparty/protobuf/util/time_util.h b/r5dev/thirdparty/protobuf/util/time_util.h index e251ca83..ee3e04fe 100644 --- a/r5dev/thirdparty/protobuf/util/time_util.h +++ b/r5dev/thirdparty/protobuf/util/time_util.h @@ -40,8 +40,8 @@ #ifdef _MSC_VER #ifdef _XBOX_ONE struct timeval { - int64 tv_sec; /* seconds */ - int64 tv_usec; /* and microseconds */ + int64_t tv_sec; /* seconds */ + int64_t tv_usec; /* and microseconds */ }; #else #include <winsock2.h> @@ -53,6 +53,7 @@ struct timeval { #include <thirdparty/protobuf/duration.pb.h> #include <thirdparty/protobuf/timestamp.pb.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/util/time_util_test.cc b/r5dev/thirdparty/protobuf/util/time_util_test.cc index 333c83ee..536d2ad0 100644 --- a/r5dev/thirdparty/protobuf/util/time_util_test.cc +++ b/r5dev/thirdparty/protobuf/util/time_util_test.cc @@ -222,7 +222,7 @@ TEST(TestUtilTest, TimestampIntegerConversion) { } TEST(TimeUtilTest, TimeTConversion) { - time_t value = time(NULL); + time_t value = time(nullptr); EXPECT_EQ(value, TimeUtil::TimestampToTimeT(TimeUtil::TimeTToTimestamp(value))); EXPECT_EQ( diff --git a/r5dev/thirdparty/protobuf/util/type_resolver.h b/r5dev/thirdparty/protobuf/util/type_resolver.h index b540714c..8f29df69 100644 --- a/r5dev/thirdparty/protobuf/util/type_resolver.h +++ b/r5dev/thirdparty/protobuf/util/type_resolver.h @@ -40,6 +40,7 @@ #include <thirdparty/protobuf/stubs/status.h> #include <thirdparty/protobuf/stubs/status.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/util/type_resolver_util.cc b/r5dev/thirdparty/protobuf/util/type_resolver_util.cc index 401d3631..0bf3cbd9 100644 --- a/r5dev/thirdparty/protobuf/util/type_resolver_util.cc +++ b/r5dev/thirdparty/protobuf/util/type_resolver_util.cc @@ -34,10 +34,10 @@ #include <thirdparty/protobuf/wrappers.pb.h> #include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/descriptor.h> -#include <thirdparty/protobuf/util/internal/utility.h> -#include <thirdparty/protobuf/util/type_resolver.h> #include <thirdparty/protobuf/stubs/strutil.h> #include <thirdparty/protobuf/stubs/status.h> +#include <thirdparty/protobuf/util/internal/utility.h> +#include <thirdparty/protobuf/util/type_resolver.h> #include <thirdparty/protobuf/stubs/status.h> // clang-format off diff --git a/r5dev/thirdparty/protobuf/util/type_resolver_util.h b/r5dev/thirdparty/protobuf/util/type_resolver_util.h index 113b2cc8..9013853e 100644 --- a/r5dev/thirdparty/protobuf/util/type_resolver_util.h +++ b/r5dev/thirdparty/protobuf/util/type_resolver_util.h @@ -41,6 +41,7 @@ class DescriptorPool; namespace util { class TypeResolver; +// Must be included last. #include <thirdparty/protobuf/port_def.inc> // Creates a TypeResolver that serves type information in the given descriptor diff --git a/r5dev/thirdparty/protobuf/util/type_resolver_util_test.cc b/r5dev/thirdparty/protobuf/util/type_resolver_util_test.cc index 3d825d8e..9389d5ca 100644 --- a/r5dev/thirdparty/protobuf/util/type_resolver_util_test.cc +++ b/r5dev/thirdparty/protobuf/util/type_resolver_util_test.cc @@ -76,13 +76,13 @@ class DescriptorPoolTypeResolverTest : public testing::Test { return &field; } } - return NULL; + return nullptr; } bool HasField(const Type& type, Field::Cardinality cardinality, Field::Kind kind, const std::string& name, int number) { const Field* field = FindField(type, name); - if (field == NULL) { + if (field == nullptr) { return false; } return field->cardinality() == cardinality && field->kind() == kind && @@ -92,7 +92,7 @@ class DescriptorPoolTypeResolverTest : public testing::Test { bool CheckFieldTypeUrl(const Type& type, const std::string& name, const std::string& type_url) { const Field* field = FindField(type, name); - if (field == NULL) { + if (field == nullptr) { return false; } return field->type_url() == type_url; @@ -101,7 +101,7 @@ class DescriptorPoolTypeResolverTest : public testing::Test { bool FieldInOneof(const Type& type, const std::string& name, const std::string& oneof_name) { const Field* field = FindField(type, name); - if (field == NULL || field->oneof_index() <= 0 || + if (field == nullptr || field->oneof_index() <= 0 || field->oneof_index() > type.oneofs_size()) { return false; } @@ -110,7 +110,7 @@ class DescriptorPoolTypeResolverTest : public testing::Test { bool IsPacked(const Type& type, const std::string& name) { const Field* field = FindField(type, name); - if (field == NULL) { + if (field == nullptr) { return false; } return field->packed(); diff --git a/r5dev/thirdparty/protobuf/wire_format.cc b/r5dev/thirdparty/protobuf/wire_format.cc index 7c8dedfa..3ea20f86 100644 --- a/r5dev/thirdparty/protobuf/wire_format.cc +++ b/r5dev/thirdparty/protobuf/wire_format.cc @@ -40,21 +40,21 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/stubs/stringprintf.h> -#include <thirdparty/protobuf/descriptor.pb.h> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/descriptor.pb.h> #include <thirdparty/protobuf/dynamic_message.h> #include <thirdparty/protobuf/map_field.h> #include <thirdparty/protobuf/map_field_inl.h> #include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/message_lite.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/unknown_field_set.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> const size_t kMapEntryTagByteSize = 2; @@ -657,9 +657,11 @@ struct WireFormat::MessageSetParser { const char* _InternalParse(const char* ptr, internal::ParseContext* ctx) { // Parse a MessageSetItem auto metadata = reflection->MutableInternalMetadata(msg); + enum class State { kNoTag, kHasType, kHasPayload, kDone }; + State state = State::kNoTag; + std::string payload; uint32_t type_id = 0; - bool payload_read = false; while (!ctx->Done(&ptr)) { // We use 64 bit tags in order to allow typeid's that span the whole // range of 32 bit numbers. @@ -668,8 +670,11 @@ struct WireFormat::MessageSetParser { uint64_t tmp; ptr = ParseBigVarint(ptr, &tmp); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - type_id = tmp; - if (payload_read) { + if (state == State::kNoTag) { + type_id = tmp; + state = State::kHasType; + } else if (state == State::kHasPayload) { + type_id = tmp; const FieldDescriptor* field; if (ctx->data().pool == nullptr) { field = reflection->FindKnownExtensionByNumber(type_id); @@ -696,17 +701,17 @@ struct WireFormat::MessageSetParser { GOOGLE_PROTOBUF_PARSER_ASSERT(value->_InternalParse(p, &tmp_ctx) && tmp_ctx.EndedAtLimit()); } - type_id = 0; + state = State::kDone; } continue; } else if (tag == WireFormatLite::kMessageSetMessageTag) { - if (type_id == 0) { + if (state == State::kNoTag) { int32_t size = ReadSize(&ptr); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); ptr = ctx->ReadString(ptr, size, &payload); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - payload_read = true; - } else { + state = State::kHasPayload; + } else if (state == State::kHasType) { // We're now parsing the payload const FieldDescriptor* field = nullptr; if (descriptor->IsExtensionNumber(type_id)) { @@ -720,7 +725,12 @@ struct WireFormat::MessageSetParser { ptr = WireFormat::_InternalParseAndMergeField( msg, ptr, ctx, static_cast<uint64_t>(type_id) * 8 + 2, reflection, field); - type_id = 0; + state = State::kDone; + } else { + int32_t size = ReadSize(&ptr); + GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); + ptr = ctx->Skip(ptr, size); + GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); } } else { // An unknown field in MessageSetItem. @@ -1125,10 +1135,11 @@ static uint8_t* SerializeMapValueRefWithCachedSizes( case FieldDescriptor::TYPE_BYTES: target = stream->WriteString(2, value.GetStringValue(), target); break; - case FieldDescriptor::TYPE_MESSAGE: - target = WireFormatLite::InternalWriteMessage(2, value.GetMessageValue(), + case FieldDescriptor::TYPE_MESSAGE: { + auto& msg = value.GetMessageValue(); + target = WireFormatLite::InternalWriteMessage(2, msg, msg.GetCachedSize(), target, stream); - break; + } break; case FieldDescriptor::TYPE_GROUP: target = WireFormatLite::InternalWriteGroup(2, value.GetMessageValue(), target, stream); @@ -1320,6 +1331,16 @@ uint8_t* WireFormat::InternalSerializeField(const FieldDescriptor* field, return target; } + auto get_message_from_field = [&message, &map_entries, message_reflection]( + const FieldDescriptor* field, int j) { + if (!field->is_repeated()) { + return &message_reflection->GetMessage(message, field); + } + if (!map_entries.empty()) { + return map_entries[j]; + } + return &message_reflection->GetRepeatedMessage(message, field, j); + }; for (int j = 0; j < count; j++) { target = stream->EnsureSpace(target); switch (field->type()) { @@ -1353,22 +1374,17 @@ uint8_t* WireFormat::InternalSerializeField(const FieldDescriptor* field, HANDLE_PRIMITIVE_TYPE(BOOL, bool, Bool, Bool) #undef HANDLE_PRIMITIVE_TYPE -#define HANDLE_TYPE(TYPE, TYPE_METHOD, CPPTYPE_METHOD) \ - case FieldDescriptor::TYPE_##TYPE: \ - target = WireFormatLite::InternalWrite##TYPE_METHOD( \ - field->number(), \ - field->is_repeated() \ - ? (map_entries.empty() \ - ? message_reflection->GetRepeated##CPPTYPE_METHOD(message, \ - field, j) \ - : *map_entries[j]) \ - : message_reflection->Get##CPPTYPE_METHOD(message, field), \ - target, stream); \ - break; + case FieldDescriptor::TYPE_GROUP: { + auto* msg = get_message_from_field(field, j); + target = WireFormatLite::InternalWriteGroup(field->number(), *msg, + target, stream); + } break; - HANDLE_TYPE(GROUP, Group, Message) - HANDLE_TYPE(MESSAGE, Message, Message) -#undef HANDLE_TYPE + case FieldDescriptor::TYPE_MESSAGE: { + auto* msg = get_message_from_field(field, j); + target = WireFormatLite::InternalWriteMessage( + field->number(), *msg, msg->GetCachedSize(), target, stream); + } break; case FieldDescriptor::TYPE_ENUM: { const EnumValueDescriptor* value = @@ -1432,9 +1448,10 @@ uint8_t* WireFormat::InternalSerializeMessageSetItem( target = WireFormatLite::WriteUInt32ToArray( WireFormatLite::kMessageSetTypeIdNumber, field->number(), target); // Write message. + auto& msg = message_reflection->GetMessage(message, field); target = WireFormatLite::InternalWriteMessage( - WireFormatLite::kMessageSetMessageNumber, - message_reflection->GetMessage(message, field), target, stream); + WireFormatLite::kMessageSetMessageNumber, msg, msg.GetCachedSize(), + target, stream); // End group. target = stream->EnsureSpace(target); target = io::CodedOutputStream::WriteTagToArray( diff --git a/r5dev/thirdparty/protobuf/wire_format.h b/r5dev/thirdparty/protobuf/wire_format.h index 3a3622dc..ffe3c09b 100644 --- a/r5dev/thirdparty/protobuf/wire_format.h +++ b/r5dev/thirdparty/protobuf/wire_format.h @@ -39,22 +39,22 @@ #ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_H__ #define GOOGLE_PROTOBUF_WIRE_FORMAT_H__ -#include <string> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/io/coded_stream.h> +#include <thirdparty/protobuf/stubs/casts.h> #include <thirdparty/protobuf/descriptor.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/message.h> #include <thirdparty/protobuf/metadata_lite.h> +#include <thirdparty/protobuf/parse_context.h> #include <thirdparty/protobuf/wire_format_lite.h> -#include <thirdparty/protobuf/stubs/casts.h> #ifdef SWIG #error "You cannot SWIG proto headers" #endif +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { diff --git a/r5dev/thirdparty/protobuf/wire_format_lite.cc b/r5dev/thirdparty/protobuf/wire_format_lite.cc index ba644f19..2abb6bb4 100644 --- a/r5dev/thirdparty/protobuf/wire_format_lite.cc +++ b/r5dev/thirdparty/protobuf/wire_format_lite.cc @@ -41,12 +41,13 @@ #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/stubs/stringprintf.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> +#include <thirdparty/protobuf/stubs/stringprintf.h> +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -527,6 +528,28 @@ void WireFormatLite::WriteMessage(int field_number, const MessageLite& value, value.SerializeWithCachedSizes(output); } +uint8_t* WireFormatLite::InternalWriteGroup(int field_number, + const MessageLite& value, + uint8_t* target, + io::EpsCopyOutputStream* stream) { + target = stream->EnsureSpace(target); + target = WriteTagToArray(field_number, WIRETYPE_START_GROUP, target); + target = value._InternalSerialize(target, stream); + target = stream->EnsureSpace(target); + return WriteTagToArray(field_number, WIRETYPE_END_GROUP, target); +} + +uint8_t* WireFormatLite::InternalWriteMessage(int field_number, + const MessageLite& value, + int cached_size, uint8_t* target, + io::EpsCopyOutputStream* stream) { + target = stream->EnsureSpace(target); + target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target); + target = io::CodedOutputStream::WriteVarint32ToArray( + static_cast<uint32_t>(cached_size), target); + return value._InternalSerialize(target, stream); +} + void WireFormatLite::WriteSubMessageMaybeToArray( int /*size*/, const MessageLite& value, io::CodedOutputStream* output) { output->SetCur(value._InternalSerialize(output->Cur(), output->EpsCopy())); @@ -570,18 +593,29 @@ bool WireFormatLite::ReadBytes(io::CodedInputStream* input, std::string** p) { return ReadBytesToString(input, *p); } -void PrintUTF8ErrorLog(const char* field_name, const char* operation_str, +void PrintUTF8ErrorLog(StringPiece message_name, + StringPiece field_name, const char* operation_str, bool emit_stacktrace) { std::string stacktrace; (void)emit_stacktrace; // Parameter is used by Google-internal code. std::string quoted_field_name = ""; - if (field_name != nullptr) { - quoted_field_name = StringPrintf(" '%s'", field_name); + if (!field_name.empty()) { + if (!message_name.empty()) { + quoted_field_name = + StrCat(" '", message_name, ".", field_name, "'"); + } else { + quoted_field_name = StrCat(" '", field_name, "'"); + } } - GOOGLE_LOG(ERROR) << "String field" << quoted_field_name << " contains invalid " - << "UTF-8 data when " << operation_str << " a protocol " - << "buffer. Use the 'bytes' type if you intend to send raw " - << "bytes. " << stacktrace; + std::string error_message = + StrCat("String field", quoted_field_name, + " contains invalid UTF-8 data " + "when ", + operation_str, + " a protocol buffer. Use the 'bytes' type if you intend to " + "send raw bytes. ", + stacktrace); + GOOGLE_LOG(ERROR) << error_message; } bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op, @@ -597,7 +631,7 @@ bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op, break; // no default case: have the compiler warn if a case is not covered. } - PrintUTF8ErrorLog(field_name, operation_str, false); + PrintUTF8ErrorLog("", field_name, operation_str, false); return false; } return true; diff --git a/r5dev/thirdparty/protobuf/wire_format_lite.h b/r5dev/thirdparty/protobuf/wire_format_lite.h index 992134a3..0c63d72d 100644 --- a/r5dev/thirdparty/protobuf/wire_format_lite.h +++ b/r5dev/thirdparty/protobuf/wire_format_lite.h @@ -40,16 +40,18 @@ #ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__ #define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__ + +#include <limits> #include <string> #include <thirdparty/protobuf/stubs/common.h> #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/io/coded_stream.h> +#include <thirdparty/protobuf/port.h> +#include <thirdparty/protobuf/stubs/casts.h> #include <thirdparty/protobuf/arenastring.h> #include <thirdparty/protobuf/message_lite.h> -#include <thirdparty/protobuf/port.h> #include <thirdparty/protobuf/repeated_field.h> -#include <thirdparty/protobuf/stubs/casts.h> // Do UTF-8 validation on string type in Debug build only #ifndef NDEBUG @@ -67,6 +69,7 @@ #undef TYPE_BOOL +// Must be included last. #include <thirdparty/protobuf/port_def.inc> namespace google { @@ -622,14 +625,13 @@ class PROTOBUF_EXPORT WireFormatLite { // of serialization, the "ToArray" variants may be invoked. But they don't // have a CodedOutputStream available, so they get an additional parameter // telling them whether to serialize deterministically. - template <typename MessageType> - PROTOBUF_NDEBUG_INLINE static uint8_t* InternalWriteGroup( - int field_number, const MessageType& value, uint8_t* target, - io::EpsCopyOutputStream* stream); - template <typename MessageType> - PROTOBUF_NDEBUG_INLINE static uint8_t* InternalWriteMessage( - int field_number, const MessageType& value, uint8_t* target, - io::EpsCopyOutputStream* stream); + static uint8_t* InternalWriteGroup(int field_number, const MessageLite& value, + uint8_t* target, + io::EpsCopyOutputStream* stream); + static uint8_t* InternalWriteMessage(int field_number, + const MessageLite& value, + int cached_size, uint8_t* target, + io::EpsCopyOutputStream* stream); // Like above, but de-virtualize the call to SerializeWithCachedSizes(). The // pointer must point at an instance of MessageType, *not* a subclass (or @@ -662,7 +664,8 @@ class PROTOBUF_EXPORT WireFormatLite { static_cast<uint32_t>(field_number) << 3) + io::CodedOutputStream::VarintSize32(size)), io::CodedOutputStream::IsDefaultSerializationDeterministic()); - return InternalWriteMessage(field_number, value, target, &stream); + return InternalWriteMessage(field_number, value, value.GetCachedSize(), + target, &stream); } // Compute the byte size of a field. The XxSize() functions do NOT include @@ -1705,25 +1708,6 @@ inline uint8_t* WireFormatLite::WriteBytesToArray(int field_number, } -template <typename MessageType> -inline uint8_t* WireFormatLite::InternalWriteGroup( - int field_number, const MessageType& value, uint8_t* target, - io::EpsCopyOutputStream* stream) { - target = WriteTagToArray(field_number, WIRETYPE_START_GROUP, target); - target = value._InternalSerialize(target, stream); - target = stream->EnsureSpace(target); - return WriteTagToArray(field_number, WIRETYPE_END_GROUP, target); -} -template <typename MessageType> -inline uint8_t* WireFormatLite::InternalWriteMessage( - int field_number, const MessageType& value, uint8_t* target, - io::EpsCopyOutputStream* stream) { - target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target); - target = io::CodedOutputStream::WriteVarint32ToArrayOutOfLine( - static_cast<uint32_t>(value.GetCachedSize()), target); - return value._InternalSerialize(target, stream); -} - // See comment on ReadGroupNoVirtual to understand the need for this template // parameter name. template <typename MessageType_WorkAroundCppLookupDefect> @@ -1847,6 +1831,9 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) { // we can parse it later. std::string message_data; + enum class State { kNoTag, kHasType, kHasPayload, kDone }; + State state = State::kNoTag; + while (true) { const uint32_t tag = input->ReadTagNoLastTag(); if (tag == 0) return false; @@ -1855,26 +1842,34 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) { case WireFormatLite::kMessageSetTypeIdTag: { uint32_t type_id; if (!input->ReadVarint32(&type_id)) return false; - last_type_id = type_id; - - if (!message_data.empty()) { + if (state == State::kNoTag) { + last_type_id = type_id; + state = State::kHasType; + } else if (state == State::kHasPayload) { // We saw some message data before the type_id. Have to parse it // now. io::CodedInputStream sub_input( reinterpret_cast<const uint8_t*>(message_data.data()), static_cast<int>(message_data.size())); sub_input.SetRecursionLimit(input->RecursionBudget()); - if (!ms.ParseField(last_type_id, &sub_input)) { + if (!ms.ParseField(type_id, &sub_input)) { return false; } message_data.clear(); + state = State::kDone; } break; } case WireFormatLite::kMessageSetMessageTag: { - if (last_type_id == 0) { + if (state == State::kHasType) { + // Already saw type_id, so we can parse this directly. + if (!ms.ParseField(last_type_id, input)) { + return false; + } + state = State::kDone; + } else if (state == State::kNoTag) { // We haven't seen a type_id yet. Append this data to message_data. uint32_t length; if (!input->ReadVarint32(&length)) return false; @@ -1885,11 +1880,9 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) { auto ptr = reinterpret_cast<uint8_t*>(&message_data[0]); ptr = io::CodedOutputStream::WriteVarint32ToArray(length, ptr); if (!input->ReadRaw(ptr, length)) return false; + state = State::kHasPayload; } else { - // Already saw type_id, so we can parse this directly. - if (!ms.ParseField(last_type_id, input)) { - return false; - } + if (!ms.SkipField(tag, input)) return false; } break; diff --git a/r5dev/thirdparty/protobuf/wire_format_unittest.inc b/r5dev/thirdparty/protobuf/wire_format_unittest.inc index 363adfdd..c6999613 100644 --- a/r5dev/thirdparty/protobuf/wire_format_unittest.inc +++ b/r5dev/thirdparty/protobuf/wire_format_unittest.inc @@ -32,22 +32,22 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include <thirdparty/protobuf/wire_format.h> - #include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/common.h> -#include <thirdparty/protobuf/test_util2.h> #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl.h> #include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h> #include <thirdparty/protobuf/descriptor.h> +#include <thirdparty/protobuf/wire_format.h> #include <thirdparty/protobuf/wire_format_lite.h> -#include <thirdparty/protobuf/testing/googletest.h> -#include <thirdparty/protobuf/stubs/logging.h> #include <gmock/gmock.h> +#include <thirdparty/protobuf/testing/googletest.h> #include <gtest/gtest.h> #include <thirdparty/protobuf/stubs/casts.h> +#include <thirdparty/protobuf/stubs/logging.h> #include <thirdparty/protobuf/stubs/strutil.h> +#include <thirdparty/protobuf/dynamic_message.h> +#include <thirdparty/protobuf/test_util2.h> #include <thirdparty/protobuf/stubs/stl_util.h> // clang-format off @@ -493,8 +493,9 @@ TEST(WireFormatTest, SerializeMessageSetVariousWaysAreEqual) { // Serialize to flat array { - uint8* target = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&flat_data)); - uint8* end = message_set.SerializeWithCachedSizesToArray(target); + uint8_t* target = + reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&flat_data)); + uint8_t* end = message_set.SerializeWithCachedSizesToArray(target); EXPECT_EQ(size, end - target); } @@ -574,34 +575,60 @@ TEST(WireFormatTest, ParseMessageSet) { // Also parse using WireFormat. PROTO2_WIREFORMAT_UNITTEST::TestMessageSet dynamic_message_set; - io::CodedInputStream input(reinterpret_cast<const uint8*>(data.data()), + io::CodedInputStream input(reinterpret_cast<const uint8_t*>(data.data()), data.size()); ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &dynamic_message_set)); EXPECT_EQ(message_set.DebugString(), dynamic_message_set.DebugString()); } -TEST(WireFormatTest, ParseMessageSetWithReverseTagOrder) { +namespace { +std::string BuildMessageSetItemStart() { std::string data; { - UNITTEST::TestMessageSetExtension1 message; - message.set_i(123); - // Build a MessageSet manually with its message content put before its - // type_id. io::StringOutputStream output_stream(&data); io::CodedOutputStream coded_output(&output_stream); coded_output.WriteTag(WireFormatLite::kMessageSetItemStartTag); + } + return data; +} +std::string BuildMessageSetItemEnd() { + std::string data; + { + io::StringOutputStream output_stream(&data); + io::CodedOutputStream coded_output(&output_stream); + coded_output.WriteTag(WireFormatLite::kMessageSetItemEndTag); + } + return data; +} +std::string BuildMessageSetTestExtension1(int value = 123) { + std::string data; + { + UNITTEST::TestMessageSetExtension1 message; + message.set_i(value); + io::StringOutputStream output_stream(&data); + io::CodedOutputStream coded_output(&output_stream); // Write the message content first. WireFormatLite::WriteTag(WireFormatLite::kMessageSetMessageNumber, WireFormatLite::WIRETYPE_LENGTH_DELIMITED, &coded_output); coded_output.WriteVarint32(message.ByteSizeLong()); message.SerializeWithCachedSizes(&coded_output); - // Write the type id. - uint32 type_id = message.GetDescriptor()->extension(0)->number(); - WireFormatLite::WriteUInt32(WireFormatLite::kMessageSetTypeIdNumber, - type_id, &coded_output); - coded_output.WriteTag(WireFormatLite::kMessageSetItemEndTag); } + return data; +} +std::string BuildMessageSetItemTypeId(int extension_number) { + std::string data; + { + io::StringOutputStream output_stream(&data); + io::CodedOutputStream coded_output(&output_stream); + WireFormatLite::WriteUInt32(WireFormatLite::kMessageSetTypeIdNumber, + extension_number, &coded_output); + } + return data; +} +void ValidateTestMessageSet(const std::string& test_case, + const std::string& data) { + SCOPED_TRACE(test_case); { PROTO2_WIREFORMAT_UNITTEST::TestMessageSet message_set; ASSERT_TRUE(message_set.ParseFromString(data)); @@ -611,11 +638,16 @@ TEST(WireFormatTest, ParseMessageSetWithReverseTagOrder) { .GetExtension( UNITTEST::TestMessageSetExtension1::message_set_extension) .i()); + + // Make sure it does not contain anything else. + message_set.ClearExtension( + UNITTEST::TestMessageSetExtension1::message_set_extension); + EXPECT_EQ(message_set.SerializeAsString(), ""); } { // Test parse the message via Reflection. PROTO2_WIREFORMAT_UNITTEST::TestMessageSet message_set; - io::CodedInputStream input(reinterpret_cast<const uint8*>(data.data()), + io::CodedInputStream input(reinterpret_cast<const uint8_t*>(data.data()), data.size()); EXPECT_TRUE(WireFormat::ParseAndMergePartial(&input, &message_set)); EXPECT_TRUE(input.ConsumedEntireMessage()); @@ -626,6 +658,61 @@ TEST(WireFormatTest, ParseMessageSetWithReverseTagOrder) { UNITTEST::TestMessageSetExtension1::message_set_extension) .i()); } + { + // Test parse the message via DynamicMessage. + DynamicMessageFactory factory; + std::unique_ptr<Message> msg( + factory + .GetPrototype( + PROTO2_WIREFORMAT_UNITTEST::TestMessageSet::descriptor()) + ->New()); + msg->ParseFromString(data); + auto* reflection = msg->GetReflection(); + std::vector<const FieldDescriptor*> fields; + reflection->ListFields(*msg, &fields); + ASSERT_EQ(fields.size(), 1); + const auto& sub = reflection->GetMessage(*msg, fields[0]); + reflection = sub.GetReflection(); + EXPECT_EQ(123, reflection->GetInt32( + sub, sub.GetDescriptor()->FindFieldByName("i"))); + } +} +} // namespace + +TEST(WireFormatTest, ParseMessageSetWithAnyTagOrder) { + std::string start = BuildMessageSetItemStart(); + std::string end = BuildMessageSetItemEnd(); + std::string id = BuildMessageSetItemTypeId( + UNITTEST::TestMessageSetExtension1::descriptor()->extension(0)->number()); + std::string message = BuildMessageSetTestExtension1(); + + ValidateTestMessageSet("id + message", start + id + message + end); + ValidateTestMessageSet("message + id", start + message + id + end); +} + +TEST(WireFormatTest, ParseMessageSetWithDuplicateTags) { + std::string start = BuildMessageSetItemStart(); + std::string end = BuildMessageSetItemEnd(); + std::string id = BuildMessageSetItemTypeId( + UNITTEST::TestMessageSetExtension1::descriptor()->extension(0)->number()); + std::string other_id = BuildMessageSetItemTypeId(123456); + std::string message = BuildMessageSetTestExtension1(); + std::string other_message = BuildMessageSetTestExtension1(321); + + // Double id + ValidateTestMessageSet("id + other_id + message", + start + id + other_id + message + end); + ValidateTestMessageSet("id + message + other_id", + start + id + message + other_id + end); + ValidateTestMessageSet("message + id + other_id", + start + message + id + other_id + end); + // Double message + ValidateTestMessageSet("id + message + other_message", + start + id + message + other_message + end); + ValidateTestMessageSet("message + id + other_message", + start + message + id + other_message + end); + ValidateTestMessageSet("message + other_message + id", + start + message + other_message + id + end); } void SerializeReverseOrder( @@ -660,7 +747,7 @@ void SerializeReverseOrder( coded_output->WriteVarint32(message.GetCachedSize()); SerializeReverseOrder(message, coded_output); // Write the type id. - uint32 type_id = message.GetDescriptor()->extension(0)->number(); + uint32_t type_id = message.GetDescriptor()->extension(0)->number(); WireFormatLite::WriteUInt32(WireFormatLite::kMessageSetTypeIdNumber, type_id, coded_output); coded_output->WriteTag(WireFormatLite::kMessageSetItemEndTag); @@ -776,6 +863,43 @@ TEST(WireFormatTest, RecursionLimit) { } } +TEST(WireFormatTest, LargeRecursionLimit) { + const int kLargeLimit = io::CodedInputStream::GetDefaultRecursionLimit() + 50; + UNITTEST::TestRecursiveMessage src, dst, *a; + a = src.mutable_a(); + for (int i = 0; i < kLargeLimit - 1; i++) { + a = a->mutable_a(); + } + a->set_i(1); + + std::string data = src.SerializeAsString(); + { + // Parse with default recursion limit. Should fail. + io::ArrayInputStream raw_input(data.data(), data.size()); + io::CodedInputStream input(&raw_input); + ASSERT_FALSE(dst.ParseFromCodedStream(&input)); + } + + { + // Parse with custom recursion limit. Should pass. + io::ArrayInputStream raw_input(data.data(), data.size()); + io::CodedInputStream input(&raw_input); + input.SetRecursionLimit(kLargeLimit); + ASSERT_TRUE(dst.ParseFromCodedStream(&input)); + } + + // Verifies the recursion depth. + int depth = 1; + a = dst.mutable_a(); + while (a->has_a()) { + a = a->mutable_a(); + depth++; + } + + EXPECT_EQ(a->i(), 1); + EXPECT_EQ(depth, kLargeLimit); +} + TEST(WireFormatTest, UnknownFieldRecursionLimit) { UNITTEST::TestEmptyMessage message; message.mutable_unknown_fields() @@ -913,7 +1037,7 @@ TEST(WireFormatTest, RepeatedScalarsDifferentTagSizes) { } TEST(WireFormatTest, CompatibleTypes) { - const int64 data = 0x100000000LL; + const int64_t data = 0x100000000LL; UNITTEST::Int64Message msg1; msg1.set_data(data); std::string serialized; @@ -927,17 +1051,17 @@ TEST(WireFormatTest, CompatibleTypes) { // Test int64 is compatible with uint64 UNITTEST::Uint64Message msg3; ASSERT_TRUE(msg3.ParseFromString(serialized)); - ASSERT_EQ(static_cast<uint64>(data), msg3.data()); + ASSERT_EQ(static_cast<uint64_t>(data), msg3.data()); // Test int64 is compatible with int32 UNITTEST::Int32Message msg4; ASSERT_TRUE(msg4.ParseFromString(serialized)); - ASSERT_EQ(static_cast<int32>(data), msg4.data()); + ASSERT_EQ(static_cast<int32_t>(data), msg4.data()); // Test int64 is compatible with uint32 UNITTEST::Uint32Message msg5; ASSERT_TRUE(msg5.ParseFromString(serialized)); - ASSERT_EQ(static_cast<uint32>(data), msg5.data()); + ASSERT_EQ(static_cast<uint32_t>(data), msg5.data()); } class Proto3PrimitiveRepeatedWireFormatTest : public ::testing::Test { @@ -1079,7 +1203,7 @@ class Proto3PrimitiveRepeatedWireFormatTest : public ::testing::Test { message->Clear(); io::CodedInputStream input( - reinterpret_cast<const uint8*>(compatible_data.data()), + reinterpret_cast<const uint8_t*>(compatible_data.data()), compatible_data.size()); WireFormat::ParseAndMergePartial(&input, message); ExpectProto3PrimitiveRepeatedFieldsSet(*message); @@ -1289,8 +1413,8 @@ bool ReadMessage(const std::string& wire_buffer, T* message) { class Utf8ValidationTest : public ::testing::Test { protected: Utf8ValidationTest() {} - virtual ~Utf8ValidationTest() {} - virtual void SetUp() { + ~Utf8ValidationTest() override {} + void SetUp() override { } }; @@ -1447,7 +1571,7 @@ TEST_F(Utf8ValidationTest, OldVerifyUTF8String) { TEST(RepeatedVarint, Int32) { - RepeatedField<int32> v; + RepeatedField<int32_t> v; // Insert -2^n, 2^n and 2^n-1. for (int n = 0; n < 10; n++) { @@ -1466,7 +1590,7 @@ TEST(RepeatedVarint, Int32) { } TEST(RepeatedVarint, Int64) { - RepeatedField<int64> v; + RepeatedField<int64_t> v; // Insert -2^n, 2^n and 2^n-1. for (int n = 0; n < 10; n++) { @@ -1485,7 +1609,7 @@ TEST(RepeatedVarint, Int64) { } TEST(RepeatedVarint, SInt32) { - RepeatedField<int32> v; + RepeatedField<int32_t> v; // Insert -2^n, 2^n and 2^n-1. for (int n = 0; n < 10; n++) { @@ -1504,7 +1628,7 @@ TEST(RepeatedVarint, SInt32) { } TEST(RepeatedVarint, SInt64) { - RepeatedField<int64> v; + RepeatedField<int64_t> v; // Insert -2^n, 2^n and 2^n-1. for (int n = 0; n < 10; n++) { @@ -1523,7 +1647,7 @@ TEST(RepeatedVarint, SInt64) { } TEST(RepeatedVarint, UInt32) { - RepeatedField<uint32> v; + RepeatedField<uint32_t> v; // Insert 2^n and 2^n-1. for (int n = 0; n < 10; n++) { @@ -1541,7 +1665,7 @@ TEST(RepeatedVarint, UInt32) { } TEST(RepeatedVarint, UInt64) { - RepeatedField<uint64> v; + RepeatedField<uint64_t> v; // Insert 2^n and 2^n-1. for (int n = 0; n < 10; n++) { diff --git a/r5dev/thirdparty/protobuf/wrappers.pb.cc b/r5dev/thirdparty/protobuf/wrappers.pb.cc index a1ce4c2d..8851798d 100644 --- a/r5dev/thirdparty/protobuf/wrappers.pb.cc +++ b/r5dev/thirdparty/protobuf/wrappers.pb.cc @@ -16,119 +16,132 @@ #include <thirdparty/protobuf/port_def.inc> PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + PROTOBUF_NAMESPACE_OPEN -constexpr DoubleValue::DoubleValue( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : value_(0){} +PROTOBUF_CONSTEXPR DoubleValue::DoubleValue( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.value_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} struct DoubleValueDefaultTypeInternal { - constexpr DoubleValueDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR DoubleValueDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~DoubleValueDefaultTypeInternal() {} union { DoubleValue _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DoubleValueDefaultTypeInternal _DoubleValue_default_instance_; -constexpr FloatValue::FloatValue( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : value_(0){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DoubleValueDefaultTypeInternal _DoubleValue_default_instance_; +PROTOBUF_CONSTEXPR FloatValue::FloatValue( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.value_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} struct FloatValueDefaultTypeInternal { - constexpr FloatValueDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FloatValueDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~FloatValueDefaultTypeInternal() {} union { FloatValue _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FloatValueDefaultTypeInternal _FloatValue_default_instance_; -constexpr Int64Value::Int64Value( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : value_(int64_t{0}){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FloatValueDefaultTypeInternal _FloatValue_default_instance_; +PROTOBUF_CONSTEXPR Int64Value::Int64Value( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.value_)*/int64_t{0} + , /*decltype(_impl_._cached_size_)*/{}} {} struct Int64ValueDefaultTypeInternal { - constexpr Int64ValueDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR Int64ValueDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~Int64ValueDefaultTypeInternal() {} union { Int64Value _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT Int64ValueDefaultTypeInternal _Int64Value_default_instance_; -constexpr UInt64Value::UInt64Value( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : value_(uint64_t{0u}){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Int64ValueDefaultTypeInternal _Int64Value_default_instance_; +PROTOBUF_CONSTEXPR UInt64Value::UInt64Value( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.value_)*/uint64_t{0u} + , /*decltype(_impl_._cached_size_)*/{}} {} struct UInt64ValueDefaultTypeInternal { - constexpr UInt64ValueDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR UInt64ValueDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~UInt64ValueDefaultTypeInternal() {} union { UInt64Value _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_; -constexpr Int32Value::Int32Value( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : value_(0){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_; +PROTOBUF_CONSTEXPR Int32Value::Int32Value( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.value_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} struct Int32ValueDefaultTypeInternal { - constexpr Int32ValueDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR Int32ValueDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~Int32ValueDefaultTypeInternal() {} union { Int32Value _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT Int32ValueDefaultTypeInternal _Int32Value_default_instance_; -constexpr UInt32Value::UInt32Value( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : value_(0u){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Int32ValueDefaultTypeInternal _Int32Value_default_instance_; +PROTOBUF_CONSTEXPR UInt32Value::UInt32Value( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.value_)*/0u + , /*decltype(_impl_._cached_size_)*/{}} {} struct UInt32ValueDefaultTypeInternal { - constexpr UInt32ValueDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR UInt32ValueDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~UInt32ValueDefaultTypeInternal() {} union { UInt32Value _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_; -constexpr BoolValue::BoolValue( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : value_(false){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_; +PROTOBUF_CONSTEXPR BoolValue::BoolValue( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.value_)*/false + , /*decltype(_impl_._cached_size_)*/{}} {} struct BoolValueDefaultTypeInternal { - constexpr BoolValueDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR BoolValueDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~BoolValueDefaultTypeInternal() {} union { BoolValue _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT BoolValueDefaultTypeInternal _BoolValue_default_instance_; -constexpr StringValue::StringValue( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BoolValueDefaultTypeInternal _BoolValue_default_instance_; +PROTOBUF_CONSTEXPR StringValue::StringValue( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} struct StringValueDefaultTypeInternal { - constexpr StringValueDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR StringValueDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~StringValueDefaultTypeInternal() {} union { StringValue _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT StringValueDefaultTypeInternal _StringValue_default_instance_; -constexpr BytesValue::BytesValue( - ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) - : value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){} +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 StringValueDefaultTypeInternal _StringValue_default_instance_; +PROTOBUF_CONSTEXPR BytesValue::BytesValue( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.value_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_._cached_size_)*/{}} {} struct BytesValueDefaultTypeInternal { - constexpr BytesValueDefaultTypeInternal() - : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR BytesValueDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} ~BytesValueDefaultTypeInternal() {} union { BytesValue _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT BytesValueDefaultTypeInternal _BytesValue_default_instance_; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 BytesValueDefaultTypeInternal _BytesValue_default_instance_; PROTOBUF_NAMESPACE_CLOSE -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[9]; -static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto = nullptr; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fwrappers_2eproto = nullptr; +static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[9]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fwrappers_2eproto = nullptr; const uint32_t TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ @@ -137,65 +150,65 @@ const uint32_t TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets[] PROTO ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DoubleValue, value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DoubleValue, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FloatValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FloatValue, value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FloatValue, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int64Value, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int64Value, value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int64Value, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt64Value, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt64Value, value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt64Value, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int32Value, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int32Value, value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Int32Value, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt32Value, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt32Value, value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UInt32Value, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BoolValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BoolValue, value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BoolValue, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::StringValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::StringValue, value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::StringValue, _impl_.value_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BytesValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BytesValue, value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::BytesValue, _impl_.value_), }; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DoubleValue)}, { 7, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FloatValue)}, { 14, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Int64Value)}, @@ -207,16 +220,16 @@ static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOB { 56, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::BytesValue)}, }; -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_DoubleValue_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_FloatValue_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Int64Value_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_UInt64Value_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_Int32Value_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_UInt32Value_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_BoolValue_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_StringValue_default_instance_), - reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::PROTOBUF_NAMESPACE_ID::_BytesValue_default_instance_), +static const ::_pb::Message* const file_default_instances[] = { + &::PROTOBUF_NAMESPACE_ID::_DoubleValue_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FloatValue_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_Int64Value_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_UInt64Value_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_Int32Value_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_UInt32Value_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_BoolValue_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_StringValue_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_BytesValue_default_instance_._instance, }; const char descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = @@ -233,19 +246,21 @@ const char descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto[] PROT "erspb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf.WellKno" "wnTypesb\006proto3" ; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fwrappers_2eproto = { - false, false, 455, descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto, "google/protobuf/wrappers.proto", - &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, nullptr, 0, 9, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fwrappers_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto, file_level_service_descriptors_google_2fprotobuf_2fwrappers_2eproto, +static ::_pbi::once_flag descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fwrappers_2eproto = { + false, false, 455, descriptor_table_protodef_google_2fprotobuf_2fwrappers_2eproto, + "google/protobuf/wrappers.proto", + &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, nullptr, 0, 9, + schemas, file_default_instances, TableStruct_google_2fprotobuf_2fwrappers_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fwrappers_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto, + file_level_service_descriptors_google_2fprotobuf_2fwrappers_2eproto, }; -PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter() { +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fwrappers_2eproto; } // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fwrappers_2eproto(&descriptor_table_google_2fprotobuf_2fwrappers_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fwrappers_2eproto(&descriptor_table_google_2fprotobuf_2fwrappers_2eproto); PROTOBUF_NAMESPACE_OPEN // =================================================================== @@ -257,42 +272,46 @@ class DoubleValue::_Internal { DoubleValue::DoubleValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.DoubleValue) } DoubleValue::DoubleValue(const DoubleValue& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + DoubleValue* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - value_ = from.value_; + _this->_impl_.value_ = from._impl_.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.DoubleValue) } -inline void DoubleValue::SharedCtor() { -value_ = 0; +inline void DoubleValue::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.value_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; } DoubleValue::~DoubleValue() { // @@protoc_insertion_point(destructor:google.protobuf.DoubleValue) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void DoubleValue::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } -void DoubleValue::ArenaDtor(void* object) { - DoubleValue* _this = reinterpret_cast< DoubleValue* >(object); - (void)_this; -} -void DoubleValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void DoubleValue::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void DoubleValue::Clear() { @@ -301,20 +320,20 @@ void DoubleValue::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - value_ = 0; + _impl_.value_ = 0; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* DoubleValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* DoubleValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // double value = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 9)) { - value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr); + _impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr); ptr += sizeof(double); } else goto handle_unusual; @@ -355,11 +374,11 @@ uint8_t* DoubleValue::_InternalSerialize( memcpy(&raw_value, &tmp_value, sizeof(tmp_value)); if (raw_value != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(1, this->_internal_value(), target); + target = ::_pbi::WireFormatLite::WriteDoubleToArray(1, this->_internal_value(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DoubleValue) @@ -383,25 +402,21 @@ size_t DoubleValue::ByteSizeLong() const { total_size += 1 + 8; } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DoubleValue::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, DoubleValue::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DoubleValue::GetClassData() const { return &_class_data_; } -void DoubleValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<DoubleValue *>(to)->MergeFrom( - static_cast<const DoubleValue &>(from)); -} - -void DoubleValue::MergeFrom(const DoubleValue& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DoubleValue) - GOOGLE_DCHECK_NE(&from, this); +void DoubleValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<DoubleValue*>(&to_msg); + auto& from = static_cast<const DoubleValue&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DoubleValue) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -410,9 +425,9 @@ void DoubleValue::MergeFrom(const DoubleValue& from) { uint64_t raw_value; memcpy(&raw_value, &tmp_value, sizeof(tmp_value)); if (raw_value != 0) { - _internal_set_value(from._internal_value()); + _this->_internal_set_value(from._internal_value()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void DoubleValue::CopyFrom(const DoubleValue& from) { @@ -429,11 +444,11 @@ bool DoubleValue::IsInitialized() const { void DoubleValue::InternalSwap(DoubleValue* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(value_, other->value_); + swap(_impl_.value_, other->_impl_.value_); } ::PROTOBUF_NAMESPACE_ID::Metadata DoubleValue::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[0]); } @@ -447,42 +462,46 @@ class FloatValue::_Internal { FloatValue::FloatValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.FloatValue) } FloatValue::FloatValue(const FloatValue& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + FloatValue* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - value_ = from.value_; + _this->_impl_.value_ = from._impl_.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.FloatValue) } -inline void FloatValue::SharedCtor() { -value_ = 0; +inline void FloatValue::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.value_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; } FloatValue::~FloatValue() { // @@protoc_insertion_point(destructor:google.protobuf.FloatValue) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void FloatValue::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } -void FloatValue::ArenaDtor(void* object) { - FloatValue* _this = reinterpret_cast< FloatValue* >(object); - (void)_this; -} -void FloatValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void FloatValue::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void FloatValue::Clear() { @@ -491,20 +510,20 @@ void FloatValue::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - value_ = 0; + _impl_.value_ = 0; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* FloatValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* FloatValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // float value = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 13)) { - value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr); + _impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr); ptr += sizeof(float); } else goto handle_unusual; @@ -545,11 +564,11 @@ uint8_t* FloatValue::_InternalSerialize( memcpy(&raw_value, &tmp_value, sizeof(tmp_value)); if (raw_value != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(1, this->_internal_value(), target); + target = ::_pbi::WireFormatLite::WriteFloatToArray(1, this->_internal_value(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FloatValue) @@ -573,25 +592,21 @@ size_t FloatValue::ByteSizeLong() const { total_size += 1 + 4; } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData FloatValue::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, FloatValue::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FloatValue::GetClassData() const { return &_class_data_; } -void FloatValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<FloatValue *>(to)->MergeFrom( - static_cast<const FloatValue &>(from)); -} - -void FloatValue::MergeFrom(const FloatValue& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FloatValue) - GOOGLE_DCHECK_NE(&from, this); +void FloatValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<FloatValue*>(&to_msg); + auto& from = static_cast<const FloatValue&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FloatValue) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; @@ -600,9 +615,9 @@ void FloatValue::MergeFrom(const FloatValue& from) { uint32_t raw_value; memcpy(&raw_value, &tmp_value, sizeof(tmp_value)); if (raw_value != 0) { - _internal_set_value(from._internal_value()); + _this->_internal_set_value(from._internal_value()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void FloatValue::CopyFrom(const FloatValue& from) { @@ -619,11 +634,11 @@ bool FloatValue::IsInitialized() const { void FloatValue::InternalSwap(FloatValue* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(value_, other->value_); + swap(_impl_.value_, other->_impl_.value_); } ::PROTOBUF_NAMESPACE_ID::Metadata FloatValue::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[1]); } @@ -637,42 +652,46 @@ class Int64Value::_Internal { Int64Value::Int64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Int64Value) } Int64Value::Int64Value(const Int64Value& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + Int64Value* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - value_ = from.value_; + _this->_impl_.value_ = from._impl_.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Int64Value) } -inline void Int64Value::SharedCtor() { -value_ = int64_t{0}; +inline void Int64Value::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.value_){int64_t{0}} + , /*decltype(_impl_._cached_size_)*/{} + }; } Int64Value::~Int64Value() { // @@protoc_insertion_point(destructor:google.protobuf.Int64Value) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Int64Value::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } -void Int64Value::ArenaDtor(void* object) { - Int64Value* _this = reinterpret_cast< Int64Value* >(object); - (void)_this; -} -void Int64Value::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Int64Value::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Int64Value::Clear() { @@ -681,20 +700,20 @@ void Int64Value::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - value_ = int64_t{0}; + _impl_.value_ = int64_t{0}; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Int64Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Int64Value::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // int64 value = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { - value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -731,11 +750,11 @@ uint8_t* Int64Value::_InternalSerialize( // int64 value = 1; if (this->_internal_value() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(1, this->_internal_value(), target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(1, this->_internal_value(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Int64Value) @@ -752,35 +771,31 @@ size_t Int64Value::ByteSizeLong() const { // int64 value = 1; if (this->_internal_value() != 0) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64SizePlusOne(this->_internal_value()); + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_value()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Int64Value::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Int64Value::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Int64Value::GetClassData() const { return &_class_data_; } -void Int64Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Int64Value *>(to)->MergeFrom( - static_cast<const Int64Value &>(from)); -} - -void Int64Value::MergeFrom(const Int64Value& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int64Value) - GOOGLE_DCHECK_NE(&from, this); +void Int64Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Int64Value*>(&to_msg); + auto& from = static_cast<const Int64Value&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int64Value) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_value() != 0) { - _internal_set_value(from._internal_value()); + _this->_internal_set_value(from._internal_value()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Int64Value::CopyFrom(const Int64Value& from) { @@ -797,11 +812,11 @@ bool Int64Value::IsInitialized() const { void Int64Value::InternalSwap(Int64Value* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(value_, other->value_); + swap(_impl_.value_, other->_impl_.value_); } ::PROTOBUF_NAMESPACE_ID::Metadata Int64Value::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[2]); } @@ -815,42 +830,46 @@ class UInt64Value::_Internal { UInt64Value::UInt64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt64Value) } UInt64Value::UInt64Value(const UInt64Value& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + UInt64Value* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - value_ = from.value_; + _this->_impl_.value_ = from._impl_.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UInt64Value) } -inline void UInt64Value::SharedCtor() { -value_ = uint64_t{0u}; +inline void UInt64Value::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.value_){uint64_t{0u}} + , /*decltype(_impl_._cached_size_)*/{} + }; } UInt64Value::~UInt64Value() { // @@protoc_insertion_point(destructor:google.protobuf.UInt64Value) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void UInt64Value::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } -void UInt64Value::ArenaDtor(void* object) { - UInt64Value* _this = reinterpret_cast< UInt64Value* >(object); - (void)_this; -} -void UInt64Value::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void UInt64Value::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void UInt64Value::Clear() { @@ -859,20 +878,20 @@ void UInt64Value::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - value_ = uint64_t{0u}; + _impl_.value_ = uint64_t{0u}; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* UInt64Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* UInt64Value::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // uint64 value = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { - value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -909,11 +928,11 @@ uint8_t* UInt64Value::_InternalSerialize( // uint64 value = 1; if (this->_internal_value() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(1, this->_internal_value(), target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(1, this->_internal_value(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UInt64Value) @@ -930,35 +949,31 @@ size_t UInt64Value::ByteSizeLong() const { // uint64 value = 1; if (this->_internal_value() != 0) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64SizePlusOne(this->_internal_value()); + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_value()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData UInt64Value::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, UInt64Value::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*UInt64Value::GetClassData() const { return &_class_data_; } -void UInt64Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<UInt64Value *>(to)->MergeFrom( - static_cast<const UInt64Value &>(from)); -} - -void UInt64Value::MergeFrom(const UInt64Value& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt64Value) - GOOGLE_DCHECK_NE(&from, this); +void UInt64Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<UInt64Value*>(&to_msg); + auto& from = static_cast<const UInt64Value&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt64Value) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_value() != 0) { - _internal_set_value(from._internal_value()); + _this->_internal_set_value(from._internal_value()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void UInt64Value::CopyFrom(const UInt64Value& from) { @@ -975,11 +990,11 @@ bool UInt64Value::IsInitialized() const { void UInt64Value::InternalSwap(UInt64Value* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(value_, other->value_); + swap(_impl_.value_, other->_impl_.value_); } ::PROTOBUF_NAMESPACE_ID::Metadata UInt64Value::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[3]); } @@ -993,42 +1008,46 @@ class Int32Value::_Internal { Int32Value::Int32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.Int32Value) } Int32Value::Int32Value(const Int32Value& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + Int32Value* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - value_ = from.value_; + _this->_impl_.value_ = from._impl_.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Int32Value) } -inline void Int32Value::SharedCtor() { -value_ = 0; +inline void Int32Value::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.value_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; } Int32Value::~Int32Value() { // @@protoc_insertion_point(destructor:google.protobuf.Int32Value) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void Int32Value::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } -void Int32Value::ArenaDtor(void* object) { - Int32Value* _this = reinterpret_cast< Int32Value* >(object); - (void)_this; -} -void Int32Value::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void Int32Value::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void Int32Value::Clear() { @@ -1037,20 +1056,20 @@ void Int32Value::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - value_ = 0; + _impl_.value_ = 0; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* Int32Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* Int32Value::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // int32 value = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { - value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -1087,11 +1106,11 @@ uint8_t* Int32Value::_InternalSerialize( // int32 value = 1; if (this->_internal_value() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_value(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_value(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Int32Value) @@ -1108,35 +1127,31 @@ size_t Int32Value::ByteSizeLong() const { // int32 value = 1; if (this->_internal_value() != 0) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_value()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_value()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Int32Value::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, Int32Value::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Int32Value::GetClassData() const { return &_class_data_; } -void Int32Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<Int32Value *>(to)->MergeFrom( - static_cast<const Int32Value &>(from)); -} - -void Int32Value::MergeFrom(const Int32Value& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int32Value) - GOOGLE_DCHECK_NE(&from, this); +void Int32Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<Int32Value*>(&to_msg); + auto& from = static_cast<const Int32Value&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int32Value) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_value() != 0) { - _internal_set_value(from._internal_value()); + _this->_internal_set_value(from._internal_value()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void Int32Value::CopyFrom(const Int32Value& from) { @@ -1153,11 +1168,11 @@ bool Int32Value::IsInitialized() const { void Int32Value::InternalSwap(Int32Value* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(value_, other->value_); + swap(_impl_.value_, other->_impl_.value_); } ::PROTOBUF_NAMESPACE_ID::Metadata Int32Value::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[4]); } @@ -1171,42 +1186,46 @@ class UInt32Value::_Internal { UInt32Value::UInt32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt32Value) } UInt32Value::UInt32Value(const UInt32Value& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + UInt32Value* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - value_ = from.value_; + _this->_impl_.value_ = from._impl_.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UInt32Value) } -inline void UInt32Value::SharedCtor() { -value_ = 0u; +inline void UInt32Value::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.value_){0u} + , /*decltype(_impl_._cached_size_)*/{} + }; } UInt32Value::~UInt32Value() { // @@protoc_insertion_point(destructor:google.protobuf.UInt32Value) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void UInt32Value::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } -void UInt32Value::ArenaDtor(void* object) { - UInt32Value* _this = reinterpret_cast< UInt32Value* >(object); - (void)_this; -} -void UInt32Value::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void UInt32Value::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void UInt32Value::Clear() { @@ -1215,20 +1234,20 @@ void UInt32Value::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - value_ = 0u; + _impl_.value_ = 0u; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* UInt32Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* UInt32Value::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // uint32 value = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { - value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -1265,11 +1284,11 @@ uint8_t* UInt32Value::_InternalSerialize( // uint32 value = 1; if (this->_internal_value() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt32ToArray(1, this->_internal_value(), target); + target = ::_pbi::WireFormatLite::WriteUInt32ToArray(1, this->_internal_value(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UInt32Value) @@ -1286,35 +1305,31 @@ size_t UInt32Value::ByteSizeLong() const { // uint32 value = 1; if (this->_internal_value() != 0) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt32SizePlusOne(this->_internal_value()); + total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_value()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData UInt32Value::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, UInt32Value::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*UInt32Value::GetClassData() const { return &_class_data_; } -void UInt32Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<UInt32Value *>(to)->MergeFrom( - static_cast<const UInt32Value &>(from)); -} - -void UInt32Value::MergeFrom(const UInt32Value& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt32Value) - GOOGLE_DCHECK_NE(&from, this); +void UInt32Value::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<UInt32Value*>(&to_msg); + auto& from = static_cast<const UInt32Value&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt32Value) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_value() != 0) { - _internal_set_value(from._internal_value()); + _this->_internal_set_value(from._internal_value()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void UInt32Value::CopyFrom(const UInt32Value& from) { @@ -1331,11 +1346,11 @@ bool UInt32Value::IsInitialized() const { void UInt32Value::InternalSwap(UInt32Value* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(value_, other->value_); + swap(_impl_.value_, other->_impl_.value_); } ::PROTOBUF_NAMESPACE_ID::Metadata UInt32Value::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[5]); } @@ -1349,42 +1364,46 @@ class BoolValue::_Internal { BoolValue::BoolValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.BoolValue) } BoolValue::BoolValue(const BoolValue& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + BoolValue* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - value_ = from.value_; + _this->_impl_.value_ = from._impl_.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.BoolValue) } -inline void BoolValue::SharedCtor() { -value_ = false; +inline void BoolValue::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.value_){false} + , /*decltype(_impl_._cached_size_)*/{} + }; } BoolValue::~BoolValue() { // @@protoc_insertion_point(destructor:google.protobuf.BoolValue) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void BoolValue::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); } -void BoolValue::ArenaDtor(void* object) { - BoolValue* _this = reinterpret_cast< BoolValue* >(object); - (void)_this; -} -void BoolValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void BoolValue::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void BoolValue::Clear() { @@ -1393,20 +1412,20 @@ void BoolValue::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - value_ = false; + _impl_.value_ = false; _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* BoolValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* BoolValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // bool value = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { - value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.value_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; @@ -1443,11 +1462,11 @@ uint8_t* BoolValue::_InternalSerialize( // bool value = 1; if (this->_internal_value() != 0) { target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(1, this->_internal_value(), target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(1, this->_internal_value(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.BoolValue) @@ -1467,32 +1486,28 @@ size_t BoolValue::ByteSizeLong() const { total_size += 1 + 1; } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData BoolValue::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, BoolValue::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*BoolValue::GetClassData() const { return &_class_data_; } -void BoolValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<BoolValue *>(to)->MergeFrom( - static_cast<const BoolValue &>(from)); -} - -void BoolValue::MergeFrom(const BoolValue& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BoolValue) - GOOGLE_DCHECK_NE(&from, this); +void BoolValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<BoolValue*>(&to_msg); + auto& from = static_cast<const BoolValue&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BoolValue) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (from._internal_value() != 0) { - _internal_set_value(from._internal_value()); + _this->_internal_set_value(from._internal_value()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void BoolValue::CopyFrom(const BoolValue& from) { @@ -1509,11 +1524,11 @@ bool BoolValue::IsInitialized() const { void BoolValue::InternalSwap(BoolValue* other) { using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(value_, other->value_); + swap(_impl_.value_, other->_impl_.value_); } ::PROTOBUF_NAMESPACE_ID::Metadata BoolValue::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[6]); } @@ -1527,53 +1542,58 @@ class StringValue::_Internal { StringValue::StringValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.StringValue) } StringValue::StringValue(const StringValue& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + StringValue* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.value_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.value_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_value().empty()) { - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(), - GetArenaForAllocation()); + _this->_impl_.value_.Set(from._internal_value(), + _this->GetArenaForAllocation()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue) } -inline void StringValue::SharedCtor() { -value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +inline void StringValue::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.value_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.value_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } StringValue::~StringValue() { // @@protoc_insertion_point(destructor:google.protobuf.StringValue) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void StringValue::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.value_.Destroy(); } -void StringValue::ArenaDtor(void* object) { - StringValue* _this = reinterpret_cast< StringValue* >(object); - (void)_this; -} -void StringValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void StringValue::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void StringValue::Clear() { @@ -1582,23 +1602,23 @@ void StringValue::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - value_.ClearToEmpty(); + _impl_.value_.ClearToEmpty(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* StringValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* StringValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // string value = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_value(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "google.protobuf.StringValue.value")); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.StringValue.value")); } else goto handle_unusual; continue; @@ -1642,7 +1662,7 @@ uint8_t* StringValue::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.StringValue) @@ -1664,32 +1684,28 @@ size_t StringValue::ByteSizeLong() const { this->_internal_value()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData StringValue::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, StringValue::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*StringValue::GetClassData() const { return &_class_data_; } -void StringValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<StringValue *>(to)->MergeFrom( - static_cast<const StringValue &>(from)); -} - -void StringValue::MergeFrom(const StringValue& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.StringValue) - GOOGLE_DCHECK_NE(&from, this); +void StringValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<StringValue*>(&to_msg); + auto& from = static_cast<const StringValue&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.StringValue) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (!from._internal_value().empty()) { - _internal_set_value(from._internal_value()); + _this->_internal_set_value(from._internal_value()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void StringValue::CopyFrom(const StringValue& from) { @@ -1709,14 +1725,13 @@ void StringValue::InternalSwap(StringValue* other) { auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &value_, lhs_arena, - &other->value_, rhs_arena + &_impl_.value_, lhs_arena, + &other->_impl_.value_, rhs_arena ); } ::PROTOBUF_NAMESPACE_ID::Metadata StringValue::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[7]); } @@ -1730,53 +1745,58 @@ class BytesValue::_Internal { BytesValue::BytesValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); - if (!is_message_owned) { - RegisterArenaDtor(arena); - } + SharedCtor(arena, is_message_owned); // @@protoc_insertion_point(arena_constructor:google.protobuf.BytesValue) } BytesValue::BytesValue(const BytesValue& from) : ::PROTOBUF_NAMESPACE_ID::Message() { + BytesValue* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{}}; + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.value_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + _impl_.value_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING if (!from._internal_value().empty()) { - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_value(), - GetArenaForAllocation()); + _this->_impl_.value_.Set(from._internal_value(), + _this->GetArenaForAllocation()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue) } -inline void BytesValue::SharedCtor() { -value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); -#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +inline void BytesValue::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.value_){} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.value_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.value_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING } BytesValue::~BytesValue() { // @@protoc_insertion_point(destructor:google.protobuf.BytesValue) - if (GetArenaForAllocation() != nullptr) return; + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } inline void BytesValue::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + _impl_.value_.Destroy(); } -void BytesValue::ArenaDtor(void* object) { - BytesValue* _this = reinterpret_cast< BytesValue* >(object); - (void)_this; -} -void BytesValue::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} void BytesValue::SetCachedSize(int size) const { - _cached_size_.Set(size); + _impl_._cached_size_.Set(size); } void BytesValue::Clear() { @@ -1785,21 +1805,21 @@ void BytesValue::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - value_.ClearToEmpty(); + _impl_.value_.ClearToEmpty(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } -const char* BytesValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +const char* BytesValue::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure while (!ctx->Done(&ptr)) { uint32_t tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { // bytes value = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { auto str = _internal_mutable_value(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); } else goto handle_unusual; @@ -1840,7 +1860,7 @@ uint8_t* BytesValue::_InternalSerialize( } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); } // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.BytesValue) @@ -1862,32 +1882,28 @@ size_t BytesValue::ByteSizeLong() const { this->_internal_value()); } - return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } const ::PROTOBUF_NAMESPACE_ID::Message::ClassData BytesValue::_class_data_ = { - ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, BytesValue::MergeImpl }; const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*BytesValue::GetClassData() const { return &_class_data_; } -void BytesValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, - const ::PROTOBUF_NAMESPACE_ID::Message& from) { - static_cast<BytesValue *>(to)->MergeFrom( - static_cast<const BytesValue &>(from)); -} - -void BytesValue::MergeFrom(const BytesValue& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BytesValue) - GOOGLE_DCHECK_NE(&from, this); +void BytesValue::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast<BytesValue*>(&to_msg); + auto& from = static_cast<const BytesValue&>(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BytesValue) + GOOGLE_DCHECK_NE(&from, _this); uint32_t cached_has_bits = 0; (void) cached_has_bits; if (!from._internal_value().empty()) { - _internal_set_value(from._internal_value()); + _this->_internal_set_value(from._internal_value()); } - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } void BytesValue::CopyFrom(const BytesValue& from) { @@ -1907,14 +1923,13 @@ void BytesValue::InternalSwap(BytesValue* other) { auto* rhs_arena = other->GetArenaForAllocation(); _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), - &value_, lhs_arena, - &other->value_, rhs_arena + &_impl_.value_, lhs_arena, + &other->_impl_.value_, rhs_arena ); } ::PROTOBUF_NAMESPACE_ID::Metadata BytesValue::GetMetadata() const { - return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( + return ::_pbi::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_getter, &descriptor_table_google_2fprotobuf_2fwrappers_2eproto_once, file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[8]); } @@ -1922,31 +1937,40 @@ void BytesValue::InternalSwap(BytesValue* other) { // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DoubleValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DoubleValue >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::DoubleValue* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::DoubleValue >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::DoubleValue >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FloatValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FloatValue >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::FloatValue* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::FloatValue >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::FloatValue >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Int64Value* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Int64Value >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Int64Value* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Int64Value >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Int64Value >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UInt64Value* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UInt64Value >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UInt64Value* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UInt64Value >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::UInt64Value >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Int32Value* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Int32Value >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Int32Value* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Int32Value >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Int32Value >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UInt32Value* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UInt32Value >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::UInt32Value* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::UInt32Value >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::UInt32Value >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::BoolValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::BoolValue >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::BoolValue* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::BoolValue >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::BoolValue >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::StringValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::StringValue >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::StringValue* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::StringValue >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::StringValue >(arena); } -template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::BytesValue* Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::BytesValue >(Arena* arena) { +template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::BytesValue* +Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::BytesValue >(Arena* arena) { return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::BytesValue >(arena); } PROTOBUF_NAMESPACE_CLOSE diff --git a/r5dev/thirdparty/protobuf/wrappers.pb.h b/r5dev/thirdparty/protobuf/wrappers.pb.h index 5ada2cfb..679f71d9 100644 --- a/r5dev/thirdparty/protobuf/wrappers.pb.h +++ b/r5dev/thirdparty/protobuf/wrappers.pb.h @@ -8,12 +8,12 @@ #include <string> #include <thirdparty/protobuf/port_def.inc> -#if PROTOBUF_VERSION < 3019000 +#if PROTOBUF_VERSION < 3021000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -23,7 +23,6 @@ #include <thirdparty/protobuf/io/coded_stream.h> #include <thirdparty/protobuf/arena.h> #include <thirdparty/protobuf/arenastring.h> -#include <thirdparty/protobuf/generated_message_table_driven.h> #include <thirdparty/protobuf/generated_message_util.h> #include <thirdparty/protobuf/metadata_lite.h> #include <thirdparty/protobuf/generated_message_reflection.h> @@ -42,14 +41,6 @@ PROTOBUF_NAMESPACE_CLOSE // Internal implementation detail -- do not use these members. struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fwrappers_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[9] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; static const uint32_t offsets[]; }; PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fwrappers_2eproto; @@ -102,7 +93,7 @@ class PROTOBUF_EXPORT DoubleValue final : public: inline DoubleValue() : DoubleValue(nullptr) {} ~DoubleValue() override; - explicit constexpr DoubleValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR DoubleValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); DoubleValue(const DoubleValue& from); DoubleValue(DoubleValue&& from) noexcept @@ -177,9 +168,11 @@ class PROTOBUF_EXPORT DoubleValue final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const DoubleValue& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const DoubleValue& from); + void MergeFrom( const DoubleValue& from) { + DoubleValue::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -188,10 +181,10 @@ class PROTOBUF_EXPORT DoubleValue final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(DoubleValue* other); @@ -204,9 +197,6 @@ class PROTOBUF_EXPORT DoubleValue final : protected: explicit DoubleValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -237,8 +227,11 @@ class PROTOBUF_EXPORT DoubleValue final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - double value_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + double value_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto; }; // ------------------------------------------------------------------- @@ -248,7 +241,7 @@ class PROTOBUF_EXPORT FloatValue final : public: inline FloatValue() : FloatValue(nullptr) {} ~FloatValue() override; - explicit constexpr FloatValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR FloatValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); FloatValue(const FloatValue& from); FloatValue(FloatValue&& from) noexcept @@ -323,9 +316,11 @@ class PROTOBUF_EXPORT FloatValue final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const FloatValue& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const FloatValue& from); + void MergeFrom( const FloatValue& from) { + FloatValue::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -334,10 +329,10 @@ class PROTOBUF_EXPORT FloatValue final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(FloatValue* other); @@ -350,9 +345,6 @@ class PROTOBUF_EXPORT FloatValue final : protected: explicit FloatValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -383,8 +375,11 @@ class PROTOBUF_EXPORT FloatValue final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - float value_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + float value_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto; }; // ------------------------------------------------------------------- @@ -394,7 +389,7 @@ class PROTOBUF_EXPORT Int64Value final : public: inline Int64Value() : Int64Value(nullptr) {} ~Int64Value() override; - explicit constexpr Int64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Int64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Int64Value(const Int64Value& from); Int64Value(Int64Value&& from) noexcept @@ -469,9 +464,11 @@ class PROTOBUF_EXPORT Int64Value final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Int64Value& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Int64Value& from); + void MergeFrom( const Int64Value& from) { + Int64Value::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -480,10 +477,10 @@ class PROTOBUF_EXPORT Int64Value final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Int64Value* other); @@ -496,9 +493,6 @@ class PROTOBUF_EXPORT Int64Value final : protected: explicit Int64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -529,8 +523,11 @@ class PROTOBUF_EXPORT Int64Value final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - int64_t value_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + int64_t value_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto; }; // ------------------------------------------------------------------- @@ -540,7 +537,7 @@ class PROTOBUF_EXPORT UInt64Value final : public: inline UInt64Value() : UInt64Value(nullptr) {} ~UInt64Value() override; - explicit constexpr UInt64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR UInt64Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); UInt64Value(const UInt64Value& from); UInt64Value(UInt64Value&& from) noexcept @@ -615,9 +612,11 @@ class PROTOBUF_EXPORT UInt64Value final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const UInt64Value& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const UInt64Value& from); + void MergeFrom( const UInt64Value& from) { + UInt64Value::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -626,10 +625,10 @@ class PROTOBUF_EXPORT UInt64Value final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(UInt64Value* other); @@ -642,9 +641,6 @@ class PROTOBUF_EXPORT UInt64Value final : protected: explicit UInt64Value(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -675,8 +671,11 @@ class PROTOBUF_EXPORT UInt64Value final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - uint64_t value_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + uint64_t value_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto; }; // ------------------------------------------------------------------- @@ -686,7 +685,7 @@ class PROTOBUF_EXPORT Int32Value final : public: inline Int32Value() : Int32Value(nullptr) {} ~Int32Value() override; - explicit constexpr Int32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR Int32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); Int32Value(const Int32Value& from); Int32Value(Int32Value&& from) noexcept @@ -761,9 +760,11 @@ class PROTOBUF_EXPORT Int32Value final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const Int32Value& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Int32Value& from); + void MergeFrom( const Int32Value& from) { + Int32Value::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -772,10 +773,10 @@ class PROTOBUF_EXPORT Int32Value final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(Int32Value* other); @@ -788,9 +789,6 @@ class PROTOBUF_EXPORT Int32Value final : protected: explicit Int32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -821,8 +819,11 @@ class PROTOBUF_EXPORT Int32Value final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - int32_t value_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + int32_t value_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto; }; // ------------------------------------------------------------------- @@ -832,7 +833,7 @@ class PROTOBUF_EXPORT UInt32Value final : public: inline UInt32Value() : UInt32Value(nullptr) {} ~UInt32Value() override; - explicit constexpr UInt32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR UInt32Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); UInt32Value(const UInt32Value& from); UInt32Value(UInt32Value&& from) noexcept @@ -907,9 +908,11 @@ class PROTOBUF_EXPORT UInt32Value final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const UInt32Value& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const UInt32Value& from); + void MergeFrom( const UInt32Value& from) { + UInt32Value::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -918,10 +921,10 @@ class PROTOBUF_EXPORT UInt32Value final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(UInt32Value* other); @@ -934,9 +937,6 @@ class PROTOBUF_EXPORT UInt32Value final : protected: explicit UInt32Value(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -967,8 +967,11 @@ class PROTOBUF_EXPORT UInt32Value final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - uint32_t value_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + uint32_t value_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto; }; // ------------------------------------------------------------------- @@ -978,7 +981,7 @@ class PROTOBUF_EXPORT BoolValue final : public: inline BoolValue() : BoolValue(nullptr) {} ~BoolValue() override; - explicit constexpr BoolValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR BoolValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); BoolValue(const BoolValue& from); BoolValue(BoolValue&& from) noexcept @@ -1053,9 +1056,11 @@ class PROTOBUF_EXPORT BoolValue final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const BoolValue& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const BoolValue& from); + void MergeFrom( const BoolValue& from) { + BoolValue::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1064,10 +1069,10 @@ class PROTOBUF_EXPORT BoolValue final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(BoolValue* other); @@ -1080,9 +1085,6 @@ class PROTOBUF_EXPORT BoolValue final : protected: explicit BoolValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -1113,8 +1115,11 @@ class PROTOBUF_EXPORT BoolValue final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - bool value_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + bool value_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto; }; // ------------------------------------------------------------------- @@ -1124,7 +1129,7 @@ class PROTOBUF_EXPORT StringValue final : public: inline StringValue() : StringValue(nullptr) {} ~StringValue() override; - explicit constexpr StringValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR StringValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); StringValue(const StringValue& from); StringValue(StringValue&& from) noexcept @@ -1199,9 +1204,11 @@ class PROTOBUF_EXPORT StringValue final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const StringValue& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const StringValue& from); + void MergeFrom( const StringValue& from) { + StringValue::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1210,10 +1217,10 @@ class PROTOBUF_EXPORT StringValue final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(StringValue* other); @@ -1226,9 +1233,6 @@ class PROTOBUF_EXPORT StringValue final : protected: explicit StringValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -1264,8 +1268,11 @@ class PROTOBUF_EXPORT StringValue final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr value_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr value_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto; }; // ------------------------------------------------------------------- @@ -1275,7 +1282,7 @@ class PROTOBUF_EXPORT BytesValue final : public: inline BytesValue() : BytesValue(nullptr) {} ~BytesValue() override; - explicit constexpr BytesValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit PROTOBUF_CONSTEXPR BytesValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); BytesValue(const BytesValue& from); BytesValue(BytesValue&& from) noexcept @@ -1350,9 +1357,11 @@ class PROTOBUF_EXPORT BytesValue final : using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; void CopyFrom(const BytesValue& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const BytesValue& from); + void MergeFrom( const BytesValue& from) { + BytesValue::MergeImpl(*this, from); + } private: - static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from); + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; @@ -1361,10 +1370,10 @@ class PROTOBUF_EXPORT BytesValue final : const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; uint8_t* _InternalSerialize( uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } private: - void SharedCtor(); + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(BytesValue* other); @@ -1377,9 +1386,6 @@ class PROTOBUF_EXPORT BytesValue final : protected: explicit BytesValue(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: static const ClassData _class_data_; @@ -1415,8 +1421,11 @@ class PROTOBUF_EXPORT BytesValue final : template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr value_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr value_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fwrappers_2eproto; }; // =================================================================== @@ -1432,10 +1441,10 @@ class PROTOBUF_EXPORT BytesValue final : // double value = 1; inline void DoubleValue::clear_value() { - value_ = 0; + _impl_.value_ = 0; } inline double DoubleValue::_internal_value() const { - return value_; + return _impl_.value_; } inline double DoubleValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.DoubleValue.value) @@ -1443,7 +1452,7 @@ inline double DoubleValue::value() const { } inline void DoubleValue::_internal_set_value(double value) { - value_ = value; + _impl_.value_ = value; } inline void DoubleValue::set_value(double value) { _internal_set_value(value); @@ -1456,10 +1465,10 @@ inline void DoubleValue::set_value(double value) { // float value = 1; inline void FloatValue::clear_value() { - value_ = 0; + _impl_.value_ = 0; } inline float FloatValue::_internal_value() const { - return value_; + return _impl_.value_; } inline float FloatValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.FloatValue.value) @@ -1467,7 +1476,7 @@ inline float FloatValue::value() const { } inline void FloatValue::_internal_set_value(float value) { - value_ = value; + _impl_.value_ = value; } inline void FloatValue::set_value(float value) { _internal_set_value(value); @@ -1480,10 +1489,10 @@ inline void FloatValue::set_value(float value) { // int64 value = 1; inline void Int64Value::clear_value() { - value_ = int64_t{0}; + _impl_.value_ = int64_t{0}; } inline int64_t Int64Value::_internal_value() const { - return value_; + return _impl_.value_; } inline int64_t Int64Value::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Int64Value.value) @@ -1491,7 +1500,7 @@ inline int64_t Int64Value::value() const { } inline void Int64Value::_internal_set_value(int64_t value) { - value_ = value; + _impl_.value_ = value; } inline void Int64Value::set_value(int64_t value) { _internal_set_value(value); @@ -1504,10 +1513,10 @@ inline void Int64Value::set_value(int64_t value) { // uint64 value = 1; inline void UInt64Value::clear_value() { - value_ = uint64_t{0u}; + _impl_.value_ = uint64_t{0u}; } inline uint64_t UInt64Value::_internal_value() const { - return value_; + return _impl_.value_; } inline uint64_t UInt64Value::value() const { // @@protoc_insertion_point(field_get:google.protobuf.UInt64Value.value) @@ -1515,7 +1524,7 @@ inline uint64_t UInt64Value::value() const { } inline void UInt64Value::_internal_set_value(uint64_t value) { - value_ = value; + _impl_.value_ = value; } inline void UInt64Value::set_value(uint64_t value) { _internal_set_value(value); @@ -1528,10 +1537,10 @@ inline void UInt64Value::set_value(uint64_t value) { // int32 value = 1; inline void Int32Value::clear_value() { - value_ = 0; + _impl_.value_ = 0; } inline int32_t Int32Value::_internal_value() const { - return value_; + return _impl_.value_; } inline int32_t Int32Value::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Int32Value.value) @@ -1539,7 +1548,7 @@ inline int32_t Int32Value::value() const { } inline void Int32Value::_internal_set_value(int32_t value) { - value_ = value; + _impl_.value_ = value; } inline void Int32Value::set_value(int32_t value) { _internal_set_value(value); @@ -1552,10 +1561,10 @@ inline void Int32Value::set_value(int32_t value) { // uint32 value = 1; inline void UInt32Value::clear_value() { - value_ = 0u; + _impl_.value_ = 0u; } inline uint32_t UInt32Value::_internal_value() const { - return value_; + return _impl_.value_; } inline uint32_t UInt32Value::value() const { // @@protoc_insertion_point(field_get:google.protobuf.UInt32Value.value) @@ -1563,7 +1572,7 @@ inline uint32_t UInt32Value::value() const { } inline void UInt32Value::_internal_set_value(uint32_t value) { - value_ = value; + _impl_.value_ = value; } inline void UInt32Value::set_value(uint32_t value) { _internal_set_value(value); @@ -1576,10 +1585,10 @@ inline void UInt32Value::set_value(uint32_t value) { // bool value = 1; inline void BoolValue::clear_value() { - value_ = false; + _impl_.value_ = false; } inline bool BoolValue::_internal_value() const { - return value_; + return _impl_.value_; } inline bool BoolValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.BoolValue.value) @@ -1587,7 +1596,7 @@ inline bool BoolValue::value() const { } inline void BoolValue::_internal_set_value(bool value) { - value_ = value; + _impl_.value_ = value; } inline void BoolValue::set_value(bool value) { _internal_set_value(value); @@ -1600,7 +1609,7 @@ inline void BoolValue::set_value(bool value) { // string value = 1; inline void StringValue::clear_value() { - value_.ClearToEmpty(); + _impl_.value_.ClearToEmpty(); } inline const std::string& StringValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.StringValue.value) @@ -1610,7 +1619,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void StringValue::set_value(ArgT0&& arg0, ArgT... args) { - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.value_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.StringValue.value) } inline std::string* StringValue::mutable_value() { @@ -1619,19 +1628,19 @@ inline std::string* StringValue::mutable_value() { return _s; } inline const std::string& StringValue::_internal_value() const { - return value_.Get(); + return _impl_.value_.Get(); } inline void StringValue::_internal_set_value(const std::string& value) { - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.value_.Set(value, GetArenaForAllocation()); } inline std::string* StringValue::_internal_mutable_value() { - return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.value_.Mutable(GetArenaForAllocation()); } inline std::string* StringValue::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.StringValue.value) - return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.value_.Release(); } inline void StringValue::set_allocated_value(std::string* value) { if (value != nullptr) { @@ -1639,11 +1648,10 @@ inline void StringValue::set_allocated_value(std::string* value) { } else { } - value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, - GetArenaForAllocation()); + _impl_.value_.SetAllocated(value, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.value_.IsDefault()) { + _impl_.value_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value) @@ -1655,7 +1663,7 @@ inline void StringValue::set_allocated_value(std::string* value) { // bytes value = 1; inline void BytesValue::clear_value() { - value_.ClearToEmpty(); + _impl_.value_.ClearToEmpty(); } inline const std::string& BytesValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value) @@ -1665,7 +1673,7 @@ template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void BytesValue::set_value(ArgT0&& arg0, ArgT... args) { - value_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + _impl_.value_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); // @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value) } inline std::string* BytesValue::mutable_value() { @@ -1674,19 +1682,19 @@ inline std::string* BytesValue::mutable_value() { return _s; } inline const std::string& BytesValue::_internal_value() const { - return value_.Get(); + return _impl_.value_.Get(); } inline void BytesValue::_internal_set_value(const std::string& value) { - value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation()); + _impl_.value_.Set(value, GetArenaForAllocation()); } inline std::string* BytesValue::_internal_mutable_value() { - return value_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); + return _impl_.value_.Mutable(GetArenaForAllocation()); } inline std::string* BytesValue::release_value() { // @@protoc_insertion_point(field_release:google.protobuf.BytesValue.value) - return value_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); + return _impl_.value_.Release(); } inline void BytesValue::set_allocated_value(std::string* value) { if (value != nullptr) { @@ -1694,11 +1702,10 @@ inline void BytesValue::set_allocated_value(std::string* value) { } else { } - value_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, - GetArenaForAllocation()); + _impl_.value_.SetAllocated(value, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (value_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) { - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation()); + if (_impl_.value_.IsDefault()) { + _impl_.value_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING // @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value) diff --git a/r5dev/vproj/libprotobuf.vcxproj b/r5dev/vproj/libprotobuf.vcxproj index b40ffff1..49f5837f 100644 --- a/r5dev/vproj/libprotobuf.vcxproj +++ b/r5dev/vproj/libprotobuf.vcxproj @@ -183,7 +183,6 @@ <ClCompile Include="..\thirdparty\protobuf\arenastring.cc" /> <ClCompile Include="..\thirdparty\protobuf\extension_set.cc" /> <ClCompile Include="..\thirdparty\protobuf\generated_enum_util.cc" /> - <ClCompile Include="..\thirdparty\protobuf\generated_message_table_driven_lite.cc" /> <ClCompile Include="..\thirdparty\protobuf\generated_message_tctable_lite.cc" /> <ClCompile Include="..\thirdparty\protobuf\generated_message_util.cc" /> <ClCompile Include="..\thirdparty\protobuf\implicit_weak_message.cc" /> diff --git a/r5dev/vproj/libprotobuf.vcxproj.filters b/r5dev/vproj/libprotobuf.vcxproj.filters index e65cb80d..5dc90c45 100644 --- a/r5dev/vproj/libprotobuf.vcxproj.filters +++ b/r5dev/vproj/libprotobuf.vcxproj.filters @@ -60,9 +60,6 @@ <ClCompile Include="..\thirdparty\protobuf\generated_enum_util.cc"> <Filter>source</Filter> </ClCompile> - <ClCompile Include="..\thirdparty\protobuf\generated_message_table_driven_lite.cc"> - <Filter>source</Filter> - </ClCompile> <ClCompile Include="..\thirdparty\protobuf\generated_message_tctable_lite.cc"> <Filter>source</Filter> </ClCompile>