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/struct.pb.cc | 559 ++++++++++++++++++++++++++++----------- 1 file changed, 402 insertions(+), 157 deletions(-) (limited to 'src/google/protobuf/struct.pb.cc') diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 998ea0e0..c609f879 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -59,14 +59,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() { Struct_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Struct_descriptor_, - Struct::default_instance_, + Struct::internal_default_instance(), Struct_offsets_, -1, -1, -1, sizeof(Struct), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_)); Struct_FieldsEntry_descriptor_ = Struct_descriptor_->nested_type(0); Value_descriptor_ = file->message_type(1); static const int Value_offsets_[7] = { @@ -81,7 +80,7 @@ void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() { Value_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Value_descriptor_, - Value::default_instance_, + Value::internal_default_instance(), Value_offsets_, -1, -1, @@ -89,8 +88,7 @@ void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() { Value_default_oneof_instance_, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _oneof_case_[0]), sizeof(Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_)); ListValue_descriptor_ = file->message_type(2); static const int ListValue_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, values_), @@ -98,21 +96,20 @@ void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() { ListValue_reflection_ = ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ListValue_descriptor_, - ListValue::default_instance_, + ListValue::internal_default_instance(), ListValue_offsets_, -1, -1, -1, sizeof(ListValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _is_default_instance_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_)); NullValue_descriptor_ = file->enum_type(0); } 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_2fstruct_2eproto); } @@ -121,7 +118,7 @@ void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Struct_descriptor_, &Struct::default_instance()); + Struct_descriptor_, Struct::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( Struct_FieldsEntry_descriptor_, ::google::protobuf::internal::MapEntry< @@ -132,30 +129,43 @@ void protobuf_RegisterTypes(const ::std::string&) { 0>::CreateDefaultInstance( Struct_FieldsEntry_descriptor_)); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Value_descriptor_, &Value::default_instance()); + Value_descriptor_, Value::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ListValue_descriptor_, &ListValue::default_instance()); + ListValue_descriptor_, ListValue::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto() { - delete Struct::default_instance_; delete Struct_reflection_; - delete Value::default_instance_; delete Value_default_oneof_instance_; delete Value_reflection_; - delete ListValue::default_instance_; delete ListValue_reflection_; } -void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::internal::GetEmptyString(); + Struct::default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Value::default_instance_.DefaultConstruct(); + Value_default_oneof_instance_ = new ValueOneofInstance(); + ListValue::default_instance_.DefaultConstruct(); + Struct::default_instance_.get_mutable()->InitAsDefaultInstance(); + Value::default_instance_.get_mutable()->InitAsDefaultInstance(); + ListValue::default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_once_); +void protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_once_, + &protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl); +} +void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\034google/protobuf/struct.proto\022\017google.p" "rotobuf\"\204\001\n\006Struct\0223\n\006fields\030\001 \003(\0132#.goo" @@ -171,21 +181,19 @@ void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() { "es\030\001 \003(\0132\026.google.protobuf.Value*\033\n\tNull" "Value\022\016\n\nNULL_VALUE\020\000B\201\001\n\023com.google.pro" "tobufB\013StructProtoP\001Z1github.com/golang/" - "protobuf/ptypes/struct;structpb\240\001\001\242\002\003GPB" + "protobuf/ptypes/struct;structpb\370\001\001\242\002\003GPB" "\252\002\036Google.Protobuf.WellKnownTypesb\006proto" "3", 641); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/struct.proto", &protobuf_RegisterTypes); - Struct::default_instance_ = new Struct(); - Value::default_instance_ = new Value(); - Value_default_oneof_instance_ = new ValueOneofInstance(); - ListValue::default_instance_ = new ListValue(); - Struct::default_instance_->InitAsDefaultInstance(); - Value::default_instance_->InitAsDefaultInstance(); - ListValue::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_once_); +void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_once_, + &protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto { StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto() { @@ -197,7 +205,7 @@ const ::google::protobuf::EnumDescriptor* NullValue_descriptor() { return NullValue_descriptor_; } bool NullValue_IsValid(int value) { - switch(value) { + switch (value) { case 0: return true; default: @@ -206,6 +214,16 @@ bool NullValue_IsValid(int value) { } +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 @@ -214,30 +232,39 @@ const int Struct::kFieldsFieldNumber; Struct::Struct() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Struct) } +Struct::Struct(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + fields_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Struct) +} void Struct::InitAsDefaultInstance() { - _is_default_instance_ = true; } Struct::Struct(const Struct& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Struct) } void Struct::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; fields_.SetAssignDescriptorCallback( protobuf_AssignDescriptorsOnce); fields_.SetEntryDescriptor( &::google::protobuf::Struct_FieldsEntry_descriptor_); + _cached_size_ = 0; } Struct::~Struct() { @@ -246,10 +273,19 @@ Struct::~Struct() { } void Struct::SharedDtor() { - if (this != default_instance_) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + } +void Struct::ArenaDtor(void* object) { + Struct* _this = reinterpret_cast< Struct* >(object); + (void)_this; +} +void Struct::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Struct::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -261,18 +297,14 @@ const ::google::protobuf::Descriptor* Struct::descriptor() { } const Struct& Struct::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + return *internal_default_instance(); } -Struct* Struct::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Struct::default_instance_; Struct* Struct::New(::google::protobuf::Arena* arena) const { - Struct* n = new Struct; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage(arena); } void Struct::Clear() { @@ -373,6 +405,9 @@ void Struct::SerializeWithCachedSizes( items[i]->first, items[i]->second)); ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 1, *entry, output); + if (entry->GetArena() != NULL) { + entry.release(); + } Utf8Check::Check(items[i]); } } else { @@ -384,6 +419,9 @@ void Struct::SerializeWithCachedSizes( it->first, it->second)); ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 1, *entry, output); + if (entry->GetArena() != NULL) { + entry.release(); + } Utf8Check::Check(&*it); } } @@ -431,6 +469,9 @@ void Struct::SerializeWithCachedSizes( InternalWriteMessageNoVirtualToArray( 1, *entry, deterministic, target); ; + if (entry->GetArena() != NULL) { + entry.release(); + } Utf8Check::Check(items[i]); } } else { @@ -444,6 +485,9 @@ void Struct::SerializeWithCachedSizes( InternalWriteMessageNoVirtualToArray( 1, *entry, deterministic, target); ; + if (entry->GetArena() != NULL) { + entry.release(); + } Utf8Check::Check(&*it); } } @@ -453,35 +497,41 @@ void Struct::SerializeWithCachedSizes( return target; } -int Struct::ByteSize() const { +size_t Struct::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Struct) - int total_size = 0; + size_t total_size = 0; // map fields = 1; - total_size += 1 * this->fields_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->fields_size()); { ::google::protobuf::scoped_ptr entry; for (::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_iterator it = this->fields().begin(); it != this->fields().end(); ++it) { + if (entry.get() != NULL && entry->GetArena() != NULL) { + entry.release(); + } entry.reset(fields_.NewEntryWrapper(it->first, it->second)); total_size += ::google::protobuf::internal::WireFormatLite:: MessageSizeNoVirtual(*entry); } + if (entry.get() != NULL && entry->GetArena() != NULL) { + entry.release(); + } } + 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 Struct::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Struct) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Struct* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Struct* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -489,15 +539,21 @@ void Struct::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Struct) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Struct::MergeFrom(const Struct& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Struct) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Struct::UnsafeMergeFrom(const Struct& from) { + GOOGLE_DCHECK(&from != this); fields_.MergeFrom(from.fields_); } @@ -512,7 +568,7 @@ void Struct::CopyFrom(const Struct& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Struct) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Struct::IsInitialized() const { @@ -522,6 +578,18 @@ bool Struct::IsInitialized() const { void Struct::Swap(Struct* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Struct temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Struct::UnsafeArenaSwap(Struct* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Struct::InternalSwap(Struct* other) { @@ -574,33 +642,43 @@ const int Value::kListValueFieldNumber; Value::Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Value) } +Value::Value(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.Value) +} void Value::InitAsDefaultInstance() { - _is_default_instance_ = true; Value_default_oneof_instance_->null_value_ = 0; Value_default_oneof_instance_->number_value_ = 0; Value_default_oneof_instance_->string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); Value_default_oneof_instance_->bool_value_ = false; - Value_default_oneof_instance_->struct_value_ = const_cast< ::google::protobuf::Struct*>(&::google::protobuf::Struct::default_instance()); - Value_default_oneof_instance_->list_value_ = const_cast< ::google::protobuf::ListValue*>(&::google::protobuf::ListValue::default_instance()); + Value_default_oneof_instance_->struct_value_ = const_cast< ::google::protobuf::Struct*>( + ::google::protobuf::Struct::internal_default_instance()); + Value_default_oneof_instance_->list_value_ = const_cast< ::google::protobuf::ListValue*>( + ::google::protobuf::ListValue::internal_default_instance()); } Value::Value(const Value& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.Value) } void Value::SharedCtor() { - _is_default_instance_ = false; - ::google::protobuf::internal::GetEmptyString(); - _cached_size_ = 0; clear_has_kind(); + _cached_size_ = 0; } Value::~Value() { @@ -609,13 +687,22 @@ Value::~Value() { } void Value::SharedDtor() { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; + } + if (has_kind()) { clear_kind(); } - if (this != default_instance_) { - } } +void Value::ArenaDtor(void* object) { + Value* _this = reinterpret_cast< Value* >(object); + (void)_this; +} +void Value::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void Value::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -627,23 +714,19 @@ const ::google::protobuf::Descriptor* Value::descriptor() { } const Value& Value::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + return *internal_default_instance(); } -Value* Value::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Value::default_instance_; Value* Value::New(::google::protobuf::Arena* arena) const { - Value* n = new Value; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage(arena); } void Value::clear_kind() { // @@protoc_insertion_point(one_of_clear_start:google.protobuf.Value) - switch(kind_case()) { + switch (kind_case()) { case kNullValue: { // No need to clear break; @@ -653,7 +736,8 @@ void Value::clear_kind() { break; } case kStringValue: { - kind_.string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + kind_.string_value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); break; } case kBoolValue: { @@ -661,11 +745,15 @@ void Value::clear_kind() { break; } case kStructValue: { - delete kind_.struct_value_; + if (GetArenaNoVirtual() == NULL) { + delete kind_.struct_value_; + } break; } case kListValue: { - delete kind_.list_value_; + if (GetArenaNoVirtual() == NULL) { + delete kind_.list_value_; + } break; } case KIND_NOT_SET: { @@ -702,14 +790,13 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(17)) goto parse_number_value; + goto after_list_value; break; } // optional double number_value = 2; case 2: { if (tag == 17) { - parse_number_value: clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -718,14 +805,13 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_string_value; + goto after_list_value; break; } // optional string string_value = 3; case 3: { if (tag == 26) { - parse_string_value: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_string_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -735,14 +821,13 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(32)) goto parse_bool_value; + goto after_list_value; break; } // optional bool bool_value = 4; case 4: { if (tag == 32) { - parse_bool_value: clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -751,14 +836,13 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(42)) goto parse_struct_value; + goto after_list_value; break; } // optional .google.protobuf.Struct struct_value = 5; case 5: { if (tag == 42) { - parse_struct_value: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_struct_value())); } else { @@ -777,6 +861,7 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } + after_list_value: if (input->ExpectAtEnd()) goto success; break; } @@ -895,9 +980,9 @@ void Value::SerializeWithCachedSizes( return target; } -int Value::ByteSize() const { +size_t Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Value) - int total_size = 0; + size_t total_size = 0; switch (kind_case()) { // optional .google.protobuf.NullValue null_value = 1; @@ -941,18 +1026,17 @@ int Value::ByteSize() const { break; } } + 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 Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const Value* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Value* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -960,15 +1044,21 @@ void Value::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Value) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void Value::MergeFrom(const Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void Value::UnsafeMergeFrom(const Value& from) { + GOOGLE_DCHECK(&from != this); switch (from.kind_case()) { case kNullValue: { set_null_value(from.null_value()); @@ -1011,7 +1101,7 @@ void Value::CopyFrom(const Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Value) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Value::IsInitialized() const { @@ -1021,6 +1111,18 @@ bool Value::IsInitialized() const { void Value::Swap(Value* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + Value temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void Value::UnsafeArenaSwap(Value* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void Value::InternalSwap(Value* other) { @@ -1054,14 +1156,14 @@ void Value::clear_null_value() { clear_has_kind(); } } - ::google::protobuf::NullValue Value::null_value() const { +::google::protobuf::NullValue Value::null_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.null_value) if (has_null_value()) { return static_cast< ::google::protobuf::NullValue >(kind_.null_value_); } return static_cast< ::google::protobuf::NullValue >(0); } - void Value::set_null_value(::google::protobuf::NullValue value) { +void Value::set_null_value(::google::protobuf::NullValue value) { if (!has_null_value()) { clear_kind(); set_has_null_value(); @@ -1083,14 +1185,14 @@ void Value::clear_number_value() { clear_has_kind(); } } - double Value::number_value() const { +double Value::number_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.number_value) if (has_number_value()) { return kind_.number_value_; } return 0; } - void Value::set_number_value(double value) { +void Value::set_number_value(double value) { if (!has_number_value()) { clear_kind(); set_has_number_value(); @@ -1108,77 +1210,105 @@ void Value::set_has_string_value() { } void Value::clear_string_value() { if (has_string_value()) { - kind_.string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + kind_.string_value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); clear_has_kind(); } } - const ::std::string& Value::string_value() const { +const ::std::string& Value::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.string_value) if (has_string_value()) { - return kind_.string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return kind_.string_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); } - void Value::set_string_value(const ::std::string& value) { - // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) +void Value::set_string_value(const ::std::string& value) { if (!has_string_value()) { clear_kind(); set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) } - void Value::set_string_value(const char* value) { +void Value::set_string_value(const char* value) { if (!has_string_value()) { clear_kind(); set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(value)); + kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(value), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_char:google.protobuf.Value.string_value) } - void Value::set_string_value(const char* value, size_t size) { +void Value::set_string_value(const char* value, + size_t size) { if (!has_string_value()) { clear_kind(); set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( - reinterpret_cast(value), size)); + kind_.string_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value) } - ::std::string* Value::mutable_string_value() { +::std::string* Value::mutable_string_value() { if (!has_string_value()) { clear_kind(); set_has_string_value(); kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } + return kind_.string_value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); // @@protoc_insertion_point(field_mutable:google.protobuf.Value.string_value) - return kind_.string_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - ::std::string* Value::release_string_value() { +::std::string* Value::release_string_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.string_value) if (has_string_value()) { clear_has_kind(); - return kind_.string_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return kind_.string_value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + GetArenaNoVirtual()); } else { return NULL; } } - void Value::set_allocated_string_value(::std::string* string_value) { +::std::string* Value::unsafe_arena_release_string_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.string_value) + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (has_string_value()) { + clear_has_kind(); + return kind_.string_value_.UnsafeArenaRelease( + &::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + } else { + return NULL; + } +} +void Value::set_allocated_string_value(::std::string* string_value) { if (!has_string_value()) { kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } clear_kind(); if (string_value != NULL) { set_has_string_value(); - kind_.string_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - string_value); + kind_.string_value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value, + GetArenaNoVirtual()); } // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value) } +void Value::unsafe_arena_set_allocated_string_value(::std::string* string_value) { + GOOGLE_DCHECK(GetArenaNoVirtual() != NULL); + if (!has_string_value()) { + kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + clear_kind(); + if (string_value) { + set_has_string_value(); + kind_.string_value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value, GetArenaNoVirtual()); + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value) +} // optional bool bool_value = 4; bool Value::has_bool_value() const { @@ -1193,14 +1323,14 @@ void Value::clear_bool_value() { clear_has_kind(); } } - bool Value::bool_value() const { +bool Value::bool_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.bool_value) if (has_bool_value()) { return kind_.bool_value_; } return false; } - void Value::set_bool_value(bool value) { +void Value::set_bool_value(bool value) { if (!has_bool_value()) { clear_kind(); set_has_bool_value(); @@ -1218,7 +1348,9 @@ void Value::set_has_struct_value() { } void Value::clear_struct_value() { if (has_struct_value()) { - delete kind_.struct_value_; + if (GetArenaNoVirtual() == NULL) { + delete kind_.struct_value_; + } clear_has_kind(); } } @@ -1232,13 +1364,51 @@ void Value::clear_struct_value() { if (!has_struct_value()) { clear_kind(); set_has_struct_value(); - kind_.struct_value_ = new ::google::protobuf::Struct; + kind_.struct_value_ = + ::google::protobuf::Arena::CreateMessage< ::google::protobuf::Struct >( + GetArenaNoVirtual()); } // @@protoc_insertion_point(field_mutable:google.protobuf.Value.struct_value) return kind_.struct_value_; } ::google::protobuf::Struct* Value::release_struct_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.struct_value) + if (has_struct_value()) { + clear_has_kind(); + if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::Struct* temp = new ::google::protobuf::Struct(*kind_.struct_value_); + kind_.struct_value_ = NULL; + return temp; + } else { + ::google::protobuf::Struct* temp = kind_.struct_value_; + kind_.struct_value_ = NULL; + return temp; + } + } else { + return NULL; + } +} +void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) { + clear_kind(); + if (struct_value) { + if (GetArenaNoVirtual() != NULL && + ::google::protobuf::Arena::GetArena(struct_value) == NULL) { + GetArenaNoVirtual()->Own(struct_value); + } else if (GetArenaNoVirtual() != + ::google::protobuf::Arena::GetArena(struct_value)) { + ::google::protobuf::Struct* new_struct_value = + ::google::protobuf::Arena::CreateMessage< ::google::protobuf::Struct >( + GetArenaNoVirtual()); + new_struct_value->CopyFrom(*struct_value); + struct_value = new_struct_value; + } + set_has_struct_value(); + kind_.struct_value_ = struct_value; + } + // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value) +} + ::google::protobuf::Struct* Value::unsafe_arena_release_struct_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.struct_value) if (has_struct_value()) { clear_has_kind(); ::google::protobuf::Struct* temp = kind_.struct_value_; @@ -1248,13 +1418,13 @@ void Value::clear_struct_value() { return NULL; } } -void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) { + void Value::unsafe_arena_set_allocated_struct_value(::google::protobuf::Struct* struct_value) { clear_kind(); if (struct_value) { set_has_struct_value(); kind_.struct_value_ = struct_value; } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value) } // optional .google.protobuf.ListValue list_value = 6; @@ -1266,7 +1436,9 @@ void Value::set_has_list_value() { } void Value::clear_list_value() { if (has_list_value()) { - delete kind_.list_value_; + if (GetArenaNoVirtual() == NULL) { + delete kind_.list_value_; + } clear_has_kind(); } } @@ -1280,13 +1452,51 @@ void Value::clear_list_value() { if (!has_list_value()) { clear_kind(); set_has_list_value(); - kind_.list_value_ = new ::google::protobuf::ListValue; + kind_.list_value_ = + ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ListValue >( + GetArenaNoVirtual()); } // @@protoc_insertion_point(field_mutable:google.protobuf.Value.list_value) return kind_.list_value_; } ::google::protobuf::ListValue* Value::release_list_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.list_value) + if (has_list_value()) { + clear_has_kind(); + if (GetArenaNoVirtual() != NULL) { + ::google::protobuf::ListValue* temp = new ::google::protobuf::ListValue(*kind_.list_value_); + kind_.list_value_ = NULL; + return temp; + } else { + ::google::protobuf::ListValue* temp = kind_.list_value_; + kind_.list_value_ = NULL; + return temp; + } + } else { + return NULL; + } +} +void Value::set_allocated_list_value(::google::protobuf::ListValue* list_value) { + clear_kind(); + if (list_value) { + if (GetArenaNoVirtual() != NULL && + ::google::protobuf::Arena::GetArena(list_value) == NULL) { + GetArenaNoVirtual()->Own(list_value); + } else if (GetArenaNoVirtual() != + ::google::protobuf::Arena::GetArena(list_value)) { + ::google::protobuf::ListValue* new_list_value = + ::google::protobuf::Arena::CreateMessage< ::google::protobuf::ListValue >( + GetArenaNoVirtual()); + new_list_value->CopyFrom(*list_value); + list_value = new_list_value; + } + set_has_list_value(); + kind_.list_value_ = list_value; + } + // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value) +} + ::google::protobuf::ListValue* Value::unsafe_arena_release_list_value() { + // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.list_value) if (has_list_value()) { clear_has_kind(); ::google::protobuf::ListValue* temp = kind_.list_value_; @@ -1296,13 +1506,13 @@ void Value::clear_list_value() { return NULL; } } -void Value::set_allocated_list_value(::google::protobuf::ListValue* list_value) { + void Value::unsafe_arena_set_allocated_list_value(::google::protobuf::ListValue* list_value) { clear_kind(); if (list_value) { set_has_list_value(); kind_.list_value_ = list_value; } - // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value) + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.list_value) } bool Value::has_kind() const { @@ -1324,24 +1534,34 @@ const int ListValue::kValuesFieldNumber; ListValue::ListValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ListValue) } +ListValue::ListValue(::google::protobuf::Arena* arena) + : ::google::protobuf::Message(), + _internal_metadata_(arena), + values_(arena) { +#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); +#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:google.protobuf.ListValue) +} void ListValue::InitAsDefaultInstance() { - _is_default_instance_ = true; } ListValue::ListValue(const ListValue& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); // @@protoc_insertion_point(copy_constructor:google.protobuf.ListValue) } void ListValue::SharedCtor() { - _is_default_instance_ = false; _cached_size_ = 0; } @@ -1351,10 +1571,19 @@ ListValue::~ListValue() { } void ListValue::SharedDtor() { - if (this != default_instance_) { + ::google::protobuf::Arena* arena = GetArenaNoVirtual(); + if (arena != NULL) { + return; } + } +void ListValue::ArenaDtor(void* object) { + ListValue* _this = reinterpret_cast< ListValue* >(object); + (void)_this; +} +void ListValue::RegisterArenaDtor(::google::protobuf::Arena* arena) { +} void ListValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -1366,18 +1595,14 @@ const ::google::protobuf::Descriptor* ListValue::descriptor() { } const ListValue& ListValue::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); - return *default_instance_; + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + return *internal_default_instance(); } -ListValue* ListValue::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ListValue::default_instance_; ListValue* ListValue::New(::google::protobuf::Arena* arena) const { - ListValue* n = new ListValue; - if (arena != NULL) { - arena->Own(n); - } - return n; + return ::google::protobuf::Arena::CreateMessage(arena); } void ListValue::Clear() { @@ -1459,30 +1684,32 @@ void ListValue::SerializeWithCachedSizes( return target; } -int ListValue::ByteSize() const { +size_t ListValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ListValue) - int total_size = 0; + size_t total_size = 0; // repeated .google.protobuf.Value values = 1; - total_size += 1 * this->values_size(); - for (int i = 0; i < this->values_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->values(i)); + { + unsigned int count = this->values_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->values(i)); + } } + 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 ListValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ListValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); - } - const ListValue* source = + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ListValue* source = ::google::protobuf::internal::DynamicCastToGenerated( &from); if (source == NULL) { @@ -1490,15 +1717,21 @@ void ListValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ListValue) - MergeFrom(*source); + UnsafeMergeFrom(*source); } } void ListValue::MergeFrom(const ListValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ListValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) { - ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__); + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} + +void ListValue::UnsafeMergeFrom(const ListValue& from) { + GOOGLE_DCHECK(&from != this); values_.MergeFrom(from.values_); } @@ -1513,7 +1746,7 @@ void ListValue::CopyFrom(const ListValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ListValue) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ListValue::IsInitialized() const { @@ -1523,6 +1756,18 @@ bool ListValue::IsInitialized() const { void ListValue::Swap(ListValue* other) { if (other == this) return; + if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { + InternalSwap(other); + } else { + ListValue temp; + temp.UnsafeMergeFrom(*this); + CopyFrom(*other); + other->CopyFrom(temp); + } +} +void ListValue::UnsafeArenaSwap(ListValue* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual()); InternalSwap(other); } void ListValue::InternalSwap(ListValue* other) { -- cgit v1.2.3