From cc8ca5b6a5478b40546d4206392eb1471454460d Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Mon, 19 Sep 2016 13:45:07 -0700 Subject: Integrate internal changes --- src/google/protobuf/duration.pb.cc | 141 +++++++++++++++++++++++++------------ 1 file changed, 96 insertions(+), 45 deletions(-) (limited to 'src/google/protobuf/duration.pb.cc') diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index 884f6ccb..0e1be63c 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -44,20 +44,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto() { Duration_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Duration_descriptor_, - Duration::default_instance_, + Duration::internal_default_instance(), Duration_offsets_, -1, -1, -1, sizeof(Duration), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_)); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto); } @@ -66,37 +65,48 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Duration_descriptor_, &Duration::default_instance()); + Duration_descriptor_, Duration::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto() { - delete Duration::default_instance_; delete Duration_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + Duration::default_instance_.DefaultConstruct(); + Duration::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\036google/protobuf/duration.proto\022\017google" ".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r" "\n\005nanos\030\002 \001(\005B|\n\023com.google.protobufB\rDu" "rationProtoP\001Z*github.com/golang/protobu" - "f/ptypes/duration\240\001\001\242\002\003GPB\252\002\036Google.Prot" + "f/ptypes/duration\370\001\001\242\002\003GPB\252\002\036Google.Prot" "obuf.WellKnownTypesb\006proto3", 227); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/duration.proto", &protobuf_RegisterTypes); - Duration::default_instance_ = new Duration(); - Duration::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto() { @@ -104,6 +114,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fduration_2eproto_; +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -113,27 +133,36 @@ const int Duration::kNanosFieldNumber; Duration::Duration() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Duration) } +Duration::Duration(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Duration) +} void Duration::InitAsDefaultInstance() { - _is_default_instance_ = true; } Duration::Duration(const Duration& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Duration) } void Duration::SharedCtor() { - _is_default_instance_ = false; + ::memset(&seconds_, 0, reinterpret_cast(&nanos_) - + reinterpret_cast(&seconds_) + sizeof(nanos_)); _cached_size_ = 0; - seconds_ = GOOGLE_LONGLONG(0); - nanos_ = 0; } Duration::~Duration() { @@ -142,10 +171,19 @@ Duration::~Duration() { } void Duration::SharedDtor() { - if (this != default_instance_) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + } +void Duration::ArenaDtor(void* object) { + Duration* _this = reinterpret_cast< Duration* >(object); + (void)_this; +} +void Duration::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Duration::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -157,18 +195,14 @@ const ::google::protobuf::Descriptor* Duration::descriptor() { } const Duration& Duration::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); + return *internal_default_instance(); } -Duration* Duration::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Duration::default_instance_; Duration* Duration::New(::google::protobuf::Arena* arena) const { - Duration* n = new Duration; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage(arena); } void Duration::Clear() { @@ -209,10 +243,10 @@ bool Duration::MergePartialFromCodedStream( // optional int64 seconds = 1; case 1: { if (tag == 8) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( input, &seconds_))); - } else { goto handle_unusual; } @@ -224,10 +258,10 @@ bool Duration::MergePartialFromCodedStream( case 2: { if (tag == 16) { parse_nanos: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &nanos_))); - } else { goto handle_unusual; } @@ -290,9 +324,9 @@ void Duration::SerializeWithCachedSizes( return target; } -int Duration::ByteSize() const { +size_t Duration::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Duration) - int total_size = 0; + size_t total_size = 0; // optional int64 seconds = 1; if (this->seconds() != 0) { @@ -308,18 +342,17 @@ int Duration::ByteSize() const { this->nanos()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Duration::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Duration) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Duration* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Duration* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -327,15 +360,21 @@ void Duration::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Duration) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Duration::MergeFrom(const Duration& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Duration) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Duration::UnsafeMergeFrom(const Duration& from) { + GOOGLE_DCHECK(&from != this); if (from.seconds() != 0) { set_seconds(from.seconds()); } @@ -355,7 +394,7 @@ void Duration::CopyFrom(const Duration& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Duration) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Duration::IsInitialized() const { @@ -365,6 +404,18 @@ bool Duration::IsInitialized() const { void Duration::Swap(Duration* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Duration temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Duration::UnsafeArenaSwap(Duration* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Duration::InternalSwap(Duration* other) { @@ -389,11 +440,11 @@ void Duration::InternalSwap(Duration* other) { void Duration::clear_seconds() { seconds_ = GOOGLE_LONGLONG(0); } - ::google::protobuf::int64 Duration::seconds() const { +::google::protobuf::int64 Duration::seconds() const { // @@protoc_insertion_point(field_get:google.protobuf.Duration.seconds) return seconds_; } - void Duration::set_seconds(::google::protobuf::int64 value) { +void Duration::set_seconds(::google::protobuf::int64 value) { seconds_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds) @@ -403,11 +454,11 @@ void Duration::clear_seconds() { void Duration::clear_nanos() { nanos_ = 0; } - ::google::protobuf::int32 Duration::nanos() const { +::google::protobuf::int32 Duration::nanos() const { // @@protoc_insertion_point(field_get:google.protobuf.Duration.nanos) return nanos_; } - void Duration::set_nanos(::google::protobuf::int32 value) { +void Duration::set_nanos(::google::protobuf::int32 value) { nanos_ = value; // @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos) -- cgit v1.2.3